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
|
---|---|---|---|---|
programs/oeis/127/A127981.asm
|
neoneye/loda
| 22 |
171472
|
; A127981: a(n) = (n + 1/3)*2^(n-1) - 1/2 + (-1)^(n-1)*(1/6).
; 1,4,13,34,85,202,469,1066,2389,5290,11605,25258,54613,117418,251221,535210,1135957,2402986,5068117,10660522,22369621,46836394,97867093,204122794,425022805,883600042,1834308949,3802835626,7874106709,16285084330,33643910485,69435304618,143165576533,294921087658,607022044501,1248403827370,2565527131477,5268493216426,10811864339797,22173484493482,45446480614741,93091984485034,190582015481173,389960123984554,797512434013525,1630209240115882,3330787224409429,6802311937174186,13886098851059029,28335147655539370,57796195217921365,117844190249527978,240191980126426453,489391159507593898,996796717524669781,2029622232068303530,4131302058174534997,8406719304424925866,17101668985001563477,34779798722306550442,70712518949219947861,143730880907653589674,292073447833734567253,593370267704323910314,1205187279482357372245,2447268047112133847722,4968323070519105901909,10084220093627888216746,20463588092435129259349,41517471995228964170410,84215535611175339644245,170792254463785501895338,346306875410440649004373,702058483786620588436138,1423006433504719757727061,2883791798872396677163690,5843141461470707677746517,11837398650393244002331306,23977028755690145298339157,48558520421187605184031402,98325966661989839542768981,199069784963208937434950314,402975273204876391568725333,815621952966669816535100074,1650586719047173699865498965,3339859064322015533321595562,6757089381099367333824386389,13668921267109407202011163306,27647327544040159472747107669,55913625107723009082943777450,113065190254731398440786679125,228606260588033557431371606698,462164281333208635962339710293,934232082980700314123872414378,1888271206589966712646130816341,3816156494437065594089033607850,7711541151388395525771611166037,15581538627805319726730310232746,31479989905667696803834796266837,63593805111449508308417944136362
mov $1,$0
mul $0,3
add $0,4
mov $2,2
pow $2,$1
mul $0,$2
div $0,3
|
archive/agda-2/Oscar/Data/AList/properties.agda
|
m0davis/oscar
| 0 |
3
|
<filename>archive/agda-2/Oscar/Data/AList/properties.agda
module Oscar.Data.AList.properties {𝔣} (FunctionName : Set 𝔣) where
open import Oscar.Category.Category
open import Oscar.Category.Functor
open import Oscar.Category.Morphism
open import Oscar.Category.Semigroupoid
open import Oscar.Category.Semifunctor
open import Oscar.Category.Setoid
open import Oscar.Class.ThickAndThin
open import Oscar.Data.AList FunctionName
open import Oscar.Data.Equality
open import Oscar.Data.Equality.properties
open import Oscar.Data.Fin
open import Oscar.Data.Fin.ThickAndThin
open import Oscar.Data.Maybe
open import Oscar.Data.Nat
open import Oscar.Data.Product
open import Oscar.Data.Term FunctionName
import Oscar.Data.Term.internal.SubstituteAndSubstitution FunctionName as S
open import Oscar.Data.Term.ThickAndThin FunctionName
open import Oscar.Function
module 𝔊₂ = Category S.𝔾₁
module 𝔉◃ = Functor S.𝔽◂
𝕞₁ = ⇧ AList
module 𝔐₁ = Morphism 𝕞₁
private
_∙_ : ∀ {m n} → m 𝔐₁.↦ n → ∀ {l} → l 𝔐₁.↦ m → l 𝔐₁.↦ n
ρ ∙ anil = ρ
ρ ∙ (σ asnoc t' / x) = (ρ ∙ σ) asnoc t' / x
∙-associativity : ∀ {l m} (ρ : l 𝔐₁.↦ m) {n} (σ : n 𝔐₁.↦ _) {o} (τ : o 𝔐₁.↦ _) → (ρ ∙ σ) ∙ τ ≡ ρ ∙ (σ ∙ τ)
∙-associativity ρ σ anil = refl
∙-associativity ρ σ (τ asnoc t / x) = cong (λ s → s asnoc t / x) (∙-associativity ρ σ τ)
instance
IsSemigroupoid𝕞₁∙ : IsSemigroupoid 𝕞₁ _∙_
IsSemigroupoid.extensionality IsSemigroupoid𝕞₁∙ f₁≡f₂ g₁≡g₂ = cong₂ (λ ‵ → _∙_ ‵) g₁≡g₂ f₁≡f₂
IsSemigroupoid.associativity IsSemigroupoid𝕞₁∙ f g h = ∙-associativity h g f
𝕘₁ : Semigroupoid _ _ _
𝕘₁ = 𝕞₁ , _∙_
private
ε : ∀ {n} → n 𝔐₁.↦ n
ε = anil
∙-left-identity : ∀ {m n} (σ : AList m n) → ε ∙ σ ≡ σ
∙-left-identity anil = refl
∙-left-identity (σ asnoc t' / x) = cong (λ σ → σ asnoc t' / x) (∙-left-identity σ)
instance
IsCategory𝕘₁ε : IsCategory 𝕘₁ ε
IsCategory.left-identity IsCategory𝕘₁ε = ∙-left-identity
IsCategory.right-identity IsCategory𝕘₁ε _ = refl
𝔾₁ : Category _ _ _
𝔾₁ = 𝕘₁ , ε
𝕞₂ = 𝔊₂.𝔐
module 𝔐₂ = Morphism 𝕞₂
private
sub : ∀ {m n} → m 𝔐₁.↦ n → m 𝔊₂.↦ n
sub anil = i
sub (σ asnoc t' / x) = sub σ 𝔊₂.∙ (t' for x)
fact1 : ∀ {l m n} (ρ : AList m n) (σ : AList l m) → sub (ρ ∙ σ) ≡̇ (sub ρ 𝔊₂.∙ sub σ)
fact1 ρ anil v = refl
fact1 {suc l} {m} {n} r (s asnoc t' / x) v = trans hyp-on-terms ◃-assoc
where
t = (t' for x) v
hyp-on-terms = 𝔉◃.extensionality (fact1 r s) t
◃-assoc = 𝔉◃.distributivity (sub s) (sub r) t
𝕘₁,₂ : Semigroupoids _ _ _ _ _ _
𝕘₁,₂ = 𝕘₁ , 𝔊₂.semigroupoid
instance
IsSemifunctorSub∙◇ : IsSemifunctor 𝕘₁,₂ sub
IsSemifunctor.extensionality IsSemifunctorSub∙◇ refl _ = refl
IsSemifunctor.distributivity IsSemifunctorSub∙◇ f g x = fact1 g f x
semifunctorSub∙◇ : Semifunctor _ _ _ _ _ _
semifunctorSub∙◇ = 𝕘₁,₂ , sub
instance
IsFunctor𝔽 : IsFunctor (𝔾₁ , S.𝔾₁) sub
IsFunctor.identity IsFunctor𝔽 _ _ = refl
𝔽 : Functor _ _ _ _ _ _
𝔽 = (𝔾₁ , S.𝔾₁) , sub
-- fact1 : ∀ {l m n} (ρ : AList m n) (σ : AList l m) → sub (ρ ∙ σ) ≡̇ (sub ρ ◇ sub σ)
-- fact1 ρ anil v = refl
-- fact1 {suc l} {m} {n} r (s asnoc t' / x) v = trans hyp-on-terms ◃-assoc
-- where
-- t = (t' for x) v
-- hyp-on-terms = ◃-extensionality (fact1 r s) t
-- ◃-assoc = ◃-associativity (sub s) (sub r) t
-- _∃asnoc_/_ : ∀ {m} (a : ∃ (AList m)) (t' : Term m) (x : Fin (suc m))
-- → ∃ (AList (suc m))
-- (n , σ) ∃asnoc t' / x = n , σ asnoc t' / x
-- flexFlex : ∀ {m} (x y : Fin m) → ∃ (AList m)
-- flexFlex {suc m} x y with check x y
-- ... | just y' = m , anil asnoc i y' / x
-- ... | nothing = suc m , anil
-- flexFlex {zero} () _
-- flexRigid : ∀ {m} (x : Fin m) (t : Term m) → Maybe (∃(AList m))
-- flexRigid {suc m} x t with check x t
-- ... | just t' = just (m , anil asnoc t' / x)
-- ... | nothing = nothing
-- flexRigid {zero} () _
|
ProcessingParser.g4
|
sayakaakioka/antlr-v4-grammar-processing
| 0 |
3213
|
<filename>ProcessingParser.g4
/*
Copyright 2022 <NAME>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
parser grammar ProcessingParser;
options {
tokenVocab = ProcessingLexer;
}
compilationUnit:
importDeclaration* (
varDecl
| funcDecl
| statement
| classDecl
)+ EOF;
importDeclaration: IMPORT qualifiedName ('.' '*')? ';';
qualifiedName: IDENTIFIER ('.' IDENTIFIER)*;
varDecl:
modifier* (classType | primitiveType) ('[' ']')* variableDeclarators ';';
modifier: PUBLIC | PRIVATE | FINAL;
variableDeclarators:
variableDeclarator (',' variableDeclarator)*;
variableDeclarator:
variableDeclaratorId ('=' variableInitializer)?;
variableDeclaratorId: IDENTIFIER ('[' ']')*;
variableInitializer: arrayInitializer | expression;
arrayInitializer:
'{' (variableInitializer (',' variableInitializer)* (',')?)? '}';
funcDecl:
modifier* typeOrVoid IDENTIFIER formalParameters ('[' ']')* (
THROWS qualifiedNameList
)? funcBody;
typeOrVoid: (classType | primitiveType) ('[' ']')* | VOID;
primitiveType:
BOOLEAN
| BYTE
| CHAR
| COLOR
| DOUBLE
| FLOAT
| INT
| LONG;
classType:
IDENTIFIER typeArguments? ('.' IDENTIFIER typeArguments?)*;
typeArguments: '<' typeArgument (',' typeArgument)* '>';
typeArgument: (classType | primitiveType) ('[' ']')*;
formalParameters:
'(' (
receiverParameter?
| receiverParameter (',' formalParameterList)?
| formalParameterList?
) ')';
receiverParameter: (classType | primitiveType) ('[' ']')* (
IDENTIFIER '.'
)* THIS;
formalParameterList: formalParameter (',' formalParameter)*;
formalParameter:
modifier* (classType | primitiveType) ('[' ']')* variableDeclaratorId;
qualifiedNameList: qualifiedName (',' qualifiedName)*;
funcBody: block | ';';
block: '{' blockStatement* '}';
blockStatement: varDecl | statement;
classDecl:
classModifier* CLASS IDENTIFIER typeParameters? (
EXTENDS (classType | primitiveType) ('[' ']')*
)? (IMPLEMENTS typeList)? classBody;
classModifier: modifier | ABSTRACT;
typeParameters: '<' typeParameter (',' typeParameter)* '>';
typeParameter: IDENTIFIER (EXTENDS typeBound)?;
typeBound: (classType | primitiveType) ('[' ']')* (
'&' (classType | primitiveType) ('[' ']')*
)*;
typeList: (classType | primitiveType) ('[' ']')* (
',' (classType | primitiveType) ('[' ']')*
)*;
classBody: '{' classBodyDeclaration* '}';
classBodyDeclaration:
';'
| STATIC? block
| modifier* memberDeclaration
| abstractMethodDeclaration;
abstractMethodDeclaration:
classModifier* modifier* typeOrVoid IDENTIFIER formalParameters (
'[' ']'
)* (THROWS qualifiedNameList)?;
memberDeclaration:
funcDecl
| genericMethodDeclaration
| fieldDeclaration
| constructorDeclaration
| genericConstructorDeclaration;
genericMethodDeclaration: typeParameters funcDecl;
fieldDeclaration: varDecl;
constructorDeclaration:
IDENTIFIER formalParameters (THROWS qualifiedNameList)? constructorBody = block;
genericConstructorDeclaration:
typeParameters constructorDeclaration;
statement:
blockLabel = block
| IF parExpression statement (ELSE statement)?
| FOR '(' forControl ')' statement
| WHILE parExpression statement
| DO statement WHILE parExpression ';'
| TRY block catchClause+
| SWITCH parExpression '{' switchBlockStatementGroup* switchLabel* '}'
| RETURN expression? ';'
| THROW expression ';'
| BREAK ';'
| CONTINUE ';'
| SEMI
| statementExpression = expression ';'
| identifierLabel = IDENTIFIER ':' statement;
parExpression: '(' expression ')';
forControl:
forInit? ';' expression? ';' forUpdate = expressionList?
| enhancedForControl;
forInit:
modifier* (classType | primitiveType) ('[' ']')* variableDeclarators
| expressionList;
expressionList: expression (',' expression)*;
enhancedForControl:
modifier* (classType | primitiveType) ('[' ']')* variableDeclaratorId ':' expression;
catchClause: CATCH '(' modifier* catchType IDENTIFIER ')' block;
catchType: qualifiedName ('|' qualifiedName)*;
switchBlockStatementGroup: switchLabel+ blockStatement+;
switchLabel:
CASE (
constantExpression = expression
| enumConstantName = IDENTIFIER
| (classType | primitiveType) ('[' ']')* varName = IDENTIFIER
) ':'
| DEFAULT ':';
expression:
primary
| expression bop = '.' (
IDENTIFIER
| funcCall
| THIS
| NEW nonWildcardTypeArguments? innerCreator
| SUPER superSuffix
| explicitGenericInvocation
)
| expression '[' expression ']'
| funcCall
| NEW creator
| '(' (classType | primitiveType) ('[' ']')* (
'&' (classType | primitiveType) ('[' ']')*
)* ')' expression
| expression postfix = ('++' | '--')
| prefix = ('+' | '-' | '++' | '--') expression
| '!' expression
| expression bop = ('*' | '/' | '%') expression
| expression bop = ('+' | '-') expression
| expression ('<' '<' | '>' '>' '>' | '>' '>') expression
| expression bop = ('<=' | '>=' | '>' | '<') expression
| expression bop = INSTANCEOF (
(classType | primitiveType) ('[' ']')*
)
| expression bop = ('==' | '!=') expression
| expression bop = '&' expression
| expression bop = '|' expression
| expression bop = '&&' expression
| expression bop = '||' expression
| <assoc = right> expression bop = '?' expression ':' expression
| <assoc = right> expression bop = (
'='
| '+='
| '-='
| '*='
| '/='
) expression;
primary:
'(' expression ')'
| THIS
| SUPER
| literal
| IDENTIFIER
| typeOrVoid '.' CLASS
| nonWildcardTypeArguments (
explicitGenericInvocationSuffix
| THIS arguments
);
literal:
integerLiteral
| floatLiteral
| CHAR_LITERAL
| STRING_LITERAL
| BOOL_LITERAL
| COLOR_LITERAL
| NULL_LITERAL;
integerLiteral: DECIMAL_LITERAL;
floatLiteral: FLOAT_LITERAL;
nonWildcardTypeArguments: '<' typeList '>';
superSuffix:
arguments
| '.' typeArguments? IDENTIFIER arguments?;
explicitGenericInvocationSuffix:
SUPER superSuffix
| IDENTIFIER arguments;
arguments: '(' expressionList? ')';
explicitGenericInvocation:
nonWildcardTypeArguments explicitGenericInvocationSuffix;
innerCreator:
IDENTIFIER nonWildcardTypeArgumentsOrDiamond? classCreatorRest;
nonWildcardTypeArgumentsOrDiamond:
'<' '>'
| nonWildcardTypeArguments;
funcCall:
IDENTIFIER '(' expressionList? ')'
| THIS '(' expressionList? ')'
| SUPER '(' expressionList? ')'
| BOOLEAN '(' expressionList? ')'
| BYTE '(' expressionList? ')'
| CHAR '(' expressionList? ')'
| FLOAT '(' expressionList? ')'
| INT '(' expressionList? ')'
| COLOR '(' expressionList? ')';
creator:
nonWildcardTypeArguments createdName classCreatorRest
| createdName (arrayCreatorRest | classCreatorRest);
createdName:
IDENTIFIER typeArgumentsOrDiamond? (
'.' IDENTIFIER typeArgumentsOrDiamond?
)*
| primitiveType;
typeArgumentsOrDiamond: '<' '>' | typeArguments;
arrayCreatorRest:
'[' (
']' ('[' ']')* arrayInitializer
| expression ']' ('[' expression ']')* ('[' ']')*
);
classCreatorRest: arguments classBody?;
|
model-sets/2021-05-06-10-28-11-watform/ehealth_ctl.als
|
WatForm/catalyst
| 0 |
2594
|
<gh_stars>0
/* ehealth_ctl.als
* Author: <NAME> <<EMAIL>>
* Date: September 28, 2019
*
* Notes:
*
* This model is an Alloy port of the original TLA+ model created by
* Prof. <NAME> at York University (Canada) and used by him in
* teaching EECS 4312, Software Engineering Requirements.
*/
open ctlfc_path[State]
sig Patient, Medication {}
sig State {
patients: set Patient,
medications: set Medication,
interactions: Medication set -> set Medication,
prescriptions: Patient lone -> set Medication,
in_patient: lone Patient,
in_medication1: lone Medication,
in_medication2: lone Medication
}
pred pre_add_patient [s: State] {
!(s.in_patient in s.patients)
}
pred post_add_patient[s, s': State] {
s'.patients = s.patients + s.in_patient
s'.medications = s.medications
s'.interactions = s.interactions
s'.prescriptions = s.prescriptions
}
pred add_patient[s, s': State] {
pre_add_patient[s]
post_add_patient[s, s']
}
pred pre_add_medication[s: State] {
!(s.in_medication1 in s.medications)
}
pred post_add_medication[s, s': State] {
s'.medications = s.medications + s.in_medication1
s'.patients = s.patients
s'.interactions = s.interactions
s'.prescriptions = s.prescriptions
}
pred add_medication[s, s': State] {
pre_add_medication[s]
post_add_medication[s, s']
}
pred pre_add_interaction[s: State] {
s.in_medication1 in s.medications
s.in_medication2 in s.medications
s.in_medication1 != s.in_medication2
!(s.in_medication2 in s.interactions[s.in_medication1])
all p: s.patients |
!((p->s.in_medication1 in s.prescriptions) and
(p->s.in_medication2 in s.prescriptions))
}
pred post_add_interaction[s, s': State] {
s'.interactions = s.interactions + { s.in_medication1->s.in_medication2 +
s.in_medication2->s.in_medication1 }
s'.patients = s.patients
s'.medications = s.medications
s'.prescriptions = s.prescriptions
}
pred add_interaction[s, s': State] {
pre_add_interaction[s]
post_add_interaction[s, s']
}
pred pre_add_prescription[s: State] {
s.in_patient in s.patients
s.in_medication1 in s.medications
!(s.in_medication1 in s.prescriptions[s.in_patient])
all m0: s.prescriptions[s.in_patient] | !(s.in_medication1 in s.interactions[m0] or
m0 in s.interactions[s.in_medication1])
}
pred post_add_prescription[s, s': State] {
s'.prescriptions = s.prescriptions + s.in_patient->s.in_medication1
s'.patients = s.patients
s'.medications = s.medications
s'.interactions = s.interactions
}
pred add_prescription[s, s': State] {
pre_add_prescription[s]
post_add_prescription[s, s']
}
pred pre_remove_interaction[s: State] {
s.in_medication1 in s.medications
s.in_medication2 in s.medications
s.in_medication1->s.in_medication2 in s.interactions
}
pred post_remove_interaction[s, s': State] {
s'.interactions = s.interactions - { s.in_medication1->s.in_medication2 +
s.in_medication2->s.in_medication1 }
s'.patients = s.patients
s'.medications = s.medications
s'.prescriptions = s.prescriptions
}
pred remove_interaction[s, s': State] {
pre_remove_interaction[s]
post_remove_interaction[s, s']
}
pred pre_remove_prescription[s: State] {
s.in_patient in s.patients
s.in_medication1 in s.medications
s.in_patient->s.in_medication1 in s.prescriptions
}
pred post_remove_prescription[s, s': State] {
s'.prescriptions = s.prescriptions - s.in_patient->s.in_medication1
s'.patients = s.patients
s'.medications = s.medications
s'.interactions = s.interactions
}
pred remove_prescription[s, s': State] {
pre_remove_prescription[s]
post_remove_prescription[s, s']
}
pred init[s: State] {
no s.patients
no s.medications
no s.interactions
no s.prescriptions
}
pred next[s, s': State] {
add_patient[s, s'] or
add_medication[s, s'] or
add_interaction[s, s'] or
add_prescription[s, s'] or
remove_interaction[s, s'] or
remove_prescription[s, s']
}
fact {
all s: State | s in initialState iff init[s]
all s, s': State | s->s' in nextState iff next[s,s']
all s, s': State |
s.patients = s'.patients and
s.medications = s'.medications and
s.interactions = s'.interactions and
s.prescriptions = s'.prescriptions and
s.in_patient = s'.in_patient and
s.in_medication1 = s'.in_medication1 and
s.in_medication2 = s'.in_medication2
implies s = s'
}
pred reachablity_axiom {
all s: State | s in State.(initialState <: *nextState)
}
pred operations_axiom {
some s, s':State | add_patient[s, s']
some s, s':State | add_medication[s, s']
some s, s':State | add_interaction[s, s']
some s, s':State | add_prescription[s, s']
some s, s':State | remove_interaction[s, s']
some s, s':State | remove_prescription[s, s']
}
pred significance_axioms {
reachablity_axiom
operations_axiom
}
run significance_axioms for 1 Patient,
2 Medication,
3 State,
3 PathNode
pred symmetry {
ctlfc_mc[ag[{s: State | all m1, m2: Medication |
m1->m2 in s.interactions iff
m2->m1 in s.interactions}]]
}
pred irreflexive {
ctlfc_mc[ag[{s: State | all m: Medication | not m in s.interactions[m]}]]
}
pred safe_prescriptions {
ctlfc_mc[ag[{s: State | all m1, m2: s.medications, p: s.patients |
m2 in s.interactions[m1] =>
!((m1 in s.prescriptions[p]) and
(m2 in s.prescriptions[p]))}]]
}
check safety_properties {
symmetry
irreflexive
safe_prescriptions
} for 3
|
bb-runtimes/runtimes/ravenscar-full-stm32g474/gnat/s-imguti.ads
|
JCGobbi/Nucleo-STM32G474RE
| 0 |
7544
|
<gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . I M G _ U T I L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2020-2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides some common utilities used by the s-imgxxx files
package System.Img_Util is
pragma Pure;
Max_Real_Image_Length : constant := 5200;
-- If Exp is set to zero and Aft is set to Text_IO.Field'Last (i.e., 255)
-- then Long_Long_Float'Last generates an image whose length is slightly
-- less than 5200.
procedure Set_Decimal_Digits
(Digs : in out String;
NDigs : Natural;
S : out String;
P : in out Natural;
Scale : Integer;
Fore : Natural;
Aft : Natural;
Exp : Natural);
-- Sets the image of Digs (1 .. NDigs), which is a string of decimal digits
-- preceded by either a minus sign or a space, i.e. the integer image of
-- the value in units of delta if this is for a decimal fixed point type
-- with the given Scale, or the integer image of the value converted to an
-- implicit decimal fixed point type with the given Scale if this is for an
-- ordinary fixed point type, starting at S (P + 1), updating P to point to
-- the last character stored. The caller promises that the buffer is large
-- enough and therefore no check is made for it. Constraint_Error will not
-- necessarily be raised if the requirement is violated since it is valid
-- to compile this unit with checks off. The Fore, Aft and Exp values can
-- be set to any valid values for the case of use by Text_IO.Decimal_IO or
-- Text_IO.Fixed_IO. Note that there is no leading space stored. The call
-- may destroy the value in Digs, which is why Digs is in-out (this happens
-- if rounding is required).
type Floating_Invalid_Value is (Minus_Infinity, Infinity, Not_A_Number);
procedure Set_Floating_Invalid_Value
(V : Floating_Invalid_Value;
S : out String;
P : in out Natural;
Fore : Natural;
Aft : Natural;
Exp : Natural);
-- Sets the image of a floating-point invalid value, starting at S (P + 1),
-- updating P to point to the last character stored. The caller promises
-- that the buffer is large enough and therefore no check is made for it.
-- Constraint_Error will not necessarily be raised if the requirement is
-- violated since it is valid to compile this unit with checks off.
end System.Img_Util;
|
Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-2.ada
|
LaudateCorpus1/RosettaCodeData
| 1 |
2128
|
X : Image (1..16, 1..16);
begin
Fill (X, White);
Line (X, ( 1, 8), ( 8,16), Black);
Line (X, ( 8,16), (16, 8), Black);
Line (X, (16, 8), ( 8, 1), Black);
Line (X, ( 8, 1), ( 1, 8), Black);
Print (X);
|
test/asm/syntax-error-lexer-mode.asm
|
michealccc/rgbds
| 522 |
168927
|
<reponame>michealccc/rgbds
newline equs "\n"
def x = 1 newline def y = 2
println "x={d:x}, y={d:y}"
; the lexer is already in normal mode at the `AF`, so `newline` gets expanded
def m = AF newline def n = 2
println "n={d:n}"
; the lexer is in raw mode at the `AF`, but the parser resets it to normal
def AF = 1 newline def q = 2
println "q={d:q}"
|
Transynther/x86/_processed/NONE/_st_un_/i9-9900K_12_0xa0.log_21829_646.asm
|
ljhsiun2/medusa
| 9 |
246307
|
<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %r8
push %rbx
push %rdi
push %rdx
lea addresses_UC_ht+0x3466, %r8
nop
nop
xor $6725, %rdi
movw $0x6162, (%r8)
nop
nop
nop
nop
nop
inc %r8
lea addresses_UC_ht+0x14ca6, %r13
nop
nop
nop
nop
nop
add %rdi, %rdi
movw $0x6162, (%r13)
add $628, %rdx
lea addresses_WT_ht+0x1a46, %r14
nop
cmp %r12, %r12
mov (%r14), %rdi
and %r8, %r8
lea addresses_WC_ht+0x15e46, %r14
add %rbx, %rbx
vmovups (%r14), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %r13
cmp $24397, %r12
pop %rdx
pop %rdi
pop %rbx
pop %r8
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r8
push %r9
push %rax
push %rbp
push %rdx
// Store
lea addresses_US+0x4e46, %rax
nop
nop
inc %r8
movl $0x51525354, (%rax)
nop
sub %r9, %r9
// Faulty Load
lea addresses_WC+0x15e46, %rbp
nop
nop
nop
nop
and %rdx, %rdx
mov (%rbp), %r8d
lea oracles, %rbp
and $0xff, %r8
shlq $12, %r8
mov (%rbp,%r8,1), %r8
pop %rdx
pop %rbp
pop %rax
pop %r9
pop %r8
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WC', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_US', 'AVXalign': True, 'size': 4}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WC', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 2}}
{'src': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'54': 21827, '5f': 2}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
MemExpansion/TestProgram/ROMCheck/TestDataPreparation/rom_testImage2.asm
|
ja1umi/MUTIF09Project
| 8 |
88344
|
<gh_stars>1-10
ORG $A000
PAGE1_1 FCB $10, $AA, $55, $FC, $FF
PAGE1_2 RMB $1000 - (PAGE1_2 - PAGE1_1)
END
|
programs/oeis/089/A089950.asm
|
neoneye/loda
| 22 |
16797
|
; A089950: Partial sums of A001652.
; 0,3,23,142,838,4897,28557,166460,970220,5654879,32959075,192099594,1119638514,6525731517,38034750617,221682772216,1292061882712,7530688524091,43892069261871,255821727047174,1491038293021214,8690408031080153,50651409893459749,295218051329678388,1720656898084610628,10028723337177985431,58451683124983302011,340681375412721826690,1985636569351347658186,11573138040695364122485,67453191674820837076785,393146012008229658338288,2291422880374557112953008,13355391270239113019379827,77840924741060121003326023,453690157176121613000576382,2644300018315669557000132342,15412109952717895729000217745,89828359697991704817001174205,523558048235232333173006827564,3051519929713402294221039791260,17785561530045181432153231920079,103661849250557686298698351729299,604185533973300936360036878455802,3521451354589247931861522919005602,20524522593562186654809100635577901,119625684206783871996993080894461897,697229582647141045327149384731193576
mov $2,$0
add $2,1
mov $0,$2
seq $0,55997 ; Numbers n such that n(n - 1)/2 is a square.
sub $0,$2
div $0,2
|
programs/oeis/003/A003953.asm
|
neoneye/loda
| 22 |
169428
|
<reponame>neoneye/loda
; A003953: Expansion of g.f.: (1+x)/(1-10*x).
; 1,11,110,1100,11000,110000,1100000,11000000,110000000,1100000000,11000000000,110000000000,1100000000000,11000000000000,110000000000000,1100000000000000,11000000000000000,110000000000000000,1100000000000000000,11000000000000000000,110000000000000000000,1100000000000000000000,11000000000000000000000,110000000000000000000000,1100000000000000000000000,11000000000000000000000000,110000000000000000000000000,1100000000000000000000000000,11000000000000000000000000000,110000000000000000000000000000,1100000000000000000000000000000,11000000000000000000000000000000,110000000000000000000000000000000,1100000000000000000000000000000000,11000000000000000000000000000000000,110000000000000000000000000000000000
mov $1,10
pow $1,$0
mul $1,11
div $1,10
mov $0,$1
|
twix-header-grammar/XProtParser.g4
|
davidrigie/twixreader
| 3 |
27
|
<reponame>davidrigie/twixreader
/*
* PARSER RULES
*/
parser grammar XProtParser;
options { tokenVocab=XProtLexer; }
header : xprot*
ASCCONV_STRING*
;
xprot : xprot_tag
LEFT_BRACE
special_node*
node*
BURN_DEPENDENCY*
RIGHT_BRACE
;
xprot_tag : BRA XPROTOCOL KET;
special_node : (param_special | param_eva);
node : (param_map | param_array | param_generic | BURN_PARAM_CARD_LAYOUT);
param_special : param_special_tag
(QUOTED_STRING | NUMBER_VALUE)
;
param_special_tag : BRA SPECIAL_TAG_TYPE KET;
param_eva : param_eva_tag
LEFT_BRACE
STRING_TABLE
RIGHT_BRACE
;
param_eva_tag : BRA EVASTRINGTABLE KET;
param_array : param_array_tag
LEFT_BRACE
DEFAULT
node
array_value*
RIGHT_BRACE
;
param_array_tag : BRA
PARAM_ARRAY_TAG_TYPE
TAG_DOT
TAG_NAME
KET;
param_map : param_map_tag
LEFT_BRACE
node*
RIGHT_BRACE
;
param_map_tag : BRA
PARAM_MAP_TAG_TYPE
TAG_DOT
TAG_NAME
KET;
array_value : LEFT_BRACE
arr_val_item*
RIGHT_BRACE
;
arr_val_item : QUOTED_STRING #String
| NUMBER_VALUE #Number
| array_value #AnArrayVal
;
param_generic : param_generic_tag
LEFT_BRACE
param_generic_val*
RIGHT_BRACE
;
param_generic_val : ASCCONV_STRING
| QUOTED_STRING
| NUMBER_VALUE
;
param_generic_tag : BRA
TAG_TYPE
(TAG_DOT TAG_NAME)?
KET
;
|
alloy4fun_models/trainstlt/models/3/YBunAS6QqN8eeNomW.als
|
Kaixi26/org.alloytools.alloy
| 0 |
4200
|
<reponame>Kaixi26/org.alloytools.alloy
open main
pred idYBunAS6QqN8eeNomW_prop4 {
always(lone pos.Train)
}
pred __repair { idYBunAS6QqN8eeNomW_prop4 }
check __repair { idYBunAS6QqN8eeNomW_prop4 <=> prop4o }
|
05_null_termination_macro/main.asm
|
christopher-besch/assembly_reference
| 2 |
87015
|
; copy in place
%include "print.asm"
%macro exit 1
mov rax, 60
mov rdi, %1
syscall
%endmacro
section .data
text db "Hello World!",10,0
text1 db "I like trains.",10,0
section .text
global _start
_start:
mov rax, text
call _print
mov rax, text1
call _print
exit 0
|
programs/oeis/168/A168361.asm
|
karttu/loda
| 1 |
23977
|
; A168361: Period 2: repeat 2, -1.
; 2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1
gcd $0,2
mov $1,-3
bin $1,$0
div $1,3
|
ee/hk/italian.asm
|
olifink/smsqe
| 0 |
94376
|
; HOTKEY messages 1988 T.Tebby QJUMP
section language
xdef hk_italian
xdef hk_stufc
xdef hk_stufp
xdef hk_stufl
include 'dev8_mac_text'
include 'dev8_ee_hk_data'
hk_italian
hk_stufc dc.b ' '
hk_stufp dc.b $fc
hk_stufl dc.l $200
mktext spce,{SPACE}
mktext exec,{EXEC}
mktext load,{LOAD}
mktext pick,{PICK}
mktext wake,{WAKE}
mktext cmd,{CMD}
mktext key,{KEY}
mktext grab,{Allocazione della memoria di lavoro (kilobytes)> }
mktext hks2,{HOTKEY System 2\}
xdef hki_llrc
hki_llrc
dc.w 'hi'
dc.w hki.llrc ; dummy last line recall item
dc.l 0
mktext llrc,{richiamo ultima linea} ;32
ds.w 0
end
|
Cubical/Categories/Constructions/FullSubcategory.agda
|
thomas-lamiaux/cubical
| 1 |
7428
|
<reponame>thomas-lamiaux/cubical
{-# OPTIONS --safe #-}
module Cubical.Categories.Constructions.FullSubcategory where
-- Full subcategory (not necessarily injective on objects)
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Categories.Category
open import Cubical.Categories.Functor renaming (𝟙⟨_⟩ to funcId)
private
variable
ℓC ℓC' ℓD ℓD' ℓE ℓE' ℓP ℓQ ℓR : Level
module _ (C : Category ℓC ℓC') (P : Category.ob C → Type ℓP) where
private
module C = Category C
open Category
open Functor
FullSubcategory : Category (ℓ-max ℓC ℓP) ℓC'
ob FullSubcategory = Σ[ x ∈ C.ob ] P x
Hom[_,_] FullSubcategory (x , p) (y , q) = C.Hom[ x , y ]
id FullSubcategory = C.id
_⋆_ FullSubcategory = C._⋆_
⋆IdL FullSubcategory = C.⋆IdL
⋆IdR FullSubcategory = C.⋆IdR
⋆Assoc FullSubcategory = C.⋆Assoc
isSetHom FullSubcategory = C.isSetHom
FullInclusion : Functor FullSubcategory C
F-ob FullInclusion = fst
F-hom FullInclusion = idfun _
F-id FullInclusion = refl
F-seq FullInclusion f g = refl
module _ (C : Category ℓC ℓC')
(D : Category ℓD ℓD') (Q : Category.ob D → Type ℓQ) where
private
module C = Category C
module D = Category D
open Category
open Functor
ToFullSubcategory : (F : Functor C D) → ((c : C.ob) → Q (F-ob F c)) → Functor C (FullSubcategory D Q)
F-ob (ToFullSubcategory F f) c = F-ob F c , f c
F-hom (ToFullSubcategory F f) = F-hom F
F-id (ToFullSubcategory F f) = F-id F
F-seq (ToFullSubcategory F f) = F-seq F
module _ (C : Category ℓC ℓC') (P : Category.ob C → Type ℓP)
(D : Category ℓD ℓD') (Q : Category.ob D → Type ℓQ) where
private
module C = Category C
module D = Category D
open Category
open Functor
MapFullSubcategory : (F : Functor C D) → ((c : C.ob) → P c → Q (F-ob F c))
→ Functor (FullSubcategory C P) (FullSubcategory D Q)
MapFullSubcategory F f = ToFullSubcategory (FullSubcategory C P) D Q
(funcComp F (FullInclusion C P) )
λ (c , p) → f c p
module _ (C : Category ℓC ℓC') (P : Category.ob C → Type ℓP) where
private
module C = Category C
open Category
open Functor
MapFullSubcategory-id :
MapFullSubcategory C P C P (funcId C) (λ c p → p) ≡ funcId (FullSubcategory C P)
MapFullSubcategory-id = Functor≡
(λ (c , p) → refl)
(λ γ → refl)
module _ (C : Category ℓC ℓC') (P : Category.ob C → Type ℓP)
(D : Category ℓD ℓD') (Q : Category.ob D → Type ℓQ)
(E : Category ℓE ℓE') (R : Category.ob E → Type ℓR) where
private
module C = Category C
module D = Category D
module E = Category E
open Category
open Functor
MapFullSubcategory-seq :
(F : Functor C D) → (f : (c : C.ob) → P c → Q (F-ob F c)) →
(G : Functor D E) → (g : (d : D.ob) → Q d → R (F-ob G d)) →
MapFullSubcategory C P E R (funcComp G F) (λ c p → g (F-ob F c) (f c p)) ≡
funcComp
(MapFullSubcategory D Q E R G g)
(MapFullSubcategory C P D Q F f)
MapFullSubcategory-seq F f G g = Functor≡
(λ (c , p) → refl)
(λ γ → refl)
|
alloy4fun_models/trashltl/models/7/JtPskT7nxEcSMt9qd.als
|
Kaixi26/org.alloytools.alloy
| 0 |
1393
|
<reponame>Kaixi26/org.alloytools.alloy
open main
pred idJtPskT7nxEcSMt9qd_prop8 {
eventually (all f:File| f.link in Trash)
}
pred __repair { idJtPskT7nxEcSMt9qd_prop8 }
check __repair { idJtPskT7nxEcSMt9qd_prop8 <=> prop8o }
|
alloy4fun_models/trainstlt/models/3/f5DDyvGotcQoRurpg.als
|
Kaixi26/org.alloytools.alloy
| 0 |
3944
|
open main
pred idf5DDyvGotcQoRurpg_prop4 {
always prox.~prox in iden
}
pred __repair { idf5DDyvGotcQoRurpg_prop4 }
check __repair { idf5DDyvGotcQoRurpg_prop4 <=> prop4o }
|
orka/src/orka/interface/orka-inputs-joysticks-filtering.ads
|
onox/orka
| 52 |
1782
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Numerics;
package Orka.Inputs.Joysticks.Filtering is
pragma Preelaborate;
function RC (Cutoff_Frequency : GL.Types.Single) return GL.Types.Single is
(1.0 / (2.0 * Ada.Numerics.Pi * Cutoff_Frequency));
-- Return the RC for a given cutoff frequency in Hertz
--
-- 1
-- fc = ---------
-- 2*Pi * RC
function Low_Pass_Filter
(Current, Last : Axis_Position;
RC, DT : GL.Types.Single) return Axis_Position;
function Dead_Zone (Value, Threshold : Axis_Position) return Axis_Position
with Pre => Threshold >= 0.0;
function Invert (Value : Axis_Position; Enable : Boolean) return Axis_Position;
end Orka.Inputs.Joysticks.Filtering;
|
Logic/Propositional/Equiv.agda
|
Lolirofle/stuff-in-agda
| 6 |
387
|
<reponame>Lolirofle/stuff-in-agda<filename>Logic/Propositional/Equiv.agda
module Logic.Propositional.Equiv where
import Lvl
open import Logic
open import Logic.Propositional
import Logic.Propositional.Theorems as Theorems
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Setoid
open import Type
private variable ℓ ℓ₁ ℓ₂ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level
private variable T A B : Type{ℓ}
instance
[↔]-reflexivity : Reflexivity{ℓ₂ = ℓ}(_↔_)
[↔]-reflexivity = intro Theorems.[↔]-reflexivity
instance
[↔]-symmetry : Symmetry{ℓ₂ = ℓ}(_↔_)
[↔]-symmetry = intro Theorems.[↔]-symmetry
instance
[↔]-transitivity : Transitivity{ℓ₂ = ℓ}(_↔_)
[↔]-transitivity = intro Theorems.[↔]-transitivity
instance
[↔]-equivalence : Equivalence{ℓ₂ = ℓ}(_↔_)
[↔]-equivalence = intro
instance
[↔]-equiv : Equiv(Stmt{ℓ})
[↔]-equiv = intro(_↔_) ⦃ [↔]-equivalence ⦄
|
src/getters/getter-for_loop.adb
|
python36/d0xfa
| 0 |
7529
|
<filename>src/getters/getter-for_loop.adb
package body getter.for_loop is
function get return character is
use type pos_count;
c : character;
begin
if cur_for_loop.last > unb.length(cur_for_loop.code) then
cur_for_loop.cur_line := cur_for_loop.first_line;
cur_for_loop.last := 1;
inc(cur_for_loop.cur_i);
if cur_for_loop.cur_i > cur_for_loop.end_i then
pop;
environment.delete(cur_for_loop.cursor);
for_loops.delete_last;
if not for_loops_t.is_empty(for_loops) then
cur_for_loop := for_loops_t.last_element(for_loops);
end if;
else
environment.replace_element(cur_for_loop.cursor, word(cur_for_loop.cur_i));
end if;
return ' ';
end if;
c := unb.element(cur_for_loop.code, cur_for_loop.last);
if c = ascii.lf then
cur_for_loop.cur_line := cur_for_loop.cur_line + 1;
set_line(cur_for_loop.cur_line);
end if;
inc(cur_for_loop.last);
return c;
end get;
procedure create (start_i, end_i : word; var : environment_t.cursor) is
ofs : natural := 1;
eqs_start : natural := 1;
eqs_end : natural := 1;
len_start : constant natural := for_statement'length;
len_end : constant natural := end_for_statement'length;
c : character;
begin
tmp_for_loop.code := unb.to_unbounded_string(" ");
tmp_for_loop.first_line := get_line;
tmp_for_loop.cur_line := tmp_for_loop.first_line;
tmp_for_loop.cursor := var;
tmp_for_loop.start_i := natural(start_i);
tmp_for_loop.cur_i := tmp_for_loop.start_i;
tmp_for_loop.end_i := natural(end_i);
environment.replace_element(var, start_i);
loop
c := getter.get(false);
if c = ascii.nul then
raise ERROR_NO_CLOSED;
end if;
if for_statement(eqs_start) = c and then unb.element(tmp_for_loop.code, unb.length(tmp_for_loop.code) - eqs_start + 1) in ' '|ascii.lf then
inc(eqs_start);
if eqs_start > len_start then
inc(ofs);
eqs_start := 1;
end if;
else
eqs_start := 1;
end if;
if end_for_statement(eqs_end) = c and then unb.element(tmp_for_loop.code, unb.length(tmp_for_loop.code) - eqs_end + 1) in ' '|ascii.lf then
inc(eqs_end);
if eqs_end > len_end then
eqs_end := 1;
dec(ofs);
if ofs = 0 then
unb.delete(tmp_for_loop.code, unb.length(tmp_for_loop.code) - 6, unb.length(tmp_for_loop.code));
exit;
end if;
end if;
else
eqs_end := 1;
end if;
unb.append(tmp_for_loop.code, c);
end loop;
if not for_loops_t.is_empty(for_loops) then
for_loops.replace_element(for_loops_t.last(for_loops), cur_for_loop);
end if;
for_loops.append(tmp_for_loop);
cur_for_loop := tmp_for_loop;
getter.push(get'access);
end create;
end getter.for_loop;
|
Assembly Works 4/Task_5_Lab_4.asm
|
AhmadVakil/Assembly-C_Micro-Controller
| 0 |
168318
|
<gh_stars>0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 1DT301, Computer Technology I
; Date: 2017-11-05
; Author:
; <NAME>
;
; Lab number: 4
; Title: Timer and USART
;
; Hardware: STK600, CPU ATmega2560
;
; Function: Now we should use interrupts in last task.
;
; Input ports: RS232
;
; Output ports: PORTB, RS232
;
; Subroutines:
;
; Included files: m2560def.inc
;
; Other information:
;
; Changes in program:
;
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.include "m2560def.inc"
.def temp = r16
.def ledLights = r17
.def reverser = r18
.def bitReceivedChecker = r19 ; Flag to check if data is received
.equ bitPerSeconds = 12
.equ yes = 0b00000001
.equ no = 0b00000000
.cseg
.org 0x00
rjmp reset
.org URXC1addr
rjmp receiveChecker
.org UDRE1addr
rjmp emptyChecker
.org 0x72
reset:
;Stack Pointer
ldi temp, LOW(RAMEND)
out SPL, temp
ldi temp, HIGH(RAMEND)
out SPH, temp
ser temp
out DDRB, temp
ldi temp, bitPerSeconds ;Serial communication setup
sts UBRR1L, temp ;setting bps rate
ldi temp, (1<<RXEN1) | (1<<TXEN1) | (1<<RXCIE1) | (1<<UDRIE1)
sts UCSR1B, temp ; UART flag is enabled
sei
clr ledLights
main_loop: ; Waits for interrupts and showing lights to PORTB
rcall showLights ; reverse the value and show it on PORTB
rjmp main_loop
showLights:
mov reverser, ledLights
com reverser
out PORTB, reverser
ret
receiveChecker: ; If data is recieved by UART 0 show it on ledLights
lds ledLights, UDR1 ; ledLights value is changed
ldi bitReceivedChecker, yes
reti
emptyChecker:
cpi bitReceivedChecker, no ; If bitReceivedChecker is equal to 0 then send to the receiver
breq isEmpty
sts UDR1, ledLights
ldi bitReceivedChecker, no
isEmpty:
reti
|
editor.asm
|
neilbaldwin/PR8
| 8 |
23450
|
.FEATURE force_range
editorInit:
jsr setupSpriteCursor
jsr initKeyRepeats
lda #$00
sta maxDma
sta editorDecoding ;clear blocking flags
sta editorEditingValue ;
sta editorEditingBuffer ;
lda #PLAY_MODE_STOPPED ;set player mode and previous mode to STOPPED
sta plyrMode
sta plyrModeOld
lda #EDIT_MODE_GRID ;set editing mode to GRID
sta editorMode
lda #$00 ;reset edit cursor position to top-left (0,0)
sta cursorX_grid
sta cursorY_grid
sta cursorY_editMenu
lda #$00 ;clear key repeats and repeat counters
sta keyStopB
sta keyDelayA
sta keyDelayB
sta keyDelayUD
sta keyDelayLR
sta editorWaitForAB ;clear various editig flags
sta editorWaitForClone
sta editorPhraseForClone
lda #$00 ;clear copy buffer
sta triggerCopyBuffer+0
sta triggerCopyBuffer+1
sta triggerCopyBuffer+2
sta triggerCopyBuffer+3
sta triggerCopyBuffer+4
ldx #$00 ;clear Editor trigger indexes
stx editorTriggerIndex+0
stx editorTriggerIndex+1
stx editorTriggerIndex+2
stx editorTriggerIndex+3
stx editorTriggerIndex+4
stx editorTriggerIndex+5
lda #4+(2*12) ;set last note value to C3
sta editorTrackLastNote+0
sta editorTrackLastNote+1
sta editorTrackLastNote+2
sta editorTrackLastNote+3
sta editorTrackLastNote+4
sta editorTrackLastNote+5
lda #$00 ;clear Last Triger for all tracks
sta editorTrackLastTrigger+0
sta editorTrackLastTrigger+1
sta editorTrackLastTrigger+2
sta editorTrackLastTrigger+3
sta editorTrackLastTrigger+4
sta editorTrackLastTrigger+5
lda #$01 ;set Channel Status to 1 for each track
sta editorChannelStatus+0 ;Channel Status is for Mute and Solo
sta editorChannelStatus+1
sta editorChannelStatus+2
sta editorChannelStatus+3
sta editorChannelStatus+4
sta editorChannelStatus+5
lda #$FF
sta editorSoloChannel ;Clear Solo channel
lda #$00 ;Clear sub mode indexes for each track
sta editorSubModeIndexes+0
sta editorSubModeIndexes+1
sta editorSubModeIndexes+2
sta editorSubModeIndexes+3
sta editorSubModeIndexes+4
sta editorSubModeIndexes+5
sta editorDrumAuxIndex ;Clear various flags
sta editorEditDrumName
sta lastDrumParameterValue
sta editorTrackWipeSpeed
sta editorForceTrackLoad
sta editMenuActive
sta editCopyBuffer
sta cursorY_grid
sta cursorX_track
sta editPatternInfoSubMode
sta editorDrumSubMode
sta editorLastDrumValue
sta editorLastPhraseValue
sta editorLastSongLoop
sta editSongIndex
sta editorSongLastPattern
lda #STARTING_SONG ;read Starting Song and load song data
jsr editorSelectSong
lda #SONG_MODE_OFF ;turn off Song Mode
sta editSongMode
lda #$00 ;turn of Song Mode Recording
sta editSongModeRecord
jsr editorInitVoiceSwitchSprites
jsr editorCheckSignature ;check to see if Save File has been 'formatted'
bcc :+ ;as a PR8 file, if not wipe all data
jsr editorWipeAll
:
lda #STARTING_PATTERN ;set starting pattern
sta editorCurrentPattern
jmp editorInit2 ;
editorInit2:
lda editorCurrentPattern ;
jsr editorSelectPattern ;fetch current pattern to display
jsr editorInitCopyInfo ;clear copy message buffer
ldx #$07
jsr editorSetPlayBackMessage
jsr editorDecodePattern ;decode current pattern for printing
jsr editorDecodeTriggerParameters ;decode current pattern triggers for printing
ldy cursorY_grid ;get drum under cursor and decode for printing
lda (editorTmp0),y
lda editorTrackDrum,y
sta editorCurrentDrum
jsr editorDecodeDrum
jsr editorDecodeSong ;decode song for printing
lda #procSongAll ;add song printing to async dma buffer (non-blocking print)
jsr addProcessToBuffer
lda #procGridRowAll ;print grid row (non blocking)
jsr addProcessToBuffer
lda #procTrackDrumAll ;print track drum assignments (non blocking)
jsr addProcessToBuffer
jsr editorPrintTriggers ;print triggers for each track
jsr editorPrintDrum ;print current drum
lda #procCopyInfoAll ;print copy message (non blocking)
jsr addProcessToBuffer
lda #procGridPattern ;print current pattern to display grid (non blocking)
jsr addProcessToBuffer
rts
editorCheckSignature: ;check if SAV file has been 'formatted' for PR8
lda #WRAM_BANK_00
jsr setMMC1r1
ldx #$00
: lda PR8_HEADER,x ;simple header check against PR8 header string
cmp @header,x
bne :+
inx
cpx #@headerEnd-@header
bcc :-
clc ;clear carry if SAV file is correctly formatted
rts
: ldx #$00 ;if header dosn't match PR8 header, write PR8 header to save area
: lda @header,x
sta PR8_HEADER,x
inx
cpx #@headerEnd-@header
bcc :-
sec
rts
@header: .BYTE "P","R","8",0 ;PR8 header for PR8 formatted save file
@headerEnd:
; ****
; Main Loop
; ****
editorMainLoop: ;main background loop, refreshed once per vertical blank
lda vblankFlag
: cmp vblankFlag
beq :-
jsr editorRefresh ;call to refresh editor (many functions below)
jmp editorMainLoop ;back to main loop
;
;
;
editorRefresh:
jsr editorGlobalKeys ;check non modal key input
jsr editorFlashCursor ;animate (flash) sprite cursor
jsr editorUpdateTrackIndexCursor ;update track index cursor
jsr editorTrackWipeSprites ;clear track sprite for later refresh
jsr editorStepIndicator ;update step indicator
jsr editorMeters ;update track meters
jsr editorShowParameterHint ;update Trigger Parameter indicator sprites
jsr editorGhostCursor ; *** not sure ***
jsr editorShowSongMode ;display current song mode
jsr editorShowTimer ;display timer
jsr editorCheckCopyInfoMessage ;update copy info message (on timer)
ldx editorMode ;editor mode is integer value
lda editModeJumpLo,x ;fetch vector for edit mode from table
sta editModeVector
lda editModeJumpHi,x
sta editModeVector+1
jmp (editModeVector) ;jump to current edit mode vector
editModeJumpLo:
.LOBYTES editorDisabled
.LOBYTES editTrack
.LOBYTES editGrid
.LOBYTES editTriggerParameters
.LOBYTES editDrum
.LOBYTES editDrumAux
.LOBYTES editorEditGridMenu
.LOBYTES editorEditDrumMenu
.LOBYTES editorEditPatternNumber
.LOBYTES editorSong
.LOBYTES editorEditSongMenu
.LOBYTES editorEditEchoMenu
.LOBYTES editorClearMenu
editModeJumpHi:
.HIBYTES editorDisabled
.HIBYTES editTrack
.HIBYTES editGrid
.HIBYTES editTriggerParameters
.HIBYTES editDrum
.HIBYTES editDrumAux
.HIBYTES editorEditGridMenu
.HIBYTES editorEditDrumMenu
.HIBYTES editorEditPatternNumber
.HIBYTES editorSong
.HIBYTES editorEditSongMenu
.HIBYTES editorEditEchoMenu
.HIBYTES editorClearMenu
editorDisabled:
rts
editorTryLoadingPattern:
lda editSongMode
cmp #SONG_MODE_OFF
bne :+
lda editorCurrentPattern
sta plyrNextPattern
: rts
editorGlobalKeys:
jsr checkRepeatKeySelect
jsr checkRepeatKeyStart
lda PAD1_firea
beq :+
lda keyReleaseStart
beq :+
lda #PLAY_MODE_SONG_LOOP
sta plyrMode
jsr editorTryLoadingPattern
rts
: lda PAD1_fireb
beq :++++
lda keyReleaseSelect
beq :+
ldx cursorY_grid
lda editorChannelStatus,x
eor #$01
sta editorChannelStatus,x
rts
: lda keyReleaseStart
beq :++
lda cursorY_grid
cmp editorSoloChannel
bne :+
lda #$FF
bmi :+
: sta editorSoloChannel
: rts
: lda PAD1_sel
beq :++
lda keyReleaseStart
beq :+
lda #PLAY_MODE_START
sta plyrMode
jsr editorTryLoadingPattern
: rts
: lda keyReleaseStart
beq :+
lda plyrMode
eor #$01
sta plyrMode
jsr editorTryLoadingPattern
: rts
.IF 0=1
lda keyReleaseStart
beq :+++
lda PAD1_firea
beq :+
;Start song from Loop point
lda #PLAY_MODE_SONG_LOOP
sta plyrMode
jsr editorTryLoadingPattern
rts
: lda PAD1_fireb
bne :++
lda #PLAY_MODE_START
ldx PAD1_sel
bne :+
lda plyrMode
eor #$01
: sta plyrMode
jsr editorTryLoadingPattern
:
lda PAD1_fireb
beq :+++
lda keyReleaseSelect
beq :+
ldx cursorY_grid
lda editorChannelStatus,x
eor #$01
sta editorChannelStatus,x
rts
: lda keyReleaseStart
beq :++
lda cursorY_grid
cmp editorSoloChannel
bne :+
lda #$FF
bmi :+
: sta editorSoloChannel
: rts
.ENDIF
;------------------------------------------------------------------------------
; SPRITE CURSOR ROUTINES
;------------------------------------------------------------------------------
setupSpriteCursor:
ldx #$00
: lda @cursor,x
sta SPR00_Y,x
inx
cpx #(5 *4)
bcc :-
rts
@cursor: ; Y CH AT X
.BYTE $23,$01,$00,$0C ;0
.BYTE $23,$02,$00,$14 ;1
.BYTE $2B,$03,$00,$0C ;2
.BYTE $2B,$04,$00,$14 ;3
.BYTE $20,$05,$02,$20 ;4
editorUpdateCursor:
ldx editorCursorMode
bne :+
lda #240
sta SPR00_Y
sta SPR01_Y
sta SPR02_Y
sta SPR03_Y
rts
: lda #$01
sta SPR00_CHAR
lda #$02
sta SPR01_CHAR
cpx #$05
bcc :+
lda #$00
sta SPR00_CHAR
sta SPR01_CHAR
:
lda editorCursorX
sta SPR00_X
sta SPR02_X
clc
adc @cursorModeXOffsets,x
sta SPR01_X
sta SPR03_X
lda editorCursorY
sta SPR00_Y
sta SPR01_Y
clc
adc @cursorModeYOffsets,x
sta SPR02_Y
sta SPR03_Y
rts
@cursorModeXOffsets:
.BYTE $00
.BYTE $0A,$12,$1B,$3A,$0A
@cursorModeYOffsets:
.BYTE $00
.BYTE $0A,$09,$09,$09,$0A
editorFlashCursor:
lda #CURSOR_HOLD_COLOUR
sta cursorFlashColour
lda keyRepeatA
ora keyRepeatB
beq @b
rts
; lda editBufferFlag
; bne @b
; lda editNavFlag
; bne @d
;@c: rts
@b: ldx cursorFlashIndex
lda cursorFlashColours,x
sta cursorFlashColour
inx
cpx #cursorFlashColoursEnd-cursorFlashColours
bcc @a
ldx #$00
@a: stx cursorFlashIndex
rts
cursorFlashColours:
;.RES 5,$30
.RES 3,$30
.RES 3,$30+CURSOR_BASE_COLOUR
.RES 2,$20+CURSOR_BASE_COLOUR
.RES 1,$10+CURSOR_BASE_COLOUR
;.RES 1,$00+CURSOR_BASE_COLOUR
.RES 6,$0F
;.RES 1,$00+CURSOR_BASE_COLOUR
.RES 2,$10+CURSOR_BASE_COLOUR
.RES 4,$20+CURSOR_BASE_COLOUR
.RES 6,$30+CURSOR_BASE_COLOUR
cursorFlashColoursEnd:
editorUpdateTriggerIndexCursor:
ldx cursorY_grid
lda editorTriggerIndex,x
tay
lda @triggerIndexY,y
sta SPR04_Y
lda #TRIGGER_CURSOR_X_BASE
sta SPR04_X
rts
@triggerIndexY:
.REPEAT 5,i
.BYTE TRIGGER_CURSOR_Y_BASE + (8 * i)
.ENDREPEAT
editorUpdateTrackIndexCursor:
ldx cursorY_grid
lda @trackCursorY,x
sta SPR0F_Y
lda #9*8
sta SPR0F_X
rts
@trackCursorY:
.BYTE 9*8-2,10*8-2,11*8-2,12*8-2,13*8-2,14*8-2
editorInitVoiceSwitchSprites:
ldx #$00
: lda @sprites,x
sta SPR05_Y,x
inx
cpx #(27 * 4)
bcc :-
rts
@sprites: .BYTE 19*8,SPR_VOICE_OFF,$01,14*8 ;5 drum voice switches
.BYTE 19*8,SPR_VOICE_OFF,$01,28*8 ;6
.BYTE 24*8,SPR_VOICE_OFF,$01,11*8 ;7
.BYTE 24*8,SPR_VOICE_OFF,$01,15*8 ;8
.BYTE 24*8,SPR_VOICE_OFF,$01,28*8 ;9
.BYTE 17*8,$00,%00100010,4*8 ;A hints
.BYTE 17*8,$00,%00100010,5*8 ;B
.BYTE 17*8,$00,%00100010,5*8 ;C
.BYTE 9*8-1,$0A,%00100010,9*8-1 ;D track wipe anim
.BYTE 8*8,$0B,%00100000,10*8 ;E step indicator
.BYTE 9*8-2,$09,%00000010,9*8 ;F track index
.BYTE 9*8-1,$10,%00100011,3*8 ;10 mute/solo/activity
.BYTE 10*8-1,$10,%00100011,3*8 ;11
.BYTE 11*8-1,$10,%00100011,3*8 ;12
.BYTE 12*8-1,$10,%00100011,3*8 ;13
.BYTE 13*8-1,$10,%00100011,3*8 ;14
.BYTE 14*8-1,$10,%00100011,3*8 ;15
.BYTE 0,$00,%00000010,0 ;16
.BYTE 0,$00,%00000010,0 ;17
.BYTE 0,$00,%00000010,0 ;18
.BYTE 0,$00,%00000010,0 ;19
.BYTE 4*8-1,$20,%00000001,13*8 ;1A play mode
.BYTE 4*8-1,$21,%00000001,14*8 ;1B
.BYTE 4*8-1,$30,%00100000,5*8 ;1C ghost cursor
.BYTE 4*8-1,$30,%00100000,6*8 ;1D
.BYTE 4*8-1,$30,%00100000,8*8 ;1E
.BYTE 4*8-1,$30,%00100000,9*8 ;1F
editorShowTimer:
lda editSongMode
cmp #SONG_MODE_OFF
bne :+
lda plyrCurrentPattern
ldx #$00
jsr @printHexSpr
lda patternIndex
ldx #$08
jsr @printHexSpr
rts
: lda plyrSongBar
ldx #$00
jsr @printHexSpr
lda plyrCurrentPattern
ldx #$08
jsr @printHexSpr
rts
@printHexSpr:
cmp #$FF
beq :+
pha
lsr a
lsr a
lsr a
lsr a
clc
adc #$30
sta SPR1C_CHAR,x
pla
and #$0F
clc
adc #$30
sta SPR1D_CHAR,x
rts
: lda #$0F
sta SPR1C_CHAR,x
sta SPR1D_CHAR,x
rts
editorShowSongMode:
ldx editSongMode
lda @chr0,x
sta SPR1A_CHAR
lda @chr1,x
sta SPR1B_CHAR
lda @attr,x
sta SPR1A_ATTR
sta SPR1B_ATTR
rts
@chr0: .BYTE $20,$22,$24
@chr1: .BYTE $21,$23,$25
@attr: .BYTE $01,$03,$00
trackWipeSpeed = 3
trackWipeX = 9*8-4
trackWipeY = 9*8-1
editorTrackWipeSprites:
lda editorTrackWipeSpeed
bne :+
sta SPR0D_CHAR
rts
: clc
adc SPR0D_X
sta SPR0D_X
cmp #26*8
bcs :+
lda #$0A
sta SPR0D_CHAR
ldx cursorY_grid
lda @wipeY,x
sta SPR0D_Y
rts
: lda #$00
sta editorTrackWipeSpeed
lda #trackWipeX
sta SPR0D_X
rts
@wipeY: .REPEAT 6,i
.BYTE trackWipeY+(i *8)
.ENDREPEAT
editorStepIndicator:
ldx patternIndex
bpl :+
ldx #$00
: lda #8*8
sta SPR0E_Y
lda @indicatorY,x
sta SPR0E_X
rts
@indicatorY: .REPEAT 16,i
.BYTE 10*8 + (i * 8)
.ENDREPEAT
editorMeters:
inc editorMuteFlashIndex
lda editorMuteFlashIndex
cmp #(@muteSpritesEnd-@muteSprites)
bcc :+
lda #$00
sta editorMuteFlashIndex
: lda editorSoloChannel
bmi @noSolo
ldx #$00
: cpx editorSoloChannel
beq :+++
lda editorChannelStatus,x
bne :+
pha
beq :++
: ldy editorMuteFlashIndex
lda @muteSprites,y
pha
: txa
asl a
asl a
tay
pla
sta SPR10_CHAR,y
lda #$00
beq :++
: lda editorMeterCounters,x
tay
lda @meterSprites,y
pha
txa
asl a
asl a
tay
pla
clc
adc #$08
sta SPR10_CHAR,y
: lda editorMeterCounters,x
beq :++
clc
adc #$01
cmp #@meterSpritesEnd-@meterSprites
bcc :+
lda #$00
: sta editorMeterCounters,x
: inx
cpx #numberOfTracks
bcc :-------
rts
@noSolo: ldx #$00
: lda editorChannelStatus,x
bne :+
lda #$00
bpl :++
: lda editorMeterCounters,x
tay
lda @meterSprites,y
: pha
txa
asl a
asl a
tay
pla
sta SPR10_CHAR,y
lda editorMeterCounters,x
beq :++
clc
adc #$01
cmp #@meterSpritesEnd-@meterSprites
bcc :+
lda #$00
: sta editorMeterCounters,x
: inx
cpx #numberOfTracks
bcc :-----
rts
@meterSprites:
.BYTE $17,$10,$11,$12,$13,$14,$15,$16,$17
@meterSpritesEnd:
.BYTE $00
@muteSprites:
.BYTE $17,$17,$17,$17,$17
.REPEAT 32
.BYTE $00
.ENDREPEAT
@muteSpritesEnd:
HINT_X_BASE = (4*8)+4
HINT_Y_BASE = (17*8)-1
HINT_CHR_DARK = $0C
HINT_CHR_LIGHT = $0D
editorShowParameterHint:
lda vblankFlag
and #%00001000
sta editorTmp2
lda vblankFlag
and #%00000011
bne :+
lda editorMultiHintIndex
clc
adc #$01
and #$03
sta editorMultiHintIndex
:
lda #HINT_CHR_DARK
sta SPR0A_CHAR
sta SPR0B_CHAR
sta SPR0C_CHAR
lda #240
sta SPR0A_Y
sta SPR0B_Y
sta SPR0C_Y
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
lda editorMode
cmp #EDIT_MODE_DRUM_AUX
bne :+
lda editorDrumAuxIndex
beq :+
sec
sbc #$01
bpl :++
: ldx cursorY_grid
lda editorTriggerIndex,x
beq :++
cmp #$02
bcc :++
sbc #$02
: asl a
asl a
tax
lda #HINT_CHR_LIGHT
sta SPR0A_CHAR,x
: ldy #mod_Parameter0
lda (editorTmp0),y
bmi :+
jsr @checkMulti
tax
lda #HINT_X_BASE
clc
adc auxHintXOffsets,x
sta SPR0A_X
lda #HINT_Y_BASE
clc
adc auxHintYOffsets,x
sta SPR0A_Y
: ldy #mod_Parameter1
lda (editorTmp0),y
bmi :+
jsr @checkMulti
tax
lda #HINT_X_BASE
clc
adc auxHintXOffsets,x
sta SPR0B_X
lda #HINT_Y_BASE
clc
adc auxHintYOffsets,x
sta SPR0B_Y
: ldy #mod_Parameter2
lda (editorTmp0),y
bmi :+
jsr @checkMulti
tax
lda #HINT_X_BASE
clc
adc auxHintXOffsets,x
sta SPR0C_X
lda #HINT_Y_BASE
clc
adc auxHintYOffsets,x
sta SPR0C_Y
: rts
;MLD = $29 $03,$0E,$18,$0E
;MLS = $2A $04,$0F,$19,$0F
;MLW = $2B $05,$10,$1A,$10
;
;MAV = $2C $06,$11,$21,$11
;MAE = $2D $07,$12,$22,$12
;MAT = $2D $08,$13,$1C,$23
;
@checkMulti: cmp #$29
bcc :+
sec
sbc #$29
asl a
asl a
clc
adc editorMultiHintIndex
tax
lda @multiIndexes,x
rts
: ldy editorTmp2
bne :+
lda #$29
: rts
@multiIndexes: .BYTE $03,$0E,$18,$2a
.BYTE $04,$0F,$19,$2a
.BYTE $05,$10,$1A,$2a
.BYTE $06,$11,$21,$2a
.BYTE $07,$12,$22,$2a
.BYTE $08,$13,$1C,$23
auxHintXOffsets:
.BYTE $00,$00,$00, $18,$18,$18, $30,$30,$30, $48,$48
.BYTE $70,$70,$70, $88,$88,$88, $A0,$A0,$A0, $B8,$B8
.BYTE $00,$00, $18,$18,$18, $30,$30
.BYTE $50, $68,$68,$68, $80,$80,$80
.BYTE $A0,$A0,$A0, $B8,$B8
.BYTE $00,$00,$00,$00,$00,$00
auxHintYOffsets:
.BYTE $00,$08,$10, $00,$08,$10, $00,$08,$10, $00,$08
.BYTE $00,$08,$10, $00,$08,$10, $00,$08,$10, $00,$08
.BYTE $28,$30, $28,$30,$38, $28,$30
.BYTE $28, $28,$30,$38, $28,$30,$38
.BYTE $28,$30,$38, $28,$30
.BYTE 240-(17*8)
.BYTE 240-(17*8)
.BYTE 240-(17*8)
.BYTE 240-(17*8)
.BYTE 240-(17*8)
.BYTE 240-(17*8)
.BYTE 240-(17*8)
editorGhostCursor:
ldx #$00
lda editorMode
cmp #EDIT_MODE_TRIGGER_PARAMETER
beq :+
stx SPR16_CHAR
stx SPR17_CHAR
stx SPR18_CHAR
stx SPR19_CHAR
rts
: inx
stx SPR16_CHAR
inx
stx SPR17_CHAR
inx
stx SPR18_CHAR
inx
stx SPR19_CHAR
rts
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------
editorInitCopyInfo:
ldx #$00
stx editorCopyInfoTimer
jsr editorSetPlayBackMessage
rts
editorCheckCopyInfoMessage:
lda editorCopyInfoTimer
beq :+
cmp #$FF
beq :++
dec editorCopyInfoTimer
bne :+
ldx editSongMode
lda @infoModes,x
tax
jsr editorSetPlayBackMessage
lda #procCopyInfoAll
jsr addProcessToBuffer
rts
: lda editSongMode
beq :+
: rts
@infoModes: .BYTE MSG_PTRN,MSG_SONG,MSG_SONG
@printHex: pha
lsr a
lsr a
lsr a
lsr a
clc
adc #$30
sta scnCopyInfoBuffer,y
iny
pla
and #$0F
clc
adc #$30
sta scnCopyInfoBuffer,y
iny
rts
editorSetPlayBackMessage:
lda infoTextIndexes,x
tax
ldy #$00
: lda infoMessages,x
sta scnCopyInfoBuffer,y
inx
iny
cpy #12
bcc :-
rts
editorSetErrorMessage:
pha
lda infoTextIndexes,x
tax
ldy #$00
: lda infoMessages,x
sta scnCopyInfoBuffer,y
inx
iny
cpy #12
bcc :-
pla
sta editorCopyInfoTimer
lda #procCopyInfoAll
jsr addProcessToBuffer
rts
editorSetCopyInfoMessage:
pha
lda infoTextIndexes,x
tax
ldy #$00
: lda infoMessages,x
sta scnCopyInfoBuffer,y
inx
iny
cpy #12
bcc :-
pla
ldy #$04
jsr @printHex
lda #$60
sta editorCopyInfoTimer
lda #procCopyInfoAll
jsr addProcessToBuffer
rts
@printHex: pha
lsr a
lsr a
lsr a
lsr a
clc
adc #$30
sta scnCopyInfoBuffer,y
iny
pla
and #$0F
clc
adc #$30
sta scnCopyInfoBuffer,y
iny
rts
editorSetConfirmMessage:
lda infoTextIndexes,x
tax
ldy #$00
: lda infoMessages,x
sta scnCopyInfoBuffer,y
inx
iny
cpy #12
bcc :-
lda #$FF
sta editorCopyInfoTimer
lda #procCopyInfoAll
jsr addProcessToBuffer
rts
editorSelectSong:
sta editorCurrentSong
sta plyrCurrentSong
tax
lda #WRAM_SONGS
jsr setMMC1r1
lda songSpeedTable,x
sta editorSongSpeedTemp
lda songSwingTable,x
sta editorSongSwingTemp
lda songLoopStartTable,x
sta editorSongLoopStartTemp
lda songLoopLengthTable,x
sta editorSongLoopLengthTemp
rts
editorSelectPattern:
sta editorCurrentPattern
tax
lda #WRAM_PATTERNS
jsr setMMC1r1
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
ldy #$00
lda (editorTmp0),y
sta editorTrackDrum+0
iny
lda (editorTmp0),y
sta editorTrackDrum+1
iny
lda (editorTmp0),y
sta editorTrackDrum+2
iny
lda (editorTmp0),y
sta editorTrackDrum+3
iny
lda (editorTmp0),y
sta editorTrackDrum+4
iny
lda (editorTmp0),y
sta editorTrackDrum+5
iny
lda (editorTmp0),y
sta editorTrackPhrase+0
iny
lda (editorTmp0),y
sta editorTrackPhrase+1
iny
lda (editorTmp0),y
sta editorTrackPhrase+2
iny
lda (editorTmp0),y
sta editorTrackPhrase+3
iny
lda (editorTmp0),y
sta editorTrackPhrase+4
iny
lda (editorTmp0),y
sta editorTrackPhrase+5
iny
lda (editorTmp0),y
sta editorPatternSpeed
iny
lda (editorTmp0),y
sta editorPatternGroove
iny
lda (editorTmp0),y
sta editorPatternSteps
rts
;------------------------------------------------------------------------------
; UTILITY ROUTINES
;------------------------------------------------------------------------------
editorDecodePattern:
lda #$00 ;track counter
sta editorTmp2
: lda editorTmp2
jsr editorDecodePhrase
lda editorTmp2
jsr editorDecodeTrackDrum
inc editorTmp2
lda editorTmp2
cmp #numberOfTracks
bcc :-
jsr editorDecodePatternInfo
rts
editorDecodeTrackDrums:
lda #$00
sta editorTmp2
: lda editorTmp2
jsr editorDecodeTrackDrum
inc editorTmp2
lda editorTmp2
cmp #numberOfTracks
bcc :-
rts
editorDecodePhrase:
pha
tax
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
pla
tax
lda @trackBufferIndexes,x
tax
ldy #$00
: lda (editorTmp0),y
jsr editorDecodeTrigger
sta scnGridBuffer,x
inx
iny
iny
iny
iny
iny
cpy #(stepsPerPhrase * bytesPerPhraseStep)
bcc :-
rts
@trackBufferIndexes:
.REPEAT numberOfTracks,i
.BYTE stepsPerPhrase * i
.ENDREPEAT
editorDecodeTrackDrum:
tay
lda @drumTrackBufferIndex,y
tax
lda editorTrackDrum,y
jsr @printHex
lda editorTrackPhrase,y
jsr @printHex
rts
@printHex: pha
lsr a
lsr a
lsr a
lsr a
sta scnTrackDrumBuffer,x
inx
pla
and #$0F
sta scnTrackDrumBuffer,x
inx
rts
@drumTrackBufferIndex:
.BYTE 0,4,8,12,16,20
.BYTE 2,6,10,14,18,22
editorDecodeTrigger:
bne :++
txa
and #%00000100
beq :+
lda #CHR_EMPTY_GRID_CELL_1
rts
: lda #CHR_EMPTY_GRID_CELL_0
rts
: bmi :+
lda #CHR_GRID_NOTE
rts
: cmp #$FF
beq :+
lda #CHR_GRID_TIE
rts
: lda #CHR_GRID_KILL
rts
editorPrintTrack:
lda @gridTrackProcs,x
jmp addProcessToBuffer
@gridTrackProcs:
.BYTE procGridRow00,procGridRow01,procGridRow02
.BYTE procGridRow03,procGridRow04,procGridRow05
.include "editTrack.asm"
editAdjustDrumSubMode:
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
lda #WRAM_DRUMS
jsr setMMC1r1
ldy #gbl_VoiceSelect
lda (editorTmp0),y
sta editorTmp2
ldx editorDrumSubMode
and @bitMasks,x
bne :+++
ldx #$00
: lda editorTmp2
and @bitMasks,x
beq :+
stx editorDrumSubMode
rts
: inx
cpx #5
bcc :--
: rts
@bitMasks: .BYTE %00000001,%00000010,%00000100,%00001000,%00010000
editClearPhraseUsedTable:
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx #$00
lda #$00
: sta phrasesUsed,x
inx
cpx #numberOfPhrases
bcc :-
rts
editClearPatternUsedTable:
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx #$00
lda #$00
: sta patternsUsed,x
inx
bne :-
rts
editorFindClonePattern:
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx editorSongToCheck
bpl :+++
ldx #$01 ;start at Pattern 1
: lda patternsUsed,x
beq :+
inx
bne :-
sec
rts
: stx editorPatternForClone
clc
rts
: lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp1
ldy #$00
: lda (editorTmp0),y
beq :+
tax
lda #$01
sta patternsUsed,x
: iny
bne :--
dec editorSongToCheck
clc
rts
editorClonePattern:
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx editorCurrentPattern
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
ldx editorPatternForClone
lda patternTableLo,x
sta editorTmp2
lda patternTableHi,x
sta editorTmp3
ldy #$00
: lda (editorTmp0),y
sta (editorTmp2),y
iny
cpy #bytesPerPattern
bcc :-
ldx editorCurrentPattern
ldy editorPatternForClone
lda songEchoSelect,x
sta songEchoSelect,y
lda songEchoLevelA,x
sta songEchoLevelA,y
lda songEchoLevelB,x
sta songEchoLevelB,y
lda songEchoLevelD,x
sta songEchoLevelD,y
lda songEchoDecay,x
sta songEchoDecay,y
lda songEchoSpeed,x
sta songEchoSpeed,y
lda editorPatternForClone
sta editorCurrentPattern
rts
editorFindClonePhrase:
lda editorPatternToCheck+1
beq :+++
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx #$01
: lda phrasesUsed,x
beq :+
inx
cpx #numberOfPhrases
bcc :-
sec
rts
: stx editorPhraseForClone
clc
rts
: lda #$08
sta editorTmp4
: ldx editorPatternToCheck
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
ldy #PATTERN_PHRASE_0
lda (editorTmp0),y
beq :+
tax
lda #$12
sta phrasesUsed,x
: iny
lda (editorTmp0),y
beq :+
tax
lda #$11
sta phrasesUsed,x
: iny
lda (editorTmp0),y
beq :+
tax
lda #$11
sta phrasesUsed,x
: iny
lda (editorTmp0),y
beq :+
tax
lda #$11
sta phrasesUsed,x
: iny
lda (editorTmp0),y
beq :+
tax
lda #$11
sta phrasesUsed,x
: iny
lda (editorTmp0),y
beq :+
tax
lda #$11
sta phrasesUsed,x
:
inc editorPatternToCheck
bne :+
inc editorPatternToCheck+1
: dec editorTmp4
bne :--------
clc
rts
editorFindEmptyPattern:
lda #WRAM_PATTERNS
jsr setMMC1r1
lda #$08
sta editorTmp2
: ldx editorPatternForClone
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
ldy #PATTERN_PHRASE_0
lda (editorTmp0),y
iny
ora (editorTmp0),y
iny
ora (editorTmp0),y
iny
ora (editorTmp0),y
iny
ora (editorTmp0),y
iny
ora (editorTmp0),y
beq :+
inc editorPatternForClone
beq :++
dec editorTmp2
bne :-
clc
rts
: lda #$01
sta editorFoundEmpty
clc
rts
: sec
rts
editorFindEmptyPhrase:
lda editorPhraseForClone
cmp #numberOfPhrases
bcc :+
sec
rts
: lda #$08
sta editorTmp2
: ldx editorPhraseForClone
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
lda phraseBanks,x
jsr setMMC1r1
ldy #$00
: lda (editorTmp0),y
bne :+
iny
iny
iny
iny
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :-
lda #$01
sta editorFoundEmpty
clc
rts
: inc editorPhraseForClone
lda editorPhraseForClone
cmp #numberOfPhrases
bcc :+
sec
rts
: dec editorTmp2
bne :----
clc
rts
editorCheckUpdatePhrases:
ldx cursorY_grid
lda editorTrackPhrase,x
sta editorTmp2
lda #$00
sta editorTmp3
: ldx editorTmp3
lda editorTrackPhrase,x
cmp editorTmp2
bne :+
txa
jsr editorDecodePhrase
ldx editorTmp3
lda @phraseProcs,x
jsr addProcessToBuffer
: inc editorTmp3
lda editorTmp3
cmp #numberOfTracks
bcc :--
rts
@phraseProcs: .BYTE procGridRow00,procGridRow01,procGridRow02
.BYTE procGridRow03,procGridRow04,procGridRow05
;------------------------------------------------------------------------------
; EDIT GRID - set triggers etc.
;------------------------------------------------------------------------------
.include "editGrid.asm"
;------------------------------------------------------------------------------
; EDIT TRIGGER PARAMETERS
;------------------------------------------------------------------------------
editTriggerParameters:
ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda editorWaitForAB
beq :+
jmp @keyWaitAB
: jsr _holdSelectTapA
bcc :+
jsr editorRemapTriggerParameters
jmp @x
: jsr _holdSelect_tapDown ;open edit menu?
bcc :+
ldx #EDIT_GRID_MENU
jsr editorShowEditMenu
lda editorMode
sta editorModeBeforeMenu
lda #EDIT_MODE_GRID_MENU
sta editorMode
jmp @x
: jsr _holdSelect_tapUp
bcc :+
ldx #MSG_CONFIRM
jsr editorSetConfirmMessage
lda #$01
sta editorWaitForAB
jmp @x
: lda keyRepeatA
beq :+++
lda PAD1_dud
ora PAD1_dlr
ora keyRepeatUD
ora keyRepeatLR
beq :++
ldx cursorX_grid
lda editorGridXOffsets,x
tay
lda (editorTmp0),y
beq :++
tya
ldx cursorY_grid
clc
adc editorTriggerIndex,x
tay
jsr editorModifyTriggerParameter
: jsr editorDecodeTriggerParameters
jsr editorPrintTriggers
: jmp @x
: lda keyReleaseB
beq :+++
ldx cursorX_grid
lda editorGridXOffsets,x
ldx cursorY_grid
clc
adc editorTriggerIndex,x
tay
lda editorTriggerIndex,x
beq :++ ;can't clear note
cmp #TRIGGER_INDEX_P1
bcs :+
;clear retrigger
lda #$00
sta (editorTmp0),y
jmp :---
: ;clear mod parameter
sty editorTmp4
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp2
lda drumAddressHi,x
sta editorTmp3
lda editorTriggerIndex,x
clc
adc #mod_Parameter0-2
tay
lda (editorTmp2),y
tay
;dey ;BUG FIX: tapping B on mod paramter would set wrong value
lda (editorTmp2),y
pha
ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
ldy editorTmp4
pla
sta (editorTmp0),y
: jmp :-----
: lda keyReleaseA
beq :+++
ldx cursorY_grid
lda editorTriggerIndex,x
bne :+
lda editorTrackLastNote,x
pha
jmp :++
: lda editorTrackLastTrigger,x
pha
: ldx cursorX_grid
lda editorGridXOffsets,x
ldx cursorY_grid
clc
adc editorTriggerIndex,x
tay
pla
sta (editorTmp0),y
jmp :--------
: lda keyRepeatB
beq :++++
lda PAD1_dud
beq :+++
bpl :+
lda editorMode
sta previousEditorMode
lda #EDIT_MODE_PATTERN_NUMBER
sta editorMode
jmp @x
: lda editorMode
sta previousEditorMode
lda editorTriggerIndex
cmp #$02
bcc :+
sbc #$01
sta editorDrumAuxIndex
lda #EDIT_MODE_DRUM_AUX
sta editorMode
jmp @x
: jsr editAdjustDrumSubMode
lda #EDIT_MODE_DRUM
sta editorMode
jmp @x
: lda PAD1_dlr
beq :++++
bpl :++++
lda #EDIT_MODE_GRID
sta editorMode
jmp @x
: lda PAD1_sel
beq :+
jsr editorMoveAroundGrid
jsr editorUpdateGhostCursor
jmp @x
: ldx cursorY_grid
lda PAD1_dud
clc
adc editorTriggerIndex,x
bpl :+
lda #$00
: cmp #$05
bcs :+
sta editorTriggerIndex,x
: ldx cursorY_grid
lda editorTriggerIndex,x
tax
lda @cursorTableX,x
sta editorCursorX
lda @cursorTableY,x
sta editorCursorY
lda @cursorModes,x
sta editorCursorMode
@x: jsr editorUpdateTriggerIndexCursor
jsr editorUpdateCursor
rts ;jmp editorMainLoop
@cursorTableX: .BYTE TRIGGER_PARAMETER_X_BASE
.BYTE TRIGGER_PARAMETER_X_BASE+8
.BYTE TRIGGER_PARAMETER_X_BASE+8
.BYTE TRIGGER_PARAMETER_X_BASE+8
.BYTE TRIGGER_PARAMETER_X_BASE+8
@cursorTableY: .BYTE TRIGGER_PARAMETER_Y_BASE
.BYTE TRIGGER_PARAMETER_Y_BASE+$08
.BYTE TRIGGER_PARAMETER_Y_BASE+$10
.BYTE TRIGGER_PARAMETER_Y_BASE+$18
.BYTE TRIGGER_PARAMETER_Y_BASE+$20
@cursorModes: .BYTE 3,2,2,2,2
@keyWaitAB:
lda editorWaitForAB
beq :++
lda keyReleaseB
bne :+
lda keyReleaseA
beq :++
jsr editorPasteGrid
: lda #$01
sta editorCopyInfoTimer
lda #$00
sta editorWaitForAB
: rts
editorUpdateGhostCursor:
ldx cursorX_grid
lda @cursorX,x
;sta editorCursorX
sta SPR16_X
sta SPR18_X
clc
adc #$0A
sta SPR17_X
sta SPR19_X
ldx cursorY_grid
lda @cursorY,x
;sta editorCursorY
sta SPR16_Y
sta SPR17_Y
clc
adc #$0A
sta SPR18_Y
sta SPR19_Y
;jsr editorUpdateTriggerIndexCursor
;jsr editorUpdateCursor
rts
@cursorX: .REPEAT colsPerGrid,i
.BYTE GRID_CURSOR_X_BASE + (i * 8)
.ENDREPEAT
@cursorY: .REPEAT rowsPerGrid,i
.BYTE GRID_CURSOR_Y_BASE + (i * 8)
.ENDREPEAT
editorModifyTriggerParameter:
;sty editorTmp3
;ldx cursorX_grid
;lda editorGridXOffsets,x
;ldx cursorY_grid
;clc
;adc editorTriggerIndex,x
;tay
ldx cursorY_grid
lda editorTriggerIndex,x
cmp #TRIGGER_INDEX_NOTE
bne :+++++++
;modify note
swapSign PAD1_dud
swapSign keyRepeatUD
lda PAD1_dlr
ora keyRepeatLR
sta editorTmp3
bne :++
ldx #$0C
lda PAD1_dud
ora keyRepeatUD
beq :+++
bpl :+
ldx #$F4
: stx editorTmp3
: lda keyRepeatB
bne :++
;jsr @modNote
jsr editorModNote
ldx cursorY_grid
and #$7F
;sta editorTrackLastNote,x ;BUG FIX - modifying note can go lower than lowest (A#1)
: rts
: ldy #$00
: lda (editorTmp0),y
beq :+
;jsr @modNote
jsr editorModNote
: iny
iny
iny
iny
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :--
rts
;modify parameter
: swapSign PAD1_dud
swapSign keyRepeatUD
lda PAD1_dud
ora keyRepeatUD
asl a
asl a
asl a
asl a
sta editorTmp2
lda keyRepeatB
bne :+
jsr @modParameter
rts
: ldx cursorY_grid
lda editorTriggerIndex,x
tay
: jsr @modParameter
iny
iny
iny
iny
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :-
rts
@modParameter:
lda PAD1_dlr
ora keyRepeatLR
clc
adc (editorTmp0),y
clc
adc editorTmp2
sta (editorTmp0),y
sta editorTrackLastTrigger,x
rts
editorModNote:
lda (editorTmp0),y
pha
and #$80
sta editorTmp2
pla
and #$7F
clc
adc editorTmp3
bmi :+
beq :+
cmp #numberOfNotes
bcs :+
ldx cursorY_grid
sta editorTrackLastNote,x
ora editorTmp2
sta (editorTmp0),y
: rts
editorDecodeTriggerParameters:
ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
ldx cursorX_grid
lda editorGridXOffsets,x
tay
lda (editorTmp0),y ;note?
beq :+
cmp #$FF
beq :+
and #$7F
tax
lda noteOctaves,x
pha
lda noteAccidentals,x
pha
lda noteNames,x
sta scnTriggerBuffer+0
pla
sta scnTriggerBuffer+1
pla
sta scnTriggerBuffer+2
ldx #$03
iny
lda (editorTmp0),y ;retrigger
jsr @printHex
iny
lda (editorTmp0),y ;p1
jsr @printHex
iny
lda (editorTmp0),y ;p2
jsr @printHex
iny
lda (editorTmp0),y ;p3
jsr @printHex
rts
: ldx #$00
lda #NONE
: sta scnTriggerBuffer,x
inx
cpx #$0B
bcc :-
rts
@printHex:
pha
lsr a
lsr a
lsr a
lsr a
sta scnTriggerBuffer,x
inx
pla
and #$0F
sta scnTriggerBuffer,x
inx
rts
noteNames: .BYTE $00
;.BYTE NOTE_A,NOTE_A,NOTE_B
.BYTE NOTE_A,NOTE_B
.REPEAT 8
.BYTE NOTE_C,NOTE_C,NOTE_D,NOTE_D,NOTE_E,NOTE_F,NOTE_F,NOTE_G,NOTE_G,NOTE_A,NOTE_A,NOTE_B
.ENDREPEAT
noteOctaves: .BYTE $00
;.BYTE OCT_1,OCT_1,OCT_1
.BYTE OCT_1,OCT_1
.REPEAT 12
.BYTE OCT_2
.ENDREPEAT
.REPEAT 12
.BYTE OCT_3
.ENDREPEAT
.REPEAT 12
.BYTE OCT_4
.ENDREPEAT
.REPEAT 12
.BYTE OCT_5
.ENDREPEAT
.REPEAT 12
.BYTE OCT_6
.ENDREPEAT
.REPEAT 12
.BYTE OCT_7
.ENDREPEAT
.REPEAT 12
.BYTE OCT_8
.ENDREPEAT
.REPEAT 12
.BYTE OCT_9
.ENDREPEAT
noteAccidentals:
.BYTE $00
;.BYTE NONE,SHARP,NONE
.BYTE SHARP,NONE
.REPEAT 8
.BYTE NONE,SHARP,NONE,SHARP,NONE,NONE,SHARP,NONE,SHARP,NONE,SHARP,NONE
.ENDREPEAT
editorPrintTriggers:
lda #procTrigger
jsr addProcessToBuffer
rts
;------------------------------------------------------------------------------
; DRUM EDITOR
;------------------------------------------------------------------------------
editDrum:
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda editorWaitForAB
beq :+
jmp @keyWaitAB
: lda keyRepeatSelect
beq :+++
lda PAD1_dud
beq :+++
bmi :+
;edit menu
ldx #EDIT_DRUM_MENU
jsr editorShowEditMenu
lda editorMode
sta editorModeBeforeMenu
lda #EDIT_MODE_DRUM_MENU
sta editorMode
jmp @x
: ;jsr editorPasteDrum
lda editCopyBuffer
cmp #COPY_ID_DRUM
bne :+
ldx #MSG_PASTE
jsr editorSetConfirmMessage
lda #$01
sta editorWaitForAB
jmp @x
: ldx #MSG_PASTE_ERROR
lda #$60
jsr editorSetErrorMessage
jmp @x
: ldx editorDrumSubMode
lda @parameterMapIndexStart,x
sta cursorDrumMin
lda @parameterMapIndexEnd,x
sta cursorDrumMax
lda cursorDrumMin
cmp editorSubModeIndexes,x
bcc :+
sta editorSubModeIndexes,x
:
lda keyRepeatB
beq :+++
lda PAD1_dud
beq :++
bpl :+
;lda #EDIT_MODE_GRID
lda previousEditorMode
sta editorMode
jmp @x
: lda #EDIT_MODE_DRUM_AUX
sta editorMode
jmp @x
: lda PAD1_dlr
beq :+
clc
adc editorDrumSubMode
bmi :+
cmp #5
bcs :+
sta editorDrumSubMode
jmp @x
: ldx editorDrumSubMode
lda editorSubModeIndexes,x
tax
lda @parameterMap,x
tay
lda keyReleaseB
beq :+
lda EMPTY_DRUM_DEFINITION,y
sta (editorTmp0),y
jmp @y
: lda keyReleaseA
beq :+
lda lastDrumParameterValue
sta (editorTmp0),y
jmp @y
: lda PAD1_firea
ora PAD1_fireb
bne @noMovement
ldx editorDrumSubMode
lda PAD1_dlr
ora keyRepeatLR
sta editorTmp2
beq :+++
lda editorSubModeIndexes,x
: clc
adc editorTmp2
bmi :++
cmp cursorDrumMin
bcc :++
cmp cursorDrumMax
bcs :++
tay
lda @parameterMap,y
cmp #$FF
bne :+
tya
jmp :-
: tya
sta editorSubModeIndexes,x
: lda PAD1_dud
;ora keyRepeatUD
asl a
asl a
sta editorTmp2
beq :+++
lda editorSubModeIndexes,x
: clc
adc editorTmp2
bmi :++
cmp cursorDrumMin
bcc :++
cmp cursorDrumMax
bcs :++
tay
lda @parameterMap,y
cmp #$FF
bne :+
tya
jmp :-
: tya
sta editorSubModeIndexes,x
jmp @x
:
@noMovement:
ldx editorDrumSubMode
lda editorSubModeIndexes,x
tax
lda @parameterMap,x
tay
lda keyReleaseSelect
beq :+
lda PAD1_fireb
bne :+
ldy #gbl_VoiceSelect
bne :++
: lda keyRepeatA
beq :++
cpy #gbl_VoiceSelect
bne :+++
lda PAD1_dud
ora PAD1_dlr
beq :++
: lda (editorTmp0),y
and #%00011111
ldx editorDrumSubMode
eor SET_BITS,x
sta (editorTmp0),y
: jmp @y
: swapSign PAD1_dud
swapSign keyRepeatUD
lda PAD1_dud
ora keyRepeatUD
cpy #osc_A_Coarse
beq :+
cpy #osc_B_Coarse
beq :+
cpy #osc_C_Coarse
beq :+
asl a
asl a
asl a
asl a
jmp :++
: asl a ; x 12 for coarse pitch
asl a
sta editorTmp2
asl a
clc
adc editorTmp2
: sta editorTmp2
lda PAD1_dlr
ora keyRepeatLR
sta editorTmp3
lda editorTmp2
ora editorTmp3
beq :++++
cpy #env_A_Volume
beq :+
cpy #env_A_Env
beq :+
cpy #env_B_Volume
beq :+
cpy #env_B_Env
beq :+
cpy #env_D_Volume
beq :+
cpy #env_D_Env
bne :++
: lda (editorTmp0),y
clc
adc editorTmp3
and #$0F
sta editorTmp3
lda (editorTmp0),y
and #$F0
clc
adc editorTmp2
ora editorTmp3
sta (editorTmp0),y
sta lastDrumParameterValue
jmp :++
: lda (editorTmp0),y
clc
adc editorTmp2
clc
adc editorTmp3
sta (editorTmp0),y
sta lastDrumParameterValue
: lda editorDrumSubMode
jsr editorDecodeDrumVoice
ldx editorDrumSubMode
lda @drumProcs,x
jsr addProcessToBuffer
: ldx editorDrumSubMode
lda editorSubModeIndexes,x
tax
lda #DRUM_CURSOR_X_BASE
clc
adc @drumCursorXOffsets,x
sta editorCursorX
lda #DRUM_CURSOR_Y_BASE
clc
adc @drumCursorYOffsets,x
sta editorCursorY
lda @drumCursorModes,x
sta editorCursorMode
@x: jsr editorUpdateCursor
rts ;jmp editorMainLoop
@y: lda editorDrumSubMode
jsr editorDecodeDrumVoice
ldx editorDrumSubMode
lda @drumProcs,x
jsr addProcessToBuffer
jmp :-
@keyWaitAB:
lda editorWaitForAB
beq :++
lda keyReleaseB
bne :+
lda keyReleaseA
beq :++
jsr editorPasteDrum
: lda #$01
sta editorCopyInfoTimer
lda #$00
sta editorWaitForAB
: rts
@drumProcs: .BYTE procVoiceA,procVoiceB,procVoiceC,procVoiceD,procVoiceE
.BYTE procDrumAux
@drumCursorModes:
.BYTE $02,$02,$02,$02
.BYTE $02,$02,$02,$02
.BYTE $02,$02,$02,$03
.BYTE $02,$02,$02,$02
.BYTE $02,$02,$02,$02
.BYTE $02,$02,$02,$03
.BYTE $02,$02,$02,$02
.BYTE $02,$02,$02,$02
.BYTE $02,$02,$03,$02
.BYTE $02,$02,$02,$02
.BYTE $02,$02,$02,$02
.BYTE $03,$02,$02,$02
.BYTE $02,$02,$02,$02
.BYTE $02,$02,$02,$02
.BYTE $02,$03,$02,$02
@parameterMap:
.BYTE $00,$03,$06,$09
.BYTE $01,$04,$07,$0A
.BYTE $02,$05,$08,gbl_VoiceSelect
.BYTE $0B,$0E,$11,$14
.BYTE $0C,$0F,$12,$15
.BYTE $0D,$10,$13,gbl_VoiceSelect
.BYTE $16,$18,$1B,$FF
.BYTE $17,$19,$1C,$FF
.BYTE $FF,$1A,gbl_VoiceSelect,$FF
.BYTE $1D, $1E,$21,$FF
.BYTE $FF, $1F,$22,$FF
.BYTE gbl_VoiceSelect,$20,$23,$FF
; .BYTE $1D,$20,$23,$FF
; .BYTE $1E,$21,$FF,$FF
; .BYTE $1F,$22,gbl_VoiceSelect,$FF
.BYTE $24,$27,$FF,$FF
.BYTE $25,$28,$FF,$FF
.BYTE $26,gbl_VoiceSelect,$FF,$FF
@parameterMapIndexStart:
.BYTE 0,12,24,36,48
@parameterMapIndexEnd:
.BYTE 12,24,36,48,60
@drumCursorXOffsets:
.BYTE $00,$18,$30,$48
.BYTE $00,$18,$30,$48
.BYTE $00,$18,$30,$41
.BYTE $70,$88,$A0,$B8
.BYTE $70,$88,$A0,$B8
.BYTE $70,$88,$A0,$B1
.BYTE $00,$18,$30,$FF
.BYTE $00,$18,$30,$FF
.BYTE $FF,$18,$29,$FF
.BYTE $50,$68,$80,$FF
.BYTE $FF,$68,$80,$FF
.BYTE $49,$68,$80,$FF
; .BYTE $50,$68,$80,$FF
; .BYTE $50,$68,$FF,$FF
; .BYTE $50,$68,$79,$FF
.BYTE $A0,$B8,$FF,$FF
.BYTE $A0,$B8,$FF,$FF
.BYTE $A0,$B1,$FF,$FF
@drumCursorYOffsets:
.BYTE $00,$00,$00,$00
.BYTE $08,$08,$08,$08
.BYTE $10,$10,$10,$11
.BYTE $00,$00,$00,$00
.BYTE $08,$08,$08,$08
.BYTE $10,$10,$10,$11
.BYTE $28,$28,$28,$FF
.BYTE $30,$30,$30,$FF
.BYTE $FF,$38,$39,$FF
.BYTE $28,$28,$28,$FF
.BYTE $FF,$30,$30,$FF
.BYTE $39,$38,$38,$FF
; .BYTE $28,$28,$28,$FF
; .BYTE $30,$30,$FF,$FF
; .BYTE $38,$38,$39,$FF
.BYTE $28,$28,$FF,$FF
.BYTE $30,$30,$FF,$FF
.BYTE $38,$39,$FF,$FF
editorDecodeDrum:
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
lda #WRAM_DRUMS
jsr setMMC1r1
lda #$00
sta editorTmp3 ;all voices
lda editorTmp3
: jsr editorDecodeDrumVoice
inc editorTmp3
lda editorTmp3
cmp #voicesPerDrum
bcc :-
jsr editorDecodeDrumAux
rts
editorDecodeDrumAux:
lda editorCurrentDrum
ldx #$00
jsr @printHex
ldy #gbl_DrumName
lda (editorTmp0),y
tax
lda editorDrumNameTranslate,x
sta scnDrumAuxBuffer+2
iny
lda (editorTmp0),y
tax
lda editorDrumNameTranslate,x
sta scnDrumAuxBuffer+3
iny
lda (editorTmp0),y
tax
lda editorDrumNameTranslate,x
sta scnDrumAuxBuffer+4
iny
lda (editorTmp0),y
bpl :+
ldx #(parameterNamesEnd-parameterNames)
bne :++
: sta editorTmp2
asl a
clc
adc editorTmp2
tax
: lda parameterNames+0,x
sta scnDrumAuxBuffer+5
lda parameterNames+1,x
sta scnDrumAuxBuffer+6
lda parameterNames+2,x
sta scnDrumAuxBuffer+7
iny
lda (editorTmp0),y
bpl :+
ldx #(parameterNamesEnd-parameterNames)
bne :++
: sta editorTmp2
asl a
clc
adc editorTmp2
tax
: lda parameterNames+0,x
sta scnDrumAuxBuffer+8
lda parameterNames+1,x
sta scnDrumAuxBuffer+9
lda parameterNames+2,x
sta scnDrumAuxBuffer+10
iny
lda (editorTmp0),y
bpl :+
ldx #(parameterNamesEnd-parameterNames)
bne :++
: sta editorTmp2
asl a
clc
adc editorTmp2
tax
: lda parameterNames+0,x
sta scnDrumAuxBuffer+11
lda parameterNames+1,x
sta scnDrumAuxBuffer+12
lda parameterNames+2,x
sta scnDrumAuxBuffer+13
rts
@printHex: pha
lsr a
lsr a
lsr a
lsr a
clc
adc #$30
sta scnDrumAuxBuffer,x
inx
pla
and #$0F
clc
adc #$30
sta scnDrumAuxBuffer,x
inx
rts
editorDecodeDrumVoice:
tax
ldy #bytesPerDrum-1
lda (editorTmp0),y
ldy #SPR_VOICE_OFF
and SET_BITS,x
beq :+
iny
: tya
pha
lda @spriteIndex,x
tay
pla
sta SPR05_CHAR,y
lda @drumVoiceStartIndex,x
tay
lda @drumVoiceEndIndex,x
sta editorTmp2
lda @drumVoiceBufferOffsets,x
tax
: lda (editorTmp0),y
jsr @printHex
iny
cpy editorTmp2
bcc :-
rts
@spriteIndex: .BYTE $00,$04,$08,$0C,$10
@printHex: pha
lsr a
lsr a
lsr a
lsr a
sta scnVoiceABuffer,x
inx
pla
and #$0F
sta scnVoiceABuffer,x
inx
rts
@drumVoiceStartIndex:
.BYTE $00,$0B,$16,$1D,$24
@drumVoiceEndIndex:
.BYTE $0B,$16,$1D,$24,$29
@drumVoiceBufferOffsets:
.BYTE 0, 22, 44, 58, 72, 82
editorPrintDrum:
lda #procVoiceA
jsr addProcessToBuffer
lda #procVoiceB
jsr addProcessToBuffer
lda #procVoiceC
jsr addProcessToBuffer
lda #procVoiceD
jsr addProcessToBuffer
lda #procVoiceE
jsr addProcessToBuffer
lda #procDrumAux
jsr addProcessToBuffer
rts
drumAddressLo:
.REPEAT numberOfDrums,i
.LOBYTES drums+(bytesPerDrum * i)
.ENDREPEAT
drumAddressHi:
.REPEAT numberOfDrums,i
.HIBYTES drums+(bytesPerDrum * i)
.ENDREPEAT
;------------------------------------------------------------------------------
; EDIT DRUM AUX
;------------------------------------------------------------------------------
editDrumAux:
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
lda editorWaitForAB
beq :+
jmp @keyWaitAB
: jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda keyRepeatSelect
beq :+++
lda PAD1_dud
beq :+++
bmi :+
;edit menu
ldx #EDIT_DRUM_MENU
jsr editorShowEditMenu
lda editorMode
sta editorModeBeforeMenu
lda #EDIT_MODE_DRUM_MENU
sta editorMode
jmp @x
: lda editCopyBuffer
cmp #COPY_ID_DRUM
bne :+
;jsr editorPasteDrum
ldx #MSG_PASTE
jsr editorSetCopyInfoMessage
lda #$01
sta editorWaitForAB
jmp @x
: ldx #MSG_PASTE_ERROR
lda #$60
jsr editorSetErrorMessage
jmp @x
: jsr @modifyValues
lda editorEditDrumName
bne @x
lda keyRepeatB
beq :+
lda PAD1_dud
beq :+
bpl :+
lda #EDIT_MODE_DRUM
sta editorMode
jmp @x
: lda PAD1_firea
ora PAD1_fireb
bne :++
lda PAD1_dlr
clc
adc editorDrumAuxIndex
bmi :+
cmp #$04
bcs :+
sta editorDrumAuxIndex
: jmp @x
: lda PAD1_sel
beq :+
lda PAD1_dlr
beq :+
clc
adc editorCurrentDrum
bmi :+
cmp #numberOfDrums
bcs :+
sta editorCurrentDrum
jsr editorDecodeDrum
jsr editorPrintDrum
jmp @x
:
@x: lda editorEditDrumName
bne :+
ldx editorDrumAuxIndex
lda #DRUM_AUX_CURSOR_X_BASE
clc
adc @cursorX,x
sta editorCursorX
lda #DRUM_AUX_CURSOR_Y_BASE
clc
adc @cursorY,x
sta editorCursorY
lda @cursorMode,x
sta editorCursorMode
:
jsr editorUpdateCursor
rts ;jmp editorMainLoop
@cursorX: .BYTE $28,$50,$78,$A0
@cursorY: .BYTE $00,$00,$00,$00
@cursorMode: .BYTE $03,$03,$03,$03
@nameX: .BYTE $00,$28,$30,$38
@modifyValues:
lda editorDrumAuxIndex
beq :+
jmp :+++++++
;edit drum name
: lda editorEditDrumName
bne :++
lda keyReleaseA
bne :+
rts
: lda #$01
sta editorEditDrumName
lda #$00
sta keyReleaseA
: clc
adc #gbl_DrumName-1
tay
lda #$05
sta editorCursorMode
lda keyRepeatUD
ora PAD1_dud
beq :+
clc
adc (editorTmp0),y
bmi :+
cmp #editorDrumNameTranslateEnd-editorDrumNameTranslate
bcs :+
sta (editorTmp0),y
jsr editorDecodeDrumAux
lda #procDrumAux
jsr addProcessToBuffer
rts
: lda keyReleaseA
beq :+
lda #$00
sta editorEditDrumName
lda @cursorMode+0
sta editorCursorMode
jsr editorDecodeTrackDrums
lda #procTrackDrumAll
jsr addProcessToBuffer
lda #WRAM_DRUMS
jsr setMMC1r1
rts
: lda PAD1_dlr
beq :+
clc
adc editorEditDrumName
beq :+
cmp #$04
bcs :+
sta editorEditDrumName
: ldx editorEditDrumName
lda @nameX,x
clc
adc #DRUM_AUX_CURSOR_X_BASE
sta editorCursorX
lda #DRUM_AUX_CURSOR_Y_BASE
sta editorCursorY
rts
;EDIT TRIGGER PARAMETERS
:
jsr _holdSelectTapA
bcc :+
jsr editorRemapTriggerParameters
rts ;jmp :+++++
: lda editorDrumAuxIndex
clc
adc #mod_Parameter0-1
tay
lda keyReleaseB
beq :+
lda (editorTmp0),y
eor #$80
sta (editorTmp0),y
jmp :+++++
: lda keyRepeatA
beq :+++++
lda PAD1_dud
ora keyRepeatUD
sta editorTmp2
bne :++
lda PAD1_dlr
beq :+++++
bmi :+
lda (editorTmp0),y
and #$7F
tax
lda @modForwards,x
jmp :+++
: lda (editorTmp0),y
and #$7F
tax
lda @modBackwards,x
jmp :++
: lda (editorTmp0),y
and #$7F
clc
adc editorTmp2
bmi :++
cmp #((parameterNamesEnd-parameterNames) / 3)
bcs :++
: sta (editorTmp0),y
: jsr editorDecodeDrumAux
lda #procDrumAux
jsr addProcessToBuffer
: rts
@modForwards: .BYTE $01
.BYTE $0C,$0C,$0C,$0C,$0C,$0C,$0C,$0C,$0C,$0C,$0C
.BYTE $17,$17,$17,$17,$17,$17,$17,$17,$17,$17,$17
.BYTE $1E,$1E,$1E,$1E,$1E,$1E,$1E
.BYTE $25,$25,$25,$25,$25,$25,$25
.BYTE $25,$25,$25,$25,$25
@modBackwards: .BYTE $00
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.BYTE $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01
.BYTE $0C,$0C,$0C,$0C,$0C,$0C,$0C
.BYTE $17,$17,$17,$17,$17,$17,$17
.BYTE $1E,$1E,$1E,$1E,$1E,$1E,$1E
@keyWaitAB:
lda editorWaitForAB
beq :++
lda keyReleaseB
bne :+
lda keyReleaseA
beq :++
jsr editorPasteDrum
: lda #$01
sta editorCopyInfoTimer
lda #$00
sta editorWaitForAB
: rts
editorRemapTriggerParameters:
;get current mod parameter number and value (from drum)
;scan current track, when a note is found replace mod parameter value
;need to do this from drum aux editor and grid/trigger editor
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
lda editorMode
cmp #EDIT_MODE_TRIGGER_PARAMETER
beq :+
cmp #EDIT_MODE_GRID
beq :+
lda editorDrumAuxIndex
beq @x
sta editorTmp2 ;contains 1 to 3 = parameter number
clc
adc #mod_Parameter0-1 ;+1? for 0 offset
tay
lda (editorTmp0),y
tay
cpy #gbl_DrumName
bcs @x
lda (editorTmp0),y
sta editorTmp3 ;value
dec editorTmp2 ;adust 0 - 2
jmp :++
: ldx cursorY_grid
lda editorTriggerIndex,x ;editing trigger/grid
cmp #$02
bcc @x
sec
sbc #$02
sta editorTmp2
clc
adc #mod_Parameter0
tay
lda (editorTmp0),y
tay
cpy #gbl_DrumName
bcs @x
lda (editorTmp0),y
sta editorTmp3
: ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
ldy #$00
: lda (editorTmp0),y
beq :+
cmp #$FF
beq :+
tya
pha ;save y index
iny
iny ;move index to first mod parameter
tya
clc
adc editorTmp2 ;add trigger index to get right one
tay
lda editorTmp3 ;write value to trigger
sta (editorTmp0),y
pla
tay ;restore Y
: iny
iny
iny
iny
iny
cpy #(16*5);stepsPerPhrase * bytesPerPhraseStep
bcc :--
lda #trackWipeSpeed
sta editorTrackWipeSpeed
jsr editorDecodeTriggerParameters
jsr editorPrintTriggers
@x: rts
_holdSelectTapA:
clc
lda PAD1_sel
beq :+
lda keyReleaseA
beq :+
sec
: rts
_holdSelect_tapDown:
clc
lda PAD1_sel
beq :+
lda PAD1_dud
beq :+
bmi :+
sec
: rts
_holdSelect_tapUp:
clc
lda PAD1_sel
beq :+
lda PAD1_dud
beq :+
bpl :+
sec
: rts
editorReorderTracks:
lda #WRAM_PATTERNS
jsr setMMC1r1
lda PAD1_dud
bne :+
@x2: rts
: clc
adc cursorY_grid ;trying to move track off top/bottom of grid
bmi @x2 ;so return
cmp #$06
bcs @x2
sta editorTmp4 ;dest
ldx cursorY_grid ;swap phrase and drum assignments
ldy editorTmp4
lda editorTrackPhrase,x
pha
lda editorTrackPhrase,y
sta editorTrackPhrase,x
pla
sta editorTrackPhrase,y
lda editorTrackDrum,x
pha
lda editorTrackDrum,y
sta editorTrackDrum,x
pla
sta editorTrackDrum,y
ldx editorCurrentPattern
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
ldy #PATTERN_DRUM_0
: lda editorTrackDrum,y
sta (editorTmp0),y
iny
cpy #bytesPerPattern
bcc :-
lda cursorY_grid
sta editorTmp5 ;old cursor Y
lda editorTmp4 ;new cursor Y
sta cursorY_grid
;reorder mutes
lda editorSoloChannel
bmi :++
cmp cursorY_grid
bne :+
lda editorTmp5
sta editorSoloChannel
jmp :+
: cmp editorTmp5
bne :+
lda cursorY_grid
sta editorSoloChannel
:
ldx cursorY_grid ;reorder solo
ldy editorTmp5
lda editorChannelStatus,x
pha
lda editorChannelStatus,y
sta editorChannelStatus,x
pla
sta editorChannelStatus,y
lda cursorY_grid
jsr editorDecodePhrase
lda editorTmp5
jsr editorDecodePhrase
lda cursorY_grid
jsr editorDecodeTrackDrum
lda editorTmp5
jsr editorDecodeTrackDrum
jsr editorDecodeTriggerParameters
ldx editorTmp4
jsr editorPrintTrack
ldx editorTmp5
jsr editorPrintTrack
jsr editorPrintTriggers
lda #procTrackDrumAll
jsr addProcessToBuffer
jsr editorPrintDrum
lda #$01
sta editorForceTrackLoad
ldx cursorY_grid
lda @cursorY,x
sta editorCursorY
@x: rts
@cursorY: .REPEAT rowsPerGrid,i
.BYTE TRACK_CURSOR_Y_BASE + (i * 8)
.ENDREPEAT
editorShiftTrackRight:
ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
clc
adc #<(stepsPerPhrase-2)*bytesPerPhraseStep
sta editorTmp0
lda phraseTableHi,x
adc #>(stepsPerPhrase-2)*bytesPerPhraseStep
sta editorTmp1
lda phraseTableLo,x
clc
adc #<(stepsPerPhrase-1)*bytesPerPhraseStep
sta editorTmp2
lda phraseTableHi,x
adc #>(stepsPerPhrase-1)*bytesPerPhraseStep
sta editorTmp3
;do 15 times
lda #stepsPerPhrase-1
sta editorTmp4 ;count
ldy #$00 ;save last step
lda (editorTmp2),y
pha
iny
lda (editorTmp2),y
pha
iny
lda (editorTmp2),y
pha
iny
lda (editorTmp2),y
pha
iny
lda (editorTmp2),y
pha
: ldy #$00 ;move 5 bytes to right
lda (editorTmp0),y
sta (editorTmp2),y
iny
lda (editorTmp0),y
sta (editorTmp2),y
iny
lda (editorTmp0),y
sta (editorTmp2),y
iny
lda (editorTmp0),y
sta (editorTmp2),y
iny
lda (editorTmp0),y
sta (editorTmp2),y
lda editorTmp0 ;move pointers to previous step
sec
sbc #bytesPerPhraseStep
sta editorTmp0
lda editorTmp1
sbc #$00
sta editorTmp1
lda editorTmp2
sec
sbc #bytesPerPhraseStep
sta editorTmp2
lda editorTmp3
sbc #$00
sta editorTmp3
dec editorTmp4
bne :-
;At this point, Tmp0/Tmp1 should point to first step
ldy #bytesPerPhraseStep-1 ;move last step to first step
pla
sta (editorTmp2),y
dey
pla
sta (editorTmp2),y
dey
pla
sta (editorTmp2),y
dey
pla
sta (editorTmp2),y
dey
pla
sta (editorTmp2),y
;lda cursorY_grid ;print track
;jsr editorDecodePhrase
;ldx cursorY_grid
;jsr editorPrintTrack
jsr editorCheckUpdatePhrases
jsr editorDecodeTriggerParameters
jsr editorPrintTriggers
rts
editorShiftTrackLeft:
ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
lda phraseTableLo,x
clc
adc #bytesPerPhraseStep
sta editorTmp2
lda phraseTableHi,x
adc #$00
sta editorTmp3
;do 15 times
lda #stepsPerPhrase-1
sta editorTmp4 ;count
ldy #$00 ;save last step
lda (editorTmp0),y
pha
iny
lda (editorTmp0),y
pha
iny
lda (editorTmp0),y
pha
iny
lda (editorTmp0),y
pha
iny
lda (editorTmp0),y
pha
: ldy #$00 ;move 5 bytes to right
lda (editorTmp2),y
sta (editorTmp0),y
iny
lda (editorTmp2),y
sta (editorTmp0),y
iny
lda (editorTmp2),y
sta (editorTmp0),y
iny
lda (editorTmp2),y
sta (editorTmp0),y
iny
lda (editorTmp2),y
sta (editorTmp0),y
lda editorTmp0 ;move pointers to previous step
clc
adc #bytesPerPhraseStep
sta editorTmp0
lda editorTmp1
adc #$00
sta editorTmp1
lda editorTmp2
clc
adc #bytesPerPhraseStep
sta editorTmp2
lda editorTmp3
adc #$00
sta editorTmp3
dec editorTmp4
bne :-
;At this point, Tmp0/Tmp1 should point to first step
ldy #bytesPerPhraseStep-1 ;move last step to first step
pla
sta (editorTmp0),y
dey
pla
sta (editorTmp0),y
dey
pla
sta (editorTmp0),y
dey
pla
sta (editorTmp0),y
dey
pla
sta (editorTmp0),y
;lda cursorY_grid ;print track
;jsr editorDecodePhrase
;ldx cursorY_grid
;jsr editorPrintTrack
jsr editorCheckUpdatePhrases
jsr editorDecodeTriggerParameters
jsr editorPrintTriggers
rts
editorEditGridMenu:
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda #$04
sta editorCursorMode
lda keyReleaseB ;cancel
beq :+
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
lda #$00
sta cursorY_editMenu
jmp @x
: lda keyReleaseA
beq :+
ldx cursorY_editMenu
lda @jumpTableLo,x
sta jumpVector
lda @jumpTableHi,x
sta jumpVector+1
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
jmp (jumpVector)
: lda cursorY_editMenu
clc
adc PAD1_dud
bmi :+
cmp #$04
bcs :+
sta cursorY_editMenu
:
@x: ldx cursorY_editMenu
lda @cursorX,x
clc
adc #GRID_CURSOR_X_BASE
sta editorCursorX
lda @cursorY,x
clc
adc #GRID_CURSOR_Y_BASE
sta editorCursorY
jsr editorUpdateCursor
rts
@cursorX: .BYTE $28,$28,$28,$28
@cursorY: .BYTE $08,$10,$18,$20
@jumpTableLo: .LOBYTES editorCopyPhrase,editorCopyPattern,editorCutPhrase,editorCutPattern
@jumpTableHi: .HIBYTES editorCopyPhrase,editorCopyPattern,editorCutPhrase,editorCutPattern
editorClearMenu:
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda editorWaitForAB
beq :+
jmp @keyWaitAB
: lda #$04
sta editorCursorMode
lda keyReleaseB ;cancel
beq :+
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
lda #$00
sta cursorY_editMenu
jmp @x
: lda keyReleaseA
beq :+
ldx #MSG_CONFIRM
;show confirmation
jsr editorSetConfirmMessage
lda #$01
sta editorWaitForAB
jmp @x
: lda cursorY_editMenu
clc
adc PAD1_dud
bmi :+
cmp #$05
bcs :+
sta cursorY_editMenu
:
@x: ldx cursorY_editMenu
lda @cursorX,x
clc
adc #GRID_CURSOR_X_BASE
sta editorCursorX
lda @cursorY,x
clc
adc #GRID_CURSOR_Y_BASE
sta editorCursorY
jsr editorUpdateCursor
rts
@keyWaitAB:
lda editorWaitForAB
beq :++
lda keyReleaseB
bne :+
lda keyReleaseA
beq :++
lda #$01 ;A = select
sta editorCopyInfoTimer
lda #$00
sta editorWaitForAB
ldx cursorY_editMenu
lda @jumpTableLo,x
sta jumpVector
lda @jumpTableHi,x
sta jumpVector+1
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
lda #PLAY_MODE_STOPPED ;stop playback always
sta plyrMode
sta plyrModeOld
jmp (jumpVector)
: lda #$01 ;B = cancel
sta editorCopyInfoTimer
lda #$00
sta editorWaitForAB
: rts
@cursorX: .BYTE $28,$28,$28,$28,$28
@cursorY: .BYTE $08,$10,$18,$20,$28
@jumpTableLo: .LOBYTES menuWipeSongs,menuWipePatterns,menuWipePhrases,menuWipeDrums,editorWipeAll
@jumpTableHi: .HIBYTES menuWipeSongs,menuWipePatterns,menuWipePhrases,menuWipeDrums,editorWipeAll
editorEditDrumMenu:
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda #$04
sta editorCursorMode
lda keyReleaseB ;cancel
beq :+
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
lda #$00
sta cursorY_editMenu
jmp @x
: lda keyReleaseA
beq :+
ldx cursorY_editMenu
lda @jumpTableLo,x
sta jumpVector
lda @jumpTableHi,x
sta jumpVector+1
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
jmp (jumpVector)
: lda cursorY_editMenu
clc
adc PAD1_dud
bmi :+
cmp #$03
bcs :+
sta cursorY_editMenu
:
@x: ldx cursorY_editMenu
lda @cursorX,x
clc
adc #GRID_CURSOR_X_BASE
sta editorCursorX
lda @cursorY,x
clc
adc #GRID_CURSOR_Y_BASE
sta editorCursorY
jsr editorUpdateCursor
rts
@cursorX: .BYTE $28,$28,$28,$28
@cursorY: .BYTE $08,$10,$18,$20
@jumpTableLo: .LOBYTES editorCopyDrum,editorCutDrum,editorSwapAB
@jumpTableHi: .HIBYTES editorCopyDrum,editorCutDrum,editorSwapAB
editorSwapAB:
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
ldy #$00
: lda (editorTmp0),y
pha
iny
cpy #osc_B_Coarse
bcc :-
: lda (editorTmp0),y
pha
iny
cpy #osc_C_Coarse
bcc :-
ldy #dty_A_Width1
: pla
sta (editorTmp0),y
dey
bpl :-
ldy #dty_B_Width1
: pla
sta (editorTmp0),y
dey
cpy #osc_B_Coarse
bcs :-
ldy #gbl_VoiceSelect
lda (editorTmp0),y
and #%00000001
asl a
sta editorTmp2
lda (editorTmp0),y
and #%00000010
lsr a
sta editorTmp3
lda (editorTmp0),y
and #%11111100
ora editorTmp2
ora editorTmp3
sta (editorTmp0),y
jsr editorDecodeDrum
jsr editorPrintDrum
rts
editorEditSongMenu:
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda #$04
sta editorCursorMode
lda keyReleaseB ;cancel
beq :+
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
lda #$00
sta cursorY_editMenu
jmp @x
: lda keyReleaseA
beq :+
ldx cursorY_editMenu
lda @jumpTableLo,x
sta jumpVector
lda @jumpTableHi,x
sta jumpVector+1
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
jmp (jumpVector)
: lda cursorY_editMenu
clc
adc PAD1_dud
bmi :+
cmp #$02
bcs :+
sta cursorY_editMenu
:
@x: ldx cursorY_editMenu
lda @cursorX,x
clc
adc #GRID_CURSOR_X_BASE
sta editorCursorX
lda @cursorY,x
clc
adc #GRID_CURSOR_Y_BASE
sta editorCursorY
jsr editorUpdateCursor
rts
@cursorX: .BYTE $28,$28,$28,$28
@cursorY: .BYTE $08,$10,$20,$20
@jumpTableLo: .LOBYTES editorPasteLoop,editorInsertLoop
@jumpTableHi: .HIBYTES editorPasteLoop,editorInsertLoop
editorDecodeEchoMenu:
CHR_OFF = $FA
CHR_ON = $FB
ldy editorCurrentPattern
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx @gridBufferIndexes+0
lda songEchoSelect,y
sta editorTmp0
lda #CHR_OFF
lsr editorTmp0
adc #$00
sta scnGridBuffer,x
ldx @gridBufferIndexes+1
lda #CHR_OFF
lsr editorTmp0
adc #$00
sta scnGridBuffer,x
ldx @gridBufferIndexes+2
lda #CHR_OFF
lsr editorTmp0
adc #$00
sta scnGridBuffer,x
ldx @gridBufferIndexes+8
lda #CHR_OFF
lsr editorTmp0
adc #$00
sta scnGridBuffer,x
ldx @gridBufferIndexes+3
lda songEchoLevelA,y
jsr @printHex1
ldx @gridBufferIndexes+4
lda songEchoLevelB,y
jsr @printHex1
ldx @gridBufferIndexes+5
lda songEchoLevelD,y
jsr @printHex1
ldx @gridBufferIndexes+6
lda songEchoDecay,y
jsr @printHex
ldx @gridBufferIndexes+7
lda songEchoSpeed,y
jsr @printHex
rts
@printHex: pha
lsr a
lsr a
lsr a
lsr a
sta scnGridBuffer,x
inx
pla
@printHex1: and #$0F
sta scnGridBuffer,x
inx
rts
@gridBufferIndexes:
.BYTE 21,37,53
.BYTE 23,39,55
.BYTE 26,42,58
.BYTE 21,23,26
.BYTE 37,39,42
.BYTE 53,55,58
editorEditEchoMenu:
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda #WRAM_PATTERNS
jsr setMMC1r1
lda keyReleaseB ;cancel
beq :+
jsr editorShowEditMenu ;toggle
lda editorModeBeforeMenu
sta editorMode
lda #$00
sta cursorY_editMenu
jmp @x
: ldx cursorY_editMenu
lda @echoParameterLo,x
sta editorTmp0
lda @echoParameterHi,x
sta editorTmp1
cpx #$03
bcc :+
cpx #$08
beq :+
lda keyRepeatA ;modify numbers
beq :++
ldy editorCurrentPattern
lda PAD1_dlr
ora keyRepeatLR
beq @x
clc
adc (editorTmp0),y
bmi @x
cmp @max,x
bcs @x
sta (editorTmp0),y
jmp @y
: lda keyReleaseA ;modify switches
beq :+
ldy editorCurrentPattern
lda (editorTmp0),y
eor @bitMasks,x
sta (editorTmp0),y
lda #procGridRow02
jsr addProcessToBuffer
jmp @y
: ldx cursorY_editMenu
lda PAD1_dlr
beq :++
bpl :+
lda @deltaU,x
bmi @x
sta cursorY_editMenu
jmp @x
: lda @deltaD,x
bmi @x
sta cursorY_editMenu
jmp @x
: lda PAD1_dud
beq @x
bpl :+
lda @deltaL,x
bmi @x
sta cursorY_editMenu
jmp @x
: lda @deltaR,x
bmi @x
sta cursorY_editMenu
jmp @x
@y: jsr editorDecodeEchoMenu
ldx cursorY_editMenu
lda @procs,x
jsr addProcessToBuffer
@x: ldx cursorY_editMenu
lda @cursorX,x
clc
adc #GRID_CURSOR_X_BASE
sta editorCursorX
lda @cursorY,x
clc
adc #GRID_CURSOR_Y_BASE
sta editorCursorY
lda @cursorMode,x
sta editorCursorMode
jsr editorUpdateCursor
rts
@echoParameterLo:
.LOBYTES songEchoSelect,songEchoSelect,songEchoSelect
.LOBYTES songEchoLevelA,songEchoLevelB,songEchoLevelD
.LOBYTES songEchoDecay,songEchoSpeed
.LOBYTES songEchoSelect
@echoParameterHi:
.HIBYTES songEchoSelect,songEchoSelect,songEchoSelect
.HIBYTES songEchoLevelA,songEchoLevelB,songEchoLevelD
.HIBYTES songEchoDecay,songEchoSpeed
.HIBYTES songEchoSelect
@max: .BYTE $00,$00,$00
.BYTE $10,$10,$10
.BYTE $10,$40,$00
@bitMasks: .BYTE $01,$02,$04
.BYTE $00,$00,$00
.BYTE $00,$00,$08
@procs: .BYTE procGridRow01,procGridRow02,procGridRow03
.BYTE procGridRow01,procGridRow02,procGridRow03
.BYTE procGridRow01,procGridRow02,procGridRow03
@cursorX: .BYTE $28,$28,$28
.BYTE $38,$38,$38
.BYTE $50,$50,$50
@cursorY: .BYTE $08,$10,$18
.BYTE $08,$10,$18
.BYTE $08,$10,$18
@cursorMode: .BYTE $01,$01,$01
.BYTE $01,$01,$01
.BYTE $02,$02,$01
@deltaU: .BYTE $FF,$FF,$FF
.BYTE $00,$01,$02
.BYTE $03,$04,$05
@deltaD: .BYTE $03,$04,$05
.BYTE $06,$07,$08
.BYTE $FF,$FF,$FF
@deltaL: .BYTE $FF,$00,$01
.BYTE $FF,$03,$04
.BYTE $FF,$06,$07
@deltaR: .BYTE $01,$02,$FF
.BYTE $04,$05,$FF
.BYTE $07,$08,$FF
;Errors
; No Loop
; No Space
; Record not enabled
editorPasteLoop:
lda editSongMode
cmp #SONG_MODE_REC
bne :+++
lda #WRAM_SONGS
jsr setMMC1r1
ldx editorCurrentSong
lda songLoopLengthTable,x
bne :+
rts
: sta editorTmp4 ;count
lda songTableLo,x
sta editorTmp0
clc
adc songLoopLengthTable,x
sta editorTmp2
lda songTableHi,x
sta editorTmp1
adc #$00
sta editorTmp3
lda songLoopStartTable,x
tay
: lda (editorTmp0),y
sta (editorTmp2),y
iny
beq :+ ;can't go past end of Song
dec editorTmp4
bne :-
lda songLoopStartTable,x
clc
adc songLoopLengthTable,x
bcs :+
sta editorSongLoopStartTemp
sta songLoopStartTable,x
ldx #MSG_LOOP_COPY
lda #$60
jsr editorSetErrorMessage
jsr editorDecodeSong
lda #procSongAll
jsr addProcessToBuffer
rts
: ;error
ldx #MSG_PASTE_ERROR
lda #$60
jsr editorSetErrorMessage
rts
editorInsertSongBar:
lda editSongMode
cmp #SONG_MODE_REC
beq :+
rts
: lda #WRAM_SONGS
jsr setMMC1r1
ldx editorCurrentSong
lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp1
lda editorSongBar
sta editorTmp4
lda #$FF
sta editorTmp2
lda #$FE
sta editorTmp3
jsr _insertBars
jsr editorDecodeSong
lda #procSongAll
jsr addProcessToBuffer
rts
editorRemoveSongBar:
lda editSongMode
cmp #SONG_MODE_REC
beq :+
rts
: lda #WRAM_SONGS
jsr setMMC1r1
ldx editorCurrentSong
lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp1
lda editorSongBar
cmp #$FF
beq :+
sta editorTmp2
sta editorTmp3
inc editorTmp3
jsr _removeBars
jsr editorDecodeSong
lda #procSongAll
jsr addProcessToBuffer
: rts
_insertBars:
: ldy editorTmp3
lda (editorTmp0),y
ldy editorTmp2
sta (editorTmp0),y
dec editorTmp2
dec editorTmp3
inc editorTmp4
bne :-
ldx editorCurrentSong
lda editorSongBar
cmp editorSongLoopStartTemp
beq :+
bcc :+
inc editorSongLoopLengthTemp
lda editorSongLoopLengthTemp
sta songLoopLengthTable,x
rts
: inc editorSongLoopStartTemp
lda editorSongLoopStartTemp
sta songLoopStartTable,x
rts
_removeBars:
: ldy editorTmp3
lda (editorTmp0),y
ldy editorTmp2
sta (editorTmp0),y
inc editorTmp2
inc editorTmp3
bne :-
ldy #$FF
lda #$00
sta (editorTmp0),y
ldx editorCurrentSong
lda editorSongBar
cmp editorSongLoopStartTemp
bcc :+
dec editorSongLoopLengthTemp
lda editorSongLoopLengthTemp
sta songLoopLengthTable,x
rts
: dec editorSongLoopStartTemp
lda editorSongLoopStartTemp
sta songLoopStartTable,x
rts
editorInsertLoop:
lda editSongMode
cmp #SONG_MODE_REC
bne :++
lda #WRAM_SONGS
jsr setMMC1r1
ldx editorCurrentSong
lda songLoopLengthTable,x
bne :+
rts
;because of way editing Loop Start and Length is range checked
; should never be able to get a loop outside of Song range
: clc
adc songLoopStartTable,x
sta editorTmp4
lda #$FF
sta editorTmp2
sec
sbc songLoopLengthTable,x
sta editorTmp3
lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp1
jsr _insertBars
lda songLoopStartTable,x
clc
adc songLoopLengthTable,x
sta editorSongLoopStartTemp
sta songLoopStartTable,x
ldx #MSG_LOOP_COPY
lda #$60
jsr editorSetErrorMessage
jsr editorDecodeSong
lda #procSongAll
jsr addProcessToBuffer
rts
: ;error
ldx #MSG_PASTE_ERROR
lda #$60
jsr editorSetErrorMessage
rts
editorCopyPhrase:
ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
ldy #$00
: lda (editorTmp0),y
sta editCopyBuffer+1,y
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :-
lda #COPY_ID_PHRASE
sta editCopyBuffer
ldx cursorY_grid
lda editorTrackPhrase,x
ldx #MSG_PHR_COPY
jsr editorSetCopyInfoMessage
rts
editorCopyPattern:
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx #$00
: lda editorTrackDrum,x
sta editCopyBuffer+1,x
inx
cpx #bytesPerPattern
bcc :-
ldy editorCurrentPattern
lda songEchoSelect,y
sta editCopyBuffer+1,x
inx
lda songEchoLevelA,y
sta editCopyBuffer+1,x
inx
lda songEchoLevelB,y
sta editCopyBuffer+1,x
inx
lda songEchoLevelD,y
sta editCopyBuffer+1,x
inx
lda songEchoDecay,y
sta editCopyBuffer+1,x
inx
lda songEchoSpeed,y
sta editCopyBuffer+1,x
lda #COPY_ID_PATTERN
sta editCopyBuffer
lda editorCurrentPattern
ldx #MSG_PTN_COPY
jsr editorSetCopyInfoMessage
rts
editorCutPhrase:
jsr editorCopyPhrase
jsr editorClearPhrase
rts
editorClearPhrase:
ldx cursorY_grid
jsr _editorClearPhrase
jsr editorCheckUpdatePhrases
lda cursorY_grid
jsr editorDecodeTrackDrum
jsr editorDecodeDrum
jsr editorDecodeTriggerParameters
ldx cursorY_grid
lda @trackProcs,x
jsr addProcessToBuffer
jsr editorPrintTriggers
rts
@trackProcs: .BYTE procTrackDrum00,procTrackDrum01,procTrackDrum02
.BYTE procTrackDrum03,procTrackDrum04,procTrackDrum05
_editorClearPhrase:
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
ldy #$00
tya
: sta (editorTmp0),y
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :-
rts
editorCutPattern:
lda #WRAM_PATTERNS
jsr setMMC1r1
jsr editorCopyPattern
ldx editorCurrentPattern
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
ldy #$00
lda #$00
: sta (editorTmp0),y
sta editorTrackDrum,y
iny
cpy #PATTERN_PHRASE_5+1
bcc :-
lda #DEFAULT_SPEED
sta (editorTmp0),y
sta editorPatternSpeed
iny
lda #DEFAULT_SWING
sta (editorTmp0),y
sta editorPatternGroove
ldx editorCurrentPattern
lda #INIT_ECHO_SELECT
sta songEchoSelect,x
lda #INIT_ECHO_LEVEL
sta songEchoLevelA,x
sta songEchoLevelB,x
sta songEchoLevelD,x
lda #INIT_ECHO_DECAY
sta songEchoDecay,x
lda #INIT_ECHO_SPEED
sta songEchoSpeed,x
lda #$01 ;01 = NMI runs in 'pass through'
sta doNotInterrupt ;used to maximise CPU bandwidth when
;performing heavy background tasks
jsr editorReprintPattern ;refresh pattern on screen
ldx cursorY_grid
lda editorTrackDrum,x
sta editorCurrentDrum
jsr editorDecodeDrum ;decode current drum parameters and print to screen
jsr editorDecodeTrackDrums ;decode track drum assignments and print
jsr editorPrintDrum
lda #procTrackDrumAll ;add 'print all drums' task to async DMA system
jsr addProcessToBuffer
lda #$00 ;resume regular NMI routines
sta doNotInterrupt
rts
editorPasteGrid:
lda editCopyBuffer
bne :+
rts ;error message?
: lda editCopyBuffer
cmp #COPY_ID_PHRASE
beq :+
cmp #COPY_ID_PATTERN
beq :+++
rts ;error message?
;paste phrase
: ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
ldy #$00
: lda editCopyBuffer+1,y
sta (editorTmp0),y
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :-
lda #$01
sta editorForceTrackLoad
jsr editorCheckUpdatePhrases
jsr editorDecodeTriggerParameters
ldx cursorY_grid
lda @trackProcs,x
jsr addProcessToBuffer
jsr editorPrintTriggers
rts
;All pattern
: lda #WRAM_PATTERNS
jsr setMMC1r1
ldx editorCurrentPattern
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
ldy #$00
: lda editCopyBuffer+1,y
sta (editorTmp0),y
sta editorTrackDrum,y
iny
cpy #bytesPerPattern
bcc :-
ldx editorCurrentPattern
lda editCopyBuffer+1,y
sta songEchoSelect,x
iny
lda editCopyBuffer+1,y
sta songEchoLevelA,x
iny
lda editCopyBuffer+1,y
sta songEchoLevelB,x
iny
lda editCopyBuffer+1,y
sta songEchoLevelD,x
iny
lda editCopyBuffer+1,y
sta songEchoDecay,x
iny
lda editCopyBuffer+1,y
sta songEchoSpeed,x
ldx cursorY_grid
lda editorTrackDrum,x
sta editorCurrentDrum
lda #$01
sta doNotInterrupt
jsr editorDecodeDrum
jsr editorDecodeTrackDrums
jsr editorPrintDrum
lda #procTrackDrumAll
jsr addProcessToBuffer
jsr editorReprintPattern
lda #$00
sta doNotInterrupt
rts
@trackProcs: .BYTE procTrackDrum00,procTrackDrum01,procTrackDrum02
.BYTE procTrackDrum03,procTrackDrum04,procTrackDrum05
editorReprintPattern:
jsr editorDecodePatternInfo
lda #procGridPattern
jsr addProcessToBuffer
lda #$00
jsr editorDecodePhrase
lda #$01
jsr editorDecodePhrase
lda #$02
jsr editorDecodePhrase
lda #$03
jsr editorDecodePhrase
lda #$04
jsr editorDecodePhrase
lda #$05
jsr editorDecodePhrase
lda cursorY_grid
jsr editorDecodeTrackDrum
jsr editorDecodeTriggerParameters
ldx #$00
jsr editorPrintTrack
ldx #$01
jsr editorPrintTrack
ldx #$02
jsr editorPrintTrack
ldx #$03
jsr editorPrintTrack
ldx #$04
jsr editorPrintTrack
ldx #$05
jsr editorPrintTrack
ldx cursorY_grid
lda @trackProcs,x
jsr addProcessToBuffer
ldx cursorY_grid
jsr editorPrintTriggers
rts
@trackProcs: .BYTE procTrackDrum00,procTrackDrum01,procTrackDrum02
.BYTE procTrackDrum03,procTrackDrum04,procTrackDrum05
editorDecodePatternInfo:
ldx #$00
lda editorCurrentPattern
jsr @phex
lda editorPatternSpeed
jsr @phex
ldy editorPatternGroove
lda @swingTable,y
jsr @phex
lda editorPatternSteps
@phex: pha
lsr a
lsr a
lsr a
lsr a
sta scnGridPatternBuffer,x
inx
pla
and #$0F
sta scnGridPatternBuffer,x
inx
rts
@swingTable: .BYTE $00,$25,$50,$75
editorCutDrum:
jsr editorCopyDrum
jsr editorClearDrum
jsr editorDecodeDrum
jsr editorDecodeTrackDrums
jsr editorPrintDrum
lda #procTrackDrumAll
jsr addProcessToBuffer
rts
editorCopyDrum:
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
lda #COPY_ID_DRUM
sta editCopyBuffer
ldy #$00
: lda (editorTmp0),y
sta editCopyBuffer+1,y
iny
cpy #bytesPerDrum
bcc :-
lda editorCurrentDrum
ldx #MSG_DRM_COPY
jsr editorSetCopyInfoMessage
rts
editorPasteDrum:
lda #WRAM_DRUMS
jsr setMMC1r1
lda editCopyBuffer
cmp #COPY_ID_DRUM
beq :+
rts ;error
: ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
ldy #$00
: lda editCopyBuffer+1,y
sta (editorTmp0),y
iny
cpy #bytesPerDrum
bcc :-
jsr editorDecodeDrum
jsr editorDecodeTrackDrums
jsr editorPrintDrum
lda #procTrackDrumAll
jsr addProcessToBuffer
rts
editorClearDrum:
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
ldy #$00
: lda EMPTY_DRUM_DEFINITION,y
sta (editorTmp0),y
iny
cpy #bytesPerDrum
bcc :-
rts
_editMenuX = 3
editorShowEditMenu:
lda editMenuActive
bne editorClearEditMenu
lda editMenuLo,x
sta editorTmp0
lda editMenuHi,x
sta editorTmp1
lda #<(scnGridBuffer+_editMenuX)
sta editorTmp2
lda #>(scnGridBuffer+_editMenuX)
sta editorTmp3
ldx #6
: ldy #$00
: lda (editorTmp0),y
sta (editorTmp2),y
iny
cpy #11
bcc :-
lda editorTmp0
clc
adc #11
sta editorTmp0
lda editorTmp1
adc #$00
sta editorTmp1
lda editorTmp2
clc
adc #$10
sta editorTmp2
lda editorTmp3
adc #$00
sta editorTmp3
dex
bne :--
lda #$01
sta editMenuActive
lda #procGridRow00
jsr addProcessToBuffer
lda #procGridRow01
jsr addProcessToBuffer
lda #procGridRow02
jsr addProcessToBuffer
lda #procGridRow03
jsr addProcessToBuffer
lda #procGridRow04
jsr addProcessToBuffer
lda #procGridRow05
jsr addProcessToBuffer
rts
editorClearEditMenu:
lda #$00
sta editMenuActive
jsr editorDecodePhrase
lda #$01
jsr editorDecodePhrase
lda #$02
jsr editorDecodePhrase
lda #$03
jsr editorDecodePhrase
lda #$04
jsr editorDecodePhrase
lda #$05
jsr editorDecodePhrase
lda #procGridRow05
jsr addProcessToBuffer
lda #procGridRow04
jsr addProcessToBuffer
lda #procGridRow03
jsr addProcessToBuffer
lda #procGridRow02
jsr addProcessToBuffer
lda #procGridRow01
jsr addProcessToBuffer
lda #procGridRow00
jsr addProcessToBuffer
rts
GRID_PATTERN_NUMBER_X = (11*8)+3
GRID_PATTERN_NUMBER_Y = (6*8)+2
editorEditPatternNumber:
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda #$02
sta editorCursorMode
lda editorWaitForClone
beq :+++++
lda editorPatternForClone
bne :++
jsr editorFindClonePattern
bcc :+
lda #$00 ;print error
sta editorWaitForClone
ldx #MSG_CLONE_ERROR
lda #$60
jsr editorSetErrorMessage
: jmp @x
: lda editorFoundEmpty
bne :+
jsr editorFindEmptyPattern
bcc :++
lda #$00
sta editorWaitForClone ;error
ldx #MSG_CLONE_ERROR
lda #$60
jsr editorSetErrorMessage
jmp @x
: jsr editorClonePattern
lda #$00
sta editorWaitForClone
lda editorCurrentPattern
jsr editorSelectPattern
lda #$01
sta doNotInterrupt
ldx cursorY_grid
lda editorTrackDrum,x
sta editorCurrentDrum
jsr editorDecodeDrum
jsr editorDecodeTrackDrums
jsr editorReprintPattern
lda #procTrackDrumAll
jsr addProcessToBuffer
jsr editorPrintDrum
lda #$00
sta doNotInterrupt
: jmp @x
: ldx editPatternInfoSubMode
lda editorWaitForAB
beq :+
jmp @keyWaitAB
: jsr _holdSelect_tapDown
bcc :+
ldx #EDIT_GRID_MENU
jsr editorShowEditMenu
lda editorMode
sta editorModeBeforeMenu
lda #EDIT_MODE_GRID_MENU
sta editorMode
jmp @x
: lda keyRepeatB
beq :++++++
lda keyReleaseA
beq :+
lda #$00 ;hold B, tap A = Pattern Clone
sta editorPatternForClone
sta editorFoundEmpty
lda #$07
sta editorSongToCheck
lda #$01
sta editorWaitForClone
jsr editClearPatternUsedTable
jmp @x
: lda PAD1_dud ;hold B, move around = change editor mode
beq :++
bmi :+
lda previousEditorMode
sta editorMode
jmp @x
: lda #EDIT_MODE_SONG
sta editorMode
jmp @x
: lda PAD1_dlr
beq :+
bpl :++
lda #EDIT_MODE_TRACK
sta editorMode
: jmp @x
: lda #EDIT_MODE_TRIGGER_PARAMETER
sta editorMode
jmp @x
: lda keyRepeatA ;hold A = modify value
bne :+
jmp :++++++++++
: lda #$01
sta editorEditingValue
lda PAD1_dlr
ora keyRepeatLR
ora PAD1_dud
beq :++
cpx #$01
bcs :+++++
swapSign PAD1_dud
lda PAD1_dud
asl a
asl a
asl a
asl a
sta editorTmp2
lda PAD1_dlr
clc
adc editorCurrentPattern ;change pattern number
clc
adc editorTmp2
sta editorTmp3
bmi :+++
lda editorCurrentPattern
bpl :+
cmp #128+16
bcs :++++
: lda editorTmp3
sta editorCurrentPattern
ldx #$01
stx doNotInterrupt
jsr editorSelectPattern
ldx cursorY_grid
lda editorTrackDrum,x
sta editorCurrentDrum
;jsr editorDecodeDrum
jsr editorDecodeTrackDrums
jsr editorReprintPattern
lda #procTrackDrumAll
jsr addProcessToBuffer
;jsr editorPrintDrum
lda #$00
sta doNotInterrupt
: jmp @x
: lda editorCurrentPattern
bmi :---
cmp #127-16
bcs :---
:
jmp @x
: cpx #$03
bcc :+
clc
adc editorPatternSpeed-1,x
beq :+++
cmp @speedGrooveLimit,x
bcs :+++
bcc :++
: clc
adc editorPatternSpeed-1,x
bmi :++
cmp @speedGrooveLimit,x
bcs :++
: sta editorPatternSpeed-1,x
jsr editorDecodePatternInfo
lda #procGridPattern
jsr addProcessToBuffer
: jmp @x
: lda editorEditingValue ;A released, write value
beq :+
dec editorEditingValue
lda editorCurrentPattern
sta plyrNextPattern
ldx editorCurrentPattern
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
lda #WRAM_PATTERNS
jsr setMMC1r1
ldy #PATTERN_SPEED
lda editorPatternSpeed
sta (editorTmp0),y
iny
lda editorPatternGroove
sta (editorTmp0),y
iny
lda editorPatternSteps
sta (editorTmp0),y
jmp @x
: lda keyRepeatSelect
beq :++++
lda PAD1_dud
beq :++++
bmi :+
;edit menu
ldx #EDIT_GRID_MENU
jsr editorShowEditMenu
lda editorMode
sta editorModeBeforeMenu
lda #EDIT_MODE_GRID_MENU
sta editorMode
jmp @x
: lda editCopyBuffer
beq :++
cmp #COPY_ID_PHRASE
beq :+
cmp #COPY_ID_PATTERN
bne :++
: ldx #MSG_PASTE
jsr editorSetConfirmMessage
lda #$01
sta editorWaitForAB
;jsr editorPasteGrid
: jmp @x
: lda PAD1_dlr
beq :+
txa
clc
adc PAD1_dlr
bmi :+
cmp #$04
bcs :+
sta editPatternInfoSubMode
tax
:
@x:
ldx editPatternInfoSubMode
lda #GRID_PATTERN_NUMBER_X
clc
adc @xOffsets,x
sta editorCursorX
lda #GRID_PATTERN_NUMBER_Y
clc
adc @yOffsets,x
sta editorCursorY
jsr editorUpdateCursor
rts
@xOffsets: .BYTE 0*8, 5*8, 10*8, 15*8
@yOffsets: .BYTE 0,0,0
@speedGrooveLimit:
.BYTE 0 ;dummy
.BYTE 30,4,17
@keyWaitAB:
lda editorWaitForAB
beq :++
lda keyReleaseB
bne :+
lda keyReleaseA
beq :++
jsr editorPasteGrid
: lda #$01
sta editorCopyInfoTimer
lda #$00
sta editorWaitForAB
: rts
editorWipeAll:
lda #$01
sta doNotInterrupt
jsr editorWipeSongs
jsr editorWipePatterns
jsr editorWipePhrases
jsr editorWipeDrums
lda #$FF
sta dmaProcessBuffer ;clear asynchronous screen DMA queue
jsr editorInit2
lda #$00
sta doNotInterrupt
rts
menuWipeSongs: lda #$01
sta doNotInterrupt
jsr editorWipeSongs
lda #$FF
sta dmaProcessBuffer
jsr editorInit2
lda #$00
sta doNotInterrupt
rts
editorWipeSongs:
ldx #$00
: jsr editorWipeSong
inx
cpx #numberOfSongs
bcc :-
rts
editorWipeSong:
lda #WRAM_SONGS
jsr setMMC1r1
lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp1
ldy #$00
tya
: sta (editorTmp0),y
iny
bne :-
lda #$00
sta songLoopStartTable,x
lda #$01
sta songLoopLengthTable,x
lda #$FF
sta songSpeedTable,x
sta songSwingTable,x
rts
menuWipePhrases:
lda #$01
sta doNotInterrupt
jsr editorWipePhrases
lda #$FF
sta dmaProcessBuffer
jsr editorInit2
lda #$00
sta doNotInterrupt
rts
editorWipePhrases:
ldx #$00
: lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
ldy #$00
lda #$00
: sta (editorTmp0),y
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :-
inx
cpx #numberOfPhrases
bcc :--
rts
menuWipePatterns:
lda #$01
sta doNotInterrupt
jsr editorWipePatterns
lda #$FF
sta dmaProcessBuffer
jsr editorInit2
lda #$00
sta doNotInterrupt
rts
editorWipePatterns:
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx #$00
: lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
ldy #$00
: lda @blankPattern,y
sta (editorTmp0),y
iny
cpy #bytesPerPattern
bcc :-
lda #INIT_ECHO_SELECT
sta songEchoSelect,x
lda #INIT_ECHO_LEVEL
sta songEchoLevelA,x
sta songEchoLevelB,x
sta songEchoLevelD,x
lda #INIT_ECHO_DECAY
sta songEchoDecay,x
lda #INIT_ECHO_SPEED
sta songEchoSpeed,x
inx
;cpx #numberOfPatterns-1
;bcc :--
bne :--
rts
@blankPattern: .BYTE $00,$00,$00,$00,$00,$00 ;drums
.BYTE $00,$00,$00,$00,$00,$00 ;phrases
.BYTE $0C,$00 ;speed, swing
.BYTE $10 ;steps
.BYTE $00
menuWipeDrums: lda #$01
sta doNotInterrupt
jsr editorWipeDrums
lda #$FF
sta dmaProcessBuffer
jsr editorInit2
lda #$00
sta doNotInterrupt
rts
editorWipeDrums:
lda #WRAM_DRUMS
jsr setMMC1r1
ldx editorCurrentDrum
: lda drumAddressLo,x
sta editorTmp0
lda drumAddressHi,x
sta editorTmp1
ldy #$00
: lda EMPTY_DRUM_DEFINITION,y
sta (editorTmp0),y
iny
cpy #bytesPerDrum
bcc :-
inx
cpx #numberOfDrums
bcc :--
rts
EMPTY_DRUM_DEFINITION:
@oscA: .BYTE $00,$00,$00
@lfoA: .BYTE $00,$00,$00
@envA: .BYTE $8F,$08,$08
@dtyA: .BYTE $00,$00
@oscB: .BYTE $00,$00,$00
@lfoB: .BYTE $00,$00,$00
@envB: .BYTE $8F,$08,$08
@dtyB: .BYTE $00,$00
@oscC: .BYTE $00,$00
@lfoC: .BYTE $00,$00,$00
@envC: .BYTE $00,$10
@oscD: .BYTE $50
@lfoD: .BYTE $00,$00,$00
@envD: .BYTE $8F,$08,$08
@esm: .BYTE $00
@est: .BYTE $00
@een: .BYTE $00
@ept: .BYTE $5F
@elp: .BYTE $00
@name: .BYTE $0D,$04,$16
@seq: .BYTE $80,$80,$80
@gbl: .BYTE %00000000
offset = $30
editorDecodeSong:
lda #WRAM_SONGS
jsr setMMC1r1
ldx editorCurrentSong
;lda songLoopStartTable,x
lda editorSongLoopStartTemp
sta editorTmp2
clc
;adc songLoopLengthTable,x
adc editorSongLoopLengthTemp
sta editorTmp3
lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp1
txa
tay
ldx #$00
jsr @printHex
;lda songSpeedTable,y
lda editorSongSpeedTemp
jsr @printBlankSpeed
;lda songSwingTable,y
lda editorSongSwingTemp
jsr @printBlankSwing
;lda songLoopStartTable,y
lda editorSongLoopStartTemp
jsr @printHex
;lda songLoopLengthTable,y
lda editorSongLoopLengthTemp
jsr @printBlankLoop
lda editorSongBar
tay
lda editorSongBar
cmp editorTmp2
bcc :+
lda editorTmp3
cmp editorSongBar
beq :+
bcc :+
tya
jsr @printTest
jmp :++
: tya
jsr @printHex
: lda (editorTmp0),y
jsr @printHex
rts
@printTest: pha
lsr a
lsr a
lsr a
lsr a
clc
adc #offset
sta scnSongBuffer,x
inx
pla
and #$0F
clc
adc #offset
sta scnSongBuffer,x
inx
rts
@printHex: pha
lsr a
lsr a
lsr a
lsr a
sta scnSongBuffer,x
inx
pla
and #$0F
sta scnSongBuffer,x
inx
rts
@printBlankSpeed:
cmp #$FF
bne @printHex
lda #$2C
sta scnSongBuffer,x
inx
sta scnSongBuffer,x
inx
rts
@printBlankLoop:
cmp #$00
bne @printHex
lda #$2C
sta scnSongBuffer,x
inx
sta scnSongBuffer,x
inx
rts
@printBlankSwing:
cmp #$FF
bne :+
lda #$2C
sta scnSongBuffer,x
inx
sta scnSongBuffer,x
inx
rts
: cmp #$00
bne :+
lda #$00
jmp @printHex
: cmp #$01
bne :+
lda #$25
jmp @printHex
: cmp #$02
bne :+
lda #$50
jmp @printHex
: lda #$75
jmp @printHex
SONG_CURSOR_X_BASE = -5
SONG_CURSOR_Y_BASE = -6
editorSong:
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda #WRAM_SONGS
jsr setMMC1r1
ldx editorCurrentSong
lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp1
lda #$02
sta editorCursorMode
ldx editSongIndex
lda keyReleaseSelect ;tapping SELECT in Song will take you to Grid and load Pattern on current Bar
beq :+
ldy editorSongBar
lda (editorTmp0),y
sta editorCurrentPattern
jsr editorSelectPattern
lda #$01
sta doNotInterrupt
ldx cursorY_grid
lda editorTrackDrum,x
sta editorCurrentDrum
jsr editorDecodeDrum
jsr editorDecodeTrackDrums
jsr editorReprintPattern
lda #procTrackDrumAll
jsr addProcessToBuffer
jsr editorPrintDrum
lda #$00
sta doNotInterrupt
lda #EDIT_MODE_GRID
sta editorMode
jmp @x
:
lda keyRepeatA ;handle INS/DEL bars
beq :+++
lda keyRepeatB
beq :+++
cpx #$04
beq :+
cpx #$05
bne :+++
: lda PAD1_dlr
beq :++
bmi :+
jmp editorInsertSongBar
: jmp editorRemoveSongBar
:
lda keyReleaseA
beq :++
ldx editSongIndex
cpx #$05
bne :+
ldy editorSongBar
lda editorSongLastPattern
sta (editorTmp0),y
jsr editorDecodeSong
lda #procSongBar
jsr addProcessToBuffer
: jmp @x
: lda keyRepeatSelect
beq :+++
lda PAD1_dud
beq :+++
bmi :++
lda PAD1_fireb
beq :+
ldx #EDIT_CLEAR_MENU
jsr editorShowEditMenu
lda editorMode
sta editorModeBeforeMenu
lda #EDIT_MODE_CLEAR_MENU
sta editorMode
jmp @x
;edit menu
: ldx #EDIT_SONG_MENU
jsr editorShowEditMenu
lda editorMode
sta editorModeBeforeMenu
lda #EDIT_MODE_SONG_MENU
sta editorMode
jmp @x
: ;jsr editorPasteDrum
;ldx #MSG_PASTE
;jsr editorSetConfirmMessage
;lda #$01
;sta editorWaitForAB
jmp @x
: lda keyRepeatB
beq :+++
lda PAD1_dud
beq :+
bmi :++
lda #EDIT_MODE_PATTERN_NUMBER
sta editorMode
jmp @x
: lda #$00
sta editorTmp2
lda PAD1_dlr
ora keyRepeatLR
beq :+
ldx editSongMode
cpx #SONG_MODE_REC
bne :+
;ldx editSongIndex
;cpx #$04
;beq :+++
jmp @editBarEntry
: jmp @x
: lda keyReleaseB
beq :+
cpx #$07
bne :+
ldx editSongMode
cpx #SONG_MODE_REC
bne :+
ldx editorCurrentSong
;lda songLoopLengthTable,x
lda editorSongLoopLengthTemp
pha
lda editorLastSongLoop
sta songLoopLengthTable,x
sta editorSongLoopLengthTemp
pla
sta editorLastSongLoop
jsr editorDecodeSong
lda #procSongLoop
jsr addProcessToBuffer
jmp @x
: lda keyRepeatA
beq :++++++++
lda #$01
sta editorEditingValue
swapSign keyRepeatUD
swapSign PAD1_dud
lda keyRepeatUD
ora PAD1_dud
asl a
asl a
asl a
asl a
sta editorTmp2
ora keyRepeatLR
ora PAD1_dlr
beq :---
ldx editSongIndex
cpx #$00
bne :+
jmp @editSongMode
: cpx #$01
bne :+
jmp @editSongNumber
: cpx #$02
bne :+
jmp @editSongSpeed
: cpx #$03
bne :+
jmp @editSongSwing
: cpx #$04
bne :+
jmp @editSongBar
: cpx #$05
bne :+
jmp @editSongPattern
: cpx #$06
bne :+
jmp @editSongLoopStart
: jmp @editSongLoopLength
: lda editorEditingValue
beq :+
lda #$00
sta editorEditingValue
jsr @writeSongValue
jmp @x
: lda PAD1_dud
beq :++
: clc
adc editSongIndex
bmi :+++
cmp #$08
bcs :+++
sta editSongIndex
tax
jmp @x
: lda PAD1_dlr
beq :++
bmi :+
lda @deltaRight,x
bpl :--
: lda @deltaLeft,x
bmi :---
:
@x: ldx editSongIndex
lda #SONG_CURSOR_X_BASE
clc
adc @cursorX,x
sta editorCursorX
lda #SONG_CURSOR_Y_BASE
clc
adc @cursorY,x
sta editorCursorY
jsr editorUpdateCursor
rts
@writeSongValue:
cpx #$00
bne :+
rts
: cpx #$01
bne :+
jmp @writeSongNumber
: cpx #$02
bne :+
jmp @writeSongSpeed
: cpx #$03
bne :+
jmp @writeSongSwing
: cpx #$04
bne :+
rts ;song bar, don't do
: cpx #$05
bne :+
rts ;jmp @writeSongPattern
: cpx #$06
bne :+
jmp @writeSongLoopStart
: jmp @writeSongLoopLength
@writeSongNumber:
lda #$FF
sta plyrSongBar
lda editorCurrentSong
sta plyrCurrentSong
jsr editorSelectSong
rts
;@writeSongPattern:
; ldx editorCurrentSong
; lda songTableLo,x
; sta editorTmp0
; lda songTableHi,x
; sta editorTmp1
; ldy editorSongBar
; lda editorEditingBuffer
; sta (editorTmp0),y
; rts
@writeSongSpeed:
ldx editorCurrentSong
lda editorSongSpeedTemp
sta songSpeedTable,x
rts
@writeSongSwing:
ldx editorCurrentSong
lda editorSongSwingTemp
sta songSwingTable,x
rts
@writeSongLoopStart:
ldx editorCurrentSong
lda editorSongLoopStartTemp
sta songLoopStartTable,x
rts
@writeSongLoopLength:
ldx editorCurrentSong
lda editorSongLoopLengthTemp
sta songLoopLengthTable,x
rts
@editSongMode:
lda PAD1_dlr
beq :++
bpl :+
lda #SONG_MODE_OFF
bpl :+++
: lda #SONG_MODE_PLY
bpl :++
: lda PAD1_dud
beq :++
bmi :++
lda #SONG_MODE_REC
: sta editSongMode
tax
lda @infoMode,x
tax
jsr editorSetPlayBackMessage
lda #procCopyInfoAll
jsr addProcessToBuffer
lda editSongMode
cmp #SONG_MODE_OFF
bne :+
lda editorCurrentPattern
sta plyrNextPattern
lda #$00
sta editorLastSongLoop
: rts
@infoMode: .BYTE MSG_PTRN,MSG_SONG,MSG_SONG
@editSongNumber:
lda PAD1_dlr
beq :+
clc
adc editorCurrentSong
bmi :+
cmp #numberOfSongs
bcs :+
sta editorCurrentSong
;sta plyrCurrentSong
;jsr editorSelectSong
;lda #$FF
;sta plyrSongBar
jsr editorDecodeSong
lda #procSongAll
jsr addProcessToBuffer
: rts
@editSongSpeed:
lda editSongMode
cmp #SONG_MODE_REC
beq :+
rts
: ldx editorCurrentSong
lda PAD1_dlr
ora keyRepeatLR
clc
;adc songSpeedTable,x
adc editorSongSpeedTemp
clc
adc editorTmp2
bpl :+
lda #$FF
bmi :++
: cmp #numberOfSpeeds
bcs :++
: ;sta songSpeedTable,x
sta editorSongSpeedTemp
jsr editorDecodeSong
lda #procSongSpeed
jsr addProcessToBuffer
: rts
@editSongSwing:
lda editSongMode
cmp #SONG_MODE_REC
beq :+
rts
: ldx editorCurrentSong
lda PAD1_dlr
ora keyRepeatLR
clc
;adc songSwingTable,x
adc editorSongSwingTemp
clc
adc editorTmp2
bpl :+
lda #$FF
bmi :++
: cmp #$04
bcs :++
: ;sta songSwingTable,x
sta editorSongSwingTemp
jsr editorDecodeSong
lda #procSongSpeed
jsr addProcessToBuffer
: rts
@editSongBar:
lda editSongMode
cmp #SONG_MODE_REC
beq :+
rts
: lda PAD1_dlr
ora keyRepeatLR
@editBarEntry: clc
adc editorSongBar
clc
adc editorTmp2
sta editorTmp3
bmi :++
lda editorSongBar
bpl :+
cmp #128+16
bcs :+++
: lda editorTmp3
sta editorSongBar
tay
ldx editorCurrentSong
lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp0
lda (editorTmp0),y
sta plyrNextPattern
jsr editorDecodeSong
lda #procSongBar
jsr addProcessToBuffer
rts
: lda editorSongBar
bmi :--
cmp #127-16
bcs :--
:
rts
@editSongPattern:
lda editSongMode
cmp #SONG_MODE_REC
beq :+
rts
:
lda #WRAM_SONGS
jsr setMMC1r1
ldx editorCurrentSong
lda songTableLo,x
sta editorTmp0
lda songTableHi,x
sta editorTmp1
ldy editorSongBar
lda PAD1_dlr
ora keyRepeatLR
clc
adc (editorTmp0),y
clc
adc editorTmp2
sta editorTmp3
bmi :++
lda (editorTmp0),y
bpl :+
cmp #128+16
bcs :+++
: lda editorTmp3
sta (editorTmp0),y
sta editorSongLastPattern
jsr editorDecodeSong
lda #procSongBar
jsr addProcessToBuffer
rts
: lda (editorTmp0),y
bmi :--
cmp #127-16
bcs :--
:
rts
@editSongLoopStart:
lda editSongMode
cmp #SONG_MODE_REC
beq :+
rts
: ldx editorCurrentSong
lda PAD1_dlr
ora keyRepeatLR
clc
;adc songLoopStartTable,x
adc editorSongLoopStartTemp
clc
adc editorTmp2
sta editorTmp3
bmi :++ ;a
;lda songLoopStartTable,x
lda editorSongLoopStartTemp
bpl :+ ;b
cmp #128+16
bcs :+++ ;c
: lda editorTmp3 ;b
clc
;adc songLoopLengthTable,x
adc editorSongLoopLengthTemp
bcs :++
lda editorTmp3
;sta songLoopStartTable,x
sta editorSongLoopStartTemp
jsr editorDecodeSong
lda #procSongLoop
jsr addProcessToBuffer
lda #procSongBar
jsr addProcessToBuffer
rts
: ;lda songLoopStartTable,x ;a
lda editorSongLoopStartTemp
bmi :--
cmp #127-16
bcs :--
: ;c
rts
@editSongLoopLength:
lda editSongMode
cmp #SONG_MODE_REC
beq :+
rts
: ldx editorCurrentSong
lda PAD1_dlr
ora keyRepeatLR
clc
;adc songLoopLengthTable,x
adc editorSongLoopLengthTemp
clc
adc editorTmp2
sta editorTmp3
bmi :++ ;a
;lda songLoopLengthTable,x
lda editorSongLoopLengthTemp
bpl :+ ;b
cmp #128+16
bcs :+++ ;c
: lda editorTmp3 ;b
clc
;adc songLoopStartTable,x
adc editorSongLoopStartTemp
bcs :++
lda editorTmp3
;sta songLoopLengthTable,x ;d
sta editorSongLoopLengthTemp
jsr editorDecodeSong
lda #procSongLoop
jsr addProcessToBuffer
lda #procSongBar
jsr addProcessToBuffer
rts
: ;lda songLoopLengthTable,x ;a
lda editorSongLoopLengthTemp
bmi :--
cmp #127-16
bcs :--
: ;c
rts
@cursorX: .BYTE 13*8,13*8,18*8,18*8,23*8,23*8,28*8,28*8
@cursorY: .BYTE 4*8,5*8,4*8,5*8,4*8,5*8,4*8,5*8
@deltaRight:
.BYTE $02,$02,$02,$02,$02,$02,$02,$02
@deltaLeft:
.BYTE $FE,$FE,$FE,$FE,$FE,$FE,$FE,$FE
editorClonePhrase:
ldx cursorY_grid
lda editorTrackPhrase,x
tax
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
ldy #$00
: lda (editorTmp0),y
sta editCopyBuffer+1,y
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :-
lda #$00
sta editCopyBuffer
ldx editorPhraseForClone
lda phraseBanks,x
jsr setMMC1r1
lda phraseTableLo,x
sta editorTmp0
lda phraseTableHi,x
sta editorTmp1
ldy #$00
: lda editCopyBuffer+1,y
sta (editorTmp0),y
iny
cpy #stepsPerPhrase * bytesPerPhraseStep
bcc :-
ldx editorCurrentPattern
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
lda #WRAM_PATTERNS
jsr setMMC1r1
lda #PATTERN_PHRASE_0
clc
adc cursorY_grid
tay
lda editorPhraseForClone
sta (editorTmp0),y
sta editorTrackPhrase-6,y
lda cursorY_grid
jsr editorDecodePhrase
lda cursorY_grid
jsr editorDecodeTrackDrum
ldx cursorY_grid
jsr editorDecodeTriggerParameters
ldx cursorY_grid
lda @trackProcs,x
jsr addProcessToBuffer
ldx cursorY_grid
lda @phraseProcs,x
jsr addProcessToBuffer
lda #procTrigger
jsr addProcessToBuffer
rts
@phraseProcs: .BYTE procGridRow00,procGridRow01,procGridRow02
.BYTE procGridRow03,procGridRow04,procGridRow05
@trackProcs: .BYTE procTrackDrum00,procTrackDrum01,procTrackDrum02
.BYTE procTrackDrum03,procTrackDrum04,procTrackDrum05
editorDrumNameTranslate:
.BYTE $10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$1A,$1B,$1C
.BYTE $1D,$1E,$1F,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29
.BYTE $00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$2C
editorDrumNameTranslateEnd:
editorDrumNameTranslate2:
.BYTE $40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$4B,$4C
.BYTE $4D,$4E,$4F,$50,$51,$52,$53,$54,$55,$56,$57,$58,$59
.BYTE $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3C
.include "editMenus.asm"
.include "keys.asm"
.include "parameters.asm"
|
src/libtcod-maps-paths.ads
|
csb6/libtcod-ada
| 0 |
15237
|
private with path_h;
package Libtcod.Maps.Paths is
type Path is limited private;
type Cost is new Float;
type Index is range 0 .. Integer'Last;
function make_path(m : Map; diagonal_cost : Cost) return Path;
function compute(p : in out Path; start_x : X_Pos; start_y : Y_Pos;
end_x : X_Pos; end_y : Y_Pos) return Boolean;
function walk(p : Path; x : aliased out X_Pos; y : aliased out Y_Pos;
recalc_when_needed : Boolean := True) return Boolean;
procedure get(p : Path; i : Index;
x : aliased out X_Pos; y : aliased out Y_Pos);
procedure get_start(p : Path; x : aliased out X_Pos; y : aliased out Y_Pos);
procedure get_end(p : Path; x : aliased out X_Pos; y : aliased out Y_Pos);
function empty(p : Path) return Boolean with Inline;
function size(p : Path) return Natural with Inline;
procedure reverse_in_place(p : in out Path) with Inline;
private
type Path is new Ada.Finalization.Limited_Controlled with record
data : access path_h.TCOD_Path;
end record;
overriding procedure Finalize(p : in out Path);
end Libtcod.Maps.Paths;
|
alloy4fun_models/trainstlt/models/6/66uH8rfaCJbERe7pw.als
|
Kaixi26/org.alloytools.alloy
| 0 |
1847
|
<gh_stars>0
open main
pred id66uH8rfaCJbERe7pw_prop7 {
all t : Train | eventually no t.pos
}
pred __repair { id66uH8rfaCJbERe7pw_prop7 }
check __repair { id66uH8rfaCJbERe7pw_prop7 <=> prop7o }
|
core/lib/cubical/Square.agda
|
AntoineAllioux/HoTT-Agda
| 294 |
7077
|
<reponame>AntoineAllioux/HoTT-Agda
{-# OPTIONS --without-K --rewriting #-}
open import lib.Base
open import lib.Equivalence
open import lib.NType
open import lib.PathFunctor
open import lib.PathGroupoid
open import lib.PathOver
open import lib.Univalence
module lib.cubical.Square where
{-
*--1--*
| |
0 3
| |
*--2--*
-}
data Square {i} {A : Type i} {a₀₀ : A} : {a₀₁ a₁₀ a₁₁ : A}
→ a₀₀ == a₀₁ → a₀₀ == a₁₀ → a₀₁ == a₁₁ → a₁₀ == a₁₁ → Type i
where
ids : Square idp idp idp idp
hid-square : ∀ {i} {A : Type i} {a₀₀ a₀₁ : A} {p : a₀₀ == a₀₁}
→ Square p idp idp p
hid-square {p = idp} = ids
vid-square : ∀ {i} {A : Type i} {a₀₀ a₁₀ : A} {p : a₀₀ == a₁₀}
→ Square idp p p idp
vid-square {p = idp} = ids
square-to-disc : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋
→ p₀₋ ∙ p₋₁ == p₋₀ ∙ p₁₋
square-to-disc ids = idp
disc-to-square : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ p₀₋ ∙ p₋₁ == p₋₀ ∙ p₁₋
→ Square p₀₋ p₋₀ p₋₁ p₁₋
disc-to-square {p₀₋ = idp} {p₋₀ = idp} {p₋₁ = idp} {p₁₋ = .idp} idp = ids
square-to-disc-β : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(α : p₀₋ ∙ p₋₁ == p₋₀ ∙ p₁₋)
→ square-to-disc (disc-to-square {p₀₋ = p₀₋} {p₋₀ = p₋₀} α) == α
square-to-disc-β {p₀₋ = idp} {p₋₀ = idp} {p₋₁ = idp} {p₁₋ = .idp} idp = idp
disc-to-square-β : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ disc-to-square (square-to-disc sq) == sq
disc-to-square-β ids = idp
square-disc-equiv : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ (Square p₀₋ p₋₀ p₋₁ p₁₋) ≃ (p₀₋ ∙ p₋₁ == p₋₀ ∙ p₁₋)
square-disc-equiv =
equiv square-to-disc disc-to-square square-to-disc-β disc-to-square-β
Square-level : ∀ {n : ℕ₋₂} {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ has-level (S (S n)) A
→ has-level n (Square p₀₋ p₋₀ p₋₁ p₁₋)
Square-level {n} A-level =
transport (has-level n) (! (ua square-disc-equiv)) $
has-level-apply (has-level-apply A-level _ _) _ _
ap-square : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
{a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋
→ Square (ap f p₀₋) (ap f p₋₀) (ap f p₋₁) (ap f p₁₋)
ap-square f ids = ids
ap-square-hid : ∀ {i j} {A : Type i} {B : Type j} {f : A → B}
{a₀ a₁ : A} {p : a₀ == a₁}
→ ap-square f (hid-square {p = p}) == hid-square
ap-square-hid {p = idp} = idp
ap-square-vid : ∀ {i j} {A : Type i} {B : Type j} {f : A → B}
{a₀ a₁ : A} {p : a₀ == a₁}
→ ap-square f (vid-square {p = p}) == vid-square
ap-square-vid {p = idp} = idp
module _ {i} {A : Type i} where
horiz-degen-square : {a a' : A} {p q : a == a'}
→ p == q → Square p idp idp q
horiz-degen-square {p = idp} α = disc-to-square α
horiz-degen-path : {a a' : A} {p q : a == a'}
→ Square p idp idp q → p == q
horiz-degen-path {p = idp} sq = square-to-disc sq
horiz-degen-path-β : {a a' : A} {p q : a == a'} (α : p == q)
→ horiz-degen-path (horiz-degen-square α) == α
horiz-degen-path-β {p = idp} α = square-to-disc-β α
horiz-degen-square-β : {a a' : A} {p q : a == a'} (sq : Square p idp idp q)
→ horiz-degen-square (horiz-degen-path sq) == sq
horiz-degen-square-β {p = idp} sq = disc-to-square-β sq
vert-degen-square : {a a' : A} {p q : a == a'}
→ p == q → Square idp p q idp
vert-degen-square {p = idp} α = disc-to-square (! α)
vert-degen-path : {a a' : A} {p q : a == a'}
→ Square idp p q idp → p == q
vert-degen-path {p = idp} sq = ! (square-to-disc sq)
vert-degen-path-β : {a a' : A} {p q : a == a'} (α : p == q)
→ vert-degen-path (vert-degen-square α) == α
vert-degen-path-β {p = idp} α = ap ! (square-to-disc-β (! α)) ∙ !-! α
vert-degen-square-β : {a a' : A} {p q : a == a'} (sq : Square idp p q idp)
→ vert-degen-square (vert-degen-path sq) == sq
vert-degen-square-β {p = idp} sq =
ap disc-to-square (!-! (square-to-disc sq)) ∙ disc-to-square-β sq
horiz-degen-square-idp : {a a' : A} {p : a == a'}
→ horiz-degen-square (idp {a = p}) == hid-square
horiz-degen-square-idp {p = idp} = idp
vert-degen-square-idp : {a a' : A} {p : a == a'}
→ vert-degen-square (idp {a = p}) == vid-square
vert-degen-square-idp {p = idp} = idp
ap-horiz-degen-square : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
{a a' : A} {p q : a == a'} (r : p == q)
→ ap-square f (horiz-degen-square r) == horiz-degen-square (ap (ap f) r)
ap-horiz-degen-square f {p = idp} r@idp = idp
ap-vert-degen-square : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
{a a' : A} {p q : a == a'} (r : p == q)
→ ap-square f (vert-degen-square r) == vert-degen-square (ap (ap f) r)
ap-vert-degen-square f {p = idp} r@idp = idp
{- Flipping squares -}
module _ {i} {A : Type i} where
square-symmetry : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₋₀ p₀₋ p₁₋ p₋₁
square-symmetry ids = ids
square-sym-inv : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ square-symmetry (square-symmetry sq) == sq
square-sym-inv ids = idp
!□h : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋
→ Square p₁₋ (! p₋₀) (! p₋₁) p₀₋
!□h ids = ids
!□v : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋
→ Square (! p₀₋) p₋₁ p₋₀ (! p₁₋)
!□v ids = ids
!□v-horiz-degen-square : {a a' : A} {p q : a == a'}
(r : p == q)
→ !□v (horiz-degen-square r) == horiz-degen-square (ap ! r)
!□v-horiz-degen-square {p = idp} r@idp = idp
!□v-vert-degen-square : {a a' : A} {p q : a == a'}
(r : p == q)
→ !□v (vert-degen-square r) == vert-degen-square (! r)
!□v-vert-degen-square {p = idp} r@idp = idp
ap-square-symmetry : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
{a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ ap-square f (square-symmetry sq) == square-symmetry (ap-square f sq)
ap-square-symmetry f ids = idp
horiz-degen-square-symmetry : ∀ {i} {A : Type i}
{a a' : A} {p q : a == a'} (r : p == q)
→ square-symmetry (horiz-degen-square r) == vert-degen-square r
horiz-degen-square-symmetry {p = idp} α@idp = idp
{- Alternate induction principles -}
square-left-J : ∀ {i j} {A : Type i} {a₀₀ a₀₁ : A} {p₀₋ : a₀₀ == a₀₁}
(P : {a₁₀ a₁₁ : A} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ Type j)
(r : P hid-square)
{a₁₀ a₁₁ : A} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ P sq
square-left-J P r ids = r
square-top-J : ∀ {i j} {A : Type i} {a₀₀ a₁₀ : A} {p₋₀ : a₀₀ == a₁₀}
(P : {a₀₁ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ Type j)
(r : P vid-square)
{a₀₁ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ P sq
square-top-J P r ids = r
square-bot-J : ∀ {i j} {A : Type i} {a₀₁ a₁₁ : A} {p₋₁ : a₀₁ == a₁₁}
(P : {a₀₀ a₁₀ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ Type j)
(r : P vid-square)
{a₀₀ a₁₀ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ P sq
square-bot-J P r ids = r
square-right-J : ∀ {i j} {A : Type i} {a₁₀ a₁₁ : A} {p₁₋ : a₁₀ == a₁₁}
(P : {a₀₀ a₀₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ Type j)
(r : P hid-square)
{a₀₀ a₀₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ P sq
square-right-J P r ids = r
module _ where
private
lemma : ∀ {i j} {A : Type i} {a₀ : A}
(P : {a₁ : A} {p q : a₀ == a₁} → p == q → Type j)
(r : P (idp {a = idp}))
{a₁ : A} {p q : a₀ == a₁} (α : p == q)
→ P α
lemma P r {p = idp} idp = r
horiz-degen-J : ∀ {i j} {A : Type i} {a₀ : A}
(P : {a₁ : A} {p q : a₀ == a₁} → Square p idp idp q → Type j)
(r : P ids)
{a₁ : A} {p q : a₀ == a₁} (sq : Square p idp idp q)
→ P sq
horiz-degen-J P r sq = transport P
(horiz-degen-square-β sq)
(lemma (P ∘ horiz-degen-square) r (horiz-degen-path sq))
vert-degen-J : ∀ {i j} {A : Type i} {a₀ : A}
(P : {a₁ : A} {p q : a₀ == a₁} → Square idp p q idp → Type j)
(r : P ids)
{a₁ : A} {p q : a₀ == a₁} (sq : Square idp p q idp)
→ P sq
vert-degen-J P r sq = transport P
(vert-degen-square-β sq)
(lemma (P ∘ vert-degen-square) r (vert-degen-path sq))
{- Square filling -}
module _ {i} {A : Type i} where
fill-square-left : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
(p₋₀ : a₀₀ == a₁₀) (p₋₁ : a₀₁ == a₁₁) (p₁₋ : a₁₀ == a₁₁)
→ Σ (a₀₀ == a₀₁) (λ p₀₋ → Square p₀₋ p₋₀ p₋₁ p₁₋)
fill-square-left idp idp p = (p , hid-square)
fill-square-top : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
(p₀₋ : a₀₀ == a₀₁) (p₋₁ : a₀₁ == a₁₁) (p₁₋ : a₁₀ == a₁₁)
→ Σ (a₀₀ == a₁₀) (λ p₋₀ → Square p₀₋ p₋₀ p₋₁ p₁₋)
fill-square-top idp p idp = (p , vid-square)
fill-square-bot : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
(p₀₋ : a₀₀ == a₀₁) (p₋₀ : a₀₀ == a₁₀) (p₁₋ : a₁₀ == a₁₁)
→ Σ (a₀₁ == a₁₁) (λ p₋₁ → Square p₀₋ p₋₀ p₋₁ p₁₋)
fill-square-bot idp p idp = (p , vid-square)
fill-square-right : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
(p₀₋ : a₀₀ == a₀₁) (p₋₀ : a₀₀ == a₁₀) (p₋₁ : a₀₁ == a₁₁)
→ Σ (a₁₀ == a₁₁) (λ p₁₋ → Square p₀₋ p₋₀ p₋₁ p₁₋)
fill-square-right p idp idp = (p , hid-square)
module _ {i j} {A : Type i} {B : Type j} {f : A → B} {b : B} where
↓-cst=app-from-square : {x y : A} {p : x == y}
{u : b == f x} {v : b == f y}
→ Square u idp (ap f p) v
→ u == v [ (λ z → b == f z) ↓ p ]
↓-cst=app-from-square {p = idp} sq = horiz-degen-path sq
↓-cst=app-to-square : {x y : A} {p : x == y}
{u : b == f x} {v : b == f y}
→ u == v [ (λ z → b == f z) ↓ p ]
→ Square u idp (ap f p) v
↓-cst=app-to-square {p = idp} α = horiz-degen-square α
↓-app=cst-from-square : {x y : A} {p : x == y}
{u : f x == b} {v : f y == b}
→ Square u (ap f p) idp v
→ u == v [ (λ z → f z == b) ↓ p ]
↓-app=cst-from-square {p = idp} sq = horiz-degen-path sq
↓-app=cst-to-square : {x y : A} {p : x == y}
{u : f x == b} {v : f y == b}
→ u == v [ (λ z → f z == b) ↓ p ]
→ Square u (ap f p) idp v
↓-app=cst-to-square {p = idp} α = horiz-degen-square α
module _ {i} {A : Type i} {f : A → A} where
↓-idf=app-from-square : {x y : A} {p : x == y}
{u : x == f x} {v : y == f y}
→ Square u p (ap f p) v
→ u == v [ (λ z → z == f z) ↓ p ]
↓-idf=app-from-square {p = idp} sq = horiz-degen-path sq
↓-idf=app-to-square : {x y : A} {p : x == y}
{u : x == f x} {v : y == f y}
→ u == v [ (λ z → z == f z) ↓ p ]
→ Square u p (ap f p) v
↓-idf=app-to-square {p = idp} α = horiz-degen-square α
↓-app=idf-from-square : {x y : A} {p : x == y}
{u : f x == x} {v : f y == y}
→ Square u (ap f p) p v
→ u == v [ (λ z → f z == z) ↓ p ]
↓-app=idf-from-square {p = idp} sq = horiz-degen-path sq
↓-app=idf-to-square : {x y : A} {p : x == y}
{u : f x == x} {v : f y == y}
→ u == v [ (λ z → f z == z) ↓ p ]
→ Square u (ap f p) p v
↓-app=idf-to-square {p = idp} α = horiz-degen-square α
module _ {i j} {A : Type i} {B : Type j} (g : B → A) (f : A → B) where
↓-∘=idf-from-square : {x y : A} {p : x == y}
{u : g (f x) == x} {v : g (f y) == y}
→ Square u (ap g (ap f p)) p v
→ (u == v [ (λ z → g (f z) == z) ↓ p ])
↓-∘=idf-from-square {p = idp} sq = horiz-degen-path sq
↓-∘=idf-to-square : {x y : A} {p : x == y}
{u : g (f x) == x} {v : g (f y) == y}
→ (u == v [ (λ z → g (f z) == z) ↓ p ])
→ Square u (ap g (ap f p)) p v
↓-∘=idf-to-square {p = idp} α = horiz-degen-square α
_⊡v_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₀₂ a₁₂ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
{q₀₋ : a₀₁ == a₀₂} {q₋₂ : a₀₂ == a₁₂} {q₁₋ : a₁₁ == a₁₂}
→ Square p₀₋ p₋₀ p₋₁ p₁₋ → Square q₀₋ p₋₁ q₋₂ q₁₋
→ Square (p₀₋ ∙ q₀₋) p₋₀ q₋₂ (p₁₋ ∙ q₁₋)
ids ⊡v sq = sq
_⊡v'_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₀₂ a₁₂ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
{q₀₋ : a₀₁ == a₀₂} {q₋₂ : a₀₂ == a₁₂} {q₁₋ : a₁₁ == a₁₂}
→ Square p₀₋ p₋₀ p₋₁ p₁₋ → Square q₀₋ p₋₁ q₋₂ q₁₋
→ Square (p₀₋ ∙' q₀₋) p₋₀ q₋₂ (p₁₋ ∙' q₁₋)
sq ⊡v' ids = sq
_∙v⊡_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ p₋₀' : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ p₋₀ == p₋₀'
→ Square p₀₋ p₋₀' p₋₁ p₁₋
→ Square p₀₋ p₋₀ p₋₁ p₁₋
idp ∙v⊡ sq = sq
_⊡v∙_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ p₋₁' : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋
→ p₋₁ == p₋₁'
→ Square p₀₋ p₋₀ p₋₁' p₁₋
sq ⊡v∙ idp = sq
_⊡h_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₂₀ a₂₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
{q₋₀ : a₁₀ == a₂₀} {q₋₁ : a₁₁ == a₂₁} {q₂₋ : a₂₀ == a₂₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋
→ Square p₁₋ q₋₀ q₋₁ q₂₋
→ Square p₀₋ (p₋₀ ∙ q₋₀) (p₋₁ ∙ q₋₁) q₂₋
ids ⊡h sq = sq
_⊡h'_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₂₀ a₂₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
{q₋₀ : a₁₀ == a₂₀} {q₋₁ : a₁₁ == a₂₁} {q₂₋ : a₂₀ == a₂₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋
→ Square p₁₋ q₋₀ q₋₁ q₂₋
→ Square p₀₋ (p₋₀ ∙' q₋₀) (p₋₁ ∙' q₋₁) q₂₋
sq ⊡h' ids = sq
_∙h⊡_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ p₀₋' : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ p₀₋ == p₀₋'
→ Square p₀₋' p₋₀ p₋₁ p₁₋
→ Square p₀₋ p₋₀ p₋₁ p₁₋
idp ∙h⊡ sq = sq
_⊡h∙_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ p₁₋' : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋
→ p₁₋ == p₁₋'
→ Square p₀₋ p₋₀ p₋₁ p₁₋'
sq ⊡h∙ idp = sq
infixr 80 _⊡v_ _⊡v'_ _⊡h_ _⊡h'_
infixr 80 _∙v⊡_ _∙h⊡_
infixl 85 _⊡v∙_ _⊡h∙_
∙h⊡-hid-square-⊡h∙ : ∀ {i} {A : Type i} {a₀₀ a₀₁ : A} {p p' : a₀₀ == a₀₁}
(q : p' == p)
→ ! q ∙h⊡ hid-square ⊡h∙ q == hid-square
∙h⊡-hid-square-⊡h∙ q@idp = idp
∙v⊡-assoc : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ p₋₀' p₋₀'' : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(q : p₋₀ == p₋₀')
(r : p₋₀' == p₋₀'')
(sq : Square p₀₋ p₋₀'' p₋₁ p₁₋)
→ (q ∙ r) ∙v⊡ sq == q ∙v⊡ (r ∙v⊡ sq)
∙v⊡-assoc q@idp r sq = idp
⊡v∙-assoc : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ p₋₁' p₋₁'' : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
(q : p₋₁ == p₋₁')
(r : p₋₁' == p₋₁'')
→ (sq ⊡v∙ q) ⊡v∙ r == sq ⊡v∙ (q ∙ r)
⊡v∙-assoc sq q@idp r = idp
⊡h∙-assoc : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ p₁₋' p₁₋'' : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
(q : p₁₋ == p₁₋')
(r : p₁₋' == p₁₋'')
→ (sq ⊡h∙ q) ⊡h∙ r == sq ⊡h∙ (q ∙ r)
⊡h∙-assoc sq q@idp r = idp
∙v⊡-⊡h∙-comm : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ p₋₀' : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ p₁₋' : a₁₀ == a₁₁}
(q : p₋₀ == p₋₀')
(sq : Square p₀₋ p₋₀' p₋₁ p₁₋)
(r : p₁₋ == p₁₋')
→ (q ∙v⊡ sq) ⊡h∙ r == q ∙v⊡ (sq ⊡h∙ r)
∙v⊡-⊡h∙-comm q@idp sq r = idp
⊡v∙-⊡h∙-comm : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ p₋₁' : a₀₁ == a₁₁} {p₁₋ p₁₋' : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
(q : p₋₁ == p₋₁')
(r : p₁₋ == p₁₋')
→ (sq ⊡v∙ q) ⊡h∙ r == (sq ⊡h∙ r) ⊡v∙ q
⊡v∙-⊡h∙-comm sq q@idp r = idp
∙v⊡-⊡v∙-comm : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ p₋₀' : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ p₋₁' : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(q : p₋₀ == p₋₀')
(sq : Square p₀₋ p₋₀' p₋₁ p₁₋)
(r : p₋₁ == p₋₁')
→ (q ∙v⊡ sq) ⊡v∙ r == q ∙v⊡ (sq ⊡v∙ r)
∙v⊡-⊡v∙-comm q@idp sq r = idp
∙h⊡-⊡h∙-comm : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ : a₀₀ == a₁₀} {p₀₋ p₀₋' : a₀₀ == a₀₁}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ p₁₋' : a₁₀ == a₁₁}
(q : p₀₋ == p₀₋')
(sq : Square p₀₋' p₋₀ p₋₁ p₁₋)
(r : p₁₋ == p₁₋')
→ (q ∙h⊡ sq) ⊡h∙ r == q ∙h⊡ (sq ⊡h∙ r)
∙h⊡-⊡h∙-comm q@idp sq r = idp
⊡h-⊡v∙-comm : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₂₀ a₂₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ p₋₁' : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
{q₋₀ : a₁₀ == a₂₀} {q₋₁ q₋₁' : a₁₁ == a₂₁} {q₂₋ : a₂₀ == a₂₁}
(p-sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
(q-sq : Square p₁₋ q₋₀ q₋₁ q₂₋)
(r : p₋₁ == p₋₁')
(s : q₋₁ == q₋₁')
→ (p-sq ⊡h q-sq) ⊡v∙ (ap2 _∙_ r s) == (p-sq ⊡v∙ r) ⊡h (q-sq ⊡v∙ s)
⊡h-⊡v∙-comm p-sq q-sq r@idp s@idp = idp
module _ {i j} {A : Type i} {B : Type j} (f : A → B) where
ap-square-∙v⊡ : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ p₋₀' : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(q : p₋₀ == p₋₀')
(sq : Square p₀₋ p₋₀' p₋₁ p₁₋)
→ ap (ap f) q ∙v⊡ ap-square f sq == ap-square f (q ∙v⊡ sq)
ap-square-∙v⊡ q@idp sq = idp
ap-square-⊡v∙ : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₋₀ : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁}
{p₋₁ p₋₁' : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
(q : p₋₁ == p₋₁')
→ ap-square f sq ⊡v∙ ap (ap f) q == ap-square f (sq ⊡v∙ q)
ap-square-⊡v∙ sq q@idp = idp
module _ {i j} {A : Type i} {B : Type j} {f g : A → B} where
↓-='-to-square : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ u == v [ (λ z → f z == g z) ↓ p ]
→ Square u (ap f p) (ap g p) v
↓-='-to-square {p = idp} α = horiz-degen-square α
↓-='-from-square : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ Square u (ap f p) (ap g p) v
→ u == v [ (λ z → f z == g z) ↓ p ]
↓-='-from-square {p = idp} sq = horiz-degen-path sq
↓-='-square-comp : {x y z : A} {p : x == y} {q : y == z}
{u : f x == g x} {v : f y == g y} {w : f z == g z}
→ Square u (ap f p) (ap g p) v
→ Square v (ap f q) (ap g q) w
→ Square u (ap f (p ∙ q)) (ap g (p ∙ q)) w
↓-='-square-comp {p = idp} {q = idp} sq₁ sq₂ =
horiz-degen-square (horiz-degen-path sq₁ ∙ horiz-degen-path sq₂)
↓-='-from-square-comp : {x y z : A} {p : x == y} {q : y == z}
{u : f x == g x} {v : f y == g y} {w : f z == g z}
(sq₁ : Square u (ap f p) (ap g p) v)
(sq₂ : Square v (ap f q) (ap g q) w)
→ ↓-='-from-square (↓-='-square-comp sq₁ sq₂) ==
↓-='-from-square sq₁ ∙ᵈ ↓-='-from-square sq₂
↓-='-from-square-comp {p = idp} {q = idp} sq₁ sq₂ =
horiz-degen-path-β _
private
custom-square-over :
{x y z : A} {p : x == y} {q : y == z} {r : x == z}
(comp : r == p ∙ q)
{u : f x == g x} {v : f y == g y} {w : f z == g z}
(p-sq : Square u (ap f p) (ap g p) v)
(q-sq : Square v (ap f q) (ap g q) w)
(r-sq : Square u (ap f r) (ap g r) w)
→ r-sq ⊡v∙ ap (ap g) comp ==
ap (ap f) comp ∙v⊡ ↓-='-square-comp p-sq q-sq
→ r-sq == ↓-='-square-comp p-sq q-sq
[ (λ s → Square u (ap f s) (ap g s) w) ↓ comp ]
custom-square-over {p = idp} {q = idp} {r = .idp} idp p-sq q-sq r-sq e = e
↓-='-from-square-comp-path :
{x y z : A} {p : x == y} {q : y == z} {r : x == z}
(comp : r == p ∙ q)
{u : f x == g x} {v : f y == g y} {w : f z == g z}
(p-sq : Square u (ap f p) (ap g p) v)
(q-sq : Square v (ap f q) (ap g q) w)
(r-sq : Square u (ap f r) (ap g r) w)
→ r-sq ⊡v∙ ap (ap g) comp ==
ap (ap f) comp ∙v⊡ ↓-='-square-comp p-sq q-sq
→ ↓-='-from-square r-sq == ↓-='-from-square p-sq ∙ᵈ ↓-='-from-square q-sq
[ (λ p → u == w [ (λ x → f x == g x) ↓ p ]) ↓ comp ]
↓-='-from-square-comp-path comp p-sq q-sq r-sq e =
ap↓ ↓-='-from-square (custom-square-over comp p-sq q-sq r-sq e) ▹
↓-='-from-square-comp p-sq q-sq
↓-='-from-square-! : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B}
{x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
(sq : Square u (ap f p) (ap g p) v)
→ ap↓ ! (↓-='-from-square sq) == ↓-='-from-square (!□v sq)
↓-='-from-square-! {p = idp} sq =
ap ! (horiz-degen-path sq)
=⟨ ! (horiz-degen-path-β (ap ! (horiz-degen-path sq))) ⟩
horiz-degen-path (horiz-degen-square (ap ! (horiz-degen-path sq)))
=⟨ ap horiz-degen-path (! (!□v-horiz-degen-square (horiz-degen-path sq))) ⟩
horiz-degen-path (!□v (horiz-degen-square (horiz-degen-path sq)))
=⟨ ap (horiz-degen-path ∘ !□v) (horiz-degen-square-β sq) ⟩
horiz-degen-path (!□v sq) =∎
↓-='-from-square-post-∘ : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
{f g : A → B} {h : B → C}
{x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (sq : Square u (ap f p) (ap g p) v)
→ ap↓ (ap h) (↓-='-from-square sq)
==
↓-='-from-square (ap-∘ h f p ∙v⊡ ap-square h sq ⊡v∙ ∘-ap h g p)
↓-='-from-square-post-∘ {h = h} {p = idp} sq =
ap (ap h) (horiz-degen-path sq)
=⟨ ! (horiz-degen-path-β (ap (ap h) (horiz-degen-path sq))) ⟩
horiz-degen-path (horiz-degen-square (ap (ap h) (horiz-degen-path sq)))
=⟨ ap horiz-degen-path (! (ap-horiz-degen-square h (horiz-degen-path sq))) ⟩
horiz-degen-path (ap-square h (horiz-degen-square (horiz-degen-path sq)))
=⟨ ap (horiz-degen-path ∘ ap-square h) (horiz-degen-square-β sq) ⟩
horiz-degen-path (ap-square h sq) =∎
module _ {i j} {A : Type i} {B : Type j} where
natural-square : {f₁ f₂ : A → B} (h : ∀ a → f₁ a == f₂ a)
{a₁ a₂ : A} (q : a₁ == a₂)
→ Square (h a₁) (ap f₁ q) (ap f₂ q) (h a₂)
natural-square h idp = hid-square
natural-square-path : {f₁ f₂ : A → B} (h h' : ∀ a → f₁ a == f₂ a)
(H : ∀ a → h' a == h a)
{a₁ a₂ : A} (q : a₁ == a₂)
→ ! (H a₁) ∙h⊡ natural-square h' q ⊡h∙ H a₂ == natural-square h q
natural-square-path h h' H {a₁} idp = ∙h⊡-hid-square-⊡h∙ (H a₁)
natural-square-idp : {f₁ : A → B} {a₁ a₂ : A} (q : a₁ == a₂)
→ natural-square {f₁ = f₁} (λ _ → idp) q == vid-square
natural-square-idp idp = idp
natural-square-cst : ∀ (b₁ b₂ : B) (h : A → b₁ == b₂)
{a₁ a₂ : A} (q : a₁ == a₂)
→ ! (ap-cst b₁ q) ∙v⊡ natural-square {f₁ = λ a → b₁} {f₂ = λ a → b₂} h q ⊡v∙ ap-cst b₂ q
==
horiz-degen-square (ap h q)
natural-square-cst b₁ b₂ h q@idp = ! horiz-degen-square-idp
{- Used for getting square equivalents of glue-β terms -}
natural-square-β : {f₁ f₂ : A → B} (h : (a : A) → f₁ a == f₂ a)
{x y : A} (q : x == y)
{sq : Square (h x) (ap f₁ q) (ap f₂ q) (h y)}
→ apd h q == ↓-='-from-square sq
→ natural-square h q == sq
natural-square-β _ idp α =
! horiz-degen-square-idp ∙ ap horiz-degen-square α ∙ horiz-degen-square-β _
module _ {i j k} {A : Type i} {B : Type j} {C : Type k} where
natural-square-ap : (g : B → C)
{f₁ f₂ : A → B} (h : ∀ a → f₁ a == f₂ a)
{a₁ a₂ : A} (q : a₁ == a₂)
→ natural-square (ap g ∘ h) q
==
ap-∘ g f₁ q ∙v⊡
ap-square g (natural-square h q) ⊡v∙
∘-ap g f₂ q
natural-square-ap g h q@idp = ! ap-square-hid
natural-square-symmetry : (f : A → B → C)
{a₁ a₂ : A} (p : a₁ == a₂)
{b₁ b₂ : B} (q : b₁ == b₂)
→ square-symmetry (natural-square (λ b → ap (λ a → f a b) p) q)
==
natural-square (λ a → ap (f a) q) p
natural-square-symmetry f p@idp q@idp = idp
module _ {i} {A : Type i} where
horiz-degen-path-⊡h : {a a' : A} {p q r : a == a'}
(sq₁ : Square p idp idp q)
(sq₂ : Square q idp idp r)
→ horiz-degen-path (sq₁ ⊡h sq₂) ==
horiz-degen-path sq₁ ∙ horiz-degen-path sq₂
horiz-degen-path-⊡h {p = idp} {q = .idp} ids sq₂ = idp
vert-degen-square-⊡v∙ : {a a' : A} {p q r : a == a'}
→ (s : p == q) (t : q == r)
→ vert-degen-square s ⊡v∙ t == vert-degen-square (s ∙ t)
vert-degen-square-⊡v∙ idp idp = idp
vert-degen-square-∙v⊡ : {a a' : A} {p q r : a == a'}
→ (s : p == q) (t : q == r)
→ s ∙v⊡ vert-degen-square t == vert-degen-square (s ∙ t)
vert-degen-square-∙v⊡ idp idp = idp
vert-degen-square-⊡h : {a a' a'' : A}
{p p' : a == a'} {q q' : a' == a''}
(s : p == p') (t : q == q')
→ vert-degen-square s ⊡h vert-degen-square t ==
vert-degen-square (ap2 _∙_ s t)
vert-degen-square-⊡h {p = idp} idp idp = idp
module _ {i j} {A : Type i} {B : Type j} {f g : A → B} where
↓-='-square-comp' : {x y z : A} {p : x == y} {q : y == z}
{u : f x == g x} {v : f y == g y} {w : f z == g z}
→ Square u (ap f p) (ap g p) v
→ Square v (ap f q) (ap g q) w
→ Square u (ap f (p ∙ q)) (ap g (p ∙ q)) w
↓-='-square-comp' {p = p} {q = q} sq₁ sq₂ =
ap-∙ f p q ∙v⊡ ((sq₁ ⊡h sq₂) ⊡v∙ ∙-ap g p q)
↓-='-square-comp'=↓-='-square-comp : {x y z : A} {p : x == y} {q : y == z}
{u : f x == g x} {v : f y == g y} {w : f z == g z}
→ (sq₁ : Square u (ap f p) (ap g p) v)
→ (sq₂ : Square v (ap f q) (ap g q) w)
→ ↓-='-square-comp' sq₁ sq₂ == ↓-='-square-comp sq₁ sq₂
↓-='-square-comp'=↓-='-square-comp {p = idp} {q = idp} sq₁ sq₂ =
↓-='-square-comp' sq₁ sq₂
=⟨ idp ⟩
sq₁ ⊡h sq₂
=⟨ ! (horiz-degen-square-β (sq₁ ⊡h sq₂)) ⟩
horiz-degen-square (horiz-degen-path (sq₁ ⊡h sq₂))
=⟨ ap horiz-degen-square (horiz-degen-path-⊡h sq₁ sq₂) ⟩
horiz-degen-square (horiz-degen-path sq₁ ∙ horiz-degen-path sq₂) =∎
module _ {i} {A : Type i} where
{- TODO rest of these -}
⊡h-unit-l : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ hid-square ⊡h sq == sq
⊡h-unit-l ids = idp
⊡h-unit-r : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ sq ⊡h hid-square == ∙-unit-r _ ∙v⊡ (sq ⊡v∙ ! (∙-unit-r _))
⊡h-unit-r ids = idp
⊡h'-unit-l : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ hid-square ⊡h' sq == ∙'-unit-l _ ∙v⊡ (sq ⊡v∙ ! (∙'-unit-l _))
⊡h'-unit-l ids = idp
⊡h-unit-l-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq' : Square p₀₋ idp idp p₀₋) (sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ sq' ⊡h sq == sq
→ sq' == hid-square
⊡h-unit-l-unique sq' ids p = ! (⊡h-unit-r sq') ∙ p
module _ {i} {A : Type i} where
!□h-inv-l : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ (!□h sq) ⊡h sq == !-inv-l p₋₀ ∙v⊡ (hid-square ⊡v∙ ! (!-inv-l p₋₁))
!□h-inv-l ids = idp
!□h-inv-r : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ sq ⊡h (!□h sq) == !-inv-r p₋₀ ∙v⊡ (hid-square ⊡v∙ ! (!-inv-r p₋₁))
!□h-inv-r ids = idp
!□v-inv-l : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ (!□v sq) ⊡v sq == !-inv-l p₀₋ ∙h⊡ (vid-square ⊡h∙ ! (!-inv-l p₁₋))
!□v-inv-l ids = idp
!□v-inv-r : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
→ sq ⊡v (!□v sq) == !-inv-r p₀₋ ∙h⊡ (vid-square ⊡h∙ ! (!-inv-r p₁₋))
!□v-inv-r ids = idp
module _ {i} {A : Type i} where
square-left-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ p₀₋' : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋' p₋₀ p₋₁ p₁₋
→ p₀₋ == p₀₋'
square-left-unique {p₋₀ = idp} {p₋₁ = idp} sq₁ sq₂ =
horiz-degen-path (sq₁ ⊡h (!□h sq₂))
square-top-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ p₋₀' : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ p₋₀' p₋₁ p₁₋
→ p₋₀ == p₋₀'
square-top-unique {p₀₋ = idp} {p₁₋ = idp} sq₁ sq₂ =
vert-degen-path (sq₁ ⊡v (!□v sq₂))
square-bot-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ p₋₁' : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ p₋₀ p₋₁' p₁₋
→ p₋₁ == p₋₁'
square-bot-unique {p₀₋ = idp} {p₁₋ = idp} sq₁ sq₂ =
vert-degen-path ((!□v sq₁) ⊡v sq₂)
square-right-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}
{p₋₁ : a₀₁ == a₁₁} {p₁₋ p₁₋' : a₁₀ == a₁₁}
→ Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ p₋₀ p₋₁ p₁₋'
→ p₁₋ == p₁₋'
square-right-unique {p₋₀ = idp} {p₋₁ = idp} sq₁ sq₂ =
horiz-degen-path ((!□h sq₁) ⊡h sq₂)
module _ {i} {A : Type i} where
{- XXX naminig -}
connection : {a₀ a₁ : A} {q : a₀ == a₁}
→ Square idp idp q q
connection {q = idp} = ids
{- XXX naminig -}
connection2 : {a₀ a₁ a₂ : A} {p : a₀ == a₁} {q : a₁ == a₂}
→ Square p p q q
connection2 {p = idp} {q = idp} = ids
lb-square : {a₀ a₁ : A} (p : a₀ == a₁)
→ Square p idp (! p) idp
lb-square idp = ids
bl-square : {a₀ a₁ : A} (p : a₀ == a₁)
→ Square (! p) idp p idp
bl-square idp = ids
br-square : {a₀ a₁ : A} (p : a₀ == a₁)
→ Square idp idp p p
br-square idp = ids
rb-square = br-square
rt-square : {a₀ a₁ : A} (p : a₀ == a₁)
→ Square idp (! p) idp p
rt-square idp = ids
tr-square : {a₀ a₁ : A} (p : a₀ == a₁)
→ Square idp p idp (! p)
tr-square idp = ids
lt-square : {a₀ a₁ : A} (p : a₀ == a₁)
→ Square p p idp idp
lt-square idp = ids
tl-square = lt-square
tr-square-∙v⊡-⊡h∙ : {a₀ a₁ : A} {p p' : a₀ == a₁} (r : p == p')
→ ! r ∙v⊡ tr-square p ⊡h∙ ap ! r == tr-square p'
tr-square-∙v⊡-⊡h∙ r@idp = idp
tr-square-! : {a₀ a₁ : A} (p : a₀ == a₁)
→ tr-square (! p) ⊡h∙ !-! p == rt-square p
tr-square-! p@idp = idp
module _ {i} {j} {A : Type i} {B : Type j} (f : A → B) where
ap-tr-square : {a₀ a₁ : A} (p : a₀ == a₁)
→ ap-square f (tr-square p) ⊡h∙ ap-! f p == tr-square (ap f p)
ap-tr-square p@idp = idp
|
Transynther/x86/_processed/AVXALIGN/_st_sm_/i7-7700_9_0xca_notsx.log_21829_33.asm
|
ljhsiun2/medusa
| 9 |
3083
|
<filename>Transynther/x86/_processed/AVXALIGN/_st_sm_/i7-7700_9_0xca_notsx.log_21829_33.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x19a29, %rsi
lea addresses_WC_ht+0x133a1, %rdi
nop
nop
nop
nop
nop
add $50932, %r15
mov $82, %rcx
rep movsq
nop
nop
nop
nop
nop
cmp %rdx, %rdx
lea addresses_WT_ht+0x149a1, %rsi
lea addresses_A_ht+0x1b4fd, %rdi
nop
nop
nop
nop
nop
add $11267, %r9
mov $123, %rcx
rep movsl
nop
nop
nop
nop
nop
sub %r15, %r15
lea addresses_WC_ht+0x12f23, %rsi
lea addresses_normal_ht+0x1ec19, %rdi
sub %rax, %rax
mov $97, %rcx
rep movsq
nop
nop
nop
nop
dec %r15
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r13
push %r8
push %rdx
push %rsi
// Store
lea addresses_WC+0x41a1, %rdx
nop
nop
inc %r8
mov $0x5152535455565758, %r11
movq %r11, %xmm5
vmovups %ymm5, (%rdx)
nop
nop
nop
sub $23964, %rdx
// Faulty Load
lea addresses_WC+0x41a1, %r13
nop
nop
sub $4110, %rsi
mov (%r13), %edx
lea oracles, %r12
and $0xff, %rdx
shlq $12, %rdx
mov (%r12,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %r8
pop %r13
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_WC'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_WC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
programs/oeis/080/A080855.asm
|
neoneye/loda
| 22 |
240915
|
; A080855: a(n) = (9*n^2 - 3*n + 2)/2.
; 1,4,16,37,67,106,154,211,277,352,436,529,631,742,862,991,1129,1276,1432,1597,1771,1954,2146,2347,2557,2776,3004,3241,3487,3742,4006,4279,4561,4852,5152,5461,5779,6106,6442,6787,7141,7504,7876,8257,8647,9046,9454,9871,10297,10732,11176,11629,12091,12562,13042,13531,14029,14536,15052,15577,16111,16654,17206,17767,18337,18916,19504,20101,20707,21322,21946,22579,23221,23872,24532,25201,25879,26566,27262,27967,28681,29404,30136,30877,31627,32386,33154,33931,34717,35512,36316,37129,37951,38782,39622,40471,41329,42196,43072,43957
mul $0,3
bin $0,2
add $0,1
|
text/ada/create/text_create.adb
|
ekzemplaro/data_base_language
| 3 |
1485
|
-- ----------------------------------------------------------------
-- text_create.adb
--
-- Oct/10/2011
--
-- ----------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams;
with Ada.Command_Line;
-- ----------------------------------------------------------------
procedure text_create is
procedure record_out_proc
(Outfile : File_Type;
key: in String;
name: in String;
population: in String;
date_mod: in String) is
begin
Ada.Text_IO.Put_Line("*** record_out_proc ***");
String'Write (Stream (Outfile),
key & ASCII.HT & name &ASCII.HT
& population & ASCII.HT & date_mod & ASCII.LF);
end record_out_proc;
Outfile : File_Type;
file_text : String := Ada.Command_Line.Argument (1);
begin
Ada.Text_IO.Put_Line("*** 開始 ***");
Create (File => Outfile, Mode => Out_File, Name => file_text);
record_out_proc (Outfile,"t2381","名古屋","47325","1943-6-28");
record_out_proc (Outfile,"t2382","豊橋","82467","1943-3-15");
record_out_proc (Outfile,"t2383","岡崎","39254","1943-8-9");
record_out_proc (Outfile,"t2384","一宮","54792","1943-6-3");
record_out_proc (Outfile,"t2385","蒲郡","84327","1943-1-12");
record_out_proc (Outfile,"t2386","常滑","32198","1943-2-7");
record_out_proc (Outfile,"t2387","大府","54982","1943-10-21");
record_out_proc (Outfile,"t2388","瀬戸","97623","1943-5-12");
record_out_proc (Outfile,"t2389","犬山","47859","1943-4-24");
Close (Outfile);
Ada.Text_IO.Put_Line("*** 終了 ***");
end Text_create;
-- ----------------------------------------------------------------
|
oeis/155/A155151.asm
|
neoneye/loda-programs
| 11 |
92013
|
; A155151: Triangle T(n, k) = 4*n*k + 2*n + 2*k + 2, read by rows.
; Submitted by <NAME>
; 10,16,26,22,36,50,28,46,64,82,34,56,78,100,122,40,66,92,118,144,170,46,76,106,136,166,196,226,52,86,120,154,188,222,256,290,58,96,134,172,210,248,286,324,362,64,106,148,190,232,274,316,358,400,442,70,116,162,208,254,300,346,392,438,484,530,76,126,176,226,276,326,376,426,476,526,576,626,82,136,190,244,298,352,406,460,514,568,622,676,730,88,146,204,262,320,378,436,494,552
mul $0,2
add $0,1
lpb $0
mov $2,$0
sub $0,2
trn $0,$1
add $1,2
add $2,2
lpe
add $1,1
mul $1,$2
mov $0,$1
add $0,1
|
Numbers/Naturals/Multiplication.agda
|
Smaug123/agdaproofs
| 4 |
14539
|
<reponame>Smaug123/agdaproofs<gh_stars>1-10
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Definition
open import Numbers.Naturals.Addition
module Numbers.Naturals.Multiplication where
infix 25 _*N_
_*N_ : ℕ → ℕ → ℕ
zero *N y = zero
(succ x) *N y = y +N (x *N y)
{-# BUILTIN NATTIMES _*N_ #-}
productZeroIsZeroLeft : (a : ℕ) → (zero *N a ≡ zero)
productZeroIsZeroLeft a = refl
productZeroIsZeroRight : (a : ℕ) → (a *N zero ≡ zero)
productZeroIsZeroRight zero = refl
productZeroIsZeroRight (succ a) = productZeroIsZeroRight a
productWithOneLeft : (a : ℕ) → ((succ zero) *N a) ≡ a
productWithOneLeft a = transitivity refl (transitivity (applyEquality (λ { m -> a +N m }) refl) (additionNIsCommutative a zero))
productWithOneRight : (a : ℕ) → a *N succ zero ≡ a
productWithOneRight zero = refl
productWithOneRight (succ a) = transitivity refl (addingPreservesEqualityLeft (succ zero) (productWithOneRight a))
productDistributes : (a b c : ℕ) → (a *N (b +N c)) ≡ a *N b +N a *N c
productDistributes zero b c = refl
productDistributes (succ a) b c = transitivity refl
(transitivity (addingPreservesEqualityLeft (b +N c) (productDistributes a b c))
(transitivity (equalityCommutative (additionNIsAssociative (b +N c) (a *N b) (a *N c)))
(transitivity (addingPreservesEqualityRight (a *N c) (additionNIsCommutative (b +N c) (a *N b)))
(transitivity (addingPreservesEqualityRight (a *N c) (equalityCommutative (additionNIsAssociative (a *N b) b c)))
(transitivity (addingPreservesEqualityRight (a *N c) (addingPreservesEqualityRight c (additionNIsCommutative (a *N b) b)))
(transitivity (addingPreservesEqualityRight (a *N c) (addingPreservesEqualityRight {b +N a *N b} {(succ a) *N b} c (refl)))
(transitivity (additionNIsAssociative ((succ a) *N b) c (a *N c))
(transitivity (addingPreservesEqualityLeft (succ a *N b) refl)
refl)
)
))))))
productPreservesEqualityLeft : (a : ℕ) → {b c : ℕ} → b ≡ c → a *N b ≡ a *N c
productPreservesEqualityLeft a {b} {.b} refl = refl
aSucB : (a b : ℕ) → a *N succ b ≡ a *N b +N a
aSucB a b = transitivity {_} {ℕ} {a *N succ b} {a *N (b +N succ zero)} (productPreservesEqualityLeft a (succIsAddOne b)) (transitivity {_} {ℕ} {a *N (b +N succ zero)} {a *N b +N a *N succ zero} (productDistributes a b (succ zero)) (addingPreservesEqualityLeft (a *N b) (productWithOneRight a)))
aSucBRight : (a b : ℕ) → (succ a) *N b ≡ a *N b +N b
aSucBRight a b = additionNIsCommutative b (a *N b)
multiplicationNIsCommutative : (a b : ℕ) → (a *N b) ≡ (b *N a)
multiplicationNIsCommutative zero b = transitivity (productZeroIsZeroLeft b) (equalityCommutative (productZeroIsZeroRight b))
multiplicationNIsCommutative (succ a) zero = multiplicationNIsCommutative a zero
multiplicationNIsCommutative (succ a) (succ b) = transitivity refl
(transitivity (addingPreservesEqualityLeft (succ b) (aSucB a b))
(transitivity (additionNIsCommutative (succ b) (a *N b +N a))
(transitivity (additionNIsAssociative (a *N b) a (succ b))
(transitivity (addingPreservesEqualityLeft (a *N b) (succCanMove a b))
(transitivity (addingPreservesEqualityLeft (a *N b) (additionNIsCommutative (succ a) b))
(transitivity (equalityCommutative (additionNIsAssociative (a *N b) b (succ a)))
(transitivity (addingPreservesEqualityRight (succ a) (equalityCommutative (aSucBRight a b)))
(transitivity (addingPreservesEqualityRight (succ a) (multiplicationNIsCommutative (succ a) b))
(transitivity (additionNIsCommutative (b *N (succ a)) (succ a))
refl
)))))))))
productDistributes' : (a b c : ℕ) → (a +N b) *N c ≡ a *N c +N b *N c
productDistributes' a b c rewrite multiplicationNIsCommutative (a +N b) c | productDistributes c a b | multiplicationNIsCommutative c a | multiplicationNIsCommutative c b = refl
flipProductsWithinSum : (a b c : ℕ) → (c *N a +N c *N b ≡ a *N c +N b *N c)
flipProductsWithinSum a b c = transitivity (addingPreservesEqualityRight (c *N b) (multiplicationNIsCommutative c a)) ((addingPreservesEqualityLeft (a *N c) (multiplicationNIsCommutative c b)))
productDistributesRight : (a b c : ℕ) → (a +N b) *N c ≡ a *N c +N b *N c
productDistributesRight a b c = transitivity (multiplicationNIsCommutative (a +N b) c) (transitivity (productDistributes c a b) (flipProductsWithinSum a b c))
multiplicationNIsAssociative : (a b c : ℕ) → (a *N (b *N c)) ≡ ((a *N b) *N c)
multiplicationNIsAssociative zero b c = refl
multiplicationNIsAssociative (succ a) b c =
transitivity refl
(transitivity refl
(transitivity (applyEquality ((λ x → b *N c +N x)) (multiplicationNIsAssociative a b c)) (transitivity (equalityCommutative (productDistributesRight b (a *N b) c)) refl)))
productOne : {a b : ℕ} → a ≡ a *N b → (a ≡ 0) || (b ≡ 1)
productOne {zero} {b} pr = inl refl
productOne {succ a} {zero} pr rewrite multiplicationNIsCommutative a 0 = exFalso (naughtE (equalityCommutative pr))
productOne {succ a} {succ zero} pr = inr refl
productOne {succ a} {succ (succ b)} pr rewrite multiplicationNIsCommutative a (succ (succ b)) | additionNIsCommutative (succ b) (a +N (a +N b *N a)) | additionNIsAssociative (succ a) (a +N b *N a) (succ b) | additionNIsCommutative (a +N b *N a) (succ b) = exFalso (bad pr)
where
bad' : {x : ℕ} → x ≡ succ x → False
bad' ()
bad : {x y : ℕ} → x ≡ x +N succ y → False
bad {succ x} {zero} pr rewrite additionNIsCommutative x 1 = bad' pr
bad {succ x} {succ y} pr = bad (succInjective pr)
|
cbm8bit/src/telnetml.asm
|
smay4finger/Zimodem
| 0 |
161106
|
<reponame>smay4finger/Zimodem
* = 0
; .D TELNETML.BIN
; TERMINAL ML 64 BY <NAME>
; UPDATED 2017/01/01 07:44P
; TERMSETUP LDA $DD01:AND #$10:STA DCDCHK
TERMINAL
LDX #$05
JSR $FFC6
JSR $FFE4
CMP #$00
BEQ TERMK
CMP #$0A
BEQ TERMK
JSR $FFD2
; TERMK LDA $DD01:AND #$10:BNE TERMK2:LDA DCDCHK:BNE ESCOUT
LDA $029B
CMP $029C
BEQ BUFUP
BCS BUFL1
LDA #$FF
SEC
SBC $029C
CLC
ADC $029B
SEC
BCS BUFL2
BUFL1
SEC
SBC $029C
BUFL2
CMP #200
BCC BUFL3
LDA $DD01
AND #$FD
STA $DD01
SEC
BCS TERMK
BUFL3 CMP #20
BCS TERMK
BUFUP
LDA $DD01
ORA #$02
STA $DD01
TERMK
LDX #$00
JSR $FFC6
JSR $FFE4
CMP #$00
BEQ TERMINAL
CMP #$85
BEQ ESCOUT
CMP #$1B
BNE TERMOUT
ESCOUT
JSR $FFCC
RTS
TERMOUT
PHA
LDX #$05
JSR $FFC9
PLA
JSR $FFD2
LDX #$00
JSR $FFC9
SEC
BCS TERMINAL
; DCDCHK = $4D
PRINT
NOP; :F$="TELNETML.BAS":OPEN8,8,15,"S0:TELNETML*":SAVEF$,8:VERIFYF$,8
|
scripts/CeladonMart5F.asm
|
opiter09/ASM-Machina
| 1 |
2371
|
<reponame>opiter09/ASM-Machina
CeladonMart5F_Script:
jp EnableAutoTextBoxDrawing
CeladonMart5F_TextPointers:
dw CeladonMart5Text1
dw CeladonMart5Text2
dw CeladonMart5Clerk1Text
dw CeladonMart5Clerk2Text
dw CeladonMart5Text5
CeladonMart5Text1:
text_far _CeladonMart5Text1
text_end
CeladonMart5Text2:
text_far _CeladonMart5Text2
text_end
CeladonMart5Text5:
text_far _CeladonMart5Text5
text_end
|
FormalAnalyzer/models/meta/cap_garageDoorControl.als
|
Mohannadcse/IoTCOM_BehavioralRuleExtractor
| 0 |
1750
|
// filename: cap_garageDoorControl.als
module cap_garageDoorControl
open IoTBottomUp
one sig cap_garageDoorControl extends Capability {}
{
attributes = cap_garageDoorControl_attr
}
abstract sig cap_garageDoorControl_attr extends Attribute {}
one sig cap_garageDoorControl_attr_door extends cap_garageDoorControl_attr {}
{
values = cap_garageDoorControl_attr_door_val
}
abstract sig cap_garageDoorControl_attr_door_val extends AttrValue {}
one sig cap_garageDoorControl_attr_door_val_closed extends cap_garageDoorControl_attr_door_val {}
one sig cap_garageDoorControl_attr_door_val_closing extends cap_garageDoorControl_attr_door_val {}
one sig cap_garageDoorControl_attr_door_val_open extends cap_garageDoorControl_attr_door_val {}
one sig cap_garageDoorControl_attr_door_val_opening extends cap_garageDoorControl_attr_door_val {}
one sig cap_garageDoorControl_attr_door_val_unknown extends cap_garageDoorControl_attr_door_val {}
|
libsrc/_DEVELOPMENT/math/float/math16/c/sdcc/cm16_sdcc_frexp.asm
|
Frodevan/z88dk
| 640 |
98891
|
<reponame>Frodevan/z88dk<filename>libsrc/_DEVELOPMENT/math/float/math16/c/sdcc/cm16_sdcc_frexp.asm<gh_stars>100-1000
SECTION code_fp_math16
PUBLIC cm16_sdcc_frexp
EXTERN asm_f16_frexp
; half_t frexp(half_t x, int16_t *pw2);
.cm16_sdcc_frexp
; Entry:
; Stack: ptr right, half_t left, ret
pop de ; my return
pop hl ; (half_t)x
pop bc ; (int*)pw2
push bc ; (int*)pw2
push hl ; (half_t)x
push de ; my return
jp asm_f16_frexp
|
RESULTS_ARCHIVE/18-08-2017/asm/Native-C.asm
|
Kosat/MixingLangsBenchmark
| 0 |
9230
|
<gh_stars>0
levenshtein_C!levenshtein_C [c:\temp\mixinglangsbenchmark\levenshtein-c\levenshtein.cpp @ 25]:
00007ffe`7b1e1030 48895c2408 mov qword ptr [rsp+8],rbx
00007ffe`7b1e1035 44894c2420 mov dword ptr [rsp+20h],r9d
00007ffe`7b1e103a 4489442418 mov dword ptr [rsp+18h],r8d
00007ffe`7b1e103f 55 push rbp
00007ffe`7b1e1040 56 push rsi
00007ffe`7b1e1041 57 push rdi
00007ffe`7b1e1042 4154 push r12
00007ffe`7b1e1044 4155 push r13
00007ffe`7b1e1046 4156 push r14
00007ffe`7b1e1048 4157 push r15
00007ffe`7b1e104a 4883ec60 sub rsp,60h
00007ffe`7b1e104e 448bac24c0000000 mov r13d,dword ptr [rsp+0C0h]
00007ffe`7b1e1056 4983ccff or r12,0FFFFFFFFFFFFFFFFh
00007ffe`7b1e105a 0f29742450 movaps xmmword ptr [rsp+50h],xmm6
00007ffe`7b1e105f 488bea mov rbp,rdx
00007ffe`7b1e1062 488bf9 mov rdi,rcx
00007ffe`7b1e1065 4d8bf4 mov r14,r12
00007ffe`7b1e1068 66410f6ef5 movd xmm6,r13d
00007ffe`7b1e106d 660f70f600 pshufd xmm6,xmm6,0
00007ffe`7b1e1072 49ffc6 inc r14
00007ffe`7b1e1075 42803c3100 cmp byte ptr [rcx+r14],0
00007ffe`7b1e107a 75f6 jne levenshtein_C!levenshtein_C+0x42 (00007ffe`7b1e1072)
00007ffe`7b1e107c 498bf4 mov rsi,r12
00007ffe`7b1e107f 90 nop
00007ffe`7b1e1080 48ffc6 inc rsi
00007ffe`7b1e1083 803c1600 cmp byte ptr [rsi+rdx],0
00007ffe`7b1e1087 75f7 jne levenshtein_C!levenshtein_C+0x50 (00007ffe`7b1e1080)
00007ffe`7b1e1089 448d7e01 lea r15d,[rsi+1]
00007ffe`7b1e108d b804000000 mov eax,4
00007ffe`7b1e1092 4963df movsxd rbx,r15d
00007ffe`7b1e1095 48f7e3 mul rax,rbx
00007ffe`7b1e1098 490f40c4 cmovo rax,r12
00007ffe`7b1e109c 488bc8 mov rcx,rax
00007ffe`7b1e109f ff15fb1f0000 call qword ptr [levenshtein_C!_imp_malloc (00007ffe`7b1e30a0)]
00007ffe`7b1e10a5 4889442428 mov qword ptr [rsp+28h],rax
00007ffe`7b1e10aa b804000000 mov eax,4
00007ffe`7b1e10af 48f7e3 mul rax,rbx
00007ffe`7b1e10b2 490f40c4 cmovo rax,r12
00007ffe`7b1e10b6 488bc8 mov rcx,rax
00007ffe`7b1e10b9 ff15e11f0000 call qword ptr [levenshtein_C!_imp_malloc (00007ffe`7b1e30a0)]
00007ffe`7b1e10bf 4c8be0 mov r12,rax
00007ffe`7b1e10c2 4889442438 mov qword ptr [rsp+38h],rax
00007ffe`7b1e10c7 48c7c1ffffffff mov rcx,0FFFFFFFFFFFFFFFFh
00007ffe`7b1e10ce b804000000 mov eax,4
00007ffe`7b1e10d3 48f7e3 mul rax,rbx
00007ffe`7b1e10d6 480f40c1 cmovo rax,rcx
00007ffe`7b1e10da 488bc8 mov rcx,rax
00007ffe`7b1e10dd ff15bd1f0000 call qword ptr [levenshtein_C!_imp_malloc (00007ffe`7b1e30a0)]
00007ffe`7b1e10e3 33c9 xor ecx,ecx
00007ffe`7b1e10e5 4889442430 mov qword ptr [rsp+30h],rax
00007ffe`7b1e10ea 488bd0 mov rdx,rax
00007ffe`7b1e10ed 85f6 test esi,esi
00007ffe`7b1e10ef 0f88c5000000 js levenshtein_C!levenshtein_C+0x18a (00007ffe`7b1e11ba)
00007ffe`7b1e10f5 4183ff10 cmp r15d,10h
00007ffe`7b1e10f9 0f82bb000000 jb levenshtein_C!levenshtein_C+0x18a (00007ffe`7b1e11ba)
00007ffe`7b1e10ff 833d122f000002 cmp dword ptr [levenshtein_C!__isa_available (00007ffe`7b1e4018)],2
00007ffe`7b1e1106 0f8cae000000 jl levenshtein_C!levenshtein_C+0x18a (00007ffe`7b1e11ba)
00007ffe`7b1e110c 660f6f156c200000 movdqa xmm2,xmmword ptr [levenshtein_C!_xmm (00007ffe`7b1e3180)]
00007ffe`7b1e1114 4181e70f000080 and r15d,8000000Fh
00007ffe`7b1e111b 7d0a jge levenshtein_C!levenshtein_C+0xf7 (00007ffe`7b1e1127)
00007ffe`7b1e111d 41ffcf dec r15d
00007ffe`7b1e1120 4183cff0 or r15d,0FFFFFFF0h
00007ffe`7b1e1124 41ffc7 inc r15d
00007ffe`7b1e1127 448bce mov r9d,esi
00007ffe`7b1e112a 498d542420 lea rdx,[r12+20h]
00007ffe`7b1e112f 452bcf sub r9d,r15d
00007ffe`7b1e1132 41b808000000 mov r8d,8
00007ffe`7b1e1138 0f1f840000000000 nop dword ptr [rax+rax]
00007ffe`7b1e1140 418d40fc lea eax,[r8-4]
00007ffe`7b1e1144 660f6ec1 movd xmm0,ecx
00007ffe`7b1e1148 660f70c000 pshufd xmm0,xmm0,0
00007ffe`7b1e114d 488d5240 lea rdx,[rdx+40h]
00007ffe`7b1e1151 660ffec2 paddd xmm0,xmm2
00007ffe`7b1e1155 660f6ec8 movd xmm1,eax
00007ffe`7b1e1159 660f70c900 pshufd xmm1,xmm1,0
00007ffe`7b1e115e 418d4004 lea eax,[r8+4]
00007ffe`7b1e1162 660ffeca paddd xmm1,xmm2
00007ffe`7b1e1166 83c110 add ecx,10h
00007ffe`7b1e1169 660f3840c6 pmulld xmm0,xmm6
00007ffe`7b1e116e f30f7f42a0 movdqu xmmword ptr [rdx-60h],xmm0
00007ffe`7b1e1173 660f3840ce pmulld xmm1,xmm6
00007ffe`7b1e1178 f30f7f4ab0 movdqu xmmword ptr [rdx-50h],xmm1
00007ffe`7b1e117d 66410f6ec0 movd xmm0,r8d
00007ffe`7b1e1182 4183c010 add r8d,10h
00007ffe`7b1e1186 660f70c000 pshufd xmm0,xmm0,0
00007ffe`7b1e118b 660f6ec8 movd xmm1,eax
00007ffe`7b1e118f 660ffec2 paddd xmm0,xmm2
00007ffe`7b1e1193 660f70c900 pshufd xmm1,xmm1,0
00007ffe`7b1e1198 660ffeca paddd xmm1,xmm2
00007ffe`7b1e119c 660f3840c6 pmulld xmm0,xmm6
00007ffe`7b1e11a1 f30f7f42c0 movdqu xmmword ptr [rdx-40h],xmm0
00007ffe`7b1e11a6 660f3840ce pmulld xmm1,xmm6
00007ffe`7b1e11ab f30f7f4ad0 movdqu xmmword ptr [rdx-30h],xmm1
00007ffe`7b1e11b0 413bc9 cmp ecx,r9d
00007ffe`7b1e11b3 7e8b jle levenshtein_C!levenshtein_C+0x110 (00007ffe`7b1e1140)
00007ffe`7b1e11b5 488b542430 mov rdx,qword ptr [rsp+30h]
00007ffe`7b1e11ba 4863c1 movsxd rax,ecx
00007ffe`7b1e11bd 4863de movsxd rbx,esi
00007ffe`7b1e11c0 483bc3 cmp rax,rbx
00007ffe`7b1e11c3 7f1a jg levenshtein_C!levenshtein_C+0x1af (00007ffe`7b1e11df)
00007ffe`7b1e11c5 410fafcd imul ecx,r13d
00007ffe`7b1e11c9 0f1f8000000000 nop dword ptr [rax]
00007ffe`7b1e11d0 41890c84 mov dword ptr [r12+rax*4],ecx
00007ffe`7b1e11d4 4103cd add ecx,r13d
00007ffe`7b1e11d7 48ffc0 inc rax
00007ffe`7b1e11da 483bc3 cmp rax,rbx
00007ffe`7b1e11dd 7ef1 jle levenshtein_C!levenshtein_C+0x1a0 (00007ffe`7b1e11d0)
00007ffe`7b1e11df 4c8b442428 mov r8,qword ptr [rsp+28h]
00007ffe`7b1e11e4 4963c6 movsxd rax,r14d
00007ffe`7b1e11e7 4889442440 mov qword ptr [rsp+40h],rax
00007ffe`7b1e11ec 4585f6 test r14d,r14d
00007ffe`7b1e11ef 0f8e16010000 jle levenshtein_C!levenshtein_C+0x2db (00007ffe`7b1e130b)
00007ffe`7b1e11f5 8bb424c8000000 mov esi,dword ptr [rsp+0C8h]
00007ffe`7b1e11fc 4c8bf7 mov r14,rdi
00007ffe`7b1e11ff 8bce mov ecx,esi
00007ffe`7b1e1201 49f7de neg r14
00007ffe`7b1e1204 894c2420 mov dword ptr [rsp+20h],ecx
00007ffe`7b1e1208 0f1f840000000000 nop dword ptr [rax+rax]
00007ffe`7b1e1210 4533d2 xor r10d,r10d
00007ffe`7b1e1213 890a mov dword ptr [rdx],ecx
00007ffe`7b1e1215 4533c9 xor r9d,r9d
00007ffe`7b1e1218 4885db test rbx,rbx
00007ffe`7b1e121b 0f8eb7000000 jle levenshtein_C!levenshtein_C+0x2a8 (00007ffe`7b1e12d8)
00007ffe`7b1e1221 4d8bdc mov r11,r12
00007ffe`7b1e1224 488d4204 lea rax,[rdx+4]
00007ffe`7b1e1228 4d8bf8 mov r15,r8
00007ffe`7b1e122b 4d2bfc sub r15,r12
00007ffe`7b1e122e 448ba424b0000000 mov r12d,dword ptr [rsp+0B0h]
00007ffe`7b1e1236 4983c7f8 add r15,0FFFFFFFFFFFFFFF8h
00007ffe`7b1e123a 4c2bda sub r11,rdx
00007ffe`7b1e123d 0f1f00 nop dword ptr [rax]
00007ffe`7b1e1240 410fb60c29 movzx ecx,byte ptr [r9+rbp]
00007ffe`7b1e1245 33d2 xor edx,edx
00007ffe`7b1e1247 380f cmp byte ptr [rdi],cl
00007ffe`7b1e1249 498d0c3e lea rcx,[r14+rdi]
00007ffe`7b1e124d 458b4403fc mov r8d,dword ptr [r11+rax-4]
00007ffe`7b1e1252 0f459424b8000000 cmovne edx,dword ptr [rsp+0B8h]
00007ffe`7b1e125a 4403c2 add r8d,edx
00007ffe`7b1e125d 448900 mov dword ptr [rax],r8d
00007ffe`7b1e1260 4885c9 test rcx,rcx
00007ffe`7b1e1263 7e2d jle levenshtein_C!levenshtein_C+0x262 (00007ffe`7b1e1292)
00007ffe`7b1e1265 4585d2 test r10d,r10d
00007ffe`7b1e1268 7e28 jle levenshtein_C!levenshtein_C+0x262 (00007ffe`7b1e1292)
00007ffe`7b1e126a 410fb60c29 movzx ecx,byte ptr [r9+rbp]
00007ffe`7b1e126f 384fff cmp byte ptr [rdi-1],cl
00007ffe`7b1e1272 751e jne levenshtein_C!levenshtein_C+0x262 (00007ffe`7b1e1292)
00007ffe`7b1e1274 410fb64c29ff movzx ecx,byte ptr [r9+rbp-1]
00007ffe`7b1e127a 380f cmp byte ptr [rdi],cl
00007ffe`7b1e127c 7514 jne levenshtein_C!levenshtein_C+0x262 (00007ffe`7b1e1292)
00007ffe`7b1e127e 4b8d0c3b lea rcx,[r11+r15]
00007ffe`7b1e1282 8b0c01 mov ecx,dword ptr [rcx+rax]
00007ffe`7b1e1285 4103cc add ecx,r12d
00007ffe`7b1e1288 443bc1 cmp r8d,ecx
00007ffe`7b1e128b 7e05 jle levenshtein_C!levenshtein_C+0x262 (00007ffe`7b1e1292)
00007ffe`7b1e128d 448bc1 mov r8d,ecx
00007ffe`7b1e1290 8908 mov dword ptr [rax],ecx
00007ffe`7b1e1292 418b1403 mov edx,dword ptr [r11+rax]
00007ffe`7b1e1296 03d6 add edx,esi
00007ffe`7b1e1298 443bc2 cmp r8d,edx
00007ffe`7b1e129b 7e05 jle levenshtein_C!levenshtein_C+0x272 (00007ffe`7b1e12a2)
00007ffe`7b1e129d 448bc2 mov r8d,edx
00007ffe`7b1e12a0 8910 mov dword ptr [rax],edx
00007ffe`7b1e12a2 8b08 mov ecx,dword ptr [rax]
00007ffe`7b1e12a4 8b50fc mov edx,dword ptr [rax-4]
00007ffe`7b1e12a7 4103d5 add edx,r13d
00007ffe`7b1e12aa 443bc2 cmp r8d,edx
00007ffe`7b1e12ad 0f4fca cmovg ecx,edx
00007ffe`7b1e12b0 41ffc2 inc r10d
00007ffe`7b1e12b3 8908 mov dword ptr [rax],ecx
00007ffe`7b1e12b5 49ffc1 inc r9
00007ffe`7b1e12b8 4883c004 add rax,4
00007ffe`7b1e12bc 4c3bcb cmp r9,rbx
00007ffe`7b1e12bf 0f8c7bffffff jl levenshtein_C!levenshtein_C+0x210 (00007ffe`7b1e1240)
00007ffe`7b1e12c5 4c8b642438 mov r12,qword ptr [rsp+38h]
00007ffe`7b1e12ca 488b542430 mov rdx,qword ptr [rsp+30h]
00007ffe`7b1e12cf 8b4c2420 mov ecx,dword ptr [rsp+20h]
00007ffe`7b1e12d3 4c8b442428 mov r8,qword ptr [rsp+28h]
00007ffe`7b1e12d8 498bc0 mov rax,r8
00007ffe`7b1e12db 4c89642428 mov qword ptr [rsp+28h],r12
00007ffe`7b1e12e0 48ffc7 inc rdi
00007ffe`7b1e12e3 4889542438 mov qword ptr [rsp+38h],rdx
00007ffe`7b1e12e8 03ce add ecx,esi
00007ffe`7b1e12ea 4889442430 mov qword ptr [rsp+30h],rax
00007ffe`7b1e12ef 4d8bc4 mov r8,r12
00007ffe`7b1e12f2 894c2420 mov dword ptr [rsp+20h],ecx
00007ffe`7b1e12f6 4c8be2 mov r12,rdx
00007ffe`7b1e12f9 488bd0 mov rdx,rax
00007ffe`7b1e12fc 498d043e lea rax,[r14+rdi]
00007ffe`7b1e1300 483b442440 cmp rax,qword ptr [rsp+40h]
00007ffe`7b1e1305 0f8c05ffffff jl levenshtein_C!levenshtein_C+0x1e0 (00007ffe`7b1e1210)
00007ffe`7b1e130b 418b1c9c mov ebx,dword ptr [r12+rbx*4]
00007ffe`7b1e130f 498bc8 mov rcx,r8
00007ffe`7b1e1312 ff15901d0000 call qword ptr [levenshtein_C!_imp_free (00007ffe`7b1e30a8)]
00007ffe`7b1e1318 498bcc mov rcx,r12
00007ffe`7b1e131b ff15871d0000 call qword ptr [levenshtein_C!_imp_free (00007ffe`7b1e30a8)]
00007ffe`7b1e1321 488b4c2430 mov rcx,qword ptr [rsp+30h]
00007ffe`7b1e1326 ff157c1d0000 call qword ptr [levenshtein_C!_imp_free (00007ffe`7b1e30a8)]
00007ffe`7b1e132c 0f28742450 movaps xmm6,xmmword ptr [rsp+50h]
00007ffe`7b1e1331 8bc3 mov eax,ebx
00007ffe`7b1e1333 488b9c24a0000000 mov rbx,qword ptr [rsp+0A0h]
00007ffe`7b1e133b 4883c460 add rsp,60h
00007ffe`7b1e133f 415f pop r15
00007ffe`7b1e1341 415e pop r14
00007ffe`7b1e1343 415d pop r13
00007ffe`7b1e1345 415c pop r12
00007ffe`7b1e1347 5f pop rdi
00007ffe`7b1e1348 5e pop rsi
00007ffe`7b1e1349 5d pop rbp
00007ffe`7b1e134a c3 ret
00007ffe`7b1e134b cc int 3
|
programs/oeis/014/A014632.asm
|
jmorken/loda
| 1 |
165202
|
<reponame>jmorken/loda
; A014632: Odd pentagonal numbers.
; 1,5,35,51,117,145,247,287,425,477,651,715,925,1001,1247,1335,1617,1717,2035,2147,2501,2625,3015,3151,3577,3725,4187,4347,4845,5017,5551,5735,6305,6501,7107,7315,7957,8177,8855,9087,9801,10045,10795,11051,11837,12105,12927,13207,14065,14357,15251,15555,16485,16801,17767,18095,19097,19437,20475,20827,21901,22265,23375,23751,24897,25285,26467,26867,28085,28497,29751,30175,31465,31901,33227,33675,35037,35497,36895,37367,38801,39285,40755,41251,42757,43265,44807,45327,46905,47437,49051,49595,51245,51801,53487,54055,55777,56357,58115,58707,60501,61105,62935,63551,65417,66045,67947,68587,70525,71177,73151,73815,75825,76501,78547,79235,81317,82017,84135,84847,87001,87725,89915,90651,92877,93625,95887,96647,98945,99717,102051,102835,105205,106001,108407,109215,111657,112477,114955,115787,118301,119145,121695,122551,125137,126005,128627,129507,132165,133057,135751,136655,139385,140301,143067,143995,146797,147737,150575,151527,154401,155365,158275,159251,162197,163185,166167,167167,170185,171197,174251,175275,178365,179401,182527,183575,186737,187797,190995,192067,195301,196385,199655,200751,204057,205165,208507,209627,213005,214137,217551,218695,222145,223301,226787,227955,231477,232657,236215,237407,241001,242205,245835,247051,250717,251945,255647,256887,260625,261877,265651,266915,270725,272001,275847,277135,281017,282317,286235,287547,291501,292825,296815,298151,302177,303525,307587,308947,313045,314417,318551,319935,324105,325501,329707,331115,335357,336777,341055,342487,346801,348245,352595,354051,358437,359905,364327,365807,370265,371757
mov $4,$0
mul $0,2
add $0,3
mov $3,$4
div $3,2
mul $4,6
add $4,1
mul $3,$4
add $0,$3
mov $2,2
mov $3,$0
mov $0,6
add $3,52
lpb $0
sub $0,2
mov $1,8
add $3,$2
lpe
add $1,$3
sub $1,69
mul $1,2
add $1,1
|
stdlib-exts/IO/Instance.agda
|
WhatisRT/meta-cedille
| 35 |
2502
|
<reponame>WhatisRT/meta-cedille
{-# OPTIONS --type-in-type --guardedness #-}
module IO.Instance where
open import Class.Monad using (Monad)
open import Class.Monad.IO
open import Class.Monoid
open import Data.Product
open import Data.Sum
open import IO
open import Monads.ExceptT
open import Monads.StateT
open import Monads.WriterT
open import Level
instance
IO-Monad : Monad IO
IO-Monad = record { _>>=_ = _>>=_ ; return = return }
IO-MonadIO : MonadIO IO
IO-MonadIO = record { liftIO = λ x -> x }
module _ {a} {M : Set a -> Set a} {{_ : Monad M}} {{_ : MonadIO M}} where
ExceptT-MonadIO : ∀ {E} -> MonadIO (ExceptT M E) {{ExceptT-Monad}}
ExceptT-MonadIO = record { liftIO = λ x -> liftIO (x >>= λ a -> return (inj₂ a)) }
StateT-MonadIO : ∀ {S} -> MonadIO (StateT M S)
StateT-MonadIO = record { liftIO = λ x -> λ s -> liftIO (x >>= (λ a -> return (a , s))) }
WriterT-MonadIO : ∀ {W} {{_ : Monoid W}} -> MonadIO (WriterT M W) {{WriterT-Monad}}
WriterT-MonadIO = record { liftIO = λ x -> liftIO (x >>= λ a -> return (a , mzero)) }
|
Transynther/x86/_processed/NC/_zr_/i7-8650U_0xd2.log_2338_1680.asm
|
ljhsiun2/medusa
| 9 |
29138
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0xd33b, %rsi
lea addresses_UC_ht+0x3f47, %rdi
clflush (%rdi)
nop
lfence
mov $47, %rcx
rep movsl
nop
sub %rsi, %rsi
lea addresses_D_ht+0xcc5b, %rsi
lea addresses_A_ht+0x16a83, %rdi
nop
nop
nop
and %r10, %r10
mov $81, %rcx
rep movsw
sub %rsi, %rsi
lea addresses_normal_ht+0x36df, %r12
nop
xor %rbx, %rbx
movb (%r12), %cl
nop
nop
nop
and %r12, %r12
lea addresses_D_ht+0x1800b, %rdi
nop
nop
nop
nop
nop
and $16815, %r10
movw $0x6162, (%rdi)
nop
nop
nop
and $23251, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %r9
push %rax
push %rdx
// Store
lea addresses_normal+0x1a293, %r15
nop
and $41641, %rax
mov $0x5152535455565758, %r12
movq %r12, %xmm0
movups %xmm0, (%r15)
nop
nop
nop
nop
sub %rax, %rax
// Store
lea addresses_D+0x280b, %r11
nop
nop
and %r10, %r10
movl $0x51525354, (%r11)
inc %r15
// Load
lea addresses_WC+0x6c4b, %r10
nop
nop
nop
nop
nop
dec %r9
movups (%r10), %xmm0
vpextrq $1, %xmm0, %r12
nop
sub $46835, %rax
// Store
lea addresses_D+0x10dd8, %r12
nop
sub $55085, %rax
movl $0x51525354, (%r12)
nop
nop
nop
and $44604, %r15
// Faulty Load
mov $0x622db0000000000b, %r10
cmp $50495, %r9
mov (%r10), %ax
lea oracles, %r11
and $0xff, %rax
shlq $12, %rax
mov (%r11,%rax,1), %rax
pop %rdx
pop %rax
pop %r9
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'00': 2338}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
Transynther/x86/_processed/P/_un_/i9-9900K_12_0xa0_notsx.log_2_725.asm
|
ljhsiun2/medusa
| 9 |
11322
|
<filename>Transynther/x86/_processed/P/_un_/i9-9900K_12_0xa0_notsx.log_2_725.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r8
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x47ba, %rsi
lea addresses_D_ht+0x1ec5a, %rdi
nop
nop
nop
nop
xor %r8, %r8
mov $80, %rcx
rep movsl
nop
and $53169, %r14
lea addresses_normal_ht+0x1a15a, %r14
nop
add %r11, %r11
mov (%r14), %esi
nop
nop
nop
nop
nop
sub %r8, %r8
pop %rsi
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r15
push %r9
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_PSE+0xeeca, %rsi
lea addresses_WT+0x1775a, %rdi
nop
nop
nop
nop
xor $65419, %r11
mov $89, %rcx
rep movsq
nop
nop
nop
nop
sub %r11, %r11
// REPMOV
lea addresses_US+0x15f5a, %rsi
lea addresses_normal+0x1eb0a, %rdi
clflush (%rsi)
clflush (%rdi)
nop
nop
nop
nop
cmp $8393, %r14
mov $39, %rcx
rep movsb
and $4425, %r11
// Faulty Load
mov $0x35a, %r11
nop
nop
nop
and $12933, %r9
mov (%r11), %ecx
lea oracles, %r11
and $0xff, %rcx
shlq $12, %rcx
mov (%r11,%rcx,1), %rcx
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_P', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_PSE', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT', 'congruent': 10, 'same': False}}
{'src': {'type': 'addresses_US', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal', 'congruent': 4, 'same': False}}
[Faulty Load]
{'src': {'type': 'addresses_P', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'}
{'75': 1, '8f': 1}
75 8f
*/
|
oeis/190/A190105.asm
|
neoneye/loda-programs
| 11 |
247498
|
; A190105: a(n) = (3*A002145(n) - 1)/4.
; Submitted by <NAME>
; 2,5,8,14,17,23,32,35,44,50,53,59,62,77,80,95,98,104,113,122,125,134,143,149,158,167,170,179,188,197,203,212,230,233,248,260,269,275,284,287,314,323,329,332,347,350,359,365,368,374,377,392,410,422,428,440,449,455,464,473,482,485,494,512,518,539,545,554,557,563,590,608,617,620,629,644,647,662,665,680,683,689,710,725,728,737,743,764,773,779,788,797,815,818,827,842,863,872,878,890
mov $2,36
mul $2,$0
mov $4,2
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,4
lpe
mov $0,$4
div $0,4
mul $0,3
add $0,2
|
racer-network.asm
|
LeifBloomquist/NetRacerClient
| 1 |
8093
|
; Network stuff for racing game
CARD_MAC dc.b $00,$80,$10,$0c,$64,$01
CARD_IP dc.b 192,168,1,64
CARD_MASK dc.b 255,255,255,0
CARD_GATE dc.b 192,168,1,1
CARD_GATE_MAC dc.b $00,$00,$00,$00,$00,$00
SERVER_IP
.byte 208,79,218,201 ; Public
SERVER_IP_LAN
.byte 192,168,7,100 ; Private
; Default, overwritten by ARP
SERVER_MAC
.byte $01,$02,$03,$04,$05,$06
USER_UDP_PORT = 3000
UDP_DATA_IN equ INPACKET+$2A ; Beginning of UDP data buffer
;Various Flags...
PACKET_RECEIVED ; Flag for incoming data
.byte $00
NETSETUPFINISHED
.byte $00
NETWORK_TIMEOUT ; Reset by packet receive.
; If this goes above a threshold, means no data received
.byte $00
NET_TIMEDOUT ; Flag for main game loop
.byte $00
NET_FAILED
.byte $00
;----------------------------------------------------------------
; Called from main program
NETWORK_SETUP
PRINT CG_RED
; Basic card initialization
jsr net_init ; Carry set if failed
bcc UDPSETUP
;Failed
jsr getanykey
lda #$01
sta NET_FAILED
jmp NETWORK_SETUP_x
UDPSETUP
; UDP Setup
lda #<3000 ; This doesn't have to match USER_UDP_PORT, but it does
ldx #>3000
jsr UDP_SET_SRC_PORT
lda #<3002
ldx #>3002
jsr UDP_SET_DEST_PORT
lda #<SERVER_IP
ldx #>SERVER_IP
jsr UDP_SET_DEST_IP
NETWORK_SETUP_x
lda #$00
sta PACKET_RECEIVED
rts
; -------------------------------------------------------------------------
; Called from IRQ
NETWORK_UPDATE
jsr NETIRQ
lda NETSETUPFINISHED
beq NETWORK_UPDATEx
lda NET_FAILED
bne NETWORK_UPDATEx
jsr SENDUPDATE
;Network timeouts
lda NET_TIMEDOUT ; Timeout in progress
bne NTIMEOUT
inc NETWORK_TIMEOUT
lda NETWORK_TIMEOUT
; Packets are sent every 50 milliseconds (20/sec)
; This routine is called every ~17 ms (NTSC)
; If we go 30 calls (~0.5 seconds) without a packet, freeze game.
cmp #30 ;Decimal
blt NETWORK_UPDATEx
lda #$01
sta NET_TIMEDOUT
lda #$00
sta PACKET_RECEIVED
jsr NTIMEOUT
NETWORK_UPDATEx
rts
NTIMEOUT
lda #$02
sta $d020
jsr SOUND_TIMEOUT
lda PACKET_RECEIVED
beq NTIMEOUT_x ; No packet yet
lda #$00
sta $d020
sta NET_TIMEDOUT
NTIMEOUT_x
rts
; -------------------------------------------------------------------------
; Get Gateway MAC
; -------------------------------------------------------------------------
;Only get gateway MAC if the opponent's not on the local subnet
GATEWAYMAC
lda #<UDP_DEST_IP
ldx #>UDP_DEST_IP
jsr IPMASK
bcc MAC_SKIP
PRINT CRLF,"RESOLVING GATEWAY MAC..."
jsr get_macs
bcc MAC_OK
;Flag errors
PRINT CRLF,CG_WHT,"ERROR RESOLVING THE GW MAC!",CRLF
nomac jmp nomac ;Freeze
MAC_OK
PRINT "OK",CRLF
MAC_SKIP
rts
; -------------------------------------------------------------------------
; Get Server MAC (LAN Mode only)
; -------------------------------------------------------------------------
SERVERMAC
PRINT CRLF,"RESOLVING SERVER MAC..."
;get MAC for server
lda #<SERVER_IP
ldx #>SERVER_IP
jsr GET_ARP
bcs SMAC_FAILED
;copy gateway mac
ldx #$00
gm1_0
lda ARP_MAC,x
sta SERVER_MAC,x
inx
cpx #$06
bne gm1_0
jmp MAC_OK
SMAC_FAILED
PRINT CRLF,CG_WHT,"ERROR RESOLVING THE SERVER MAC!",CRLF
nomac1 jmp nomac1 ;Freeze
; -------------------------------------------------------------------------
; Packet Send Routine
; -------------------------------------------------------------------------
SENDUPDATE
lda #$0e ; Including zero-term. and checksum
ldx #$00
jsr UDP_SET_DATALEN
; Packet type
lda #$00 ; Game update
sta UDP_DATA
; X Position
lda MYXPOS+1
ldx MYXPOS+2 ; High byte, TODO
sta UDP_DATA+1
stx UDP_DATA+2
; Y Position
lda REALTRACKPOS+1
ldx REALTRACKPOS+2
sta UDP_DATA+3
stx UDP_DATA+4
;X Speed (include fractional)
lda MYX_SPEED
ldx MYX_SPEED+1
sta UDP_DATA+5
stx UDP_DATA+6
;Y Speed (include fractional)
lda MY_SPEED
ldx MY_SPEED+1
sta UDP_DATA+7
stx UDP_DATA+8
;Car color
lda sprite1color
sta UDP_DATA+9
;Sprite#
lda sprite1pnt
sta UDP_DATA+10
; Send!
jsr UDP_SEND
rts
; -------------------------------------------------------------------------
; Packet Receive + Handling Routines
; -------------------------------------------------------------------------
; Temporary holder of the checksum we received
RCV_CSUM
dc.b $ff
; ==============================================================
; Master packet receiver. This occurs inside the interrupt!
; A UDP packet has arrived, and the port matches the one we want.
; ==============================================================
MYUDP_PROCESS SUBROUTINE
; Check checksum, and don't ack if bad
; jsr CHECKSUM
; jmp BADCSUM
inc COMMSLED
; Reset timeout
lda #$00
sta NETWORK_TIMEOUT
; Display sprites as commanded by the server
;--------------------------------------
ldx UDP_DATA_IN+1
ldy UDP_DATA_IN+3
stx sprite2x
stx IN_XPOSLOW+1
sty sprite2y
sty IN_YPOS+1
lda UDP_DATA_IN+5
sta IN_XSPEEDLOW+1
lda UDP_DATA_IN+6
sta IN_XSPEEDHIGH+1
lda UDP_DATA_IN+7
sta IN_YSPEEDLOW+1
lda UDP_DATA_IN+8
sta IN_YSPEEDHIGH+1
lda UDP_DATA_IN+9
sta sprite2color
lda UDP_DATA_IN+10
sta sprite2pnt
;--------------------------------------
ldx UDP_DATA_IN+13
ldy UDP_DATA_IN+15
stx sprite3x
stx IN_XPOSLOW+2
sty sprite3y
sty IN_YPOS+2
lda UDP_DATA_IN+17
sta IN_XSPEEDLOW+2
lda UDP_DATA_IN+18
sta IN_XSPEEDHIGH+2
lda UDP_DATA_IN+19
sta IN_YSPEEDLOW+2
lda UDP_DATA_IN+20
sta IN_YSPEEDHIGH+2
lda UDP_DATA_IN+21
sta sprite3color
lda UDP_DATA_IN+22
sta sprite3pnt
;--------------------------------------
ldx UDP_DATA_IN+25
ldy UDP_DATA_IN+27
stx sprite4x
stx IN_XPOSLOW+3
sty sprite4y
sty IN_YPOS+3
lda UDP_DATA_IN+29
sta IN_XSPEEDLOW+3
lda UDP_DATA_IN+30
sta IN_XSPEEDHIGH+3
lda UDP_DATA_IN+31
sta IN_YSPEEDLOW+3
lda UDP_DATA_IN+32
sta IN_YSPEEDHIGH+3
lda UDP_DATA_IN+33
sta sprite4color
lda UDP_DATA_IN+34
sta sprite4pnt
;--------------------------------------
ldx UDP_DATA_IN+37
ldy UDP_DATA_IN+39
stx sprite5x
stx IN_XPOSLOW+4
sty sprite5y
sty IN_YPOS+4
lda UDP_DATA_IN+41
sta IN_XSPEEDLOW+4
lda UDP_DATA_IN+42
sta IN_XSPEEDHIGH+4
lda UDP_DATA_IN+43
sta IN_YSPEEDLOW+4
lda UDP_DATA_IN+44
sta IN_YSPEEDHIGH+4
lda UDP_DATA_IN+45
sta sprite5color
lda UDP_DATA_IN+46
sta sprite5pnt
;--------------------------------------
ldx UDP_DATA_IN+49
ldy UDP_DATA_IN+51
stx sprite6x
stx IN_XPOSLOW+5
sty sprite6y
sty IN_YPOS+5
lda UDP_DATA_IN+53
sta IN_XSPEEDLOW+5
lda UDP_DATA_IN+54
sta IN_XSPEEDHIGH+5
lda UDP_DATA_IN+55
sta IN_YSPEEDLOW+5
lda UDP_DATA_IN+56
sta IN_YSPEEDHIGH+5
lda UDP_DATA_IN+57
sta sprite6color
lda UDP_DATA_IN+58
sta sprite6pnt
;--------------------------------------
ldx UDP_DATA_IN+61
ldy UDP_DATA_IN+63
stx sprite7x
stx IN_XPOSLOW+6
sty sprite7y
sty IN_YPOS+6
lda UDP_DATA_IN+65
sta IN_XSPEEDLOW+6
lda UDP_DATA_IN+66
sta IN_XSPEEDHIGH+6
lda UDP_DATA_IN+67
sta IN_YSPEEDLOW+6
lda UDP_DATA_IN+68
sta IN_YSPEEDHIGH+6
lda UDP_DATA_IN+69
sta sprite7color
lda UDP_DATA_IN+70
sta sprite7pnt
;--------------------------------------
ldx UDP_DATA_IN+73
ldy UDP_DATA_IN+75
stx sprite8x
stx IN_XPOSLOW+7
sty sprite8y
sty IN_YPOS+7
lda UDP_DATA_IN+77
sta IN_XSPEEDLOW+7
lda UDP_DATA_IN+78
sta IN_XSPEEDHIGH+7
lda UDP_DATA_IN+79
sta IN_YSPEEDLOW+7
lda UDP_DATA_IN+80
sta IN_YSPEEDHIGH+7
lda UDP_DATA_IN+81
sta sprite8color
lda UDP_DATA_IN+82
sta sprite8pnt
;now, calculate MSB for sprites
lda #0
ldx UDP_DATA_IN+2
stx IN_XPOSHIGH+1
beq .ahead1
ora #2
.ahead1
ldx UDP_DATA_IN+14
stx IN_XPOSHIGH+2
beq .ahead2
ora #4
.ahead2
ldx UDP_DATA_IN+26
stx IN_XPOSHIGH+3
beq .ahead3
ora #8
.ahead3
ldx UDP_DATA_IN+38
stx IN_XPOSHIGH+4
beq .ahead4
ora #16
.ahead4
ldx UDP_DATA_IN+50
stx IN_XPOSHIGH+5
beq .ahead5
ora #32
.ahead5
ldx UDP_DATA_IN+62
stx IN_XPOSHIGH+6
beq .ahead6
ora #64
.ahead6
ldx UDP_DATA_IN+74
stx IN_XPOSHIGH+7
beq .ahead7
ora #128
.ahead7
;sta .self+1
;lda $d010
;and #1
;.self
;ora #$ff ;self-mod!
;sta $d010
sta IN_XPOS_D010
;--------------------------------------
MYUDP_PROCESS_x
lda #$01
sta PACKET_RECEIVED
rts
; -------------------------------------------------------------------------
; Do Checksum here
CHECKSUM
; lda INPACKET+???? ; A now holds the checksum we received
; sta RCV_CSUM
;Point x:a to start of received packet
;and calculate our own checksum
ldx #<(INPACKET+$2A)
lda #>(INPACKET+$2A)
dey ; So we aren't including the checksum byte itself
; jsr DATACHECKSUM
lda CSUM
;sta CSUM_SAVE
lda RCV_CSUM
cmp CSUM
; Zero bit now contains whether or not checksum matches, use bne/beq
rts
|
Transynther/x86/_processed/NONE/_zr_/i9-9900K_12_0xa0.log_21829_1834.asm
|
ljhsiun2/medusa
| 9 |
20592
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x1a34a, %rbx
xor $14983, %r11
mov (%rbx), %r14w
nop
inc %rcx
lea addresses_D_ht+0xbb4a, %r15
nop
nop
xor $5909, %rcx
mov (%r15), %r10
and $12355, %r14
lea addresses_A_ht+0x3490, %rbx
mfence
movb (%rbx), %r14b
mfence
lea addresses_A_ht+0xa74a, %r11
clflush (%r11)
nop
nop
xor %rcx, %rcx
mov (%r11), %r15
nop
nop
nop
and %r10, %r10
lea addresses_WC_ht+0x16d92, %r15
clflush (%r15)
nop
nop
nop
nop
xor %r14, %r14
mov (%r15), %r11
xor %r15, %r15
lea addresses_WT_ht+0x18c4a, %r15
nop
nop
nop
nop
inc %r10
mov (%r15), %r11d
nop
nop
nop
nop
and %r11, %r11
lea addresses_WT_ht+0x16f4a, %r14
nop
nop
nop
inc %r11
mov $0x6162636465666768, %rbp
movq %rbp, (%r14)
add %rbp, %rbp
lea addresses_WC_ht+0xa3ca, %r15
nop
nop
nop
nop
xor $55493, %rbx
mov $0x6162636465666768, %rbp
movq %rbp, (%r15)
cmp $6779, %r10
lea addresses_A_ht+0x1d20a, %rsi
lea addresses_A_ht+0x9fea, %rdi
nop
inc %r14
mov $119, %rcx
rep movsl
nop
nop
nop
nop
inc %r14
lea addresses_WT_ht+0x13a4a, %r10
nop
nop
cmp %rbp, %rbp
movb $0x61, (%r10)
nop
nop
and %r15, %r15
lea addresses_A_ht+0x37ca, %rcx
nop
nop
nop
cmp %r14, %r14
movl $0x61626364, (%rcx)
nop
cmp %r11, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r15
push %r8
push %rbx
push %rdx
push %rsi
// Store
mov $0x49919200000001ca, %rbx
cmp %rdx, %rdx
mov $0x5152535455565758, %r13
movq %r13, %xmm6
vmovaps %ymm6, (%rbx)
nop
nop
nop
nop
sub $7892, %r13
// Store
lea addresses_A+0x1ba3a, %rbx
nop
nop
nop
sub %rsi, %rsi
movl $0x51525354, (%rbx)
nop
nop
nop
cmp $27874, %r11
// Faulty Load
lea addresses_WT+0x1f74a, %rdx
nop
nop
dec %r8
movb (%rdx), %bl
lea oracles, %r11
and $0xff, %rbx
shlq $12, %rbx
mov (%r11,%rbx,1), %rbx
pop %rsi
pop %rdx
pop %rbx
pop %r8
pop %r15
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_NC', 'AVXalign': True, 'size': 32}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_A', 'AVXalign': False, 'size': 4}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': True, 'congruent': 1, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
{'src': {'NT': True, 'same': False, 'congruent': 11, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8}}
{'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 4, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
elan520-registers.ads
|
Jellix/elan520
| 0 |
14123
|
<filename>elan520-registers.ads
------------------------------------------------------------------------
-- Copyright (C) 2004-2020 by <<EMAIL>> --
-- --
-- This work is free. You can redistribute it and/or modify it under --
-- the terms of the Do What The Fuck You Want To Public License, --
-- Version 2, as published by Sam Hocevar. See the LICENSE file for --
-- more details. --
------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------
-- Definitions for the AMD Elan 520 embedded Microprozessor --
------------------------------------------------------------------------
with Elan520.Basic_Types;
package Elan520.Registers is
-- type for Address_Decode_Register IO_Hole_Dest
type ISA_Space_Destination is (External_GP, PCI_Bus);
for ISA_Space_Destination use (External_GP => 0, PCI_Bus => 1);
-- contents of the address control register at 16#80# of the MMCR
type Address_Decode_Control is
record
UART1 : Basic_Types.Negative_Bit;
UART2 : Basic_Types.Negative_Bit;
RTC : Basic_Types.Negative_Bit;
IO_Hole_Dest : ISA_Space_Destination;
WPV_Int : Basic_Types.Positive_Bit;
end record;
ADDRESS_DECODE_CONTROL_SIZE : constant := 8;
MMCR_OFFSET_ADDRESS_DECODE_CONTROL : constant := 16#80#;
for Address_Decode_Control use
record
UART1 at 0 range 0 .. 0;
UART2 at 0 range 1 .. 1;
RTC at 0 range 2 .. 2;
-- bit 3 is reserved
IO_Hole_Dest at 0 range 4 .. 4;
-- bit 5 & 6 are reserved
WPV_Int at 0 range 7 .. 7;
end record;
for Address_Decode_Control'Size use ADDRESS_DECODE_CONTROL_SIZE;
end Elan520.Registers;
|
_lessons/05-academy/code/academia-1.als
|
HanielB/2021.1-fm
| 0 |
4343
|
<reponame>HanielB/2021.1-fm
---------------- Signatures ----------------
abstract sig Person {}
sig Faculty extends Person {}
abstract sig Student extends Person {}
sig Graduate, Undergrad extends Student {}
sig Instructor in Person {}
sig Course {
taughtby: one Instructor,
enrolled: some Student,
waitlist: set Student
}
fun teaches : Instructor -> Course { ~taughtby }
---------------- Fact ----------------
fact
{
-- All instructors are either Faculty or Graduate Students
all i: Instructor | i in Faculty+Graduate
-- No one is waiting for a course unless someone is enrolled
all c: Course | some c.waitlist => some c.enrolled
-- Graduate students do not teach courses they are enrolled in
-- or wainting to enroll in
all c: Course | c.taughtby !in c.enrolled + c.waitlist
}
------------------- Run ---------------------
pred RealismConstraints [] {
-- There is a graduate student who is an instructor
some Graduate & Instructor
-- There are at least two courses
#Course >= 2
-- There are at least three undergraduates
#Undergrad > 2
}
run RealismConstraints -- for 4
---------------- Assertion ----------------
-- Note: to check the assertion below you must comment the run command
-- above first (similarly for the second check)
-- No instructor is on the waitlist for a course that he/she teaches
assert NoWaitingTeacher {
all c: Course | no (c.taughtby & c.waitlist)
}
check NoWaitingTeacher for 10
-- No student is enrolled and on the waitlist for the same course
assert NoEnrolledAndWaiting {
all c: Course | no (c.enrolled & c.waitlist)
}
check NoEnrolledAndWaiting for 10
|
Engine Hacks/FE8-Item Range Fix/Write Range.asm
|
sme23/Christmas2
| 3 |
241376
|
.thumb
.org 0x0
@r0 has x, r1 has y, r2 has bitfield, r3 has halfword, r12 has ballista flag
push {r4-r7,r14}
mov r7,r8
push {r7}
mov r8,r12
mov r4,r0
mov r5,r1
mov r6,r2
cmp r3,#0x0
beq NoRangeHalfword @this should usually be the case
lsr r7,r3,#0x8 @r7 has min
lsl r2,r3,#0x18 @get max
lsr r2,r2,#0x18
mov r3,#0x1
push {r4}
ldr r4,WriteRange @fill in squares with radius [max]
bl goto_r4
pop {r4}
mov r0,r4
mov r1,r5
sub r2,r7,#0x1
mov r3,#0x1
neg r3,r3
push {r4}
ldr r4,WriteRange @remove squares with radius [min - 1]
bl goto_r4
pop {r4}
NoRangeHalfword:
mov r0,#0xF
lsl r0,r0,#0x10
add r6,r6,r0
BitfieldMagic:
lsr r2,r6,#0x10
lsl r0,r6,#0x10
lsr r0,r2
lsl r0,r0,#0x10
mov r3,#0x1
lsl r3,r3,#0x10
sub r6,r6,r3
cmp r0,#0x0
beq BallistaCheck
MaxBit:
cmp r0,#0x0
blt BitFound1
sub r2,#0x1
sub r6,r6,r3
lsl r0,r0,#0x1
b MaxBit
BitFound1:
mov r0,r4
mov r1,r5
lsr r3,r3,#0x10
push {r4}
ldr r4,WriteRange
bl goto_r4
pop {r4}
lsr r2,r6,#0x10
lsl r0,r6,#0x10
lsr r0,r2
lsl r0,r0,#0x10
mov r3,#0x1
lsl r3,r3,#0x10
sub r6,r6,r3
MinBit:
cmp r0,#0x0
bge BitFound2
sub r2,#0x1
sub r6,r6,r3
lsl r0,r0,#0x1
b MinBit
BitFound2:
mov r0,r4
mov r1,r5
lsr r3,r3,#0x10
neg r3,r3
push {r4}
ldr r4,WriteRange
bl goto_r4
pop {r4}
b BitfieldMagic
BallistaCheck:
mov r0,r12
cmp r0,#0x0
beq EndRangeWrite
mov r0,r4
mov r1,r5
ldr r3,IsBallista
bl goto_r3 @given coordinates, returns ballista item id/uses halfword
cmp r0,#0x0
beq EndRangeWrite
mov r7,r0
ldr r3,BallistaMax
bl goto_r3 @given item id, returns range max nybble
mov r2,r0
mov r0,r4
mov r1,r5
mov r3,#0x1
push {r4}
ldr r4,WriteRange
bl goto_r4
pop {r4}
mov r0,r7
ldr r3,BallistaMin @given item id, returns range max nybble
bl goto_r3
sub r2,r0,#0x1
mov r0,r4
mov r1,r5
mov r3,#0x1
neg r3,r3
push {r4}
ldr r4,WriteRange
bl goto_r4
pop {r4}
EndRangeWrite:
pop {r7}
mov r8,r7
pop {r4-r7}
pop {r0}
bx r0
goto_r3:
bx r3
goto_r4:
bx r4
.align
BallistaMin:
.long 0x0801766C+1
BallistaMax:
.long 0x08017684+1
IsBallista:
.long 0x0803798C+1
WriteRange:
.long 0x0801AABC+1
|
programs/oeis/022/A022776.asm
|
karttu/loda
| 0 |
93735
|
; A022776: Place where n-th 1 occurs in A023115.
; 1,2,4,7,10,14,19,24,30,37,45,53,62,72,82,93,105,118,131,145,160,175,191,208,225,243,262,282,302,323,345,367,390,414,439,464,490,517,544,572,601,630,660,691,723,755,788,822,856,891,927,964,1001,1039,1078,1117,1157,1198,1240,1282,1325,1369,1413,1458,1504,1550,1597,1645,1694,1743,1793,1844,1895,1947,2000,2054,2108,2163,2219,2275,2332,2390,2448,2507,2567,2628,2689,2751,2814,2877,2941,3006,3072,3138,3205,3273,3341,3410,3480,3551,3622,3694,3767,3840,3914,3989,4064,4140,4217,4295,4373,4452,4532,4612,4693,4775,4858,4941,5025,5110,5195,5281,5368,5455,5543,5632,5722,5812,5903,5995,6087,6180,6274,6369,6464,6560,6657,6754,6852,6951,7050,7150,7251,7353,7455,7558,7662,7766,7871,7977,8084,8191,8299,8408,8517,8627,8738,8850,8962,9075,9189,9303,9418,9534,9650,9767,9885,10004,10123,10243,10364,10485,10607,10730,10854,10978,11103,11229,11355,11482,11610,11738,11867,11997,12128,12259,12391,12524,12657,12791,12926,13062,13198,13335,13473,13611,13750,13890,14031,14172,14314,14457,14600,14744,14889,15034,15180,15327,15475,15623,15772,15922,16072,16223,16375,16528,16681,16835,16990,17145,17301,17458,17615,17773,17932,18092,18252,18413,18575,18737,18900,19064,19229,19394,19560,19727,19894,20062,20231,20400,20570,20741,20913,21085,21258,21432,21606,21781,21957,22134
mov $2,$0
add $2,1
mov $4,$0
lpb $2,1
mov $0,$4
sub $2,1
sub $0,$2
mul $0,7
mov $3,21
mul $3,$0
sub $3,$0
div $3,198
add $3,1
add $1,$3
lpe
|
src/parser/VelocityHtmlLexer.g4
|
fvclaus/prettier-velocity-html-plugin
| 0 |
6519
|
<reponame>fvclaus/prettier-velocity-html-plugin<gh_stars>0
lexer grammar VelocityHtmlLexer;
@lexer::header {
import { Interval } from 'antlr4ts/misc/Interval';
type VelocityMode = "directive" | "reference";
}
@lexer::members {
private tagStringSingle = false;
private tagStringDouble = false;
public setTagString(tagString: 'single' | 'double') {
if (tagString == 'single') {
this.tagStringSingle = true;
} else {
this.tagStringDouble = true;
}
}
public isTagStringDouble() {
return this.tagStringDouble;
}
public isTagStringSingle() {
return this.tagStringSingle;
}
public resetTagString() {
this.tagStringSingle = false;
this.tagStringDouble = false;
}
private vtlPrefixes = ['if', 'foreach', 'end', 'set', 'else', 'elseif', 'include', 'parse', 'break', 'stop', 'evaluate', 'define', 'macro'];
private maxVtlPrefixLength = this.vtlPrefixes.reduce((maxLength, vtlPrefix) => {
return Math.max(maxLength, vtlPrefix.length);
}, 0);
private toCodePoints(characters: string[] | string): Set<number> {
// TODO Fix Me
return (characters instanceof Array? characters : characters.split("")).map(character => character.codePointAt(0)).reduce((set, codePoint) => {
if (codePoint != null && !set.has(codePoint)) {
set.add(codePoint);
}
return set;
}, new Set<number>());
}
private vtlStart = this.toCodePoints(["#", "$"]);
private vtlValidAlpha = this.toCodePoints("abcdefghijklmnopqrstuvwxyz");
private vtlValidAlphaNumeric = this.toCodePoints("abcdefghijklmnopqrstuvwxyz0123456789")
private vtlOperators = this.toCodePoints([".", "(", "[", "|"]);
private vtlWhitespace = this.toCodePoints([" ", "\t", "\n", "\r", "\f"]);
private vtlContinueReferenceMode = new Set([...this.vtlOperators, ...this.vtlWhitespace, ...this.toCodePoints(["}"])])
// Characters break syntax highlighting of file
private static LEFT_CURLY = "\u007b"
private static DOLLAR = "\u0024";
private static EXCLAMATION_MARK = "\u0021";
private isStartOfVtl(): boolean {
let index;
let mode;
[index, mode] = this.isStartOfVelocityElement();
if (mode == null) {
return false;
}
return this.tryMatchVelocityElement(index, mode) && !this.isEscaped();
}
private isEscaped() {
let index = 1;
let escapeCount = 0;
while (true) {
const startPosition = this._tokenStartCharIndex - index;
if (startPosition < 0) {
break;
}
let characterInStream = this.inputStream.getText(Interval.of(startPosition, startPosition));
if (characterInStream == "\\") {
escapeCount++;
} else {
break;
}
index++;
}
return escapeCount % 2 == 1;
}
private isStartOfVelocityElement(): [number, VelocityMode | null] {
let index = 0;
let mode: VelocityMode | null = null;
const nextCharacters = this.getNextCharacters(3);
if ("#" == nextCharacters.charAt(index)) {
mode = 'directive';
index++;
if ("@" == nextCharacters.charAt(index)) {
index++;
}
if (VelocityHtmlLexer.LEFT_CURLY === nextCharacters.charAt(index)) {
index++;
}
} else if (VelocityHtmlLexer.DOLLAR == nextCharacters.charAt(index)) {
mode = 'reference';
index++;
if (VelocityHtmlLexer.EXCLAMATION_MARK == nextCharacters.charAt(index)) {
index++;
}
if (VelocityHtmlLexer.LEFT_CURLY == nextCharacters.charAt(index)) {
index++;
}
}
return [index, mode];
}
private tryMatchVelocityElement(index: number, mode: VelocityMode): boolean {
let velocityDirectiveMode : 'start' | 'identifier' | 'space' = 'start';
while (true) {
const startPosition = this._tokenStartCharIndex + index;
// TODO Test
if (startPosition >= this.inputStream.size) {
return false;
}
let characterInStream = this.inputStream.getText(Interval.of(startPosition, startPosition));
let codePoint = characterInStream.toLowerCase().codePointAt(0) as number;
const isAlpha = this.vtlValidAlpha.has(codePoint);
const isAlphaNumeric = this.vtlValidAlphaNumeric.has(codePoint);
const isWhitespace = this.vtlWhitespace.has(codePoint);
switch(mode) {
case 'reference': {
if (!isAlpha) {
return false;
}
return true;
}
case 'directive': {
switch(velocityDirectiveMode) {
case 'start': {
// Some built-in directives don't have parameters.
const nextCharacters = this.getNextCharacters(this.maxVtlPrefixLength, index);
for (let vtlDirective of this.vtlPrefixes) {
if (nextCharacters.startsWith(vtlDirective)) {
return true;
}
}
if (!isAlpha) {
return false;
}
velocityDirectiveMode = 'identifier';
break;
}
case 'identifier': {
if (characterInStream == "(") {
return true;
} else if (isWhitespace) {
velocityDirectiveMode = 'space';
} else if (!isAlphaNumeric) {
return false;
}
break;
}
case 'space': {
if (characterInStream == "(") {
return true;
} else if (!isWhitespace) {
return false;
}
break;
}
default: {
throw new Error(`Unknown mode ${velocityDirectiveMode}`);
}
}
break;
}
default: {
throw new Error(`Unknown mode ${mode}`);
}
}
index++;
}
}
private popModeIfNecessary(): void {
const characterInStream = this.inputStream.getText(Interval.of((this.inputStream as any)._position, (this.inputStream as any)._position));
const codePoint = characterInStream.toLowerCase().codePointAt(0);
if (codePoint == null) {
// ?
return;
}
if (!this.vtlContinueReferenceMode.has(codePoint)) {
// Pop velocity reference mode (no popMode in lexer grammar)
const isVelocityReferenceMode = this._mode == VelocityHtmlLexer.VELOCITY_REFERENCE_MODE;
// Pop velocity mode and lexer popMode will pop velocity reference mode.
// ▼
// Example: allProducts.get(key)</span>
const isVelocityModeInsideVelocityReferenceMode = this._mode == VelocityHtmlLexer.VELOCITY_MODE && this._modeStack.peek() == VelocityHtmlLexer.VELOCITY_REFERENCE_MODE;
if (isVelocityModeInsideVelocityReferenceMode || isVelocityReferenceMode) {
this.debug(`next character ${characterInStream} is not VTL continuation. Popping mode`, this.printModeStack());
this.popMode();
this.debug(`New mode stack`, this.printModeStack())
}
}
}
private pushModeIfNecessary(): void {
const tokenText = this.inputStream.getText(Interval.of(this._tokenStartCharIndex, (this.inputStream as any)._position));
const codePoint = tokenText.toLowerCase().codePointAt(tokenText.length - 1);
if (codePoint == null) {
// ?
return;
}
if (this.vtlOperators.has(codePoint)) {
this.pushMode(VelocityHtmlLexer.VELOCITY_REFERENCE_MODE);
} else if (tokenText.charAt(1) == "\u007b" || tokenText.charAt(2) == "\u007b") {
this.pushMode(VelocityHtmlLexer.VELOCITY_REFERENCE_MODE);
}
}
private isNotStartOfConditionalComment(): boolean {
const nextCharacters = this.getNextCharacters(4);
return nextCharacters !== '<!--[';
}
private getNextCharacters(numberOfCharacters:number, offset = 0) {
const currentPosition = this._tokenStartCharIndex + offset;
const nextCharacters = this.inputStream.getText(Interval.of(currentPosition, currentPosition + numberOfCharacters));
this.debug('nextCharacters', nextCharacters);
return nextCharacters;
}
public isVtlReferenceInsideString = false;
public nextTagCloseMode : number | null = null;
public popModeForCurrentTag() : void {
this.debug(`before ${this.text}`, this.printModeStack());
if (this.nextTagCloseMode != null) {
this.mode(this.nextTagCloseMode);
this.nextTagCloseMode = null;
} else {
this.popMode();
}
this.debug(`after ${this.text}`, this.printModeStack());
}
public printModeStack() {
const modeStack = this._modeStack.toArray();
return `mode: ${this._mode}, modeStack: ${modeStack.length === 0? '<empty>' : modeStack}`;
}
private rcDataTags = ["script", "pre", "textarea", "title"];
private tagName: string | null = null;
public setNextTagCloseMode() {
this.tagName = this.text.substring(1).toLowerCase();
this.nextTagCloseMode = this.rcDataTags.includes(this.tagName)? VelocityHtmlLexer.RCDATA_MODE : VelocityHtmlLexer.DEFAULT_MODE;
}
private makeVtlReferenceInsideToken(): void {
}
public isDebugEnabled = false;
private debug(...something: any[]): void {
if (this.isDebugEnabled) {
console.log.apply(undefined, something);
}
}
public isCurrentTagName(): boolean {
const tagName = this.text
.substring(2, this.text.length - 1)
.trim()
.toLowerCase();
return tagName === this.tagName;
}
}
IE_COMMENT_START: '<!--[' ~[\]]+ ']>';
IE_COMMENT_CLOSE: '<![endif]-->';
// Slurp whitespace after comment to avoid handling of whitespace between comment and node that it should attach to.
IE_REVEALED_COMMENT_START: '<!--[' ~[\]]+ ']><!-->' DEFAULT_WS*;
// Same as above
IE_REVEALED_COMMENT_CLOSE: DEFAULT_WS* '<!--<![endif]-->';
// See revealed comment
PRETTIER_IGNORE: '<!--' DEFAULT_WS* 'prettier-ignore' DEFAULT_WS* '-->' DEFAULT_WS*;
// Comment that is NOT an IE comment.
// Using (~[[] .*?)? breaks non-greediness
COMMENT: {this.isNotStartOfConditionalComment()}? '<!--' .*? '-->';
CDATA: '<![CDATA['~[\]]*? ']]>';
// doctype case-insensitive
DOCTYPE_START: '<!' [dD] [oO] [cC] [tT] [yY] [pP] [eE] -> pushMode(DOCTYPE_MODE);
// Text inside certain tags must be tokenized as RCDATA, because <> are valid characters.
// See RCDATA_MODE for more information.
TAG_START_OPEN: '<' HTML_LIBERAL_NAME { this.setNextTagCloseMode() } -> pushMode(TAG_MODE);
TAG_END: '<' '/' HTML_LIBERAL_NAME DEFAULT_WS* '>';
// TODO Try to break this
// Not escapable
VTL_COMMENT: '##' ~[\n\r\f]*;
// Not escapable
VTL_MULTILINE_COMMENT: '#*' ( ~[*] | ('*' ~[#]) )* '*#';
// This needs to be above all velocity rules that can be escaped
NOT_VTL_VARIABLE: {!this.isStartOfVtl()}? [#$] ~[ \t\n\r\f<]* -> type(HTML_TEXT);
VTL_DIRECTIVE_START : '#' '{'? VTL_IDENTIFIER '}'? VTL_WS* '(' -> pushMode(VELOCITY_MODE);
VTL_ELSE: '#' '{'? 'else' '}'?;
VTL_DIRECTIVE_END: '#' '{' ? 'end' '}'?;
VTL_NO_CODE_DIRECTIVE: '#' '{'? ('break' | 'stop') '}'?;
VTL_MACRO_WITH_BODY_START: '#@' VTL_IDENTIFIER VTL_WS* '(' -> pushMode(VELOCITY_MODE);
VTL_VARIABLE: '$' '!'? '{'? VTL_IDENTIFIER {this.pushModeIfNecessary()};
HTML_TEXT: ~[ \t\n\r\f<$#]+;
WS
: DEFAULT_WS +
;
fragment DEFAULT_WS: [ \t\n\r\f] ;
// fragment NOT_DEFAULT_WS not working
// handle characters which failed to match any other token
ERROR_CHARACTER : . ;
mode VELOCITY_REFERENCE_MODE;
VTL_REFERENCE_IDENTIFIER: VTL_IDENTIFIER {this.popModeIfNecessary()} -> type(VTL_IDENTIFIER);
VTL_REFERENCE_DOT: '.';
VTL_REFERENCE_PIPE: '|' -> type(VTL_KEYWORD);
VTL_REFERENCE_STRING: VTL_STRING -> type(VTL_STRING);
VTL_REFERENCE_PARENS_OPEN: '(' -> type(VTL_PARENS_OPEN), pushMode(VELOCITY_MODE);
// TODO Also used for ranges
VTL_REFERENCE_INDEX_OPEN: '[' -> type(VTL_INDEX_OPEN), pushMode(VELOCITY_MODE);
// TODO Entfernen
VTL_REFERENCE_WS: DEFAULT_WS -> type(WS), popMode;
VTL_REFERENCE_FORMAL_CLOSE: '}' -> type(VTL_FORMAL_CLOSE), popMode;
VTL_REFERENCE_ERROR_CHARACTER: . -> type(ERROR_CHARACTER);
// TODO Velocity variable. Keep preformatted:
// - $122.22
// Example from user_guide.
mode VELOCITY_MODE;
VTL_KEYWORD: 'in' | '=' | ',' | '|' | '<' | '>' | '!' | '&' | ':' | '+' | '-' | '*' | '/' | '.';
VTL_IDENTIFIER: [a-zA-Z][a-zA-Z0-9_]* { this.makeVtlReferenceInsideToken() };
// TODO Velocity terminology
VTL_INDEX_OPEN: '[' -> pushMode(VELOCITY_MODE);
VTL_INDEX_CLOSE: ']' {this.popModeIfNecessary()} -> popMode;
VTL_PARENS_OPEN: '(' -> pushMode(VELOCITY_MODE);
VTL_PARENS_CLOSE: ')' {this.popModeIfNecessary()} -> popMode;
VTL_CURLY_OPEN: '{' -> pushMode(VELOCITY_MODE);
VTL_FORMAL_CLOSE: '}' {this.popModeIfNecessary()} -> popMode;
VTL_REFERENCE: '$' VTL_IDENTIFIER;
VTL_FORMAL_REFERENCE_OPEN: '${' VTL_IDENTIFIER -> pushMode(VELOCITY_MODE);
// VTL_VALUE
// : VTL_STRING
// | VTL_NUMBER
// | VTL_REFERENCE;
VTL_STRING
: '"' (('\\' ~[\\\u0000-\u001F]) | ~ ["\\\u0000-\u001F])* '"'
| '\'' (('\\' ~[\\\u0000-\u001F]) | ~ ['\\\u0000-\u001F])* '\''
;
// TODO VTL Variables in CSS. Do not format CSS
VTL_NUMBER
: [1-9][0-9]* | '0';
VTL_WS
: DEFAULT_WS + -> type(WS)
;
VTL_ERROR_CHARACTER: . -> type(ERROR_CHARACTER);
mode TAG_MODE;
// Mix between tag name and attribute name:
// Tag open state: ASCII alpha https://html.spec.whatwg.org/#tag-open-state
// Tag name state: Not tab, lf, ff, space, solidus, > https://html.spec.whatwg.org/#tag-name-state
// Attribute name: https://html.spec.whatwg.org/#attribute-name-state
fragment HTML_LIBERAL_NAME: ~[ \t\n\r\f/><="'#]+;
HTML_NAME: HTML_LIBERAL_NAME;
EQUAL: '=';
// \- since - means "range" inside [...]
HTML_STRING_START: '\''{this.setTagString('single')}-> pushMode(TAG_STRING);
HTML_STRING_START_DOUBLE: '"' {this.setTagString('double')}-> type(HTML_STRING_START), pushMode(TAG_STRING);
// TODO Does this make sense?
fragment VALID_ESCAPES: '\\' ~[\\\u0000-\u001F];
TAG_CLOSE: '>' { this.popModeForCurrentTag() };
SELF_CLOSING_TAG_CLOSE :'/' '>' -> popMode;
// TODO Support other tags
TAG_VTL_DIRECTIVE_START : '#' '{'? ('if'|'elseif') '}'? VTL_WS* '(' -> type(VTL_DIRECTIVE_START), pushMode(VELOCITY_MODE);
TAG_VTL_ELSE: '#' '{'? 'else' '}'? -> type(VTL_ELSE);
TAG_VTL_DIRECTIVE_END: '#end' -> type(VTL_DIRECTIVE_END);
TAG_NOT_VTL_VARIABLE: {!this.isStartOfVtl()}? [#] ~[ \t\n\r\f<]* -> type(HTML_NAME);
HTML_WS
: DEFAULT_WS -> skip
;
HTML_ERROR_CHARACTER: . -> type(ERROR_CHARACTER);
mode TAG_STRING;
TAG_STRING_NOT_VTL_VARIABLE_SINGLE : {this.isTagStringSingle() && !this.isStartOfVtl()}? [#$] ('\\"' | ~[$#'])* -> type(HTML_STRING);
TAG_STRING_NOT_VTL_VARIABLE_DOUBLE : {this.isTagStringDouble() && !this.isStartOfVtl()}? [#$] ('\\"' | ~[$#"])* -> type(HTML_STRING);
TAG_STRING_VTL_DIRECTIVE_START : VTL_DIRECTIVE_START -> type(VTL_DIRECTIVE_START), pushMode(VELOCITY_MODE);
TAG_STRING_VTL_VARIABLE: VTL_VARIABLE {this.pushModeIfNecessary()} -> type(VTL_VARIABLE);
HTML_STRING: {this.isTagStringSingle()}? ('\\"' | ~[$#'])+;
HTML_STRING_DOUBLE: {this.isTagStringDouble()}? ('\\"' | ~[$#"])+ -> type(HTML_STRING) ;
TAG_STRING_VTL_ELSE: VTL_ELSE;
TAG_STRING_VTL_DIRECTIVE_END: VTL_DIRECTIVE_END;
TAG_STRING_VTL_NO_CODE_DIRECTIVE: VTL_NO_CODE_DIRECTIVE;
HTML_STRING_END: {this.isTagStringSingle()}? '\'' {this.resetTagString()} -> popMode;
HTML_STRING_END_DOUBLE: {this.isTagStringDouble()}? '"' {this.resetTagString()} -> type(HTML_STRING_END), popMode;
mode DOCTYPE_MODE;
// https://html.spec.whatwg.org/multipage/parsing.html#before-doctype-name-state
DOCTYPE_TYPE: ~[ \t\n\r\f>] +;
DOCTYPE_WS: DEFAULT_WS + -> skip;
DOCTYPE_END: '>' -> popMode;
DOCTYPE_ERROR_CHARACTER: . -> type(ERROR_CHARACTER);
mode RCDATA_MODE;
// Script state only changes on closing script tag: https://html.spec.whatwg.org/#script-data-less-than-sign-state
// TODO Space after t possible?
SCRIPT_END_TAG: '</'HTML_LIBERAL_NAME '>' {this.isCurrentTagName()}? -> mode(DEFAULT_MODE), type(TAG_END);
// All other valid tags (ASCII alpha: https://html.spec.whatwg.org/#script-data-end-tag-open-state)
SCRIPT_OTHER_CLOSING_TAG: '<' '/'? HTML_LIBERAL_NAME -> type(HTML_TEXT);
SCRIPT_TEXT: (~[ \t\n\r\f<]+ | '<') -> type(HTML_TEXT);
SCRIPT_WS: DEFAULT_WS -> type(HTML_TEXT);
SCRIPT_ERROR_CHARACTER: . -> type(ERROR_CHARACTER);
|
AX2ALBLCLDL.asm
|
CallMeMengMeng/ASSEMBLY-LANGUAGE
| 0 |
165657
|
<reponame>CallMeMengMeng/ASSEMBLY-LANGUAGE
; THERE IS A 16-BIT FIGURE IN AX, DIVIDE IT INTO 4 PARTS, THEN STORE THEM AS FOLLOW:
; | AL | BL | CL | DL |
; |0000AX00|0000AX01|0000AX10|0000AX11|
CODE SEGMENT
ASSUME CS:CODE
START: MOV AX,0D9BDH ; AX=D9BD
MOV BX,AX ; BACKUP IN BX
MOV CL,4 ; SET A 4 TIMES COUNTER
MOV DX,AX ; BACKUP IN DX
MOV AL,AH ; MOVE D9H TO AL
SHR AL,CL ; SHIFT AL TO RIGHT WITH 4 BITS TO GET 0DH IN AL
MOV BL,BH ; MOVE D9H TO BL
AND BL,0FH ; SAVE THE LAST 4 BITS TO GET 09H IN BL
MOV DH,DL ; MOVE BDH TO DH
SHR DH,CL ; SHIFT DH TO RIGHT WITH 4 BITS TO GET 0BH IN DH
MOV CL,DH ; MOVE 0BH TO CL
AND DL,0FH ; SAVE THE LAST 4 BITS WHICH IS 0DH IN DL
CODE ENDS
END START
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/bindo-graphs.adb
|
djamal2727/Main-Bearing-Analytical-Model
| 0 |
24313
|
<gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- B I N D O . G R A P H S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2019-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Butil; use Butil;
with Debug; use Debug;
with Output; use Output;
with Bindo.Writers;
use Bindo.Writers;
use Bindo.Writers.Phase_Writers;
package body Bindo.Graphs is
-----------------------
-- Local subprograms --
-----------------------
function Sequence_Next_Cycle return Library_Graph_Cycle_Id;
pragma Inline (Sequence_Next_Cycle);
-- Generate a new unique library graph cycle handle
function Sequence_Next_Edge return Invocation_Graph_Edge_Id;
pragma Inline (Sequence_Next_Edge);
-- Generate a new unique invocation graph edge handle
function Sequence_Next_Edge return Library_Graph_Edge_Id;
pragma Inline (Sequence_Next_Edge);
-- Generate a new unique library graph edge handle
function Sequence_Next_Vertex return Invocation_Graph_Vertex_Id;
pragma Inline (Sequence_Next_Vertex);
-- Generate a new unique invocation graph vertex handle
function Sequence_Next_Vertex return Library_Graph_Vertex_Id;
pragma Inline (Sequence_Next_Vertex);
-- Generate a new unique library graph vertex handle
-----------------------------------
-- Destroy_Invocation_Graph_Edge --
-----------------------------------
procedure Destroy_Invocation_Graph_Edge
(Edge : in out Invocation_Graph_Edge_Id)
is
pragma Unreferenced (Edge);
begin
null;
end Destroy_Invocation_Graph_Edge;
---------------------------------
-- Destroy_Library_Graph_Cycle --
---------------------------------
procedure Destroy_Library_Graph_Cycle
(Cycle : in out Library_Graph_Cycle_Id)
is
pragma Unreferenced (Cycle);
begin
null;
end Destroy_Library_Graph_Cycle;
--------------------------------
-- Destroy_Library_Graph_Edge --
--------------------------------
procedure Destroy_Library_Graph_Edge
(Edge : in out Library_Graph_Edge_Id)
is
pragma Unreferenced (Edge);
begin
null;
end Destroy_Library_Graph_Edge;
----------------------------------
-- Destroy_Library_Graph_Vertex --
----------------------------------
procedure Destroy_Library_Graph_Vertex
(Vertex : in out Library_Graph_Vertex_Id)
is
pragma Unreferenced (Vertex);
begin
null;
end Destroy_Library_Graph_Vertex;
--------------------------------
-- Hash_Invocation_Graph_Edge --
--------------------------------
function Hash_Invocation_Graph_Edge
(Edge : Invocation_Graph_Edge_Id) return Bucket_Range_Type
is
begin
pragma Assert (Present (Edge));
return Bucket_Range_Type (Edge);
end Hash_Invocation_Graph_Edge;
----------------------------------
-- Hash_Invocation_Graph_Vertex --
----------------------------------
function Hash_Invocation_Graph_Vertex
(Vertex : Invocation_Graph_Vertex_Id) return Bucket_Range_Type
is
begin
pragma Assert (Present (Vertex));
return Bucket_Range_Type (Vertex);
end Hash_Invocation_Graph_Vertex;
------------------------------
-- Hash_Library_Graph_Cycle --
------------------------------
function Hash_Library_Graph_Cycle
(Cycle : Library_Graph_Cycle_Id) return Bucket_Range_Type
is
begin
pragma Assert (Present (Cycle));
return Bucket_Range_Type (Cycle);
end Hash_Library_Graph_Cycle;
-----------------------------
-- Hash_Library_Graph_Edge --
-----------------------------
function Hash_Library_Graph_Edge
(Edge : Library_Graph_Edge_Id) return Bucket_Range_Type
is
begin
pragma Assert (Present (Edge));
return Bucket_Range_Type (Edge);
end Hash_Library_Graph_Edge;
-------------------------------
-- Hash_Library_Graph_Vertex --
-------------------------------
function Hash_Library_Graph_Vertex
(Vertex : Library_Graph_Vertex_Id) return Bucket_Range_Type
is
begin
pragma Assert (Present (Vertex));
return Bucket_Range_Type (Vertex);
end Hash_Library_Graph_Vertex;
--------------------
-- Library_Graphs --
--------------------
package body Library_Graphs is
-----------------------
-- Local subprograms --
-----------------------
procedure Add_Body_Before_Spec_Edge
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Edges : LGE_Lists.Doubly_Linked_List);
pragma Inline (Add_Body_Before_Spec_Edge);
-- Create a new edge in library graph G between vertex Vertex and its
-- corresponding spec or body, where the body is a predecessor and the
-- spec a successor. Add the edge to list Edges.
procedure Add_Body_Before_Spec_Edges
(G : Library_Graph;
Edges : LGE_Lists.Doubly_Linked_List);
pragma Inline (Add_Body_Before_Spec_Edges);
-- Create new edges in library graph G for all vertices and their
-- corresponding specs or bodies, where the body is a predecessor
-- and the spec is a successor. Add all edges to list Edges.
procedure Add_Edge_Kind_Check
(G : Library_Graph;
Pred : Library_Graph_Vertex_Id;
Succ : Library_Graph_Vertex_Id;
New_Kind : Library_Graph_Edge_Kind);
-- This is called by Add_Edge in the case where there is already a
-- Pred-->Succ edge, to assert that the New_Kind is appropriate. Raises
-- Program_Error if a bug is detected. The purpose is to prevent bugs
-- where calling Add_Edge in different orders produces different output.
function Add_Edge
(G : Library_Graph;
Pred : Library_Graph_Vertex_Id;
Succ : Library_Graph_Vertex_Id;
Kind : Library_Graph_Edge_Kind;
Activates_Task : Boolean) return Library_Graph_Edge_Id;
pragma Inline (Add_Edge);
-- Create a new edge in library graph G with source vertex Pred and
-- destination vertex Succ, and return its handle. Kind denotes the
-- nature of the edge. Activates_Task should be set when the edge
-- involves a task activation. If Pred and Succ are already related,
-- no edge is created and No_Library_Graph_Edge is returned, but if
-- Activates_Task is True, then the flag of the existing edge is
-- updated.
function At_Least_One_Edge_Satisfies
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id;
Predicate : LGE_Predicate_Ptr) return Boolean;
pragma Inline (At_Least_One_Edge_Satisfies);
-- Determine whether at least one edge of cycle Cycle of library graph G
-- satisfies predicate Predicate.
function Copy_Cycle_Path
(Cycle_Path : LGE_Lists.Doubly_Linked_List)
return LGE_Lists.Doubly_Linked_List;
pragma Inline (Copy_Cycle_Path);
-- Create a deep copy of list Cycle_Path
function Cycle_End_Vertices
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Elaborate_All_Active : Boolean) return LGV_Sets.Membership_Set;
pragma Inline (Cycle_End_Vertices);
-- Part of Tarjan's enumeration of the elementary circuits of a directed
-- graph algorithm. Collect the vertices that terminate a cycle starting
-- from vertex Vertex of library graph G in a set. This is usually the
-- vertex itself, unless the vertex is part of an Elaborate_Body pair,
-- or flag Elaborate_All_Active is set. In that case the complementary
-- vertex is also added to the set.
function Cycle_Kind_Of
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Cycle_Kind;
pragma Inline (Cycle_Kind_Of);
-- Determine the cycle kind of edge Edge of library graph G if the edge
-- participated in a circuit.
function Cycle_Kind_Precedence
(Kind : Library_Graph_Cycle_Kind;
Compared_To : Library_Graph_Cycle_Kind) return Precedence_Kind;
pragma Inline (Cycle_Kind_Precedence);
-- Determine the precedence of cycle kind Kind compared to cycle kind
-- Compared_To.
function Cycle_Path_Precedence
(G : Library_Graph;
Path : LGE_Lists.Doubly_Linked_List;
Compared_To : LGE_Lists.Doubly_Linked_List) return Precedence_Kind;
pragma Inline (Cycle_Path_Precedence);
-- Determine the precedence of cycle path Path of library graph G
-- compared to path Compared_To.
function Cycle_Precedence
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id;
Compared_To : Library_Graph_Cycle_Id) return Precedence_Kind;
pragma Inline (Cycle_Precedence);
-- Determine the precedence of cycle Cycle of library graph G compared
-- to cycle Compared_To.
procedure Decrement_Library_Graph_Edge_Count
(G : Library_Graph;
Kind : Library_Graph_Edge_Kind);
pragma Inline (Decrement_Library_Graph_Edge_Count);
-- Decrement the number of edges of kind King in library graph G by one
procedure Delete_Body_Before_Spec_Edges
(G : Library_Graph;
Edges : LGE_Lists.Doubly_Linked_List);
pragma Inline (Delete_Body_Before_Spec_Edges);
-- Delete all edges in list Edges from library graph G, that link spec
-- and bodies, where the body acts as the predecessor and the spec as a
-- successor.
procedure Delete_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id);
pragma Inline (Delete_Edge);
-- Delete edge Edge from library graph G
function Edge_Precedence
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
Compared_To : Library_Graph_Edge_Id) return Precedence_Kind;
pragma Inline (Edge_Precedence);
-- Determine the precedence of edge Edge of library graph G compared to
-- edge Compared_To.
procedure Find_Cycles_From_Successor
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
End_Vertices : LGV_Sets.Membership_Set;
Deleted_Vertices : LGV_Sets.Membership_Set;
Most_Significant_Edge : Library_Graph_Edge_Id;
Invocation_Edge_Count : Natural;
Cycle_Path_Stack : LGE_Lists.Doubly_Linked_List;
Visited_Set : LGV_Sets.Membership_Set;
Visited_Stack : LGV_Lists.Doubly_Linked_List;
Cycle_Count : in out Natural;
Cycle_Limit : Natural;
Elaborate_All_Active : Boolean;
Has_Cycle : out Boolean;
Indent : Indentation_Level);
pragma Inline (Find_Cycles_From_Successor);
-- Part of Tarjan's enumeration of the elementary circuits of a directed
-- graph algorithm. Find all cycles from the successor indicated by edge
-- Edge of library graph G. If at least one cycle exists, set Has_Cycle
-- to True. The remaining parameters are as follows:
--
-- * End vertices is the set of vertices that terminate a potential
-- cycle.
--
-- * Deleted vertices is the set of vertices that have been expanded
-- during previous depth-first searches and should not be visited
-- for the rest of the algorithm.
--
-- * Most_Significant_Edge is the current highest-precedence edge on
-- the path of the potential cycle.
--
-- * Invocation_Edge_Count is the number of invocation edges on the
-- path of the potential cycle.
--
-- * Cycle_Path_Stack is the path of the potential cycle.
--
-- * Visited_Set is the set of vertices that have been visited during
-- the current depth-first search.
--
-- * Visited_Stack maintains the vertices of Visited_Set in a stack
-- for later unvisiting.
--
-- * Cycle_Count is the number of cycles discovered so far.
--
-- * Cycle_Limit is the upper bound of the number of cycles to be
-- discovered.
--
-- * Elaborate_All_Active should be set when the component currently
-- being examined for cycles contains an Elaborate_All edge.
--
-- * Indent in the desired indentation level for tracing.
procedure Find_Cycles_From_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
End_Vertices : LGV_Sets.Membership_Set;
Deleted_Vertices : LGV_Sets.Membership_Set;
Most_Significant_Edge : Library_Graph_Edge_Id;
Invocation_Edge_Count : Natural;
Cycle_Path_Stack : LGE_Lists.Doubly_Linked_List;
Visited_Set : LGV_Sets.Membership_Set;
Visited_Stack : LGV_Lists.Doubly_Linked_List;
Cycle_Count : in out Natural;
Cycle_Limit : Natural;
Elaborate_All_Active : Boolean;
Is_Start_Vertex : Boolean;
Has_Cycle : out Boolean;
Indent : Indentation_Level);
pragma Inline (Find_Cycles_From_Vertex);
-- Part of Tarjan's enumeration of the elementary circuits of a directed
-- graph algorithm. Find all cycles from vertex Vertex of library graph
-- G. If at least one cycle exists, set Has_Cycle to True. The remaining
-- parameters are as follows:
--
-- * End_Vertices is the set of vertices that terminate a potential
-- cycle.
--
-- * Deleted_Vertices is the set of vertices that have been expanded
-- during previous depth-first searches and should not be visited
-- for the rest of the algorithm.
--
-- * Most_Significant_Edge is the current highest-precedence edge on
-- the path of the potential cycle.
--
-- * Invocation_Edge_Count is the number of invocation edges on the
-- path of the potential cycle.
--
-- * Cycle_Path_Stack is the path of the potential cycle.
--
-- * Visited_Set is the set of vertices that have been visited during
-- the current depth-first search.
--
-- * Visited_Stack maintains the vertices of Visited_Set in a stack
-- for later unvisiting.
--
-- * Cycle_Count is the number of cycles discovered so far.
--
-- * Cycle_Limit is the upper bound of the number of cycles to be
-- discovered.
--
-- * Elaborate_All_Active should be set when the component currently
-- being examined for cycles contains an Elaborate_All edge.
--
-- * Indent in the desired indentation level for tracing.
procedure Find_Cycles_In_Component
(G : Library_Graph;
Comp : Component_Id;
Cycle_Count : in out Natural;
Cycle_Limit : Natural);
pragma Inline (Find_Cycles_In_Component);
-- Part of Tarjan's enumeration of the elementary circuits of a directed
-- graph algorithm. Find all cycles in component Comp of library graph
-- G. The remaining parameters are as follows:
--
-- * Cycle_Count is the number of cycles discovered so far.
--
-- * Cycle_Limit is the upper bound of the number of cycles to be
-- discovered.
function Find_Edge
(G : Library_Graph;
Pred : Library_Graph_Vertex_Id;
Succ : Library_Graph_Vertex_Id) return Library_Graph_Edge_Id;
-- There must be an edge Pred-->Succ; this returns it
function Find_First_Lower_Precedence_Cycle
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Library_Graph_Cycle_Id;
pragma Inline (Find_First_Lower_Precedence_Cycle);
-- Inspect the list of cycles of library graph G and return the first
-- cycle whose precedence is lower than that of cycle Cycle. If there
-- is no such cycle, return No_Library_Graph_Cycle.
procedure Free is
new Ada.Unchecked_Deallocation
(Library_Graph_Attributes, Library_Graph);
function Get_Component_Attributes
(G : Library_Graph;
Comp : Component_Id) return Component_Attributes;
pragma Inline (Get_Component_Attributes);
-- Obtain the attributes of component Comp of library graph G
function Get_LGC_Attributes
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Library_Graph_Cycle_Attributes;
pragma Inline (Get_LGC_Attributes);
-- Obtain the attributes of cycle Cycle of library graph G
function Get_LGE_Attributes
(G : Library_Graph;
Edge : Library_Graph_Edge_Id)
return Library_Graph_Edge_Attributes;
pragma Inline (Get_LGE_Attributes);
-- Obtain the attributes of edge Edge of library graph G
function Get_LGV_Attributes
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id)
return Library_Graph_Vertex_Attributes;
pragma Inline (Get_LGV_Attributes);
-- Obtain the attributes of vertex Edge of library graph G
function Has_Elaborate_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Has_Elaborate_Body);
-- Determine whether vertex Vertex of library graph G is subject to
-- pragma Elaborate_Body.
function Has_Elaborate_All_Edge
(G : Library_Graph;
Comp : Component_Id) return Boolean;
pragma Inline (Has_Elaborate_All_Edge);
-- Determine whether component Comp of library graph G contains an
-- Elaborate_All edge that links two vertices in the same component.
function Has_Elaborate_All_Edge
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Has_Elaborate_All_Edge);
-- Determine whether vertex Vertex of library graph G contains an
-- Elaborate_All edge to a successor where both the vertex and the
-- successor reside in the same component.
function Highest_Precedence_Edge
(G : Library_Graph;
Left : Library_Graph_Edge_Id;
Right : Library_Graph_Edge_Id) return Library_Graph_Edge_Id;
pragma Inline (Highest_Precedence_Edge);
-- Return the edge with highest precedence among edges Left and Right of
-- library graph G.
procedure Increment_Library_Graph_Edge_Count
(G : Library_Graph;
Kind : Library_Graph_Edge_Kind);
pragma Inline (Increment_Library_Graph_Edge_Count);
-- Increment the number of edges of king Kind in library graph G by one
procedure Increment_Pending_Predecessors
(G : Library_Graph;
Comp : Component_Id;
Edge : Library_Graph_Edge_Id);
pragma Inline (Increment_Pending_Predecessors);
-- Increment the number of pending predecessors component Comp which was
-- reached via edge Edge of library graph G must wait on before it can
-- be elaborated by one.
procedure Increment_Pending_Predecessors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Edge : Library_Graph_Edge_Id);
pragma Inline (Increment_Pending_Predecessors);
-- Increment the number of pending predecessors vertex Vertex which was
-- reached via edge Edge of library graph G must wait on before it can
-- be elaborated by one.
procedure Initialize_Components (G : Library_Graph);
pragma Inline (Initialize_Components);
-- Initialize on the initial call or re-initialize on subsequent calls
-- all components of library graph G.
function Is_Cycle_Initiating_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Cycle_Initiating_Edge);
-- Determine whether edge Edge of library graph G starts a cycle
function Is_Cyclic_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Cyclic_Edge);
-- Determine whether edge Edge of library graph G participates in a
-- cycle.
function Is_Cyclic_Elaborate_All_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Cyclic_Elaborate_All_Edge);
-- Determine whether edge Edge of library graph G participates in a
-- cycle and has a predecessor that is subject to pragma Elaborate_All.
function Is_Cyclic_Elaborate_Body_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Cyclic_Elaborate_Body_Edge);
-- Determine whether edge Edge of library graph G participates in a
-- cycle and has a successor that is either a spec subject to pragma
-- Elaborate_Body, or a body that completes such a spec.
function Is_Cyclic_Elaborate_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Cyclic_Elaborate_Edge);
-- Determine whether edge Edge of library graph G participates in a
-- cycle and has a predecessor that is subject to pragma Elaborate.
function Is_Cyclic_Forced_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Cyclic_Forced_Edge);
-- Determine whether edge Edge of library graph G participates in a
-- cycle and came from the forced-elaboration-order file.
function Is_Cyclic_Invocation_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Cyclic_Invocation_Edge);
-- Determine whether edge Edge of library graph G participates in a
-- cycle and came from the traversal of the invocation graph.
function Is_Cyclic_With_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Cyclic_With_Edge);
-- Determine whether edge Edge of library graph G participates in a
-- cycle and is the result of a with dependency between its successor
-- and predecessor.
function Is_Recorded_Edge
(G : Library_Graph;
Rel : Predecessor_Successor_Relation) return Boolean;
pragma Inline (Is_Recorded_Edge);
-- Determine whether a predecessor vertex and a successor vertex
-- described by relation Rel are already linked in library graph G.
function Is_Static_Successor_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Is_Static_Successor_Edge);
-- Determine whether the successor of invocation edge Edge represents a
-- unit that was compiled with the static model.
function Is_Vertex_With_Elaborate_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Vertex_With_Elaborate_Body);
-- Determine whether vertex Vertex of library graph G denotes a spec
-- subject to pragma Elaborate_Body or the completing body of such a
-- spec.
function Links_Vertices_In_Same_Component
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean;
pragma Inline (Links_Vertices_In_Same_Component);
-- Determine whether edge Edge of library graph G links a predecessor
-- and successor that reside in the same component.
function Maximum_Invocation_Edge_Count
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
Count : Natural) return Natural;
pragma Inline (Maximum_Invocation_Edge_Count);
-- Determine whether edge Edge of library graph G is an invocation edge,
-- and if it is return Count + 1, otherwise return Count.
procedure Normalize_Cycle_Path
(Cycle_Path : LGE_Lists.Doubly_Linked_List;
Most_Significant_Edge : Library_Graph_Edge_Id);
pragma Inline (Normalize_Cycle_Path);
-- Normalize cycle path Path by rotating it until its starting edge is
-- Sig_Edge.
procedure Order_Cycle
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id);
pragma Inline (Order_Cycle);
-- Insert cycle Cycle in library graph G and sort it based on its
-- precedence relative to all recorded cycles.
function Path
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return LGE_Lists.Doubly_Linked_List;
pragma Inline (Path);
-- Obtain the path of edges which comprises cycle Cycle of library
-- graph G.
procedure Record_Cycle
(G : Library_Graph;
Most_Significant_Edge : Library_Graph_Edge_Id;
Invocation_Edge_Count : Natural;
Cycle_Path : LGE_Lists.Doubly_Linked_List;
Indent : Indentation_Level);
pragma Inline (Record_Cycle);
-- Normalize a cycle described by its path Cycle_Path and add it to
-- library graph G. Most_Significant_Edge denotes the edge with the
-- highest significance along the cycle path. Invocation_Edge_Count
-- is the number of invocation edges along the cycle path. Indent is
-- the desired indentation level for tracing.
procedure Set_Activates_Task
(G : Library_Graph;
Edge : Library_Graph_Edge_Id);
-- Set the Activates_Task flag of the Edge to True
procedure Set_Component_Attributes
(G : Library_Graph;
Comp : Component_Id;
Val : Component_Attributes);
pragma Inline (Set_Component_Attributes);
-- Set the attributes of component Comp of library graph G to value Val
procedure Set_Corresponding_Vertex
(G : Library_Graph;
U_Id : Unit_Id;
Val : Library_Graph_Vertex_Id);
pragma Inline (Set_Corresponding_Vertex);
-- Associate vertex Val of library graph G with unit U_Id
procedure Set_Is_Recorded_Edge
(G : Library_Graph;
Rel : Predecessor_Successor_Relation);
pragma Inline (Set_Is_Recorded_Edge);
-- Mark a predecessor vertex and a successor vertex described by
-- relation Rel as already linked.
procedure Set_LGC_Attributes
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id;
Val : Library_Graph_Cycle_Attributes);
pragma Inline (Set_LGC_Attributes);
-- Set the attributes of cycle Cycle of library graph G to value Val
procedure Set_LGE_Attributes
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
Val : Library_Graph_Edge_Attributes);
pragma Inline (Set_LGE_Attributes);
-- Set the attributes of edge Edge of library graph G to value Val
procedure Set_LGV_Attributes
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Val : Library_Graph_Vertex_Attributes);
pragma Inline (Set_LGV_Attributes);
-- Set the attributes of vertex Vertex of library graph G to value Val
procedure Trace_Component
(G : Library_Graph;
Comp : Component_Id;
Indent : Indentation_Level);
pragma Inline (Trace_Component);
-- Write the contents of component Comp of library graph G to standard
-- output. Indent is the desired indentation level for tracing.
procedure Trace_Cycle
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id;
Indent : Indentation_Level);
pragma Inline (Trace_Cycle);
-- Write the contents of cycle Cycle of library graph G to standard
-- output. Indent is the desired indentation level for tracing.
procedure Trace_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
Indent : Indentation_Level);
pragma Inline (Trace_Edge);
-- Write the contents of edge Edge of library graph G to standard
-- output. Indent is the desired indentation level for tracing.
procedure Trace_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Indent : Indentation_Level);
pragma Inline (Trace_Vertex);
-- Write the contents of vertex Vertex of library graph G to standard
-- output. Indent is the desired indentation level for tracing.
procedure Unvisit
(Vertex : Library_Graph_Vertex_Id;
Visited_Set : LGV_Sets.Membership_Set;
Visited_Stack : LGV_Lists.Doubly_Linked_List);
pragma Inline (Unvisit);
-- Part of Tarjan's enumeration of the elementary circuits of a directed
-- graph algorithm. Unwind the Visited_Stack by removing the top vertex
-- from set Visited_Set until vertex Vertex is reached, inclusive.
procedure Update_Pending_Predecessors
(Strong_Predecessors : in out Natural;
Weak_Predecessors : in out Natural;
Update_Weak : Boolean;
Value : Integer);
pragma Inline (Update_Pending_Predecessors);
-- Update the number of pending strong or weak predecessors denoted by
-- Strong_Predecessors and Weak_Predecessors respectively depending on
-- flag Update_Weak by adding value Value.
procedure Update_Pending_Predecessors_Of_Components (G : Library_Graph);
pragma Inline (Update_Pending_Predecessors_Of_Components);
-- Update the number of pending predecessors all components of library
-- graph G must wait on before they can be elaborated.
procedure Update_Pending_Predecessors_Of_Components
(G : Library_Graph;
Edge : Library_Graph_Edge_Id);
pragma Inline (Update_Pending_Predecessors_Of_Components);
-- Update the number of pending predecessors the component of edge
-- LGE_Is's successor vertex of library graph G must wait on before
-- it can be elaborated.
function Vertex_Precedence
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Compared_To : Library_Graph_Vertex_Id) return Precedence_Kind;
pragma Inline (Vertex_Precedence);
-- Determine the precedence of vertex Vertex of library graph G compared
-- to vertex Compared_To.
procedure Visit
(Vertex : Library_Graph_Vertex_Id;
Visited_Set : LGV_Sets.Membership_Set;
Visited_Stack : LGV_Lists.Doubly_Linked_List);
pragma Inline (Visit);
-- Part of Tarjan's enumeration of the elementary circuits of a directed
-- graph algorithm. Push vertex Vertex on the Visited_Stack and add it
-- to set Visited_Set.
--------------------
-- Activates_Task --
--------------------
function Activates_Task
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
return Get_LGE_Attributes (G, Edge).Activates_Task;
end Activates_Task;
-------------------------------
-- Add_Body_Before_Spec_Edge --
-------------------------------
procedure Add_Body_Before_Spec_Edge
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Edges : LGE_Lists.Doubly_Linked_List)
is
Edge : Library_Graph_Edge_Id;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
pragma Assert (LGE_Lists.Present (Edges));
-- A vertex requires a special Body_Before_Spec edge to its
-- Corresponding_Item when it either denotes a
--
-- * Body that completes a previous spec
--
-- * Spec with a completing body
--
-- The edge creates an intentional circularity between the spec and
-- body in order to emulate a library unit, and guarantees that both
-- will appear in the same component.
--
-- Due to the structure of the library graph, either the spec or
-- the body may be visited first, yet Corresponding_Item will still
-- attempt to create the Body_Before_Spec edge. This is OK because
-- successor and predecessor are kept consistent in both cases, and
-- Add_Edge will prevent the creation of the second edge.
-- Assume that no Body_Before_Spec is necessary
Edge := No_Library_Graph_Edge;
-- A body that completes a previous spec
if Is_Body_With_Spec (G, Vertex) then
Edge :=
Add_Edge
(G => G,
Pred => Vertex,
Succ => Corresponding_Item (G, Vertex),
Kind => Body_Before_Spec_Edge,
Activates_Task => False);
-- A spec with a completing body
elsif Is_Spec_With_Body (G, Vertex) then
Edge :=
Add_Edge
(G => G,
Pred => Corresponding_Item (G, Vertex),
Succ => Vertex,
Kind => Body_Before_Spec_Edge,
Activates_Task => False);
end if;
if Present (Edge) then
LGE_Lists.Append (Edges, Edge);
end if;
end Add_Body_Before_Spec_Edge;
--------------------------------
-- Add_Body_Before_Spec_Edges --
--------------------------------
procedure Add_Body_Before_Spec_Edges
(G : Library_Graph;
Edges : LGE_Lists.Doubly_Linked_List)
is
Iter : Elaborable_Units_Iterator;
U_Id : Unit_Id;
begin
pragma Assert (Present (G));
pragma Assert (LGE_Lists.Present (Edges));
Iter := Iterate_Elaborable_Units;
while Has_Next (Iter) loop
Next (Iter, U_Id);
Add_Body_Before_Spec_Edge
(G => G,
Vertex => Corresponding_Vertex (G, U_Id),
Edges => Edges);
end loop;
end Add_Body_Before_Spec_Edges;
--------------
-- Add_Edge --
--------------
procedure Add_Edge
(G : Library_Graph;
Pred : Library_Graph_Vertex_Id;
Succ : Library_Graph_Vertex_Id;
Kind : Library_Graph_Edge_Kind;
Activates_Task : Boolean)
is
Ignore : constant Library_Graph_Edge_Id :=
Add_Edge
(G => G,
Pred => Pred,
Succ => Succ,
Kind => Kind,
Activates_Task => Activates_Task);
begin
null;
end Add_Edge;
-------------------------
-- Add_Edge_Kind_Check --
-------------------------
procedure Add_Edge_Kind_Check
(G : Library_Graph;
Pred : Library_Graph_Vertex_Id;
Succ : Library_Graph_Vertex_Id;
New_Kind : Library_Graph_Edge_Kind)
is
Old_Edge : constant Library_Graph_Edge_Id :=
Find_Edge (G, Pred, Succ);
Old_Kind : constant Library_Graph_Edge_Kind :=
Get_LGE_Attributes (G, Old_Edge).Kind;
OK : Boolean;
begin
case New_Kind is
when Spec_Before_Body_Edge =>
OK := False;
-- Spec_Before_Body_Edge comes first, and there is never more
-- than one Spec_Before_Body_Edge for a given unit, so we can't
-- have a preexisting edge in the Spec_Before_Body_Edge case.
when With_Edge | Elaborate_Edge | Elaborate_All_Edge
| Forced_Edge | Invocation_Edge =>
OK := Old_Kind <= New_Kind;
-- These edges are created in the order of the enumeration
-- type, and there can be duplicates; hence "<=".
when Body_Before_Spec_Edge =>
OK := Old_Kind = Body_Before_Spec_Edge
-- We call Add_Edge with Body_Before_Spec_Edge twice -- once
-- for the spec and once for the body.
or else Old_Kind = Forced_Edge
or else Old_Kind = Invocation_Edge;
-- The old one can be Forced_Edge or Invocation_Edge, which
-- necessarily results in an elaboration cycle (in the static
-- model), but this assertion happens before cycle detection,
-- so we need to allow these cases.
when No_Edge =>
OK := False;
end case;
if not OK then
raise Program_Error with Old_Kind'Img & "-->" & New_Kind'Img;
end if;
end Add_Edge_Kind_Check;
--------------
-- Add_Edge --
--------------
function Add_Edge
(G : Library_Graph;
Pred : Library_Graph_Vertex_Id;
Succ : Library_Graph_Vertex_Id;
Kind : Library_Graph_Edge_Kind;
Activates_Task : Boolean) return Library_Graph_Edge_Id
is
pragma Assert (Present (G));
pragma Assert (Present (Pred));
pragma Assert (Present (Succ));
pragma Assert (Kind = Invocation_Edge or else not Activates_Task);
-- Only invocation edges can activate tasks
Rel : constant Predecessor_Successor_Relation :=
(Predecessor => Pred, Successor => Succ);
Edge : Library_Graph_Edge_Id;
begin
-- If we already have a Pred-->Succ edge, we don't add another
-- one. But we need to update Activates_Task, in order to avoid
-- depending on the order of processing of edges. If we have
-- Pred-->Succ with Activates_Task=True, and another Pred-->Succ with
-- Activates_Task=False, we want Activates_Task to be True no matter
-- which order we processed those two Add_Edge calls.
if Is_Recorded_Edge (G, Rel) then
pragma Debug (Add_Edge_Kind_Check (G, Pred, Succ, Kind));
if Activates_Task then
Set_Activates_Task (G, Find_Edge (G, Pred, Succ));
end if;
return No_Library_Graph_Edge;
end if;
Edge := Sequence_Next_Edge;
-- Add the edge to the underlying graph. Note that the predecessor
-- is the source of the edge because it will later need to notify
-- all its successors that it has been elaborated.
DG.Add_Edge
(G => G.Graph,
E => Edge,
Source => Pred,
Destination => Succ);
-- Construct and save the attributes of the edge
Set_LGE_Attributes
(G => G,
Edge => Edge,
Val =>
(Activates_Task => Activates_Task,
Kind => Kind));
-- Mark the predecessor and successor as related by the new edge.
-- This prevents all further attempts to link the same predecessor
-- and successor.
Set_Is_Recorded_Edge (G, Rel);
-- Update the number of pending predecessors the successor must wait
-- on before it is elaborated.
Increment_Pending_Predecessors
(G => G,
Vertex => Succ,
Edge => Edge);
-- Update the edge statistics
Increment_Library_Graph_Edge_Count (G, Kind);
return Edge;
end Add_Edge;
----------------
-- Add_Vertex --
----------------
procedure Add_Vertex
(G : Library_Graph;
U_Id : Unit_Id)
is
Vertex : Library_Graph_Vertex_Id;
begin
pragma Assert (Present (G));
pragma Assert (Present (U_Id));
-- Nothing to do when the unit already has a vertex
if Present (Corresponding_Vertex (G, U_Id)) then
return;
end if;
Vertex := Sequence_Next_Vertex;
-- Add the vertex to the underlying graph
DG.Add_Vertex (G.Graph, Vertex);
-- Construct and save the attributes of the vertex
Set_LGV_Attributes
(G => G,
Vertex => Vertex,
Val =>
(Corresponding_Item => No_Library_Graph_Vertex,
In_Elaboration_Order => False,
Pending_Strong_Predecessors => 0,
Pending_Weak_Predecessors => 0,
Unit => U_Id));
-- Associate the unit with its corresponding vertex
Set_Corresponding_Vertex (G, U_Id, Vertex);
end Add_Vertex;
---------------------------------
-- At_Least_One_Edge_Satisfies --
---------------------------------
function At_Least_One_Edge_Satisfies
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id;
Predicate : LGE_Predicate_Ptr) return Boolean
is
Edge : Library_Graph_Edge_Id;
Iter : Edges_Of_Cycle_Iterator;
Satisfied : Boolean;
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
pragma Assert (Predicate /= null);
-- Assume that the predicate cannot be satisfied
Satisfied := False;
-- IMPORTANT:
--
-- * The iteration must run to completion in order to unlock the
-- edges of the cycle.
Iter := Iterate_Edges_Of_Cycle (G, Cycle);
while Has_Next (Iter) loop
Next (Iter, Edge);
Satisfied := Satisfied or else Predicate.all (G, Edge);
end loop;
return Satisfied;
end At_Least_One_Edge_Satisfies;
--------------------------
-- Complementary_Vertex --
--------------------------
function Complementary_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Force_Complement : Boolean) return Library_Graph_Vertex_Id
is
Complement : Library_Graph_Vertex_Id;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
-- Assume that there is no complementary vertex
Complement := No_Library_Graph_Vertex;
-- The caller requests the complement explicitly
if Force_Complement then
Complement := Corresponding_Item (G, Vertex);
-- The vertex is a completing body of a spec subject to pragma
-- Elaborate_Body. The complementary vertex is the spec.
elsif Is_Body_Of_Spec_With_Elaborate_Body (G, Vertex) then
Complement := Proper_Spec (G, Vertex);
-- The vertex is a spec subject to pragma Elaborate_Body. The
-- complementary vertex is the body.
elsif Is_Spec_With_Elaborate_Body (G, Vertex) then
Complement := Proper_Body (G, Vertex);
end if;
return Complement;
end Complementary_Vertex;
---------------
-- Component --
---------------
function Component
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Component_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return DG.Component (G.Graph, Vertex);
end Component;
---------------------------------
-- Contains_Elaborate_All_Edge --
---------------------------------
function Contains_Elaborate_All_Edge
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return
At_Least_One_Edge_Satisfies
(G => G,
Cycle => Cycle,
Predicate => Is_Elaborate_All_Edge'Access);
end Contains_Elaborate_All_Edge;
------------------------------------
-- Contains_Static_Successor_Edge --
------------------------------------
function Contains_Static_Successor_Edge
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return
At_Least_One_Edge_Satisfies
(G => G,
Cycle => Cycle,
Predicate => Is_Static_Successor_Edge'Access);
end Contains_Static_Successor_Edge;
------------------------------
-- Contains_Task_Activation --
------------------------------
function Contains_Task_Activation
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return
At_Least_One_Edge_Satisfies
(G => G,
Cycle => Cycle,
Predicate => Activates_Task'Access);
end Contains_Task_Activation;
---------------------
-- Copy_Cycle_Path --
---------------------
function Copy_Cycle_Path
(Cycle_Path : LGE_Lists.Doubly_Linked_List)
return LGE_Lists.Doubly_Linked_List
is
Edge : Library_Graph_Edge_Id;
Iter : LGE_Lists.Iterator;
Path : LGE_Lists.Doubly_Linked_List;
begin
pragma Assert (LGE_Lists.Present (Cycle_Path));
Path := LGE_Lists.Create;
Iter := LGE_Lists.Iterate (Cycle_Path);
while LGE_Lists.Has_Next (Iter) loop
LGE_Lists.Next (Iter, Edge);
LGE_Lists.Append (Path, Edge);
end loop;
return Path;
end Copy_Cycle_Path;
------------------------
-- Corresponding_Item --
------------------------
function Corresponding_Item
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Library_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Get_LGV_Attributes (G, Vertex).Corresponding_Item;
end Corresponding_Item;
--------------------------
-- Corresponding_Vertex --
--------------------------
function Corresponding_Vertex
(G : Library_Graph;
U_Id : Unit_Id) return Library_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (U_Id));
return Unit_Tables.Get (G.Unit_To_Vertex, U_Id);
end Corresponding_Vertex;
------------
-- Create --
------------
function Create
(Initial_Vertices : Positive;
Initial_Edges : Positive) return Library_Graph
is
G : constant Library_Graph := new Library_Graph_Attributes;
begin
G.Component_Attributes := Component_Tables.Create (Initial_Vertices);
G.Cycle_Attributes := LGC_Tables.Create (Initial_Vertices);
G.Cycles := LGC_Lists.Create;
G.Edge_Attributes := LGE_Tables.Create (Initial_Edges);
G.Graph :=
DG.Create
(Initial_Vertices => Initial_Vertices,
Initial_Edges => Initial_Edges);
G.Recorded_Edges := RE_Sets.Create (Initial_Edges);
G.Unit_To_Vertex := Unit_Tables.Create (Initial_Vertices);
G.Vertex_Attributes := LGV_Tables.Create (Initial_Vertices);
return G;
end Create;
------------------------
-- Cycle_End_Vertices --
------------------------
function Cycle_End_Vertices
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Elaborate_All_Active : Boolean) return LGV_Sets.Membership_Set
is
Complement : Library_Graph_Vertex_Id;
End_Vertices : LGV_Sets.Membership_Set := LGV_Sets.Nil;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
End_Vertices := LGV_Sets.Create (2);
-- The input vertex always terminates a cycle path
LGV_Sets.Insert (End_Vertices, Vertex);
-- Add the complementary vertex to the set of cycle terminating
-- vertices when either Elaborate_All is in effect, or the input
-- vertex is part of an Elaborat_Body pair.
if Elaborate_All_Active
or else Is_Vertex_With_Elaborate_Body (G, Vertex)
then
Complement :=
Complementary_Vertex
(G => G,
Vertex => Vertex,
Force_Complement => Elaborate_All_Active);
if Present (Complement) then
LGV_Sets.Insert (End_Vertices, Complement);
end if;
end if;
return End_Vertices;
end Cycle_End_Vertices;
-------------------
-- Cycle_Kind_Of --
-------------------
function Cycle_Kind_Of
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Cycle_Kind
is
pragma Assert (Present (G));
pragma Assert (Present (Edge));
begin
if Is_Cyclic_Elaborate_All_Edge (G, Edge) then
return Elaborate_All_Cycle;
elsif Is_Cyclic_Elaborate_Body_Edge (G, Edge) then
return Elaborate_Body_Cycle;
elsif Is_Cyclic_Elaborate_Edge (G, Edge) then
return Elaborate_Cycle;
elsif Is_Cyclic_Forced_Edge (G, Edge) then
return Forced_Cycle;
elsif Is_Cyclic_Invocation_Edge (G, Edge) then
return Invocation_Cycle;
else
return No_Cycle_Kind;
end if;
end Cycle_Kind_Of;
---------------------------
-- Cycle_Kind_Precedence --
---------------------------
function Cycle_Kind_Precedence
(Kind : Library_Graph_Cycle_Kind;
Compared_To : Library_Graph_Cycle_Kind) return Precedence_Kind
is
Comp_Pos : constant Integer :=
Library_Graph_Cycle_Kind'Pos (Compared_To);
Kind_Pos : constant Integer := Library_Graph_Cycle_Kind'Pos (Kind);
begin
-- A lower ordinal indicates a higher precedence
if Kind_Pos < Comp_Pos then
return Higher_Precedence;
elsif Kind_Pos > Comp_Pos then
return Lower_Precedence;
else
return Equal_Precedence;
end if;
end Cycle_Kind_Precedence;
---------------------------
-- Cycle_Path_Precedence --
---------------------------
function Cycle_Path_Precedence
(G : Library_Graph;
Path : LGE_Lists.Doubly_Linked_List;
Compared_To : LGE_Lists.Doubly_Linked_List) return Precedence_Kind
is
procedure Next_Available
(Iter : in out LGE_Lists.Iterator;
Edge : out Library_Graph_Edge_Id);
pragma Inline (Next_Available);
-- Obtain the next edge available through iterator Iter, or return
-- No_Library_Graph_Edge if the iterator has been exhausted.
--------------------
-- Next_Available --
--------------------
procedure Next_Available
(Iter : in out LGE_Lists.Iterator;
Edge : out Library_Graph_Edge_Id)
is
begin
-- Assume that the iterator has been exhausted
Edge := No_Library_Graph_Edge;
if LGE_Lists.Has_Next (Iter) then
LGE_Lists.Next (Iter, Edge);
end if;
end Next_Available;
-- Local variables
Comp_Edge : Library_Graph_Edge_Id;
Comp_Iter : LGE_Lists.Iterator;
Path_Edge : Library_Graph_Edge_Id;
Path_Iter : LGE_Lists.Iterator;
Prec : Precedence_Kind;
-- Start of processing for Cycle_Path_Precedence
begin
pragma Assert (Present (G));
pragma Assert (LGE_Lists.Present (Path));
pragma Assert (LGE_Lists.Present (Compared_To));
-- Assume that the paths have equal precedence
Prec := Equal_Precedence;
Comp_Iter := LGE_Lists.Iterate (Compared_To);
Path_Iter := LGE_Lists.Iterate (Path);
Next_Available (Comp_Iter, Comp_Edge);
Next_Available (Path_Iter, Path_Edge);
-- IMPORTANT:
--
-- * The iteration must run to completion in order to unlock the
-- edges of both paths.
while Present (Comp_Edge) or else Present (Path_Edge) loop
if Prec = Equal_Precedence
and then Present (Comp_Edge)
and then Present (Path_Edge)
then
Prec :=
Edge_Precedence
(G => G,
Edge => Path_Edge,
Compared_To => Comp_Edge);
end if;
Next_Available (Comp_Iter, Comp_Edge);
Next_Available (Path_Iter, Path_Edge);
end loop;
return Prec;
end Cycle_Path_Precedence;
----------------------
-- Cycle_Precedence --
----------------------
function Cycle_Precedence
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id;
Compared_To : Library_Graph_Cycle_Id) return Precedence_Kind
is
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
pragma Assert (Present (Compared_To));
Comp_Invs : constant Natural :=
Invocation_Edge_Count (G, Compared_To);
Comp_Len : constant Natural := Length (G, Compared_To);
Cycle_Invs : constant Natural := Invocation_Edge_Count (G, Cycle);
Cycle_Len : constant Natural := Length (G, Cycle);
Kind_Prec : constant Precedence_Kind :=
Cycle_Kind_Precedence
(Kind => Kind (G, Cycle),
Compared_To => Kind (G, Compared_To));
begin
-- Prefer a cycle with higher precedence based on its kind
if Kind_Prec = Higher_Precedence
or else
Kind_Prec = Lower_Precedence
then
return Kind_Prec;
-- Prefer a shorter cycle
elsif Cycle_Len < Comp_Len then
return Higher_Precedence;
elsif Cycle_Len > Comp_Len then
return Lower_Precedence;
-- Prefer a cycle wih fewer invocation edges
elsif Cycle_Invs < Comp_Invs then
return Higher_Precedence;
elsif Cycle_Invs > Comp_Invs then
return Lower_Precedence;
-- Prefer a cycle with a higher path precedence
else
return
Cycle_Path_Precedence
(G => G,
Path => Path (G, Cycle),
Compared_To => Path (G, Compared_To));
end if;
end Cycle_Precedence;
----------------------------------------
-- Decrement_Library_Graph_Edge_Count --
----------------------------------------
procedure Decrement_Library_Graph_Edge_Count
(G : Library_Graph;
Kind : Library_Graph_Edge_Kind)
is
pragma Assert (Present (G));
Count : Natural renames G.Counts (Kind);
begin
Count := Count - 1;
end Decrement_Library_Graph_Edge_Count;
------------------------------------
-- Decrement_Pending_Predecessors --
------------------------------------
procedure Decrement_Pending_Predecessors
(G : Library_Graph;
Comp : Component_Id;
Edge : Library_Graph_Edge_Id)
is
Attrs : Component_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
Attrs := Get_Component_Attributes (G, Comp);
Update_Pending_Predecessors
(Strong_Predecessors => Attrs.Pending_Strong_Predecessors,
Weak_Predecessors => Attrs.Pending_Weak_Predecessors,
Update_Weak => Is_Invocation_Edge (G, Edge),
Value => -1);
Set_Component_Attributes (G, Comp, Attrs);
end Decrement_Pending_Predecessors;
------------------------------------
-- Decrement_Pending_Predecessors --
------------------------------------
procedure Decrement_Pending_Predecessors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Edge : Library_Graph_Edge_Id)
is
Attrs : Library_Graph_Vertex_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
Attrs := Get_LGV_Attributes (G, Vertex);
Update_Pending_Predecessors
(Strong_Predecessors => Attrs.Pending_Strong_Predecessors,
Weak_Predecessors => Attrs.Pending_Weak_Predecessors,
Update_Weak => Is_Invocation_Edge (G, Edge),
Value => -1);
Set_LGV_Attributes (G, Vertex, Attrs);
end Decrement_Pending_Predecessors;
-----------------------------------
-- Delete_Body_Before_Spec_Edges --
-----------------------------------
procedure Delete_Body_Before_Spec_Edges
(G : Library_Graph;
Edges : LGE_Lists.Doubly_Linked_List)
is
Edge : Library_Graph_Edge_Id;
Iter : LGE_Lists.Iterator;
begin
pragma Assert (Present (G));
pragma Assert (LGE_Lists.Present (Edges));
Iter := LGE_Lists.Iterate (Edges);
while LGE_Lists.Has_Next (Iter) loop
LGE_Lists.Next (Iter, Edge);
pragma Assert (Kind (G, Edge) = Body_Before_Spec_Edge);
Delete_Edge (G, Edge);
end loop;
end Delete_Body_Before_Spec_Edges;
-----------------
-- Delete_Edge --
-----------------
procedure Delete_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id)
is
pragma Assert (Present (G));
pragma Assert (Present (Edge));
Pred : constant Library_Graph_Vertex_Id := Predecessor (G, Edge);
Succ : constant Library_Graph_Vertex_Id := Successor (G, Edge);
Rel : constant Predecessor_Successor_Relation :=
(Predecessor => Pred,
Successor => Succ);
begin
-- Update the edge statistics
Decrement_Library_Graph_Edge_Count (G, Kind (G, Edge));
-- Update the number of pending predecessors the successor must wait
-- on before it is elaborated.
Decrement_Pending_Predecessors
(G => G,
Vertex => Succ,
Edge => Edge);
-- Delete the link between the predecessor and successor. This allows
-- for further attempts to link the same predecessor and successor.
RE_Sets.Delete (G.Recorded_Edges, Rel);
-- Delete the attributes of the edge
LGE_Tables.Delete (G.Edge_Attributes, Edge);
-- Delete the edge from the underlying graph
DG.Delete_Edge (G.Graph, Edge);
end Delete_Edge;
-------------
-- Destroy --
-------------
procedure Destroy (G : in out Library_Graph) is
begin
pragma Assert (Present (G));
Component_Tables.Destroy (G.Component_Attributes);
LGC_Tables.Destroy (G.Cycle_Attributes);
LGC_Lists.Destroy (G.Cycles);
LGE_Tables.Destroy (G.Edge_Attributes);
DG.Destroy (G.Graph);
RE_Sets.Destroy (G.Recorded_Edges);
Unit_Tables.Destroy (G.Unit_To_Vertex);
LGV_Tables.Destroy (G.Vertex_Attributes);
Free (G);
end Destroy;
----------------------------------
-- Destroy_Component_Attributes --
----------------------------------
procedure Destroy_Component_Attributes
(Attrs : in out Component_Attributes)
is
pragma Unreferenced (Attrs);
begin
null;
end Destroy_Component_Attributes;
--------------------------------------------
-- Destroy_Library_Graph_Cycle_Attributes --
--------------------------------------------
procedure Destroy_Library_Graph_Cycle_Attributes
(Attrs : in out Library_Graph_Cycle_Attributes)
is
begin
LGE_Lists.Destroy (Attrs.Path);
end Destroy_Library_Graph_Cycle_Attributes;
-------------------------------------------
-- Destroy_Library_Graph_Edge_Attributes --
-------------------------------------------
procedure Destroy_Library_Graph_Edge_Attributes
(Attrs : in out Library_Graph_Edge_Attributes)
is
pragma Unreferenced (Attrs);
begin
null;
end Destroy_Library_Graph_Edge_Attributes;
---------------------------------------------
-- Destroy_Library_Graph_Vertex_Attributes --
---------------------------------------------
procedure Destroy_Library_Graph_Vertex_Attributes
(Attrs : in out Library_Graph_Vertex_Attributes)
is
pragma Unreferenced (Attrs);
begin
null;
end Destroy_Library_Graph_Vertex_Attributes;
---------------------
-- Edge_Precedence --
---------------------
function Edge_Precedence
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
Compared_To : Library_Graph_Edge_Id) return Precedence_Kind
is
pragma Assert (Present (G));
pragma Assert (Present (Edge));
pragma Assert (Present (Compared_To));
Comp_Succ : constant Library_Graph_Vertex_Id :=
Successor (G, Compared_To);
Edge_Succ : constant Library_Graph_Vertex_Id :=
Successor (G, Edge);
Kind_Prec : constant Precedence_Kind :=
Cycle_Kind_Precedence
(Kind => Cycle_Kind_Of (G, Edge),
Compared_To => Cycle_Kind_Of (G, Compared_To));
Succ_Prec : constant Precedence_Kind :=
Vertex_Precedence
(G => G,
Vertex => Edge_Succ,
Compared_To => Comp_Succ);
begin
-- Prefer an edge with a higher cycle kind precedence
if Kind_Prec = Higher_Precedence
or else
Kind_Prec = Lower_Precedence
then
return Kind_Prec;
-- Prefer an edge whose successor has a higher precedence
elsif Comp_Succ /= Edge_Succ
and then (Succ_Prec = Higher_Precedence
or else
Succ_Prec = Lower_Precedence)
then
return Succ_Prec;
-- Prefer an edge whose predecessor has a higher precedence
else
return
Vertex_Precedence
(G => G,
Vertex => Predecessor (G, Edge),
Compared_To => Predecessor (G, Compared_To));
end if;
end Edge_Precedence;
---------------
-- File_Name --
---------------
function File_Name
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return File_Name_Type
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return File_Name (Unit (G, Vertex));
end File_Name;
---------------------
-- Find_Components --
---------------------
procedure Find_Components (G : Library_Graph) is
Edges : LGE_Lists.Doubly_Linked_List;
begin
pragma Assert (Present (G));
Start_Phase (Component_Discovery);
-- Initialize or reinitialize the components of the graph
Initialize_Components (G);
-- Create a set of special edges that link a predecessor body with a
-- successor spec. This is an illegal dependency, however using such
-- edges eliminates the need to create yet another graph, where both
-- spec and body are collapsed into a single vertex.
Edges := LGE_Lists.Create;
Add_Body_Before_Spec_Edges (G, Edges);
DG.Find_Components (G.Graph);
-- Remove the special edges that link a predecessor body with a
-- successor spec because they cause unresolvable circularities.
Delete_Body_Before_Spec_Edges (G, Edges);
LGE_Lists.Destroy (Edges);
-- Update the number of predecessors various components must wait on
-- before they can be elaborated.
Update_Pending_Predecessors_Of_Components (G);
End_Phase (Component_Discovery);
end Find_Components;
-----------------
-- Find_Cycles --
-----------------
procedure Find_Cycles (G : Library_Graph) is
All_Cycle_Limit : constant Natural := 64;
-- The performance of Tarjan's algorithm may degrate to exponential
-- when pragma Elaborate_All is in effect, or some vertex is part of
-- an Elaborate_Body pair. In this case the algorithm discovers all
-- combinations of edges that close a circuit starting and ending on
-- some start vertex while going through different vertices. Use a
-- limit on the total number of cycles within a component to guard
-- against such degradation.
Comp : Component_Id;
Cycle_Count : Natural;
Iter : Component_Iterator;
begin
pragma Assert (Present (G));
Start_Phase (Cycle_Discovery);
-- The cycles of graph G are discovered using Tarjan's enumeration
-- of the elementary circuits of a directed-graph algorithm. Do not
-- modify this code unless you intimately understand the algorithm.
--
-- The logic of the algorithm is split among the following routines:
--
-- Cycle_End_Vertices
-- Find_Cycles_From_Successor
-- Find_Cycles_From_Vertex
-- Find_Cycles_In_Component
-- Unvisit
-- Visit
--
-- The original algorithm has been significantly modified in order to
--
-- * Accommodate the semantics of Elaborate_All and Elaborate_Body.
--
-- * Capture cycle paths as edges rather than vertices.
--
-- * Take advantage of graph components.
-- Assume that the graph does not contain a cycle
Cycle_Count := 0;
-- Run the modified version of the algorithm on each component of the
-- graph.
Iter := Iterate_Components (G);
while Has_Next (Iter) loop
Next (Iter, Comp);
Find_Cycles_In_Component
(G => G,
Comp => Comp,
Cycle_Count => Cycle_Count,
Cycle_Limit => All_Cycle_Limit);
end loop;
End_Phase (Cycle_Discovery);
end Find_Cycles;
--------------------------------
-- Find_Cycles_From_Successor --
--------------------------------
procedure Find_Cycles_From_Successor
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
End_Vertices : LGV_Sets.Membership_Set;
Deleted_Vertices : LGV_Sets.Membership_Set;
Most_Significant_Edge : Library_Graph_Edge_Id;
Invocation_Edge_Count : Natural;
Cycle_Path_Stack : LGE_Lists.Doubly_Linked_List;
Visited_Set : LGV_Sets.Membership_Set;
Visited_Stack : LGV_Lists.Doubly_Linked_List;
Cycle_Count : in out Natural;
Cycle_Limit : Natural;
Elaborate_All_Active : Boolean;
Has_Cycle : out Boolean;
Indent : Indentation_Level)
is
pragma Assert (Present (G));
pragma Assert (Present (Edge));
pragma Assert (LGV_Sets.Present (End_Vertices));
pragma Assert (LGV_Sets.Present (Deleted_Vertices));
pragma Assert (LGE_Lists.Present (Cycle_Path_Stack));
pragma Assert (LGV_Sets.Present (Visited_Set));
pragma Assert (LGV_Lists.Present (Visited_Stack));
Succ : constant Library_Graph_Vertex_Id := Successor (G, Edge);
Succ_Indent : constant Indentation_Level :=
Indent + Nested_Indentation;
begin
-- Assume that the successor reached via the edge does not result in
-- a cycle.
Has_Cycle := False;
-- Nothing to do when the edge connects two vertices residing in two
-- different components.
if not Is_Cyclic_Edge (G, Edge) then
return;
end if;
Trace_Edge (G, Edge, Indent);
-- The modified version does not place vertices on the "point stack",
-- but instead collects the edges comprising the cycle. Prepare the
-- edge for backtracking.
LGE_Lists.Prepend (Cycle_Path_Stack, Edge);
Find_Cycles_From_Vertex
(G => G,
Vertex => Succ,
End_Vertices => End_Vertices,
Deleted_Vertices => Deleted_Vertices,
Most_Significant_Edge => Most_Significant_Edge,
Invocation_Edge_Count => Invocation_Edge_Count,
Cycle_Path_Stack => Cycle_Path_Stack,
Visited_Set => Visited_Set,
Visited_Stack => Visited_Stack,
Cycle_Count => Cycle_Count,
Cycle_Limit => Cycle_Limit,
Elaborate_All_Active => Elaborate_All_Active,
Is_Start_Vertex => False,
Has_Cycle => Has_Cycle,
Indent => Succ_Indent);
-- The modified version does not place vertices on the "point stack",
-- but instead collects the edges comprising the cycle. Backtrack the
-- edge.
LGE_Lists.Delete_First (Cycle_Path_Stack);
end Find_Cycles_From_Successor;
-----------------------------
-- Find_Cycles_From_Vertex --
-----------------------------
procedure Find_Cycles_From_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
End_Vertices : LGV_Sets.Membership_Set;
Deleted_Vertices : LGV_Sets.Membership_Set;
Most_Significant_Edge : Library_Graph_Edge_Id;
Invocation_Edge_Count : Natural;
Cycle_Path_Stack : LGE_Lists.Doubly_Linked_List;
Visited_Set : LGV_Sets.Membership_Set;
Visited_Stack : LGV_Lists.Doubly_Linked_List;
Cycle_Count : in out Natural;
Cycle_Limit : Natural;
Elaborate_All_Active : Boolean;
Is_Start_Vertex : Boolean;
Has_Cycle : out Boolean;
Indent : Indentation_Level)
is
Edge_Indent : constant Indentation_Level :=
Indent + Nested_Indentation;
Complement : Library_Graph_Vertex_Id;
Edge : Library_Graph_Edge_Id;
Iter : Edges_To_Successors_Iterator;
Complement_Has_Cycle : Boolean;
-- This flag is set when either Elaborate_All is in effect or the
-- current vertex is part of an Elaborate_Body pair, and visiting
-- the "complementary" vertex resulted in a cycle.
Successor_Has_Cycle : Boolean;
-- This flag is set when visiting at least one successor of the
-- current vertex resulted in a cycle.
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
pragma Assert (LGV_Sets.Present (End_Vertices));
pragma Assert (LGV_Sets.Present (Deleted_Vertices));
pragma Assert (LGE_Lists.Present (Cycle_Path_Stack));
pragma Assert (LGV_Sets.Present (Visited_Set));
pragma Assert (LGV_Lists.Present (Visited_Stack));
-- Assume that the vertex does not close a circuit
Has_Cycle := False;
-- Nothing to do when the limit on the number of saved cycles has
-- been reached. This protects against a combinatorial explosion
-- in components with Elaborate_All cycles.
if Cycle_Count >= Cycle_Limit then
return;
-- The vertex closes the circuit, thus resulting in a cycle. Save
-- the cycle for later diagnostics. The initial invocation of the
-- routine always ignores the starting vertex, to prevent a spurious
-- self-cycle.
elsif not Is_Start_Vertex
and then LGV_Sets.Contains (End_Vertices, Vertex)
then
Trace_Vertex (G, Vertex, Indent);
Record_Cycle
(G => G,
Most_Significant_Edge => Most_Significant_Edge,
Invocation_Edge_Count => Invocation_Edge_Count,
Cycle_Path => Cycle_Path_Stack,
Indent => Indent);
Has_Cycle := True;
Cycle_Count := Cycle_Count + 1;
return;
-- Nothing to do when the vertex has already been deleted. This
-- indicates that all available cycles involving the vertex have
-- been discovered, and the vertex cannot contribute further to
-- the depth-first search.
elsif LGV_Sets.Contains (Deleted_Vertices, Vertex) then
return;
-- Nothing to do when the vertex has already been visited. This
-- indicates that the depth-first search initiated from some start
-- vertex already encountered this vertex, and the visited stack has
-- not been unrolled yet.
elsif LGV_Sets.Contains (Visited_Set, Vertex) then
return;
end if;
Trace_Vertex (G, Vertex, Indent);
-- Mark the vertex as visited
Visit
(Vertex => Vertex,
Visited_Set => Visited_Set,
Visited_Stack => Visited_Stack);
-- Extend the depth-first search via all the edges to successors
Iter := Iterate_Edges_To_Successors (G, Vertex);
while Has_Next (Iter) loop
Next (Iter, Edge);
Find_Cycles_From_Successor
(G => G,
Edge => Edge,
End_Vertices => End_Vertices,
Deleted_Vertices => Deleted_Vertices,
-- The edge may be more important than the most important edge
-- up to this point, thus "upgrading" the nature of the cycle,
-- and shifting its point of normalization.
Most_Significant_Edge =>
Highest_Precedence_Edge
(G => G,
Left => Edge,
Right => Most_Significant_Edge),
-- The edge may be an invocation edge, in which case the count
-- of invocation edges increases by one.
Invocation_Edge_Count =>
Maximum_Invocation_Edge_Count
(G => G,
Edge => Edge,
Count => Invocation_Edge_Count),
Cycle_Path_Stack => Cycle_Path_Stack,
Visited_Set => Visited_Set,
Visited_Stack => Visited_Stack,
Cycle_Count => Cycle_Count,
Cycle_Limit => Cycle_Limit,
Elaborate_All_Active => Elaborate_All_Active,
Has_Cycle => Successor_Has_Cycle,
Indent => Edge_Indent);
Has_Cycle := Has_Cycle or Successor_Has_Cycle;
end loop;
-- Visit the complementary vertex of the current vertex when pragma
-- Elaborate_All is in effect, or the current vertex is part of an
-- Elaborate_Body pair.
if Elaborate_All_Active
or else Is_Vertex_With_Elaborate_Body (G, Vertex)
then
Complement :=
Complementary_Vertex
(G => G,
Vertex => Vertex,
Force_Complement => Elaborate_All_Active);
if Present (Complement) then
Find_Cycles_From_Vertex
(G => G,
Vertex => Complement,
End_Vertices => End_Vertices,
Deleted_Vertices => Deleted_Vertices,
Most_Significant_Edge => Most_Significant_Edge,
Invocation_Edge_Count => Invocation_Edge_Count,
Cycle_Path_Stack => Cycle_Path_Stack,
Visited_Set => Visited_Set,
Visited_Stack => Visited_Stack,
Cycle_Count => Cycle_Count,
Cycle_Limit => Cycle_Limit,
Elaborate_All_Active => Elaborate_All_Active,
Is_Start_Vertex => Is_Start_Vertex,
Has_Cycle => Complement_Has_Cycle,
Indent => Indent);
Has_Cycle := Has_Cycle or Complement_Has_Cycle;
end if;
end if;
-- The original algorithm clears the "marked stack" in two places:
--
-- * When the depth-first search starting from the current vertex
-- discovers at least one cycle, and
--
-- * When the depth-first search initiated from a start vertex
-- completes.
--
-- The modified version handles both cases in one place.
if Has_Cycle or else Is_Start_Vertex then
Unvisit
(Vertex => Vertex,
Visited_Set => Visited_Set,
Visited_Stack => Visited_Stack);
end if;
-- Delete a start vertex from the graph once its depth-first search
-- completes. This action preserves the invariant where a cycle is
-- not rediscovered "later" in some permuted form.
if Is_Start_Vertex then
LGV_Sets.Insert (Deleted_Vertices, Vertex);
end if;
end Find_Cycles_From_Vertex;
------------------------------
-- Find_Cycles_In_Component --
------------------------------
procedure Find_Cycles_In_Component
(G : Library_Graph;
Comp : Component_Id;
Cycle_Count : in out Natural;
Cycle_Limit : Natural)
is
pragma Assert (Present (G));
pragma Assert (Present (Comp));
Num_Of_Vertices : constant Natural :=
Number_Of_Component_Vertices (G, Comp);
Elaborate_All_Active : constant Boolean :=
Has_Elaborate_All_Edge (G, Comp);
-- The presence of an Elaborate_All edge within a component causes
-- all spec-body pairs to be treated as one vertex.
Has_Cycle : Boolean;
Iter : Component_Vertex_Iterator;
Vertex : Library_Graph_Vertex_Id;
Cycle_Path_Stack : LGE_Lists.Doubly_Linked_List := LGE_Lists.Nil;
-- The "point stack" of Tarjan's algorithm. The original maintains
-- a stack of vertices, however for diagnostic purposes using edges
-- is preferable.
Deleted_Vertices : LGV_Sets.Membership_Set := LGV_Sets.Nil;
-- The original algorithm alters the graph by deleting vertices with
-- lower ordinals compared to some starting vertex. Since the graph
-- must remain intact for diagnostic purposes, vertices are instead
-- inserted in this set and treated as "deleted".
End_Vertices : LGV_Sets.Membership_Set := LGV_Sets.Nil;
-- The original algorithm uses a single vertex to indicate the start
-- and end vertex of a cycle. The semantics of pragmas Elaborate_All
-- and Elaborate_Body increase this number by one. The end vertices
-- are added to this set and treated as "cycle-terminating".
Visited_Set : LGV_Sets.Membership_Set := LGV_Sets.Nil;
-- The "mark" array of Tarjan's algorithm. Since the original visits
-- all vertices in increasing ordinal number 1 .. N, the array offers
-- a one-to-one mapping between a vertex and its "marked" state. The
-- modified version however visits vertices within components, where
-- their ordinals are not contiguous. Vertices are added to this set
-- and treated as "marked".
Visited_Stack : LGV_Lists.Doubly_Linked_List := LGV_Lists.Nil;
-- The "marked stack" of Tarjan's algorithm
begin
Trace_Component (G, Comp, No_Indentation);
-- Initialize all component-level data structures
Cycle_Path_Stack := LGE_Lists.Create;
Deleted_Vertices := LGV_Sets.Create (Num_Of_Vertices);
Visited_Set := LGV_Sets.Create (Num_Of_Vertices);
Visited_Stack := LGV_Lists.Create;
-- The modified version does not use ordinals to visit vertices in
-- 1 .. N fashion. To preserve the invariant of the original, this
-- version deletes a vertex after its depth-first search completes.
-- The timing of the deletion is sound because all cycles through
-- that vertex have already been discovered, thus the vertex cannot
-- contribute to any cycles discovered "later" in the algorithm.
Iter := Iterate_Component_Vertices (G, Comp);
while Has_Next (Iter) loop
Next (Iter, Vertex);
-- Construct the set of vertices (at most 2) that terminates a
-- potential cycle that starts from the current vertex.
End_Vertices :=
Cycle_End_Vertices
(G => G,
Vertex => Vertex,
Elaborate_All_Active => Elaborate_All_Active);
-- The modified version maintains two additional attributes while
-- performing the depth-first search:
--
-- * The most significant edge of the current potential cycle.
--
-- * The number of invocation edges encountered along the path
-- of the current potential cycle.
--
-- Both attributes are used in the heuristic that determines the
-- importance of cycles.
Find_Cycles_From_Vertex
(G => G,
Vertex => Vertex,
End_Vertices => End_Vertices,
Deleted_Vertices => Deleted_Vertices,
Most_Significant_Edge => No_Library_Graph_Edge,
Invocation_Edge_Count => 0,
Cycle_Path_Stack => Cycle_Path_Stack,
Visited_Set => Visited_Set,
Visited_Stack => Visited_Stack,
Cycle_Count => Cycle_Count,
Cycle_Limit => Cycle_Limit,
Elaborate_All_Active => Elaborate_All_Active,
Is_Start_Vertex => True,
Has_Cycle => Has_Cycle,
Indent => Nested_Indentation);
-- Destroy the cycle-terminating vertices because a new set must
-- be constructed for the next vertex.
LGV_Sets.Destroy (End_Vertices);
end loop;
-- Destroy all component-level data structures
LGE_Lists.Destroy (Cycle_Path_Stack);
LGV_Sets.Destroy (Deleted_Vertices);
LGV_Sets.Destroy (Visited_Set);
LGV_Lists.Destroy (Visited_Stack);
end Find_Cycles_In_Component;
---------------
-- Find_Edge --
---------------
function Find_Edge
(G : Library_Graph;
Pred : Library_Graph_Vertex_Id;
Succ : Library_Graph_Vertex_Id) return Library_Graph_Edge_Id
is
Result : Library_Graph_Edge_Id := No_Library_Graph_Edge;
Edge : Library_Graph_Edge_Id;
Iter : Edges_To_Successors_Iterator :=
Iterate_Edges_To_Successors (G, Pred);
begin
-- IMPORTANT:
--
-- * The iteration must run to completion in order to unlock the
-- edges to successors.
-- This does a linear search through the successors of Pred.
-- Efficiency is not a problem, because this is called only when
-- Activates_Task is True, which is rare, and anyway, there aren't
-- usually large numbers of successors.
while Has_Next (Iter) loop
Next (Iter, Edge);
if Succ = Successor (G, Edge) then
pragma Assert (not Present (Result));
Result := Edge;
end if;
end loop;
pragma Assert (Present (Result));
return Result;
end Find_Edge;
---------------------------------------
-- Find_First_Lower_Precedence_Cycle --
---------------------------------------
function Find_First_Lower_Precedence_Cycle
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Library_Graph_Cycle_Id
is
Current_Cycle : Library_Graph_Cycle_Id;
Iter : All_Cycle_Iterator;
Lesser_Cycle : Library_Graph_Cycle_Id;
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
-- Assume that there is no lesser cycle
Lesser_Cycle := No_Library_Graph_Cycle;
-- Find a cycle with a slightly lower precedence than the input
-- cycle.
--
-- IMPORTANT:
--
-- * The iterator must run to completion in order to unlock the
-- list of all cycles.
Iter := Iterate_All_Cycles (G);
while Has_Next (Iter) loop
Next (Iter, Current_Cycle);
if not Present (Lesser_Cycle)
and then Cycle_Precedence
(G => G,
Cycle => Cycle,
Compared_To => Current_Cycle) = Higher_Precedence
then
Lesser_Cycle := Current_Cycle;
end if;
end loop;
return Lesser_Cycle;
end Find_First_Lower_Precedence_Cycle;
------------------------------
-- Get_Component_Attributes --
------------------------------
function Get_Component_Attributes
(G : Library_Graph;
Comp : Component_Id) return Component_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
return Component_Tables.Get (G.Component_Attributes, Comp);
end Get_Component_Attributes;
------------------------
-- Get_LGC_Attributes --
------------------------
function Get_LGC_Attributes
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Library_Graph_Cycle_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return LGC_Tables.Get (G.Cycle_Attributes, Cycle);
end Get_LGC_Attributes;
------------------------
-- Get_LGE_Attributes --
------------------------
function Get_LGE_Attributes
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Edge_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return LGE_Tables.Get (G.Edge_Attributes, Edge);
end Get_LGE_Attributes;
------------------------
-- Get_LGV_Attributes --
------------------------
function Get_LGV_Attributes
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id)
return Library_Graph_Vertex_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return LGV_Tables.Get (G.Vertex_Attributes, Vertex);
end Get_LGV_Attributes;
-----------------------------
-- Has_Elaborate_All_Cycle --
-----------------------------
function Has_Elaborate_All_Cycle (G : Library_Graph) return Boolean is
Edge : Library_Graph_Edge_Id;
Iter : All_Edge_Iterator;
Seen : Boolean;
begin
pragma Assert (Present (G));
-- Assume that no cyclic Elaborate_All edge has been seen
Seen := False;
-- IMPORTANT:
--
-- * The iteration must run to completion in order to unlock the
-- graph.
Iter := Iterate_All_Edges (G);
while Has_Next (Iter) loop
Next (Iter, Edge);
if not Seen and then Is_Cyclic_Elaborate_All_Edge (G, Edge) then
Seen := True;
end if;
end loop;
return Seen;
end Has_Elaborate_All_Cycle;
----------------------------
-- Has_Elaborate_All_Edge --
----------------------------
function Has_Elaborate_All_Edge
(G : Library_Graph;
Comp : Component_Id) return Boolean
is
Has_Edge : Boolean;
Iter : Component_Vertex_Iterator;
Vertex : Library_Graph_Vertex_Id;
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
-- Assume that there is no Elaborate_All edge
Has_Edge := False;
-- IMPORTANT:
--
-- * The iteration must run to completion in order to unlock the
-- component vertices.
Iter := Iterate_Component_Vertices (G, Comp);
while Has_Next (Iter) loop
Next (Iter, Vertex);
Has_Edge := Has_Edge or else Has_Elaborate_All_Edge (G, Vertex);
end loop;
return Has_Edge;
end Has_Elaborate_All_Edge;
----------------------------
-- Has_Elaborate_All_Edge --
----------------------------
function Has_Elaborate_All_Edge
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
Edge : Library_Graph_Edge_Id;
Has_Edge : Boolean;
Iter : Edges_To_Successors_Iterator;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
-- Assume that there is no Elaborate_All edge
Has_Edge := False;
-- IMPORTANT:
--
-- * The iteration must run to completion in order to unlock the
-- edges to successors.
Iter := Iterate_Edges_To_Successors (G, Vertex);
while Has_Next (Iter) loop
Next (Iter, Edge);
Has_Edge :=
Has_Edge or else Is_Cyclic_Elaborate_All_Edge (G, Edge);
end loop;
return Has_Edge;
end Has_Elaborate_All_Edge;
------------------------
-- Has_Elaborate_Body --
------------------------
function Has_Elaborate_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
U_Id : constant Unit_Id := Unit (G, Vertex);
U_Rec : Unit_Record renames ALI.Units.Table (U_Id);
begin
-- Treat the spec and body as decoupled when switch -d_b (ignore the
-- effects of pragma Elaborate_Body) is in effect.
return U_Rec.Elaborate_Body and not Debug_Flag_Underscore_B;
end Has_Elaborate_Body;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : All_Cycle_Iterator) return Boolean is
begin
return LGC_Lists.Has_Next (LGC_Lists.Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : All_Edge_Iterator) return Boolean is
begin
return DG.Has_Next (DG.All_Edge_Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : All_Vertex_Iterator) return Boolean is
begin
return DG.Has_Next (DG.All_Vertex_Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Component_Iterator) return Boolean is
begin
return DG.Has_Next (DG.Component_Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Component_Vertex_Iterator) return Boolean is
begin
return DG.Has_Next (DG.Component_Vertex_Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Edges_Of_Cycle_Iterator) return Boolean is
begin
return LGE_Lists.Has_Next (LGE_Lists.Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Edges_To_Successors_Iterator) return Boolean is
begin
return DG.Has_Next (DG.Outgoing_Edge_Iterator (Iter));
end Has_Next;
-----------------------------
-- Has_No_Elaboration_Code --
-----------------------------
function Has_No_Elaboration_Code
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Has_No_Elaboration_Code (Unit (G, Vertex));
end Has_No_Elaboration_Code;
-----------------------------------------
-- Hash_Library_Graph_Cycle_Attributes --
-----------------------------------------
function Hash_Library_Graph_Cycle_Attributes
(Attrs : Library_Graph_Cycle_Attributes) return Bucket_Range_Type
is
Edge : Library_Graph_Edge_Id;
Hash : Bucket_Range_Type;
Iter : LGE_Lists.Iterator;
begin
pragma Assert (LGE_Lists.Present (Attrs.Path));
-- The hash is obtained in the following manner:
--
-- (((edge1 * 31) + edge2) * 31) + edgeN
Hash := 0;
Iter := LGE_Lists.Iterate (Attrs.Path);
while LGE_Lists.Has_Next (Iter) loop
LGE_Lists.Next (Iter, Edge);
Hash := (Hash * 31) + Bucket_Range_Type (Edge);
end loop;
return Hash;
end Hash_Library_Graph_Cycle_Attributes;
-----------------------------------------
-- Hash_Predecessor_Successor_Relation --
-----------------------------------------
function Hash_Predecessor_Successor_Relation
(Rel : Predecessor_Successor_Relation) return Bucket_Range_Type
is
begin
pragma Assert (Present (Rel.Predecessor));
pragma Assert (Present (Rel.Successor));
return
Hash_Two_Keys
(Bucket_Range_Type (Rel.Predecessor),
Bucket_Range_Type (Rel.Successor));
end Hash_Predecessor_Successor_Relation;
------------------------------
-- Highest_Precedence_Cycle --
------------------------------
function Highest_Precedence_Cycle
(G : Library_Graph) return Library_Graph_Cycle_Id
is
begin
pragma Assert (Present (G));
pragma Assert (LGC_Lists.Present (G.Cycles));
if LGC_Lists.Is_Empty (G.Cycles) then
return No_Library_Graph_Cycle;
-- The highest precedence cycle is always the first in the list of
-- all cycles.
else
return LGC_Lists.First (G.Cycles);
end if;
end Highest_Precedence_Cycle;
-----------------------------
-- Highest_Precedence_Edge --
-----------------------------
function Highest_Precedence_Edge
(G : Library_Graph;
Left : Library_Graph_Edge_Id;
Right : Library_Graph_Edge_Id) return Library_Graph_Edge_Id
is
Edge_Prec : Precedence_Kind;
begin
pragma Assert (Present (G));
-- Both edges are available, pick the one with highest precedence
if Present (Left) and then Present (Right) then
Edge_Prec :=
Edge_Precedence
(G => G,
Edge => Left,
Compared_To => Right);
if Edge_Prec = Higher_Precedence then
return Left;
-- The precedence rules for edges are such that no two edges can
-- ever have the same precedence.
else
pragma Assert (Edge_Prec = Lower_Precedence);
return Right;
end if;
-- Otherwise at least one edge must be present
elsif Present (Left) then
return Left;
else
pragma Assert (Present (Right));
return Right;
end if;
end Highest_Precedence_Edge;
--------------------------
-- In_Elaboration_Order --
--------------------------
function In_Elaboration_Order
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Get_LGV_Attributes (G, Vertex).In_Elaboration_Order;
end In_Elaboration_Order;
-----------------------
-- In_Same_Component --
-----------------------
function In_Same_Component
(G : Library_Graph;
Left : Library_Graph_Vertex_Id;
Right : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Left));
pragma Assert (Present (Right));
return Component (G, Left) = Component (G, Right);
end In_Same_Component;
----------------------------------------
-- Increment_Library_Graph_Edge_Count --
----------------------------------------
procedure Increment_Library_Graph_Edge_Count
(G : Library_Graph;
Kind : Library_Graph_Edge_Kind)
is
pragma Assert (Present (G));
Count : Natural renames G.Counts (Kind);
begin
Count := Count + 1;
end Increment_Library_Graph_Edge_Count;
------------------------------------
-- Increment_Pending_Predecessors --
------------------------------------
procedure Increment_Pending_Predecessors
(G : Library_Graph;
Comp : Component_Id;
Edge : Library_Graph_Edge_Id)
is
Attrs : Component_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
Attrs := Get_Component_Attributes (G, Comp);
Update_Pending_Predecessors
(Strong_Predecessors => Attrs.Pending_Strong_Predecessors,
Weak_Predecessors => Attrs.Pending_Weak_Predecessors,
Update_Weak => Is_Invocation_Edge (G, Edge),
Value => 1);
Set_Component_Attributes (G, Comp, Attrs);
end Increment_Pending_Predecessors;
------------------------------------
-- Increment_Pending_Predecessors --
------------------------------------
procedure Increment_Pending_Predecessors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Edge : Library_Graph_Edge_Id)
is
Attrs : Library_Graph_Vertex_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
Attrs := Get_LGV_Attributes (G, Vertex);
Update_Pending_Predecessors
(Strong_Predecessors => Attrs.Pending_Strong_Predecessors,
Weak_Predecessors => Attrs.Pending_Weak_Predecessors,
Update_Weak => Is_Invocation_Edge (G, Edge),
Value => 1);
Set_LGV_Attributes (G, Vertex, Attrs);
end Increment_Pending_Predecessors;
---------------------------
-- Initialize_Components --
---------------------------
procedure Initialize_Components (G : Library_Graph) is
begin
pragma Assert (Present (G));
-- The graph already contains a set of components. Reinitialize
-- them in order to accommodate the new set of components about to
-- be computed.
if Number_Of_Components (G) > 0 then
Component_Tables.Destroy (G.Component_Attributes);
G.Component_Attributes :=
Component_Tables.Create (Number_Of_Vertices (G));
end if;
end Initialize_Components;
---------------------------
-- Invocation_Edge_Count --
---------------------------
function Invocation_Edge_Count
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Natural
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return Get_LGC_Attributes (G, Cycle).Invocation_Edge_Count;
end Invocation_Edge_Count;
-------------------------------
-- Invocation_Graph_Encoding --
-------------------------------
function Invocation_Graph_Encoding
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id)
return Invocation_Graph_Encoding_Kind
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Invocation_Graph_Encoding (Unit (G, Vertex));
end Invocation_Graph_Encoding;
-------------
-- Is_Body --
-------------
function Is_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
U_Id : constant Unit_Id := Unit (G, Vertex);
U_Rec : Unit_Record renames ALI.Units.Table (U_Id);
begin
return U_Rec.Utype = Is_Body or else U_Rec.Utype = Is_Body_Only;
end Is_Body;
-----------------------------------------
-- Is_Body_Of_Spec_With_Elaborate_Body --
-----------------------------------------
function Is_Body_Of_Spec_With_Elaborate_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
if Is_Body_With_Spec (G, Vertex) then
return
Is_Spec_With_Elaborate_Body
(G => G,
Vertex => Proper_Spec (G, Vertex));
end if;
return False;
end Is_Body_Of_Spec_With_Elaborate_Body;
-----------------------
-- Is_Body_With_Spec --
-----------------------
function Is_Body_With_Spec
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
U_Id : constant Unit_Id := Unit (G, Vertex);
U_Rec : Unit_Record renames ALI.Units.Table (U_Id);
begin
return U_Rec.Utype = Is_Body;
end Is_Body_With_Spec;
------------------------------
-- Is_Cycle_Initiating_Edge --
------------------------------
function Is_Cycle_Initiating_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Is_Cyclic_Elaborate_All_Edge (G, Edge)
or else Is_Cyclic_Elaborate_Body_Edge (G, Edge)
or else Is_Cyclic_Elaborate_Edge (G, Edge)
or else Is_Cyclic_Forced_Edge (G, Edge)
or else Is_Cyclic_Invocation_Edge (G, Edge);
end Is_Cycle_Initiating_Edge;
--------------------
-- Is_Cyclic_Edge --
--------------------
function Is_Cyclic_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Is_Cycle_Initiating_Edge (G, Edge)
or else Is_Cyclic_With_Edge (G, Edge);
end Is_Cyclic_Edge;
----------------------------------
-- Is_Cyclic_Elaborate_All_Edge --
----------------------------------
function Is_Cyclic_Elaborate_All_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Is_Elaborate_All_Edge (G, Edge)
and then Links_Vertices_In_Same_Component (G, Edge);
end Is_Cyclic_Elaborate_All_Edge;
-----------------------------------
-- Is_Cyclic_Elaborate_Body_Edge --
-----------------------------------
function Is_Cyclic_Elaborate_Body_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Is_Elaborate_Body_Edge (G, Edge)
and then Links_Vertices_In_Same_Component (G, Edge);
end Is_Cyclic_Elaborate_Body_Edge;
------------------------------
-- Is_Cyclic_Elaborate_Edge --
------------------------------
function Is_Cyclic_Elaborate_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Is_Elaborate_Edge (G, Edge)
and then Links_Vertices_In_Same_Component (G, Edge);
end Is_Cyclic_Elaborate_Edge;
---------------------------
-- Is_Cyclic_Forced_Edge --
---------------------------
function Is_Cyclic_Forced_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Is_Forced_Edge (G, Edge)
and then Links_Vertices_In_Same_Component (G, Edge);
end Is_Cyclic_Forced_Edge;
-------------------------------
-- Is_Cyclic_Invocation_Edge --
-------------------------------
function Is_Cyclic_Invocation_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Is_Invocation_Edge (G, Edge)
and then Links_Vertices_In_Same_Component (G, Edge);
end Is_Cyclic_Invocation_Edge;
-------------------------
-- Is_Cyclic_With_Edge --
-------------------------
function Is_Cyclic_With_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
-- Ignore Elaborate_Body edges because they also appear as with
-- edges, but have special successors.
return
Is_With_Edge (G, Edge)
and then Links_Vertices_In_Same_Component (G, Edge)
and then not Is_Elaborate_Body_Edge (G, Edge);
end Is_Cyclic_With_Edge;
-------------------------------
-- Is_Dynamically_Elaborated --
-------------------------------
function Is_Dynamically_Elaborated
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Is_Dynamically_Elaborated (Unit (G, Vertex));
end Is_Dynamically_Elaborated;
-----------------------------
-- Is_Elaborable_Component --
-----------------------------
function Is_Elaborable_Component
(G : Library_Graph;
Comp : Component_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
-- A component is elaborable when:
--
-- * It is not waiting on strong predecessors, and
-- * It is not waiting on weak predecessors
return
Pending_Strong_Predecessors (G, Comp) = 0
and then Pending_Weak_Predecessors (G, Comp) = 0;
end Is_Elaborable_Component;
--------------------------
-- Is_Elaborable_Vertex --
--------------------------
function Is_Elaborable_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
Complement : constant Library_Graph_Vertex_Id :=
Complementary_Vertex
(G => G,
Vertex => Vertex,
Force_Complement => False);
Strong_Preds : Natural;
Weak_Preds : Natural;
begin
-- A vertex is elaborable when:
--
-- * It has not been elaborated yet, and
-- * The complement vertex of an Elaborate_Body pair has not been
-- elaborated yet, and
-- * It resides within an elaborable component, and
-- * It is not waiting on strong predecessors, and
-- * It is not waiting on weak predecessors
if In_Elaboration_Order (G, Vertex) then
return False;
elsif Present (Complement)
and then In_Elaboration_Order (G, Complement)
then
return False;
elsif not Is_Elaborable_Component (G, Component (G, Vertex)) then
return False;
end if;
Pending_Predecessors_For_Elaboration
(G => G,
Vertex => Vertex,
Strong_Preds => Strong_Preds,
Weak_Preds => Weak_Preds);
return Strong_Preds = 0 and then Weak_Preds = 0;
end Is_Elaborable_Vertex;
---------------------------
-- Is_Elaborate_All_Edge --
---------------------------
function Is_Elaborate_All_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Kind (G, Edge) = Elaborate_All_Edge;
end Is_Elaborate_All_Edge;
----------------------------
-- Is_Elaborate_Body_Edge --
----------------------------
function Is_Elaborate_Body_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Kind (G, Edge) = With_Edge
and then Is_Vertex_With_Elaborate_Body (G, Successor (G, Edge));
end Is_Elaborate_Body_Edge;
-----------------------
-- Is_Elaborate_Edge --
-----------------------
function Is_Elaborate_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Kind (G, Edge) = Elaborate_Edge;
end Is_Elaborate_Edge;
----------------------------
-- Is_Elaborate_Body_Pair --
----------------------------
function Is_Elaborate_Body_Pair
(G : Library_Graph;
Spec_Vertex : Library_Graph_Vertex_Id;
Body_Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Spec_Vertex));
pragma Assert (Present (Body_Vertex));
return
Is_Spec_With_Elaborate_Body (G, Spec_Vertex)
and then Is_Body_Of_Spec_With_Elaborate_Body (G, Body_Vertex)
and then Proper_Body (G, Spec_Vertex) = Body_Vertex;
end Is_Elaborate_Body_Pair;
--------------------
-- Is_Forced_Edge --
--------------------
function Is_Forced_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Kind (G, Edge) = Forced_Edge;
end Is_Forced_Edge;
----------------------
-- Is_Internal_Unit --
----------------------
function Is_Internal_Unit
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Is_Internal_Unit (Unit (G, Vertex));
end Is_Internal_Unit;
------------------------
-- Is_Invocation_Edge --
------------------------
function Is_Invocation_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Kind (G, Edge) = Invocation_Edge;
end Is_Invocation_Edge;
------------------------
-- Is_Predefined_Unit --
------------------------
function Is_Predefined_Unit
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Is_Predefined_Unit (Unit (G, Vertex));
end Is_Predefined_Unit;
---------------------------
-- Is_Preelaborated_Unit --
---------------------------
function Is_Preelaborated_Unit
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
U_Id : constant Unit_Id := Unit (G, Vertex);
U_Rec : Unit_Record renames ALI.Units.Table (U_Id);
begin
return U_Rec.Preelab or else U_Rec.Pure;
end Is_Preelaborated_Unit;
----------------------
-- Is_Recorded_Edge --
----------------------
function Is_Recorded_Edge
(G : Library_Graph;
Rel : Predecessor_Successor_Relation) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Rel.Predecessor));
pragma Assert (Present (Rel.Successor));
return RE_Sets.Contains (G.Recorded_Edges, Rel);
end Is_Recorded_Edge;
-------------
-- Is_Spec --
-------------
function Is_Spec
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
U_Id : constant Unit_Id := Unit (G, Vertex);
U_Rec : Unit_Record renames ALI.Units.Table (U_Id);
begin
return U_Rec.Utype = Is_Spec or else U_Rec.Utype = Is_Spec_Only;
end Is_Spec;
------------------------------
-- Is_Spec_Before_Body_Edge --
------------------------------
function Is_Spec_Before_Body_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Kind (G, Edge) = Spec_Before_Body_Edge;
end Is_Spec_Before_Body_Edge;
-----------------------
-- Is_Spec_With_Body --
-----------------------
function Is_Spec_With_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
U_Id : constant Unit_Id := Unit (G, Vertex);
U_Rec : Unit_Record renames ALI.Units.Table (U_Id);
begin
return U_Rec.Utype = Is_Spec;
end Is_Spec_With_Body;
---------------------------------
-- Is_Spec_With_Elaborate_Body --
---------------------------------
function Is_Spec_With_Elaborate_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return
Is_Spec_With_Body (G, Vertex)
and then Has_Elaborate_Body (G, Vertex);
end Is_Spec_With_Elaborate_Body;
------------------------------
-- Is_Static_Successor_Edge --
------------------------------
function Is_Static_Successor_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return
Is_Invocation_Edge (G, Edge)
and then not Is_Dynamically_Elaborated (G, Successor (G, Edge));
end Is_Static_Successor_Edge;
-----------------------------------
-- Is_Vertex_With_Elaborate_Body --
-----------------------------------
function Is_Vertex_With_Elaborate_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return
Is_Spec_With_Elaborate_Body (G, Vertex)
or else
Is_Body_Of_Spec_With_Elaborate_Body (G, Vertex);
end Is_Vertex_With_Elaborate_Body;
---------------------------------
-- Is_Weakly_Elaborable_Vertex --
----------------------------------
function Is_Weakly_Elaborable_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
Complement : constant Library_Graph_Vertex_Id :=
Complementary_Vertex
(G => G,
Vertex => Vertex,
Force_Complement => False);
Strong_Preds : Natural;
Weak_Preds : Natural;
begin
-- A vertex is weakly elaborable when:
--
-- * It has not been elaborated yet, and
-- * The complement vertex of an Elaborate_Body pair has not been
-- elaborated yet, and
-- * It resides within an elaborable component, and
-- * It is not waiting on strong predecessors, and
-- * It is waiting on at least one weak predecessor
if In_Elaboration_Order (G, Vertex) then
return False;
elsif Present (Complement)
and then In_Elaboration_Order (G, Complement)
then
return False;
elsif not Is_Elaborable_Component (G, Component (G, Vertex)) then
return False;
end if;
Pending_Predecessors_For_Elaboration
(G => G,
Vertex => Vertex,
Strong_Preds => Strong_Preds,
Weak_Preds => Weak_Preds);
return Strong_Preds = 0 and then Weak_Preds >= 1;
end Is_Weakly_Elaborable_Vertex;
------------------
-- Is_With_Edge --
------------------
function Is_With_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Kind (G, Edge) = With_Edge;
end Is_With_Edge;
------------------------
-- Iterate_All_Cycles --
------------------------
function Iterate_All_Cycles
(G : Library_Graph) return All_Cycle_Iterator
is
begin
pragma Assert (Present (G));
return All_Cycle_Iterator (LGC_Lists.Iterate (G.Cycles));
end Iterate_All_Cycles;
-----------------------
-- Iterate_All_Edges --
-----------------------
function Iterate_All_Edges
(G : Library_Graph) return All_Edge_Iterator
is
begin
pragma Assert (Present (G));
return All_Edge_Iterator (DG.Iterate_All_Edges (G.Graph));
end Iterate_All_Edges;
--------------------------
-- Iterate_All_Vertices --
--------------------------
function Iterate_All_Vertices
(G : Library_Graph) return All_Vertex_Iterator
is
begin
pragma Assert (Present (G));
return All_Vertex_Iterator (DG.Iterate_All_Vertices (G.Graph));
end Iterate_All_Vertices;
------------------------
-- Iterate_Components --
------------------------
function Iterate_Components
(G : Library_Graph) return Component_Iterator
is
begin
pragma Assert (Present (G));
return Component_Iterator (DG.Iterate_Components (G.Graph));
end Iterate_Components;
--------------------------------
-- Iterate_Component_Vertices --
--------------------------------
function Iterate_Component_Vertices
(G : Library_Graph;
Comp : Component_Id) return Component_Vertex_Iterator
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
return
Component_Vertex_Iterator
(DG.Iterate_Component_Vertices (G.Graph, Comp));
end Iterate_Component_Vertices;
----------------------------
-- Iterate_Edges_Of_Cycle --
----------------------------
function Iterate_Edges_Of_Cycle
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Edges_Of_Cycle_Iterator
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return Edges_Of_Cycle_Iterator (LGE_Lists.Iterate (Path (G, Cycle)));
end Iterate_Edges_Of_Cycle;
---------------------------------
-- Iterate_Edges_To_Successors --
---------------------------------
function Iterate_Edges_To_Successors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Edges_To_Successors_Iterator
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return
Edges_To_Successors_Iterator
(DG.Iterate_Outgoing_Edges (G.Graph, Vertex));
end Iterate_Edges_To_Successors;
----------
-- Kind --
----------
function Kind
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Library_Graph_Cycle_Kind
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return Get_LGC_Attributes (G, Cycle).Kind;
end Kind;
----------
-- Kind --
----------
function Kind
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Edge_Kind
is
begin
return Get_LGE_Attributes (G, Edge).Kind;
end Kind;
------------
-- Length --
------------
function Length
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return Natural
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return LGE_Lists.Size (Path (G, Cycle));
end Length;
------------------------------
-- Library_Graph_Edge_Count --
------------------------------
function Library_Graph_Edge_Count
(G : Library_Graph;
Kind : Library_Graph_Edge_Kind) return Natural
is
begin
pragma Assert (Present (G));
return G.Counts (Kind);
end Library_Graph_Edge_Count;
--------------------------------------
-- Links_Vertices_In_Same_Component --
--------------------------------------
function Links_Vertices_In_Same_Component
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
-- An edge is part of a cycle when both the successor and predecessor
-- reside in the same component.
return
In_Same_Component
(G => G,
Left => Predecessor (G, Edge),
Right => Successor (G, Edge));
end Links_Vertices_In_Same_Component;
-----------------------------------
-- Maximum_Invocation_Edge_Count --
-----------------------------------
function Maximum_Invocation_Edge_Count
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
Count : Natural) return Natural
is
New_Count : Natural;
begin
pragma Assert (Present (G));
New_Count := Count;
if Present (Edge) and then Is_Invocation_Edge (G, Edge) then
New_Count := New_Count + 1;
end if;
return New_Count;
end Maximum_Invocation_Edge_Count;
----------
-- Name --
----------
function Name
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Unit_Name_Type
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Name (Unit (G, Vertex));
end Name;
-----------------------
-- Needs_Elaboration --
-----------------------
function Needs_Elaboration
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Needs_Elaboration (Unit (G, Vertex));
end Needs_Elaboration;
----------
-- Next --
----------
procedure Next
(Iter : in out All_Cycle_Iterator;
Cycle : out Library_Graph_Cycle_Id)
is
begin
LGC_Lists.Next (LGC_Lists.Iterator (Iter), Cycle);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out All_Edge_Iterator;
Edge : out Library_Graph_Edge_Id)
is
begin
DG.Next (DG.All_Edge_Iterator (Iter), Edge);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out All_Vertex_Iterator;
Vertex : out Library_Graph_Vertex_Id)
is
begin
DG.Next (DG.All_Vertex_Iterator (Iter), Vertex);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Edges_Of_Cycle_Iterator;
Edge : out Library_Graph_Edge_Id)
is
begin
LGE_Lists.Next (LGE_Lists.Iterator (Iter), Edge);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Component_Iterator;
Comp : out Component_Id)
is
begin
DG.Next (DG.Component_Iterator (Iter), Comp);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Edges_To_Successors_Iterator;
Edge : out Library_Graph_Edge_Id)
is
begin
DG.Next (DG.Outgoing_Edge_Iterator (Iter), Edge);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Component_Vertex_Iterator;
Vertex : out Library_Graph_Vertex_Id)
is
begin
DG.Next (DG.Component_Vertex_Iterator (Iter), Vertex);
end Next;
--------------------------
-- Normalize_Cycle_Path --
--------------------------
procedure Normalize_Cycle_Path
(Cycle_Path : LGE_Lists.Doubly_Linked_List;
Most_Significant_Edge : Library_Graph_Edge_Id)
is
Edge : Library_Graph_Edge_Id;
begin
pragma Assert (LGE_Lists.Present (Cycle_Path));
pragma Assert (Present (Most_Significant_Edge));
-- Perform at most |Cycle_Path| rotations in case the cycle is
-- malformed and the significant edge does not appear within.
for Rotation in 1 .. LGE_Lists.Size (Cycle_Path) loop
Edge := LGE_Lists.First (Cycle_Path);
-- The cycle is already rotated such that the most significant
-- edge is first.
if Edge = Most_Significant_Edge then
return;
-- Otherwise rotate the cycle by relocating the current edge from
-- the start to the end of the path. This preserves the order of
-- the path.
else
LGE_Lists.Delete_First (Cycle_Path);
LGE_Lists.Append (Cycle_Path, Edge);
end if;
end loop;
pragma Assert (False);
end Normalize_Cycle_Path;
----------------------------------
-- Number_Of_Component_Vertices --
----------------------------------
function Number_Of_Component_Vertices
(G : Library_Graph;
Comp : Component_Id) return Natural
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
return DG.Number_Of_Component_Vertices (G.Graph, Comp);
end Number_Of_Component_Vertices;
--------------------------
-- Number_Of_Components --
--------------------------
function Number_Of_Components (G : Library_Graph) return Natural is
begin
pragma Assert (Present (G));
return DG.Number_Of_Components (G.Graph);
end Number_Of_Components;
----------------------
-- Number_Of_Cycles --
----------------------
function Number_Of_Cycles (G : Library_Graph) return Natural is
begin
pragma Assert (Present (G));
return LGC_Lists.Size (G.Cycles);
end Number_Of_Cycles;
---------------------
-- Number_Of_Edges --
---------------------
function Number_Of_Edges (G : Library_Graph) return Natural is
begin
pragma Assert (Present (G));
return DG.Number_Of_Edges (G.Graph);
end Number_Of_Edges;
-----------------------------------
-- Number_Of_Edges_To_Successors --
-----------------------------------
function Number_Of_Edges_To_Successors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Natural
is
begin
pragma Assert (Present (G));
return DG.Number_Of_Outgoing_Edges (G.Graph, Vertex);
end Number_Of_Edges_To_Successors;
------------------------
-- Number_Of_Vertices --
------------------------
function Number_Of_Vertices (G : Library_Graph) return Natural is
begin
pragma Assert (Present (G));
return DG.Number_Of_Vertices (G.Graph);
end Number_Of_Vertices;
-----------------
-- Order_Cycle --
-----------------
procedure Order_Cycle
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id)
is
Lesser_Cycle : Library_Graph_Cycle_Id;
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
pragma Assert (LGC_Lists.Present (G.Cycles));
-- The input cycle is the first to be inserted
if LGC_Lists.Is_Empty (G.Cycles) then
LGC_Lists.Prepend (G.Cycles, Cycle);
-- Otherwise the list of all cycles contains at least one cycle.
-- Insert the input cycle based on its precedence.
else
Lesser_Cycle := Find_First_Lower_Precedence_Cycle (G, Cycle);
-- The list contains at least one cycle, and the input cycle has a
-- higher precedence compared to some cycle in the list.
if Present (Lesser_Cycle) then
LGC_Lists.Insert_Before
(L => G.Cycles,
Before => Lesser_Cycle,
Elem => Cycle);
-- Otherwise the input cycle has the lowest precedence among all
-- cycles.
else
LGC_Lists.Append (G.Cycles, Cycle);
end if;
end if;
end Order_Cycle;
----------
-- Path --
----------
function Path
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id) return LGE_Lists.Doubly_Linked_List
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
return Get_LGC_Attributes (G, Cycle).Path;
end Path;
------------------------------------------
-- Pending_Predecessors_For_Elaboration --
------------------------------------------
procedure Pending_Predecessors_For_Elaboration
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Strong_Preds : out Natural;
Weak_Preds : out Natural)
is
Complement : Library_Graph_Vertex_Id;
Spec_Vertex : Library_Graph_Vertex_Id;
Total_Strong_Preds : Natural;
Total_Weak_Preds : Natural;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
Total_Strong_Preds := Pending_Strong_Predecessors (G, Vertex);
Total_Weak_Preds := Pending_Weak_Predecessors (G, Vertex);
-- Assume that there is no complementary vertex that needs to be
-- examined.
Complement := No_Library_Graph_Vertex;
Spec_Vertex := No_Library_Graph_Vertex;
if Is_Body_Of_Spec_With_Elaborate_Body (G, Vertex) then
Complement := Proper_Spec (G, Vertex);
Spec_Vertex := Complement;
elsif Is_Spec_With_Elaborate_Body (G, Vertex) then
Complement := Proper_Body (G, Vertex);
Spec_Vertex := Vertex;
end if;
-- The vertex is part of an Elaborate_Body pair. Take into account
-- the strong and weak predecessors of the complementary vertex.
if Present (Complement) then
Total_Strong_Preds :=
Pending_Strong_Predecessors (G, Complement) + Total_Strong_Preds;
Total_Weak_Preds :=
Pending_Weak_Predecessors (G, Complement) + Total_Weak_Preds;
-- The body of an Elaborate_Body pair is the successor of a strong
-- edge where the predecessor is the spec. This edge must not be
-- considered for elaboration purposes because the pair is treated
-- as one vertex. Account for the edge only when the spec has not
-- been elaborated yet.
if not In_Elaboration_Order (G, Spec_Vertex) then
Total_Strong_Preds := Total_Strong_Preds - 1;
end if;
end if;
Strong_Preds := Total_Strong_Preds;
Weak_Preds := Total_Weak_Preds;
end Pending_Predecessors_For_Elaboration;
---------------------------------
-- Pending_Strong_Predecessors --
---------------------------------
function Pending_Strong_Predecessors
(G : Library_Graph;
Comp : Component_Id) return Natural
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
return Get_Component_Attributes (G, Comp).Pending_Strong_Predecessors;
end Pending_Strong_Predecessors;
---------------------------------
-- Pending_Strong_Predecessors --
---------------------------------
function Pending_Strong_Predecessors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Natural
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Get_LGV_Attributes (G, Vertex).Pending_Strong_Predecessors;
end Pending_Strong_Predecessors;
-------------------------------
-- Pending_Weak_Predecessors --
-------------------------------
function Pending_Weak_Predecessors
(G : Library_Graph;
Comp : Component_Id) return Natural
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
return Get_Component_Attributes (G, Comp).Pending_Weak_Predecessors;
end Pending_Weak_Predecessors;
-------------------------------
-- Pending_Weak_Predecessors --
-------------------------------
function Pending_Weak_Predecessors
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Natural
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Get_LGV_Attributes (G, Vertex).Pending_Weak_Predecessors;
end Pending_Weak_Predecessors;
-----------------
-- Predecessor --
-----------------
function Predecessor
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return DG.Source_Vertex (G.Graph, Edge);
end Predecessor;
-------------
-- Present --
-------------
function Present (G : Library_Graph) return Boolean is
begin
return G /= Nil;
end Present;
-----------------
-- Proper_Body --
-----------------
function Proper_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Library_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
-- When the vertex denotes a spec with a completing body, return the
-- body.
if Is_Spec_With_Body (G, Vertex) then
return Corresponding_Item (G, Vertex);
-- Otherwise the vertex must be a body
else
pragma Assert (Is_Body (G, Vertex));
return Vertex;
end if;
end Proper_Body;
-----------------
-- Proper_Spec --
-----------------
function Proper_Spec
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Library_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
-- When the vertex denotes a body that completes a spec, return the
-- spec.
if Is_Body_With_Spec (G, Vertex) then
return Corresponding_Item (G, Vertex);
-- Otherwise the vertex must denote a spec
else
pragma Assert (Is_Spec (G, Vertex));
return Vertex;
end if;
end Proper_Spec;
------------------
-- Record_Cycle --
------------------
procedure Record_Cycle
(G : Library_Graph;
Most_Significant_Edge : Library_Graph_Edge_Id;
Invocation_Edge_Count : Natural;
Cycle_Path : LGE_Lists.Doubly_Linked_List;
Indent : Indentation_Level)
is
Cycle : Library_Graph_Cycle_Id;
Path : LGE_Lists.Doubly_Linked_List;
begin
pragma Assert (Present (G));
pragma Assert (Present (Most_Significant_Edge));
pragma Assert (LGE_Lists.Present (Cycle_Path));
-- Replicate the path of the cycle in order to avoid sharing lists
Path := Copy_Cycle_Path (Cycle_Path);
-- Normalize the path of the cycle such that its most significant
-- edge is the first in the list of edges.
Normalize_Cycle_Path
(Cycle_Path => Path,
Most_Significant_Edge => Most_Significant_Edge);
-- Save the cycle for diagnostic purposes. Its kind is determined by
-- its most significant edge.
Cycle := Sequence_Next_Cycle;
Set_LGC_Attributes
(G => G,
Cycle => Cycle,
Val =>
(Invocation_Edge_Count => Invocation_Edge_Count,
Kind =>
Cycle_Kind_Of
(G => G,
Edge => Most_Significant_Edge),
Path => Path));
Trace_Cycle (G, Cycle, Indent);
-- Order the cycle based on its precedence relative to previously
-- discovered cycles.
Order_Cycle (G, Cycle);
end Record_Cycle;
-----------------------------------------
-- Same_Library_Graph_Cycle_Attributes --
-----------------------------------------
function Same_Library_Graph_Cycle_Attributes
(Left : Library_Graph_Cycle_Attributes;
Right : Library_Graph_Cycle_Attributes) return Boolean
is
begin
-- Two cycles are the same when
--
-- * They are of the same kind
-- * They have the same number of invocation edges in their paths
-- * Their paths are the same length
-- * The edges comprising their paths are the same
return
Left.Invocation_Edge_Count = Right.Invocation_Edge_Count
and then Left.Kind = Right.Kind
and then LGE_Lists.Equal (Left.Path, Right.Path);
end Same_Library_Graph_Cycle_Attributes;
------------------------
-- Set_Activates_Task --
------------------------
procedure Set_Activates_Task
(G : Library_Graph;
Edge : Library_Graph_Edge_Id)
is
Attributes : Library_Graph_Edge_Attributes :=
Get_LGE_Attributes (G, Edge);
begin
Attributes.Activates_Task := True;
Set_LGE_Attributes (G, Edge, Attributes);
end Set_Activates_Task;
------------------------------
-- Set_Component_Attributes --
------------------------------
procedure Set_Component_Attributes
(G : Library_Graph;
Comp : Component_Id;
Val : Component_Attributes)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
Component_Tables.Put (G.Component_Attributes, Comp, Val);
end Set_Component_Attributes;
----------------------------
-- Set_Corresponding_Item --
----------------------------
procedure Set_Corresponding_Item
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Val : Library_Graph_Vertex_Id)
is
Attrs : Library_Graph_Vertex_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
Attrs := Get_LGV_Attributes (G, Vertex);
Attrs.Corresponding_Item := Val;
Set_LGV_Attributes (G, Vertex, Attrs);
end Set_Corresponding_Item;
------------------------------
-- Set_Corresponding_Vertex --
------------------------------
procedure Set_Corresponding_Vertex
(G : Library_Graph;
U_Id : Unit_Id;
Val : Library_Graph_Vertex_Id)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (U_Id));
Unit_Tables.Put (G.Unit_To_Vertex, U_Id, Val);
end Set_Corresponding_Vertex;
------------------------------
-- Set_In_Elaboration_Order --
------------------------------
procedure Set_In_Elaboration_Order
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Val : Boolean := True)
is
Attrs : Library_Graph_Vertex_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
Attrs := Get_LGV_Attributes (G, Vertex);
Attrs.In_Elaboration_Order := Val;
Set_LGV_Attributes (G, Vertex, Attrs);
end Set_In_Elaboration_Order;
--------------------------
-- Set_Is_Recorded_Edge --
--------------------------
procedure Set_Is_Recorded_Edge
(G : Library_Graph;
Rel : Predecessor_Successor_Relation)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Rel.Predecessor));
pragma Assert (Present (Rel.Successor));
RE_Sets.Insert (G.Recorded_Edges, Rel);
end Set_Is_Recorded_Edge;
------------------------
-- Set_LGC_Attributes --
------------------------
procedure Set_LGC_Attributes
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id;
Val : Library_Graph_Cycle_Attributes)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
LGC_Tables.Put (G.Cycle_Attributes, Cycle, Val);
end Set_LGC_Attributes;
------------------------
-- Set_LGE_Attributes --
------------------------
procedure Set_LGE_Attributes
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
Val : Library_Graph_Edge_Attributes)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
LGE_Tables.Put (G.Edge_Attributes, Edge, Val);
end Set_LGE_Attributes;
------------------------
-- Set_LGV_Attributes --
------------------------
procedure Set_LGV_Attributes
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Val : Library_Graph_Vertex_Attributes)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
LGV_Tables.Put (G.Vertex_Attributes, Vertex, Val);
end Set_LGV_Attributes;
---------------
-- Successor --
---------------
function Successor
(G : Library_Graph;
Edge : Library_Graph_Edge_Id) return Library_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return DG.Destination_Vertex (G.Graph, Edge);
end Successor;
---------------------
-- Trace_Component --
---------------------
procedure Trace_Component
(G : Library_Graph;
Comp : Component_Id;
Indent : Indentation_Level)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Comp));
-- Nothing to do when switch -d_t (output cycle-detection trace
-- information) is not in effect.
if not Debug_Flag_Underscore_T then
return;
end if;
Write_Eol;
Indent_By (Indent);
Write_Str ("component (Comp_");
Write_Int (Int (Comp));
Write_Str (")");
Write_Eol;
end Trace_Component;
-----------------
-- Trace_Cycle --
-----------------
procedure Trace_Cycle
(G : Library_Graph;
Cycle : Library_Graph_Cycle_Id;
Indent : Indentation_Level)
is
Attr_Indent : constant Indentation_Level :=
Indent + Nested_Indentation;
Edge_Indent : constant Indentation_Level :=
Attr_Indent + Nested_Indentation;
Edge : Library_Graph_Edge_Id;
Iter : Edges_Of_Cycle_Iterator;
begin
pragma Assert (Present (G));
pragma Assert (Present (Cycle));
-- Nothing to do when switch -d_t (output cycle-detection trace
-- information) is not in effect.
if not Debug_Flag_Underscore_T then
return;
end if;
Indent_By (Indent);
Write_Str ("cycle (LGC_Id_");
Write_Int (Int (Cycle));
Write_Str (")");
Write_Eol;
Indent_By (Attr_Indent);
Write_Str ("kind = ");
Write_Str (Kind (G, Cycle)'Img);
Write_Eol;
Indent_By (Attr_Indent);
Write_Str ("invocation edges = ");
Write_Int (Int (Invocation_Edge_Count (G, Cycle)));
Write_Eol;
Indent_By (Attr_Indent);
Write_Str ("length: ");
Write_Int (Int (Length (G, Cycle)));
Write_Eol;
Iter := Iterate_Edges_Of_Cycle (G, Cycle);
while Has_Next (Iter) loop
Next (Iter, Edge);
Indent_By (Edge_Indent);
Write_Str ("library graph edge (LGE_Id_");
Write_Int (Int (Edge));
Write_Str (")");
Write_Eol;
end loop;
end Trace_Cycle;
----------------
-- Trace_Edge --
----------------
procedure Trace_Edge
(G : Library_Graph;
Edge : Library_Graph_Edge_Id;
Indent : Indentation_Level)
is
pragma Assert (Present (G));
pragma Assert (Present (Edge));
Attr_Indent : constant Indentation_Level :=
Indent + Nested_Indentation;
Pred : constant Library_Graph_Vertex_Id := Predecessor (G, Edge);
Succ : constant Library_Graph_Vertex_Id := Successor (G, Edge);
begin
-- Nothing to do when switch -d_t (output cycle-detection trace
-- information) is not in effect.
if not Debug_Flag_Underscore_T then
return;
end if;
Indent_By (Indent);
Write_Str ("library graph edge (LGE_Id_");
Write_Int (Int (Edge));
Write_Str (")");
Write_Eol;
Indent_By (Attr_Indent);
Write_Str ("kind = ");
Write_Str (Kind (G, Edge)'Img);
Write_Eol;
Indent_By (Attr_Indent);
Write_Str ("Predecessor (LGV_Id_");
Write_Int (Int (Pred));
Write_Str (") name = ");
Write_Name (Name (G, Pred));
Write_Eol;
Indent_By (Attr_Indent);
Write_Str ("Successor (LGV_Id_");
Write_Int (Int (Succ));
Write_Str (") name = ");
Write_Name (Name (G, Succ));
Write_Eol;
end Trace_Edge;
------------------
-- Trace_Vertex --
------------------
procedure Trace_Vertex
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Indent : Indentation_Level)
is
Attr_Indent : constant Indentation_Level :=
Indent + Nested_Indentation;
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
-- Nothing to do when switch -d_t (output cycle-detection trace
-- information) is not in effect.
if not Debug_Flag_Underscore_T then
return;
end if;
Indent_By (Indent);
Write_Str ("library graph vertex (LGV_Id_");
Write_Int (Int (Vertex));
Write_Str (")");
Write_Eol;
Indent_By (Attr_Indent);
Write_Str ("Unit (U_Id_");
Write_Int (Int (Unit (G, Vertex)));
Write_Str (") name = ");
Write_Name (Name (G, Vertex));
Write_Eol;
end Trace_Vertex;
----------
-- Unit --
----------
function Unit
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Unit_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Get_LGV_Attributes (G, Vertex).Unit;
end Unit;
-------------
-- Unvisit --
-------------
procedure Unvisit
(Vertex : Library_Graph_Vertex_Id;
Visited_Set : LGV_Sets.Membership_Set;
Visited_Stack : LGV_Lists.Doubly_Linked_List)
is
Current_Vertex : Library_Graph_Vertex_Id;
begin
pragma Assert (Present (Vertex));
pragma Assert (LGV_Sets.Present (Visited_Set));
pragma Assert (LGV_Lists.Present (Visited_Stack));
while not LGV_Lists.Is_Empty (Visited_Stack) loop
Current_Vertex := LGV_Lists.First (Visited_Stack);
LGV_Lists.Delete_First (Visited_Stack);
LGV_Sets.Delete (Visited_Set, Current_Vertex);
exit when Current_Vertex = Vertex;
end loop;
end Unvisit;
---------------------------------
-- Update_Pending_Predecessors --
---------------------------------
procedure Update_Pending_Predecessors
(Strong_Predecessors : in out Natural;
Weak_Predecessors : in out Natural;
Update_Weak : Boolean;
Value : Integer)
is
begin
if Update_Weak then
Weak_Predecessors := Weak_Predecessors + Value;
else
Strong_Predecessors := Strong_Predecessors + Value;
end if;
end Update_Pending_Predecessors;
-----------------------------------------------
-- Update_Pending_Predecessors_Of_Components --
-----------------------------------------------
procedure Update_Pending_Predecessors_Of_Components
(G : Library_Graph)
is
Edge : Library_Graph_Edge_Id;
Iter : All_Edge_Iterator;
begin
pragma Assert (Present (G));
Iter := Iterate_All_Edges (G);
while Has_Next (Iter) loop
Next (Iter, Edge);
Update_Pending_Predecessors_Of_Components (G, Edge);
end loop;
end Update_Pending_Predecessors_Of_Components;
-----------------------------------------------
-- Update_Pending_Predecessors_Of_Components --
-----------------------------------------------
procedure Update_Pending_Predecessors_Of_Components
(G : Library_Graph;
Edge : Library_Graph_Edge_Id)
is
pragma Assert (Present (G));
pragma Assert (Present (Edge));
Pred_Comp : constant Component_Id :=
Component (G, Predecessor (G, Edge));
Succ_Comp : constant Component_Id :=
Component (G, Successor (G, Edge));
pragma Assert (Present (Pred_Comp));
pragma Assert (Present (Succ_Comp));
begin
-- The edge links a successor and a predecessor coming from two
-- different SCCs. This indicates that the SCC of the successor
-- must wait on another predecessor until it can be elaborated.
if Pred_Comp /= Succ_Comp then
Increment_Pending_Predecessors
(G => G,
Comp => Succ_Comp,
Edge => Edge);
end if;
end Update_Pending_Predecessors_Of_Components;
-----------------------
-- Vertex_Precedence --
-----------------------
function Vertex_Precedence
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id;
Compared_To : Library_Graph_Vertex_Id) return Precedence_Kind
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
pragma Assert (Present (Compared_To));
-- Use lexicographical order to determine precedence and ensure
-- deterministic behavior.
if Uname_Less (Name (G, Vertex), Name (G, Compared_To)) then
return Higher_Precedence;
else
return Lower_Precedence;
end if;
end Vertex_Precedence;
-----------
-- Visit --
-----------
procedure Visit
(Vertex : Library_Graph_Vertex_Id;
Visited_Set : LGV_Sets.Membership_Set;
Visited_Stack : LGV_Lists.Doubly_Linked_List)
is
begin
pragma Assert (Present (Vertex));
pragma Assert (LGV_Sets.Present (Visited_Set));
pragma Assert (LGV_Lists.Present (Visited_Stack));
LGV_Sets.Insert (Visited_Set, Vertex);
LGV_Lists.Prepend (Visited_Stack, Vertex);
end Visit;
end Library_Graphs;
-----------------------
-- Invocation_Graphs --
-----------------------
package body Invocation_Graphs is
-----------------------
-- Local subprograms --
-----------------------
procedure Free is
new Ada.Unchecked_Deallocation
(Invocation_Graph_Attributes, Invocation_Graph);
function Get_IGE_Attributes
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id)
return Invocation_Graph_Edge_Attributes;
pragma Inline (Get_IGE_Attributes);
-- Obtain the attributes of edge Edge of invocation graph G
function Get_IGV_Attributes
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id)
return Invocation_Graph_Vertex_Attributes;
pragma Inline (Get_IGV_Attributes);
-- Obtain the attributes of vertex Vertex of invocation graph G
procedure Increment_Invocation_Graph_Edge_Count
(G : Invocation_Graph;
Kind : Invocation_Kind);
pragma Inline (Increment_Invocation_Graph_Edge_Count);
-- Increment the number of edges of king Kind in invocation graph G by
-- one.
function Is_Elaboration_Root
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Boolean;
pragma Inline (Is_Elaboration_Root);
-- Determine whether vertex Vertex of invocation graph denotes the
-- elaboration procedure of a spec or a body.
function Is_Existing_Source_Target_Relation
(G : Invocation_Graph;
Rel : Source_Target_Relation) return Boolean;
pragma Inline (Is_Existing_Source_Target_Relation);
-- Determine whether a source vertex and a target vertex described by
-- relation Rel are already related in invocation graph G.
procedure Save_Elaboration_Root
(G : Invocation_Graph;
Root : Invocation_Graph_Vertex_Id);
pragma Inline (Save_Elaboration_Root);
-- Save elaboration root Root of invocation graph G
procedure Set_Corresponding_Vertex
(G : Invocation_Graph;
IS_Id : Invocation_Signature_Id;
Vertex : Invocation_Graph_Vertex_Id);
pragma Inline (Set_Corresponding_Vertex);
-- Associate vertex Vertex of invocation graph G with signature IS_Id
procedure Set_Is_Existing_Source_Target_Relation
(G : Invocation_Graph;
Rel : Source_Target_Relation;
Val : Boolean := True);
pragma Inline (Set_Is_Existing_Source_Target_Relation);
-- Mark a source vertex and a target vertex described by relation Rel as
-- already related in invocation graph G depending on value Val.
procedure Set_IGE_Attributes
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id;
Val : Invocation_Graph_Edge_Attributes);
pragma Inline (Set_IGE_Attributes);
-- Set the attributes of edge Edge of invocation graph G to value Val
procedure Set_IGV_Attributes
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id;
Val : Invocation_Graph_Vertex_Attributes);
pragma Inline (Set_IGV_Attributes);
-- Set the attributes of vertex Vertex of invocation graph G to value
-- Val.
--------------
-- Add_Edge --
--------------
procedure Add_Edge
(G : Invocation_Graph;
Source : Invocation_Graph_Vertex_Id;
Target : Invocation_Graph_Vertex_Id;
IR_Id : Invocation_Relation_Id)
is
pragma Assert (Present (G));
pragma Assert (Present (Source));
pragma Assert (Present (Target));
pragma Assert (Present (IR_Id));
Rel : constant Source_Target_Relation :=
(Source => Source,
Target => Target);
Edge : Invocation_Graph_Edge_Id;
begin
-- Nothing to do when the source and target are already related by an
-- edge.
if Is_Existing_Source_Target_Relation (G, Rel) then
return;
end if;
Edge := Sequence_Next_Edge;
-- Add the edge to the underlying graph
DG.Add_Edge
(G => G.Graph,
E => Edge,
Source => Source,
Destination => Target);
-- Build and save the attributes of the edge
Set_IGE_Attributes
(G => G,
Edge => Edge,
Val => (Relation => IR_Id));
-- Mark the source and target as related by the new edge. This
-- prevents all further attempts to link the same source and target.
Set_Is_Existing_Source_Target_Relation (G, Rel);
-- Update the edge statistics
Increment_Invocation_Graph_Edge_Count (G, Kind (IR_Id));
end Add_Edge;
----------------
-- Add_Vertex --
----------------
procedure Add_Vertex
(G : Invocation_Graph;
IC_Id : Invocation_Construct_Id;
Body_Vertex : Library_Graph_Vertex_Id;
Spec_Vertex : Library_Graph_Vertex_Id)
is
pragma Assert (Present (G));
pragma Assert (Present (IC_Id));
pragma Assert (Present (Body_Vertex));
pragma Assert (Present (Spec_Vertex));
Construct_Signature : constant Invocation_Signature_Id :=
Signature (IC_Id);
Vertex : Invocation_Graph_Vertex_Id;
begin
-- Nothing to do when the construct already has a vertex
if Present (Corresponding_Vertex (G, Construct_Signature)) then
return;
end if;
Vertex := Sequence_Next_Vertex;
-- Add the vertex to the underlying graph
DG.Add_Vertex (G.Graph, Vertex);
-- Build and save the attributes of the vertex
Set_IGV_Attributes
(G => G,
Vertex => Vertex,
Val => (Body_Vertex => Body_Vertex,
Construct => IC_Id,
Spec_Vertex => Spec_Vertex));
-- Associate the construct with its corresponding vertex
Set_Corresponding_Vertex (G, Construct_Signature, Vertex);
-- Save the vertex for later processing when it denotes a spec or
-- body elaboration procedure.
if Is_Elaboration_Root (G, Vertex) then
Save_Elaboration_Root (G, Vertex);
end if;
end Add_Vertex;
-----------------
-- Body_Vertex --
-----------------
function Body_Vertex
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Library_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Get_IGV_Attributes (G, Vertex).Body_Vertex;
end Body_Vertex;
------------
-- Column --
------------
function Column
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Nat
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Column (Signature (Construct (G, Vertex)));
end Column;
---------------
-- Construct --
---------------
function Construct
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Invocation_Construct_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Get_IGV_Attributes (G, Vertex).Construct;
end Construct;
--------------------------
-- Corresponding_Vertex --
--------------------------
function Corresponding_Vertex
(G : Invocation_Graph;
IS_Id : Invocation_Signature_Id) return Invocation_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (IS_Id));
return Signature_Tables.Get (G.Signature_To_Vertex, IS_Id);
end Corresponding_Vertex;
------------
-- Create --
------------
function Create
(Initial_Vertices : Positive;
Initial_Edges : Positive;
Lib_Graph : Library_Graphs.Library_Graph)
return Invocation_Graph
is
G : constant Invocation_Graph := new Invocation_Graph_Attributes'
(Counts => <>,
Edge_Attributes => IGE_Tables.Create (Initial_Edges),
Graph =>
DG.Create
(Initial_Vertices => Initial_Vertices,
Initial_Edges => Initial_Edges),
Relations => Relation_Sets.Create (Initial_Edges),
Roots => IGV_Sets.Create (Initial_Vertices),
Signature_To_Vertex => Signature_Tables.Create (Initial_Vertices),
Vertex_Attributes => IGV_Tables.Create (Initial_Vertices),
Lib_Graph => Lib_Graph);
begin
return G;
end Create;
-------------
-- Destroy --
-------------
procedure Destroy (G : in out Invocation_Graph) is
begin
pragma Assert (Present (G));
IGE_Tables.Destroy (G.Edge_Attributes);
DG.Destroy (G.Graph);
Relation_Sets.Destroy (G.Relations);
IGV_Sets.Destroy (G.Roots);
Signature_Tables.Destroy (G.Signature_To_Vertex);
IGV_Tables.Destroy (G.Vertex_Attributes);
Free (G);
end Destroy;
-----------------------------------
-- Destroy_Invocation_Graph_Edge --
-----------------------------------
procedure Destroy_Invocation_Graph_Edge
(Edge : in out Invocation_Graph_Edge_Id)
is
pragma Unreferenced (Edge);
begin
null;
end Destroy_Invocation_Graph_Edge;
----------------------------------------------
-- Destroy_Invocation_Graph_Edge_Attributes --
----------------------------------------------
procedure Destroy_Invocation_Graph_Edge_Attributes
(Attrs : in out Invocation_Graph_Edge_Attributes)
is
pragma Unreferenced (Attrs);
begin
null;
end Destroy_Invocation_Graph_Edge_Attributes;
-------------------------------------
-- Destroy_Invocation_Graph_Vertex --
-------------------------------------
procedure Destroy_Invocation_Graph_Vertex
(Vertex : in out Invocation_Graph_Vertex_Id)
is
pragma Unreferenced (Vertex);
begin
null;
end Destroy_Invocation_Graph_Vertex;
------------------------------------------------
-- Destroy_Invocation_Graph_Vertex_Attributes --
------------------------------------------------
procedure Destroy_Invocation_Graph_Vertex_Attributes
(Attrs : in out Invocation_Graph_Vertex_Attributes)
is
pragma Unreferenced (Attrs);
begin
null;
end Destroy_Invocation_Graph_Vertex_Attributes;
-----------
-- Extra --
-----------
function Extra
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id) return Name_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Extra (Relation (G, Edge));
end Extra;
------------------------
-- Get_IGE_Attributes --
------------------------
function Get_IGE_Attributes
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id)
return Invocation_Graph_Edge_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return IGE_Tables.Get (G.Edge_Attributes, Edge);
end Get_IGE_Attributes;
------------------------
-- Get_IGV_Attributes --
------------------------
function Get_IGV_Attributes
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id)
return Invocation_Graph_Vertex_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return IGV_Tables.Get (G.Vertex_Attributes, Vertex);
end Get_IGV_Attributes;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : All_Edge_Iterator) return Boolean is
begin
return DG.Has_Next (DG.All_Edge_Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : All_Vertex_Iterator) return Boolean is
begin
return DG.Has_Next (DG.All_Vertex_Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Edges_To_Targets_Iterator) return Boolean is
begin
return DG.Has_Next (DG.Outgoing_Edge_Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Elaboration_Root_Iterator) return Boolean is
begin
return IGV_Sets.Has_Next (IGV_Sets.Iterator (Iter));
end Has_Next;
-------------------------------
-- Hash_Invocation_Signature --
-------------------------------
function Hash_Invocation_Signature
(IS_Id : Invocation_Signature_Id) return Bucket_Range_Type
is
begin
pragma Assert (Present (IS_Id));
return Bucket_Range_Type (IS_Id);
end Hash_Invocation_Signature;
---------------------------------
-- Hash_Source_Target_Relation --
---------------------------------
function Hash_Source_Target_Relation
(Rel : Source_Target_Relation) return Bucket_Range_Type
is
begin
pragma Assert (Present (Rel.Source));
pragma Assert (Present (Rel.Target));
return
Hash_Two_Keys
(Bucket_Range_Type (Rel.Source),
Bucket_Range_Type (Rel.Target));
end Hash_Source_Target_Relation;
-------------------------------------------
-- Increment_Invocation_Graph_Edge_Count --
-------------------------------------------
procedure Increment_Invocation_Graph_Edge_Count
(G : Invocation_Graph;
Kind : Invocation_Kind)
is
pragma Assert (Present (G));
Count : Natural renames G.Counts (Kind);
begin
Count := Count + 1;
end Increment_Invocation_Graph_Edge_Count;
---------------------------------
-- Invocation_Graph_Edge_Count --
---------------------------------
function Invocation_Graph_Edge_Count
(G : Invocation_Graph;
Kind : Invocation_Kind) return Natural
is
begin
pragma Assert (Present (G));
return G.Counts (Kind);
end Invocation_Graph_Edge_Count;
-------------------------
-- Is_Elaboration_Root --
-------------------------
function Is_Elaboration_Root
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Boolean
is
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
Vertex_Kind : constant Invocation_Construct_Kind :=
Kind (Construct (G, Vertex));
begin
return
Vertex_Kind = Elaborate_Body_Procedure
or else
Vertex_Kind = Elaborate_Spec_Procedure;
end Is_Elaboration_Root;
----------------------------------------
-- Is_Existing_Source_Target_Relation --
----------------------------------------
function Is_Existing_Source_Target_Relation
(G : Invocation_Graph;
Rel : Source_Target_Relation) return Boolean
is
begin
pragma Assert (Present (G));
return Relation_Sets.Contains (G.Relations, Rel);
end Is_Existing_Source_Target_Relation;
-----------------------
-- Iterate_All_Edges --
-----------------------
function Iterate_All_Edges
(G : Invocation_Graph) return All_Edge_Iterator
is
begin
pragma Assert (Present (G));
return All_Edge_Iterator (DG.Iterate_All_Edges (G.Graph));
end Iterate_All_Edges;
--------------------------
-- Iterate_All_Vertices --
--------------------------
function Iterate_All_Vertices
(G : Invocation_Graph) return All_Vertex_Iterator
is
begin
pragma Assert (Present (G));
return All_Vertex_Iterator (DG.Iterate_All_Vertices (G.Graph));
end Iterate_All_Vertices;
------------------------------
-- Iterate_Edges_To_Targets --
------------------------------
function Iterate_Edges_To_Targets
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Edges_To_Targets_Iterator
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return
Edges_To_Targets_Iterator
(DG.Iterate_Outgoing_Edges (G.Graph, Vertex));
end Iterate_Edges_To_Targets;
-------------------------------
-- Iterate_Elaboration_Roots --
-------------------------------
function Iterate_Elaboration_Roots
(G : Invocation_Graph) return Elaboration_Root_Iterator
is
begin
pragma Assert (Present (G));
return Elaboration_Root_Iterator (IGV_Sets.Iterate (G.Roots));
end Iterate_Elaboration_Roots;
----------
-- Kind --
----------
function Kind
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id) return Invocation_Kind
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Kind (Relation (G, Edge));
end Kind;
-------------------
-- Get_Lib_Graph --
-------------------
function Get_Lib_Graph
(G : Invocation_Graph) return Library_Graphs.Library_Graph
is
pragma Assert (Present (G));
begin
return G.Lib_Graph;
end Get_Lib_Graph;
----------
-- Line --
----------
function Line
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Nat
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Line (Signature (Construct (G, Vertex)));
end Line;
----------
-- Name --
----------
function Name
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Name_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Name (Signature (Construct (G, Vertex)));
end Name;
----------
-- Next --
----------
procedure Next
(Iter : in out All_Edge_Iterator;
Edge : out Invocation_Graph_Edge_Id)
is
begin
DG.Next (DG.All_Edge_Iterator (Iter), Edge);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out All_Vertex_Iterator;
Vertex : out Invocation_Graph_Vertex_Id)
is
begin
DG.Next (DG.All_Vertex_Iterator (Iter), Vertex);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Edges_To_Targets_Iterator;
Edge : out Invocation_Graph_Edge_Id)
is
begin
DG.Next (DG.Outgoing_Edge_Iterator (Iter), Edge);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Elaboration_Root_Iterator;
Root : out Invocation_Graph_Vertex_Id)
is
begin
IGV_Sets.Next (IGV_Sets.Iterator (Iter), Root);
end Next;
---------------------
-- Number_Of_Edges --
---------------------
function Number_Of_Edges (G : Invocation_Graph) return Natural is
begin
pragma Assert (Present (G));
return DG.Number_Of_Edges (G.Graph);
end Number_Of_Edges;
--------------------------------
-- Number_Of_Edges_To_Targets --
--------------------------------
function Number_Of_Edges_To_Targets
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Natural
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return DG.Number_Of_Outgoing_Edges (G.Graph, Vertex);
end Number_Of_Edges_To_Targets;
---------------------------------
-- Number_Of_Elaboration_Roots --
---------------------------------
function Number_Of_Elaboration_Roots
(G : Invocation_Graph) return Natural
is
begin
pragma Assert (Present (G));
return IGV_Sets.Size (G.Roots);
end Number_Of_Elaboration_Roots;
------------------------
-- Number_Of_Vertices --
------------------------
function Number_Of_Vertices (G : Invocation_Graph) return Natural is
begin
pragma Assert (Present (G));
return DG.Number_Of_Vertices (G.Graph);
end Number_Of_Vertices;
-------------
-- Present --
-------------
function Present (G : Invocation_Graph) return Boolean is
begin
return G /= Nil;
end Present;
--------------
-- Relation --
--------------
function Relation
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id) return Invocation_Relation_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return Get_IGE_Attributes (G, Edge).Relation;
end Relation;
---------------------------
-- Save_Elaboration_Root --
---------------------------
procedure Save_Elaboration_Root
(G : Invocation_Graph;
Root : Invocation_Graph_Vertex_Id)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Root));
IGV_Sets.Insert (G.Roots, Root);
end Save_Elaboration_Root;
------------------------------
-- Set_Corresponding_Vertex --
------------------------------
procedure Set_Corresponding_Vertex
(G : Invocation_Graph;
IS_Id : Invocation_Signature_Id;
Vertex : Invocation_Graph_Vertex_Id)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (IS_Id));
pragma Assert (Present (Vertex));
Signature_Tables.Put (G.Signature_To_Vertex, IS_Id, Vertex);
end Set_Corresponding_Vertex;
--------------------------------------------
-- Set_Is_Existing_Source_Target_Relation --
--------------------------------------------
procedure Set_Is_Existing_Source_Target_Relation
(G : Invocation_Graph;
Rel : Source_Target_Relation;
Val : Boolean := True)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Rel.Source));
pragma Assert (Present (Rel.Target));
if Val then
Relation_Sets.Insert (G.Relations, Rel);
else
Relation_Sets.Delete (G.Relations, Rel);
end if;
end Set_Is_Existing_Source_Target_Relation;
------------------------
-- Set_IGE_Attributes --
------------------------
procedure Set_IGE_Attributes
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id;
Val : Invocation_Graph_Edge_Attributes)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
IGE_Tables.Put (G.Edge_Attributes, Edge, Val);
end Set_IGE_Attributes;
------------------------
-- Set_IGV_Attributes --
------------------------
procedure Set_IGV_Attributes
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id;
Val : Invocation_Graph_Vertex_Attributes)
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
IGV_Tables.Put (G.Vertex_Attributes, Vertex, Val);
end Set_IGV_Attributes;
-----------------
-- Spec_Vertex --
-----------------
function Spec_Vertex
(G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id) return Library_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Vertex));
return Get_IGV_Attributes (G, Vertex).Spec_Vertex;
end Spec_Vertex;
------------
-- Target --
------------
function Target
(G : Invocation_Graph;
Edge : Invocation_Graph_Edge_Id) return Invocation_Graph_Vertex_Id
is
begin
pragma Assert (Present (G));
pragma Assert (Present (Edge));
return DG.Destination_Vertex (G.Graph, Edge);
end Target;
end Invocation_Graphs;
-------------
-- Present --
-------------
function Present (Edge : Invocation_Graph_Edge_Id) return Boolean is
begin
return Edge /= No_Invocation_Graph_Edge;
end Present;
-------------
-- Present --
-------------
function Present (Vertex : Invocation_Graph_Vertex_Id) return Boolean is
begin
return Vertex /= No_Invocation_Graph_Vertex;
end Present;
-------------
-- Present --
-------------
function Present (Cycle : Library_Graph_Cycle_Id) return Boolean is
begin
return Cycle /= No_Library_Graph_Cycle;
end Present;
-------------
-- Present --
-------------
function Present (Edge : Library_Graph_Edge_Id) return Boolean is
begin
return Edge /= No_Library_Graph_Edge;
end Present;
-------------
-- Present --
-------------
function Present (Vertex : Library_Graph_Vertex_Id) return Boolean is
begin
return Vertex /= No_Library_Graph_Vertex;
end Present;
--------------------------
-- Sequence_Next_Edge --
--------------------------
IGE_Sequencer : Invocation_Graph_Edge_Id := First_Invocation_Graph_Edge;
-- The counter for invocation graph edges. Do not directly manipulate its
-- value.
function Sequence_Next_Edge return Invocation_Graph_Edge_Id is
Edge : constant Invocation_Graph_Edge_Id := IGE_Sequencer;
begin
IGE_Sequencer := IGE_Sequencer + 1;
return Edge;
end Sequence_Next_Edge;
--------------------------
-- Sequence_Next_Vertex --
--------------------------
IGV_Sequencer : Invocation_Graph_Vertex_Id := First_Invocation_Graph_Vertex;
-- The counter for invocation graph vertices. Do not directly manipulate
-- its value.
function Sequence_Next_Vertex return Invocation_Graph_Vertex_Id is
Vertex : constant Invocation_Graph_Vertex_Id := IGV_Sequencer;
begin
IGV_Sequencer := IGV_Sequencer + 1;
return Vertex;
end Sequence_Next_Vertex;
--------------------------
-- Sequence_Next_Cycle --
--------------------------
LGC_Sequencer : Library_Graph_Cycle_Id := First_Library_Graph_Cycle;
-- The counter for library graph cycles. Do not directly manipulate its
-- value.
function Sequence_Next_Cycle return Library_Graph_Cycle_Id is
Cycle : constant Library_Graph_Cycle_Id := LGC_Sequencer;
begin
LGC_Sequencer := LGC_Sequencer + 1;
return Cycle;
end Sequence_Next_Cycle;
--------------------------
-- Sequence_Next_Edge --
--------------------------
LGE_Sequencer : Library_Graph_Edge_Id := First_Library_Graph_Edge;
-- The counter for library graph edges. Do not directly manipulate its
-- value.
function Sequence_Next_Edge return Library_Graph_Edge_Id is
Edge : constant Library_Graph_Edge_Id := LGE_Sequencer;
begin
LGE_Sequencer := LGE_Sequencer + 1;
return Edge;
end Sequence_Next_Edge;
--------------------------
-- Sequence_Next_Vertex --
--------------------------
LGV_Sequencer : Library_Graph_Vertex_Id := First_Library_Graph_Vertex;
-- The counter for library graph vertices. Do not directly manipulate its
-- value.
function Sequence_Next_Vertex return Library_Graph_Vertex_Id is
Vertex : constant Library_Graph_Vertex_Id := LGV_Sequencer;
begin
LGV_Sequencer := LGV_Sequencer + 1;
return Vertex;
end Sequence_Next_Vertex;
end Bindo.Graphs;
|
Transynther/x86/_processed/US/_zr_/i9-9900K_12_0xca_notsx.log_21829_698.asm
|
ljhsiun2/medusa
| 9 |
23209
|
<reponame>ljhsiun2/medusa<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r14
push %r15
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x2a94, %rsi
lea addresses_A_ht+0x1090e, %rdi
dec %r14
mov $3, %rcx
rep movsb
nop
xor $24727, %r15
lea addresses_WC_ht+0x17294, %r13
and $63028, %r9
vmovups (%r13), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %rdi
nop
sub $35692, %r14
lea addresses_D_ht+0x12114, %r15
nop
nop
nop
nop
inc %r14
mov (%r15), %edi
and $25482, %r15
lea addresses_WC_ht+0x15634, %rcx
nop
nop
nop
nop
sub $27726, %r15
mov (%rcx), %r13d
nop
dec %r14
lea addresses_D_ht+0x301, %rdi
nop
nop
nop
nop
nop
inc %r13
mov $0x6162636465666768, %rsi
movq %rsi, (%rdi)
nop
nop
nop
nop
cmp $3187, %rcx
lea addresses_UC_ht+0x3294, %rsi
lea addresses_D_ht+0xa494, %rdi
nop
and %r11, %r11
mov $40, %rcx
rep movsw
nop
nop
nop
nop
nop
sub %r11, %r11
lea addresses_UC_ht+0x1376c, %r13
nop
nop
xor $20373, %r15
movl $0x61626364, (%r13)
cmp $18069, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r14
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r15
push %r9
push %rax
push %rcx
push %rdi
push %rsi
// Load
lea addresses_D+0x18e14, %rdi
nop
nop
xor $11627, %rcx
movb (%rdi), %al
nop
dec %rsi
// Store
lea addresses_RW+0x5528, %rax
and %rdi, %rdi
mov $0x5152535455565758, %r9
movq %r9, %xmm3
movups %xmm3, (%rax)
nop
inc %r9
// Store
mov $0x9d187000000058a, %rcx
sub $49488, %r15
movw $0x5152, (%rcx)
nop
nop
and %rsi, %rsi
// Store
lea addresses_normal+0x19a34, %rdi
nop
nop
nop
cmp %rsi, %rsi
movw $0x5152, (%rdi)
nop
sub %r14, %r14
// Store
mov $0x72235c0000000f8c, %r9
nop
nop
nop
nop
nop
and $24283, %rsi
movl $0x51525354, (%r9)
nop
xor %rsi, %rsi
// Load
lea addresses_US+0x802a, %rcx
nop
nop
nop
dec %r15
mov (%rcx), %rax
sub %r14, %r14
// Store
lea addresses_WC+0x78f4, %rax
nop
nop
and $38165, %r15
movw $0x5152, (%rax)
nop
sub $49766, %rax
// Faulty Load
lea addresses_US+0x7294, %r14
nop
nop
nop
nop
xor %rax, %rax
mov (%r14), %rcx
lea oracles, %r9
and $0xff, %rcx
shlq $12, %rcx
mov (%r9,%rcx,1), %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 3}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0xca.log_1275_689.asm
|
ljhsiun2/medusa
| 9 |
242007
|
<reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0xca.log_1275_689.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x14faf, %r15
clflush (%r15)
nop
nop
cmp %rbp, %rbp
vmovups (%r15), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $1, %xmm3, %r9
nop
cmp %r12, %r12
lea addresses_UC_ht+0x8287, %rsi
lea addresses_normal_ht+0x10287, %rdi
nop
nop
add $51623, %r9
mov $66, %rcx
rep movsw
and %rdi, %rdi
lea addresses_WC_ht+0x487, %r15
nop
nop
nop
add %rbp, %rbp
movups (%r15), %xmm6
vpextrq $1, %xmm6, %rdi
nop
nop
nop
nop
cmp %rbp, %rbp
lea addresses_WT_ht+0x14a87, %rdi
nop
nop
sub $20088, %r9
movups (%rdi), %xmm2
vpextrq $1, %xmm2, %rbp
nop
nop
nop
nop
and $16338, %rbp
lea addresses_D_ht+0xa287, %rsi
lea addresses_WC_ht+0x1a367, %rdi
nop
sub %r8, %r8
mov $127, %rcx
rep movsq
nop
nop
nop
nop
xor %r9, %r9
lea addresses_WT_ht+0x1220b, %r9
nop
nop
nop
sub $48406, %r8
movl $0x61626364, (%r9)
nop
nop
nop
nop
sub $2123, %r12
lea addresses_D_ht+0xa4a7, %rcx
clflush (%rcx)
nop
nop
mfence
mov (%rcx), %ebp
nop
nop
nop
nop
and $6828, %r15
lea addresses_normal_ht+0x9e87, %rsi
lea addresses_WC_ht+0x10287, %rdi
nop
nop
nop
nop
nop
cmp %r15, %r15
mov $30, %rcx
rep movsb
nop
nop
nop
nop
nop
inc %r15
lea addresses_WC_ht+0x1e2f6, %rcx
nop
nop
nop
nop
nop
sub %r12, %r12
mov $0x6162636465666768, %r9
movq %r9, (%rcx)
nop
nop
nop
nop
nop
sub %r9, %r9
lea addresses_normal_ht+0x1ee87, %rsi
lea addresses_D_ht+0x607f, %rdi
nop
nop
sub $43133, %r15
mov $112, %rcx
rep movsw
nop
nop
nop
nop
nop
xor $40977, %r15
lea addresses_normal_ht+0x21e7, %r15
clflush (%r15)
nop
nop
nop
nop
nop
cmp %rdi, %rdi
movw $0x6162, (%r15)
nop
nop
nop
nop
nop
sub $26853, %r12
lea addresses_WT_ht+0x129af, %r12
nop
nop
xor $57841, %r8
vmovups (%r12), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %rcx
nop
nop
nop
sub %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r15
push %r8
push %rax
push %rbp
push %rcx
push %rdi
// Store
lea addresses_WT+0xc687, %r15
nop
nop
nop
xor $5261, %rcx
movb $0x51, (%r15)
nop
nop
sub %rcx, %rcx
// Store
lea addresses_RW+0x9287, %rcx
nop
nop
nop
nop
nop
sub $48856, %r11
mov $0x5152535455565758, %rdi
movq %rdi, %xmm1
movups %xmm1, (%rcx)
nop
and $45542, %rax
// Store
lea addresses_WT+0x6a87, %rbp
clflush (%rbp)
nop
nop
add $37131, %r8
mov $0x5152535455565758, %r11
movq %r11, %xmm2
movups %xmm2, (%rbp)
xor $37544, %r8
// Store
mov $0x395f1d00000009c7, %rbp
nop
nop
cmp $453, %r8
mov $0x5152535455565758, %rax
movq %rax, (%rbp)
nop
nop
nop
nop
nop
add $11063, %r15
// Store
lea addresses_D+0x10147, %r11
nop
nop
nop
xor $63429, %rbp
mov $0x5152535455565758, %r8
movq %r8, %xmm2
movups %xmm2, (%r11)
nop
nop
nop
nop
add $47983, %r11
// Store
lea addresses_D+0x19bff, %rcx
nop
nop
cmp %rdi, %rdi
mov $0x5152535455565758, %r15
movq %r15, %xmm0
vmovaps %ymm0, (%rcx)
nop
nop
cmp %r8, %r8
// Faulty Load
lea addresses_RW+0x9287, %rbp
nop
nop
nop
xor %rax, %rax
mov (%rbp), %r11w
lea oracles, %rcx
and $0xff, %r11
shlq $12, %r11
mov (%rcx,%r11,1), %r11
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': True, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WT'}}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_RW'}}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT'}}
{'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_NC'}}
{'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_D'}}
{'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': True, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}}
{'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 3, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}}
{'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'58': 1275}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_1293.asm
|
ljhsiun2/medusa
| 9 |
172683
|
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x1cf05, %rax
nop
inc %r9
mov (%rax), %esi
nop
nop
nop
and $43785, %r15
lea addresses_WT_ht+0x25f5, %rsi
lea addresses_normal_ht+0x15905, %rdi
nop
add %r9, %r9
mov $104, %rcx
rep movsw
nop
nop
nop
xor $28543, %rax
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r15
push %r9
push %rcx
push %rdi
push %rsi
// Store
lea addresses_normal+0x1df05, %rsi
nop
nop
nop
cmp %r14, %r14
movl $0x51525354, (%rsi)
nop
nop
nop
sub $22823, %rdi
// Store
lea addresses_UC+0x1b951, %rcx
nop
nop
xor $52327, %r15
mov $0x5152535455565758, %r10
movq %r10, %xmm2
movups %xmm2, (%rcx)
nop
nop
nop
nop
nop
add %r14, %r14
// Load
lea addresses_UC+0x21b1, %r15
nop
nop
nop
nop
sub %rcx, %rcx
mov (%r15), %r10w
nop
nop
nop
xor $10088, %rsi
// REPMOV
lea addresses_normal+0x1df05, %rsi
lea addresses_WT+0x6d05, %rdi
nop
nop
nop
nop
nop
sub %r15, %r15
mov $108, %rcx
rep movsb
nop
nop
nop
nop
nop
inc %r15
// Store
lea addresses_normal+0xca85, %r10
cmp $26658, %r9
mov $0x5152535455565758, %r14
movq %r14, %xmm0
vmovups %ymm0, (%r10)
and $5425, %r14
// Faulty Load
lea addresses_normal+0x1df05, %rcx
sub $64226, %r14
movups (%rcx), %xmm7
vpextrq $1, %xmm7, %r15
lea oracles, %r14
and $0xff, %r15
shlq $12, %r15
mov (%r14,%r15,1), %r15
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': True, 'congruent': 0, 'type': 'addresses_normal'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WT'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/BagAndSetEquality.agda
|
omega12345/agda-mode
| 0 |
710
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Bag and set equality
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Binary.BagAndSetEquality where
open import Algebra using (CommutativeSemiring; CommutativeMonoid)
open import Algebra.FunctionProperties using (Idempotent)
open import Category.Monad using (RawMonad)
open import Data.Empty
open import Data.Fin
open import Data.List
open import Data.List.Categorical using (monad; module MonadProperties)
import Data.List.Properties as LP
open import Data.List.Relation.Unary.Any using (Any; here; there)
open import Data.List.Relation.Unary.Any.Properties
open import Data.List.Membership.Propositional using (_∈_)
open import Data.List.Relation.Binary.Subset.Propositional.Properties
using (⊆-preorder)
open import Data.Product as Prod hiding (map)
import Data.Product.Function.Dependent.Propositional as Σ
open import Data.Sum as Sum hiding (map)
open import Data.Sum.Properties
open import Data.Sum.Function.Propositional using (_⊎-cong_)
open import Data.Unit
open import Function
open import Function.Equality using (_⟨$⟩_)
import Function.Equivalence as FE
open import Function.Inverse as Inv using (_↔_; Inverse; inverse)
open import Function.Related as Related
using (↔⇒; ⌊_⌋; ⌊_⌋→; ⇒→; K-refl; SK-sym)
open import Function.Related.TypeIsomorphisms
open import Level using (Lift)
open import Relation.Binary
import Relation.Binary.Reasoning.Setoid as EqR
import Relation.Binary.Reasoning.Preorder as PreorderReasoning
open import Relation.Binary.PropositionalEquality as P
using (_≡_; _≢_; _≗_; refl)
open import Relation.Nullary
open import Data.List.Membership.Propositional.Properties
------------------------------------------------------------------------
-- Definitions
open Related public using (Kind; Symmetric-kind) renaming
( implication to subset
; reverse-implication to superset
; equivalence to set
; injection to subbag
; reverse-injection to superbag
; bijection to bag
)
[_]-Order : Kind → ∀ {a} → Set a → Preorder _ _ _
[ k ]-Order A = Related.InducedPreorder₂ k {A = A} _∈_
[_]-Equality : Symmetric-kind → ∀ {a} → Set a → Setoid _ _
[ k ]-Equality A = Related.InducedEquivalence₂ k {A = A} _∈_
infix 4 _∼[_]_
_∼[_]_ : ∀ {a} {A : Set a} → List A → Kind → List A → Set _
_∼[_]_ {A = A} xs k ys = Preorder._∼_ ([ k ]-Order A) xs ys
private
module Eq {k a} {A : Set a} = Setoid ([ k ]-Equality A)
module Ord {k a} {A : Set a} = Preorder ([ k ]-Order A)
open module ListMonad {ℓ} = RawMonad (monad {ℓ = ℓ})
module MP = MonadProperties
------------------------------------------------------------------------
-- Bag equality implies the other relations.
bag-=⇒ : ∀ {k a} {A : Set a} {xs ys : List A} →
xs ∼[ bag ] ys → xs ∼[ k ] ys
bag-=⇒ xs≈ys = ↔⇒ xs≈ys
------------------------------------------------------------------------
-- "Equational" reasoning for _⊆_ along with an additional relatedness
module ⊆-Reasoning where
private
module PreOrder {a} {A : Set a} = PreorderReasoning (⊆-preorder A)
open PreOrder public
hiding (_≈⟨_⟩_; _≈˘⟨_⟩_) renaming (_∼⟨_⟩_ to _⊆⟨_⟩_)
infixr 2 _∼⟨_⟩_
infix 1 _∈⟨_⟩_
_∈⟨_⟩_ : ∀ {a} {A : Set a} x {xs ys : List A} →
x ∈ xs → xs IsRelatedTo ys → x ∈ ys
x ∈⟨ x∈xs ⟩ xs⊆ys = (begin xs⊆ys) x∈xs
_∼⟨_⟩_ : ∀ {k a} {A : Set a} xs {ys zs : List A} →
xs ∼[ ⌊ k ⌋→ ] ys → ys IsRelatedTo zs → xs IsRelatedTo zs
xs ∼⟨ xs≈ys ⟩ ys≈zs = xs ⊆⟨ ⇒→ xs≈ys ⟩ ys≈zs
------------------------------------------------------------------------
-- Congruence lemmas
------------------------------------------------------------------------
-- _∷_
module _ {a k} {A : Set a} {x y : A} {xs ys} where
∷-cong : x ≡ y → xs ∼[ k ] ys → x ∷ xs ∼[ k ] y ∷ ys
∷-cong refl xs≈ys {y} =
y ∈ x ∷ xs ↔⟨ SK-sym $ ∷↔ (y ≡_) ⟩
(y ≡ x ⊎ y ∈ xs) ∼⟨ (y ≡ x ∎) ⊎-cong xs≈ys ⟩
(y ≡ x ⊎ y ∈ ys) ↔⟨ ∷↔ (y ≡_) ⟩
y ∈ x ∷ ys ∎
where open Related.EquationalReasoning
------------------------------------------------------------------------
-- map
module _ {ℓ k} {A B : Set ℓ} {f g : A → B} {xs ys} where
map-cong : f ≗ g → xs ∼[ k ] ys → map f xs ∼[ k ] map g ys
map-cong f≗g xs≈ys {x} =
x ∈ map f xs ↔⟨ SK-sym $ map↔ ⟩
Any (λ y → x ≡ f y) xs ∼⟨ Any-cong (↔⇒ ∘ helper) xs≈ys ⟩
Any (λ y → x ≡ g y) ys ↔⟨ map↔ ⟩
x ∈ map g ys ∎
where
open Related.EquationalReasoning
helper : ∀ y → x ≡ f y ↔ x ≡ g y
helper y = record
{ to = P.→-to-⟶ (λ x≡fy → P.trans x≡fy ( f≗g y))
; from = P.→-to-⟶ (λ x≡gy → P.trans x≡gy (P.sym $ f≗g y))
; inverse-of = record
{ left-inverse-of = λ { P.refl → P.trans-symʳ (f≗g y) }
; right-inverse-of = λ { P.refl → P.trans-symˡ (f≗g y) }
}
}
------------------------------------------------------------------------
-- _++_
module _ {a k} {A : Set a} {xs₁ xs₂ ys₁ ys₂ : List A} where
++-cong : xs₁ ∼[ k ] xs₂ → ys₁ ∼[ k ] ys₂ →
xs₁ ++ ys₁ ∼[ k ] xs₂ ++ ys₂
++-cong xs₁≈xs₂ ys₁≈ys₂ {x} =
x ∈ xs₁ ++ ys₁ ↔⟨ SK-sym $ ++↔ ⟩
(x ∈ xs₁ ⊎ x ∈ ys₁) ∼⟨ xs₁≈xs₂ ⊎-cong ys₁≈ys₂ ⟩
(x ∈ xs₂ ⊎ x ∈ ys₂) ↔⟨ ++↔ ⟩
x ∈ xs₂ ++ ys₂ ∎
where open Related.EquationalReasoning
------------------------------------------------------------------------
-- concat
module _ {a k} {A : Set a} {xss yss : List (List A)} where
concat-cong : xss ∼[ k ] yss → concat xss ∼[ k ] concat yss
concat-cong xss≈yss {x} =
x ∈ concat xss ↔⟨ SK-sym concat↔ ⟩
Any (Any (x ≡_)) xss ∼⟨ Any-cong (λ _ → _ ∎) xss≈yss ⟩
Any (Any (x ≡_)) yss ↔⟨ concat↔ ⟩
x ∈ concat yss ∎
where open Related.EquationalReasoning
------------------------------------------------------------------------
-- _>>=_
module _ {ℓ k} {A B : Set ℓ} {xs ys} {f g : A → List B} where
>>=-cong : xs ∼[ k ] ys → (∀ x → f x ∼[ k ] g x) →
(xs >>= f) ∼[ k ] (ys >>= g)
>>=-cong xs≈ys f≈g {x} =
x ∈ (xs >>= f) ↔⟨ SK-sym >>=↔ ⟩
Any (λ y → x ∈ f y) xs ∼⟨ Any-cong (λ x → f≈g x) xs≈ys ⟩
Any (λ y → x ∈ g y) ys ↔⟨ >>=↔ ⟩
x ∈ (ys >>= g) ∎
where open Related.EquationalReasoning
------------------------------------------------------------------------
-- _⊛_
module _ {ℓ k} {A B : Set ℓ} {fs gs : List (A → B)} {xs ys} where
⊛-cong : fs ∼[ k ] gs → xs ∼[ k ] ys → (fs ⊛ xs) ∼[ k ] (gs ⊛ ys)
⊛-cong fs≈gs xs≈ys =
>>=-cong fs≈gs λ f →
>>=-cong xs≈ys λ x →
_ ∎
where open Related.EquationalReasoning
------------------------------------------------------------------------
-- _⊗_
module _ {ℓ k} {A B : Set ℓ} {xs₁ xs₂ : List A} {ys₁ ys₂ : List B} where
⊗-cong : xs₁ ∼[ k ] xs₂ → ys₁ ∼[ k ] ys₂ →
(xs₁ ⊗ ys₁) ∼[ k ] (xs₂ ⊗ ys₂)
⊗-cong xs₁≈xs₂ ys₁≈ys₂ =
⊛-cong (⊛-cong (Ord.refl {x = [ _,_ ]}) xs₁≈xs₂) ys₁≈ys₂
------------------------------------------------------------------------
-- Other properties
-- _++_ and [] form a commutative monoid, with either bag or set
-- equality as the underlying equality.
commutativeMonoid : ∀ {a} → Symmetric-kind → Set a →
CommutativeMonoid _ _
commutativeMonoid {a} k A = record
{ Carrier = List A
; _≈_ = _∼[ ⌊ k ⌋ ]_
; _∙_ = _++_
; ε = []
; isCommutativeMonoid = record
{ isSemigroup = record
{ isMagma = record
{ isEquivalence = Eq.isEquivalence
; ∙-cong = ++-cong
}
; assoc = λ xs ys zs →
Eq.reflexive (LP.++-assoc xs ys zs)
}
; identityˡ = λ xs {x} → x ∈ xs ∎
; comm = λ xs ys {x} →
x ∈ xs ++ ys ↔⟨ ++↔++ xs ys ⟩
x ∈ ys ++ xs ∎
}
}
where open Related.EquationalReasoning
-- The only list which is bag or set equal to the empty list (or a
-- subset or subbag of the list) is the empty list itself.
empty-unique : ∀ {k a} {A : Set a} {xs : List A} →
xs ∼[ ⌊ k ⌋→ ] [] → xs ≡ []
empty-unique {xs = []} _ = refl
empty-unique {xs = _ ∷ _} ∷∼[] with ⇒→ ∷∼[] (here refl)
... | ()
-- _++_ is idempotent (under set equality).
++-idempotent : ∀ {a} {A : Set a} → Idempotent {A = List A} _∼[ set ]_ _++_
++-idempotent {a} xs {x} =
x ∈ xs ++ xs ∼⟨ FE.equivalence ([ id , id ]′ ∘ _⟨$⟩_ (Inverse.from $ ++↔))
(_⟨$⟩_ (Inverse.to $ ++↔) ∘ inj₁) ⟩
x ∈ xs ∎
where open Related.EquationalReasoning
-- The list monad's bind distributes from the left over _++_.
>>=-left-distributive :
∀ {ℓ} {A B : Set ℓ} (xs : List A) {f g : A → List B} →
(xs >>= λ x → f x ++ g x) ∼[ bag ] (xs >>= f) ++ (xs >>= g)
>>=-left-distributive {ℓ} xs {f} {g} {y} =
y ∈ (xs >>= λ x → f x ++ g x) ↔⟨ SK-sym $ >>=↔ ⟩
Any (λ x → y ∈ f x ++ g x) xs ↔⟨ SK-sym (Any-cong (λ _ → ++↔) (_ ∎)) ⟩
Any (λ x → y ∈ f x ⊎ y ∈ g x) xs ↔⟨ SK-sym $ ⊎↔ ⟩
(Any (λ x → y ∈ f x) xs ⊎ Any (λ x → y ∈ g x) xs) ↔⟨ >>=↔ ⟨ _⊎-cong_ ⟩ >>=↔ ⟩
(y ∈ (xs >>= f) ⊎ y ∈ (xs >>= g)) ↔⟨ ++↔ ⟩
y ∈ (xs >>= f) ++ (xs >>= g) ∎
where open Related.EquationalReasoning
-- The same applies to _⊛_.
⊛-left-distributive :
∀ {ℓ} {A B : Set ℓ} (fs : List (A → B)) xs₁ xs₂ →
(fs ⊛ (xs₁ ++ xs₂)) ∼[ bag ] (fs ⊛ xs₁) ++ (fs ⊛ xs₂)
⊛-left-distributive {B = B} fs xs₁ xs₂ = begin
fs ⊛ (xs₁ ++ xs₂) ≡⟨⟩
(fs >>= λ f → xs₁ ++ xs₂ >>= return ∘ f) ≡⟨ (MP.cong (refl {x = fs}) λ f →
MP.right-distributive xs₁ xs₂ (return ∘ f)) ⟩
(fs >>= λ f → (xs₁ >>= return ∘ f) ++
(xs₂ >>= return ∘ f)) ≈⟨ >>=-left-distributive fs ⟩
(fs >>= λ f → xs₁ >>= return ∘ f) ++
(fs >>= λ f → xs₂ >>= return ∘ f) ≡⟨⟩
(fs ⊛ xs₁) ++ (fs ⊛ xs₂) ∎
where open EqR ([ bag ]-Equality B)
private
-- If x ∷ xs is set equal to x ∷ ys, then xs and ys are not
-- necessarily set equal.
¬-drop-cons : ∀ {a} {A : Set a} {x : A} →
¬ (∀ {xs ys} → x ∷ xs ∼[ set ] x ∷ ys → xs ∼[ set ] ys)
¬-drop-cons {x = x} drop-cons
with FE.Equivalence.to x∼[] ⟨$⟩ here refl
where
x,x≈x : (x ∷ x ∷ []) ∼[ set ] [ x ]
x,x≈x = ++-idempotent [ x ]
x∼[] : [ x ] ∼[ set ] []
x∼[] = drop-cons x,x≈x
... | ()
-- However, the corresponding property does hold for bag equality.
drop-cons : ∀ {a} {A : Set a} {x : A} {xs ys} →
x ∷ xs ∼[ bag ] x ∷ ys → xs ∼[ bag ] ys
drop-cons {A = A} {x} {xs} {ys} x∷xs≈x∷ys =
⊎-left-cancellative
(∼→⊎↔⊎ x∷xs≈x∷ys)
(lemma x∷xs≈x∷ys)
(lemma (SK-sym x∷xs≈x∷ys))
where
-- TODO: Some of the code below could perhaps be exposed to users.
-- Finds the element at the given position.
index : ∀ {a} {A : Set a} (xs : List A) → Fin (length xs) → A
index [] ()
index (x ∷ xs) zero = x
index (x ∷ xs) (suc i) = index xs i
-- List membership can be expressed as "there is an index which
-- points to the element".
∈-index : ∀ {a} {A : Set a} {z}
(xs : List A) → z ∈ xs ↔ ∃ λ i → z ≡ index xs i
∈-index {z = z} [] =
z ∈ [] ↔⟨ SK-sym ⊥↔Any[] ⟩
⊥ ↔⟨ SK-sym $ inverse (λ { (() , _) }) (λ ()) (λ { (() , _) }) (λ ()) ⟩
(∃ λ (i : Fin 0) → z ≡ index [] i) ∎
where
open Related.EquationalReasoning
∈-index {z = z} (x ∷ xs) =
z ∈ x ∷ xs ↔⟨ SK-sym (∷↔ _) ⟩
(z ≡ x ⊎ z ∈ xs) ↔⟨ K-refl ⊎-cong ∈-index xs ⟩
(z ≡ x ⊎ ∃ λ i → z ≡ index xs i) ↔⟨ SK-sym $ inverse (λ { (zero , p) → inj₁ p; (suc i , p) → inj₂ (i , p) })
(λ { (inj₁ p) → zero , p; (inj₂ (i , p)) → suc i , p })
(λ { (zero , _) → refl; (suc _ , _) → refl })
(λ { (inj₁ _) → refl; (inj₂ _) → refl }) ⟩
(∃ λ i → z ≡ index (x ∷ xs) i) ∎
where
open Related.EquationalReasoning
-- The index which points to the element.
index-of : ∀ {a} {A : Set a} {z} {xs : List A} →
z ∈ xs → Fin (length xs)
index-of = proj₁ ∘ (Inverse.to (∈-index _) ⟨$⟩_)
-- The type ∃ λ z → z ∈ xs is isomorphic to Fin n, where n is the
-- length of xs.
--
-- <NAME> pointed out that (a variant of) this statement is
-- a generalisation of the fact that singletons are contractible.
Fin-length : ∀ {a} {A : Set a}
(xs : List A) → (∃ λ z → z ∈ xs) ↔ Fin (length xs)
Fin-length xs =
(∃ λ z → z ∈ xs) ↔⟨ Σ.cong K-refl (∈-index xs) ⟩
(∃ λ z → ∃ λ i → z ≡ index xs i) ↔⟨ ∃∃↔∃∃ _ ⟩
(∃ λ i → ∃ λ z → z ≡ index xs i) ↔⟨ Σ.cong K-refl (inverse _ (λ _ → _ , refl) (λ { (_ , refl) → refl }) (λ _ → refl)) ⟩
(Fin (length xs) × Lift _ ⊤) ↔⟨ ×-identityʳ _ _ ⟩
Fin (length xs) ∎
where
open Related.EquationalReasoning
-- From this lemma we get that lists which are bag equivalent have
-- related lengths.
Fin-length-cong : ∀ {a} {A : Set a} {xs ys : List A} →
xs ∼[ bag ] ys → Fin (length xs) ↔ Fin (length ys)
Fin-length-cong {xs = xs} {ys} xs≈ys =
Fin (length xs) ↔⟨ SK-sym $ Fin-length xs ⟩
∃ (λ z → z ∈ xs) ↔⟨ Σ.cong K-refl xs≈ys ⟩
∃ (λ z → z ∈ ys) ↔⟨ Fin-length ys ⟩
Fin (length ys) ∎
where
open Related.EquationalReasoning
-- The index-of function commutes with applications of certain
-- inverses.
index-of-commutes :
∀ {a} {A : Set a} {z : A} {xs ys} →
(xs≈ys : xs ∼[ bag ] ys) (p : z ∈ xs) →
index-of (Inverse.to xs≈ys ⟨$⟩ p) ≡
Inverse.to (Fin-length-cong xs≈ys) ⟨$⟩ index-of p
index-of-commutes {z = z} {xs} {ys} xs≈ys p =
index-of (to xs≈ys ⟨$⟩ p) ≡⟨ lemma z p ⟩
index-of (to xs≈ys ⟨$⟩ proj₂
(from (Fin-length xs) ⟨$⟩ (to (Fin-length xs) ⟨$⟩ (z , p)))) ≡⟨⟩
index-of (proj₂ (Prod.map id (to xs≈ys ⟨$⟩_)
(from (Fin-length xs) ⟨$⟩ (to (Fin-length xs) ⟨$⟩ (z , p))))) ≡⟨⟩
to (Fin-length ys) ⟨$⟩ Prod.map id (to xs≈ys ⟨$⟩_)
(from (Fin-length xs) ⟨$⟩ index-of p) ≡⟨⟩
to (Fin-length-cong xs≈ys) ⟨$⟩ index-of p ∎
where
open P.≡-Reasoning
open Inverse
lemma :
∀ z p →
index-of (to xs≈ys ⟨$⟩ p) ≡
index-of (to xs≈ys ⟨$⟩ proj₂
(from (Fin-length xs) ⟨$⟩ (to (Fin-length xs) ⟨$⟩ (z , p))))
lemma z p with to (Fin-length xs) ⟨$⟩ (z , p)
| left-inverse-of (Fin-length xs) (z , p)
lemma .(index xs i) .(from (∈-index xs) ⟨$⟩ (i , refl)) | i | refl =
refl
-- Bag equivalence isomorphisms preserve index equality. Note that
-- this means that, even if the underlying equality is proof
-- relevant, a bag equivalence isomorphism cannot map two distinct
-- proofs, that point to the same position, to different positions.
index-equality-preserved :
∀ {a} {A : Set a} {z : A} {xs ys} {p q : z ∈ xs}
(xs≈ys : xs ∼[ bag ] ys) →
index-of p ≡ index-of q →
index-of (Inverse.to xs≈ys ⟨$⟩ p) ≡
index-of (Inverse.to xs≈ys ⟨$⟩ q)
index-equality-preserved {p = p} {q} xs≈ys eq =
index-of (Inverse.to xs≈ys ⟨$⟩ p) ≡⟨ index-of-commutes xs≈ys p ⟩
Inverse.to (Fin-length-cong xs≈ys) ⟨$⟩ index-of p ≡⟨ P.cong (Inverse.to (Fin-length-cong xs≈ys) ⟨$⟩_) eq ⟩
Inverse.to (Fin-length-cong xs≈ys) ⟨$⟩ index-of q ≡⟨ P.sym $ index-of-commutes xs≈ys q ⟩
index-of (Inverse.to xs≈ys ⟨$⟩ q) ∎
where
open P.≡-Reasoning
-- The old inspect idiom.
inspect : ∀ {a} {A : Set a} (x : A) → ∃ (x ≡_)
inspect x = x , refl
-- A function is "well-behaved" if any "left" element which is the
-- image of a "right" element is in turn not mapped to another
-- "left" element.
Well-behaved : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
(A ⊎ B → A ⊎ C) → Set _
Well-behaved f =
∀ {b a a′} → f (inj₂ b) ≡ inj₁ a → f (inj₁ a) ≢ inj₁ a′
-- The type constructor _⊎_ is left cancellative for certain
-- well-behaved inverses.
⊎-left-cancellative :
∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
(f : (A ⊎ B) ↔ (A ⊎ C)) →
Well-behaved (Inverse.to f ⟨$⟩_) →
Well-behaved (Inverse.from f ⟨$⟩_) →
B ↔ C
⊎-left-cancellative {A = A} = λ inv to-hyp from-hyp → inverse
(g (to inv ⟨$⟩_) to-hyp)
(g (from inv ⟨$⟩_) from-hyp)
(g∘g inv to-hyp from-hyp)
(g∘g (SK-sym inv) from-hyp to-hyp)
where
open Inverse
module _
{a b c} {A : Set a} {B : Set b} {C : Set c}
(f : A ⊎ B → A ⊎ C)
(hyp : Well-behaved f)
where
mutual
g : B → C
g b = g′ (inspect (f (inj₂ b)))
g′ : ∀ {b} → ∃ (f (inj₂ b) ≡_) → C
g′ (inj₂ c , _) = c
g′ (inj₁ a , eq) = g″ eq (inspect (f (inj₁ a)))
g″ : ∀ {a b} →
f (inj₂ b) ≡ inj₁ a → ∃ (f (inj₁ a) ≡_) → C
g″ _ (inj₂ c , _) = c
g″ eq₁ (inj₁ _ , eq₂) = ⊥-elim $ hyp eq₁ eq₂
g∘g : ∀ {b c} {B : Set b} {C : Set c}
(f : (A ⊎ B) ↔ (A ⊎ C)) →
(to-hyp : Well-behaved (to f ⟨$⟩_)) →
(from-hyp : Well-behaved (from f ⟨$⟩_)) →
∀ b → g (from f ⟨$⟩_) from-hyp (g (to f ⟨$⟩_) to-hyp b) ≡ b
g∘g f to-hyp from-hyp b = g∘g′
where
open P.≡-Reasoning
g∘g′ : g (from f ⟨$⟩_) from-hyp (g (to f ⟨$⟩_) to-hyp b) ≡ b
g∘g′ with inspect (to f ⟨$⟩ inj₂ b)
g∘g′ | inj₂ c , eq₁ with inspect (from f ⟨$⟩ inj₂ c)
g∘g′ | inj₂ c , eq₁ | inj₂ b′ , eq₂ = inj₂-injective (
inj₂ b′ ≡⟨ P.sym eq₂ ⟩
from f ⟨$⟩ inj₂ c ≡⟨ to-from f eq₁ ⟩
inj₂ b ∎)
g∘g′ | inj₂ c , eq₁ | inj₁ a , eq₂ with
inj₁ a ≡⟨ P.sym eq₂ ⟩
from f ⟨$⟩ inj₂ c ≡⟨ to-from f eq₁ ⟩
inj₂ b ∎
... | ()
g∘g′ | inj₁ a , eq₁ with inspect (to f ⟨$⟩ inj₁ a)
g∘g′ | inj₁ a , eq₁ | inj₁ a′ , eq₂ = ⊥-elim $ to-hyp eq₁ eq₂
g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ with inspect (from f ⟨$⟩ inj₂ c)
g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₂ b′ , eq₃ with
inj₁ a ≡⟨ P.sym $ to-from f eq₂ ⟩
from f ⟨$⟩ inj₂ c ≡⟨ eq₃ ⟩
inj₂ b′ ∎
... | ()
g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ with inspect (from f ⟨$⟩ inj₁ a′)
g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ | inj₁ a″ , eq₄ = ⊥-elim $ from-hyp eq₃ eq₄
g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ | inj₂ b′ , eq₄ = inj₂-injective (
let lemma =
inj₁ a′ ≡⟨ P.sym eq₃ ⟩
from f ⟨$⟩ inj₂ c ≡⟨ to-from f eq₂ ⟩
inj₁ a ∎
in
inj₂ b′ ≡⟨ P.sym eq₄ ⟩
from f ⟨$⟩ inj₁ a′ ≡⟨ P.cong ((from f ⟨$⟩_) ∘ inj₁) $ inj₁-injective lemma ⟩
from f ⟨$⟩ inj₁ a ≡⟨ to-from f eq₁ ⟩
inj₂ b ∎)
-- Some final lemmas.
∼→⊎↔⊎ :
∀ {x : A} {xs ys} →
x ∷ xs ∼[ bag ] x ∷ ys →
∀ {z} → (z ≡ x ⊎ z ∈ xs) ↔ (z ≡ x ⊎ z ∈ ys)
∼→⊎↔⊎ {x} {xs} {ys} x∷xs≈x∷ys {z} =
(z ≡ x ⊎ z ∈ xs) ↔⟨ ∷↔ _ ⟩
z ∈ x ∷ xs ↔⟨ x∷xs≈x∷ys ⟩
z ∈ x ∷ ys ↔⟨ SK-sym (∷↔ _) ⟩
(z ≡ x ⊎ z ∈ ys) ∎
where
open Related.EquationalReasoning
lemma : ∀ {xs ys} (inv : x ∷ xs ∼[ bag ] x ∷ ys) {z} →
Well-behaved (Inverse.to (∼→⊎↔⊎ inv {z}) ⟨$⟩_)
lemma {xs} inv {b = z∈xs} {a = p} {a′ = q} hyp₁ hyp₂ with
zero ≡⟨⟩
index-of {xs = x ∷ xs} (here p) ≡⟨⟩
index-of {xs = x ∷ xs} (to (∷↔ _) ⟨$⟩ inj₁ p) ≡⟨ P.cong (index-of ∘ (to (∷↔ (_ ≡_)) ⟨$⟩_)) $ P.sym $
to-from (∼→⊎↔⊎ inv) {x = inj₁ p} hyp₂ ⟩
index-of {xs = x ∷ xs} (to (∷↔ _) ⟨$⟩ (from (∼→⊎↔⊎ inv) ⟨$⟩ inj₁ q)) ≡⟨ P.cong index-of $
right-inverse-of (∷↔ _) (from inv ⟨$⟩ here q) ⟩
index-of {xs = x ∷ xs} (to (SK-sym inv) ⟨$⟩ here q) ≡⟨ index-equality-preserved (SK-sym inv) refl ⟩
index-of {xs = x ∷ xs} (to (SK-sym inv) ⟨$⟩ here p) ≡⟨ P.cong index-of $ P.sym $
right-inverse-of (∷↔ _) (from inv ⟨$⟩ here p) ⟩
index-of {xs = x ∷ xs} (to (∷↔ _) ⟨$⟩ (from (∼→⊎↔⊎ inv) ⟨$⟩ inj₁ p)) ≡⟨ P.cong (index-of ∘ (to (∷↔ (_ ≡_)) ⟨$⟩_)) $
to-from (∼→⊎↔⊎ inv) {x = inj₂ z∈xs} hyp₁ ⟩
index-of {xs = x ∷ xs} (to (∷↔ _) ⟨$⟩ inj₂ z∈xs) ≡⟨⟩
index-of {xs = x ∷ xs} (there z∈xs) ≡⟨⟩
suc (index-of {xs = xs} z∈xs) ∎
where
open Inverse
open P.≡-Reasoning
... | ()
|
alloy4fun_models/trainstlt/models/8/xzoeJzjNRveTbGj5P.als
|
Kaixi26/org.alloytools.alloy
| 0 |
4144
|
<reponame>Kaixi26/org.alloytools.alloy
open main
pred idxzoeJzjNRveTbGj5P_prop9 {
all t:Train | before no t.pos and eventually ( some t.pos & Entry)
}
pred __repair { idxzoeJzjNRveTbGj5P_prop9 }
check __repair { idxzoeJzjNRveTbGj5P_prop9 <=> prop9o }
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_21829_158.asm
|
ljhsiun2/medusa
| 9 |
87661
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x9682, %rdx
nop
nop
nop
nop
nop
inc %r9
mov $0x6162636465666768, %r13
movq %r13, %xmm7
vmovups %ymm7, (%rdx)
nop
add %r10, %r10
lea addresses_A_ht+0x17178, %r13
nop
nop
nop
nop
nop
inc %rdi
mov (%r13), %r14w
nop
inc %r9
lea addresses_UC_ht+0xf718, %rsi
lea addresses_WC_ht+0xc288, %rdi
nop
nop
nop
cmp %r13, %r13
mov $43, %rcx
rep movsb
nop
nop
nop
nop
cmp $15000, %rcx
lea addresses_WC_ht+0x101a8, %r10
nop
nop
cmp $35694, %r9
movw $0x6162, (%r10)
nop
nop
add %r13, %r13
lea addresses_D_ht+0x6778, %r13
sub %r14, %r14
mov (%r13), %rdi
nop
nop
cmp $4931, %r9
lea addresses_D_ht+0x1b8f8, %rcx
nop
xor $21617, %rsi
movb (%rcx), %r14b
nop
nop
add $26786, %rdx
lea addresses_UC_ht+0x278, %rsi
lea addresses_WT_ht+0x1c928, %rdi
nop
nop
nop
nop
nop
sub %rdx, %rdx
mov $72, %rcx
rep movsw
nop
nop
nop
nop
nop
dec %r14
lea addresses_D_ht+0xb990, %rcx
nop
nop
nop
nop
nop
cmp %r10, %r10
mov $0x6162636465666768, %rdi
movq %rdi, (%rcx)
nop
nop
sub $56803, %r13
lea addresses_WC_ht+0x10778, %rsi
lea addresses_normal_ht+0x72f8, %rdi
nop
nop
nop
nop
add %r13, %r13
mov $15, %rcx
rep movsb
nop
nop
nop
sub $48819, %rsi
lea addresses_UC_ht+0x153f8, %r10
nop
nop
nop
and $50455, %rsi
movw $0x6162, (%r10)
nop
inc %rsi
lea addresses_UC_ht+0x10d68, %rsi
lea addresses_D_ht+0xa778, %rdi
clflush (%rsi)
nop
and %r13, %r13
mov $67, %rcx
rep movsl
nop
nop
nop
nop
nop
sub %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
// Load
mov $0xb78, %rsi
nop
nop
nop
nop
nop
add %r12, %r12
movups (%rsi), %xmm2
vpextrq $0, %xmm2, %r10
nop
nop
nop
add $57164, %r10
// Store
lea addresses_PSE+0x13178, %rdi
clflush (%rdi)
nop
nop
add $2291, %rcx
mov $0x5152535455565758, %r10
movq %r10, %xmm6
movups %xmm6, (%rdi)
nop
nop
nop
nop
and $61432, %rbp
// Store
lea addresses_WC+0x179b8, %rbp
xor $23656, %rdi
mov $0x5152535455565758, %r10
movq %r10, %xmm5
and $0xffffffffffffffc0, %rbp
movntdq %xmm5, (%rbp)
nop
nop
nop
nop
nop
and $11843, %r9
// Store
lea addresses_RW+0x1b178, %rsi
sub $40336, %r12
movb $0x51, (%rsi)
nop
cmp $269, %rdi
// Store
lea addresses_normal+0xb142, %rsi
nop
nop
nop
nop
nop
add $53614, %rbp
mov $0x5152535455565758, %r12
movq %r12, %xmm6
movups %xmm6, (%rsi)
nop
nop
nop
nop
cmp $44480, %rsi
// Faulty Load
lea addresses_D+0x9778, %rsi
nop
add $41715, %r9
movups (%rsi), %xmm5
vpextrq $1, %xmm5, %r12
lea oracles, %rcx
and $0xff, %r12
shlq $12, %r12
mov (%rcx,%r12,1), %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': True, 'type': 'addresses_D', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_P', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_PSE', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': True, 'type': 'addresses_WC', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_RW', 'size': 1, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 16, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 7, 'NT': True, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
unittests/ASM/H0F3A/0_66_DF.asm
|
cobalt2727/FEX
| 628 |
5540
|
%ifdef CONFIG
{
"RegData": {
"XMM0": ["0x6363636363636363", "0x6363636363636363"],
"XMM1": ["0x1616161616161616", "0x1616161616161616"],
"XMM2": ["0x7c6363636363637c", "0x7c6363636363637c"],
"XMM3": ["0x1616161616161616", "0x7c6363636363637c"],
"XMM4": ["0x6363636263636363", "0x6363636263636363"],
"XMM5": ["0x1616161416161616", "0x1616161416161616"],
"XMM6": ["0x7c6363606363637c", "0x7c6363606363637c"],
"XMM7": ["0x1616161216161616", "0x7c6363676363637c"],
"XMM8": ["0x6363636663636363", "0x6363636663636363"],
"XMM9": ["0x1616161016161616", "0x1616161016161616"],
"XMM10": ["0x7c6363646363637c", "0x7c6363646363637c"],
"XMM11": ["0x1616161e16161616", "0x7c63636b6363637c"],
"XMM12": ["0x6363636a63636363", "0x6363636a63636363"],
"XMM13": ["0x1616161c16161616", "0x1616161c16161616"],
"XMM14": ["0x7c6363686363637c", "0x7c6363686363637c"],
"XMM15": ["0x1616161a16161616", "0x7c63636f6363637c"]
}
}
%endif
mov rdx, 0xe0000000
mov rax, 0x0000000000000000
mov [rdx + 8 * 0], rax
mov [rdx + 8 * 1], rax
mov rax, 0xFFFFFFFFFFFFFFFF
mov [rdx + 8 * 2], rax
mov [rdx + 8 * 3], rax
mov rax, 0x0000000100000001
mov [rdx + 8 * 4], rax
mov [rdx + 8 * 5], rax
mov rax, 0xFFFFFFFF00000000
mov [rdx + 8 * 6], rax
mov rax, 0x00000001FFFFFFFF
mov [rdx + 8 * 7], rax
mov rax, 0x0202020202020202
mov [rdx + 8 * 8], rax
mov rax, 0x0303030303030303
mov [rdx + 8 * 9], rax
aeskeygenassist xmm0, [rdx + 8 * 0], 0
aeskeygenassist xmm1, [rdx + 8 * 2], 0
aeskeygenassist xmm2, [rdx + 8 * 4], 0
aeskeygenassist xmm3, [rdx + 8 * 6], 0
aeskeygenassist xmm4, [rdx + 8 * 0], 1
aeskeygenassist xmm5, [rdx + 8 * 2], 2
aeskeygenassist xmm6, [rdx + 8 * 4], 3
aeskeygenassist xmm7, [rdx + 8 * 6], 4
aeskeygenassist xmm8, [rdx + 8 * 0], 5
aeskeygenassist xmm9, [rdx + 8 * 2], 6
aeskeygenassist xmm10, [rdx + 8 * 4], 7
aeskeygenassist xmm11, [rdx + 8 * 6], 8
aeskeygenassist xmm12, [rdx + 8 * 0], 9
aeskeygenassist xmm13, [rdx + 8 * 2], 10
aeskeygenassist xmm14, [rdx + 8 * 4], 11
aeskeygenassist xmm15, [rdx + 8 * 6], 12
hlt
|
_lessons/07-solving/pigeonhole.als
|
HanielB/2021.1-fm
| 0 |
2913
|
<gh_stars>0
-- The pigeonhole problem
sig Hole {}
sig Pigeon {
nest : set Hole
}
fact {
all p : Pigeon | one p.nest
all h : Hole | lone nest.h
}
run {}
check { (no h : Hole | #nest.h > 1) and (no p : Pigeon | no p.nest)} for 5
pred hasSubNest {
some subNest : Pigeon -> Hole | some subNest and #subNest < #nest and subNest in nest
}
run {hasSubNest} for exactly 3 Hole, exactly 3 Pigeon
|
oeis/293/A293637.asm
|
neoneye/loda-programs
| 11 |
168755
|
<gh_stars>10-100
; A293637: a(n) is the least integer k such that k/Fibonacci(n) > 1/5.
; Submitted by <NAME>(m1)
; 0,1,1,1,1,1,2,3,5,7,11,18,29,47,76,122,198,320,517,837,1353,2190,3543,5732,9274,15005,24279,39284,63563,102846,166408,269254,435662,704916,1140578,1845493,2986071,4831564,7817634,12649198,20466831,33116029,53582860,86698888,140281747,226980634,367262381,594243015,961505396,1555748410,2517253805,4073002215,6590256020,10663258235,17253514255,27916772489,45170286744,73087059233,118257345976,191344405209,309601751184,500946156393,810547907577,1311494063969,2122041971545,3433536035513,5555578007058
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
add $0,4
div $0,5
|
Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0x48.log_21829_63.asm
|
ljhsiun2/medusa
| 9 |
9742
|
<filename>Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0x48.log_21829_63.asm<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x1dbde, %r9
nop
nop
nop
nop
nop
xor $48561, %rdi
movb (%r9), %bl
nop
nop
nop
nop
add $53039, %rdi
lea addresses_normal_ht+0x163fa, %r9
nop
add $24756, %rdx
movl $0x61626364, (%r9)
nop
nop
nop
cmp %rsi, %rsi
lea addresses_A_ht+0x1f9e, %r14
nop
nop
sub %rax, %rax
movb (%r14), %r9b
nop
nop
nop
nop
xor $8573, %r14
lea addresses_UC_ht+0xd456, %rsi
lea addresses_WT_ht+0x915a, %rdi
nop
nop
nop
nop
nop
cmp $5438, %rbx
mov $47, %rcx
rep movsl
nop
nop
nop
nop
nop
and %rax, %rax
lea addresses_WC_ht+0x8e2e, %rsi
lea addresses_WC_ht+0x1e806, %rdi
nop
nop
nop
nop
nop
and %r9, %r9
mov $21, %rcx
rep movsw
nop
nop
nop
nop
nop
sub %rax, %rax
lea addresses_normal_ht+0x355e, %r9
nop
nop
nop
and $44554, %r14
mov (%r9), %edx
nop
nop
nop
sub $32047, %r14
lea addresses_WT_ht+0xce9e, %rsi
nop
nop
sub $23517, %rdi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm7
vmovups %ymm7, (%rsi)
nop
nop
sub $14879, %r9
lea addresses_normal_ht+0x9016, %r14
nop
xor %rdi, %rdi
mov (%r14), %rsi
nop
nop
nop
add $42277, %rax
lea addresses_A_ht+0x831e, %rcx
nop
nop
nop
nop
nop
sub %rdx, %rdx
mov (%rcx), %r14w
nop
nop
nop
nop
add $52950, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r15
push %r9
push %rbp
push %rdx
push %rsi
// Store
mov $0x196, %rsi
sub %rbp, %rbp
movl $0x51525354, (%rsi)
nop
nop
nop
nop
nop
and $8748, %r12
// Load
lea addresses_RW+0xa79e, %rbp
nop
and $14502, %r9
mov (%rbp), %rsi
nop
nop
nop
sub $25578, %rsi
// Faulty Load
lea addresses_normal+0x6a9e, %r13
nop
xor $19071, %rbp
mov (%r13), %si
lea oracles, %r15
and $0xff, %rsi
shlq $12, %rsi
mov (%r15,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rbp
pop %r9
pop %r15
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 3, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 2, 'size': 4, 'same': True, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 8, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': True, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 7, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
ch3/src/main.asm
|
impact-eintr/x86
| 0 |
100007
|
; 显示文本
;start:
; mov ax, 0xb800
; mov ds, ax
;
; mov byte [0x00], 'A'
; mov byte [0x01], 0x0c ;黑底红字无闪烁
;
; mov byte [0x02], 's'
; mov byte [0x03], 0x04
;
; mov byte [0x04], 's'
; mov byte [0x05], 0x04
;
; mov byte [0x06], 'e'
; mov byte [0x07], 0x04
;
; mov byte [0x08], 'm'
; mov byte [0x09], 0x04
;
; mov byte [0x0a], 'b'
; mov byte [0x0b], 0x04
;
; mov byte [0x0c], 'l'
; mov byte [0x0d], 0x04
;
; mov byte [0x0e], 'y'
; mov byte [0x0f], 0x04
;
; mov byte [0x10], '.'
; mov byte [0x11], 0x04
;
;again:
; jmp near start
;
;current:
; times 510-(current-start) db 0
; db 0x55, 0xaa ; DB作为汇编语言中的伪操作命令,它用来定义操作数占用的字节数
;
;
;
; 显示数字
;start:
; mov cx, 0
; mov ds, cx
;
; ; 计算65535除以10的结果
; mov ax, 0xffff
; xor dx, dx ; 初始化被除数
;
; mov bx, 10 ; 初始化除数
;
; div bx ; AX: 商 DX: 余数
; add dl, 0x30 ; 将数字转换为数字字符
; mov [0x7c00+buffer+0], dl
;
; xor dx, dx
; div bx ; AX: 商 DX: 余数
; add dl, 0x30 ; 将数字转换为数字字符
; mov [0x7c00+buffer+1], dl
;
; xor dx, dx
; div bx ; AX: 商 DX: 余数
; add dl, 0x30 ; 将数字转换为数字字符
; mov [0x7c00+buffer+2], dl
;
; xor dx, dx
; div bx ; AX: 商 DX: 余数
; add dl, 0x30 ; 将数字转换为数字字符
; mov [0x7c00+buffer+3], dl
;
; xor dx, dx
; div bx ; AX: 商 DX: 余数
; add dl, 0x30 ; 将数字转换为数字字符
; mov [0x7c00+buffer+4], dl
;
;
; ; 转化到显存段
; mov cx, 0xb800
; mov es, cx ; es extra segment reg
;
; mov al, [0x7c00+buffer+4]
; mov [es:0x00], al ; `es:` 段超越前缀
; mov byte [es:0x01], 0x2f
;
; mov al, [0x7c00+buffer+3]
; mov [es:0x02], al
; mov byte [es:0x03], 0x2f
;
; mov al, [0x7c00+buffer+2]
; mov [es:0x04], al
; mov byte [es:0x05], 0x2f
;
; mov al, [0x7c00+buffer+1]
; mov [es:0x06], al
; mov byte [es:0x07], 0x2f
;
; mov al, [0x7c00+buffer+0]
; mov [es:0x08], al
; mov byte [es:0x09], 0x2f
;
;again:
; jmp again
;
;buffer:
; times 5 db 0 ; 临时数组
;
;current:
; times 510-(current-start) db 0
; db 0x55, 0xaa
;
;
;
mov ax,0xb800 ;指向文本模式的显示缓冲区
mov es,ax
;以下显示字符串"Label offset:"
mov byte [es:0x00],'L'
mov byte [es:0x01],0x07
mov byte [es:0x02],'a'
mov byte [es:0x03],0x07
mov byte [es:0x04],'b'
mov byte [es:0x05],0x07
mov byte [es:0x06],'e'
mov byte [es:0x07],0x07
mov byte [es:0x08],'l'
mov byte [es:0x09],0x07
mov byte [es:0x0a],' '
mov byte [es:0x0b],0x07
mov byte [es:0x0c],'o'
mov byte [es:0x0d],0x07
mov byte [es:0x0e],'f'
mov byte [es:0x0f],0x07
mov byte [es:0x10],'f'
mov byte [es:0x11],0x07
mov byte [es:0x12],'s'
mov byte [es:0x13],0x07
mov byte [es:0x14],'e'
mov byte [es:0x15],0x07
mov byte [es:0x16],'t'
mov byte [es:0x17],0x07
mov byte [es:0x18],':'
mov byte [es:0x19],0x07
mov ax,number ;取得标号number的汇编地址(段内偏移地址)
mov bx,10
;设置数据段的基地址
mov cx,cs
mov ds,cx
;求个位上的数字
mov dx,0
div bx
mov [0x7c00+number+0x00],dl ;保存个位上的数字
;求十位上的数字
xor dx,dx
div bx
mov [0x7c00+number+0x01],dl ;保存十位上的数字
;求百位上的数字
xor dx,dx
div bx
mov [0x7c00+number+0x02],dl ;保存百位上的数字
;求千位上的数字
xor dx,dx
div bx
mov [0x7c00+number+0x03],dl ;保存千位上的数字
;求万位上的数字
xor dx,dx
div bx
mov [0x7c00+number+0x04],dl ;保存万位上的数字
;以下用十进制显示标号的偏移地址
mov al,[0x7c00+number+0x04]
add al,0x30
mov [es:0x1a],al
mov byte [es:0x1b],0x04
mov al,[0x7c00+number+0x03]
add al,0x30
mov [es:0x1c],al
mov byte [es:0x1d],0x04
mov al,[0x7c00+number+0x02]
add al,0x30
mov [es:0x1e],al
mov byte [es:0x1f],0x04
mov al,[0x7c00+number+0x01]
add al,0x30
mov [es:0x20],al
mov byte [es:0x21],0x04
mov al,[0x7c00+number+0x00]
add al,0x30
mov [es:0x22],al
mov byte [es:0x23],0x04
mov byte [es:0x24],'D'
mov byte [es:0x25],0x07
infi:
jmp near infi ;无限循环
number:
db 0,0,0,0,0
times 203 db 0
db 0x55,0xaa
|
p8/upload/timer/timer.asm
|
t0ush1/ComputerOrganization
| 2 |
243183
|
.text
# li $t0, 10
# sw $t0, 0x7f50($0)
# set default values and init
li $t0, 0x1401 # 1_0100_0000_0001
mtc0 $t0, $12
li $t0, 60000000 # frequency -> preset
sw $t0, 0x7f04($0)
li $a0, 9 # 1001
li $a1, -1 # 111...111
li $s0, 0 # cnt
li $s1, 0 # pre-value
loop:
lw $t0, 0x7f50($0)
beq $s1, $t0, if_1_end
nop
sw $0, 0x7f00($0) # stop count
addu $s1, $0, $t0
addu $s0, $0, $t0 # reload
sw $0, 0x7f60($0) # LED off
sw $a0, 0x7f00($0) # restart count
if_2_end:
if_1_end:
sw $s0, 0x7f40($0) # digitalTube
j loop
nop
.ktext 0x4180
sw $a0, 0x7f00($0)
sw $0, 0x7f60($0) # LED off
bnez $s0, if_3_end
nop
addu $s0, $0, $s1 # reload
eret
if_3_end:
addiu $s0, $s0, -1
bnez $s0, if_4_end
nop
sw $a1, 0x7f60($0) # LED on
eret
if_4_end:
eret
|
test/Succeed/Prefix-Right-Postfix-Left.agda
|
shlevy/agda
| 1,989 |
2341
|
<reponame>shlevy/agda
open import Common.Equality
open import Common.Prelude renaming (Nat to ℕ)
infixr 4 _,_
infix 4 ,_
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ
,_ : {A : Set} {B : A → Set} {x : A} → B x → Σ A B
, y = _ , y
should-be-accepted : Σ ℕ λ i → Σ ℕ λ j → Σ (i ≡ j) λ _ → Σ ℕ λ k → j ≡ k
should-be-accepted = 5 , , refl , , refl
_⊕_ : ℕ → ℕ → ℕ
_⊕_ = _+_
_↓ : ℕ → ℕ
_↓ = pred
infixl 6 _⊕_
infix 6 _↓
should-also-be-accepted : ℕ
should-also-be-accepted = 1 ⊕ 0 ↓ ⊕ 1 ↓ ⊕ 1 ⊕ 1 ↓
parses-correctly : should-also-be-accepted ≡ 1
parses-correctly = refl
|
source/web/spikedog/daemon/service/services.ads
|
svn2github/matreshka
| 24 |
27340
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the <NAME>, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- Windows Service abstraction
with League.String_Vectors;
with League.Strings;
private with System;
private with Matreshka.Internals.Windows;
package Services is
pragma Preelaborate;
type Service_Status is
(Stopped,
Start_Pending,
Stop_Pending,
Running,
Continue_Pending,
Pause_Pending,
Paused);
type Status_Listener is tagged limited private;
type Status_Listener_Access is not null access all Status_Listener;
not overriding procedure Set_Status
(Self : in out Status_Listener;
Value : Service_Status);
type Service is abstract tagged limited private;
type Service_Access is access all Service'Class;
not overriding function Name (Self : Service)
return League.Strings.Universal_String is abstract;
not overriding procedure Run
(Self : in out Service;
Args : League.String_Vectors.Universal_String_Vector;
Status : Services.Status_Listener_Access) is abstract;
type Control_Kind is
(Continue, -- Notifies a paused service that it should resume.
Interrogate, -- Notifies a service to report its current status
-- information to the service control manager.
Pause, -- Notifies a service that it should pause.
Pre_Shutdown, -- Notifies a service that the system will be shutdown.
Shutdown, -- Notifies a service that the system is shutting down
-- so the service can perform cleanup tasks.
Stop); -- Notifies a service that it should stop.
not overriding procedure Control
(Self : in out Service;
Control : Services.Control_Kind;
Status : Services.Status_Listener_Access) is abstract;
-- The control handler function is intended to receive notification and
-- return immediately.
procedure Dispatch (Service : Service_Access);
private
type HANDLE is new System.Address;
subtype DWORD is Matreshka.Internals.Windows.DWORD;
SERVICE_FILE_SYSTEM_DRIVER : constant := 16#00000002#;
-- The service is a file system driver.
SERVICE_KERNEL_DRIVER : constant := 16#00000001#;
-- The service is a device driver.
SERVICE_WIN32_OWN_PROCESS : constant := 16#00000010#;
-- The service runs in its own process.
SERVICE_WIN32_SHARE_PROCESS : constant := 16#00000020#;
-- The service shares a process with other services.
SERVICE_USER_OWN_PROCESS : constant := 16#00000050#;
-- The service runs in its own process under the logged-on user account.
SERVICE_USER_SHARE_PROCESS : constant := 16#00000060#;
-- The service shares a process with one or more other services that run
-- under the logged-on user account.
SERVICE_CONTINUE_PENDING : constant := 16#00000005#;
-- The service continue is pending.
SERVICE_PAUSE_PENDING : constant := 16#00000006#;
-- The service pause is pending.
SERVICE_PAUSED : constant := 16#00000007#;
-- The service is paused.
SERVICE_RUNNING : constant := 16#00000004#;
-- The service is running.
SERVICE_START_PENDING : constant := 16#00000002#;
-- The service is starting.
SERVICE_STOP_PENDING : constant := 16#00000003#;
-- The service is stopping.
SERVICE_STOPPED : constant := 16#00000001#;
-- The service is not running.
SERVICE_CONTROL_CONTINUE : constant := 16#00000003#;
-- Notifies a paused service that it should resume.
SERVICE_CONTROL_INTERROGATE : constant := 16#00000004#;
-- Notifies a service to report its current status information to the
-- service control manager.
SERVICE_CONTROL_PAUSE : constant := 16#00000002#;
-- Notifies a service that it should pause.
SERVICE_CONTROL_PRESHUTDOWN : constant := 16#0000000F#;
-- Notifies a service that the system will be shutting down.
SERVICE_CONTROL_SHUTDOWN : constant := 16#00000005#;
-- Notifies a service that the system is shutting down so the service can
-- perform cleanup tasks.
SERVICE_CONTROL_STOP : constant := 16#00000001#;
-- Notifies a service that it should stop.
SERVICE_ACCEPT_PAUSE_CONTINUE : constant := 16#00000002#;
-- The service can be paused and continued.
-- This control code allows the service to receive SERVICE_CONTROL_PAUSE
-- and SERVICE_CONTROL_CONTINUE notifications.
SERVICE_ACCEPT_PRESHUTDOWN : constant := 16#00000100#;
-- The service can perform preshutdown tasks.
-- This control code enables the service to receive
-- SERVICE_CONTROL_PRESHUTDOWN notifications. Note that ControlService and
-- ControlServiceEx cannot send this notification; only the system can
-- send it.
-- Windows Server 2003 and Windows XP: This value is not supported.
SERVICE_ACCEPT_SHUTDOWN : constant := 16#00000004#;
-- The service is notified when system shutdown occurs.
-- This control code allows the service to receive SERVICE_CONTROL_SHUTDOWN
-- notifications. Note that ControlService and ControlServiceEx cannot send
-- this notification; only the system can send it.
SERVICE_ACCEPT_STOP : constant := 16#00000001#;
-- The service can be stopped.
-- This control code allows the service to receive SERVICE_CONTROL_STOP
-- notifications.
NO_ERROR : constant := 0;
type C_SERVICE_STATUS is record
dwServiceType : DWORD := SERVICE_WIN32_OWN_PROCESS;
dwCurrentState : DWORD := SERVICE_STOPPED;
dwControlsAccepted : DWORD := SERVICE_ACCEPT_STOP;
dwWin32ExitCode : DWORD := NO_ERROR;
dwServiceSpecificExitCode : DWORD := NO_ERROR;
dwCheckPoint : DWORD := 0;
dwWaitHint : DWORD := 0;
end record
with Convention => C;
type Status_Listener is tagged limited record
StatusHandle : HANDLE;
Status : aliased C_SERVICE_STATUS;
end record;
type Service is abstract tagged limited record
Listener : aliased Status_Listener;
end record;
end Services;
|
oeis/171/A171536.asm
|
neoneye/loda-programs
| 11 |
25913
|
<reponame>neoneye/loda-programs
; A171536: Decimal expansion of 2/sqrt(7).
; Submitted by <NAME>
; 7,5,5,9,2,8,9,4,6,0,1,8,4,5,4,4,5,4,4,2,9,0,3,3,0,7,2,4,6,8,3,6,0,1,2,1,6,3,1,5,0,2,6,2,3,7,3,7,8,4,2,9,0,8,6,7,6,6,6,6,9,8,8,3,4,3,1,6,2,5,2,0,9,2,2,9,3,8,1,7,9,3,6,0,1,1,2,2,5,3,2,7,8,4,4,1,0,3,1,6
add $0,1
mov $3,$0
mul $3,4
lpb $3
add $1,$5
mov $2,$1
add $5,4
add $5,$1
add $1,$5
add $2,$1
mul $1,2
sub $3,1
lpe
add $1,$5
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
mov $0,$1
mod $0,10
|
Appl/FileMgrs2/CommonDesktop/CShObj/cshobjReceive.asm
|
steakknife/pcgeos
| 504 |
101778
|
<gh_stars>100-1000
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: cshobjReceive.asm
AUTHOR: <NAME>
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 1/26/93 Initial version.
DESCRIPTION:
$Id: cshobjReceive.asm,v 1.2 98/06/03 13:46:30 joon Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ShellObjectCheckTransferEntry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: See if this object can receive transfers.
PASS: *ds:si - ShellObjectClass object
ds:di - ShellObjectClass instance data
es - dgroup
dx:bp - FileOperationInfoEntry
RETURN: carry clear if OK, carry SET otherwise
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 1/26/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ShellObjectCheckTransferEntry method dynamic ShellObjectClass,
MSG_SHELL_OBJECT_CHECK_TRANSFER_ENTRY
.enter
mov es, dx
test ds:[di].SOI_attrs, mask SOA_RECEIVES_TRANSFERS
jz rejectWholeBlock
mov ax, ATTR_SHELL_OBJECT_RESTRICT_TRANSFERS
call ObjVarFindData
jnc afterRestrict
call CheckInfoEntryInVarData
jc rejectEntry
afterRestrict:
mov ax, ATTR_SHELL_OBJECT_ACCEPT_TRANSFERS
call ObjVarFindData
jnc done
call CheckInfoEntryInVarData
jnc rejectEntry
clc
done:
.leave
ret
rejectWholeBlock:
; reject all items in this FQT block. Only beeps once
cmp cx, es:[FQTH_numFiles]
jne rejectSilently
rejectEntry:
mov ax, ERROR_REJECT_ENTRY
call DesktopOKError
rejectSilently:
stc
jmp done
ShellObjectCheckTransferEntry endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckInfoEntryInVarData
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if the NewDeskObjectType of the current
FileOperationInfoEntry is in the vardata pointed to by
ds:bx
CALLED BY: ShellObjectCheckTransferEntry
PASS: ds:bx - vardata entry
es:bp - FileOperationInfoEntry
RETURN: carry SET if found, clear otherwise
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 1/26/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckInfoEntryInVarData proc near
uses cx
.enter
mov ax, es:[bp].FOIE_info ; fetch the info entry's type
VarDataSizePtr ds, bx, cx ; fetch the # entries in the list
shr cx
startLoop:
cmp ax, ds:[bx]
stc
je done
loop startLoop
clc
done:
.leave
ret
CheckInfoEntryInVarData endp
|
testsuite/tests/NA17-007__Ada_units/ada05-ok-1.adb
|
AdaCore/style_checker
| 2 |
2354
|
<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . E X E C U T I V E . T H R E A D S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2005 The European Space Agency --
-- Copyright (C) 2003-2006, AdaCore --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- The executive was developed by the Real-Time Systems Group at the --
-- Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
with System.Parameters;
-- Used for Size_Type
with System.Executive.Parameters;
-- Used for Default_Stack_Size
with System.Executive.Protection;
-- Used for Enter_Kernel
-- Leave_Kernel
with System.Executive.Threads.Queues;
pragma Elaborate (System.Executive.Threads.Queues);
-- Used for Extract_From_Ready
-- Insert_At_Tail
-- Insert_At_Head
-- Change_Priority
-- Running_Thread
-- Environment_Thread_Id
with Unchecked_Conversion;
package body System.Executive.Threads is
use System.Executive.CPU_Primitives;
use System.Executive.Time;
use System.Executive.Parameters;
use type System.Address;
use type System.Parameters.Size_Type;
type Ada_05_Record is record
Anonymous_Access : access Integer;
end record;
-----------------
-- Local data --
-----------------
Main_Priority : Integer := -1;
pragma Import (C, Main_Priority, "__gl_main_priority");
---------------------
-- Local functions --
---------------------
function New_Stack
(Size : System.Parameters.Size_Type) return System.Address;
-- Create a new stack of Size bytes. If there is not enough free space
-- returns System.Null_Address.
--------------
-- Get_ATCB --
--------------
function Get_ATCB return System.Address is
begin
return System.Executive.Threads.Queues.Running_Thread.ATCB;
end Get_ATCB;
------------------
-- Get_Priority --
------------------
function Get_Priority (Id : Thread_Id) return System.Any_Priority is
begin
-- This function does not need to be protected by Enter_Kernel and
-- Leave_Kernel, because the Active_Priority value is only updated
-- by Set_Priority (atomically). Moreover, Active_Priority is
-- marked as Volatile.
return Id.Active_Priority;
end Get_Priority;
----------------
-- Initialize --
----------------
procedure Initialize is
Base_Priority : System.Any_Priority;
begin
Protection.Enter_Kernel;
-- If priority is not specified then the default priority will be used
if Main_Priority not in System.Any_Priority then
Base_Priority := System.Default_Priority;
else
Base_Priority := Main_Priority;
end if;
-- The environment thread is created. This thread executes the
-- main procedure of the program.
-- The active priority is initially equal to the base priority
Queues.Environment_Thread_Id.Base_Priority := Base_Priority;
Queues.Environment_Thread_Id.Active_Priority := Base_Priority;
-- Insert environment thread into the ready queue
Queues.Insert_At_Head (Queues.Environment_Thread_Id);
-- The currently executing thread is the environment thread
Queues.Running_Thread := Queues.Environment_Thread_Id;
-- Store stack information
Queues.Environment_Thread_Id.Top_Of_Stack := Top_Of_Environment_Stack;
Queues.Environment_Thread_Id.Stack_Size := Environment_Stack_Size;
-- Initialize the saved registers, including the program
-- counter and the stack pointer for the environment
-- thread. The stack for the environment thread must be created
-- first.
Initialize_Context
(Queues.Environment_Thread_Id.Context'Access,
System.Null_Address,
System.Null_Address,
Base_Priority,
Top_Of_Environment_Stack);
-- Initialize alarm status
Queues.Environment_Thread_Id.Alarm_Time :=
System.Executive.Time.Time'Last;
Queues.Environment_Thread_Id.Next_Alarm := Null_Thread_Id;
Protection.Leave_Kernel;
end Initialize;
---------------
-- New_Stack --
---------------
type Stack_Element is new Natural;
for Stack_Element'Size use 64;
-- The elements in the stack must be 64 bits wide to allow double
-- word data movements.
subtype Range_Of_Stack is System.Parameters.Size_Type range
1 .. (System.Executive.Parameters.Stack_Area_Size /
(Stack_Element'Size / 8) + 1);
type Stack_Space is array (Range_Of_Stack) of Stack_Element;
-- The total space for stacks is equal to the Stack_Area_Size
-- defined in System.Executive.Parameters (in bytes), rounded
-- to the upper 8 bytes bound.
Stack : Stack_Space;
for Stack'Alignment use Standard'Maximum_Alignment;
-- Object to store all the stacks. It represents the stack
-- space. The stack must be aligned to the maximum.
Index : Range_Of_Stack := Range_Of_Stack'Last;
-- Index points to the top of the free stack space
function New_Stack
(Size : System.Parameters.Size_Type) return System.Address
is
Real_Size : constant System.Parameters.Size_Type :=
(Size / (Stack_Element'Size / 8)) + 1;
-- Translate Size into bytes to eight bytes size
Old_Index : Range_Of_Stack;
begin
-- If we try to allocate more stack than available System.Null_Address
-- is returned. Otherwise return address of the top of the stack.
if (Index - Range_Of_Stack'First) < Real_Size then
return System.Null_Address;
else
Old_Index := Index;
Index := Index - Real_Size;
return Stack (Old_Index)'Address;
end if;
end New_Stack;
--------------
-- Set_ATCB --
--------------
procedure Set_ATCB (ATCB : System.Address) is
begin
-- Set_ATCB is only called in the initialization of the task, and
-- just by the owner of the thread, so there is no need of explicit
-- kernel protection when calling this function.
System.Executive.Threads.Queues.Running_Thread.ATCB := ATCB;
end Set_ATCB;
------------------
-- Set_Priority --
------------------
procedure Set_Priority (Priority : System.Any_Priority) is
begin
Protection.Enter_Kernel;
-- The Ravenscar profile does not allow dynamic priority changes. Tasks
-- change their priority only when they inherit the ceiling priority of
-- a PO (Ceiling Locking policy). Hence, the task must be running when
-- changing the priority. It is not possible to change the priority of
-- another thread within the Ravenscar profile, so that is why
-- Running_Thread is used.
-- Priority changes are only possible as a result of inheriting
-- the ceiling priority of a protected object. Hence, it can
-- never be set a priority which is lower than the base
-- priority of the thread.
pragma Assert (Priority >= Queues.Running_Thread.Base_Priority);
Queues.Change_Priority (Queues.Running_Thread, Priority);
Protection.Leave_Kernel;
end Set_Priority;
-----------
-- Sleep --
-----------
procedure Sleep is
begin
Protection.Enter_Kernel;
Queues.Extract_From_Ready (Queues.Running_Thread);
-- The currently executing thread is now blocked, and it will leave
-- the CPU when executing the Leave_Kernel procedure.
Protection.Leave_Kernel;
-- Now the thread has been awaken again and it is executing
end Sleep;
-------------------
-- Thread_Create --
-------------------
procedure Thread_Create
(Id : out Thread_Id;
Code : System.Address;
Arg : System.Address;
Priority : System.Any_Priority;
Stack_Size : System.Parameters.Size_Type)
is
Stack_Address : System.Address;
begin
Protection.Enter_Kernel;
-- Create the stack
Stack_Address := New_Stack (Stack_Size);
if Stack_Address = System.Null_Address then
-- If there is not enough stack then the thread cannot be created.
-- Return an invalid identifier for signaling the problem.
Id := Null_Thread_Id;
else
-- The first free position is assigned to the new thread
Id := Queues.New_Thread_Descriptor;
-- If the maximum number of threads supported by the kernel has been
-- exceeded, a Null_Thread_Id is returned.
if Id /= Null_Thread_Id then
-- Set the base and active priority
Id.Base_Priority := Priority;
Id.Active_Priority := Priority;
-- Insert task inside the ready list (as last within its priority)
Queues.Insert_At_Tail (Id);
-- Store stack information
Id.Top_Of_Stack := Stack_Address;
Id.Stack_Size := Stack_Size;
-- Initialize the saved registers, including the program
-- counter and stack pointer. The thread will execute the
-- Thread_Caller procedure and the stack pointer points to
-- the top of the stack assigned to the thread.
Initialize_Context
(Id.Context'Access,
Code,
Arg,
Priority,
Stack_Address);
-- Initialize alarm status
Id.Alarm_Time := System.Executive.Time.Time'Last;
Id.Next_Alarm := Null_Thread_Id;
end if;
end if;
Protection.Leave_Kernel;
end Thread_Create;
-----------------
-- Thread_Self --
-----------------
function Thread_Self return Thread_Id is
begin
-- Return the thread that is currently executing
return Queues.Running_Thread;
end Thread_Self;
------------
-- Wakeup --
------------
procedure Wakeup (Id : Thread_Id) is
begin
Protection.Enter_Kernel;
-- Insert the thread at the tail of its active priority so that the
-- thread will resume execution.
System.Executive.Threads.Queues.Insert_At_Tail (Id);
Protection.Leave_Kernel;
end Wakeup;
-----------
-- Yield --
-----------
procedure Yield is
begin
Protection.Enter_Kernel;
-- Move the currently running thread to the tail of its active priority
Queues.Extract_From_Ready (Queues.Running_Thread);
Queues.Insert_At_Tail (Queues.Running_Thread);
Protection.Leave_Kernel;
end Yield;
end System.Executive.Threads;
|
dft.ads
|
adrianhoe/adadft
| 0 |
14819
|
<filename>dft.ads
--------------------------------------------------------------------------------
-- * Spec name dft.ads
-- * Project name dfttest
-- *
-- * Version 1.0
-- * Last update 11/9/08
-- *
-- * Created by <NAME> on 11/9/08.
-- * Copyright (c) 2008 AdaStar Informatics http://adastarinformatics.com
-- * All rights reserved.
-- *
--------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Numerics;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Numerics.Generic_Complex_Types;
use Ada.Numerics;
package Dft is
type Value_Type is new Float;
type Value_Vector is array ( Positive range <> ) of Value_Type;
package T_IO renames Ada.Text_IO;
package F_IO is new Ada.Text_IO.Float_IO ( Value_Type );
package Complex_Functions is new Ada.Numerics.Generic_Elementary_Functions ( Value_Type );
package Complex_Types is new Ada.Numerics.Generic_Complex_Types ( Value_Type );
use Complex_Functions;
use Complex_Types;
type Complex_Vector is array ( Positive range <> ) of Complex;
procedure Compute ( Input : in Value_Vector;
Output : out Complex_Vector);
end Dft;
|
Sistemi e reti/Assembly/divisori.asm
|
Gabri3445/EquazioneSecondoGrado
| 0 |
91492
|
<gh_stars>0
input:
INP
STA [num]
JIZ [end]
JSP [loop]
loop:
LDA [num]
STA [numDiv]
JSP [divisori]
JMP [loop]
divisori:
LDA [num]
LDB [numDiv]
DIV
STA [divRes]
LDA [numDiv]
LDB [divRes]
MUL
STA [mulRes]
LDA [num]
LDB [mulRes]
SUB
STA [rem]
LDA [numDiv]
STA [outputNum]
LDB #1
SUB
STA [numDiv]
JIZ [input]
LDA [rem]
JIZ [output]
LDA [numDiv]
JMP [divisori]
output:
LDA [outputNum]
OUT
JMP [divisori]
end:
HLT
== VARS ==
num: LDA #1
STA [num]
numDiv: NOP
numCount: NOP
divRes: NOP
mulRes: NOP
rem: NOP
outputNum:NOP
|
programs/oeis/179/A179942 (2 cal).asm
|
jmorken/loda
| 1 |
154
|
; A179942: Number of times n appears in a 1000 x 1000 multiplication table.
; 1,2,2,3,2,4,2,4,3,4,2,6,2,4,4,5,2,6,2,6,4,4,2,8,3,4,4,6,2,8,2,6,4,4,4,9,2,4,4,8,2,8,2,6,6,4,2,10,3,6,4,6,2,8,4,8,4,4,2,12,2,4,6,7,4,8,2,6,4,8,2,12,2,4,6,6,4,8,2,10,5,4,2,12,4,4,4,8,2,12,4,6,4,4,4,12,2,6,6,9,2,8,2,8,8,4,2,12,2,8,4,10,2,8,4,6,6,4,4,16,3,4,4,6,4,12,2,8,4,8,2,12,4,4,8,8,2,8,2,12,4,4,4,15,4,4,6,6,2,12,2,8,6,8,4,12,2,4,4,12,4,10,2,6,8,4,2,16,3,8,6,6,2,8,6,10,4,4,2,18,2,8,4,8,4,8,4,6,8,8,2,14,2,4,8,9,2,12,2,12,4,4,4,12,4,4,6,10,4,16,2,6,4,4,4,16,4,4,4,12,4,8,2,12,9,4,2,12,2,8,8,8,2,12,4,6,4,8,2,20,2,6,6,6,6,8,4,8,4,8
mov $1,3
mov $1,$0
mov $2,$0
sub $2,1
mul $2,$0
mov $3,1
mov $3,$0
mov $4,$0
add $4,2
mov $4,$2
sub $2,1
mov $4,1
mov $5,$0
sub $5,$0
mov $9,0
mov $9,$5
cmp $9,0
add $5,$9
mov $8,$0
div $0,$5
sub $0,$1
mov $2,7
mov $4,$3
add $4,$1
trn $1,$0
div $1,7
mov $2,7
mov $5,0
mov $6,$3
bin $6,$4
mov $9,0
cal $1,179070 ; a(1)=a(2)=a(3)=1, a(4)=3; thereafter a(n) = a(n-1) + a(n-3).
mul $2,$6
mod $6,2
cal $3,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n.
sub $1,11
mov $2,$3
mov $5,1
mul $6,2
trn $2,$6
sub $3,2
add $2,$3
mov $4,9
mov $5,$1
mul $6,2
add $6,$0
mul $4,$6
add $4,6
add $4,$6
add $5,4
mul $5,2
mov $5,$1
mov $1,$3
add $1,2
mov $7,$8
mul $7,$8
mul $7,$8
|
test/Fail/TrustMe.agda
|
alhassy/agda
| 3 |
4502
|
<reponame>alhassy/agda<gh_stars>1-10
{-# OPTIONS --universe-polymorphism #-}
module TrustMe where
open import Common.Equality
postulate
A : Set
x y : A
eq : x ≡ y
eq = primTrustMe
does-not-evaluate-to-refl : sym (sym eq) ≡ eq
does-not-evaluate-to-refl = refl
|
assets/assembly/IA32/linux_nasm_progs/nasm_linux_ORG_CH10/procfib1.asm
|
edassis/SB-Tradutor
| 1 |
14013
|
<filename>assets/assembly/IA32/linux_nasm_progs/nasm_linux_ORG_CH10/procfib1.asm
;Fibonacci numbers (register version) PROCFIB1.ASM
;
; Objective: To compute Fibinacci number using registers
; for local variables.
; Input: Requests a positive integer from the user.
; Output: Outputs the largest Fibonacci number that
; is less than or equal to the input number.
%include "io.mac"
.DATA
prompt_msg db "Please input a positive number (>1): ",0
output_msg1 db "The largest Fibonacci number less than "
db "or equal to ",0
output_msg2 db " is ",0
.CODE
.STARTUP
PutStr prompt_msg ; request input number
GetInt DX ; DX = input number
call fibonacci
PutStr output_msg1 ; display Fibonacci number
PutInt DX
PutStr output_msg2
PutInt AX
nwln
done:
.EXIT
;-----------------------------------------------------------
;Procedure fibonacci receives an integer in DX and computes
; the largest Fibonacci number that is less than or equal to
; the input number. The Fibonacci number is returned in AX.
;-----------------------------------------------------------
.CODE
fibonacci:
push BX
; AX maintains the smaller of the last two Fibonacci
; numbers computed; BX maintains the larger one.
mov AX,1 ; initialize AX and BX to
mov BX,AX ; first two Fibonacci numbers
fib_loop:
add AX,BX ; compute next Fibonacci number
xchg AX,BX ; maintain the required order
cmp BX,DX ; compare with input number in DX
jle fib_loop ; if not greater, find next number
; AX contains the required Fibonacci number
pop BX
ret
|
src/boot/print_pm.asm
|
C-McKinley/ColbyOS
| 0 |
245986
|
<gh_stars>0
[bits 32]
VIDEO_MEMORY equ 0xb800
WHITE_ON_BLACK equ 0x0f
print_string_pm:
pusha
mov edx, VIDEO_MEMORY
print_string_pm_loop:
mov al, [ebx]
mov ah, WHITE_ON_BLACK
cmp al, 0
je done
mov [edx], ax
add ebx, 1
add edx, 2
jmp print_string_pm_loop
print_string_pm_done:
popa
ret
|
src/asf-utils.ads
|
jquorning/ada-asf
| 12 |
9745
|
<reponame>jquorning/ada-asf<gh_stars>10-100
-----------------------------------------------------------------------
-- asf-utils -- Various utility operations for ASF
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 <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.Strings;
with Ada.Strings.Unbounded;
with Util.Texts.Formats;
with Util.Beans.Objects;
package ASF.Utils is
pragma Preelaborate;
-- Add in the <b>names</b> set, the basic text attributes that can be set
-- on HTML elements (dir, lang, style, title).
procedure Set_Text_Attributes (Names : in out Util.Strings.String_Set.Set);
-- Add in the <b>names</b> set, the onXXX attributes that can be set
-- on HTML elements (accesskey, tabindex, onXXX).
procedure Set_Interactive_Attributes (Names : in out Util.Strings.String_Set.Set);
-- Add in the <b>names</b> set, the size attributes that can be set
-- on HTML elements.
procedure Set_Input_Attributes (Names : in out Util.Strings.String_Set.Set);
-- Add in the <b>names</b> set, the size attributes that can be set
-- on <textarea> elements.
procedure Set_Textarea_Attributes (Names : in out Util.Strings.String_Set.Set);
-- Add in the <b>names</b> set, the online and onunload attributes that can be set
-- on <body> elements.
procedure Set_Body_Attributes (Names : in out Util.Strings.String_Set.Set);
-- Add in the <b>names</b> set, the dir, lang attributes that can be set
-- on <head> elements.
procedure Set_Head_Attributes (Names : in out Util.Strings.String_Set.Set);
-- Add in the <b>names</b> set, the onreset and onsubmit attributes that can be set
-- on <form> elements.
procedure Set_Form_Attributes (Names : in out Util.Strings.String_Set.Set);
-- Add in the <b>names</b> set, the attributes which are specific to a link.
procedure Set_Link_Attributes (Names : in out Util.Strings.String_Set.Set);
-- Add in the <b>names</b> set, the attributes which are specific to an input file.
procedure Set_File_Attributes (Names : in out Util.Strings.String_Set.Set);
type Object_Array is array (Positive range <>) of Util.Beans.Objects.Object;
package Formats is
new Util.Texts.Formats (Stream => Ada.Strings.Unbounded.Unbounded_String,
Char => Character,
Input => String,
Value => Util.Beans.Objects.Object,
Value_List => Object_Array,
Put => Ada.Strings.Unbounded.Append,
To_Input => Util.Beans.Objects.To_String);
end ASF.Utils;
|
runtime/ravenscar-sfp-stm32f427/common/i-c.ads
|
TUM-EI-RCS/StratoX
| 12 |
13692
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- I N T E R F A C E S . C --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This version contains only the type definitions for standard interfacing
-- with C. All functions have been removed from the original spec.
package Interfaces.C is
pragma Pure;
-- Declaration's based on C's <limits.h>
CHAR_BIT : constant := 8;
SCHAR_MIN : constant := -128;
SCHAR_MAX : constant := 127;
UCHAR_MAX : constant := 255;
-- Signed and Unsigned Integers. Note that in GNAT, we have ensured that
-- the standard predefined Ada types correspond to the standard C types
type int is new Integer;
type short is new Short_Integer;
type long is new Long_Integer;
type signed_char is range SCHAR_MIN .. SCHAR_MAX;
for signed_char'Size use CHAR_BIT;
type unsigned is mod 2 ** int'Size;
type unsigned_short is mod 2 ** short'Size;
type unsigned_long is mod 2 ** long'Size;
type unsigned_char is mod (UCHAR_MAX + 1);
for unsigned_char'Size use CHAR_BIT;
subtype plain_char is unsigned_char;
type ptrdiff_t is
range -(2 ** (Standard'Address_Size - 1)) ..
+(2 ** (Standard'Address_Size - 1) - 1);
type size_t is mod 2 ** Standard'Address_Size;
-- Floating-Point
type C_float is new Float;
type double is new Standard.Long_Float;
type long_double is new Standard.Long_Long_Float;
----------------------------
-- Characters and Strings --
----------------------------
type char is new Character;
nul : constant char := char'First;
type char_array is array (size_t range <>) of aliased char;
for char_array'Component_Size use CHAR_BIT;
------------------------------------
-- Wide Character and Wide String --
------------------------------------
type wchar_t is new Wide_Character;
for wchar_t'Size use Standard'Wchar_T_Size;
wide_nul : constant wchar_t := wchar_t'First;
type wchar_array is array (size_t range <>) of aliased wchar_t;
end Interfaces.C;
|
Application Support/BBEdit/Packages/dStyle.bbpackage/Contents/Scripts/Selection/Uppercase Current Line and Move Down.applescript
|
bhdicaire/bbeditSetup
| 0 |
1889
|
-- <NAME> (@olivertaylor, http://olivertaylor.net) - Dec 2013
tell application "BBEdit"
find "^.*$" searching in text of front text window options {search mode:grep, backwards:true} with selecting match
set selection to (grep substitution of "\\U&\\n")
select insertion point after selection
end tell
|
Assignment1/src/tree/BKOOL.g4
|
ntnguyen648936/PPL-BKOOOL
| 0 |
7639
|
<reponame>ntnguyen648936/PPL-BKOOOL
/*
** - Author: <NAME>
** - ID: 1752349
*/
grammar BKOOL;
options{
language=Java;
}
program : classDecl+ EOF ;
// CLASS DECLARE
classDecl
: CLASS ID LCB classBody RCB
| CLASS ID classDeclExtension LCB classBody RCB
;
classDeclExtension
: EXTENDS ID
;
classBody
: members*
|
; // nullable list of members
members
: attrDecl
| methodDecl
;
// ATTRIBUTE MEMBER
attrDecl
: varDecl SIMI
| attrPreDecl varDecl SIMI
;
attrPreDecl
: FINAL
| STATIC
| STATIC FINAL
| FINAL STATIC
;
varDecl
: langTYPE oneAttr listAttr
;
oneAttr
: ID
| ID declAssignment
;
listAttr
: COMMA oneAttr listAttr
|
;
declAssignment
: EQUATION expr
| EQUATION arrayLit
;
// METHOD MEMBER
methodDecl
: preMethodDecl ID LP paramDecl RP blockStmt
| ID LP paramDecl RP blockStmt
;
preMethodDecl
: langTYPE
| VOID
| STATIC langTYPE
| STATIC VOID
;
paramDecl
: langTYPE oneAttr listAttr listParamDecl
|
;
listParamDecl
: SIMI langTYPE oneAttr listAttr listParamDecl
|
;
// STATEMENT
statement
: blockStmt
| singleStmt
;
blockStmt
: LCB varDeclStmt* statement* RCB
;
singleStmt
: ifStmt
| forStmt
| funcCallStmt
| assignStmt
| breakStmt
| continueStmt
| retStmt
;
/*
singleStmt
: matchStmt
| unmatchStmt
;
matchStmt
: IF expr THEN matchStmt ELSE matchStmt
| otherStmt
;
unmatchStmt
: IF expr THEN statement
| IF expr THEN matchStmt ELSE unmatchStmt
;
*/
varDeclStmt
: varDecl SIMI
| FINAL varDecl SIMI
;
assignStmt
: lhs ASSIGN expr SIMI
;
lhs
: indexExpr
| term_MemAccess DOT ID
| ID
;
ifStmt
: IF expr THEN statement (ELSE statement)*
;
forStmt
: FOR ID ASSIGN expr TO_DOWNTO expr DO statement
;
funcCallStmt
: funcCallExpr SIMI
| term_MemAccess DOT funcCallExpr SIMI
; // Method invocation
retStmt
: RETURN expr SIMI
;
continueStmt
: CONTINUE SIMI
;
breakStmt
: BREAK SIMI
;
// EXPRESSION
expr
: term_0 (LOWER | GREATER | LOWER_E | GREATER_E) term_0
| term_0
; // < > <= >=
term_0
: term_1 (EQUALS | NOT_EQUALS) term_1
| term_1
; // == !=
term_1
: term_1 (AND | OR) term_2
| term_2
; // && || @left
term_2
: term_2 (PLUS | MINUS) term_3
| term_3
; // + - (binary) @left
term_3
: term_3 (MUL | INT_DIV | FLOAT_DIV | PERCENT) term_4
| term_4
; // * / \ & @left
term_4
: term_4 CONCAT term_5
| term_5
; // ^ (concat string) @left
term_5
: NOT term_5
| term_6
; // ! (not) @right
term_6
: (PLUS | MINUS) term_6
| term_IndexExpr
; // + - (unary) @right
term_IndexExpr
: indexExpr
| term_MemAccess
; // INDEX expr
/*
indexExpr
: ID LSB expr RSB
| funcCallExpr LSB expr RSB
| term_MemAccess DOT ID LSB expr RSB
| term_MemAccess DOT funcCallExpr LSB expr RSB
;
*/
indexExpr
: term_MemAccess LSB expr RSB
;
term_MemAccess
: term_MemAccess DOT ID
| term_MemAccess DOT funcCallExpr
| term_ObjCreation
; // Member access @left
term_ObjCreation
: NEW ID LP listExpr RP
| operands
; // Object Creation @right
operands
: LP expr RP
| funcCallExpr
| INT_LIT
| FLOATLIT
| BOOL_LIT
| STRING_LIT
| NIL
| THIS
| ID
;
funcCallExpr
: ID LP listExpr RP
;
listExpr
: expr nextExpr
|
;
nextExpr
: COMMA expr nextExpr
|
;
// Literals
/*
intArray: LCB INT_LIT listIntLit RCB;
listIntLit: COMMA INT_LIT listIntLit |;
floatArray: LCB FLOAT_LIT listFloatLit RCB;
listFloatLit: COMMA FLOAT_LIT listFloatLit |;
stringArray: LCB STRING_LIT listStringLit RCB;
listStringLit: COMMA STRING_LIT listStringLit | ;
boolArray: LCB BOOLEAN_LIT listBoolLit RCB;
listBoolLit: COMMA BOOLEAN_LIT listBoolLit |;
arrayLit
: intArray
| floatArray
| stringArray
| boolArray
;
*/
arrayLit
: LCB primLit listOfPrimLit RCB
;
listOfPrimLit
: COMMA primLit listOfPrimLit
|
;
primLit
: INT_LIT
| STRING_LIT
| FLOATLIT
| BOOL_LIT
;
literal
: primLit
| arrayLit
;
arrayType
: PRIMITIVE LSB INT_LIT RSB
| ID LSB INT_LIT RSB
;
langTYPE
: PRIMITIVE
| arrayType
| ID
;
// ----------- TOKENS ---------------------------------------------
FLOATLIT: DIGIT+ (DECIMAL | EXPONENT | DECIMAL EXPONENT);
fragment DECIMAL: DOT DIGIT*; // ditgit after decimal point is optinal
fragment EXPONENT: [Ee] ('+'|'-')? DIGIT+;
INT_LIT
: [1-9] DIGIT*
| [0]
;
fragment DIGIT: [0-9];
STRING_LIT: '"' STR_CHAR* '"';
BOOL_LIT: 'true' | 'false';
PRIMITIVE
: 'int'
| 'float'
| 'boolean'
| 'string'
;
VOID: 'void';
CLASS: 'class';
FINAL: 'final';
STATIC: 'static';
EXTENDS: 'extends';
//MAIN: 'main';
NEW: 'new';
RETURN: 'return';
FOR: 'for';
THEN: 'then';
NIL: 'nil';
IF: 'if';
TO_DOWNTO: 'to' | 'downto';
DO: 'do';
BREAK: 'break';
ELSE: 'else';
CONTINUE: 'continue';
THIS: 'this';
COMMA: ',';
SIMI: ';';
LP: '(';
RP: ')';
LCB: '{';
RCB: '}';
LSB: '[';
RSB: ']';
EQUATION: '=';
PLUS: '+';
MINUS: '-';
MUL: '*';
INT_DIV: '/';
FLOAT_DIV: '\\';
ASSIGN: ':=';
LOWER_E: '<=';
GREATER_E: '>=';
NOT_EQUALS: '!=';
EQUALS : '==' ;
LOWER : '<' ;
GREATER : '>' ;
PERCENT: '%';
DOT: '.';
AND: '&&';
NOT: '!';
OR: '||';
CONCAT: '^';
ID: [_a-zA-Z][_a-zA-Z0-9]*;
// Skip comments
BLOCK_COMMENT: '/*' .*? '*/' -> skip ;
LINE_COMMENT : '#' ~[\r\n]* ([\r\n]|EOF) -> skip ;
WS : [ \t\r\n\f]+ -> skip ; // skip spaces, tabs, newlines
UNCLOSE_STRING: '"' STR_CHAR*
;
ILLEGAL_ESCAPE: '"' STR_CHAR* ESC_ILLEGAL
;
fragment STR_CHAR: ~[\n\r"\\] | ESC_ACCEPT ;
fragment ESC_ACCEPT: '\\' [btnfr"\\] ;
fragment ESC_ILLEGAL: '\\' ~[btnfr"\\] ;
ERROR_CHAR: .
;
|
programs/oeis/112/A112440.asm
|
karttu/loda
| 0 |
240143
|
<reponame>karttu/loda
; A112440: Next term is the sum of the last 10 digits in the sequence, beginning with a(10) = 9.
; 0,0,0,0,0,0,0,0,0,9,9,18,27,36,45,54,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45
sub $0,1
pow $0,2
div $0,28
mov $2,2
lpb $0,1
mov $3,$2
mov $2,1
mov $4,$3
add $4,5
mov $0,$4
lpe
trn $0,1
mov $1,$0
mul $1,9
|
math.asm
|
aaronscode/mipsCalc
| 1 |
22294
|
.globl math_pow
.include "macros.asm"
.text
# method: math_pow
# (integer) raise one number to the power of another
# arguments:
# $a0 - a value x, the base
# $a1 - a value y, the power we are raising x to
# return:
# $v0 - if y > 0 : x^y
# else : 1
math_pow:
push($ra)
# if the power we're raising it to is 0, result is 1
addi $v0, $zero, 1
ble $a1, $zero, math_pow_end
# else
move $t0, $zero # zero out the loop counter
math_pow_L:
mul $v0, $v0, $a0
inc($t0)
beq $a1, $t0, math_pow_end
j math_pow_L
math_pow_end:
return()
|
src/prototyping/term/examples/Data.agda
|
larrytheliquid/agda
| 1 |
15024
|
{-# OPTIONS --type-in-type #-}
module Data where
open import Prelude
data Sigma (A : Set)(B : A -> Set) : Set
data Sigma A B where
pair : (x : A) -> B x -> Sigma A B
fst : {A : _} {B : _} -> Sigma A B -> A
fst (pair x y) = x
snd : {A : _} {B : _} (p : Sigma A B) -> B (fst p)
snd (pair x y) = y
data Unit : Set
data Unit where
tt : Unit
Cat : Set
Cat =
Sigma Set (\ Obj ->
Sigma (Obj -> Obj -> Set) (\ Hom ->
Sigma ((X : _) -> Hom X X) (\ id ->
Sigma ((X Y Z : _) -> Hom Y Z -> Hom X Y -> Hom X Z) (\ comp ->
Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ (id Y) f == f) (\ idl ->
Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ f (id X) == f) (\ idr ->
Sigma ((W X Y Z : _)
(f : Hom W X)(g : Hom X Y)(h : Hom Y Z) ->
comp _ _ _ (comp _ _ _ h g) f ==
comp _ _ _ h (comp _ _ _ g f)) (\ assoc ->
Unit)))))))
Obj : (C : Cat) -> Set
Obj C = fst C
Hom : (C : Cat) -> Obj C -> Obj C -> Set
Hom C = fst (snd C)
id : (C : Cat) -> (X : _) -> Hom C X X
id C = fst (snd (snd C))
comp : (C : Cat) -> (X Y Z : _) -> Hom C Y Z -> Hom C X Y -> Hom C X Z
comp C = fst (snd (snd (snd C)))
idl : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->
comp C _ _ _ (id C Y) f == f
idl C = fst (snd (snd (snd (snd C))))
idr : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->
comp C _ _ _ f (id C X) == f
idr C = fst (snd (snd (snd (snd (snd C)))))
assoc : (C : Cat) ->
(W X Y Z : _) (f : Hom C W X)(g : Hom C X Y)(h : Hom C Y Z) ->
comp C _ _ _ (comp C _ _ _ h g) f ==
comp C _ _ _ h (comp C _ _ _ g f)
assoc C = fst (snd (snd (snd (snd (snd (snd C))))))
|
Server/src/main/java/server/parser/SmartMessage.g4
|
EdoCrippaOfficial/SmartMessaging
| 0 |
1914
|
grammar SmartMessage;
program : (message | priorita | invia | stats)+ exit;
priorita : 'Priorità' NUM ;
invia : 'Invia';
stats: 'Stats' (utente)?;
message : new_mess dest+ duepunti titolo corpo opzioni;
new_mess : 'Messaggio a';
dest: utente;
duepunti : ':';
titolo : 'Titolo' TESTO;
corpo : 'Corpo' TESTO;
opzioni : (cc)? (img)? (format)?;
utente: TESTO;
cc : 'CC';
img : 'Img' TESTO;
format : 'Formattazione' TESTO;
exit : EXIT;
TESTO
: '"' (~('\\'|'"') )* '"'
;
NUM
: [0-9]
;
EXIT : 'Exit';
LINE_COMMENT
: '//' (~('\n'|'\r'))* -> skip;
WS: [ \n\t\r]+ -> skip;
|
Sources/Library/vectors_xd.ads
|
ForYouEyesOnly/Space-Convoy
| 1 |
25277
|
<gh_stars>1-10
generic
type Real is digits <>;
type Coordinates is (<>);
package Vectors_xD is
pragma Elaborate_Body;
type Vector_xD is array (Coordinates) of Real;
Zero_Vector_xD : constant Vector_xD := (others => 0.0);
function Image (V : Vector_xD) return String;
function Norm (V : Vector_xD) return Vector_xD;
function "*" (Scalar : Real; V : Vector_xD) return Vector_xD;
function "*" (V : Vector_xD; Scalar : Real) return Vector_xD;
function "/" (V : Vector_xD; Scalar : Real) return Vector_xD;
function "*" (V_Left, V_Right : Vector_xD) return Real;
function Angle_Between (V_Left, V_Right : Vector_xD) return Real;
function "+" (V_Left, V_Right : Vector_xD) return Vector_xD;
function "-" (V_Left, V_Right : Vector_xD) return Vector_xD;
function "abs" (V : Vector_xD) return Real;
end Vectors_xD;
|
externals/mpir-3.0.0/mpn/x86_64w/k8/nand_n.asm
|
JaminChan/eos_win
| 12 |
14927
|
; PROLOGUE(mpn_nand_n)
; Copyright 2008 <NAME>
;
; Windows Conversion Copyright 2008 <NAME>
;
; This file is part of the MPIR Library.
; The MPIR Library is free software; you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published
; by the Free Software Foundation; either version 2.1 of the License, or (at
; your option) any later version.
; The MPIR Library is distributed in the hope that it will be useful, but
; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
; License for more details.
; You should have received a copy of the GNU Lesser General Public License
; along with the MPIR Library; see the file COPYING.LIB. If not, write
; to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
; Boston, MA 02110-1301, USA.
;
; void mpn_nand_n(mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)
; rdi rsi rdx rcx
; rcx rdx r8 r9
%include "yasm_mac.inc"
CPU Athlon64
BITS 64
%define reg_save_list rbx, rsi, rdi
FRAME_PROC mpn_nand_n, 0, reg_save_list
lea rdi, [rcx+r9*8]
lea rsi, [rdx+r9*8]
lea rdx, [r8+r9*8]
mov rcx, r9
neg rcx
add rcx, 3
jc .2
mov r8, [rdx+rcx*8-24]
mov r9, [rdx+rcx*8-16]
mov r8, [rdx+rcx*8-24]
mov r9, [rdx+rcx*8-16]
add rcx, 4
mov r10, [rdx+rcx*8-40]
mov r11, [rdx+rcx*8-32]
jc .1
xalign 16
.0:
and r8, [rsi+rcx*8-56]
not r8
and r9, [rsi+rcx*8-48]
and r10, [rsi+rcx*8-40]
and r11, [rsi+rcx*8-32]
mov [rdi+rcx*8-56], r8
not r9
not r10
mov [rdi+rcx*8-48], r9
not r11
mov r8, [rdx+rcx*8-24]
mov r9, [rdx+rcx*8-16]
mov [rdi+rcx*8-40], r10
mov [rdi+rcx*8-32], r11
add rcx, 4
mov r10, [rdx+rcx*8-40]
mov r11, [rdx+rcx*8-32]
jnc .0
.1:
and r8, [rsi+rcx*8-56]
not r8
and r9, [rsi+rcx*8-48]
and r10, [rsi+rcx*8-40]
and r11, [rsi+rcx*8-32]
mov [rdi+rcx*8-56], r8
not r9
not r10
mov [rdi+rcx*8-48], r9
not r11
mov [rdi+rcx*8-40], r10
mov [rdi+rcx*8-32], r11
.2:
cmp rcx, 2
jg .6
je .5
jp .4
.3: mov r8, [rdx-24]
and r8, [rsi-24]
not r8
mov [rdi-24], r8
.4: mov r8, [rdx-16]
and r8, [rsi-16]
not r8
mov [rdi-16], r8
.5: mov r8, [rdx-8]
and r8, [rsi-8]
not r8
mov [rdi-8], r8
.6: END_PROC reg_save_list
end
|
apple_scripts/Light.applescript
|
joaopalmeiro/dotfiles
| 0 |
4474
|
<filename>apple_scripts/Light.applescript
tell application "System Events"
repeat 32 times
key code 144
-- delay 0.02
end repeat
end tell
|
FormalAnalyzer/models/apps/LeftItOpenStill.als
|
Mohannadcse/IoTCOM_BehavioralRuleExtractor
| 0 |
4229
|
module app_LeftItOpenStill
open IoTBottomUp as base
open cap_runIn
open cap_now
open cap_contactSensor
one sig app_LeftItOpenStill extends IoTApp {
contact : one cap_contactSensor,
state : one cap_state,
} {
rules = r
//capabilities = contact + state
}
one sig cap_state extends cap_runIn {} {
attributes = cap_state_attr + cap_runIn_attr
}
abstract sig cap_state_attr extends Attribute {}
abstract sig r extends Rule {}
one sig r0 extends r {}{
triggers = r0_trig
no conditions
commands = r0_comm
}
abstract sig r0_trig extends Trigger {}
one sig r0_trig0 extends r0_trig {} {
capabilities = app_LeftItOpenStill.contact
attribute = cap_contactSensor_attr_contact
value = cap_contactSensor_attr_contact_val_open
}
abstract sig r0_comm extends Command {}
one sig r0_comm0 extends r0_comm {} {
capability = app_LeftItOpenStill.state
attribute = cap_runIn_attr_runIn
value = cap_runIn_attr_runIn_val_on
}
|
src/implementation/yaml-lexer-evaluation.adb
|
robdaemon/AdaYaml
| 32 |
26364
|
<reponame>robdaemon/AdaYaml<gh_stars>10-100
-- part of AdaYaml, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Strings.UTF_Encoding.Strings;
with Ada.Strings.UTF_Encoding.Wide_Strings;
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
with Text.Builder;
package body Yaml.Lexer.Evaluation is
-----------------------------------------------------------------------------
-- constant UTF-8 strings that may be generated from escape sequences
-----------------------------------------------------------------------------
function Next_Line return Ada.Strings.UTF_Encoding.UTF_8_String is
(Ada.Strings.UTF_Encoding.Strings.Encode ("" & Character'Val (16#85#)));
function Non_Breaking_Space return Ada.Strings.UTF_Encoding.UTF_8_String is
(Ada.Strings.UTF_Encoding.Strings.Encode ("" & Character'Val (16#A0#)));
function Line_Separator return Ada.Strings.UTF_Encoding.UTF_8_String is
(Ada.Strings.UTF_Encoding.Wide_Strings.Encode
("" & Wide_Character'Val (16#2028#)));
function Paragraph_Separator return Ada.Strings.UTF_Encoding.UTF_8_String is
(Ada.Strings.UTF_Encoding.Wide_Strings.Encode
("" & Wide_Character'Val (16#2029#)));
-----------------------------------------------------------------------------
-- implementation
-----------------------------------------------------------------------------
procedure Read_Plain_Scalar (L : in out Instance; T : out Token) is
Target : Text.Builder.Reference := Text.Builder.Create (L.Pool);
After_Newline_State : constant State_Type :=
(if L.Flow_Depth + L.Annotation_Depth = 0 then Line_Indentation'Access
else Flow_Line_Indentation'Access);
Line_Start_Pos : Positive;
begin
L.Seen_Multiline := False;
Start_Token (L);
if L.Proposed_Indentation /= -1 then
L.Indentation := L.Proposed_Indentation;
L.Proposed_Indentation := -1;
end if;
T := (Start_Pos => L.Token_Start_Mark, End_Pos => <>,
Kind => Plain_Scalar);
Multiline_Loop : loop
Line_Start_Pos := L.Pos - 1;
Inline_Loop : loop
L.Cur := Next (L);
case L.Cur is
when ' ' =>
T.End_Pos := Cur_Mark (L);
declare
Space_Start : constant Positive := L.Pos - 1;
begin
Space_Loop : loop
L.Cur := Next (L);
case L.Cur is
when Line_Feed | Carriage_Return =>
Target.Append
(L.Buffer (Line_Start_Pos .. Space_Start - 1));
exit Inline_Loop;
when End_Of_Input =>
Target.Append
(L.Buffer (Line_Start_Pos .. Space_Start - 1));
L.State := Stream_End'Access;
exit Multiline_Loop;
when '#' =>
Target.Append
(L.Buffer (Line_Start_Pos .. Space_Start - 1));
L.State := Expect_Line_End'Access;
exit Multiline_Loop;
when ':' =>
if not Next_Is_Plain_Safe (L) then
Target.Append
(L.Buffer (Line_Start_Pos .. Space_Start - 1));
L.State := Inside_Line'Access;
exit Multiline_Loop;
end if;
exit Space_Loop;
when Flow_Indicator =>
if L.Flow_Depth + L.Annotation_Depth > 0 then
Target.Append
(L.Buffer (Line_Start_Pos .. Space_Start - 1));
L.State := Inside_Line'Access;
exit Multiline_Loop;
end if;
exit Space_Loop;
when ')' =>
if L.Annotation_Depth > 0 then
Target.Append
(L.Buffer (Line_Start_Pos .. Space_Start - 1));
L.State := Inside_Line'Access;
exit Multiline_Loop;
end if;
exit Space_Loop;
when ' ' => null;
when others => exit Space_Loop;
end case;
end loop Space_Loop;
end;
when ':' =>
if not Next_Is_Plain_Safe (L) then
Target.Append
(L.Buffer (Line_Start_Pos .. L.Pos - 2));
T.End_Pos := Cur_Mark (L);
L.State := Inside_Line'Access;
exit Multiline_Loop;
end if;
when Flow_Indicator =>
if L.Flow_Depth + L.Annotation_Depth > 0 then
Target.Append
(L.Buffer (Line_Start_Pos .. L.Pos - 2));
T.End_Pos := Cur_Mark (L);
L.State := Inside_Line'Access;
exit Multiline_Loop;
end if;
when ')' =>
if L.Annotation_Depth > 0 then
Target.Append
(L.Buffer (Line_Start_Pos .. L.Pos - 2));
T.End_Pos := Cur_Mark (L);
L.State := Inside_Line'Access;
exit Multiline_Loop;
end if;
when Line_Feed | Carriage_Return =>
Target.Append
(L.Buffer (Line_Start_Pos .. L.Pos - 2));
T.End_Pos := Cur_Mark (L);
exit Inline_Loop;
when End_Of_Input =>
Target.Append
(L.Buffer (Line_Start_Pos .. L.Pos - 2));
if L.Pos /= L.Line_Start then
T.End_Pos := Cur_Mark (L);
end if;
L.State := Stream_End'Access;
exit Multiline_Loop;
when others => null;
end case;
end loop Inline_Loop;
End_Line (L);
declare
Newlines : Positive := 1;
begin
Newline_Loop : loop
case Start_Line (L) is
when Content =>
if L.Pos - L.Line_Start - 1 <= L.Indentation then
L.State := After_Newline_State;
exit Multiline_Loop;
end if;
exit Newline_Loop;
when Directives_End_Marker =>
L.State := Line_Dir_End'Access;
exit Multiline_Loop;
when Document_End_Marker =>
L.State := Line_Doc_End'Access;
exit Multiline_Loop;
when Stream_End =>
exit Multiline_Loop;
when Comment =>
End_Line (L);
L.State := Line_Start'Access;
exit Multiline_Loop;
when Newline =>
End_Line (L);
end case;
Newlines := Newlines + 1;
end loop Newline_Loop;
if
(L.Cur = ':' and then not Next_Is_Plain_Safe (L)) or else
L.Cur = '#' or else (L.Cur in Flow_Indicator and
L.Flow_Depth + L.Annotation_Depth > 0)
or else (L.Cur = ')' and L.Annotation_Depth > 0)
then
L.State := After_Newline_State;
exit Multiline_Loop;
end if;
L.Seen_Multiline := True;
if Newlines = 1 then
Target.Append (' ');
else
Target.Append ((1 .. Newlines - 1 => Line_Feed));
end if;
end;
end loop Multiline_Loop;
L.Value := Target.Lock;
end Read_Plain_Scalar;
procedure Process_Quoted_Whitespace (L : in out Instance; Init : Natural;
Target : in out Text.Builder.Reference) is
Newlines : Natural := Init;
First_Space : constant Positive := L.Pos - 1;
begin
loop
case L.Cur is
when ' ' => null;
when Line_Feed =>
Handle_LF (L);
L.Cur := L.Next;
exit;
when Carriage_Return =>
Handle_CR (L);
L.Cur := L.Next;
exit;
when others =>
Target.Append (L.Buffer (First_Space .. L.Pos - 2));
return;
end case;
L.Cur := Next (L);
end loop;
L.Seen_Multiline := True;
loop
case Start_Line (L) is
when Content | Comment => exit;
when Directives_End_Marker =>
raise Lexer_Error with "Illegal '---' within quoted scalar";
when Document_End_Marker =>
raise Lexer_Error with "Illegal '...' within quoted scalar";
when Newline => End_Line (L);
when Stream_End =>
raise Lexer_Error with
"Unexpected end of input (quoted string not closed)";
end case;
Newlines := Newlines + 1;
end loop;
if Newlines = 0 then
null;
elsif Newlines = 1 then
Target.Append (' ');
else
Target.Append ((1 .. Newlines - 1 => Line_Feed));
end if;
end Process_Quoted_Whitespace;
procedure Read_Single_Quoted_Scalar (L : in out Instance; T : out Token) is
Target : Text.Builder.Reference := Text.Builder.Create (L.Pool);
Literal_Start : Positive;
begin
L.Seen_Multiline := False;
Start_Token (L);
if L.Proposed_Indentation /= -1 then
L.Indentation := L.Proposed_Indentation;
L.Proposed_Indentation := -1;
end if;
Literal_Start := L.Pos;
L.Cur := Next (L);
loop
case L.Cur is
when End_Of_Input =>
raise Lexer_Error with
"Unexpected end of input (quoted string not closed)";
when ''' =>
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
L.Cur := Next (L);
if L.Cur = ''' then
Target.Append (''');
Literal_Start := L.Pos;
L.Cur := Next (L);
else
exit;
end if;
when ' ' | Line_Feed | Carriage_Return =>
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
Process_Quoted_Whitespace (L, 1, Target);
Literal_Start := L.Pos - 1;
when others =>
L.Cur := Next (L);
end case;
end loop;
T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L),
Kind => Single_Quoted_Scalar);
L.Value := Target.Lock;
end Read_Single_Quoted_Scalar;
subtype Hex_Code_Point is Natural range 0 .. 16#1FFFFF#;
procedure Read_Hex_Sequence (L : in out Instance; Length : Positive;
Target : in out Text.Builder.Reference) is
Char_Pos : Hex_Code_Point := 0;
Start_Pos : constant Positive := L.Pos;
begin
-- first, we make sure that this is a valid escape sequence. it is
-- important to not calculate its value directly because that may lead
-- to an overflow before we checked that the escape sequence is
-- syntactically correct. We only want to report that the value is out of
-- range if it is a valid escape sequence.
for I in 0 .. Length - 1 loop
if not (L.Buffer (Start_Pos + I) in Digit | 'a' .. 'f' | 'A' .. 'F')
then
raise Lexer_Error with
"Invalid character in hex escape sequence: " &
Escaped (L.Buffer (Start_Pos + I));
end if;
end loop;
for Exponent in reverse 0 .. Length - 1 loop
L.Cur := Next (L);
case L.Cur is
when Digit =>
Char_Pos := Char_Pos + (16 ** Exponent) *
(Character'Pos (L.Cur) - Character'Pos ('0'));
when 'a' .. 'f' =>
Char_Pos := Char_Pos + (16 ** Exponent) *
(Character'Pos (L.Cur) - Character'Pos ('a') + 10);
when 'A' .. 'F' =>
Char_Pos := Char_Pos + (16 ** Exponent) *
(Character'Pos (L.Cur) - Character'Pos ('A') + 10);
when others =>
null; -- cannot happen because of the check above
end case;
end loop;
Target.Append (Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Encode (
"" & Wide_Wide_Character'Val (Char_Pos)));
exception
when Constraint_Error =>
raise Lexer_Error with
"Invalid hex escape sequence (value too large): " &
L.Buffer (Start_Pos .. Start_Pos + Length - 1);
end Read_Hex_Sequence;
procedure Read_Double_Quoted_Scalar (L : in out Instance; T : out Token) is
Target : Text.Builder.Reference := Text.Builder.Create (L.Pool);
Literal_Start : Positive;
begin
L.Seen_Multiline := False;
Start_Token (L);
if L.Proposed_Indentation /= -1 then
L.Indentation := L.Proposed_Indentation;
L.Proposed_Indentation := -1;
end if;
Literal_Start := L.Pos;
L.Cur := Next (L);
loop
<<Handle_Char>>
case L.Cur is
when End_Of_Input =>
raise Lexer_Error with
"Unexpected end of input (quoted string not closed)";
when '\' =>
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
L.Cur := Next (L);
Literal_Start := L.Pos;
case L.Cur is
when '0' => Target.Append (Character'Val (0));
when 'a' => Target.Append (Character'Val (7));
when 'b' => Target.Append (Character'Val (8));
when 't' | Character'Val (9) =>
Target.Append (Character'Val (9));
when 'n' => Target.Append (Line_Feed);
when 'v' => Target.Append (Character'Val (11));
when 'f' => Target.Append (Character'Val (12));
when 'r' => Target.Append (Carriage_Return);
when 'e' => Target.Append (Character'Val (27));
when ' ' | '"' | '/' | '\' => Target.Append (L.Cur);
when 'N' => Target.Append (Next_Line);
when '_' => Target.Append (Non_Breaking_Space);
when 'L' => Target.Append (Line_Separator);
when 'P' => Target.Append (Paragraph_Separator);
when 'x' =>
Read_Hex_Sequence (L, 2, Target);
Literal_Start := L.Pos;
when 'u' =>
Read_Hex_Sequence (L, 4, Target);
Literal_Start := L.Pos;
when 'U' =>
Read_Hex_Sequence (L, 8, Target);
Literal_Start := L.Pos;
when Line_Feed | Carriage_Return =>
Process_Quoted_Whitespace (L, 0, Target);
Literal_Start := L.Pos - 1;
goto Handle_Char;
when others =>
raise Lexer_Error with
"Illegal character in escape sequence: " &
Escaped (L.Cur);
end case;
when '"' =>
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
exit;
when ' ' | Line_Feed | Carriage_Return =>
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
Process_Quoted_Whitespace (L, 1, Target);
Literal_Start := L.Pos - 1;
goto Handle_Char;
when others => null;
end case;
L.Cur := Next (L);
end loop;
L.Cur := Next (L);
T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L),
Kind => Double_Quoted_Scalar);
L.Value := Target.Lock;
end Read_Double_Quoted_Scalar;
procedure Read_Block_Scalar (L : in out Instance; T : out Token) is
type Chomp_Style is (Clip, Strip, Keep);
Chomp : Chomp_Style := Clip;
Indent : Natural := 0;
Separation_Lines : Natural := 0;
Content_Start : Positive;
Target : Text.Builder.Reference := Text.Builder.Create (L.Pool);
begin
Start_Token (L);
T := (Start_Pos => L.Token_Start_Mark, End_Pos => <>,
Kind => (if L.Cur = '>' then Folded_Scalar else Literal_Scalar));
-- header
loop
L.Cur := Next (L);
case L.Cur is
when '+' =>
if Chomp /= Clip then
raise Lexer_Error with "Multiple chomping indicators!";
end if;
Chomp := Keep;
when '-' =>
if Chomp /= Clip then
raise Lexer_Error with "Multiple chomping indicators!";
end if;
Chomp := Strip;
when '1' .. '9' =>
if Indent /= 0 then
raise Lexer_Error with "Multiple indentation indicators!";
end if;
Indent := Natural'Max (0, L.Indentation) +
Character'Pos (L.Cur) - Character'Pos ('0');
when ' ' =>
while L.Cur = ' ' loop
L.Cur := Next (L);
end loop;
if not (L.Cur in Comment_Or_Line_End) then
raise Lexer_Error with
"Illegal character after block scalar header: " &
Escaped (L.Cur);
end if;
exit;
when Line_End => exit;
when others =>
raise Lexer_Error with
"Illegal character in block scalar header: " & Escaped (L.Cur);
end case;
end loop;
End_Line (L);
-- determining indentation and leading empty lines
declare
Max_Leading_Spaces : Natural := 0;
begin
loop
if Indent = 0 then
while L.Cur = ' ' loop
L.Cur := Next (L);
end loop;
else
Max_Leading_Spaces := L.Line_Start + Indent;
while L.Cur = ' ' and L.Pos <= Max_Leading_Spaces loop
L.Cur := Next (L);
end loop;
end if;
case L.Cur is
when Line_Feed | Carriage_Return =>
T.End_Pos := Cur_Mark (L);
Max_Leading_Spaces :=
Natural'Max (Max_Leading_Spaces, L.Pos - 1 - L.Line_Start);
End_Line (L);
Separation_Lines := Separation_Lines + 1;
when End_Of_Input =>
L.State := Stream_End'Access;
goto End_Of_Input_Target;
when others =>
if Indent = 0 then
Indent := L.Pos - L.Line_Start - 1;
if Indent <= Indentation_Type'Max (0, L.Indentation) then
L.State := Line_Indentation'Access;
goto Finalize;
elsif Indent < Max_Leading_Spaces then
raise Lexer_Error with
"Leading all-spaces line contains too many spaces.";
end if;
elsif L.Pos - L.Line_Start - 1 < Indent then
goto Finalize;
end if;
exit;
end case;
end loop;
if Separation_Lines > 0 then
Target.Append ((1 .. Separation_Lines => Line_Feed));
end if;
end;
-- read block scalar content
Block_Content : loop
-- content of line
Content_Start := L.Pos - 1;
while not (L.Cur in Line_End) loop
L.Cur := Next (L);
end loop;
Target.Append (L.Buffer (Content_Start .. L.Pos - 2));
Separation_Lines := 0;
if L.Cur = End_Of_Input then
L.State := Stream_End'Access;
goto End_Of_Input_Target;
end if;
Separation_Lines := Separation_Lines + 1;
T.End_Pos := Cur_Mark (L);
End_Line (L);
-- empty lines and indentation of next line
loop
declare
Indent_Pos : constant Natural := L.Line_Start + Indent;
begin
while L.Cur = ' ' and L.Pos - 1 < Indent_Pos loop
L.Cur := Next (L);
end loop;
case L.Cur is
when Carriage_Return | Line_Feed =>
T.End_Pos := Cur_Mark (L);
Separation_Lines := Separation_Lines + 1;
End_Line (L);
when End_Of_Input =>
L.State := Stream_End'Access;
goto End_Of_Input_Target;
when others =>
if L.Pos - 1 < Indent_Pos then
exit Block_Content;
else
exit;
end if;
end case;
end;
end loop;
-- line folding
if T.Kind = Literal_Scalar then
Target.Append ((1 .. Separation_Lines => Line_Feed));
elsif Separation_Lines = 1 then
Target.Append (' ');
else
Target.Append ((1 .. Separation_Lines - 1 => Line_Feed));
end if;
end loop Block_Content;
if L.Pos - L.Line_Start - 1 > Indentation_Type'Max (0, L.Indentation) then
if L.Cur = '#' then
L.State := Expect_Line_End'Access;
else
raise Lexer_Error with
"This line at " & Escaped (L.Cur) & " is less indented than necessary." & L.Cur_Line'Img;
end if;
elsif L.Pos = L.Line_Start + 1 then
L.State := Line_Start'Access;
else
L.State := Line_Indentation'Access;
end if;
<<Finalize>>
T.End_Pos := Cur_Mark (L);
goto Finish;
<<End_Of_Input_Target>>
-- if we encounter the stream end directly after a newline character,
-- we must have stored the T.End_Pos beforehand because we cannot
-- calculate it back (we do not know how long the recent line was).
if L.Pos /= L.Line_Start + 1 then
T.End_Pos := Cur_Mark (L);
-- the generated End_Pos is *after* the stream end char, which is one
-- too far; compensate here.
T.End_Pos.Index := T.End_Pos.Index - 1;
T.End_Pos.Column := T.End_Pos.Column - 1;
end if;
<<Finish>>
T.End_Pos := Cur_Mark (L);
-- handling trailing empty lines
case Chomp is
when Strip => null;
when Clip =>
if Target.Length > 0 then
Target.Append (Line_Feed);
end if;
when Keep => Target.Append ((1 .. Separation_Lines => Line_Feed));
end case;
L.Value := Target.Lock;
end Read_Block_Scalar;
procedure Read_URI (L : in out Instance; Restricted : Boolean) is
Target : Text.Builder.Reference := Text.Builder.Create (L.Pool);
End_With_Space : constant Boolean := L.Cur /= '<';
Literal_Start : Positive;
begin
if End_With_Space then
if (not Restricted) and L.Cur in '[' | ']' | ',' then
raise Lexer_Error with "Flow indicator cannot start tag prefix";
end if;
Literal_Start := L.Pos - 1;
else
Literal_Start := L.Pos;
L.Cur := Next (L);
end if;
loop
case L.Cur is
when Space_Or_Line_End =>
if End_With_Space then
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
exit;
else
raise Lexer_Error with "Unclosed verbatim tag";
end if;
when '%' =>
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
Read_Hex_Sequence (L, 2, Target);
Literal_Start := L.Pos;
when Tag_Char => null;
when '[' | ']' | ',' =>
if Restricted then
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
exit;
end if;
when '!' =>
if Restricted then
raise Lexer_Error with "Illegal '!' in tag suffix!";
end if;
when '>' =>
if End_With_Space then
raise Lexer_Error with "Illegal character in URI: "">""";
else
Target.Append (L.Buffer (Literal_Start .. L.Pos - 2));
L.Cur := Next (L);
exit;
end if;
when others =>
raise Lexer_Error with "Illegal character in URI: " &
Escaped (L.Cur);
end case;
L.Cur := Next (L);
end loop;
L.Value := Target.Lock;
end Read_URI;
end Yaml.Lexer.Evaluation;
|
data/tilesets/mart_collision.asm
|
Dev727/ancientplatinum
| 28 |
7551
|
tilecoll WALL, WALL, WALL, WALL ; 00
tilecoll STAIRCASE, WALL, FLOOR, FLOOR ; 01
tilecoll WALL, STAIRCASE, FLOOR, FLOOR ; 02
tilecoll WALL, WALL, FLOOR, FLOOR ; 03
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 04
tilecoll STAIRCASE, WALL, FLOOR, FLOOR ; 05
tilecoll FLOOR, FLOOR, FLOOR, WARP_CARPET_DOWN ; 06
tilecoll WALL, FLOOR, WALL, FLOOR ; 07
tilecoll WALL, WALL, FLOOR, COUNTER ; 08
tilecoll WALL, WALL, FLOOR, FLOOR ; 09
tilecoll WALL, WALL, COUNTER, FLOOR ; 0a
tilecoll WALL, FLOOR, WALL, FLOOR ; 0b
tilecoll FLOOR, COUNTER, FLOOR, FLOOR ; 0c
tilecoll COUNTER, COUNTER, FLOOR, FLOOR ; 0d
tilecoll COUNTER, FLOOR, FLOOR, FLOOR ; 0e
tilecoll FLOOR, WALL, WALL, WALL ; 0f
tilecoll COUNTER, COUNTER, COUNTER, FLOOR ; 10
tilecoll COUNTER, COUNTER, FLOOR, FLOOR ; 11
tilecoll FLOOR, MART_SHELF, FLOOR, MART_SHELF ; 12
tilecoll WALL, WALL, MART_SHELF, MART_SHELF ; 13
tilecoll WALL, WALL, MART_SHELF, MART_SHELF ; 14
tilecoll WALL, WALL, MART_SHELF, MART_SHELF ; 15
tilecoll WALL, WALL, FLOOR, FLOOR ; 16
tilecoll WALL, WALL, FLOOR, COUNTER ; 17
tilecoll STAIRCASE, WALL, FLOOR, FLOOR ; 18
tilecoll WALL, STAIRCASE, FLOOR, FLOOR ; 19
tilecoll COUNTER, COUNTER, COUNTER, FLOOR ; 1a
tilecoll COUNTER, COUNTER, FLOOR, COUNTER ; 1b
tilecoll WALL, WALL, WALL, WALL ; 1c
tilecoll WALL, WALL, WALL, WALL ; 1d
tilecoll FLOOR, WARP_CARPET_RIGHT, FLOOR, WARP_CARPET_RIGHT ; 1e
tilecoll WARP_CARPET_LEFT, FLOOR, WARP_CARPET_LEFT, FLOOR ; 1f
tilecoll FLOOR, WALL, FLOOR, WALL ; 20
tilecoll WALL, WALL, WALL, WALL ; 21
tilecoll COUNTER, FLOOR, COUNTER, FLOOR ; 22
tilecoll FLOOR, MART_SHELF, FLOOR, MART_SHELF ; 23
tilecoll WALL, WALL, WALL, WALL ; 24
tilecoll FLOOR, FLOOR, WARP_CARPET_DOWN, FLOOR ; 25
tilecoll WALL, WALL, FLOOR, FLOOR ; 26
tilecoll WALL, WALL, COUNTER, MART_SHELF ; 27
tilecoll FLOOR, MART_SHELF, FLOOR, MART_SHELF ; 28
tilecoll WALL, FLOOR, FLOOR, FLOOR ; 29
tilecoll FLOOR, FLOOR, WARP_CARPET_DOWN, WARP_CARPET_DOWN ; 2a
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 2b
tilecoll COUNTER, COUNTER, FLOOR, MART_SHELF ; 2c
tilecoll FLOOR, MART_SHELF, COUNTER, COUNTER ; 2d
tilecoll COUNTER, FLOOR, COUNTER, COUNTER ; 2e
tilecoll WALL, STAIRCASE, FLOOR, FLOOR ; 2f
tilecoll WALL, WALL, WALL, WALL ; 30
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 31
tilecoll WALL, WALL, WALL, WALL ; 32
tilecoll WALL, FLOOR, WALL, WALL ; 33
tilecoll FLOOR, FLOOR, WALL, WALL ; 34
tilecoll FLOOR, WALL, WALL, WALL ; 35
tilecoll FLOOR, WALL, FLOOR, WALL ; 36
tilecoll FLOOR, WALL, FLOOR, WALL ; 37
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 38
tilecoll FLOOR, FLOOR, FLOOR, STAIRCASE ; 39
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 3a
tilecoll WALL, WALL, WALL, WALL ; 3b
tilecoll WALL, WALL, WALL, WALL ; 3c
tilecoll WALL, WALL, WALL, WALL ; 3d
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 3e
tilecoll WALL, WALL, WALL, WALL ; 3f
|
programs/oeis/282/A282848.asm
|
neoneye/loda
| 22 |
168658
|
<reponame>neoneye/loda
; A282848: a(n) = 2*n + 1 + n mod 4.
; 4,7,10,9,12,15,18,17,20,23,26,25,28,31,34,33,36,39,42,41,44,47,50,49,52,55,58,57,60,63,66,65,68,71,74,73,76,79,82,81,84,87,90,89,92,95,98,97,100,103,106,105,108,111,114,113,116,119,122,121,124,127,130,129,132,135,138,137,140,143,146,145,148,151,154,153,156,159,162,161,164,167,170,169,172,175,178,177,180,183,186,185,188,191,194,193,196,199,202,201
mov $1,$0
mul $0,2
add $1,1
mod $1,4
add $0,$1
add $0,3
|
programs/oeis/156/A156279.asm
|
karttu/loda
| 0 |
11793
|
; A156279: 4 times the Lucas number A000032(n).
; 8,4,12,16,28,44,72,116,188,304,492,796,1288,2084,3372,5456,8828,14284,23112,37396,60508,97904,158412,256316,414728,671044,1085772,1756816,2842588,4599404,7441992,12041396,19483388,31524784,51008172,82532956,133541128,216074084,349615212,565689296,915304508,1480993804,2396298312,3877292116,6273590428,10150882544,16424472972,26575355516,42999828488,69575184004,112575012492,182150196496,294725208988,476875405484,771600614472,1248476019956,2020076634428,3268552654384,5288629288812,8557181943196,13845811232008,22402993175204,36248804407212,58651797582416,94900601989628,153552399572044,248453001561672,402005401133716,650458402695388,1052463803829104,1702922206524492,2755386010353596,4458308216878088,7213694227231684
mov $1,8
mov $2,4
lpb $0,1
sub $0,1
mov $3,$2
add $2,$1
mov $1,$3
lpe
|
arch/ARM/STM32/driversF1/stm32-i2s.ads
|
morbos/Ada_Drivers_Library
| 2 |
5188
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 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 STMicroelectronics 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. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_i2s.h --
-- @author MCD Application Team --
-- @version V1.0.0 --
-- @date 18-February-2014 --
-- @brief Header file of I2S HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides definitions for the STM32F4 (ARM Cortex M4F
-- from ST Microelectronics) Inter-IC Sound (I2S) facility.
private with STM32_SVD.SPI;
with HAL.Audio; use HAL.Audio;
with System;
package STM32.I2S is
type I2S_Mode is (Slave_Transmit,
Slave_Receive,
Master_Transmit,
Master_Receive);
type I2S_Standard is (I2S_Philips_Standard,
MSB_Justified_Standard,
LSB_Justified_Standard,
PCM_Standard);
type I2S_Synchronization is (Short_Frame_Syncrho,
Long_Frame_Synchro);
type I2S_Clock_Polarity is (Steady_State_Low,
Steady_State_High);
type I2S_Data_Length is (Data_16bits, Data_24bits, Data_32bits);
type I2S_Channel_Length is (Channel_16bits, Channel_32bits);
type I2S_Linear_Prescaler is range 2 .. 255;
type I2S_Configuration is record
Mode : I2S_Mode;
Standard : I2S_Standard;
Syncho : I2S_Synchronization;
Clock_Polarity : I2S_Clock_Polarity;
Data_Length : I2S_Data_Length;
Chan_Length : I2S_Channel_Length;
Master_Clock_Out_Enabled : Boolean;
Transmit_DMA_Enabled : Boolean;
Receive_DMA_Enabled : Boolean;
end record;
type Internal_I2S_Port is private;
type I2S_Port (Periph : not null access Internal_I2S_Port) is
limited new Audio_Stream with private;
function In_I2S_Mode (This : in out I2S_Port) return Boolean;
-- I2S peripherals are shared with SPI, this function returns True only if
-- the periperal is configure in I2S mode.
procedure Configure (This : in out I2S_Port; Conf : I2S_Configuration)
with Pre => not This.Enabled,
Post => not This.Enabled;
procedure Enable (This : in out I2S_Port)
with Post => This.Enabled and This.In_I2S_Mode;
procedure Disable (This : in out I2S_Port)
with Pre => This.In_I2S_Mode;
function Enabled (This : I2S_Port) return Boolean;
function Data_Register_Address (This : I2S_Port)
return System.Address;
-- For DMA transfer
overriding
procedure Set_Frequency (This : in out I2S_Port;
Frequency : Audio_Frequency)
with Pre => not This.Enabled;
overriding
procedure Transmit (This : in out I2S_Port;
Data : Audio_Buffer)
with Pre => This.In_I2S_Mode;
overriding
procedure Receive (This : in out I2S_Port;
Data : out Audio_Buffer)
with Pre => This.In_I2S_Mode;
private
type Internal_I2S_Port is new STM32_SVD.SPI.SPI_Peripheral;
type I2S_Port (Periph : not null access Internal_I2S_Port) is
limited new Audio_Stream with null record;
end STM32.I2S;
|
oeis/303/A303295.asm
|
neoneye/loda-programs
| 11 |
99549
|
<reponame>neoneye/loda-programs
; A303295: a(n) is the maximum water retention of a height-3 length-n number parallelogram with maximum water area.
; 0,20,49,99,165,247,345,459,589,735,897,1075,1269,1479,1705,1947,2205,2479,2769,3075,3397,3735,4089,4459,4845,5247,5665,6099,6549,7015,7497,7995,8509,9039,9585,10147,10725,11319,11929,12555,13197,13855,14529,15219,15925,16647,17385,18139,18909,19695,20497,21315,22149,22999,23865,24747,25645,26559,27489,28435,29397,30375,31369,32379,33405,34447,35505,36579,37669,38775,39897,41035,42189,43359,44545,45747,46965,48199,49449,50715,51997,53295,54609,55939,57285,58647,60025,61419,62829,64255,65697
mul $0,2
mov $1,$0
trn $0,3
lpb $1
sub $1,1
add $2,$0
add $2,5
lpe
mul $2,2
add $0,$2
|
programs/oeis/193/A193643.asm
|
neoneye/loda
| 22 |
18676
|
<reponame>neoneye/loda
; A193643: Number of arrays of -3..3 integers x(1..n) with every x(i) in a subsequence of length 1 or 2 with sum zero
; 1,7,19,67,217,721,2377,7855,25939,85675,282961,934561,3086641,10194487,33670099,111204787,367284457,1213058161,4006458937,13232434975,43703763859,144343726555,476734943521,1574548557121,5200380614881,17175690401767,56727451820179,187358045862307,618801589407097,2043762814083601,6750090031657897,22294032909057295,73632188758829779,243190599185546635,803203986315469681,2652802558131955681,8761611660711336721,28937637540265965847,95574524281509234259,315661210384793668627,1042558155435890240137,3443335676692464389041,11372565185513283407257,37561031233232314610815,124055658885210227239699,409728007888862996329915,1353239682551799216229441,4469447055544260645018241,14761580849184581151284161,48754189603098004098870727,161024149658478593447896339,531826638578533784442559747,1756504065394079946775575577,5801338834760773624769286481,19160520569676400821083435017,63282900543789976088019591535,209009222201046329085142209619,690310567146928963343446220395,2279940923641833219115480870801,7530133338072428620689888832801,24870340937859119081185147369201,82141156151649785864245330940407,271293809392808476673921140190419,896022584330075215886008751511667,2959361562383034124331947394725417,9774107271479177588881850935687921,32281683376820566890977500201789177,106619157401940878261814351541055455,352139155582643201676420554824955539
add $0,1
seq $0,52991 ; Expansion of (1-x-x^2)/(1-3x-x^2).
div $0,6
mul $0,6
add $0,1
|
oeis/166/A166814.asm
|
neoneye/loda-programs
| 11 |
104378
|
<reponame>neoneye/loda-programs<filename>oeis/166/A166814.asm
; A166814: Number of nX2 1..3 arrays containing at least one of each value, all equal values connected, rows considered as a single number in nondecreasing order, and columns considered as a single number in increasing order.
; Submitted by <NAME>(s2)
; 0,6,25,66,140,260,441,700,1056,1530,2145,2926,3900,5096,6545,8280,10336,12750,15561,18810,22540,26796,31625,37076,43200,50050,57681,66150,75516,85840,97185,109616,123200,138006,154105,171570,190476,210900,232921,256620,282080,309386,338625,369886,403260,438840,476721,517000,559776,605150,653225,704106,757900,814716,874665,937860,1004416,1074450,1148081,1225430,1306620,1391776,1481025,1574496,1672320,1774630,1881561,1993250,2109836,2231460,2358265,2490396,2628000,2771226,2920225,3075150,3236156
add $0,1
mov $1,$0
bin $0,2
add $1,5
bin $1,2
sub $1,3
mul $0,$1
div $0,3
|
intrepyd/formula2py/Formula.g4
|
bobosoft/intrepyd
| 2 |
1570
|
grammar Formula;
formula: expr EOF;
expr: op=('not' | 'NOT') expr # notExpr
| op=('pre' | 'PRE') expr # preExpr
| expr (('and' | 'AND') expr)+ # andExpr
| expr (('or' | 'OR') expr)+ # orExpr
| '(' expr ')' # parExpr
| ID # parID
;
ID: [a-zA-Z_][a-zA-Z_0-9]*;
WS: [ \t\n\r\f]+ -> skip;
ERROR: .;
|
programs/oeis/166/A166911.asm
|
neoneye/loda
| 22 |
80560
|
<gh_stars>10-100
; A166911: a(n) = (9 + 14*n + 12*n^2 + 4*n^3)/3.
; 3,13,39,89,171,293,463,689,979,1341,1783,2313,2939,3669,4511,5473,6563,7789,9159,10681,12363,14213,16239,18449,20851,23453,26263,29289,32539,36021,39743,43713,47939,52429,57191,62233,67563,73189,79119,85361,91923,98813,106039,113609,121531,129813,138463,147489,156899,166701,176903,187513,198539,209989,221871,234193,246963,260189,273879,288041,302683,317813,333439,349569,366211,383373,401063,419289,438059,457381,477263,497713,518739,540349,562551,585353,608763,632789,657439,682721,708643,735213,762439,790329,818891,848133,878063,908689,940019,972061,1004823,1038313,1072539,1107509,1143231,1179713,1216963,1254989,1293799,1333401
mov $1,$0
add $0,3
add $0,$1
bin $0,3
add $1,$0
mov $0,$1
add $0,2
|
test/Compiler/with-stdlib/HelloWorld.agda
|
shlevy/agda
| 7 |
10176
|
<reponame>shlevy/agda
module HelloWorld where
open import IO
open import Data.String
open import Data.Unit
main = run (putStrLn "Hello World!")
|
src/test/resources/framework_specifications/TestResourceParser.g4
|
google/polymorphicDSL
| 3 |
5593
|
parser grammar TestResourceParser ;
import GherkinCommonParser ;
options {tokenVocab=TestResourceLexer ;}
givenTheTestResource : GIVEN_THE_TEST_RESOURCE textInDoubleQuotes END;
givenTheRawResource : GIVEN_THE_FOLLOWING_TEST_RESOURCE docstring ;
|
src/main/antlr/BiaLexer.g4
|
cubuspl42/bia
| 4 |
3496
|
lexer grammar BiaLexer;
// Keywords
If : 'if' ;
Then : 'then' ;
Else : 'else' ;
Val : 'val' ;
Return : 'return' ;
Def : 'def' ;
Or : 'or' ;
And : 'and' ;
Not : 'not' ;
External : 'external' ;
Typealias : 'typealias' ;
Union : 'union' ;
Is : 'is' ;
Untag : 'untag' ;
Match : 'match' ;
Case : 'case' ;
Singleton : 'singleton' ;
// Built-in types / type constructors
NumberType : 'Number' ;
BooleanType : 'Boolean' ;
BigIntegerType : 'BigInteger' ;
ListTypeConstructor : 'List' ;
SequenceTypeConstructor : 'Sequence' ;
// Literals
IntLiteral : '0'|[1-9][0-9]* ;
TrueLiteral : 'true' ;
FalseLiteral : 'false' ;
// Arrows
ThinArrow : '->' ;
FatArrow : '=>' ;
// Operators
Plus : '+' ;
Minus : '-' ;
Multiplication : '*' ;
Division : '/' ;
IntegerDivision : '~/' ;
Reminder : '%' ;
Equals : '==' ;
Assign : '=' ;
Lt : '<' ;
Gt : '>' ;
// Other
Whitespace : (' ' | '\n') -> skip ;
LineComment : '//' ~[\r\n]* -> skip ;
Identifier : [a-zA-Z] ([a-zA-Z1-9] | ':')* ;
LeftParen : '(' ;
RightParen : ')' ;
LeftBrace : '{' ;
RightBrace : '}' ;
Comma : ',' ;
Colon : ':' ;
QuestionMark : '?' ;
Ellipsis : '...' ;
Dot : '.' ;
Pipe : '|' ;
Hash : '#' ;
|
oeis/199/A199492.asm
|
neoneye/loda-programs
| 11 |
92102
|
; A199492: 11*7^n+1.
; 12,78,540,3774,26412,184878,1294140,9058974,63412812,443889678,3107227740,21750594174,152254159212,1065779114478,7460453801340,52223176609374,365562236265612,2558935653859278,17912549577014940,125387847039104574,877714929273732012,6144004504916124078,43008031534412868540,301056220740890079774,2107393545186230558412,14751754816303613908878,103262283714125297362140,722835985998877081534974,5059851901992139570744812,35418963313944976995213678,247932743197614838966495740
mov $1,7
pow $1,$0
sub $1,1
mul $1,11
add $1,12
mov $0,$1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.