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 |
|---|---|---|---|---|
alloy4fun_models/trashltl/models/16/bG7DdcDXycuGkjZCx.als | Kaixi26/org.alloytools.alloy | 0 | 324 | <gh_stars>0
open main
pred idbG7DdcDXycuGkjZCx_prop17 {
all f: File |always (eventually f in Trash) implies after File' = File-f
}
pred __repair { idbG7DdcDXycuGkjZCx_prop17 }
check __repair { idbG7DdcDXycuGkjZCx_prop17 <=> prop17o } |
tests/tashy2-test_data-tests.adb | thindil/tashy2 | 2 | 25109 | -- This package has been generated automatically by GNATtest.
-- You are allowed to add your code to the bodies of test routines.
-- Such changes will be kept during further regeneration of this file.
-- All code placed outside of test routine bodies will be lost. The
-- code intended to set up and tear down the test environment should be
-- placed into Tashy2.Test_Data.
with AUnit.Assertions; use AUnit.Assertions;
with System.Assertions;
-- begin read only
-- id:2.2/00/
--
-- This section can be used to add with clauses if necessary.
--
-- end read only
-- begin read only
-- end read only
package body Tashy2.Test_Data.Tests is
-- begin read only
-- id:2.2/01/
--
-- This section can be used to add global variables and other elements.
--
-- end read only
-- begin read only
-- end read only
-- begin read only
function Wrap_Test_To_C_String_399e2e_d041fb
(Str: String) return chars_ptr is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(tashy2.ads:0):Test_To_C_String test requirement violated");
end;
declare
Test_To_C_String_399e2e_d041fb_Result: constant chars_ptr :=
GNATtest_Generated.GNATtest_Standard.Tashy2.To_C_String(Str);
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(tashy2.ads:0:):Test_To_C_String test commitment violated");
end;
return Test_To_C_String_399e2e_d041fb_Result;
end;
end Wrap_Test_To_C_String_399e2e_d041fb;
-- end read only
-- begin read only
procedure Test_To_C_String_test_to_c_string(Gnattest_T: in out Test);
procedure Test_To_C_String_399e2e_d041fb(Gnattest_T: in out Test) renames
Test_To_C_String_test_to_c_string;
-- id:2.2/399e2ed874392483/To_C_String/1/0/test_to_c_string/
procedure Test_To_C_String_test_to_c_string(Gnattest_T: in out Test) is
function To_C_String(Str: String) return chars_ptr renames
Wrap_Test_To_C_String_399e2e_d041fb;
-- end read only
pragma Unreferenced(Gnattest_T);
C_String: constant chars_ptr := To_C_String("My String");
begin
Assert(True, "This test can only crash.");
-- begin read only
end Test_To_C_String_test_to_c_string;
-- end read only
-- begin read only
function Wrap_Test_From_C_String_0232b0_cebe6b
(Item: chars_ptr) return String is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(tashy2.ads:0):Test_From_C_String test requirement violated");
end;
declare
Test_From_C_String_0232b0_cebe6b_Result: constant String :=
GNATtest_Generated.GNATtest_Standard.Tashy2.From_C_String(Item);
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(tashy2.ads:0:):Test_From_C_String test commitment violated");
end;
return Test_From_C_String_0232b0_cebe6b_Result;
end;
end Wrap_Test_From_C_String_0232b0_cebe6b;
-- end read only
-- begin read only
procedure Test_From_C_String_test_from_c_string(Gnattest_T: in out Test);
procedure Test_From_C_String_0232b0_cebe6b(Gnattest_T: in out Test) renames
Test_From_C_String_test_from_c_string;
-- id:2.2/0232b0bd023bca97/From_C_String/1/0/test_from_c_string/
procedure Test_From_C_String_test_from_c_string(Gnattest_T: in out Test) is
function From_C_String(Item: chars_ptr) return String renames
Wrap_Test_From_C_String_0232b0_cebe6b;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Assert
(From_C_String(To_C_String("My String2")) = "My String2",
"Failed to convert C String to Ada String.");
-- begin read only
end Test_From_C_String_test_from_c_string;
-- end read only
-- begin read only
-- id:2.2/02/
--
-- This section can be used to add elaboration code for the global state.
--
begin
-- end read only
null;
-- begin read only
-- end read only
end Tashy2.Test_Data.Tests;
|
alloy4fun_models/trashltl/models/9/NciNXggczjmNimeSY.als | Kaixi26/org.alloytools.alloy | 0 | 4408 | open main
pred idNciNXggczjmNimeSY_prop10 {
always all f:File | f in Protected implies after always f in Protected
}
pred __repair { idNciNXggczjmNimeSY_prop10 }
check __repair { idNciNXggczjmNimeSY_prop10 <=> prop10o } |
programs/oeis/017/A017643.asm | neoneye/loda | 22 | 29263 | <reponame>neoneye/loda<filename>programs/oeis/017/A017643.asm
; A017643: a(n) = (12n+10)^3.
; 1000,10648,39304,97336,195112,343000,551368,830584,1191016,1643032,2197000,2863288,3652264,4574296,5639752,6859000,8242408,9800344,11543176,13481272,15625000,17984728,20570824,23393656,26463592,29791000,33386248,37259704
mul $0,12
add $0,10
pow $0,3
|
src/Control/Bug-Loop.agda | andreasabel/cubical | 0 | 7214 | <filename>src/Control/Bug-Loop.agda
{-# OPTIONS --copatterns #-}
{-# OPTIONS -v tc.constr.findInScope:15 #-}
-- One-place functors (decorations) on Set
module Control.Bug-Loop where
open import Function using (id; _∘_)
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open import Control.Functor
open IsFunctor {{...}}
record IsDecoration (D : Set → Set) : Set₁ where
field
traverse : ∀ {F} {{ functor : IsFunctor F }} {A B} →
(A → F B) → D A → F (D B)
traverse-id : ∀ {A} →
traverse {F = λ A → A} {A = A} id ≡ id
traverse-∘ :
∀ {F G} {{ funcF : IsFunctor F}} {{ funcG : IsFunctor G}} →
∀ {A B C} {f : A → F B} {g : B → G C} →
traverse ((map g) ∘ f) ≡ map {{funcF}} (traverse g) ∘ traverse f
isFunctor : IsFunctor D
isFunctor = record
{ ops = record { map = traverse }
; laws = record { map-id = traverse-id
; map-∘ = traverse-∘
}
}
open IsDecoration
idIsDecoration : IsDecoration (λ A → A)
traverse idIsDecoration f = f
traverse-id idIsDecoration = refl
traverse-∘ idIsDecoration = refl
compIsDecoration : ∀ {D E} → IsDecoration D → IsDecoration E → IsDecoration (λ A → D (E A))
traverse (compIsDecoration d e) f = traverse d (traverse e f)
traverse-id (compIsDecoration d e) = begin
traverse d (traverse e id)
≡⟨ cong (traverse d) (traverse-id e) ⟩
traverse d id
≡⟨ traverse-id d ⟩
id
∎
traverse-∘ (compIsDecoration d e) {{funcF = funcF}} {{funcG = funcG}} {f = f} {g = g} = begin
traverse (compIsDecoration d e) (map g ∘ f)
≡⟨⟩
traverse d (traverse e (map g ∘ f))
≡⟨ cong (traverse d) (traverse-∘ e) ⟩
traverse d (map (traverse e g) ∘ traverse e f)
≡⟨ traverse-∘ d ⟩
map (traverse d (traverse e g)) ∘ traverse d (traverse e f)
≡⟨⟩
map (traverse (compIsDecoration d e) g) ∘ traverse (compIsDecoration d e) f
∎
|
oeis/041/A041422.asm | neoneye/loda-programs | 11 | 97308 | ; A041422: Numerators of continued fraction convergents to sqrt(227).
; Submitted by <NAME>
; 15,226,6795,102151,3071325,46172026,1388232105,20869653601,627477840135,9433037255626,283618595508915,4263711969889351,128194977692189445,1927188377352731026,57943846298274120225,871084882851464534401,26190490331842210152255,393728439860484616818226,11838043686146380714699035,177964383732056195337303751,5350769555647832240833811565,80439507718449539807844477226,2418536001109134026476168128345,36358479524355459936950366402401,1093172921731772932134987160200375,16433952305500949441961757769408026
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
dif $2,2
mul $2,15
add $3,$2
lpe
mov $0,$3
|
programs/oeis/163/A163817.asm | jmorken/loda | 1 | 18161 | ; A163817: Expansion of (1 - x^2) * (1 - x^5) / ((1 - x) * (1 - x^6)) in powers of x.
; 1,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0,0,-1,0,1,0,0
mov $1,$0
mov $2,3
cmp $3,$0
lpb $1
sub $1,$2
sub $1,$2
lpe
lpb $1
mov $1,1
sub $3,1
lpe
add $1,$3
|
source/protocol/lsp.ads | reznikmm/ada_lsp | 11 | 6773 | -- Copyright (c) 2017 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package LSP is
pragma Pure;
end LSP;
|
oeis/142/A142894.asm | neoneye/loda-programs | 11 | 8730 | <reponame>neoneye/loda-programs<filename>oeis/142/A142894.asm
; A142894: Primes congruent to 10 mod 63.
; Submitted by <NAME>
; 73,199,577,829,1459,2089,2341,2467,2593,2719,2971,3727,3853,4231,4357,4483,4861,4987,5113,5743,5869,6121,6247,6373,7129,7507,7759,8011,8263,8389,8641,8893,9397,9649,9901,10531,10657,10909,11161,11287,12043,12421,12547,12799,13177,13681,13807,13933,14437,14563,15193,15319,15823,16453,16831,17209,17713,17839,18217,18973,19477,19603,20107,20233,20359,20611,21493,21871,21997,22123,22501,23131,23509,23761,23887,24391,24517,25147,25903,26029,26407,27541,27793,27919,28297,28549,28927,29179,29683,30187
mov $1,12
mov $2,$0
add $2,2
pow $2,2
lpb $2
sub $2,1
mov $3,$1
add $1,2
mul $3,6
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,19
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
mul $0,6
sub $0,125
|
doc/grammar/PetalParser.g4 | NekoGoddessAlyx/Petal | 0 | 4403 | parser grammar PetalParser;
options { tokenVocab = PetalLexer; language = Java; }
// file
file : ( NL* topLevelDeclaration )* EOF ;
topLevelDeclaration
: functionDeclaration
| classDeclaration
;
// declaration
declaration
: variableDeclaration
| functionDeclaration
| classDeclaration
| statement
;
variableDeclaration : ( VAL | VAR ) NL* Identifier ( NL* EQUAL NL* expression )? eos ;
functionDeclaration : FUN NL* Identifier NL* parenthesizedParameters? NL* block ;
classDeclaration : CLASS NL* Identifier NL* parenthesizedParameters? NL* ( COLON NL* Identifier ( NL* parenthesizedArguments )? NL* )? classBody? ;
classBody : BRACE_OPEN NL* ( classMember NL* )* BRACE_CLOSE ;
classMember : ( STATIC NL* )? functionDeclaration ;
// statement
statement
: printStatement
| ifStatement
| whileStatement
| expressionStatement
;
ifStatement : IF NL* PAREN_OPEN NL* expression NL* PAREN_CLOSE NL* blockOrStatement ( NL* ELSE NL* blockOrStatement )? ;
whileStatement : WHILE NL* PAREN_OPEN NL* expression NL* PAREN_CLOSE NL* blockOrStatement ;
printStatement : PRINT NL* expression eos ;
expressionStatement : expression eos ;
// block
blockOrStatement
: block
| statement
;
block : BRACE_OPEN NL* ( declaration NL* )* BRACE_CLOSE ;
// parameters and arguments
parenthesizedParameters : PAREN_OPEN NL* parameters? NL* PAREN_CLOSE ;
parameters : Identifier ( NL* COMMA NL* Identifier )* ( NL* COMMA )? ;
parenthesizedArguments : PAREN_OPEN NL* arguments? NL* PAREN_CLOSE ;
bracketedArguments : BRACKET_OPEN NL* arguments? NL* BRACKET_CLOSE ;
arguments : expression ( NL* COMMA NL* expression )* ( NL* COMMA )? ;
// expression
expression : assignment ;
assignment : disjunction ( assignmentOperator NL* disjunction )* ;
assignmentOperator
: EQUAL
| PLUS_EQUAL
| MINUS_EQUAL
| STAR_EQUAL
| SLASH_EQUAL
;
disjunction : conjunction ( OR NL* conjunction )* ;
conjunction : equality ( AND NL* equality )* ;
equality : comparison ( equalityOperator NL* comparison )* ;
equalityOperator
: EQUAL_EQUAL
| BANG_EQUAL
;
comparison : addition ( comparisonOperator NL* addition )* ;
comparisonOperator
: GREATER
| GREATER_EQUAL
| LESSER
| LESSER_EQUAL
;
addition : multiplication ( additionOperator NL* multiplication )* ;
additionOperator
: PLUS
| MINUS
;
multiplication : prefixUnary (multiplicationOperator NL* prefixUnary )* ;
multiplicationOperator
: STAR
| SLASH
;
prefixUnary : prefixUnaryOperator NL* prefixUnary | postfixUnary ;
prefixUnaryOperator
: PLUS
| MINUS
| BANG
;
postfixUnary : primary postfixUnaryOperation* ;
postfixUnaryOperation
: PLUS_PLUS
| MINUS_MINUS
| callOperation
| indexingOperation
| navigationOperation
;
callOperation : parenthesizedArguments ;
indexingOperation : bracketedArguments ;
navigationOperation : DOT NL* Identifier ;
primary
: Identifier
| literal
| parenthesizedExpression
| ifExpression
| BREAK
| CONTINUE
| returnExpression
;
literal
: DecLiteral
| HexLiteral
| NULL
| TRUE
| FALSE
| THIS
| SUPER
| stringLiteral
| listLiteral
| dictionaryLiteral
;
stringLiteral : QUOTE_OPEN StringText QUOTE_CLOSE ;
listLiteral : BRACKET_OPEN NL* listElements? NL* BRACKET_CLOSE ;
listElements : expression ( NL* COMMA NL* expression )* ( NL* COMMA )? ;
dictionaryLiteral : BRACKET_OPEN NL* dictionaryElements? NL* BRACKET_CLOSE ;
dictionaryElements : dictionaryElement ( NL* COMMA NL* dictionaryElement )* ( NL* COMMA )? ;
dictionaryElement : expression NL* COLON NL* expression ;
parenthesizedExpression : PAREN_OPEN NL* expression NL* PAREN_CLOSE ;
ifExpression : IF NL* PAREN_OPEN NL* expression NL* PAREN_CLOSE NL* ifExpressionBody NL* ELSE NL* ifExpressionBody ;
ifExpressionBody
: BRACE_OPEN NL* expression NL* BRACE_CLOSE
| expression
;
returnExpression : RETURN expression? ;
// ...
eos : SEMI | NL+ | EOF | { ELSE }? | { BRACE_CLOSE }? ; |
oeis/233/A233123.asm | neoneye/loda-programs | 11 | 15685 | <reponame>neoneye/loda-programs
; A233123: Number of n X 2 0..5 arrays with no element x(i,j) adjacent to itself or value 5-x(i,j) horizontally or vertically, top left element zero, and 1 appearing before 2 3 and 4, and 2 appearing before 3 in row major order (unlabelled 6-colorings with no clashing color pairs).
; 1,8,80,896,10496,124928,1495040,17924096,215023616,2580021248,30959206400,371506282496,4458058612736,53496636243968,641959366492160,7703511324164096,92442131595001856,1109305561960153088,13311666674802360320,159739999822750416896,1916879996773493374976,23002559956883873988608,276030719465014301818880,3312368633509802877648896,39748423601836159555076096,476981083220908014754070528,5723772998646392577421475840,68685275983738696530548228096,824223311804792300772540809216
mov $1,4
pow $1,$0
mov $2,12
pow $2,$0
add $1,$2
mov $0,$1
div $0,2
|
awa/plugins/awa-storages/src/awa-storages-stores.ads | fuzzysloth/ada-awa | 81 | 7632 | -----------------------------------------------------------------------
-- awa-storages-stores -- The storage interface
-- Copyright (C) 2012 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ADO.Sessions;
with AWA.Storages.Models;
-- == Store Service ==
-- The `AWA.Storages.Stores` package defines the interface that a store must implement to
-- be able to save and retrieve a data content. The store can be a file system, a database
-- or a remote store service.
--
-- @include awa-storages-stores-databases.ads
-- @include awa-storages-stores-files.ads
package AWA.Storages.Stores is
-- ------------------------------
-- Store Service
-- ------------------------------
type Store is limited interface;
type Store_Access is access all Store'Class;
-- Create a storage
procedure Create (Storage : in Store;
Session : in out ADO.Sessions.Master_Session;
From : in AWA.Storages.Models.Storage_Ref'Class;
Into : in out AWA.Storages.Storage_File) is abstract;
-- Save the file represented by the `Path` variable into a store and associate that
-- content with the storage reference represented by `Into`.
procedure Save (Storage : in Store;
Session : in out ADO.Sessions.Master_Session;
Into : in out AWA.Storages.Models.Storage_Ref'Class;
Path : in String) is abstract;
-- Load the storage item represented by `From` in a file that can be accessed locally.
procedure Load (Storage : in Store;
Session : in out ADO.Sessions.Session'Class;
From : in AWA.Storages.Models.Storage_Ref'Class;
Into : in out AWA.Storages.Storage_File) is abstract;
-- Delete the content associate with the storage represented by `From`.
procedure Delete (Storage : in Store;
Session : in out ADO.Sessions.Master_Session;
From : in out AWA.Storages.Models.Storage_Ref'Class) is abstract;
end AWA.Storages.Stores;
|
programs/oeis/196/A196126.asm | karttu/loda | 0 | 15647 | ; A196126: Let A = {(x,y): x, y positive natural numbers and y <= x <= y^2}. a(n) is the cardinality of the subset {(x,y) in A such that x <= n}.
; 1,2,4,7,10,14,19,25,32,39,47,56,66,77,89,102,115,129,144,160,177,195,214,234,255,276,298,321,345,370,396,423,451,480,510,541,572,604,637,671
mov $2,$0
mov $3,3
mov $4,$0
lpb $0,1
add $1,$0
sub $0,1
sub $1,$2
trn $2,$3
add $3,2
lpe
add $1,1
lpb $4,1
add $1,1
sub $4,1
lpe
|
oeis/350/A350108.asm | neoneye/loda-programs | 11 | 90815 | <reponame>neoneye/loda-programs
; A350108: a(n) = Sum_{k=1..n} k * floor(n/k)^3.
; Submitted by <NAME>
; 1,10,32,87,153,309,443,722,1005,1443,1785,2605,3087,3951,4875,6154,6988,8809,9855,12057,13853,16001,17543,21347,23478,26484,29440,33696,36162,41994,44816,50351,54755,59909,64577,73524,77558,84002,90142,100072,105034,116218,121680,132060,141858,151314,157848,174388,182383,195526,206002,220452,228774,247038,258330,277266,290342,305396,315722,343970,355012,372220,390846,414013,429697,456769,470103,494709,513849,542553,557535,597258,613100,637634,664308,695000,716348,753956,772522,814948,843257
add $0,1
mov $2,$0
lpb $0
mov $4,$0
max $0,1
mov $3,$2
div $3,$0
sub $0,1
pow $3,3
mul $3,$4
add $1,$3
lpe
mov $0,$1
|
cemu/examples/arm_sys_exec_bin_sh.asm | MatejKastak/cemu | 823 | 5969 | <filename>cemu/examples/arm_sys_exec_bin_sh.asm
#
# ARM sys_exec("/bin/sh") shellcode
#
# @_hugsy_
#
ldr r0, ="nib/"
str r0, [sp]
ldr r0, ="hs//"
str r0, [sp, 4]
mov r0, sp
mov r1, 0
mov r2, 0
mov r7, __NR_SYS_execve
svc 0
wfi
|
Transynther/x86/_processed/NONE/_zr_/i9-9900K_12_0xca_notsx.log_10494_1239.asm | ljhsiun2/medusa | 9 | 86388 | .global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x19d37, %r9
clflush (%r9)
nop
nop
nop
dec %rax
mov $0x6162636465666768, %r15
movq %r15, (%r9)
nop
nop
sub %rbx, %rbx
lea addresses_WT_ht+0x45b7, %r9
nop
nop
add %r8, %r8
mov $0x6162636465666768, %rdi
movq %rdi, %xmm3
vmovups %ymm3, (%r9)
nop
nop
nop
nop
nop
and %rbx, %rbx
lea addresses_D_ht+0x62c7, %rdi
nop
nop
nop
add $28353, %rax
and $0xffffffffffffffc0, %rdi
movaps (%rdi), %xmm1
vpextrq $1, %xmm1, %r15
nop
nop
nop
nop
xor %r8, %r8
lea addresses_A_ht+0x1b537, %rsi
lea addresses_UC_ht+0xc137, %rdi
nop
and $28751, %r8
mov $84, %rcx
rep movsb
nop
cmp $45895, %r9
lea addresses_WT_ht+0x1d31d, %rax
nop
nop
nop
add %rsi, %rsi
movups (%rax), %xmm3
vpextrq $1, %xmm3, %r8
nop
cmp $12318, %r9
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_A+0xb683, %rbp
nop
nop
nop
dec %rax
mov $0x5152535455565758, %rdx
movq %rdx, %xmm3
vmovups %ymm3, (%rbp)
nop
nop
xor $60417, %rbp
// REPMOV
lea addresses_RW+0x14677, %rsi
mov $0xd37, %rdi
clflush (%rdi)
nop
nop
inc %rbp
mov $43, %rcx
rep movsb
nop
nop
nop
nop
add %rbp, %rbp
// Store
lea addresses_RW+0x6817, %rax
nop
nop
nop
nop
xor %rdx, %rdx
movw $0x5152, (%rax)
nop
nop
add $29864, %rcx
// Faulty Load
lea addresses_A+0x3937, %r9
clflush (%r9)
nop
nop
nop
and %rsi, %rsi
mov (%r9), %rbp
lea oracles, %rax
and $0xff, %rbp
shlq $12, %rbp
mov (%rax,%rbp,1), %rbp
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_RW'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_P'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1}}
{'00': 10494}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
programs/oeis/130/A130727.asm | karttu/loda | 0 | 7897 | <filename>programs/oeis/130/A130727.asm<gh_stars>0
; A130727: List of triples 2n+1, 2n+3, 2n+2.
; 1,3,2,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,26,27,29,28,29,31,30,31,33,32,33,35,34,35,37,36,37,39,38,39,41,40,41,43,42,43,45,44,45,47,46,47,49,48,49,51
add $0,2
mov $2,$0
mov $3,$0
lpb $2,1
trn $2,2
mov $1,$2
trn $2,1
sub $3,1
add $1,$3
lpe
|
programs/oeis/099/A099062.asm | karttu/loda | 1 | 95735 | ; A099062: A bisection of A000960.
; 3,13,27,49,79,109,147,207,253,307,387,459,529,613,709,807,927,1009,1111,1261,1359,1483,1693,1807,1933,2161,2269,2479,2703,2799,3019,3199,3421,3619,3841,4083,4249,4603,4783,5067,5293,5547,5767,6109,6387,6589
mul $0,2
add $0,1
mov $1,$0
cal $1,278484 ; Main diagonal of A278482.
div $1,2
mul $1,2
add $1,1
|
audio/music/sinnohwildbattle.asm | AtmaBuster/pokeplat-gen2 | 6 | 23439 | Music_SinnohWildBattle:
channel_count 3
channel 1, Music_SinnohWildBattle_Ch1
channel 2, Music_SinnohWildBattle_Ch2
channel 3, Music_SinnohWildBattle_Ch3
Music_SinnohWildBattle_Ch1_sub_0:
octave 5
note E_, 2
octave 4
note A_, 2
note B_, 2
note E_, 2
note G_, 2
note D_, 2
note E_, 2
note C_, 2
note D_, 2
octave 3
note B_, 2
octave 4
note C_, 2
octave 3
note A_, 2
note B_, 2
note G_, 2
sound_ret
Music_SinnohWildBattle_Ch1_sub_1:
note A_, 6
note F#, 4
note D_, 2
note A_, 2
octave 4
note D_, 2
octave 3
note D_, 2
note G_, 2
note A_, 2
note G_, 2
note D_, 2
note F#, 2
note A_, 2
sound_ret
Music_SinnohWildBattle_Ch1_sub_2:
octave 3
note E_, 10
note C_, 2
note G_, 2
octave 4
note C_, 2
octave 3
note C_, 2
note F_, 2
note G_, 2
note F_, 2
note C_, 2
note E_, 2
note G_, 2
sound_ret
Music_SinnohWildBattle_Ch1::
tempo 104
volume 7, 7
duty_cycle 3
vibrato 18, 1, 5
note_type 12, 11, 2
pitch_offset 1
octave 4
note C_, 1
octave 3
note B_, 1
note A#, 1
note A_, 1
note A#, 1
note A_, 1
note G#, 1
note G_, 1
note G#, 1
note G_, 1
note F#, 1
note F_, 1
note F#, 1
note F_, 1
note E_, 1
note D#, 1
note E_, 1
note D#, 1
note D_, 1
note C#, 1
note D_, 1
note C#, 1
note C_, 1
octave 2
note B_, 1
octave 3
note C_, 1
octave 2
note B_, 1
note A#, 1
note A_, 1
note A#, 1
note A_, 1
note G#, 1
note G_, 1
note G_, 6
octave 3
note C_, 6
note C#, 6
rest 6
octave 2
volume_envelope 11, 5
note G_, 8
volume_envelope 11, 2
note G#, 6
octave 3
note C#, 6
note D#, 6
rest 6
octave 2
volume_envelope 11, 5
note G#, 8
volume_envelope 11, 2
octave 3
note G_, 6
octave 4
note C_, 6
note C#, 6
rest 6
octave 3
volume_envelope 11, 5
note G_, 8
volume_envelope 11, 2
note G#, 6
octave 4
note C#, 6
note D#, 6
rest 6
volume_envelope 6, -7
note G#, 8
.loop
volume_envelope 11, 6
sound_call Music_SinnohWildBattle_Ch1_sub_2
octave 4
note C_, 2
note C#, 4
octave 3
note C#, 8
note D#, 8
note F_, 4
note G#, 8
sound_call Music_SinnohWildBattle_Ch1_sub_2
note A_, 2
note F_, 4
note F_, 8
note D#, 8
note C#, 4
note F_, 4
note G_, 4
sound_call Music_SinnohWildBattle_Ch1_sub_1
octave 4
note D_, 2
note D#, 4
octave 3
note D#, 8
note F_, 8
note G_, 8
note A#, 4
sound_call Music_SinnohWildBattle_Ch1_sub_1
note B_, 2
note G_, 2
note A_, 2
octave 4
note D#, 2
note G_, 4
note F_, 2
note D#, 2
note D_, 2
note D#, 4
note D#, 4
note G_, 4
octave 3
note A#, 4
note G_, 10
note G_, 2
note F_, 2
note D#, 2
octave 2
note A#, 6
note G_, 10
octave 3
note C#, 8
note F_, 8
note G#, 8
note G_, 8
note G_, 2
note F_, 2
note D#, 2
note F_, 2
note G_, 8
note D#, 2
note C#, 2
note C_, 2
note C#, 2
note D#, 8
note G_, 2
note F_, 2
note D#, 2
note F_, 2
note G_, 4
octave 4
note D#, 2
note F_, 2
note G_, 2
note F_, 2
note D#, 2
note F_, 2
note G_, 8
volume_envelope 11, 7
note F_, 16
note F#, 16
volume_envelope 11, 0
note G_, 16
volume_envelope 11, 7
note G_, 16
rest 6
volume_envelope 11, 6
octave 3
note C_, 6
octave 2
note A#, 4
note G#, 16
rest 6
octave 3
note C_, 6
octave 2
note A#, 4
octave 3
note C#, 16
volume_envelope 11, 2
sound_call Music_SinnohWildBattle_Ch1_sub_0
note A_, 2
note F_, 2
sound_call Music_SinnohWildBattle_Ch1_sub_0
volume_envelope 11, 6
octave 4
note D#, 4
note E_, 10
note E_, 2
note D_, 2
note C_, 2
octave 3
note G_, 6
note C_, 10
octave 4
note F_, 10
note F_, 2
note D#, 2
note C#, 2
octave 3
note G#, 6
note C#, 10
octave 4
note F#, 10
note F#, 2
note E_, 2
note D_, 2
octave 3
note A_, 6
note D_, 10
rest 16
volume_envelope 6, -7
note A_, 16
sound_loop 0, .loop
Music_SinnohWildBattle_Ch2_sub_0:
octave 4
note G_, 1
octave 5
note C_, 2
note C_, 1
octave 4
note G_, 1
octave 5
note C_, 2
sound_ret
Music_SinnohWildBattle_Ch2_sub_1:
note C_, 6
note G_, 6
note F_, 6
rest 6
volume_envelope 12, 5
note C_, 8
volume_envelope 12, 2
note C#, 6
note G#, 6
note G_, 6
rest 6
sound_ret
Music_SinnohWildBattle_Ch2_sub_2:
note D_, 10
octave 3
note A_, 2
octave 4
note D_, 2
note A_, 2
note G_, 2
note F#, 2
note E_, 2
note D_, 2
note G_, 2
note F#, 2
sound_ret
Music_SinnohWildBattle_Ch2_sub_3:
note C_, 10
octave 3
note G_, 2
octave 4
note C_, 2
note G_, 2
note F_, 2
note E_, 2
note D_, 2
note C_, 2
note F_, 2
note E_, 2
sound_ret
Music_SinnohWildBattle_Ch2_sub_4:
note A#, 2
note G#, 2
note G_, 2
note G#, 2
volume_envelope 12, 0
note A#, 8
volume_envelope 12, 6
note A#, 16
sound_ret
Music_SinnohWildBattle_Ch2::
duty_cycle 3
vibrato 8, 3, 6
note_type 12, 12, 2
octave 5
note C_, 1
sound_call Music_SinnohWildBattle_Ch2_sub_0
note C_, 1
sound_call Music_SinnohWildBattle_Ch2_sub_0
note C_, 1
sound_call Music_SinnohWildBattle_Ch2_sub_0
note C_, 1
sound_call Music_SinnohWildBattle_Ch2_sub_0
octave 3
sound_call Music_SinnohWildBattle_Ch2_sub_1
volume_envelope 12, 5
note C#, 8
volume_envelope 12, 2
octave 4
sound_call Music_SinnohWildBattle_Ch2_sub_1
octave 5
volume_envelope 6, -7
note C#, 8
octave 4
.loop
volume_envelope 12, 6
sound_call Music_SinnohWildBattle_Ch2_sub_3
note F_, 2
note G_, 2
volume_envelope 12, 0
note G#, 16
volume_envelope 12, 7
note G#, 16
sound_call Music_SinnohWildBattle_Ch2_sub_3
note D_, 2
note C_, 2
octave 3
volume_envelope 12, 0
note A#, 16
volume_envelope 12, 7
note A#, 12
octave 4
note C#, 4
sound_call Music_SinnohWildBattle_Ch2_sub_2
note G_, 2
note A_, 2
volume_envelope 12, 0
note A#, 16
volume_envelope 12, 7
note A#, 16
volume_envelope 12, 7
sound_call Music_SinnohWildBattle_Ch2_sub_2
note E_, 2
note D_, 2
volume_envelope 12, 0
note C_, 16
volume_envelope 12, 5
note C_, 12
volume_envelope 12, 6
note D#, 4
octave 3
note A#, 10
note A#, 2
note G#, 2
note G_, 2
note D#, 6
octave 2
note A#, 10
octave 3
note F_, 8
note G#, 8
octave 4
note C#, 8
note C_, 8
octave 3
sound_call Music_SinnohWildBattle_Ch2_sub_4
sound_call Music_SinnohWildBattle_Ch2_sub_4
octave 4
volume_envelope 12, 7
note G#, 16
note A_, 16
volume_envelope 12, 0
note A#, 16
volume_envelope 12, 7
note A#, 16
volume_envelope 12, 6
octave 3
note C_, 6
note G_, 6
note F_, 4
note C#, 16
note C_, 6
note G_, 6
note F_, 4
note G#, 16
note E_, 6
note B_, 6
note A_, 4
note F_, 16
note E_, 6
note B_, 6
note A_, 4
octave 4
note C_, 12
note F#, 4
note G_, 10
note G_, 2
note F_, 2
note E_, 2
note C_, 6
octave 3
note G_, 10
octave 4
note G#, 10
note G#, 2
note F#, 2
note F_, 2
note C#, 6
octave 3
note G#, 10
octave 4
note A_, 10
note A_, 2
note G_, 2
note F#, 2
note D_, 6
octave 3
note A_, 10
rest 16
octave 4
volume_envelope 6, -7
note D_, 16
sound_loop 0, .loop
Music_SinnohWildBattle_Ch3_sub_0:
note C_, 2
octave 2
note G_, 2
octave 3
note C_, 2
note G_, 4
note G_, 2
note C_, 2
note G_, 2
note C_, 2
octave 2
note G_, 2
octave 3
note C_, 2
note F_, 4
note G_, 2
note G_, 2
note F_, 2
note C#, 2
note G#, 2
sound_ret
Music_SinnohWildBattle_Ch3_sub_1:
note C_, 2
note G_, 2
note C_, 2
note G_, 2
note C_, 2
note G_, 2
note C_, 2
note G_, 2
note C_, 2
note G_, 2
note C_, 4
note G_, 2
note F_, 2
note D#, 2
note G_, 2
note C#, 2
note G#, 2
note C#, 2
note G#, 2
note C#, 2
note G#, 2
note C#, 2
note G#, 2
note C#, 2
note G#, 2
note C#, 4
note G#, 2
note G_, 2
note F_, 2
note G#, 2
sound_ret
Music_SinnohWildBattle_Ch3_sub_2:
note D_, 2
octave 2
note A_, 2
octave 3
note D_, 2
note A_, 4
note A_, 2
note D_, 2
note A_, 2
note D_, 2
octave 2
note A_, 2
octave 3
note D_, 2
note G_, 4
note A_, 2
note A_, 2
note G_, 2
note D#, 2
note A#, 2
octave 4
sound_ret
Music_SinnohWildBattle_Ch3_sub_3:
note A#, 2
note D#, 2
note A#, 2
note D#, 2
note A#, 2
note D#, 2
note A#, 2
sound_ret
Music_SinnohWildBattle_Ch3_sub_4:
note C_, 2
note G_, 2
note C_, 2
note G_, 2
note G_, 2
note C_, 2
note G_, 2
note C_, 2
note C#, 2
note G#, 2
note C#, 2
note G#, 2
note G#, 2
note C#, 2
note C#, 2
note G#, 2
sound_ret
Music_SinnohWildBattle_Ch3_sub_5:
note D_, 2
note A_, 2
note D_, 2
note A_, 2
note A_, 2
note D_, 2
note A_, 2
note D_, 2
note D#, 2
note A#, 2
note D#, 2
note A#, 2
note A#, 2
note D#, 2
note D#, 2
note A#, 2
sound_ret
Music_SinnohWildBattle_Ch3_sub_6:
octave 3
note D_, 2
note A_, 2
octave 4
note F#, 2
note D_, 4
octave 3
note A_, 2
note F#, 2
note A_, 2
note D_, 2
note A_, 2
octave 4
note D_, 2
octave 3
note A_, 2
sound_ret
Music_SinnohWildBattle_Ch3_sub_7:
note D#, 4
octave 3
note A#, 2
note G_, 2
note A#, 2
note D#, 2
note A#, 2
octave 4
note G_, 2
sound_ret
Music_SinnohWildBattle_Ch3_sub_8:
note A#, 2
note D#, 2
note A#, 2
octave 4
note D#, 2
octave 3
sound_ret
Music_SinnohWildBattle_Ch3_sub_9:
note G#, 2
note F_, 2
note G#, 2
note C#, 2
note G#, 2
octave 4
note C#, 2
octave 3
note G#, 2
sound_ret
Music_SinnohWildBattle_Ch3::
note_type 12, 1, 4
octave 3
note D_, 1
rest 1
note D#, 1
note E_, 1
note D#, 1
rest 1
note E_, 1
note F_, 1
note E_, 1
rest 1
note F_, 1
note F#, 1
note F_, 1
rest 1
note F#, 1
note G_, 1
note F#, 1
rest 1
note G_, 1
note G#, 1
note G_, 1
rest 1
note G#, 1
note A_, 1
note G#, 1
rest 1
note D#, 2
note D_, 2
note C#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_1
sound_call Music_SinnohWildBattle_Ch3_sub_1
.loop
sound_call Music_SinnohWildBattle_Ch3_sub_0
octave 4
note G#, 2
note C#, 4
octave 3
note G#, 2
note F_, 2
note G#, 2
note C#, 2
note G#, 2
octave 4
note F_, 2
note C#, 4
octave 3
note G#, 2
note F_, 2
note G#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_0
octave 2
note G#, 2
octave 3
note C#, 4
sound_call Music_SinnohWildBattle_Ch3_sub_9
note G#, 2
octave 4
note C#, 2
octave 3
note C#, 2
note G#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_2
note A#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_7
note D#, 4
octave 3
note A#, 2
note G_, 2
note A#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_2
note G_, 2
sound_call Music_SinnohWildBattle_Ch3_sub_7
octave 3
note A#, 2
note D#, 2
note G_, 2
note A#, 2
octave 4
note D#, 2
octave 3
note D#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_3
octave 2
note A#, 2
octave 3
note D#, 2
octave 2
note A#, 2
octave 3
note D#, 2
octave 2
note A#, 2
octave 3
note D#, 2
octave 2
note A#, 2
octave 3
note D#, 2
note G#, 2
note C#, 2
octave 4
note C#, 4
octave 3
note G#, 2
note C#, 2
octave 4
note F_, 4
octave 3
note G#, 2
note C#, 2
octave 4
note F_, 2
octave 3
note G#, 2
octave 4
note C#, 2
note C_, 2
octave 3
note A#, 2
note G#, 2
note D#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_3
note D#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_3
note D#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_3
note D#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_3
note C_, 2
note G_, 2
note C_, 2
note G_, 2
note C_, 2
note G_, 2
note C_, 2
note G_, 2
note C#, 2
note G#, 2
note C#, 2
note G#, 2
note C#, 2
note G#, 2
note C#, 2
note G#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_8
sound_call Music_SinnohWildBattle_Ch3_sub_8
sound_call Music_SinnohWildBattle_Ch3_sub_8
note A#, 2
octave 2
note B_, 2
note A_, 2
note B_, 2
octave 3
sound_call Music_SinnohWildBattle_Ch3_sub_4
sound_call Music_SinnohWildBattle_Ch3_sub_4
sound_call Music_SinnohWildBattle_Ch3_sub_5
sound_call Music_SinnohWildBattle_Ch3_sub_5
sound_call Music_SinnohWildBattle_Ch3_sub_0
octave 4
note F_, 2
note C#, 4
octave 3
sound_call Music_SinnohWildBattle_Ch3_sub_9
note C#, 2
note F_, 2
note G#, 2
octave 4
note C#, 2
sound_call Music_SinnohWildBattle_Ch3_sub_6
note D_, 2
note F#, 2
note A_, 2
octave 4
note D_, 2
sound_call Music_SinnohWildBattle_Ch3_sub_6
octave 4
note D_, 2
octave 3
note G_, 2
note A_, 2
note G_, 2
sound_loop 0, .loop |
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/align_check.adb | best08618/asylo | 7 | 23770 | -- { dg-do run }
with System;
procedure align_check is
N_Allocated_Buffers : Natural := 0;
--
function New_Buffer (N_Bytes : Natural) return System.Address is
begin
N_Allocated_Buffers := N_Allocated_Buffers + 1;
return System.Null_Address;
end;
--
Buffer_Address : constant System.Address := New_Buffer (N_Bytes => 8);
N : Natural;
for N'Address use Buffer_Address;
--
begin
if N_Allocated_Buffers /= 1 then
raise Program_Error;
end if;
end;
|
programs/oeis/178/A178742.asm | neoneye/loda | 22 | 167906 | <reponame>neoneye/loda<gh_stars>10-100
; A178742: Partial sums of floor(2^n/9).
; 0,0,0,0,1,4,11,25,53,109,222,449,904,1814,3634,7274,14555,29118,58245,116499,233007,466023,932056,1864123,3728258,7456528,14913068,29826148,59652309,119304632,238609279,477218573,954437161,1908874337,3817748690,7635497397,15270994812,30541989642,61083979302,122167958622,244335917263,488671834546,977343669113,1954687338247,3909374676515,7818749353051,15637498706124,31274997412271,62549994824566,125099989649156,250199979298336,500399958596696,1000799917193417,2001599834386860,4003199668773747,8006399337547521,16012798675095069,32025597350190165,64051194700380358,128102389400760745,256204778801521520,512409557603043070,1024819115206086170,2049638230412172370,4099276460824344771,8198552921648689574,16397105843297379181,32794211686594758395,65588423373189516823,131176846746379033679,262353693492758067392,524707386985516134819,1049414773971032269674,2098829547942064539384,4197659095884129078804,8395318191768258157644,16790636383536516315325,33581272767073032630688,67162545534146065261415,134325091068292130522869,268650182136584261045777,537300364273168522091593,1074600728546337044183226,2149201457092674088366493,4298402914185348176733028,8596805828370696353466098,17193611656741392706932238,34387223313482785413864518,68774446626965570827729079,137548893253931141655458202,275097786507862283310916449,550195573015724566621832943,1100391146031449133243665931,2200782292062898266487331907,4401564584125796532974663860,8803129168251593065949327767,17606258336503186131898655582,35212516673006372263797311212,70425033346012744527594622472,140850066692025489055189244992
lpb $0
mov $2,$0
sub $0,1
seq $2,153234 ; a(n) = floor(2^n/9).
add $1,$2
lpe
mov $0,$1
|
mac/app-scripts/url of Chrome.scpt | albertz/foreground_app_info | 2 | 1501 | tell application "Google Chrome"
if the (count of windows) is not 0 then
set weburl to URL of active tab of front window
end if
end tell
return weburl
|
Palmtree.Math.Core.Implements/vs_build/x86_Debug/pmc_bitwiseor.asm | rougemeilland/Palmtree.Math.Core.Implements | 0 | 243518 | ; Listing generated by Microsoft (R) Optimizing Compiler Version 19.16.27026.1
TITLE Z:\Sources\Lunor\Repos\rougemeilland\Palmtree.Math.Core.Implements\Palmtree.Math.Core.Implements\pmc_bitwiseor.c
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB MSVCRTD
INCLUDELIB OLDNAMES
msvcjmc SEGMENT
__7B7A869E_ctype@h DB 01H
__457DD326_basetsd@h DB 01H
__4384A2D9_corecrt_memcpy_s@h DB 01H
__4E51A221_corecrt_wstring@h DB 01H
__2140C079_string@h DB 01H
__1887E595_winnt@h DB 01H
__9FC7C64B_processthreadsapi@h DB 01H
__FA470AEC_memoryapi@h DB 01H
__F37DAFF1_winerror@h DB 01H
__7A450CCC_winbase@h DB 01H
__B4B40122_winioctl@h DB 01H
__86261D59_stralign@h DB 01H
__7B8DBFC3_pmc_uint_internal@h DB 01H
__6B0481B0_pmc_inline_func@h DB 01H
__AC60EF90_pmc_bitwiseor@c DB 01H
msvcjmc ENDS
PUBLIC _Initialize_BitwiseOr
PUBLIC _PMC_BitwiseOr_I_X@12
PUBLIC _PMC_BitwiseOr_L_X@16
PUBLIC _PMC_BitwiseOr_X_I@12
PUBLIC _PMC_BitwiseOr_X_L@16
PUBLIC _PMC_BitwiseOr_X_X@12
PUBLIC __JustMyCode_Default
EXTRN _CheckBlockLight:PROC
EXTRN _AllocateNumber:PROC
EXTRN _CommitNumber:PROC
EXTRN _CheckNumber:PROC
EXTRN _DuplicateNumber:PROC
EXTRN _From_I_Imp:PROC
EXTRN _From_L_Imp:PROC
EXTRN @_RTC_CheckStackVars@8:PROC
EXTRN @__CheckForDebuggerJustMyCode@4:PROC
EXTRN __RTC_CheckEsp:PROC
EXTRN __RTC_InitBase:PROC
EXTRN __RTC_Shutdown:PROC
EXTRN __aullshr:PROC
EXTRN _number_zero:BYTE
; COMDAT rtc$TMZ
rtc$TMZ SEGMENT
__RTC_Shutdown.rtc$TMZ DD FLAT:__RTC_Shutdown
rtc$TMZ ENDS
; COMDAT rtc$IMZ
rtc$IMZ SEGMENT
__RTC_InitBase.rtc$IMZ DD FLAT:__RTC_InitBase
rtc$IMZ ENDS
; Function compile flags: /Odt
; COMDAT __JustMyCode_Default
_TEXT SEGMENT
__JustMyCode_Default PROC ; COMDAT
push ebp
mov ebp, esp
pop ebp
ret 0
__JustMyCode_Default ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_nw_light_check_code$1 = -84 ; size = 4
_w_bit_count$2 = -76 ; size = 4
_v_bit_count$3 = -72 ; size = 4
_u_bit_count$4 = -68 ; size = 4
_w_light_check_code$5 = -60 ; size = 4
_w_bit_count$6 = -52 ; size = 4
_v_bit_count$7 = -48 ; size = 4
_w_light_check_code$8 = -40 ; size = 4
_w_bit_count$9 = -32 ; size = 4
_v_bit_count$10 = -28 ; size = 4
_v_lo$11 = -24 ; size = 4
_v_hi$12 = -16 ; size = 4
_u_bit_count$13 = -8 ; size = 4
_result$ = -4 ; size = 4
_u$ = 8 ; size = 4
_v$ = 12 ; size = 8
_w$ = 20 ; size = 4
_PMC_BitwiseOr_X_L_Imp PROC
; 275 : {
push ebp
mov ebp, esp
sub esp, 88 ; 00000058H
push edi
lea edi, DWORD PTR [ebp-88]
mov ecx, 22 ; 00000016H
mov eax, -858993460 ; ccccccccH
rep stosd
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 276 : PMC_STATUS_CODE result;
; 277 : if (u->IS_ZERO)
mov eax, DWORD PTR _u$[ebp]
mov ecx, DWORD PTR [eax+24]
shr ecx, 1
and ecx, 1
je SHORT $LN2@PMC_Bitwis
; 278 : {
; 279 : // u が 0 である場合
; 280 : if (v == 0)
mov edx, DWORD PTR _v$[ebp]
or edx, DWORD PTR _v$[ebp+4]
jne SHORT $LN4@PMC_Bitwis
; 281 : {
; 282 : // v が 0 である場合
; 283 : *w = &number_zero;
mov eax, DWORD PTR _w$[ebp]
mov DWORD PTR [eax], OFFSET _number_zero
; 284 : }
jmp SHORT $LN5@PMC_Bitwis
$LN4@PMC_Bitwis:
; 285 : else
; 286 : {
; 287 : // v が 0 でない場合
; 288 : if ((result = From_L_Imp(v, w)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _w$[ebp]
push ecx
mov edx, DWORD PTR _v$[ebp+4]
push edx
mov eax, DWORD PTR _v$[ebp]
push eax
call _From_L_Imp
add esp, 12 ; 0000000cH
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN5@PMC_Bitwis
; 289 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN5@PMC_Bitwis:
; 290 : }
; 291 : }
jmp $LN3@PMC_Bitwis
$LN2@PMC_Bitwis:
; 292 : else if (v == 0)
mov ecx, DWORD PTR _v$[ebp]
or ecx, DWORD PTR _v$[ebp+4]
jne SHORT $LN7@PMC_Bitwis
; 293 : {
; 294 : // v が 0 である場合
; 295 : if ((result = DuplicateNumber(u, w)) != PMC_STATUS_OK)
mov edx, DWORD PTR _w$[ebp]
push edx
mov eax, DWORD PTR _u$[ebp]
push eax
call _DuplicateNumber
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN9@PMC_Bitwis
; 296 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN9@PMC_Bitwis:
; 297 : }
jmp $LN3@PMC_Bitwis
$LN7@PMC_Bitwis:
; 298 : else
; 299 : {
; 300 : // u と v がともに 0 ではない場合
; 301 : if (__UNIT_TYPE_BIT_COUNT < sizeof(v) * 8)
mov ecx, 1
test ecx, ecx
je $LN10@PMC_Bitwis
; 302 : {
; 303 : // _UINT64_T が 1 ワードで表現しきれない場合
; 304 : __UNIT_TYPE u_bit_count = u->UNIT_BIT_COUNT;
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+12]
mov DWORD PTR _u_bit_count$13[ebp], eax
; 305 : _UINT32_T v_hi;
; 306 : _UINT32_T v_lo = _FROMDWORDTOWORD(v, &v_hi);
lea ecx, DWORD PTR _v_hi$12[ebp]
push ecx
mov edx, DWORD PTR _v$[ebp+4]
push edx
mov eax, DWORD PTR _v$[ebp]
push eax
call __FROMDWORDTOWORD
add esp, 12 ; 0000000cH
mov DWORD PTR _v_lo$11[ebp], eax
; 307 : if (v_hi == 0)
cmp DWORD PTR _v_hi$12[ebp], 0
jne $LN12@PMC_Bitwis
; 308 : {
; 309 : // v の値が 32bit で表現可能な場合
; 310 : __UNIT_TYPE v_bit_count = sizeof(v_lo) * 8 - _LZCNT_ALT_32(v_lo);
mov ecx, DWORD PTR _v_lo$11[ebp]
push ecx
call __LZCNT_ALT_32
add esp, 4
mov edx, 32 ; 00000020H
sub edx, eax
mov DWORD PTR _v_bit_count$10[ebp], edx
; 311 : __UNIT_TYPE w_bit_count = _MAXIMUM_UNIT(u_bit_count, v_bit_count);
mov eax, DWORD PTR _v_bit_count$10[ebp]
push eax
mov ecx, DWORD PTR _u_bit_count$13[ebp]
push ecx
call __MAXIMUM_UNIT
add esp, 8
mov DWORD PTR _w_bit_count$9[ebp], eax
; 312 : __UNIT_TYPE w_light_check_code;
; 313 : if ((result = AllocateNumber(w, w_bit_count, &w_light_check_code)) != PMC_STATUS_OK)
lea edx, DWORD PTR _w_light_check_code$8[ebp]
push edx
mov eax, DWORD PTR _w_bit_count$9[ebp]
push eax
mov ecx, DWORD PTR _w$[ebp]
push ecx
call _AllocateNumber
add esp, 12 ; 0000000cH
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN14@PMC_Bitwis
; 314 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN14@PMC_Bitwis:
; 315 : BitwiseOr_X_1W(u->BLOCK, u->UNIT_WORD_COUNT, v_lo, (*w)->BLOCK);
mov edx, DWORD PTR _w$[ebp]
mov eax, DWORD PTR [edx]
mov ecx, DWORD PTR [eax+32]
push ecx
mov edx, DWORD PTR _v_lo$11[ebp]
push edx
mov eax, DWORD PTR _u$[ebp]
mov ecx, DWORD PTR [eax+8]
push ecx
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+32]
push eax
call _BitwiseOr_X_1W
add esp, 16 ; 00000010H
; 316 : if ((result = CheckBlockLight((*w)->BLOCK, w_light_check_code)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _w_light_check_code$8[ebp]
push ecx
mov edx, DWORD PTR _w$[ebp]
mov eax, DWORD PTR [edx]
mov ecx, DWORD PTR [eax+32]
push ecx
call _CheckBlockLight
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN15@PMC_Bitwis
; 317 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN15@PMC_Bitwis:
; 318 : }
jmp $LN13@PMC_Bitwis
$LN12@PMC_Bitwis:
; 319 : else
; 320 : {
; 321 : // y の値が 32bit では表現できない場合
; 322 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_32(v_hi);
mov edx, DWORD PTR _v_hi$12[ebp]
push edx
call __LZCNT_ALT_32
add esp, 4
mov ecx, 64 ; 00000040H
sub ecx, eax
mov DWORD PTR _v_bit_count$7[ebp], ecx
; 323 : __UNIT_TYPE w_bit_count = _MAXIMUM_UNIT(u_bit_count, v_bit_count);
mov edx, DWORD PTR _v_bit_count$7[ebp]
push edx
mov eax, DWORD PTR _u_bit_count$13[ebp]
push eax
call __MAXIMUM_UNIT
add esp, 8
mov DWORD PTR _w_bit_count$6[ebp], eax
; 324 : __UNIT_TYPE w_light_check_code;
; 325 : if ((result = AllocateNumber(w, w_bit_count, &w_light_check_code)) != PMC_STATUS_OK)
lea ecx, DWORD PTR _w_light_check_code$5[ebp]
push ecx
mov edx, DWORD PTR _w_bit_count$6[ebp]
push edx
mov eax, DWORD PTR _w$[ebp]
push eax
call _AllocateNumber
add esp, 12 ; 0000000cH
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN16@PMC_Bitwis
; 326 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN16@PMC_Bitwis:
; 327 : BitwiseOr_X_2W(u->BLOCK, u->UNIT_WORD_COUNT, v_hi, v_lo, (*w)->BLOCK);
mov ecx, DWORD PTR _w$[ebp]
mov edx, DWORD PTR [ecx]
mov eax, DWORD PTR [edx+32]
push eax
mov ecx, DWORD PTR _v_lo$11[ebp]
push ecx
mov edx, DWORD PTR _v_hi$12[ebp]
push edx
mov eax, DWORD PTR _u$[ebp]
mov ecx, DWORD PTR [eax+8]
push ecx
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+32]
push eax
call _BitwiseOr_X_2W
add esp, 20 ; 00000014H
; 328 : if ((result = CheckBlockLight((*w)->BLOCK, w_light_check_code)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _w_light_check_code$5[ebp]
push ecx
mov edx, DWORD PTR _w$[ebp]
mov eax, DWORD PTR [edx]
mov ecx, DWORD PTR [eax+32]
push ecx
call _CheckBlockLight
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN13@PMC_Bitwis
; 329 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN13@PMC_Bitwis:
; 330 : }
; 331 : CommitNumber(*w);
mov edx, DWORD PTR _w$[ebp]
mov eax, DWORD PTR [edx]
push eax
call _CommitNumber
add esp, 4
; 332 : }
jmp $LN3@PMC_Bitwis
$LN10@PMC_Bitwis:
; 333 : else
; 334 : {
; 335 : // _UINT64_T が 1 ワードで表現できる場合
; 336 :
; 337 : __UNIT_TYPE u_bit_count = u->UNIT_BIT_COUNT;
mov ecx, DWORD PTR _u$[ebp]
mov edx, DWORD PTR [ecx+12]
mov DWORD PTR _u_bit_count$4[ebp], edx
; 338 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_UNIT((__UNIT_TYPE)v);
mov eax, DWORD PTR _v$[ebp]
push eax
call __LZCNT_ALT_UNIT
add esp, 4
mov ecx, 64 ; 00000040H
sub ecx, eax
mov DWORD PTR _v_bit_count$3[ebp], ecx
; 339 : __UNIT_TYPE w_bit_count = _MAXIMUM_UNIT(u_bit_count, v_bit_count) + 1;
mov edx, DWORD PTR _v_bit_count$3[ebp]
push edx
mov eax, DWORD PTR _u_bit_count$4[ebp]
push eax
call __MAXIMUM_UNIT
add esp, 8
add eax, 1
mov DWORD PTR _w_bit_count$2[ebp], eax
; 340 : __UNIT_TYPE nw_light_check_code;
; 341 : if ((result = AllocateNumber(w, w_bit_count, &nw_light_check_code)) != PMC_STATUS_OK)
lea ecx, DWORD PTR _nw_light_check_code$1[ebp]
push ecx
mov edx, DWORD PTR _w_bit_count$2[ebp]
push edx
mov eax, DWORD PTR _w$[ebp]
push eax
call _AllocateNumber
add esp, 12 ; 0000000cH
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN18@PMC_Bitwis
; 342 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN18@PMC_Bitwis:
; 343 : BitwiseOr_X_1W(u->BLOCK, u->UNIT_WORD_COUNT, (__UNIT_TYPE)v, (*w)->BLOCK);
mov ecx, DWORD PTR _w$[ebp]
mov edx, DWORD PTR [ecx]
mov eax, DWORD PTR [edx+32]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+8]
push eax
mov ecx, DWORD PTR _u$[ebp]
mov edx, DWORD PTR [ecx+32]
push edx
call _BitwiseOr_X_1W
add esp, 16 ; 00000010H
; 344 : if ((result = CheckBlockLight((*w)->BLOCK, nw_light_check_code)) != PMC_STATUS_OK)
mov eax, DWORD PTR _nw_light_check_code$1[ebp]
push eax
mov ecx, DWORD PTR _w$[ebp]
mov edx, DWORD PTR [ecx]
mov eax, DWORD PTR [edx+32]
push eax
call _CheckBlockLight
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN19@PMC_Bitwis
; 345 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN19@PMC_Bitwis:
; 346 : CommitNumber(*w);
mov ecx, DWORD PTR _w$[ebp]
mov edx, DWORD PTR [ecx]
push edx
call _CommitNumber
add esp, 4
$LN3@PMC_Bitwis:
; 347 : }
; 348 : }
; 349 : return (PMC_STATUS_OK);
xor eax, eax
$LN1@PMC_Bitwis:
; 350 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN26@PMC_Bitwis
call @_RTC_CheckStackVars@8
pop eax
pop edx
pop edi
add esp, 88 ; 00000058H
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
npad 2
$LN26@PMC_Bitwis:
DD 4
DD $LN25@PMC_Bitwis
$LN25@PMC_Bitwis:
DD -16 ; fffffff0H
DD 4
DD $LN21@PMC_Bitwis
DD -40 ; ffffffd8H
DD 4
DD $LN22@PMC_Bitwis
DD -60 ; ffffffc4H
DD 4
DD $LN23@PMC_Bitwis
DD -84 ; ffffffacH
DD 4
DD $LN24@PMC_Bitwis
$LN24@PMC_Bitwis:
DB 110 ; 0000006eH
DB 119 ; 00000077H
DB 95 ; 0000005fH
DB 108 ; 0000006cH
DB 105 ; 00000069H
DB 103 ; 00000067H
DB 104 ; 00000068H
DB 116 ; 00000074H
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 104 ; 00000068H
DB 101 ; 00000065H
DB 99 ; 00000063H
DB 107 ; 0000006bH
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 111 ; 0000006fH
DB 100 ; 00000064H
DB 101 ; 00000065H
DB 0
$LN23@PMC_Bitwis:
DB 119 ; 00000077H
DB 95 ; 0000005fH
DB 108 ; 0000006cH
DB 105 ; 00000069H
DB 103 ; 00000067H
DB 104 ; 00000068H
DB 116 ; 00000074H
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 104 ; 00000068H
DB 101 ; 00000065H
DB 99 ; 00000063H
DB 107 ; 0000006bH
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 111 ; 0000006fH
DB 100 ; 00000064H
DB 101 ; 00000065H
DB 0
$LN22@PMC_Bitwis:
DB 119 ; 00000077H
DB 95 ; 0000005fH
DB 108 ; 0000006cH
DB 105 ; 00000069H
DB 103 ; 00000067H
DB 104 ; 00000068H
DB 116 ; 00000074H
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 104 ; 00000068H
DB 101 ; 00000065H
DB 99 ; 00000063H
DB 107 ; 0000006bH
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 111 ; 0000006fH
DB 100 ; 00000064H
DB 101 ; 00000065H
DB 0
$LN21@PMC_Bitwis:
DB 118 ; 00000076H
DB 95 ; 0000005fH
DB 104 ; 00000068H
DB 105 ; 00000069H
DB 0
_PMC_BitwiseOr_X_L_Imp ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_nz_check_code$1 = -24 ; size = 4
_w_bit_count$2 = -16 ; size = 4
_v_bit_count$3 = -12 ; size = 4
_u_bit_count$4 = -8 ; size = 4
_result$ = -4 ; size = 4
_u$ = 8 ; size = 4
_v$ = 12 ; size = 4
_w$ = 16 ; size = 4
_PMC_BitwiseOr_X_I_Imp PROC
; 188 : {
push ebp
mov ebp, esp
sub esp, 28 ; 0000001cH
mov eax, -858993460 ; ccccccccH
mov DWORD PTR [ebp-28], eax
mov DWORD PTR [ebp-24], eax
mov DWORD PTR [ebp-20], eax
mov DWORD PTR [ebp-16], eax
mov DWORD PTR [ebp-12], eax
mov DWORD PTR [ebp-8], eax
mov DWORD PTR [ebp-4], eax
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 189 : PMC_STATUS_CODE result;
; 190 : if (u->IS_ZERO)
mov eax, DWORD PTR _u$[ebp]
mov ecx, DWORD PTR [eax+24]
shr ecx, 1
and ecx, 1
je SHORT $LN2@PMC_Bitwis
; 191 : {
; 192 : // u が 0 である場合
; 193 : if (v == 0)
cmp DWORD PTR _v$[ebp], 0
jne SHORT $LN4@PMC_Bitwis
; 194 : {
; 195 : // v が 0 である場合
; 196 : *w = &number_zero;
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx], OFFSET _number_zero
; 197 : }
jmp SHORT $LN5@PMC_Bitwis
$LN4@PMC_Bitwis:
; 198 : else
; 199 : {
; 200 : // v が 0 でない場合
; 201 : if ((result = From_I_Imp(v, w)) != PMC_STATUS_OK)
mov eax, DWORD PTR _w$[ebp]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
call _From_I_Imp
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN5@PMC_Bitwis
; 202 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN5@PMC_Bitwis:
; 203 : }
; 204 : }
jmp $LN3@PMC_Bitwis
$LN2@PMC_Bitwis:
; 205 : else if (v == 0)
cmp DWORD PTR _v$[ebp], 0
jne SHORT $LN7@PMC_Bitwis
; 206 : {
; 207 : // v が 0 である場合
; 208 : if ((result = DuplicateNumber(u, w)) != PMC_STATUS_OK)
mov edx, DWORD PTR _w$[ebp]
push edx
mov eax, DWORD PTR _u$[ebp]
push eax
call _DuplicateNumber
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN9@PMC_Bitwis
; 209 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN9@PMC_Bitwis:
; 210 : }
jmp $LN3@PMC_Bitwis
$LN7@PMC_Bitwis:
; 211 : else
; 212 : {
; 213 : // x と y がともに 0 ではない場合
; 214 : __UNIT_TYPE u_bit_count = u->UNIT_BIT_COUNT;
mov ecx, DWORD PTR _u$[ebp]
mov edx, DWORD PTR [ecx+12]
mov DWORD PTR _u_bit_count$4[ebp], edx
; 215 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_32(v);
mov eax, DWORD PTR _v$[ebp]
push eax
call __LZCNT_ALT_32
add esp, 4
mov ecx, 32 ; 00000020H
sub ecx, eax
mov DWORD PTR _v_bit_count$3[ebp], ecx
; 216 : __UNIT_TYPE w_bit_count = _MAXIMUM_UNIT(u_bit_count, v_bit_count) + 1;
mov edx, DWORD PTR _v_bit_count$3[ebp]
push edx
mov eax, DWORD PTR _u_bit_count$4[ebp]
push eax
call __MAXIMUM_UNIT
add esp, 8
add eax, 1
mov DWORD PTR _w_bit_count$2[ebp], eax
; 217 : __UNIT_TYPE nz_check_code;
; 218 : if ((result = AllocateNumber(w, w_bit_count, &nz_check_code)) != PMC_STATUS_OK)
lea ecx, DWORD PTR _nz_check_code$1[ebp]
push ecx
mov edx, DWORD PTR _w_bit_count$2[ebp]
push edx
mov eax, DWORD PTR _w$[ebp]
push eax
call _AllocateNumber
add esp, 12 ; 0000000cH
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN10@PMC_Bitwis
; 219 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN10@PMC_Bitwis:
; 220 : BitwiseOr_X_1W(u->BLOCK, u->UNIT_WORD_COUNT, v, (*w)->BLOCK);
mov ecx, DWORD PTR _w$[ebp]
mov edx, DWORD PTR [ecx]
mov eax, DWORD PTR [edx+32]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+8]
push eax
mov ecx, DWORD PTR _u$[ebp]
mov edx, DWORD PTR [ecx+32]
push edx
call _BitwiseOr_X_1W
add esp, 16 ; 00000010H
; 221 : if ((result = CheckBlockLight((*w)->BLOCK, nz_check_code)) != PMC_STATUS_OK)
mov eax, DWORD PTR _nz_check_code$1[ebp]
push eax
mov ecx, DWORD PTR _w$[ebp]
mov edx, DWORD PTR [ecx]
mov eax, DWORD PTR [edx+32]
push eax
call _CheckBlockLight
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN11@PMC_Bitwis
; 222 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN11@PMC_Bitwis:
; 223 : CommitNumber(*w);
mov ecx, DWORD PTR _w$[ebp]
mov edx, DWORD PTR [ecx]
push edx
call _CommitNumber
add esp, 4
$LN3@PMC_Bitwis:
; 224 : }
; 225 : return (PMC_STATUS_OK);
xor eax, eax
$LN1@PMC_Bitwis:
; 226 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN15@PMC_Bitwis
call @_RTC_CheckStackVars@8
pop eax
pop edx
add esp, 28 ; 0000001cH
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
npad 2
$LN15@PMC_Bitwis:
DD 1
DD $LN14@PMC_Bitwis
$LN14@PMC_Bitwis:
DD -24 ; ffffffe8H
DD 4
DD $LN13@PMC_Bitwis
$LN13@PMC_Bitwis:
DB 110 ; 0000006eH
DB 122 ; 0000007aH
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 104 ; 00000068H
DB 101 ; 00000065H
DB 99 ; 00000063H
DB 107 ; 0000006bH
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 111 ; 0000006fH
DB 100 ; 00000064H
DB 101 ; 00000065H
DB 0
_PMC_BitwiseOr_X_I_Imp ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_count$ = -12 ; size = 4
_cp_count$ = -8 ; size = 4
_or_count$ = -4 ; size = 4
_u$ = 8 ; size = 4
_u_count$ = 12 ; size = 4
_v$ = 16 ; size = 4
_v_count$ = 20 ; size = 4
_w$ = 24 ; size = 4
_BitwiseOr_X_X PROC
; 73 : {
push ebp
mov ebp, esp
sub esp, 12 ; 0000000cH
push esi
mov DWORD PTR [ebp-12], -858993460 ; ccccccccH
mov DWORD PTR [ebp-8], -858993460 ; ccccccccH
mov DWORD PTR [ebp-4], -858993460 ; ccccccccH
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 74 : __UNIT_TYPE or_count = v_count;
mov eax, DWORD PTR _v_count$[ebp]
mov DWORD PTR _or_count$[ebp], eax
; 75 : __UNIT_TYPE cp_count = u_count - v_count;
mov ecx, DWORD PTR _u_count$[ebp]
sub ecx, DWORD PTR _v_count$[ebp]
mov DWORD PTR _cp_count$[ebp], ecx
; 76 :
; 77 : __UNIT_TYPE count = or_count >> 5;
mov edx, DWORD PTR _or_count$[ebp]
shr edx, 5
mov DWORD PTR _count$[ebp], edx
$LN2@BitwiseOr_:
; 78 : while (count > 0)
cmp DWORD PTR _count$[ebp], 0
jbe $LN3@BitwiseOr_
; 79 : {
; 80 : w[0] = u[0] | v[0];
mov eax, 4
imul ecx, eax, 0
mov edx, 4
imul eax, edx, 0
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 0
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 81 : w[1] = u[1] | v[1];
mov eax, 4
shl eax, 0
mov ecx, 4
shl ecx, 0
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [edx+eax]
or eax, DWORD PTR [esi+ecx]
mov ecx, 4
shl ecx, 0
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 82 : w[2] = u[2] | v[2];
mov eax, 4
shl eax, 1
mov ecx, 4
shl ecx, 1
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [edx+eax]
or eax, DWORD PTR [esi+ecx]
mov ecx, 4
shl ecx, 1
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 83 : w[3] = u[3] | v[3];
mov eax, 4
imul ecx, eax, 3
mov edx, 4
imul eax, edx, 3
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 3
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 84 : w[4] = u[4] | v[4];
mov eax, 4
shl eax, 2
mov ecx, 4
shl ecx, 2
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [edx+eax]
or eax, DWORD PTR [esi+ecx]
mov ecx, 4
shl ecx, 2
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 85 : w[5] = u[5] | v[5];
mov eax, 4
imul ecx, eax, 5
mov edx, 4
imul eax, edx, 5
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 5
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 86 : w[6] = u[6] | v[6];
mov eax, 4
imul ecx, eax, 6
mov edx, 4
imul eax, edx, 6
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 6
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 87 : w[7] = u[7] | v[7];
mov eax, 4
imul ecx, eax, 7
mov edx, 4
imul eax, edx, 7
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 7
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 88 : w[8] = u[8] | v[8];
mov eax, 4
shl eax, 3
mov ecx, 4
shl ecx, 3
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [edx+eax]
or eax, DWORD PTR [esi+ecx]
mov ecx, 4
shl ecx, 3
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 89 : w[9] = u[9] | v[9];
mov eax, 4
imul ecx, eax, 9
mov edx, 4
imul eax, edx, 9
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 9
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 90 : w[10] = u[10] | v[10];
mov eax, 4
imul ecx, eax, 10
mov edx, 4
imul eax, edx, 10
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 10
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 91 : w[11] = u[11] | v[11];
mov eax, 4
imul ecx, eax, 11
mov edx, 4
imul eax, edx, 11
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 11
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 92 : w[12] = u[12] | v[12];
mov eax, 4
imul ecx, eax, 12
mov edx, 4
imul eax, edx, 12
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 12
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 93 : w[13] = u[13] | v[13];
mov eax, 4
imul ecx, eax, 13
mov edx, 4
imul eax, edx, 13
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 13
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 94 : w[14] = u[14] | v[14];
mov eax, 4
imul ecx, eax, 14
mov edx, 4
imul eax, edx, 14
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 14
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 95 : w[15] = u[15] | v[15];
mov eax, 4
imul ecx, eax, 15
mov edx, 4
imul eax, edx, 15
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 15
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 96 : w[16] = u[16] | v[16];
mov eax, 4
shl eax, 4
mov ecx, 4
shl ecx, 4
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [edx+eax]
or eax, DWORD PTR [esi+ecx]
mov ecx, 4
shl ecx, 4
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 97 : w[17] = u[17] | v[17];
mov eax, 4
imul ecx, eax, 17
mov edx, 4
imul eax, edx, 17
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 17
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 98 : w[18] = u[18] | v[18];
mov eax, 4
imul ecx, eax, 18
mov edx, 4
imul eax, edx, 18
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 18
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 99 : w[19] = u[19] | v[19];
mov eax, 4
imul ecx, eax, 19
mov edx, 4
imul eax, edx, 19
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 19
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 100 : w[20] = u[20] | v[20];
mov eax, 4
imul ecx, eax, 20
mov edx, 4
imul eax, edx, 20
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 20
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 101 : w[21] = u[21] | v[21];
mov eax, 4
imul ecx, eax, 21
mov edx, 4
imul eax, edx, 21
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 21
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 102 : w[22] = u[22] | v[22];
mov eax, 4
imul ecx, eax, 22
mov edx, 4
imul eax, edx, 22
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 22
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 103 : w[23] = u[23] | v[23];
mov eax, 4
imul ecx, eax, 23
mov edx, 4
imul eax, edx, 23
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 23
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 104 : w[24] = u[24] | v[24];
mov eax, 4
imul ecx, eax, 24
mov edx, 4
imul eax, edx, 24
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 24
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 105 : w[25] = u[25] | v[25];
mov eax, 4
imul ecx, eax, 25
mov edx, 4
imul eax, edx, 25
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 25
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 106 : w[26] = u[26] | v[26];
mov eax, 4
imul ecx, eax, 26
mov edx, 4
imul eax, edx, 26
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 26
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 107 : w[27] = u[27] | v[27];
mov eax, 4
imul ecx, eax, 27
mov edx, 4
imul eax, edx, 27
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 27
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 108 : w[28] = u[28] | v[28];
mov eax, 4
imul ecx, eax, 28
mov edx, 4
imul eax, edx, 28
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 28
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 109 : w[29] = u[29] | v[29];
mov eax, 4
imul ecx, eax, 29
mov edx, 4
imul eax, edx, 29
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 29
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 110 : w[30] = u[30] | v[30];
mov eax, 4
imul ecx, eax, 30
mov edx, 4
imul eax, edx, 30
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 30
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 111 : w[31] = u[31] | v[31];
mov eax, 4
imul ecx, eax, 31
mov edx, 4
imul eax, edx, 31
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 31
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 112 : u += 32;
mov eax, DWORD PTR _u$[ebp]
add eax, 128 ; 00000080H
mov DWORD PTR _u$[ebp], eax
; 113 : v += 32;
mov ecx, DWORD PTR _v$[ebp]
add ecx, 128 ; 00000080H
mov DWORD PTR _v$[ebp], ecx
; 114 : w += 32;
mov edx, DWORD PTR _w$[ebp]
add edx, 128 ; 00000080H
mov DWORD PTR _w$[ebp], edx
; 115 : --count;
mov eax, DWORD PTR _count$[ebp]
sub eax, 1
mov DWORD PTR _count$[ebp], eax
; 116 : }
jmp $LN2@BitwiseOr_
$LN3@BitwiseOr_:
; 117 :
; 118 : if (or_count & 0x10)
mov ecx, DWORD PTR _or_count$[ebp]
and ecx, 16 ; 00000010H
je $LN4@BitwiseOr_
; 119 : {
; 120 : w[0] = u[0] | v[0];
mov edx, 4
imul eax, edx, 0
mov ecx, 4
imul edx, ecx, 0
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 0
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 121 : w[1] = u[1] | v[1];
mov edx, 4
shl edx, 0
mov eax, 4
shl eax, 0
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov edx, DWORD PTR [ecx+edx]
or edx, DWORD PTR [esi+eax]
mov eax, 4
shl eax, 0
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+eax], edx
; 122 : w[2] = u[2] | v[2];
mov edx, 4
shl edx, 1
mov eax, 4
shl eax, 1
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov edx, DWORD PTR [ecx+edx]
or edx, DWORD PTR [esi+eax]
mov eax, 4
shl eax, 1
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+eax], edx
; 123 : w[3] = u[3] | v[3];
mov edx, 4
imul eax, edx, 3
mov ecx, 4
imul edx, ecx, 3
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 3
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 124 : w[4] = u[4] | v[4];
mov edx, 4
shl edx, 2
mov eax, 4
shl eax, 2
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov edx, DWORD PTR [ecx+edx]
or edx, DWORD PTR [esi+eax]
mov eax, 4
shl eax, 2
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+eax], edx
; 125 : w[5] = u[5] | v[5];
mov edx, 4
imul eax, edx, 5
mov ecx, 4
imul edx, ecx, 5
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 5
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 126 : w[6] = u[6] | v[6];
mov edx, 4
imul eax, edx, 6
mov ecx, 4
imul edx, ecx, 6
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 6
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 127 : w[7] = u[7] | v[7];
mov edx, 4
imul eax, edx, 7
mov ecx, 4
imul edx, ecx, 7
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 7
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 128 : w[8] = u[8] | v[8];
mov edx, 4
shl edx, 3
mov eax, 4
shl eax, 3
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov edx, DWORD PTR [ecx+edx]
or edx, DWORD PTR [esi+eax]
mov eax, 4
shl eax, 3
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+eax], edx
; 129 : w[9] = u[9] | v[9];
mov edx, 4
imul eax, edx, 9
mov ecx, 4
imul edx, ecx, 9
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 9
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 130 : w[10] = u[10] | v[10];
mov edx, 4
imul eax, edx, 10
mov ecx, 4
imul edx, ecx, 10
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 10
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 131 : w[11] = u[11] | v[11];
mov edx, 4
imul eax, edx, 11
mov ecx, 4
imul edx, ecx, 11
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 11
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 132 : w[12] = u[12] | v[12];
mov edx, 4
imul eax, edx, 12
mov ecx, 4
imul edx, ecx, 12
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 12
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 133 : w[13] = u[13] | v[13];
mov edx, 4
imul eax, edx, 13
mov ecx, 4
imul edx, ecx, 13
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 13
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 134 : w[14] = u[14] | v[14];
mov edx, 4
imul eax, edx, 14
mov ecx, 4
imul edx, ecx, 14
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 14
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 135 : w[15] = u[15] | v[15];
mov edx, 4
imul eax, edx, 15
mov ecx, 4
imul edx, ecx, 15
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 15
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 136 : u += 16;
mov edx, DWORD PTR _u$[ebp]
add edx, 64 ; 00000040H
mov DWORD PTR _u$[ebp], edx
; 137 : v += 16;
mov eax, DWORD PTR _v$[ebp]
add eax, 64 ; 00000040H
mov DWORD PTR _v$[ebp], eax
; 138 : w += 16;
mov ecx, DWORD PTR _w$[ebp]
add ecx, 64 ; 00000040H
mov DWORD PTR _w$[ebp], ecx
$LN4@BitwiseOr_:
; 139 : }
; 140 :
; 141 : if (or_count & 0x8)
mov edx, DWORD PTR _or_count$[ebp]
and edx, 8
je $LN5@BitwiseOr_
; 142 : {
; 143 : w[0] = u[0] | v[0];
mov eax, 4
imul ecx, eax, 0
mov edx, 4
imul eax, edx, 0
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 0
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 144 : w[1] = u[1] | v[1];
mov eax, 4
shl eax, 0
mov ecx, 4
shl ecx, 0
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [edx+eax]
or eax, DWORD PTR [esi+ecx]
mov ecx, 4
shl ecx, 0
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 145 : w[2] = u[2] | v[2];
mov eax, 4
shl eax, 1
mov ecx, 4
shl ecx, 1
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [edx+eax]
or eax, DWORD PTR [esi+ecx]
mov ecx, 4
shl ecx, 1
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 146 : w[3] = u[3] | v[3];
mov eax, 4
imul ecx, eax, 3
mov edx, 4
imul eax, edx, 3
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 3
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 147 : w[4] = u[4] | v[4];
mov eax, 4
shl eax, 2
mov ecx, 4
shl ecx, 2
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [edx+eax]
or eax, DWORD PTR [esi+ecx]
mov ecx, 4
shl ecx, 2
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 148 : w[5] = u[5] | v[5];
mov eax, 4
imul ecx, eax, 5
mov edx, 4
imul eax, edx, 5
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 5
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 149 : w[6] = u[6] | v[6];
mov eax, 4
imul ecx, eax, 6
mov edx, 4
imul eax, edx, 6
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 6
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 150 : w[7] = u[7] | v[7];
mov eax, 4
imul ecx, eax, 7
mov edx, 4
imul eax, edx, 7
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 7
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 151 : u += 8;
mov eax, DWORD PTR _u$[ebp]
add eax, 32 ; 00000020H
mov DWORD PTR _u$[ebp], eax
; 152 : v += 8;
mov ecx, DWORD PTR _v$[ebp]
add ecx, 32 ; 00000020H
mov DWORD PTR _v$[ebp], ecx
; 153 : w += 8;
mov edx, DWORD PTR _w$[ebp]
add edx, 32 ; 00000020H
mov DWORD PTR _w$[ebp], edx
$LN5@BitwiseOr_:
; 154 : }
; 155 :
; 156 : if (or_count & 0x4)
mov eax, DWORD PTR _or_count$[ebp]
and eax, 4
je $LN6@BitwiseOr_
; 157 : {
; 158 : w[0] = u[0] | v[0];
mov ecx, 4
imul edx, ecx, 0
mov eax, 4
imul ecx, eax, 0
mov eax, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov edx, DWORD PTR [eax+edx]
or edx, DWORD PTR [esi+ecx]
mov eax, 4
imul ecx, eax, 0
mov eax, DWORD PTR _w$[ebp]
mov DWORD PTR [eax+ecx], edx
; 159 : w[1] = u[1] | v[1];
mov ecx, 4
shl ecx, 0
mov edx, 4
shl edx, 0
mov eax, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [eax+ecx]
or ecx, DWORD PTR [esi+edx]
mov edx, 4
shl edx, 0
mov eax, DWORD PTR _w$[ebp]
mov DWORD PTR [eax+edx], ecx
; 160 : w[2] = u[2] | v[2];
mov ecx, 4
shl ecx, 1
mov edx, 4
shl edx, 1
mov eax, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [eax+ecx]
or ecx, DWORD PTR [esi+edx]
mov edx, 4
shl edx, 1
mov eax, DWORD PTR _w$[ebp]
mov DWORD PTR [eax+edx], ecx
; 161 : w[3] = u[3] | v[3];
mov ecx, 4
imul edx, ecx, 3
mov eax, 4
imul ecx, eax, 3
mov eax, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov edx, DWORD PTR [eax+edx]
or edx, DWORD PTR [esi+ecx]
mov eax, 4
imul ecx, eax, 3
mov eax, DWORD PTR _w$[ebp]
mov DWORD PTR [eax+ecx], edx
; 162 : u += 4;
mov ecx, DWORD PTR _u$[ebp]
add ecx, 16 ; 00000010H
mov DWORD PTR _u$[ebp], ecx
; 163 : v += 4;
mov edx, DWORD PTR _v$[ebp]
add edx, 16 ; 00000010H
mov DWORD PTR _v$[ebp], edx
; 164 : w += 4;
mov eax, DWORD PTR _w$[ebp]
add eax, 16 ; 00000010H
mov DWORD PTR _w$[ebp], eax
$LN6@BitwiseOr_:
; 165 : }
; 166 :
; 167 : if (or_count & 0x2)
mov ecx, DWORD PTR _or_count$[ebp]
and ecx, 2
je SHORT $LN7@BitwiseOr_
; 168 : {
; 169 : w[0] = u[0] | v[0];
mov edx, 4
imul eax, edx, 0
mov ecx, 4
imul edx, ecx, 0
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov eax, DWORD PTR [ecx+eax]
or eax, DWORD PTR [esi+edx]
mov ecx, 4
imul edx, ecx, 0
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 170 : w[1] = u[1] | v[1];
mov edx, 4
shl edx, 0
mov eax, 4
shl eax, 0
mov ecx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov edx, DWORD PTR [ecx+edx]
or edx, DWORD PTR [esi+eax]
mov eax, 4
shl eax, 0
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+eax], edx
; 171 : u += 2;
mov edx, DWORD PTR _u$[ebp]
add edx, 8
mov DWORD PTR _u$[ebp], edx
; 172 : v += 2;
mov eax, DWORD PTR _v$[ebp]
add eax, 8
mov DWORD PTR _v$[ebp], eax
; 173 : w += 2;
mov ecx, DWORD PTR _w$[ebp]
add ecx, 8
mov DWORD PTR _w$[ebp], ecx
$LN7@BitwiseOr_:
; 174 : }
; 175 :
; 176 : if (or_count & 0x1)
mov edx, DWORD PTR _or_count$[ebp]
and edx, 1
je SHORT $LN8@BitwiseOr_
; 177 : {
; 178 : w[0] = u[0] | v[0];
mov eax, 4
imul ecx, eax, 0
mov edx, 4
imul eax, edx, 0
mov edx, DWORD PTR _u$[ebp]
mov esi, DWORD PTR _v$[ebp]
mov ecx, DWORD PTR [edx+ecx]
or ecx, DWORD PTR [esi+eax]
mov edx, 4
imul eax, edx, 0
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+eax], ecx
; 179 : u += 1;
mov eax, DWORD PTR _u$[ebp]
add eax, 4
mov DWORD PTR _u$[ebp], eax
; 180 : v += 1;
mov ecx, DWORD PTR _v$[ebp]
add ecx, 4
mov DWORD PTR _v$[ebp], ecx
; 181 : w += 1;
mov edx, DWORD PTR _w$[ebp]
add edx, 4
mov DWORD PTR _w$[ebp], edx
$LN8@BitwiseOr_:
; 182 : }
; 183 :
; 184 : _COPY_MEMORY_UNIT(w, u, cp_count);
mov eax, DWORD PTR _cp_count$[ebp]
push eax
mov ecx, DWORD PTR _u$[ebp]
push ecx
mov edx, DWORD PTR _w$[ebp]
push edx
call __COPY_MEMORY_UNIT
add esp, 12 ; 0000000cH
; 185 : }
pop esi
add esp, 12 ; 0000000cH
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
_BitwiseOr_X_X ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_u$ = 8 ; size = 4
_u_count$ = 12 ; size = 4
_v_hi$ = 16 ; size = 4
_v_lo$ = 20 ; size = 4
_w$ = 24 ; size = 4
_BitwiseOr_X_2W PROC
; 52 : {
push ebp
mov ebp, esp
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 53 : if (u_count == 1)
cmp DWORD PTR _u_count$[ebp], 1
jne SHORT $LN2@BitwiseOr_
; 54 : {
; 55 : w[0] = u[0] | v_lo;
mov eax, 4
imul ecx, eax, 0
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+ecx]
or eax, DWORD PTR _v_lo$[ebp]
mov ecx, 4
imul edx, ecx, 0
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 56 : w[1] = v_hi;
mov edx, 4
shl edx, 0
mov eax, DWORD PTR _w$[ebp]
mov ecx, DWORD PTR _v_hi$[ebp]
mov DWORD PTR [eax+edx], ecx
; 57 : }
jmp $LN1@BitwiseOr_
$LN2@BitwiseOr_:
; 58 : else if (u_count == 2)
cmp DWORD PTR _u_count$[ebp], 2
jne SHORT $LN4@BitwiseOr_
; 59 : {
; 60 : w[0] = u[0] | v_lo;
mov edx, 4
imul eax, edx, 0
mov ecx, DWORD PTR _u$[ebp]
mov edx, DWORD PTR [ecx+eax]
or edx, DWORD PTR _v_lo$[ebp]
mov eax, 4
imul ecx, eax, 0
mov eax, DWORD PTR _w$[ebp]
mov DWORD PTR [eax+ecx], edx
; 61 : w[1] = u[1] | v_hi;
mov ecx, 4
shl ecx, 0
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+ecx]
or eax, DWORD PTR _v_hi$[ebp]
mov ecx, 4
shl ecx, 0
mov edx, DWORD PTR _w$[ebp]
mov DWORD PTR [edx+ecx], eax
; 62 : }
jmp SHORT $LN1@BitwiseOr_
$LN4@BitwiseOr_:
; 63 : else
; 64 : {
; 65 : w[0] = u[0] | v_lo;
mov eax, 4
imul ecx, eax, 0
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+ecx]
or eax, DWORD PTR _v_lo$[ebp]
mov ecx, 4
imul edx, ecx, 0
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
; 66 : w[1] = u[1] | v_hi;
mov edx, 4
shl edx, 0
mov eax, DWORD PTR _u$[ebp]
mov ecx, DWORD PTR [eax+edx]
or ecx, DWORD PTR _v_hi$[ebp]
mov edx, 4
shl edx, 0
mov eax, DWORD PTR _w$[ebp]
mov DWORD PTR [eax+edx], ecx
; 67 : _COPY_MEMORY_UNIT(w + 2, u + 2, u_count - 2);
mov ecx, DWORD PTR _u_count$[ebp]
sub ecx, 2
push ecx
mov edx, DWORD PTR _u$[ebp]
add edx, 8
push edx
mov eax, DWORD PTR _w$[ebp]
add eax, 8
push eax
call __COPY_MEMORY_UNIT
add esp, 12 ; 0000000cH
$LN1@BitwiseOr_:
; 68 : }
; 69 : }
cmp ebp, esp
call __RTC_CheckEsp
pop ebp
ret 0
_BitwiseOr_X_2W ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_u$ = 8 ; size = 4
_u_count$ = 12 ; size = 4
_v$ = 16 ; size = 4
_w$ = 20 ; size = 4
_BitwiseOr_X_1W PROC
; 40 : {
push ebp
mov ebp, esp
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 41 : if (u_count == 1)
cmp DWORD PTR _u_count$[ebp], 1
jne SHORT $LN2@BitwiseOr_
; 42 : w[0] = u[0] | v;
mov eax, 4
imul ecx, eax, 0
mov edx, DWORD PTR _u$[ebp]
mov eax, DWORD PTR [edx+ecx]
or eax, DWORD PTR _v$[ebp]
mov ecx, 4
imul edx, ecx, 0
mov ecx, DWORD PTR _w$[ebp]
mov DWORD PTR [ecx+edx], eax
jmp SHORT $LN1@BitwiseOr_
$LN2@BitwiseOr_:
; 43 : else
; 44 : {
; 45 : w[0] = u[0] | v;
mov edx, 4
imul eax, edx, 0
mov ecx, DWORD PTR _u$[ebp]
mov edx, DWORD PTR [ecx+eax]
or edx, DWORD PTR _v$[ebp]
mov eax, 4
imul ecx, eax, 0
mov eax, DWORD PTR _w$[ebp]
mov DWORD PTR [eax+ecx], edx
; 46 : _COPY_MEMORY_UNIT(w + 1, u + 1, u_count - 1);
mov ecx, DWORD PTR _u_count$[ebp]
sub ecx, 1
push ecx
mov edx, DWORD PTR _u$[ebp]
add edx, 4
push edx
mov eax, DWORD PTR _w$[ebp]
add eax, 4
push eax
call __COPY_MEMORY_UNIT
add esp, 12 ; 0000000cH
$LN1@BitwiseOr_:
; 47 : }
; 48 : }
cmp ebp, esp
call __RTC_CheckEsp
pop ebp
ret 0
_BitwiseOr_X_1W ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
_TEXT SEGMENT
_pos$ = -8 ; size = 4
_x$ = 8 ; size = 4
__LZCNT_ALT_UNIT PROC
; 629 : {
push ebp
mov ebp, esp
sub esp, 12 ; 0000000cH
mov DWORD PTR [ebp-12], -858993460 ; ccccccccH
mov DWORD PTR [ebp-8], -858993460 ; ccccccccH
mov DWORD PTR [ebp-4], -858993460 ; ccccccccH
mov ecx, OFFSET __6B0481B0_pmc_inline_func@h
call @__CheckForDebuggerJustMyCode@4
; 630 : if (x == 0)
cmp DWORD PTR _x$[ebp], 0
jne SHORT $LN2@LZCNT_ALT_
; 631 : return (sizeof(x) * 8);
mov eax, 32 ; 00000020H
jmp SHORT $LN1@LZCNT_ALT_
$LN2@LZCNT_ALT_:
; 632 : #ifdef _M_IX86
; 633 : _UINT32_T pos;
; 634 : #ifdef _MSC_VER
; 635 : _BitScanReverse(&pos, x);
bsr eax, DWORD PTR _x$[ebp]
mov DWORD PTR _pos$[ebp], eax
; 636 : #elif defined(__GNUC__)
; 637 : __asm__("bsrl %1, %0" : "=r"(pos) : "rm"(x));
; 638 : #else
; 639 : #error unknown compiler
; 640 : #endif
; 641 : #elif defined(_M_X64)
; 642 : #ifdef _MSC_VER
; 643 : _UINT32_T pos;
; 644 : _BitScanReverse64(&pos, x);
; 645 : #elif defined(__GNUC__)
; 646 : _UINT64_T pos;
; 647 : __asm__("bsrq %1, %0" : "=r"(pos) : "rm"(x));
; 648 : #else
; 649 : #error unknown compiler
; 650 : #endif
; 651 : #else
; 652 : #error unknown platform
; 653 : #endif
; 654 : return (sizeof(x) * 8 - 1 - pos);
mov eax, 31 ; 0000001fH
sub eax, DWORD PTR _pos$[ebp]
$LN1@LZCNT_ALT_:
; 655 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN6@LZCNT_ALT_
call @_RTC_CheckStackVars@8
pop eax
pop edx
add esp, 12 ; 0000000cH
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
$LN6@LZCNT_ALT_:
DD 1
DD $LN5@LZCNT_ALT_
$LN5@LZCNT_ALT_:
DD -8 ; fffffff8H
DD 4
DD $LN4@LZCNT_ALT_
$LN4@LZCNT_ALT_:
DB 112 ; 00000070H
DB 111 ; 0000006fH
DB 115 ; 00000073H
DB 0
__LZCNT_ALT_UNIT ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
_TEXT SEGMENT
_pos$ = -8 ; size = 4
_x$ = 8 ; size = 4
__LZCNT_ALT_32 PROC
; 596 : {
push ebp
mov ebp, esp
sub esp, 12 ; 0000000cH
mov DWORD PTR [ebp-12], -858993460 ; ccccccccH
mov DWORD PTR [ebp-8], -858993460 ; ccccccccH
mov DWORD PTR [ebp-4], -858993460 ; ccccccccH
mov ecx, OFFSET __6B0481B0_pmc_inline_func@h
call @__CheckForDebuggerJustMyCode@4
; 597 : if (x == 0)
cmp DWORD PTR _x$[ebp], 0
jne SHORT $LN2@LZCNT_ALT_
; 598 : return (sizeof(x) * 8);
mov eax, 32 ; 00000020H
jmp SHORT $LN1@LZCNT_ALT_
$LN2@LZCNT_ALT_:
; 599 : _UINT32_T pos;
; 600 : #ifdef _MSC_VER
; 601 : _BitScanReverse(&pos, x);
bsr eax, DWORD PTR _x$[ebp]
mov DWORD PTR _pos$[ebp], eax
; 602 : #elif defined(__GNUC__)
; 603 : __asm__("bsrl %1, %0" : "=r"(pos) : "rm"(x));
; 604 : #else
; 605 : #error unknown compiler
; 606 : #endif
; 607 : return (sizeof(x) * 8 - 1 - pos);
mov eax, 31 ; 0000001fH
sub eax, DWORD PTR _pos$[ebp]
$LN1@LZCNT_ALT_:
; 608 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN6@LZCNT_ALT_
call @_RTC_CheckStackVars@8
pop eax
pop edx
add esp, 12 ; 0000000cH
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
$LN6@LZCNT_ALT_:
DD 1
DD $LN5@LZCNT_ALT_
$LN5@LZCNT_ALT_:
DD -8 ; fffffff8H
DD 4
DD $LN4@LZCNT_ALT_
$LN4@LZCNT_ALT_:
DB 112 ; 00000070H
DB 111 ; 0000006fH
DB 115 ; 00000073H
DB 0
__LZCNT_ALT_32 ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
_TEXT SEGMENT
tv65 = -4 ; size = 4
_x$ = 8 ; size = 4
_y$ = 12 ; size = 4
__MAXIMUM_UNIT PROC
; 203 : {
push ebp
mov ebp, esp
push ecx
mov DWORD PTR [ebp-4], -858993460 ; ccccccccH
mov ecx, OFFSET __6B0481B0_pmc_inline_func@h
call @__CheckForDebuggerJustMyCode@4
; 204 : return (x >= y ? x : y);
mov eax, DWORD PTR _x$[ebp]
cmp eax, DWORD PTR _y$[ebp]
jb SHORT $LN3@MAXIMUM_UN
mov ecx, DWORD PTR _x$[ebp]
mov DWORD PTR tv65[ebp], ecx
jmp SHORT $LN4@MAXIMUM_UN
$LN3@MAXIMUM_UN:
mov edx, DWORD PTR _y$[ebp]
mov DWORD PTR tv65[ebp], edx
$LN4@MAXIMUM_UN:
mov eax, DWORD PTR tv65[ebp]
; 205 : }
add esp, 4
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
__MAXIMUM_UNIT ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
_TEXT SEGMENT
_value$ = 8 ; size = 8
_result_high$ = 16 ; size = 4
__FROMDWORDTOWORD PROC
; 182 : {
push ebp
mov ebp, esp
mov ecx, OFFSET __6B0481B0_pmc_inline_func@h
call @__CheckForDebuggerJustMyCode@4
; 183 : *result_high = (_UINT32_T)(value >> 32);
mov eax, DWORD PTR _value$[ebp]
mov edx, DWORD PTR _value$[ebp+4]
mov cl, 32 ; 00000020H
call __aullshr
mov ecx, DWORD PTR _result_high$[ebp]
mov DWORD PTR [ecx], eax
; 184 : return ((_UINT32_T)value);
mov eax, DWORD PTR _value$[ebp]
; 185 : }
cmp ebp, esp
call __RTC_CheckEsp
pop ebp
ret 0
__FROMDWORDTOWORD ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
_TEXT SEGMENT
_d$ = 8 ; size = 4
_s$ = 12 ; size = 4
_count$ = 16 ; size = 4
__COPY_MEMORY_UNIT PROC
; 66 : {
push ebp
mov ebp, esp
push esi
push edi
mov ecx, OFFSET __6B0481B0_pmc_inline_func@h
call @__CheckForDebuggerJustMyCode@4
; 67 : #ifdef _M_IX86
; 68 : __movsd((unsigned long *)d, (unsigned long *)s, (unsigned long)count);
mov edi, DWORD PTR _d$[ebp]
mov esi, DWORD PTR _s$[ebp]
mov ecx, DWORD PTR _count$[ebp]
rep movsd
; 69 : #elif defined(_M_X64)
; 70 : __movsq(d, s, count);
; 71 : #else
; 72 : #error unknown platform
; 73 : #endif
; 74 : }
pop edi
pop esi
cmp ebp, esp
call __RTC_CheckEsp
pop ebp
ret 0
__COPY_MEMORY_UNIT ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_nw_light_check_code$1 = -48 ; size = 4
_w_bit_count$2 = -40 ; size = 4
_v_bit_count$3 = -36 ; size = 4
_u_bit_count$4 = -32 ; size = 4
_t$5 = -28 ; size = 4
_nw$ = -20 ; size = 4
_result$ = -12 ; size = 4
_nv$ = -8 ; size = 4
_nu$ = -4 ; size = 4
_u$ = 8 ; size = 4
_v$ = 12 ; size = 4
_w$ = 16 ; size = 4
_PMC_BitwiseOr_X_X@12 PROC
; 399 : {
push ebp
mov ebp, esp
sub esp, 52 ; 00000034H
push edi
lea edi, DWORD PTR [ebp-52]
mov ecx, 13 ; 0000000dH
mov eax, -858993460 ; ccccccccH
rep stosd
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 400 : if (u == NULL)
cmp DWORD PTR _u$[ebp], 0
jne SHORT $LN2@PMC_Bitwis
; 401 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp $LN1@PMC_Bitwis
$LN2@PMC_Bitwis:
; 402 : if (v == NULL)
cmp DWORD PTR _v$[ebp], 0
jne SHORT $LN3@PMC_Bitwis
; 403 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp $LN1@PMC_Bitwis
$LN3@PMC_Bitwis:
; 404 : if (w == NULL)
cmp DWORD PTR _w$[ebp], 0
jne SHORT $LN4@PMC_Bitwis
; 405 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp $LN1@PMC_Bitwis
$LN4@PMC_Bitwis:
; 406 : NUMBER_HEADER* nu = (NUMBER_HEADER*)u;
mov eax, DWORD PTR _u$[ebp]
mov DWORD PTR _nu$[ebp], eax
; 407 : NUMBER_HEADER* nv = (NUMBER_HEADER*)v;
mov ecx, DWORD PTR _v$[ebp]
mov DWORD PTR _nv$[ebp], ecx
; 408 : PMC_STATUS_CODE result;
; 409 : if ((result = CheckNumber(nu)) != PMC_STATUS_OK)
mov edx, DWORD PTR _nu$[ebp]
push edx
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN5@PMC_Bitwis
; 410 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN5@PMC_Bitwis:
; 411 : if ((result = CheckNumber(nv)) != PMC_STATUS_OK)
mov eax, DWORD PTR _nv$[ebp]
push eax
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN6@PMC_Bitwis
; 412 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN6@PMC_Bitwis:
; 413 : NUMBER_HEADER* nw;
; 414 : if (nu->IS_ZERO)
mov ecx, DWORD PTR _nu$[ebp]
mov edx, DWORD PTR [ecx+24]
shr edx, 1
and edx, 1
je SHORT $LN7@PMC_Bitwis
; 415 : {
; 416 : if ((result = DuplicateNumber(nv, &nw)) != PMC_STATUS_OK)
lea eax, DWORD PTR _nw$[ebp]
push eax
mov ecx, DWORD PTR _nv$[ebp]
push ecx
call _DuplicateNumber
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN9@PMC_Bitwis
; 417 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN9@PMC_Bitwis:
; 418 : }
jmp $LN8@PMC_Bitwis
$LN7@PMC_Bitwis:
; 419 : else if (nv->IS_ZERO)
mov edx, DWORD PTR _nv$[ebp]
mov eax, DWORD PTR [edx+24]
shr eax, 1
and eax, 1
je SHORT $LN10@PMC_Bitwis
; 420 : {
; 421 : if ((result = DuplicateNumber(nu, &nw)) != PMC_STATUS_OK)
lea ecx, DWORD PTR _nw$[ebp]
push ecx
mov edx, DWORD PTR _nu$[ebp]
push edx
call _DuplicateNumber
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN12@PMC_Bitwis
; 422 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp $LN1@PMC_Bitwis
$LN12@PMC_Bitwis:
; 423 : }
jmp $LN8@PMC_Bitwis
$LN10@PMC_Bitwis:
; 424 : else
; 425 : {
; 426 : if (nu->UNIT_WORD_COUNT < nv->UNIT_WORD_COUNT)
mov eax, DWORD PTR _nu$[ebp]
mov ecx, DWORD PTR _nv$[ebp]
mov edx, DWORD PTR [eax+8]
cmp edx, DWORD PTR [ecx+8]
jae SHORT $LN13@PMC_Bitwis
; 427 : {
; 428 : NUMBER_HEADER* t = nu;
mov eax, DWORD PTR _nu$[ebp]
mov DWORD PTR _t$5[ebp], eax
; 429 : nu = nv;
mov ecx, DWORD PTR _nv$[ebp]
mov DWORD PTR _nu$[ebp], ecx
; 430 : nv = t;
mov edx, DWORD PTR _t$5[ebp]
mov DWORD PTR _nv$[ebp], edx
$LN13@PMC_Bitwis:
; 431 : }
; 432 : __UNIT_TYPE u_bit_count = nu->UNIT_BIT_COUNT;
mov eax, DWORD PTR _nu$[ebp]
mov ecx, DWORD PTR [eax+12]
mov DWORD PTR _u_bit_count$4[ebp], ecx
; 433 : __UNIT_TYPE v_bit_count = nv->UNIT_BIT_COUNT;
mov edx, DWORD PTR _nv$[ebp]
mov eax, DWORD PTR [edx+12]
mov DWORD PTR _v_bit_count$3[ebp], eax
; 434 : __UNIT_TYPE w_bit_count = _MAXIMUM_UNIT(u_bit_count, v_bit_count);
mov ecx, DWORD PTR _v_bit_count$3[ebp]
push ecx
mov edx, DWORD PTR _u_bit_count$4[ebp]
push edx
call __MAXIMUM_UNIT
add esp, 8
mov DWORD PTR _w_bit_count$2[ebp], eax
; 435 : __UNIT_TYPE nw_light_check_code;
; 436 : if ((result = AllocateNumber(&nw, w_bit_count, &nw_light_check_code)) != PMC_STATUS_OK)
lea eax, DWORD PTR _nw_light_check_code$1[ebp]
push eax
mov ecx, DWORD PTR _w_bit_count$2[ebp]
push ecx
lea edx, DWORD PTR _nw$[ebp]
push edx
call _AllocateNumber
add esp, 12 ; 0000000cH
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN14@PMC_Bitwis
; 437 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN14@PMC_Bitwis:
; 438 : BitwiseOr_X_X(nu->BLOCK, nu->UNIT_WORD_COUNT, nv->BLOCK, nv->UNIT_WORD_COUNT, nw->BLOCK);
mov eax, DWORD PTR _nw$[ebp]
mov ecx, DWORD PTR [eax+32]
push ecx
mov edx, DWORD PTR _nv$[ebp]
mov eax, DWORD PTR [edx+8]
push eax
mov ecx, DWORD PTR _nv$[ebp]
mov edx, DWORD PTR [ecx+32]
push edx
mov eax, DWORD PTR _nu$[ebp]
mov ecx, DWORD PTR [eax+8]
push ecx
mov edx, DWORD PTR _nu$[ebp]
mov eax, DWORD PTR [edx+32]
push eax
call _BitwiseOr_X_X
add esp, 20 ; 00000014H
; 439 : if ((result = CheckBlockLight(nw->BLOCK, nw_light_check_code)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _nw_light_check_code$1[ebp]
push ecx
mov edx, DWORD PTR _nw$[ebp]
mov eax, DWORD PTR [edx+32]
push eax
call _CheckBlockLight
add esp, 8
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN15@PMC_Bitwis
; 440 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN15@PMC_Bitwis:
; 441 : CommitNumber(nw);
mov ecx, DWORD PTR _nw$[ebp]
push ecx
call _CommitNumber
add esp, 4
$LN8@PMC_Bitwis:
; 442 : }
; 443 : *w = nw;
mov edx, DWORD PTR _w$[ebp]
mov eax, DWORD PTR _nw$[ebp]
mov DWORD PTR [edx], eax
; 444 : #ifdef _DEBUG
; 445 : if ((result = CheckNumber(*w)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _w$[ebp]
mov edx, DWORD PTR [ecx]
push edx
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN16@PMC_Bitwis
; 446 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN16@PMC_Bitwis:
; 447 : #endif
; 448 : return (PMC_STATUS_OK);
xor eax, eax
$LN1@PMC_Bitwis:
; 449 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN21@PMC_Bitwis
call @_RTC_CheckStackVars@8
pop eax
pop edx
pop edi
add esp, 52 ; 00000034H
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 12 ; 0000000cH
npad 3
$LN21@PMC_Bitwis:
DD 2
DD $LN20@PMC_Bitwis
$LN20@PMC_Bitwis:
DD -20 ; ffffffecH
DD 4
DD $LN18@PMC_Bitwis
DD -48 ; ffffffd0H
DD 4
DD $LN19@PMC_Bitwis
$LN19@PMC_Bitwis:
DB 110 ; 0000006eH
DB 119 ; 00000077H
DB 95 ; 0000005fH
DB 108 ; 0000006cH
DB 105 ; 00000069H
DB 103 ; 00000067H
DB 104 ; 00000068H
DB 116 ; 00000074H
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 104 ; 00000068H
DB 101 ; 00000065H
DB 99 ; 00000063H
DB 107 ; 0000006bH
DB 95 ; 0000005fH
DB 99 ; 00000063H
DB 111 ; 0000006fH
DB 100 ; 00000064H
DB 101 ; 00000065H
DB 0
$LN18@PMC_Bitwis:
DB 110 ; 0000006eH
DB 119 ; 00000077H
DB 0
_PMC_BitwiseOr_X_X@12 ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_result$ = -4 ; size = 4
_u$ = 8 ; size = 4
_v$ = 12 ; size = 8
_w$ = 20 ; size = 4
_PMC_BitwiseOr_X_L@16 PROC
; 376 : {
push ebp
mov ebp, esp
push ecx
mov DWORD PTR [ebp-4], -858993460 ; ccccccccH
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 377 : if (__UNIT_TYPE_BIT_COUNT * 2 < sizeof(v) * 8)
xor eax, eax
je SHORT $LN2@PMC_Bitwis
; 378 : {
; 379 : // _UINT64_T が 2 ワードで表現しきれない処理系には対応しない
; 380 : return (PMC_STATUS_INTERNAL_ERROR);
mov eax, -256 ; ffffff00H
jmp SHORT $LN1@PMC_Bitwis
$LN2@PMC_Bitwis:
; 381 : }
; 382 : if (u == NULL)
cmp DWORD PTR _u$[ebp], 0
jne SHORT $LN3@PMC_Bitwis
; 383 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp SHORT $LN1@PMC_Bitwis
$LN3@PMC_Bitwis:
; 384 : if (w == NULL)
cmp DWORD PTR _w$[ebp], 0
jne SHORT $LN4@PMC_Bitwis
; 385 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp SHORT $LN1@PMC_Bitwis
$LN4@PMC_Bitwis:
; 386 : PMC_STATUS_CODE result;
; 387 : if ((result = CheckNumber((NUMBER_HEADER*)u)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _u$[ebp]
push ecx
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN5@PMC_Bitwis
; 388 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN5@PMC_Bitwis:
; 389 : if ((result = PMC_BitwiseOr_X_L_Imp((NUMBER_HEADER*)u, v, (NUMBER_HEADER**)w)) != PMC_STATUS_OK)
mov edx, DWORD PTR _w$[ebp]
push edx
mov eax, DWORD PTR _v$[ebp+4]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _u$[ebp]
push edx
call _PMC_BitwiseOr_X_L_Imp
add esp, 16 ; 00000010H
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN6@PMC_Bitwis
; 390 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN6@PMC_Bitwis:
; 391 : #ifdef _DEBUG
; 392 : if ((result = CheckNumber(*w)) != PMC_STATUS_OK)
mov eax, DWORD PTR _w$[ebp]
mov ecx, DWORD PTR [eax]
push ecx
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN7@PMC_Bitwis
; 393 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN7@PMC_Bitwis:
; 394 : #endif
; 395 : return (PMC_STATUS_OK);
xor eax, eax
$LN1@PMC_Bitwis:
; 396 : }
add esp, 4
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 16 ; 00000010H
_PMC_BitwiseOr_X_L@16 ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_result$ = -4 ; size = 4
_u$ = 8 ; size = 4
_v$ = 12 ; size = 4
_w$ = 16 ; size = 4
_PMC_BitwiseOr_X_I@12 PROC
; 252 : {
push ebp
mov ebp, esp
push ecx
mov DWORD PTR [ebp-4], -858993460 ; ccccccccH
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 253 : if (__UNIT_TYPE_BIT_COUNT < sizeof(v) * 8)
xor eax, eax
je SHORT $LN2@PMC_Bitwis
; 254 : {
; 255 : // _UINT32_T が 1 ワードで表現しきれない処理系には対応しない
; 256 : return (PMC_STATUS_INTERNAL_ERROR);
mov eax, -256 ; ffffff00H
jmp SHORT $LN1@PMC_Bitwis
$LN2@PMC_Bitwis:
; 257 : }
; 258 : if (u == NULL)
cmp DWORD PTR _u$[ebp], 0
jne SHORT $LN3@PMC_Bitwis
; 259 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp SHORT $LN1@PMC_Bitwis
$LN3@PMC_Bitwis:
; 260 : if (w == NULL)
cmp DWORD PTR _w$[ebp], 0
jne SHORT $LN4@PMC_Bitwis
; 261 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp SHORT $LN1@PMC_Bitwis
$LN4@PMC_Bitwis:
; 262 : PMC_STATUS_CODE result;
; 263 : if ((result = CheckNumber((NUMBER_HEADER*)u)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _u$[ebp]
push ecx
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN5@PMC_Bitwis
; 264 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN5@PMC_Bitwis:
; 265 : if ((result = PMC_BitwiseOr_X_I_Imp((NUMBER_HEADER*)u, v, (NUMBER_HEADER**)w)) != PMC_STATUS_OK)
mov edx, DWORD PTR _w$[ebp]
push edx
mov eax, DWORD PTR _v$[ebp]
push eax
mov ecx, DWORD PTR _u$[ebp]
push ecx
call _PMC_BitwiseOr_X_I_Imp
add esp, 12 ; 0000000cH
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN6@PMC_Bitwis
; 266 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN6@PMC_Bitwis:
; 267 : #ifdef _DEBUG
; 268 : if ((result = CheckNumber(*w)) != PMC_STATUS_OK)
mov edx, DWORD PTR _w$[ebp]
mov eax, DWORD PTR [edx]
push eax
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN7@PMC_Bitwis
; 269 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN7@PMC_Bitwis:
; 270 : #endif
; 271 : return (PMC_STATUS_OK);
xor eax, eax
$LN1@PMC_Bitwis:
; 272 : }
add esp, 4
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 12 ; 0000000cH
_PMC_BitwiseOr_X_I@12 ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_result$ = -4 ; size = 4
_u$ = 8 ; size = 8
_v$ = 16 ; size = 4
_w$ = 20 ; size = 4
_PMC_BitwiseOr_L_X@16 PROC
; 353 : {
push ebp
mov ebp, esp
push ecx
mov DWORD PTR [ebp-4], -858993460 ; ccccccccH
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 354 : if (__UNIT_TYPE_BIT_COUNT * 2 < sizeof(u) * 8)
xor eax, eax
je SHORT $LN2@PMC_Bitwis
; 355 : {
; 356 : // _UINT64_T が 2 ワードで表現しきれない処理系には対応しない
; 357 : return (PMC_STATUS_INTERNAL_ERROR);
mov eax, -256 ; ffffff00H
jmp SHORT $LN1@PMC_Bitwis
$LN2@PMC_Bitwis:
; 358 : }
; 359 : if (v == NULL)
cmp DWORD PTR _v$[ebp], 0
jne SHORT $LN3@PMC_Bitwis
; 360 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp SHORT $LN1@PMC_Bitwis
$LN3@PMC_Bitwis:
; 361 : if (w == NULL)
cmp DWORD PTR _w$[ebp], 0
jne SHORT $LN4@PMC_Bitwis
; 362 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp SHORT $LN1@PMC_Bitwis
$LN4@PMC_Bitwis:
; 363 : PMC_STATUS_CODE result;
; 364 : if ((result = CheckNumber((NUMBER_HEADER*)v)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _v$[ebp]
push ecx
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN5@PMC_Bitwis
; 365 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN5@PMC_Bitwis:
; 366 : if ((result = PMC_BitwiseOr_X_L_Imp((NUMBER_HEADER*)v, u, (NUMBER_HEADER**)w)) != PMC_STATUS_OK)
mov edx, DWORD PTR _w$[ebp]
push edx
mov eax, DWORD PTR _u$[ebp+4]
push eax
mov ecx, DWORD PTR _u$[ebp]
push ecx
mov edx, DWORD PTR _v$[ebp]
push edx
call _PMC_BitwiseOr_X_L_Imp
add esp, 16 ; 00000010H
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN6@PMC_Bitwis
; 367 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN6@PMC_Bitwis:
; 368 : #ifdef _DEBUG
; 369 : if ((result = CheckNumber(*w)) != PMC_STATUS_OK)
mov eax, DWORD PTR _w$[ebp]
mov ecx, DWORD PTR [eax]
push ecx
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN7@PMC_Bitwis
; 370 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN7@PMC_Bitwis:
; 371 : #endif
; 372 : return (PMC_STATUS_OK);
xor eax, eax
$LN1@PMC_Bitwis:
; 373 : }
add esp, 4
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 16 ; 00000010H
_PMC_BitwiseOr_L_X@16 ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_result$ = -4 ; size = 4
_u$ = 8 ; size = 4
_v$ = 12 ; size = 4
_w$ = 16 ; size = 4
_PMC_BitwiseOr_I_X@12 PROC
; 229 : {
push ebp
mov ebp, esp
push ecx
mov DWORD PTR [ebp-4], -858993460 ; ccccccccH
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 230 : if (__UNIT_TYPE_BIT_COUNT < sizeof(u) * 8)
xor eax, eax
je SHORT $LN2@PMC_Bitwis
; 231 : {
; 232 : // _UINT32_T が 1 ワードで表現しきれない処理系には対応しない
; 233 : return (PMC_STATUS_INTERNAL_ERROR);
mov eax, -256 ; ffffff00H
jmp SHORT $LN1@PMC_Bitwis
$LN2@PMC_Bitwis:
; 234 : }
; 235 : if (v == NULL)
cmp DWORD PTR _v$[ebp], 0
jne SHORT $LN3@PMC_Bitwis
; 236 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp SHORT $LN1@PMC_Bitwis
$LN3@PMC_Bitwis:
; 237 : if (w == NULL)
cmp DWORD PTR _w$[ebp], 0
jne SHORT $LN4@PMC_Bitwis
; 238 : return (PMC_STATUS_ARGUMENT_ERROR);
or eax, -1
jmp SHORT $LN1@PMC_Bitwis
$LN4@PMC_Bitwis:
; 239 : PMC_STATUS_CODE result;
; 240 : if ((result = CheckNumber((NUMBER_HEADER*)v)) != PMC_STATUS_OK)
mov ecx, DWORD PTR _v$[ebp]
push ecx
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN5@PMC_Bitwis
; 241 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN5@PMC_Bitwis:
; 242 : if ((result = PMC_BitwiseOr_X_I_Imp((NUMBER_HEADER*)v, u, (NUMBER_HEADER**)w)) != PMC_STATUS_OK)
mov edx, DWORD PTR _w$[ebp]
push edx
mov eax, DWORD PTR _u$[ebp]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
call _PMC_BitwiseOr_X_I_Imp
add esp, 12 ; 0000000cH
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN6@PMC_Bitwis
; 243 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN6@PMC_Bitwis:
; 244 : #ifdef _DEBUG
; 245 : if ((result = CheckNumber(*w)) != PMC_STATUS_OK)
mov edx, DWORD PTR _w$[ebp]
mov eax, DWORD PTR [edx]
push eax
call _CheckNumber
add esp, 4
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
je SHORT $LN7@PMC_Bitwis
; 246 : return (result);
mov eax, DWORD PTR _result$[ebp]
jmp SHORT $LN1@PMC_Bitwis
$LN7@PMC_Bitwis:
; 247 : #endif
; 248 : return (PMC_STATUS_OK);
xor eax, eax
$LN1@PMC_Bitwis:
; 249 : }
add esp, 4
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 12 ; 0000000cH
_PMC_BitwiseOr_I_X@12 ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_bitwiseor.c
_TEXT SEGMENT
_feature$ = 8 ; size = 4
_Initialize_BitwiseOr PROC
; 452 : {
push ebp
mov ebp, esp
mov ecx, OFFSET __AC60EF90_pmc_bitwiseor@c
call @__CheckForDebuggerJustMyCode@4
; 453 : return (PMC_STATUS_OK);
xor eax, eax
; 454 : }
cmp ebp, esp
call __RTC_CheckEsp
pop ebp
ret 0
_Initialize_BitwiseOr ENDP
_TEXT ENDS
END
|
k0/src/arch/x64/_x64.asm | nebulaeonline/nebulae | 29 | 174323 | <filename>k0/src/arch/x64/_x64.asm
; Copyright (c) 2003-2018 RCH3 (<EMAIL>)
; Copyright (c) 2019 Nebulae Foundation, LLC. All rights reserved.
; Copyright (c) 2006, Intel Corporation. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice,
; this list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
; 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.
;==================================
global x64OutportB, x64OutportW
global x64InportB, x64InportW
global x64EnableInterrupts, x64DisableInterrupts
global x64ReadTsc, x64ReadCR3
global x64WriteCR3, x64ReadGdtr, x64WriteGdtr
global x64ReadIdtr, x64WriteIdtr, x64ReadCR2
global x64ReadCS, x64ReadDS, x64ReadSS
global x64ReadES, x64ReadFS, x64ReadGS
global x64LoadTR, x64InvalidatePage, x64AtomicOr
global x64AtomicAnd, x64AtomicXor, x64AtomicAdd
global x64AtomicSub, x64AtomicInc, x64AtomicDec
global x64AtomicDecAndTestZero,
global x64SpinlockAcquire, x64SpinlockRelease
bits 64
%define retfq o64 retf
segment .text
;==================================
; VOID x64OutportB(
; UINT16 Port,
; UINT8 Value);
;
x64OutportB:
mov rax, rcx
mov rbx, rdx
mov dx, ax
mov al, bl
out dx, al
ret
;==================================
; VOID x64OutportW(
; UINT16 Port,
; UINT16 Value);
;
x64OutportW:
mov rax, rcx
mov rbx, rdx
mov dx, ax
mov ax, bx
out dx, ax
ret
;==================================
; UINT8 x64InportB(
; UINT16 Port);
;
x64InportB:
mov rax, rcx
mov dx, ax
in al, dx
ret
;==================================
; UINT16 x64InportW(
; UINT16 Port);
;
x64InportW:
mov rax, rcx
mov dx, ax
in eax, dx
ret
;==================================
; VOID x64EnableInterrupts();
;
x64EnableInterrupts:
cli
ret
;==================================
; VOID x64DisableInterrupts();
;
x64DisableInterrupts:
sti
ret
;==================================
; UINT64
; EFIAPI
; x64ReadTsc ();
;
x64ReadTsc:
rdtsc
shl rdx, 20h
or rax, rdx
ret
;==================================
; UINT64
; EFIAPI
; x64ReadCR3 ();
;
x64ReadCR3:
mov rax, cr3
ret
;==================================
; UINT64
; EFIAPI
; x64WriteCR3 (UINTN new_cr3);
;
x64WriteCR3:
mov cr3, rcx
mov rax, rcx
ret
;==================================
; VOID
; EFIAPI
; x64ReadGdtr (
; OUT x64_seg_sel *gdtr);
;
x64ReadGdtr:
sgdt [rcx]
ret
;==================================
; VOID
; EFIAPI
; x64WriteGdtr (
; IN CONST x64_seg_sel *gdtr);
;
x64WriteGdtr:
lgdt [rcx]
ret
;==================================
; VOID
; EFIAPI
; x64ReadIdtr (
; OUT x64_seg_sel *idtr);
;
x64ReadIdtr:
sidt [rcx]
ret
;==================================
; VOID
; EFIAPI
; x64WriteIdtr (
; IN CONST x64_seg_sel *idtr);
;
x64WriteIdtr:
lidt [rcx]
ret
;==================================
; UINT64
; EFIAPI
; x64ReadCR2 (VOID);
;
x64ReadCR2:
mov rax, cr2
ret
;==================================
; UINT16
; EFIAPI
; x64ReadCS ();
;
x64ReadCS:
xor rax, rax
mov ax, cs
ret
;==================================
; UINT16
; EFIAPI
; x64ReadDS ();
;
x64ReadDS:
xor rax, rax
mov ax, ds
ret
;==================================
; UINT16
; EFIAPI
; x64ReadSS ();
;
x64ReadSS:
xor rax, rax
mov ax, ss
ret
;==================================
; UINT16
; EFIAPI
; x64ReadES ();
;
x64ReadES:
xor rax, rax
mov ax, es
ret
;==================================
; UINT16
; EFIAPI
; x64ReadFS ();
;
x64ReadFS:
xor rax, rax
mov ax, fs
ret
;==================================
; UINT16
; EFIAPI
; x64ReadGS ();
;
x64ReadGS:
xor rax, rax
mov ax, es
ret
;==================================
; VOID
; EFIAPI
; x64LoadTR (
; UINT16 tr_gdt_descr_index);
;
x64LoadTR:
ltr cx
ret
;==================================
; VOID
; EFIAPI
; x64InvalidatePage(
; EFI_PHYSICAL_ADDRESS *addr);
;
x64InvalidatePage:
invlpg [rcx]
ret
;==================================
; VOID
; EFIAPI
; x64AtomicOr(
; UINT64 *value,
; UINT64 mask);
;
x64AtomicOr:
lock or qword [rcx], rdx
ret
;==================================
; VOID
; EFIAPI
; x64AtomicAnd(
; UINT64 *value,
; UINT64 mask);
;
x64AtomicAnd:
lock and qword [rcx], rdx
ret
;==================================
; VOID
; EFIAPI
; x64AtomicXor(
; UINT64 *value,
; UINT64 mask);
;
x64AtomicXor:
lock xor qword [rcx], rdx
ret
;==================================
; VOID
; EFIAPI
; x64AtomicAdd(
; UINT64 *value,
; UINT64 addend);
;
x64AtomicAdd:
lock add qword [rcx], rdx
ret
;==================================
; VOID
; EFIAPI
; x64AtomicSub(
; UINT64 *value,
; UINT64 subtrahend);
;
x64AtomicSub:
lock sub qword [rcx], rdx
ret
;==================================
; VOID
; EFIAPI
; x64AtomicInc(UINT64 *value);
;
x64AtomicInc:
lock inc qword [rcx]
ret
;==================================
; VOID
; EFIAPI
; x64AtomicDec(UINT64 *value);
;
x64AtomicDec:
lock dec qword [rcx]
ret
;==================================
; UINT8
; EFIAPI
; x64AtomicDecAndTestZero(
; UINT64 *value);
;
x64AtomicDecAndTestZero:
xor rax, rax
lock dec qword [rcx]
setz al
ret
;==================================
; VOID
; EFIAPI
; x64SpinlockAcquire(
; VOID *spinlock);
;
x64SpinlockAcquire:
cmp qword [rcx], 0
je x64_s_a_get_spinlock
pause
jmp x64SpinlockAcquire
x64_s_a_get_spinlock:
mov qword rbx, 1
xchg [rcx], rbx
cmp qword rbx, 0
jne x64SpinlockAcquire
ret
;==================================
; VOID
; EFIAPI
; x64SpinlockRelease(
; VOID *spinlock);
;
x64SpinlockRelease:
mov qword rbx, 0
xchg [rcx], rbx
ret
|
oeis/086/A086192.asm | neoneye/loda-programs | 11 | 247857 | ; A086192: Tribonacci numbers that start with first three squares.
; Submitted by <NAME>(s1)
; 1,4,9,14,27,50,91,168,309,568,1045,1922,3535,6502,11959,21996,40457,74412,136865,251734,463011,851610,1566355,2880976,5298941,9746272,17926189,32971402,60643863,111541454,205156719,377342036,694040209
mov $1,1
mov $2,2
mov $3,2
mov $4,4
lpb $0
sub $0,1
add $2,$3
mov $3,$4
add $4,$1
mov $1,$2
mov $2,$4
lpe
mov $0,$1
|
libsrc/_DEVELOPMENT/alloc/obstack/z80/asm_obstack_grow.asm | meesokim/z88dk | 0 | 173583 | <reponame>meesokim/z88dk
; ===============================================================
; Dec 2013
; ===============================================================
;
; int obstack_grow(struct obstack *ob, void *data, size_t size)
;
; Grow the current object by appending size bytes read from
; address data.
;
; ===============================================================
SECTION code_alloc_obstack
PUBLIC asm_obstack_grow
EXTERN asm0_obstack_blank, asm_memcpy
asm_obstack_grow:
; enter : hl = struct obstack *ob
; bc = size_t size
; de = void *data
;
; exit : success
;
; carry reset
; hl = non-zero
; de = address of byte following grown area
;
; fail on insufficient memory
;
; carry set
; hl = 0
;
; uses : af, bc, de, hl
push de ; save data
call asm0_obstack_blank ; de = & allocated bytes
pop hl ; hl = data
ret c
jp asm_memcpy
|
programs/oeis/098/A098298.asm | neoneye/loda | 22 | 29181 | ; A098298: Member r=13 of the family of Chebyshev sequences S_r(n) defined in A092184.
; 0,1,13,144,1573,17161,187200,2042041,22275253,242985744,2650567933,28913261521,315395308800,3440435135281,37529391179293,409382867836944,4465682155027093,48713120837461081,531378647057044800,5796451996790031721,63229593317633304133,689729074497176313744,7523790226151306147053,82071963413167191303841,895267807318687798195200,9765873917092398588843361,106529345280697696679081773,1162056924170582264881056144,12676096820595707217012535813,138275008102382197122256837801,1508348992305608461127812680000,16453563907259310875283682642201,179480853987546811166992696384213,1957835829955755611961635977584144,21356713275525764920411003057041373,232966010200827658512559397649870961
mul $0,2
seq $0,100230 ; Main diagonal of triangle A100229.
div $0,9
|
projects/batfish/src/main/antlr4/org/batfish/grammar/f5_bigip_structured/F5BigipStructured_route_map.g4 | loftwah/batfish | 0 | 3001 | parser grammar F5BigipStructured_route_map;
import F5BigipStructured_common;
options {
tokenVocab = F5BigipStructuredLexer;
}
nr_route_map
:
ROUTE_MAP name = word BRACE_LEFT
(
NEWLINE
(
nrr_entries
| nrr_route_domain
| unrecognized
)*
)? BRACE_RIGHT NEWLINE
;
nrr_entries
:
ENTRIES BRACE_LEFT
(
NEWLINE nrre_entry*
)? BRACE_RIGHT NEWLINE
;
nrre_entry
:
num = word BRACE_LEFT
(
NEWLINE
(
nrree_action
| nrree_match
| nrree_set
)*
)? BRACE_RIGHT NEWLINE
;
nrree_action
:
ACTION action = route_map_action NEWLINE
;
nrree_match
:
MATCH BRACE_LEFT
(
NEWLINE
(
nreem_ipv4
| unrecognized
)*
)? BRACE_RIGHT NEWLINE
;
nreem_ipv4
:
IPV4 BRACE_LEFT
(
NEWLINE
(
nreem4_address
| unrecognized
)*
)? BRACE_RIGHT NEWLINE
;
nreem4_address
:
ADDRESS BRACE_LEFT
(
NEWLINE
(
nreem4a_prefix_list
| unrecognized
)*
)? BRACE_RIGHT NEWLINE
;
nreem4a_prefix_list
:
PREFIX_LIST name = word NEWLINE
;
nrree_set
:
SET BRACE_LEFT
(
NEWLINE
(
nrrees_community
| unrecognized
)*
)? BRACE_RIGHT NEWLINE
;
nrrees_community
:
COMMUNITY BRACE_LEFT
(
NEWLINE
(
nreesc_value
| unrecognized
)*
)? BRACE_RIGHT NEWLINE
;
nreesc_value
:
VALUE BRACE_LEFT communities += standard_community+ BRACE_RIGHT NEWLINE
;
nrr_route_domain
:
ROUTE_DOMAIN name = word NEWLINE
;
route_map_action
:
PERMIT
| DENY
;
standard_community
:
word
;
|
templates/vc.asm | RV8V/asm-code | 1 | 8042 | .global _start
.data
s: .ascii "testing string\n\0"
len = . - s
.text
_start:
mov $s, %r8
movb $'a', 4(%r8)
mov $1, %rax
mov $1, %rdi
mov $s, %rsi
mov $len, %rdx
syscall
mov $60, %rax
mov $0, %rdi
syscall
|
src/sprite_minotauro_inf.asm | fjpena/sword-of-ianna-msx2 | 43 | 27655 | <reponame>fjpena/sword-of-ianna-msx2
idle:
DB 145, 85, 170, 41, 34, 136, 18, 151, 121, 17, 18, 0
DB 16, 89, 170, 25, 34, 130, 18, 17, 17, 17, 18, 0
DB 16, 89, 154, 17, 17, 33, 17, 71, 120, 17, 17, 1
DB 16, 89, 154, 17, 17, 17, 17, 22, 129, 17, 17, 23
DB 16, 89, 170, 25, 151, 119, 121, 20, 132, 151, 113, 25
DB 16, 89, 170, 154, 17, 17, 17, 20, 129, 17, 145, 23
DB 16, 89, 170, 154, 17, 17, 17, 71, 120, 17, 113, 1
DB 0, 161, 169, 25, 17, 17, 17, 17, 17, 17, 17, 0
DB 0, 16, 17, 17, 151, 121, 17, 17, 17, 23, 0, 0
DB 0, 145, 17, 151, 85, 153, 23, 17, 113, 23, 0, 0
DB 16, 25, 145, 89, 165, 154, 25, 113, 119, 25, 0, 0
DB 16, 25, 145, 85, 170, 170, 25, 113, 151, 25, 0, 0
DB 145, 1, 145, 85, 170, 170, 25, 113, 153, 25, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 153, 25, 0, 0
DB 145, 1, 145, 165, 170, 154, 25, 119, 153, 25, 0, 0
DB 16, 25, 145, 165, 170, 154, 17, 119, 153, 23, 0, 0
DB 16, 25, 145, 165, 170, 153, 113, 119, 153, 23, 0, 0
DB 16, 25, 89, 170, 154, 25, 113, 151, 121, 1, 0, 0
DB 161, 17, 89, 170, 25, 17, 119, 153, 23, 0, 0, 0
DB 90, 26, 89, 154, 1, 16, 151, 121, 1, 0, 0, 0
DB 81, 17, 169, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 170, 17, 89, 26, 0, 16, 151, 25, 0, 0, 0, 0
DB 26, 16, 89, 26, 0, 16, 151, 25, 0, 0, 0, 0
DB 1, 16, 89, 26, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 89, 26, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 89, 26, 0, 0, 113, 25, 0, 0, 0, 0
DB 0, 16, 89, 26, 0, 0, 113, 25, 0, 0, 0, 0
DB 0, 16, 89, 26, 0, 0, 113, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 1, 0, 113, 25, 0, 0, 0, 0
DB 0, 0, 145, 85, 25, 0, 16, 121, 1, 0, 0, 0
DB 0, 0, 145, 154, 26, 0, 16, 151, 23, 1, 0, 0
DB 0, 0, 16, 154, 26, 0, 16, 113, 121, 1, 0, 0
gira:
DB 161, 165, 154, 33, 130, 145, 154, 129, 34, 145, 170, 165
DB 16, 165, 154, 33, 40, 17, 17, 33, 40, 145, 170, 21
DB 16, 165, 25, 33, 18, 97, 100, 17, 34, 17, 169, 21
DB 16, 165, 25, 17, 17, 22, 17, 22, 17, 17, 169, 21
DB 16, 165, 154, 113, 121, 20, 20, 120, 121, 145, 170, 21
DB 16, 165, 170, 25, 17, 20, 17, 24, 17, 169, 170, 21
DB 16, 85, 154, 25, 17, 65, 136, 17, 17, 153, 90, 21
DB 0, 145, 153, 17, 17, 17, 17, 17, 17, 145, 153, 1
DB 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0
DB 0, 0, 16, 85, 25, 17, 17, 17, 89, 21, 0, 0
DB 0, 0, 81, 85, 154, 17, 17, 145, 90, 85, 1, 0
DB 0, 0, 81, 165, 154, 17, 17, 145, 170, 85, 1, 0
DB 0, 0, 81, 165, 170, 25, 17, 169, 170, 85, 1, 0
DB 0, 0, 81, 165, 170, 25, 23, 169, 170, 85, 1, 0
DB 0, 0, 81, 170, 170, 25, 23, 169, 170, 90, 1, 0
DB 0, 0, 81, 170, 170, 25, 23, 169, 170, 90, 1, 0
DB 0, 0, 81, 170, 170, 25, 23, 169, 170, 90, 1, 0
DB 0, 0, 81, 170, 154, 17, 25, 145, 170, 90, 1, 0
DB 0, 16, 85, 149, 25, 0, 145, 17, 153, 85, 21, 0
DB 0, 16, 154, 153, 1, 0, 145, 1, 145, 153, 26, 0
DB 0, 16, 153, 25, 0, 0, 16, 25, 16, 153, 25, 0
DB 0, 16, 154, 25, 0, 0, 16, 25, 16, 153, 26, 0
DB 0, 16, 149, 25, 0, 0, 145, 25, 16, 153, 21, 0
DB 0, 16, 149, 25, 0, 0, 145, 25, 16, 153, 21, 0
DB 0, 16, 165, 25, 0, 16, 153, 1, 16, 169, 21, 0
DB 0, 16, 85, 25, 0, 0, 17, 0, 16, 89, 21, 0
DB 0, 16, 165, 25, 0, 0, 0, 0, 16, 169, 21, 0
DB 0, 16, 165, 25, 0, 0, 0, 0, 16, 169, 21, 0
DB 0, 16, 165, 17, 0, 0, 0, 0, 16, 161, 21, 0
DB 0, 0, 81, 170, 1, 0, 0, 0, 161, 90, 1, 0
DB 0, 0, 81, 154, 26, 0, 0, 16, 154, 90, 1, 0
DB 0, 0, 16, 149, 26, 0, 0, 16, 154, 21, 0, 0
camina:
DB 165, 154, 17, 34, 136, 40, 17, 17, 17, 33, 1, 0
DB 89, 154, 17, 17, 34, 34, 17, 132, 17, 17, 23, 0
DB 145, 154, 17, 17, 17, 17, 97, 17, 24, 113, 153, 1
DB 145, 170, 25, 119, 121, 151, 71, 65, 120, 113, 153, 25
DB 145, 170, 25, 17, 17, 17, 65, 17, 24, 113, 151, 25
DB 16, 165, 25, 17, 17, 17, 17, 132, 17, 17, 119, 23
DB 16, 165, 154, 17, 17, 17, 17, 17, 17, 1, 17, 1
DB 16, 89, 154, 17, 17, 17, 17, 17, 17, 1, 0, 0
DB 16, 145, 25, 145, 153, 25, 17, 17, 113, 1, 0, 0
DB 145, 17, 17, 153, 149, 153, 17, 17, 113, 1, 0, 0
DB 25, 0, 145, 89, 165, 153, 17, 17, 119, 23, 0, 0
DB 25, 0, 145, 85, 170, 154, 113, 119, 151, 25, 0, 0
DB 145, 1, 145, 165, 170, 154, 17, 119, 151, 153, 1, 0
DB 16, 25, 145, 165, 170, 154, 1, 113, 151, 153, 25, 0
DB 0, 145, 145, 165, 170, 154, 1, 16, 119, 153, 25, 0
DB 0, 145, 145, 165, 170, 25, 0, 16, 119, 153, 25, 0
DB 16, 25, 145, 165, 170, 25, 17, 17, 119, 153, 25, 0
DB 145, 1, 145, 165, 170, 25, 119, 119, 151, 153, 1, 0
DB 21, 0, 145, 165, 154, 17, 119, 119, 23, 17, 0, 0
DB 170, 1, 145, 165, 153, 113, 119, 17, 1, 0, 0, 0
DB 165, 1, 145, 154, 25, 119, 23, 0, 0, 0, 0, 0
DB 81, 17, 89, 149, 17, 151, 1, 0, 0, 0, 0, 0
DB 16, 26, 89, 26, 16, 151, 1, 0, 0, 0, 0, 0
DB 0, 17, 89, 26, 16, 151, 1, 0, 0, 0, 0, 0
DB 0, 16, 89, 26, 16, 151, 1, 0, 0, 0, 0, 0
DB 0, 16, 89, 26, 0, 113, 1, 0, 0, 0, 0, 0
DB 0, 16, 89, 26, 0, 113, 25, 0, 0, 0, 0, 0
DB 0, 16, 89, 26, 0, 113, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 1, 16, 119, 1, 0, 0, 0, 0
DB 0, 0, 161, 170, 25, 0, 17, 0, 0, 0, 0, 0
DB 0, 0, 145, 154, 26, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 165, 170, 153, 129, 18, 151, 23, 0
DB 0, 0, 0, 16, 89, 170, 154, 33, 18, 17, 17, 0
DB 0, 0, 0, 0, 145, 165, 170, 25, 17, 24, 113, 1
DB 0, 0, 0, 0, 17, 89, 170, 154, 129, 129, 113, 1
DB 0, 0, 16, 17, 17, 17, 89, 170, 137, 129, 17, 0
DB 0, 0, 145, 25, 17, 17, 17, 169, 154, 129, 1, 0
DB 0, 16, 25, 17, 17, 17, 145, 170, 154, 24, 1, 0
DB 0, 145, 1, 16, 153, 153, 17, 153, 25, 17, 1, 0
DB 0, 145, 1, 145, 89, 153, 25, 17, 17, 113, 1, 0
DB 0, 16, 25, 145, 165, 154, 25, 17, 17, 113, 1, 0
DB 0, 16, 25, 145, 165, 170, 153, 17, 17, 113, 1, 0
DB 0, 145, 17, 153, 165, 170, 154, 17, 17, 119, 1, 0
DB 16, 25, 16, 89, 170, 170, 154, 113, 119, 119, 25, 0
DB 81, 1, 16, 89, 170, 170, 154, 113, 119, 119, 153, 1
DB 170, 1, 16, 89, 170, 170, 25, 113, 119, 119, 153, 1
DB 170, 1, 0, 145, 165, 170, 25, 119, 119, 151, 153, 25
DB 165, 1, 0, 145, 165, 170, 25, 17, 119, 151, 153, 25
DB 81, 1, 16, 89, 170, 154, 1, 16, 119, 153, 153, 25
DB 16, 26, 145, 165, 153, 25, 0, 0, 145, 153, 153, 25
DB 0, 17, 89, 154, 17, 1, 0, 0, 16, 151, 153, 1
DB 0, 16, 89, 26, 0, 0, 0, 0, 113, 151, 17, 0
DB 0, 16, 89, 25, 0, 0, 0, 16, 119, 25, 0, 0
DB 0, 16, 89, 1, 0, 0, 0, 0, 113, 151, 1, 0
DB 0, 16, 89, 1, 0, 0, 0, 0, 16, 119, 25, 0
DB 0, 145, 165, 1, 0, 0, 0, 0, 0, 113, 151, 1
DB 0, 145, 165, 1, 0, 0, 0, 0, 0, 16, 119, 25
DB 0, 145, 165, 1, 0, 0, 0, 0, 0, 0, 113, 151
DB 0, 16, 169, 1, 0, 0, 0, 0, 0, 0, 113, 153
DB 0, 16, 169, 25, 1, 0, 0, 0, 0, 0, 113, 153
DB 0, 0, 145, 170, 26, 0, 0, 0, 0, 0, 16, 25
DB 0, 0, 145, 154, 26, 0, 0, 0, 0, 0, 0, 1
DB 0, 0, 16, 154, 26, 0, 0, 0, 0, 0, 0, 0
DB 0, 16, 89, 154, 153, 17, 18, 23, 17, 0, 0, 0
DB 0, 0, 81, 154, 153, 153, 17, 145, 25, 0, 0, 0
DB 0, 0, 145, 165, 170, 153, 153, 153, 153, 1, 0, 0
DB 0, 0, 17, 89, 165, 170, 170, 169, 154, 1, 0, 0
DB 0, 0, 16, 145, 89, 85, 170, 170, 154, 1, 0, 0
DB 0, 0, 16, 17, 17, 17, 145, 170, 26, 0, 0, 0
DB 0, 16, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0
DB 0, 145, 25, 17, 17, 17, 17, 17, 1, 0, 0, 0
DB 16, 25, 17, 145, 153, 25, 17, 17, 1, 0, 0, 0
DB 16, 25, 16, 153, 169, 170, 25, 17, 1, 0, 0, 0
DB 0, 145, 17, 153, 170, 170, 154, 17, 0, 0, 0, 0
DB 16, 16, 25, 153, 170, 170, 170, 25, 0, 0, 0, 0
DB 81, 1, 145, 145, 165, 170, 170, 154, 1, 0, 0, 0
DB 165, 26, 145, 145, 89, 165, 170, 170, 25, 0, 0, 0
DB 170, 145, 25, 16, 153, 89, 85, 165, 25, 0, 0, 0
DB 21, 16, 1, 0, 17, 145, 153, 89, 154, 1, 0, 0
DB 161, 1, 0, 0, 16, 17, 17, 145, 154, 1, 0, 0
DB 16, 1, 0, 0, 145, 153, 153, 169, 153, 1, 0, 0
DB 0, 0, 0, 16, 89, 170, 154, 153, 17, 0, 0, 0
DB 0, 0, 0, 145, 165, 153, 25, 17, 0, 0, 0, 0
DB 0, 0, 0, 16, 149, 17, 17, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 165, 25, 23, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 169, 25, 23, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 161, 25, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 161, 25, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 161, 25, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 81, 165, 25, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 145, 169, 25, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 81, 154, 17, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 17, 16, 151, 1, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 113, 25, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 113, 153, 1, 0, 0, 0
DB 0, 0, 16, 169, 154, 153, 129, 18, 65, 24, 17, 18
DB 0, 0, 16, 89, 170, 153, 33, 18, 22, 129, 17, 18
DB 0, 0, 0, 145, 165, 153, 25, 121, 20, 132, 23, 1
DB 0, 0, 0, 16, 89, 154, 25, 17, 20, 129, 17, 0
DB 0, 0, 0, 0, 145, 170, 153, 17, 65, 24, 17, 0
DB 0, 0, 0, 0, 16, 165, 154, 25, 17, 17, 17, 0
DB 0, 0, 0, 16, 17, 169, 154, 25, 17, 17, 17, 0
DB 0, 0, 16, 145, 25, 145, 153, 25, 153, 17, 23, 0
DB 0, 0, 145, 25, 17, 25, 17, 145, 154, 25, 23, 0
DB 0, 16, 25, 1, 16, 153, 153, 169, 170, 153, 17, 0
DB 0, 16, 25, 1, 0, 145, 169, 170, 170, 154, 17, 0
DB 0, 0, 145, 25, 0, 16, 89, 170, 170, 154, 25, 0
DB 0, 17, 16, 145, 1, 16, 145, 165, 170, 170, 25, 0
DB 16, 21, 0, 145, 1, 16, 17, 89, 170, 170, 25, 0
DB 81, 17, 17, 25, 0, 17, 25, 145, 165, 170, 153, 1
DB 81, 170, 170, 1, 0, 145, 121, 17, 89, 170, 153, 1
DB 16, 165, 26, 0, 0, 145, 119, 23, 145, 165, 154, 25
DB 0, 17, 1, 0, 0, 113, 23, 145, 89, 170, 154, 25
DB 0, 0, 0, 0, 0, 16, 17, 89, 170, 170, 153, 1
DB 0, 0, 0, 0, 0, 0, 145, 149, 153, 153, 17, 0
DB 0, 0, 0, 0, 0, 0, 81, 154, 17, 17, 0, 0
DB 0, 0, 0, 0, 0, 0, 161, 154, 1, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 16, 154, 1, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 16, 154, 1, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 81, 154, 1, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 145, 154, 1, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 16, 165, 25, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 16, 89, 170, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 161, 169, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 161, 169, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 17, 17, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 145, 145, 1, 0, 0
DB 169, 153, 25, 130, 136, 18, 17, 17, 17, 18, 0, 0
DB 89, 154, 25, 130, 136, 18, 17, 17, 17, 18, 1, 0
DB 145, 154, 153, 33, 136, 18, 17, 132, 17, 18, 25, 0
DB 16, 165, 153, 33, 34, 18, 97, 17, 24, 18, 25, 0
DB 16, 169, 153, 113, 121, 151, 71, 65, 120, 145, 25, 0
DB 0, 161, 154, 17, 17, 17, 129, 17, 24, 16, 1, 0
DB 0, 161, 170, 25, 153, 153, 25, 129, 17, 0, 0, 0
DB 0, 81, 170, 154, 145, 169, 153, 25, 17, 0, 0, 0
DB 0, 145, 165, 153, 145, 170, 154, 153, 17, 0, 0, 0
DB 0, 17, 153, 25, 89, 170, 170, 153, 25, 0, 0, 0
DB 16, 25, 17, 17, 89, 170, 170, 170, 153, 1, 0, 0
DB 16, 25, 17, 16, 145, 165, 170, 170, 153, 1, 0, 0
DB 0, 145, 153, 1, 17, 89, 170, 170, 154, 25, 0, 0
DB 0, 16, 17, 25, 16, 145, 165, 170, 153, 25, 0, 0
DB 0, 0, 0, 145, 1, 17, 89, 170, 153, 1, 0, 0
DB 0, 0, 0, 145, 1, 17, 145, 154, 25, 0, 0, 0
DB 0, 0, 16, 165, 17, 89, 170, 153, 1, 0, 0, 0
DB 0, 0, 81, 170, 145, 149, 153, 25, 1, 0, 0, 0
DB 0, 0, 161, 26, 16, 154, 17, 17, 0, 0, 0, 0
DB 0, 16, 21, 1, 16, 154, 17, 1, 0, 0, 0, 0
DB 0, 16, 1, 0, 16, 89, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 113, 81, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 119, 81, 154, 1, 0, 0, 0, 0
DB 0, 0, 0, 16, 23, 145, 154, 1, 0, 0, 0, 0
DB 0, 0, 0, 113, 23, 16, 149, 1, 0, 0, 0, 0
DB 0, 0, 16, 119, 1, 16, 169, 25, 1, 0, 0, 0
DB 0, 0, 16, 151, 1, 0, 81, 170, 26, 0, 0, 0
DB 0, 0, 16, 151, 1, 0, 145, 154, 26, 0, 0, 0
DB 0, 0, 16, 153, 1, 0, 16, 154, 26, 0, 0, 0
DB 0, 0, 0, 145, 1, 0, 0, 17, 1, 0, 0, 0
DB 0, 0, 0, 145, 25, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 145, 153, 1, 0, 0, 0, 0, 0, 0
DB 0, 145, 165, 154, 33, 136, 136, 18, 153, 151, 25, 18
DB 0, 145, 165, 154, 33, 136, 136, 18, 151, 153, 23, 18
DB 0, 16, 89, 154, 33, 130, 136, 18, 17, 17, 17, 18
DB 0, 0, 145, 154, 25, 34, 136, 18, 65, 24, 17, 18
DB 0, 0, 145, 170, 25, 17, 34, 18, 20, 129, 17, 18
DB 0, 0, 145, 170, 25, 151, 119, 121, 20, 132, 23, 1
DB 0, 0, 145, 170, 153, 17, 17, 17, 20, 129, 1, 0
DB 0, 0, 145, 170, 153, 17, 17, 17, 65, 24, 1, 0
DB 0, 16, 17, 153, 25, 145, 153, 25, 17, 17, 1, 0
DB 0, 145, 17, 17, 17, 153, 153, 153, 17, 17, 1, 0
DB 16, 25, 0, 0, 145, 89, 170, 153, 25, 113, 1, 0
DB 145, 1, 16, 17, 145, 89, 170, 154, 25, 113, 1, 0
DB 145, 1, 145, 26, 17, 153, 165, 154, 153, 17, 0, 0
DB 145, 17, 25, 170, 17, 145, 165, 170, 153, 17, 0, 0
DB 16, 153, 17, 165, 17, 23, 89, 170, 153, 1, 0, 0
DB 0, 17, 0, 81, 17, 23, 89, 170, 154, 1, 0, 0
DB 0, 0, 16, 21, 16, 119, 145, 165, 154, 1, 0, 0
DB 0, 0, 16, 1, 16, 23, 89, 154, 25, 0, 0, 0
DB 0, 0, 0, 0, 16, 145, 149, 25, 1, 0, 0, 0
DB 0, 0, 0, 0, 16, 89, 25, 1, 0, 0, 0, 0
DB 0, 0, 0, 0, 16, 169, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 17, 169, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 23, 161, 25, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 119, 81, 26, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 119, 81, 154, 1, 0, 0, 0, 0
DB 0, 0, 0, 113, 23, 17, 154, 1, 0, 0, 0, 0
DB 0, 0, 0, 113, 23, 16, 165, 1, 0, 0, 0, 0
DB 0, 0, 0, 113, 25, 16, 165, 25, 0, 0, 0, 0
DB 0, 0, 0, 145, 25, 0, 161, 25, 1, 0, 0, 0
DB 0, 0, 0, 145, 25, 0, 81, 170, 26, 0, 0, 0
DB 0, 0, 0, 145, 25, 0, 81, 154, 26, 0, 0, 0
DB 0, 0, 0, 145, 153, 1, 16, 154, 26, 0, 0, 0
cae:
DB 154, 170, 153, 33, 40, 145, 121, 153, 33, 130, 1, 0
DB 165, 170, 25, 34, 136, 114, 153, 121, 33, 34, 24, 0
DB 169, 154, 25, 130, 136, 40, 17, 17, 33, 130, 1, 0
DB 145, 153, 33, 130, 136, 18, 65, 24, 33, 24, 0, 0
DB 17, 17, 17, 17, 17, 17, 22, 129, 129, 1, 0, 0
DB 21, 113, 121, 151, 119, 121, 20, 132, 23, 1, 0, 0
DB 165, 17, 17, 17, 17, 17, 20, 129, 17, 17, 17, 0
DB 165, 17, 17, 17, 17, 17, 65, 24, 17, 119, 119, 1
DB 170, 17, 145, 153, 153, 17, 17, 17, 17, 119, 119, 23
DB 161, 17, 153, 169, 154, 25, 17, 17, 113, 119, 119, 121
DB 25, 16, 153, 165, 170, 153, 17, 113, 119, 119, 151, 121
DB 25, 16, 153, 165, 170, 154, 25, 16, 113, 119, 153, 121
DB 25, 0, 145, 165, 170, 154, 25, 0, 16, 151, 153, 23
DB 145, 1, 17, 89, 170, 154, 25, 0, 113, 153, 121, 1
DB 145, 1, 16, 89, 170, 170, 25, 16, 119, 119, 23, 0
DB 16, 25, 17, 145, 165, 170, 153, 17, 119, 23, 1, 0
DB 0, 145, 25, 145, 89, 170, 153, 1, 113, 121, 1, 0
DB 0, 16, 17, 17, 89, 170, 25, 0, 16, 151, 23, 0
DB 0, 0, 0, 0, 145, 165, 1, 0, 0, 113, 121, 1
DB 0, 0, 0, 16, 89, 26, 0, 0, 0, 16, 151, 1
DB 0, 0, 0, 145, 165, 1, 0, 0, 0, 0, 145, 23
DB 0, 0, 16, 89, 26, 0, 0, 0, 0, 0, 145, 121
DB 0, 0, 16, 169, 1, 0, 0, 0, 0, 0, 145, 121
DB 0, 0, 16, 169, 25, 0, 0, 0, 0, 0, 145, 121
DB 0, 0, 0, 145, 154, 1, 0, 0, 0, 0, 16, 23
DB 0, 0, 0, 145, 154, 1, 0, 0, 0, 0, 0, 1
DB 0, 0, 0, 145, 165, 17, 1, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 89, 170, 26, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 161, 149, 26, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 16, 149, 26, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 169, 89, 154, 25, 130, 18, 25, 145, 17, 18, 23, 23
DB 169, 89, 154, 25, 130, 18, 119, 145, 23, 18, 119, 1
DB 169, 169, 154, 33, 136, 18, 113, 119, 23, 18, 119, 1
DB 81, 170, 154, 33, 136, 40, 113, 153, 23, 129, 17, 0
DB 145, 165, 25, 130, 136, 40, 113, 121, 25, 33, 17, 0
DB 16, 153, 17, 130, 136, 40, 113, 23, 23, 17, 24, 0
DB 0, 17, 33, 40, 34, 18, 119, 121, 23, 130, 1, 0
DB 0, 16, 34, 18, 17, 17, 17, 119, 129, 17, 0, 0
DB 1, 145, 119, 17, 17, 17, 132, 17, 17, 0, 0, 0
DB 21, 33, 17, 121, 23, 97, 17, 24, 0, 0, 0, 0
DB 165, 33, 17, 17, 145, 71, 65, 120, 0, 0, 0, 0
DB 165, 33, 17, 17, 17, 65, 17, 24, 0, 0, 0, 0
DB 170, 33, 17, 17, 17, 17, 132, 17, 1, 0, 0, 0
DB 26, 33, 17, 89, 154, 25, 17, 17, 23, 0, 0, 0
DB 26, 17, 146, 165, 170, 153, 17, 113, 119, 1, 0, 0
DB 145, 17, 145, 165, 170, 154, 17, 119, 119, 23, 0, 0
DB 145, 1, 16, 165, 170, 170, 25, 119, 151, 23, 0, 0
DB 16, 25, 17, 89, 170, 170, 154, 113, 153, 23, 0, 0
DB 0, 145, 153, 17, 89, 170, 154, 113, 151, 121, 1, 0
DB 0, 16, 17, 17, 145, 165, 154, 25, 151, 121, 1, 0
DB 0, 0, 0, 16, 89, 170, 154, 25, 151, 121, 1, 0
DB 0, 0, 0, 145, 165, 170, 153, 113, 153, 23, 0, 0
DB 0, 0, 16, 89, 153, 153, 25, 151, 121, 1, 0, 0
DB 0, 0, 145, 149, 17, 17, 113, 121, 17, 0, 0, 0
DB 0, 16, 89, 25, 0, 0, 145, 23, 0, 0, 0, 0
DB 0, 16, 165, 25, 0, 16, 119, 1, 0, 0, 0, 0
DB 0, 16, 165, 25, 0, 113, 23, 0, 0, 0, 0, 0
DB 0, 16, 165, 9, 0, 113, 119, 1, 0, 0, 0, 0
DB 0, 16, 169, 17, 1, 16, 119, 23, 0, 0, 0, 0
DB 0, 0, 81, 170, 25, 0, 113, 153, 1, 0, 0, 0
DB 0, 0, 145, 154, 26, 0, 16, 151, 25, 0, 0, 0
DB 0, 0, 16, 149, 26, 0, 0, 113, 153, 1, 0, 0
agacha:
DB 0, 0, 0, 0, 0, 161, 145, 165, 169, 170, 170, 1
DB 0, 0, 0, 0, 0, 16, 170, 153, 170, 154, 154, 1
DB 0, 0, 0, 0, 0, 17, 161, 154, 154, 170, 169, 25
DB 0, 0, 0, 0, 16, 153, 25, 161, 170, 119, 17, 1
DB 0, 0, 0, 0, 145, 89, 154, 145, 170, 170, 153, 1
DB 0, 0, 0, 16, 153, 165, 170, 25, 170, 26, 26, 17
DB 0, 0, 0, 17, 89, 170, 170, 25, 169, 170, 153, 113
DB 0, 0, 16, 18, 89, 170, 170, 153, 161, 119, 17, 113
DB 0, 0, 33, 34, 145, 165, 154, 25, 17, 170, 25, 119
DB 0, 16, 34, 40, 145, 165, 153, 17, 23, 145, 33, 119
DB 0, 16, 130, 136, 145, 165, 170, 25, 119, 17, 33, 113
DB 0, 33, 130, 136, 145, 165, 170, 153, 113, 23, 33, 113
DB 0, 33, 136, 136, 145, 165, 170, 153, 113, 121, 33, 113
DB 0, 33, 130, 136, 145, 165, 154, 153, 113, 121, 33, 113
DB 0, 33, 34, 40, 145, 165, 154, 25, 151, 23, 34, 113
DB 16, 17, 33, 34, 18, 89, 153, 113, 119, 33, 34, 113
DB 145, 33, 17, 33, 18, 89, 170, 25, 23, 34, 34, 113
DB 25, 33, 17, 17, 17, 89, 170, 153, 17, 34, 34, 113
DB 25, 33, 17, 17, 25, 89, 170, 153, 113, 33, 34, 113
DB 25, 33, 17, 153, 25, 89, 170, 153, 113, 23, 17, 119
DB 25, 33, 145, 153, 26, 89, 154, 25, 119, 119, 17, 119
DB 145, 17, 146, 169, 170, 145, 149, 25, 119, 151, 23, 121
DB 16, 25, 17, 89, 165, 145, 149, 25, 119, 153, 23, 121
DB 0, 145, 17, 145, 89, 145, 149, 25, 151, 153, 23, 25
DB 0, 145, 17, 17, 145, 17, 89, 25, 151, 121, 17, 25
DB 16, 25, 17, 153, 153, 154, 145, 153, 145, 23, 113, 25
DB 145, 17, 153, 165, 25, 17, 17, 154, 113, 17, 151, 23
DB 25, 145, 85, 26, 1, 0, 16, 154, 17, 113, 121, 23
DB 25, 145, 165, 17, 1, 0, 81, 154, 17, 145, 119, 1
DB 165, 17, 153, 165, 26, 16, 165, 25, 17, 17, 23, 0
DB 81, 26, 89, 154, 26, 0, 17, 17, 23, 17, 1, 0
DB 16, 165, 17, 154, 26, 0, 0, 145, 121, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 81, 154, 170, 169, 89, 26
DB 0, 0, 0, 0, 0, 0, 81, 165, 169, 170, 154, 26
DB 0, 0, 0, 0, 0, 0, 16, 165, 169, 170, 170, 1
DB 0, 0, 0, 0, 0, 17, 17, 153, 170, 154, 154, 1
DB 0, 0, 0, 17, 17, 153, 153, 145, 154, 170, 169, 25
DB 0, 0, 16, 34, 145, 85, 154, 25, 169, 119, 17, 113
DB 0, 0, 33, 18, 89, 165, 170, 153, 161, 170, 153, 113
DB 0, 16, 34, 18, 89, 170, 170, 154, 161, 26, 26, 113
DB 0, 33, 34, 24, 89, 170, 170, 154, 161, 170, 153, 113
DB 0, 33, 130, 24, 89, 170, 170, 25, 161, 119, 17, 119
DB 16, 34, 136, 40, 145, 165, 153, 25, 145, 170, 25, 23
DB 16, 34, 136, 40, 145, 165, 154, 153, 17, 145, 17, 17
DB 33, 34, 136, 136, 145, 165, 170, 153, 113, 17, 18, 23
DB 33, 130, 136, 136, 145, 165, 170, 153, 113, 23, 18, 23
DB 33, 130, 136, 136, 145, 165, 170, 153, 113, 23, 18, 23
DB 33, 130, 136, 136, 18, 89, 154, 25, 119, 33, 18, 23
DB 33, 34, 34, 136, 18, 89, 153, 113, 119, 33, 18, 23
DB 17, 17, 33, 34, 18, 89, 154, 25, 17, 23, 18, 23
DB 33, 17, 17, 17, 18, 89, 170, 153, 113, 121, 17, 17
DB 33, 17, 17, 153, 25, 89, 170, 153, 113, 153, 23, 23
DB 41, 17, 153, 153, 169, 145, 165, 153, 113, 151, 23, 23
DB 25, 146, 153, 153, 170, 145, 165, 25, 119, 151, 23, 23
DB 25, 17, 153, 89, 85, 145, 165, 25, 119, 151, 23, 23
DB 145, 1, 17, 153, 153, 21, 169, 25, 119, 153, 23, 23
DB 16, 25, 0, 17, 17, 25, 169, 25, 151, 121, 113, 23
DB 0, 145, 17, 17, 153, 21, 169, 25, 151, 23, 113, 23
DB 0, 16, 145, 153, 165, 170, 145, 154, 113, 17, 17, 23
DB 16, 17, 89, 170, 26, 17, 85, 154, 17, 17, 145, 23
DB 145, 25, 25, 17, 1, 16, 165, 154, 1, 17, 121, 23
DB 165, 17, 85, 165, 26, 16, 169, 25, 1, 113, 119, 1
DB 165, 26, 89, 154, 26, 16, 153, 113, 23, 16, 23, 0
DB 81, 170, 145, 154, 26, 0, 17, 151, 23, 0, 1, 0
DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 1, 0, 0
DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 1, 0, 0
DB 145, 165, 170, 153, 33, 40, 113, 113, 33, 1, 0, 0
DB 145, 165, 170, 153, 33, 40, 17, 23, 33, 1, 0, 0
DB 145, 89, 170, 153, 33, 40, 113, 121, 17, 18, 0, 0
DB 16, 89, 154, 25, 130, 40, 113, 153, 23, 18, 0, 0
DB 16, 169, 153, 33, 136, 40, 113, 121, 23, 18, 0, 0
DB 16, 89, 170, 25, 130, 40, 113, 23, 23, 18, 0, 0
DB 0, 145, 170, 25, 130, 40, 113, 121, 17, 18, 1, 0
DB 0, 145, 165, 154, 33, 18, 17, 113, 17, 18, 23, 0
DB 0, 16, 169, 154, 17, 17, 132, 17, 17, 113, 23, 0
DB 0, 16, 89, 170, 25, 65, 17, 24, 17, 119, 23, 0
DB 0, 16, 145, 165, 121, 71, 65, 120, 23, 113, 153, 1
DB 0, 145, 17, 89, 154, 129, 17, 24, 17, 113, 153, 1
DB 0, 145, 17, 145, 170, 25, 136, 17, 17, 113, 153, 1
DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0
DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0
DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0
DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0
DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0
DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0
DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0
DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0
DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0
DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0
DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0
DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0
DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0
saca_espada:
DB 0, 0, 33, 136, 136, 136, 18, 121, 113, 25, 18, 119
DB 0, 17, 17, 130, 136, 136, 18, 153, 151, 25, 18, 153
DB 16, 153, 17, 33, 136, 136, 18, 151, 153, 23, 18, 121
DB 145, 17, 25, 17, 34, 130, 18, 23, 17, 23, 18, 23
DB 25, 0, 145, 23, 17, 33, 17, 65, 24, 17, 17, 1
DB 25, 0, 17, 145, 23, 17, 17, 20, 129, 17, 1, 0
DB 25, 0, 17, 17, 145, 119, 121, 20, 132, 151, 1, 0
DB 25, 0, 17, 17, 17, 17, 17, 20, 129, 17, 0, 0
DB 145, 1, 17, 17, 17, 17, 17, 65, 24, 17, 0, 0
DB 16, 25, 17, 153, 25, 17, 17, 17, 17, 17, 0, 0
DB 16, 25, 145, 89, 154, 25, 17, 17, 17, 17, 0, 0
DB 16, 25, 145, 165, 170, 153, 17, 17, 17, 17, 0, 0
DB 145, 1, 145, 165, 170, 153, 25, 17, 17, 23, 0, 0
DB 25, 1, 145, 165, 170, 154, 25, 17, 113, 23, 0, 0
DB 165, 1, 145, 165, 170, 154, 25, 17, 119, 25, 0, 0
DB 165, 1, 145, 165, 170, 153, 17, 119, 151, 25, 0, 0
DB 165, 1, 145, 165, 170, 153, 113, 119, 153, 23, 0, 0
DB 161, 17, 89, 170, 153, 25, 113, 151, 121, 1, 0, 0
DB 16, 145, 165, 154, 25, 17, 113, 153, 23, 0, 0, 0
DB 16, 89, 154, 153, 1, 0, 145, 121, 1, 0, 0, 0
DB 16, 169, 25, 17, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 81, 153, 1, 0, 113, 121, 1, 0, 0, 0, 0
DB 0, 81, 154, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 0, 145, 154, 1, 0, 16, 25, 0, 0, 0, 0, 0
DB 0, 16, 165, 25, 0, 16, 121, 1, 0, 0, 0, 0
DB 0, 16, 165, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 165, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 0, 145, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 1, 0, 113, 25, 0, 0, 0, 0
DB 0, 0, 81, 165, 26, 0, 16, 121, 1, 0, 0, 0
DB 0, 0, 145, 154, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0
idle_espada:
DB 16, 145, 153, 25, 17, 145, 25, 145, 169, 154, 153, 1
DB 0, 16, 17, 33, 145, 153, 170, 170, 170, 153, 17, 0
DB 0, 0, 33, 34, 145, 169, 154, 153, 153, 17, 0, 0
DB 0, 0, 17, 33, 18, 153, 153, 33, 18, 17, 0, 0
DB 0, 16, 114, 25, 17, 17, 17, 18, 129, 17, 0, 0
DB 0, 16, 18, 113, 151, 119, 121, 20, 136, 151, 0, 0
DB 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0, 0
DB 0, 16, 34, 17, 17, 17, 17, 65, 24, 17, 0, 0
DB 0, 16, 33, 145, 153, 25, 17, 17, 17, 17, 0, 0
DB 0, 145, 17, 153, 153, 153, 17, 17, 17, 23, 0, 0
DB 16, 25, 145, 153, 165, 154, 25, 17, 113, 23, 0, 0
DB 16, 25, 145, 89, 170, 170, 25, 17, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 151, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 151, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 151, 23, 0, 0
DB 16, 25, 145, 165, 170, 154, 25, 119, 153, 23, 0, 0
DB 16, 25, 145, 165, 170, 153, 17, 151, 153, 23, 0, 0
DB 16, 25, 89, 170, 154, 25, 113, 153, 121, 1, 0, 0
DB 81, 17, 89, 170, 25, 17, 119, 151, 23, 0, 0, 0
DB 165, 26, 89, 154, 1, 16, 119, 119, 1, 0, 0, 0
DB 165, 17, 89, 25, 0, 16, 119, 23, 0, 0, 0, 0
DB 170, 17, 89, 25, 0, 16, 119, 1, 0, 0, 0, 0
DB 26, 16, 89, 25, 0, 16, 119, 1, 0, 0, 0, 0
DB 1, 16, 89, 25, 0, 16, 119, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 1, 0, 113, 23, 0, 0, 0, 0
DB 0, 0, 145, 85, 26, 0, 16, 121, 1, 0, 0, 0
DB 0, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0
camina_espada:
DB 0, 0, 145, 153, 25, 17, 17, 153, 145, 170, 154, 1
DB 0, 0, 16, 17, 33, 18, 153, 169, 170, 154, 25, 0
DB 0, 0, 0, 16, 34, 18, 153, 153, 153, 25, 17, 0
DB 0, 0, 0, 16, 17, 34, 145, 153, 33, 18, 17, 0
DB 0, 0, 0, 33, 121, 17, 17, 17, 18, 129, 17, 0
DB 0, 0, 0, 18, 17, 151, 119, 121, 18, 136, 151, 0
DB 0, 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0
DB 0, 0, 16, 18, 17, 17, 17, 17, 65, 24, 17, 0
DB 0, 0, 17, 18, 17, 17, 17, 17, 17, 17, 17, 0
DB 0, 17, 153, 18, 145, 153, 17, 17, 17, 17, 23, 0
DB 16, 153, 17, 146, 153, 153, 25, 17, 17, 17, 23, 0
DB 145, 17, 16, 153, 89, 170, 153, 17, 17, 119, 23, 0
DB 25, 0, 16, 153, 165, 170, 154, 17, 119, 119, 23, 0
DB 25, 0, 0, 145, 89, 170, 170, 25, 119, 121, 1, 0
DB 25, 0, 0, 16, 89, 170, 170, 25, 119, 121, 1, 0
DB 145, 1, 0, 16, 153, 170, 170, 154, 113, 121, 1, 0
DB 16, 25, 0, 0, 145, 165, 170, 153, 145, 23, 0, 0
DB 0, 81, 1, 0, 145, 165, 170, 25, 119, 1, 0, 0
DB 16, 165, 1, 16, 145, 165, 154, 113, 23, 0, 0, 0
DB 16, 170, 1, 145, 85, 170, 25, 119, 1, 0, 0, 0
DB 81, 26, 16, 89, 170, 154, 17, 119, 1, 0, 0, 0
DB 17, 1, 0, 145, 165, 25, 16, 151, 1, 0, 0, 0
DB 0, 0, 0, 16, 89, 154, 17, 151, 1, 0, 0, 0
DB 0, 0, 0, 0, 145, 154, 17, 151, 1, 0, 0, 0
DB 0, 0, 0, 0, 16, 149, 17, 151, 1, 0, 0, 0
DB 0, 0, 0, 0, 16, 169, 25, 151, 1, 0, 0, 0
DB 0, 0, 0, 0, 0, 145, 25, 23, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 16, 149, 17, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 16, 169, 25, 1, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 161, 85, 26, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 145, 149, 26, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 16, 154, 26, 0, 0, 0
DB 0, 0, 16, 153, 153, 17, 17, 145, 25, 17, 169, 154
DB 0, 0, 0, 17, 17, 34, 145, 153, 170, 170, 154, 25
DB 0, 0, 0, 0, 33, 34, 145, 153, 153, 153, 25, 17
DB 0, 0, 0, 0, 17, 33, 18, 153, 25, 33, 18, 17
DB 0, 0, 0, 16, 114, 25, 17, 17, 17, 18, 129, 17
DB 0, 0, 0, 16, 18, 113, 151, 119, 121, 20, 136, 151
DB 0, 0, 0, 16, 18, 17, 17, 17, 17, 20, 129, 17
DB 0, 0, 0, 16, 18, 17, 17, 17, 17, 65, 24, 17
DB 0, 0, 17, 17, 18, 17, 17, 17, 17, 17, 17, 17
DB 0, 17, 153, 25, 18, 17, 153, 25, 17, 17, 17, 17
DB 16, 153, 17, 17, 18, 153, 169, 154, 17, 17, 113, 23
DB 145, 17, 0, 0, 145, 153, 165, 154, 17, 17, 119, 23
DB 25, 0, 0, 0, 145, 89, 170, 154, 17, 17, 119, 25
DB 25, 0, 0, 0, 16, 89, 170, 170, 25, 119, 151, 23
DB 25, 0, 0, 0, 16, 89, 170, 170, 25, 119, 153, 1
DB 145, 1, 0, 0, 16, 89, 170, 170, 25, 119, 153, 1
DB 16, 25, 0, 0, 16, 89, 170, 170, 25, 151, 121, 1
DB 0, 81, 1, 0, 145, 165, 170, 170, 25, 151, 23, 0
DB 16, 165, 1, 0, 145, 165, 170, 154, 25, 119, 1, 0
DB 16, 170, 1, 0, 145, 149, 153, 153, 113, 23, 0, 0
DB 81, 26, 0, 0, 16, 169, 25, 17, 119, 23, 0, 0
DB 17, 1, 0, 0, 0, 161, 25, 16, 119, 1, 0, 0
DB 0, 0, 0, 0, 0, 81, 25, 16, 151, 1, 0, 0
DB 0, 0, 0, 0, 0, 81, 25, 16, 151, 1, 0, 0
DB 0, 0, 0, 0, 0, 145, 25, 16, 151, 1, 0, 0
DB 0, 0, 0, 0, 0, 16, 26, 16, 151, 1, 0, 0
DB 0, 0, 0, 0, 0, 16, 21, 16, 151, 1, 0, 0
DB 0, 0, 0, 0, 0, 16, 149, 17, 151, 1, 0, 0
DB 0, 0, 0, 0, 0, 16, 169, 25, 113, 23, 0, 0
DB 0, 0, 0, 0, 0, 0, 161, 85, 25, 121, 1, 0
DB 0, 0, 0, 0, 0, 0, 145, 149, 26, 151, 23, 0
DB 0, 0, 0, 0, 0, 0, 16, 154, 26, 113, 121, 1
DB 16, 153, 153, 17, 17, 145, 25, 145, 169, 122, 1, 0
DB 0, 17, 17, 34, 145, 153, 170, 170, 154, 25, 0, 0
DB 0, 0, 33, 34, 145, 153, 153, 153, 25, 17, 0, 0
DB 0, 0, 17, 33, 18, 153, 25, 33, 18, 17, 0, 0
DB 0, 16, 114, 25, 17, 17, 17, 18, 129, 17, 0, 0
DB 0, 16, 18, 113, 151, 119, 121, 20, 136, 151, 0, 0
DB 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0, 0
DB 0, 16, 18, 17, 17, 17, 17, 65, 24, 17, 0, 0
DB 0, 16, 18, 17, 153, 25, 17, 17, 17, 17, 0, 0
DB 0, 145, 17, 153, 153, 153, 17, 17, 17, 23, 0, 0
DB 16, 25, 145, 153, 165, 154, 25, 17, 17, 23, 0, 0
DB 16, 25, 145, 89, 170, 170, 25, 17, 113, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 17, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 154, 25, 119, 119, 23, 0, 0
DB 16, 25, 145, 165, 170, 154, 113, 151, 121, 23, 0, 0
DB 16, 25, 145, 165, 170, 153, 113, 153, 153, 23, 0, 0
DB 16, 25, 145, 165, 154, 25, 113, 153, 121, 1, 0, 0
DB 81, 17, 89, 170, 25, 17, 119, 153, 23, 0, 0, 0
DB 165, 26, 89, 154, 1, 16, 119, 121, 1, 0, 0, 0
DB 165, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 170, 17, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 26, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 1, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 119, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 1, 0, 113, 25, 0, 0, 0, 0
DB 0, 0, 161, 85, 25, 0, 16, 119, 1, 0, 0, 0
DB 0, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0
espada_golpealto:
DB 0, 16, 17, 0, 0, 33, 136, 136, 40, 17, 1, 0
DB 0, 145, 153, 1, 0, 33, 136, 136, 40, 113, 1, 0
DB 16, 25, 17, 25, 16, 34, 136, 136, 40, 113, 23, 0
DB 145, 1, 0, 145, 33, 130, 136, 136, 34, 113, 23, 0
DB 25, 0, 0, 16, 34, 34, 130, 136, 34, 113, 23, 0
DB 25, 0, 0, 33, 18, 17, 34, 40, 18, 113, 23, 0
DB 25, 0, 16, 18, 17, 17, 33, 34, 18, 17, 17, 0
DB 145, 1, 33, 17, 145, 25, 17, 34, 17, 65, 24, 0
DB 16, 25, 33, 145, 153, 153, 17, 17, 17, 20, 24, 0
DB 0, 145, 17, 153, 153, 153, 25, 17, 65, 129, 1, 0
DB 0, 145, 145, 153, 165, 154, 25, 17, 129, 24, 0, 0
DB 16, 145, 145, 89, 170, 170, 25, 17, 17, 17, 0, 0
DB 81, 25, 145, 89, 170, 170, 25, 17, 17, 17, 0, 0
DB 165, 1, 145, 165, 170, 170, 25, 17, 17, 113, 1, 0
DB 170, 1, 17, 89, 170, 170, 25, 17, 17, 119, 23, 0
DB 21, 0, 17, 89, 170, 170, 25, 17, 113, 119, 119, 1
DB 161, 17, 153, 89, 170, 170, 25, 17, 119, 151, 121, 1
DB 16, 145, 153, 153, 170, 170, 25, 16, 119, 153, 153, 23
DB 0, 145, 149, 17, 169, 154, 1, 16, 151, 153, 153, 23
DB 0, 145, 165, 1, 145, 25, 0, 16, 151, 153, 121, 1
DB 0, 16, 169, 1, 16, 1, 0, 0, 113, 121, 17, 0
DB 0, 16, 89, 1, 0, 0, 0, 0, 113, 121, 1, 0
DB 0, 16, 89, 1, 0, 0, 0, 0, 113, 121, 1, 0
DB 0, 16, 89, 1, 0, 0, 0, 0, 16, 121, 1, 0
DB 0, 16, 89, 1, 0, 0, 0, 0, 16, 121, 1, 0
DB 0, 16, 169, 1, 0, 0, 0, 0, 16, 151, 23, 0
DB 0, 16, 169, 25, 0, 0, 0, 0, 0, 113, 23, 0
DB 0, 16, 153, 153, 1, 0, 0, 0, 0, 16, 121, 1
DB 0, 0, 145, 85, 25, 0, 0, 0, 0, 16, 151, 23
DB 0, 0, 145, 85, 26, 0, 0, 0, 0, 0, 113, 121
DB 0, 0, 16, 149, 26, 0, 0, 0, 0, 0, 16, 17
DB 0, 0, 16, 154, 26, 0, 0, 0, 0, 0, 0, 0
DB 160, 0, 0, 0, 0, 0, 81, 154, 170, 169, 89, 26
DB 0, 0, 0, 0, 0, 0, 81, 165, 169, 170, 154, 26
DB 0, 0, 0, 0, 0, 0, 16, 165, 169, 170, 170, 1
DB 0, 0, 0, 0, 0, 17, 17, 153, 170, 154, 154, 1
DB 0, 0, 0, 17, 17, 153, 25, 145, 154, 170, 169, 25
DB 0, 0, 16, 34, 145, 89, 154, 25, 169, 119, 17, 113
DB 0, 0, 33, 24, 153, 165, 170, 153, 161, 170, 153, 113
DB 0, 16, 130, 24, 89, 170, 170, 154, 161, 26, 26, 113
DB 0, 33, 136, 18, 89, 170, 170, 153, 161, 170, 153, 113
DB 0, 33, 136, 18, 89, 170, 154, 25, 161, 119, 17, 113
DB 16, 130, 136, 40, 145, 165, 153, 25, 145, 170, 25, 119
DB 16, 130, 34, 130, 145, 165, 154, 17, 23, 145, 17, 151
DB 33, 34, 17, 33, 18, 169, 170, 25, 119, 17, 18, 151
DB 33, 17, 17, 17, 18, 89, 170, 153, 113, 39, 17, 151
DB 18, 17, 145, 153, 17, 145, 170, 153, 17, 18, 113, 151
DB 18, 17, 89, 154, 25, 145, 165, 154, 41, 17, 119, 151
DB 18, 145, 165, 170, 153, 17, 89, 170, 25, 0, 113, 151
DB 18, 89, 170, 170, 154, 17, 89, 170, 25, 0, 16, 151
DB 18, 89, 170, 170, 154, 25, 145, 165, 153, 1, 0, 113
DB 145, 145, 165, 170, 170, 153, 17, 89, 170, 25, 0, 16
DB 25, 16, 89, 170, 170, 154, 17, 145, 170, 154, 1, 16
DB 25, 0, 145, 89, 170, 154, 25, 17, 89, 170, 25, 16
DB 25, 0, 16, 145, 165, 170, 25, 23, 145, 165, 26, 16
DB 145, 1, 0, 16, 89, 154, 25, 119, 17, 153, 154, 17
DB 16, 25, 0, 145, 165, 153, 113, 119, 119, 17, 89, 154
DB 0, 145, 17, 89, 154, 25, 113, 119, 119, 119, 145, 165
DB 0, 16, 89, 154, 153, 17, 119, 151, 153, 121, 17, 169
DB 16, 145, 149, 25, 17, 17, 119, 25, 153, 121, 1, 145
DB 81, 154, 26, 17, 1, 0, 113, 25, 113, 119, 1, 16
DB 165, 17, 169, 85, 25, 0, 16, 119, 17, 17, 0, 0
DB 165, 26, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 81, 170, 17, 154, 26, 0, 0, 113, 121, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 85, 85, 102, 102, 86, 5
DB 0, 0, 0, 0, 0, 0, 85, 101, 102, 102, 102, 5
DB 0, 0, 0, 0, 0, 0, 85, 102, 102, 102, 102, 5
DB 0, 0, 0, 0, 0, 0, 101, 102, 102, 102, 102, 6
DB 0, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 6
DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 6
DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 6
DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102
DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102
DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102
DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102
DB 1, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102
DB 1, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102
DB 1, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102
DB 23, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102
DB 23, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102
DB 25, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102
DB 25, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102
DB 25, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102
DB 25, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102
DB 121, 1, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102
DB 119, 1, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102
DB 119, 1, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102
DB 17, 1, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102
DB 153, 17, 1, 0, 0, 102, 102, 102, 102, 102, 102, 102
DB 25, 68, 22, 17, 17, 102, 102, 102, 102, 102, 102, 102
DB 153, 136, 72, 68, 102, 17, 97, 102, 102, 102, 102, 102
DB 25, 17, 129, 136, 72, 100, 22, 17, 17, 17, 17, 102
DB 1, 0, 16, 17, 136, 72, 66, 134, 40, 100, 134, 97
DB 0, 0, 0, 0, 17, 129, 130, 72, 66, 100, 70, 24
DB 0, 0, 0, 0, 0, 16, 17, 136, 130, 136, 136, 24
DB 0, 0, 0, 0, 0, 0, 0, 17, 17, 136, 136, 1
DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 129, 130, 24
DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 129, 38, 1
DB 145, 165, 170, 153, 33, 40, 113, 113, 17, 104, 136, 1
DB 145, 165, 170, 153, 33, 40, 17, 23, 17, 132, 24, 0
DB 145, 89, 170, 153, 33, 40, 113, 121, 97, 130, 1, 0
DB 16, 89, 154, 25, 130, 40, 113, 25, 70, 18, 0, 0
DB 16, 169, 153, 33, 136, 40, 113, 97, 132, 24, 0, 0
DB 16, 89, 170, 25, 130, 40, 113, 65, 136, 17, 0, 0
DB 0, 145, 170, 25, 130, 40, 17, 70, 24, 18, 1, 0
DB 0, 145, 165, 154, 33, 18, 97, 132, 24, 18, 23, 0
DB 0, 16, 169, 154, 17, 17, 70, 136, 17, 113, 23, 0
DB 0, 16, 89, 170, 25, 17, 132, 24, 17, 119, 23, 0
DB 0, 16, 145, 165, 121, 65, 132, 113, 23, 113, 153, 1
DB 0, 145, 17, 89, 154, 129, 24, 17, 17, 113, 153, 1
DB 0, 145, 17, 145, 170, 25, 17, 17, 17, 113, 153, 1
DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0
DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0
DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0
DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0
DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0
DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0
DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0
DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0
DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0
DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0
DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0
DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0
DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0
espada_golpeadelante:
DB 0, 0, 33, 136, 136, 18, 119, 17, 113, 17, 18, 0
DB 0, 0, 33, 136, 136, 18, 119, 119, 119, 17, 18, 0
DB 0, 0, 33, 130, 136, 18, 119, 23, 17, 33, 18, 0
DB 0, 0, 17, 33, 34, 18, 113, 65, 24, 33, 1, 0
DB 0, 16, 114, 25, 17, 17, 17, 20, 129, 17, 1, 0
DB 0, 16, 18, 113, 151, 119, 121, 20, 132, 151, 1, 0
DB 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0, 0
DB 0, 16, 18, 17, 17, 17, 17, 65, 24, 17, 0, 0
DB 0, 16, 18, 17, 153, 25, 17, 17, 17, 17, 0, 0
DB 0, 145, 17, 153, 153, 153, 17, 17, 17, 23, 0, 0
DB 16, 25, 145, 153, 165, 154, 25, 17, 17, 23, 0, 0
DB 16, 25, 145, 89, 170, 170, 25, 17, 113, 23, 0, 0
DB 145, 1, 145, 89, 170, 170, 25, 17, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 154, 25, 119, 151, 23, 0, 0
DB 16, 25, 145, 165, 170, 154, 17, 119, 153, 23, 0, 0
DB 16, 25, 145, 165, 170, 153, 113, 151, 121, 23, 0, 0
DB 16, 25, 89, 170, 154, 25, 113, 153, 121, 1, 0, 0
DB 81, 17, 89, 170, 25, 17, 113, 153, 23, 0, 0, 0
DB 165, 26, 89, 154, 1, 16, 119, 121, 1, 0, 0, 0
DB 165, 17, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0
DB 170, 17, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0
DB 26, 16, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0
DB 1, 16, 169, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 0, 113, 25, 0, 0, 0, 0
DB 0, 16, 169, 25, 1, 0, 113, 25, 0, 0, 0, 0
DB 0, 0, 81, 85, 25, 0, 16, 119, 1, 0, 0, 0
DB 0, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0
DB 0, 0, 16, 26, 89, 154, 170, 170, 26, 0, 0, 0
DB 0, 0, 0, 161, 154, 169, 170, 169, 25, 0, 0, 0
DB 0, 0, 16, 17, 170, 169, 169, 154, 154, 1, 0, 0
DB 0, 0, 145, 153, 145, 170, 122, 23, 17, 0, 0, 0
DB 0, 16, 89, 165, 25, 169, 170, 170, 26, 0, 0, 0
DB 0, 145, 165, 170, 154, 161, 170, 161, 17, 0, 0, 0
DB 16, 153, 165, 170, 170, 25, 169, 170, 26, 0, 0, 0
DB 16, 153, 89, 170, 170, 154, 17, 153, 1, 0, 0, 0
DB 17, 145, 153, 165, 170, 170, 153, 17, 17, 17, 0, 0
DB 33, 18, 153, 89, 165, 170, 170, 153, 153, 153, 17, 1
DB 33, 34, 17, 153, 89, 85, 165, 169, 170, 90, 153, 25
DB 162, 34, 34, 17, 153, 153, 89, 170, 170, 170, 170, 170
DB 34, 170, 42, 34, 17, 145, 153, 153, 89, 85, 149, 153
DB 34, 162, 170, 170, 34, 18, 17, 17, 153, 153, 25, 17
DB 34, 34, 34, 170, 170, 170, 26, 17, 17, 17, 1, 0
DB 18, 34, 34, 34, 162, 170, 170, 90, 85, 85, 85, 85
DB 18, 17, 34, 34, 34, 34, 170, 170, 170, 85, 85, 85
DB 18, 17, 17, 33, 130, 34, 24, 17, 161, 90, 85, 85
DB 18, 153, 153, 25, 17, 136, 17, 17, 17, 0, 0, 0
DB 146, 153, 153, 149, 25, 17, 17, 119, 119, 1, 0, 0
DB 146, 153, 165, 170, 154, 17, 113, 119, 119, 23, 0, 0
DB 145, 153, 165, 170, 170, 25, 119, 119, 153, 23, 0, 0
DB 16, 25, 89, 165, 170, 154, 113, 151, 121, 1, 0, 0
DB 0, 145, 145, 89, 170, 154, 113, 153, 23, 0, 0, 0
DB 0, 145, 17, 145, 165, 153, 113, 121, 1, 0, 0, 0
DB 16, 25, 145, 89, 154, 25, 151, 23, 0, 0, 0, 0
DB 145, 17, 89, 170, 26, 113, 121, 1, 0, 0, 0, 0
DB 25, 89, 170, 17, 1, 113, 25, 0, 0, 0, 0, 0
DB 25, 145, 21, 17, 1, 16, 121, 1, 0, 0, 0, 0
DB 165, 17, 169, 85, 25, 16, 151, 23, 1, 0, 0, 0
DB 81, 26, 161, 149, 26, 0, 113, 151, 23, 0, 0, 0
DB 16, 165, 17, 154, 26, 0, 16, 151, 119, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 16, 17, 0, 0, 0, 16, 17, 17, 17, 17, 17, 1
DB 145, 149, 17, 17, 17, 97, 102, 129, 136, 24, 102, 22
DB 89, 26, 65, 102, 70, 68, 68, 65, 102, 20, 68, 100
DB 170, 25, 136, 136, 136, 136, 68, 129, 136, 24, 136, 72
DB 170, 153, 17, 17, 17, 129, 136, 129, 136, 24, 136, 136
DB 153, 25, 0, 0, 0, 16, 17, 17, 17, 97, 102, 102
DB 17, 1, 0, 0, 102, 102, 102, 102, 102, 102, 102, 6
DB 85, 85, 101, 102, 102, 102, 102, 102, 102, 102, 102, 0
DB 85, 85, 85, 101, 102, 102, 102, 102, 6, 0, 0, 0
DB 85, 85, 85, 85, 102, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 129, 130, 24
DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 129, 38, 1
DB 145, 165, 170, 153, 33, 40, 113, 113, 17, 104, 136, 1
DB 145, 165, 170, 153, 33, 40, 17, 23, 17, 132, 24, 0
DB 145, 89, 170, 153, 33, 40, 113, 121, 97, 130, 1, 0
DB 16, 89, 154, 25, 130, 40, 113, 25, 70, 18, 0, 0
DB 16, 169, 153, 33, 136, 40, 113, 97, 132, 24, 0, 0
DB 16, 89, 170, 25, 130, 40, 113, 65, 136, 17, 0, 0
DB 0, 145, 170, 25, 130, 40, 17, 70, 24, 18, 1, 0
DB 0, 145, 165, 154, 33, 18, 97, 132, 24, 18, 23, 0
DB 0, 16, 169, 154, 17, 17, 70, 136, 17, 113, 23, 0
DB 0, 16, 89, 170, 25, 17, 132, 24, 17, 119, 23, 0
DB 0, 16, 145, 165, 121, 65, 132, 113, 23, 113, 153, 1
DB 0, 145, 17, 89, 154, 129, 24, 17, 17, 113, 153, 1
DB 0, 145, 17, 145, 170, 25, 17, 17, 17, 113, 153, 1
DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0
DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0
DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0
DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0
DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0
DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0
DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0
DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0
DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0
DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0
DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0
DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0
DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0
espada_comboadelante:
DB 0, 0, 16, 26, 89, 154, 170, 170, 26, 0, 0, 0
DB 0, 0, 0, 161, 154, 169, 170, 169, 25, 0, 0, 0
DB 0, 0, 16, 17, 170, 169, 169, 154, 154, 1, 0, 0
DB 0, 0, 145, 153, 145, 170, 122, 23, 17, 0, 0, 0
DB 0, 16, 89, 165, 25, 169, 170, 170, 26, 0, 0, 0
DB 0, 145, 165, 170, 154, 161, 170, 161, 17, 0, 0, 0
DB 16, 153, 165, 170, 170, 25, 169, 170, 26, 0, 0, 0
DB 16, 153, 89, 170, 170, 154, 17, 153, 1, 0, 0, 0
DB 17, 145, 153, 165, 170, 170, 153, 17, 17, 17, 0, 0
DB 33, 18, 153, 89, 165, 170, 170, 153, 153, 153, 17, 1
DB 33, 34, 17, 153, 89, 85, 165, 169, 170, 90, 153, 25
DB 162, 34, 34, 17, 153, 153, 89, 170, 170, 170, 170, 170
DB 34, 170, 42, 34, 17, 145, 153, 153, 89, 85, 149, 153
DB 34, 162, 170, 170, 34, 18, 17, 17, 153, 153, 25, 17
DB 34, 34, 34, 170, 170, 170, 26, 17, 17, 17, 1, 0
DB 18, 34, 34, 34, 162, 170, 170, 90, 85, 85, 85, 85
DB 18, 17, 34, 34, 34, 34, 170, 170, 170, 85, 85, 85
DB 18, 17, 17, 33, 130, 34, 24, 17, 161, 90, 85, 85
DB 18, 153, 153, 25, 17, 136, 17, 17, 17, 0, 0, 0
DB 146, 153, 153, 149, 25, 17, 17, 119, 119, 1, 0, 0
DB 146, 153, 165, 170, 154, 17, 113, 119, 119, 23, 0, 0
DB 145, 153, 165, 170, 170, 25, 119, 119, 153, 23, 0, 0
DB 16, 25, 89, 165, 170, 154, 113, 151, 121, 1, 0, 0
DB 0, 145, 145, 89, 170, 154, 113, 153, 23, 0, 0, 0
DB 0, 145, 17, 145, 165, 153, 113, 121, 1, 0, 0, 0
DB 16, 25, 145, 89, 154, 25, 151, 23, 0, 0, 0, 0
DB 145, 17, 89, 170, 26, 113, 121, 1, 0, 0, 0, 0
DB 25, 89, 170, 17, 1, 113, 25, 0, 0, 0, 0, 0
DB 25, 145, 21, 17, 1, 16, 121, 1, 0, 0, 0, 0
DB 165, 17, 169, 85, 25, 16, 151, 23, 1, 0, 0, 0
DB 81, 26, 161, 149, 26, 0, 113, 151, 23, 0, 0, 0
DB 16, 165, 17, 154, 26, 0, 16, 151, 119, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 16, 17, 0, 0, 0, 16, 17, 17, 17, 17, 17, 1
DB 145, 149, 17, 17, 17, 97, 102, 129, 136, 24, 102, 22
DB 89, 26, 65, 102, 70, 68, 68, 65, 102, 20, 68, 100
DB 170, 25, 136, 136, 136, 136, 68, 129, 136, 24, 136, 72
DB 170, 153, 17, 17, 17, 129, 136, 129, 136, 24, 136, 136
DB 153, 25, 0, 0, 0, 16, 17, 17, 17, 97, 102, 102
DB 17, 1, 0, 0, 102, 102, 102, 102, 102, 102, 102, 6
DB 85, 85, 101, 102, 102, 102, 102, 102, 102, 102, 102, 0
DB 85, 85, 85, 101, 102, 102, 102, 102, 6, 0, 0, 0
DB 85, 85, 85, 85, 102, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
espada_golpebajo:
DB 64, 16, 130, 136, 136, 34, 113, 17, 145, 165, 153, 17
DB 64, 16, 130, 136, 136, 34, 113, 119, 23, 145, 165, 153
DB 64, 16, 130, 136, 136, 40, 17, 151, 121, 17, 89, 154
DB 64, 16, 130, 136, 136, 40, 18, 119, 121, 1, 161, 153
DB 0, 20, 34, 136, 136, 136, 18, 113, 121, 1, 145, 25
DB 0, 4, 33, 136, 136, 136, 34, 113, 121, 1, 16, 129
DB 0, 4, 33, 130, 136, 40, 18, 113, 23, 0, 16, 136
DB 0, 68, 33, 130, 40, 34, 17, 17, 1, 0, 16, 132
DB 0, 68, 17, 34, 34, 17, 132, 17, 9, 0, 16, 134
DB 0, 68, 113, 17, 17, 65, 17, 120, 1, 0, 16, 134
DB 0, 64, 20, 121, 151, 71, 97, 24, 1, 0, 16, 132
DB 0, 64, 68, 17, 17, 65, 17, 24, 23, 0, 129, 132
DB 0, 17, 68, 20, 17, 17, 132, 17, 119, 1, 97, 132
DB 16, 25, 68, 20, 17, 17, 17, 17, 119, 23, 97, 132
DB 145, 17, 68, 68, 153, 17, 17, 17, 119, 23, 72, 132
DB 25, 0, 65, 68, 164, 153, 17, 113, 151, 23, 70, 132
DB 25, 17, 145, 68, 68, 154, 25, 113, 153, 23, 70, 24
DB 145, 153, 145, 68, 100, 164, 154, 113, 121, 129, 70, 24
DB 16, 17, 25, 73, 102, 102, 153, 113, 121, 33, 66, 24
DB 16, 17, 25, 105, 102, 102, 102, 17, 23, 104, 40, 24
DB 145, 153, 17, 169, 102, 102, 102, 22, 23, 72, 136, 1
DB 21, 17, 145, 154, 97, 102, 102, 102, 129, 134, 24, 0
DB 165, 1, 145, 25, 0, 102, 102, 22, 104, 136, 24, 0
DB 165, 17, 169, 1, 0, 96, 102, 65, 34, 136, 1, 0
DB 81, 26, 169, 1, 0, 0, 22, 102, 68, 18, 0, 0
DB 16, 26, 169, 1, 0, 16, 17, 102, 132, 24, 0, 0
DB 0, 17, 169, 1, 0, 16, 23, 68, 136, 1, 0, 0
DB 0, 16, 169, 1, 0, 113, 119, 129, 24, 0, 0, 0
DB 0, 16, 169, 17, 1, 16, 151, 23, 1, 0, 0, 0
DB 0, 0, 145, 170, 25, 0, 113, 121, 1, 0, 0, 0
DB 0, 0, 145, 154, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0
DB 154, 153, 1, 16, 34, 136, 136, 136, 136, 18, 113, 113
DB 153, 25, 0, 16, 130, 136, 136, 136, 136, 18, 119, 17
DB 17, 1, 0, 33, 130, 136, 136, 136, 40, 18, 119, 25
DB 0, 0, 0, 33, 136, 136, 136, 136, 40, 113, 119, 25
DB 0, 0, 0, 33, 34, 130, 136, 136, 34, 113, 151, 25
DB 0, 0, 0, 17, 17, 34, 130, 136, 34, 113, 151, 25
DB 0, 0, 16, 25, 17, 33, 34, 136, 18, 119, 151, 25
DB 0, 0, 32, 113, 25, 17, 33, 34, 18, 119, 153, 25
DB 0, 0, 18, 17, 113, 23, 17, 132, 113, 119, 153, 1
DB 0, 32, 17, 17, 17, 145, 71, 17, 24, 153, 25, 0
DB 0, 33, 17, 17, 17, 17, 65, 65, 120, 17, 1, 0
DB 16, 33, 17, 17, 17, 17, 65, 17, 24, 1, 0, 0
DB 145, 33, 145, 153, 153, 17, 17, 132, 17, 23, 0, 0
DB 25, 16, 153, 169, 170, 25, 17, 17, 17, 119, 1, 0
DB 25, 0, 145, 170, 170, 154, 17, 17, 17, 119, 23, 0
DB 145, 1, 16, 169, 170, 170, 25, 17, 113, 151, 119, 1
DB 16, 25, 0, 145, 170, 170, 25, 17, 119, 151, 121, 1
DB 0, 145, 1, 145, 170, 170, 25, 119, 119, 153, 121, 1
DB 0, 145, 17, 169, 170, 170, 25, 119, 153, 153, 23, 0
DB 16, 25, 16, 169, 170, 153, 17, 151, 121, 119, 1, 0
DB 145, 1, 16, 169, 170, 25, 113, 119, 23, 17, 0, 0
DB 21, 0, 161, 154, 153, 17, 119, 23, 1, 0, 0, 0
DB 165, 1, 161, 25, 17, 113, 119, 1, 0, 0, 0, 0
DB 165, 17, 169, 1, 170, 113, 26, 0, 0, 0, 0, 0
DB 81, 17, 169, 1, 0, 170, 26, 0, 0, 0, 0, 0
DB 16, 26, 169, 1, 0, 113, 170, 170, 0, 0, 0, 0
DB 0, 17, 169, 1, 0, 113, 26, 170, 170, 10, 0, 0
DB 0, 16, 169, 1, 0, 113, 119, 1, 170, 170, 0, 0
DB 0, 16, 169, 17, 1, 16, 151, 23, 0, 170, 170, 170
DB 0, 0, 145, 170, 25, 0, 113, 121, 1, 0, 160, 170
DB 0, 0, 145, 154, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 113, 119, 1, 0, 0
DB 1, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 85
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 85
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5
DB 0, 0, 0, 0, 0, 0, 0, 0, 80, 85, 85, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 80, 85, 85, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 80, 85, 85, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 160, 85, 170, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 160, 170, 170, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 160, 170, 10, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 160, 170, 10, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 170, 170, 10, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 170, 170, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 170, 170, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 160, 170, 10, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 170, 170, 10, 0, 0
DB 0, 0, 0, 0, 0, 0, 160, 170, 170, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 170, 170, 10, 0, 0, 0
DB 0, 0, 0, 0, 0, 160, 170, 170, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 170, 170, 10, 0, 0, 0, 0
DB 0, 0, 0, 0, 160, 170, 170, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 170, 170, 10, 0, 0, 0, 0, 0
DB 0, 0, 0, 160, 170, 170, 0, 0, 0, 0, 0, 0
DB 0, 0, 170, 170, 170, 0, 0, 0, 0, 0, 0, 0
DB 0, 170, 170, 170, 10, 0, 0, 0, 0, 0, 0, 0
DB 170, 170, 170, 10, 0, 0, 0, 0, 0, 0, 0, 0
DB 170, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 129, 130, 24
DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 129, 38, 1
DB 145, 165, 170, 153, 33, 40, 113, 113, 17, 104, 136, 1
DB 145, 165, 170, 153, 33, 40, 17, 23, 17, 132, 24, 0
DB 145, 89, 170, 153, 33, 40, 113, 121, 97, 130, 1, 0
DB 16, 89, 154, 25, 130, 40, 113, 25, 70, 18, 0, 0
DB 16, 169, 153, 33, 136, 40, 113, 97, 132, 24, 0, 0
DB 16, 89, 170, 25, 130, 40, 113, 65, 136, 17, 0, 0
DB 0, 145, 170, 25, 130, 40, 17, 70, 24, 18, 1, 0
DB 0, 145, 165, 154, 33, 18, 97, 132, 24, 18, 23, 0
DB 0, 16, 169, 154, 17, 17, 70, 136, 17, 113, 23, 0
DB 0, 16, 89, 170, 25, 17, 132, 24, 17, 119, 23, 0
DB 0, 16, 145, 165, 121, 65, 132, 113, 23, 113, 153, 1
DB 0, 145, 17, 89, 154, 129, 24, 17, 17, 113, 153, 1
DB 0, 145, 17, 145, 170, 25, 17, 17, 17, 113, 153, 1
DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0
DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0
DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0
DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0
DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0
DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0
DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0
DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0
DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0
DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0
DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0
DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0
DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0
espada_golpeatras:
DB 0, 0, 33, 136, 136, 18, 119, 17, 113, 17, 18, 0
DB 0, 0, 33, 136, 136, 18, 119, 119, 119, 17, 18, 0
DB 0, 0, 33, 130, 136, 18, 119, 23, 17, 33, 18, 0
DB 0, 0, 17, 33, 34, 18, 113, 65, 24, 33, 1, 0
DB 0, 16, 114, 25, 17, 17, 17, 20, 129, 17, 1, 0
DB 0, 16, 18, 113, 151, 119, 121, 20, 132, 151, 1, 0
DB 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0, 0
DB 0, 16, 18, 17, 17, 17, 17, 65, 24, 17, 0, 0
DB 0, 16, 18, 17, 153, 25, 17, 17, 17, 17, 0, 0
DB 0, 145, 17, 153, 153, 153, 17, 17, 17, 23, 0, 0
DB 16, 25, 145, 153, 165, 154, 25, 17, 17, 23, 0, 0
DB 16, 25, 145, 89, 170, 170, 25, 17, 113, 23, 0, 0
DB 145, 1, 145, 89, 170, 170, 25, 17, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 154, 25, 119, 151, 23, 0, 0
DB 16, 25, 145, 165, 170, 154, 17, 119, 153, 23, 0, 0
DB 16, 25, 145, 165, 170, 153, 113, 151, 121, 23, 0, 0
DB 16, 25, 89, 170, 154, 25, 113, 153, 121, 1, 0, 0
DB 81, 17, 89, 170, 25, 17, 113, 153, 23, 0, 0, 0
DB 165, 26, 89, 154, 1, 16, 119, 121, 1, 0, 0, 0
DB 165, 17, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0
DB 170, 17, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0
DB 26, 16, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0
DB 1, 16, 169, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 0, 113, 25, 0, 0, 0, 0
DB 0, 16, 169, 25, 1, 0, 113, 25, 0, 0, 0, 0
DB 0, 0, 81, 85, 25, 0, 16, 119, 1, 0, 0, 0
DB 0, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0
DB 0, 0, 16, 26, 89, 154, 170, 170, 26, 0, 0, 0
DB 0, 0, 0, 161, 154, 169, 170, 169, 25, 0, 0, 0
DB 0, 0, 16, 17, 170, 169, 169, 154, 154, 1, 0, 0
DB 0, 0, 145, 153, 145, 170, 122, 23, 17, 0, 0, 0
DB 0, 16, 89, 165, 25, 169, 170, 170, 26, 0, 0, 0
DB 0, 145, 165, 170, 154, 161, 170, 161, 17, 0, 0, 0
DB 16, 153, 165, 170, 170, 25, 169, 170, 26, 0, 0, 0
DB 16, 153, 89, 170, 170, 154, 17, 153, 1, 0, 0, 0
DB 17, 145, 153, 165, 170, 170, 153, 17, 17, 17, 0, 0
DB 33, 18, 153, 89, 165, 170, 170, 153, 153, 153, 17, 1
DB 33, 34, 17, 153, 89, 85, 165, 169, 170, 90, 153, 25
DB 162, 34, 34, 17, 153, 153, 89, 170, 170, 170, 170, 170
DB 34, 170, 42, 34, 17, 145, 153, 153, 89, 85, 149, 153
DB 34, 162, 170, 170, 34, 18, 17, 17, 153, 153, 25, 17
DB 34, 34, 34, 170, 170, 170, 26, 17, 17, 17, 1, 0
DB 18, 34, 34, 34, 162, 170, 170, 90, 85, 85, 85, 85
DB 18, 17, 34, 34, 34, 34, 170, 170, 170, 85, 85, 85
DB 18, 17, 17, 33, 130, 34, 24, 17, 161, 90, 85, 85
DB 18, 153, 153, 25, 17, 136, 17, 17, 17, 0, 0, 0
DB 146, 153, 153, 149, 25, 17, 17, 119, 119, 1, 0, 0
DB 146, 153, 165, 170, 154, 17, 113, 119, 119, 23, 0, 0
DB 145, 153, 165, 170, 170, 25, 119, 119, 153, 23, 0, 0
DB 16, 25, 89, 165, 170, 154, 113, 151, 121, 1, 0, 0
DB 0, 145, 145, 89, 170, 154, 113, 153, 23, 0, 0, 0
DB 0, 145, 17, 145, 165, 153, 113, 121, 1, 0, 0, 0
DB 16, 25, 145, 89, 154, 25, 151, 23, 0, 0, 0, 0
DB 145, 17, 89, 170, 26, 113, 121, 1, 0, 0, 0, 0
DB 25, 89, 170, 17, 1, 113, 25, 0, 0, 0, 0, 0
DB 25, 145, 21, 17, 1, 16, 121, 1, 0, 0, 0, 0
DB 165, 17, 169, 85, 25, 16, 151, 23, 1, 0, 0, 0
DB 81, 26, 161, 149, 26, 0, 113, 151, 23, 0, 0, 0
DB 16, 165, 17, 154, 26, 0, 16, 151, 119, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 16, 17, 0, 0, 0, 16, 17, 17, 17, 17, 17, 1
DB 145, 149, 17, 17, 17, 97, 102, 129, 136, 24, 102, 22
DB 89, 26, 65, 102, 70, 68, 68, 65, 102, 20, 68, 100
DB 170, 25, 136, 136, 136, 136, 68, 129, 136, 24, 136, 72
DB 170, 153, 17, 17, 17, 129, 136, 129, 136, 24, 136, 136
DB 153, 25, 0, 0, 0, 16, 17, 17, 17, 97, 102, 102
DB 17, 1, 0, 0, 102, 102, 102, 102, 102, 102, 102, 6
DB 85, 85, 101, 102, 102, 102, 102, 102, 102, 102, 102, 0
DB 85, 85, 85, 101, 102, 102, 102, 102, 6, 0, 0, 0
DB 85, 85, 85, 85, 102, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 129, 130, 24
DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 129, 38, 1
DB 145, 165, 170, 153, 33, 40, 113, 113, 17, 104, 136, 1
DB 145, 165, 170, 153, 33, 40, 17, 23, 17, 132, 24, 0
DB 145, 89, 170, 153, 33, 40, 113, 121, 97, 130, 1, 0
DB 16, 89, 154, 25, 130, 40, 113, 25, 70, 18, 0, 0
DB 16, 169, 153, 33, 136, 40, 113, 97, 132, 24, 0, 0
DB 16, 89, 170, 25, 130, 40, 113, 65, 136, 17, 0, 0
DB 0, 145, 170, 25, 130, 40, 17, 70, 24, 18, 1, 0
DB 0, 145, 165, 154, 33, 18, 97, 132, 24, 18, 23, 0
DB 0, 16, 169, 154, 17, 17, 70, 136, 17, 113, 23, 0
DB 0, 16, 89, 170, 25, 17, 132, 24, 17, 119, 23, 0
DB 0, 16, 145, 165, 121, 65, 132, 113, 23, 113, 153, 1
DB 0, 145, 17, 89, 154, 129, 24, 17, 17, 113, 153, 1
DB 0, 145, 17, 145, 170, 25, 17, 17, 17, 113, 153, 1
DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0
DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0
DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0
DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0
DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0
DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0
DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0
DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0
DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0
DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0
DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0
DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0
DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0
DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0
espada_ouch:
DB 154, 170, 153, 33, 40, 49, 51, 51, 51, 51, 51, 0
DB 165, 170, 25, 34, 136, 51, 147, 121, 51, 51, 51, 3
DB 169, 154, 25, 130, 56, 40, 17, 17, 49, 51, 51, 3
DB 145, 153, 33, 130, 136, 18, 65, 24, 33, 51, 51, 3
DB 17, 17, 17, 17, 17, 17, 19, 129, 129, 51, 48, 3
DB 21, 113, 121, 151, 119, 121, 20, 132, 23, 51, 0, 51
DB 165, 17, 17, 17, 17, 19, 20, 129, 17, 49, 17, 48
DB 165, 17, 17, 17, 17, 17, 49, 24, 17, 115, 119, 49
DB 170, 17, 145, 153, 153, 17, 17, 17, 17, 115, 119, 23
DB 161, 17, 153, 169, 154, 25, 17, 17, 113, 119, 119, 121
DB 25, 16, 153, 165, 170, 153, 17, 113, 119, 115, 151, 121
DB 25, 16, 153, 165, 170, 154, 25, 16, 49, 119, 153, 121
DB 25, 0, 145, 165, 170, 154, 25, 3, 16, 151, 153, 23
DB 145, 1, 17, 89, 170, 154, 25, 0, 113, 153, 121, 1
DB 145, 1, 16, 89, 170, 170, 25, 16, 119, 119, 23, 0
DB 16, 25, 17, 145, 165, 170, 153, 17, 119, 23, 1, 0
DB 0, 145, 25, 145, 89, 170, 153, 1, 113, 121, 1, 0
DB 0, 16, 17, 17, 89, 170, 25, 0, 16, 151, 23, 0
DB 0, 0, 0, 0, 145, 165, 1, 0, 0, 113, 121, 1
DB 0, 0, 0, 16, 89, 26, 0, 0, 0, 16, 151, 1
DB 0, 0, 0, 145, 165, 1, 0, 0, 0, 0, 145, 23
DB 0, 0, 16, 89, 26, 0, 0, 0, 0, 0, 145, 121
DB 0, 0, 16, 169, 1, 0, 0, 0, 0, 0, 145, 121
DB 0, 0, 16, 169, 25, 0, 0, 0, 0, 0, 145, 121
DB 0, 0, 0, 145, 154, 1, 0, 0, 0, 0, 16, 23
DB 0, 0, 0, 145, 154, 1, 0, 0, 0, 0, 0, 1
DB 0, 0, 0, 145, 165, 17, 1, 0, 0, 0, 0, 0
DB 0, 0, 0, 16, 89, 170, 26, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 161, 149, 26, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 16, 149, 26, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
muere:
DB 80, 165, 170, 41, 34, 34, 18, 119, 153, 23, 18, 0
DB 0, 165, 154, 17, 34, 34, 18, 17, 17, 17, 18, 0
DB 0, 165, 154, 17, 34, 34, 18, 65, 24, 17, 18, 1
DB 0, 165, 154, 17, 34, 34, 18, 20, 129, 33, 18, 25
DB 16, 165, 154, 25, 33, 34, 18, 20, 132, 33, 145, 25
DB 16, 165, 170, 25, 16, 17, 17, 20, 129, 17, 145, 25
DB 16, 165, 154, 25, 0, 0, 0, 65, 24, 0, 145, 1
DB 16, 81, 153, 145, 153, 9, 0, 16, 1, 0, 16, 0
DB 0, 17, 17, 153, 89, 153, 0, 0, 0, 0, 0, 0
DB 0, 145, 17, 153, 165, 154, 9, 112, 119, 7, 0, 0
DB 16, 25, 145, 85, 170, 154, 25, 119, 119, 23, 0, 0
DB 16, 25, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0
DB 145, 1, 145, 165, 170, 170, 25, 119, 151, 23, 0, 0
DB 145, 1, 145, 165, 170, 154, 25, 151, 153, 23, 0, 0
DB 16, 25, 145, 89, 170, 154, 113, 151, 153, 23, 0, 0
DB 16, 25, 17, 89, 170, 153, 113, 153, 121, 23, 0, 0
DB 16, 25, 145, 153, 149, 25, 113, 153, 119, 1, 0, 0
DB 81, 17, 89, 153, 25, 17, 151, 153, 23, 0, 0, 0
DB 165, 26, 89, 149, 1, 16, 151, 121, 1, 0, 0, 0
DB 165, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 170, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 26, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 1, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 1, 0, 113, 23, 0, 0, 0, 0
DB 0, 0, 145, 85, 25, 0, 16, 151, 1, 0, 0, 0
DB 0, 0, 145, 149, 26, 0, 16, 119, 25, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 113, 151, 1, 0, 0
DB 0, 0, 5, 16, 149, 149, 170, 169, 25, 0, 5, 0
DB 0, 0, 10, 16, 25, 17, 17, 145, 25, 0, 5, 0
DB 0, 160, 0, 16, 21, 0, 0, 145, 1, 0, 0, 5
DB 0, 5, 0, 0, 17, 0, 0, 17, 0, 160, 0, 5
DB 0, 10, 0, 0, 0, 0, 0, 0, 0, 10, 160, 0
DB 0, 160, 0, 0, 10, 0, 160, 0, 0, 0, 10, 0
DB 0, 0, 5, 80, 0, 0, 0, 0, 5, 0, 5, 0
DB 0, 0, 160, 160, 0, 0, 160, 0, 0, 0, 80, 0
DB 0, 0, 10, 0, 10, 0, 0, 10, 80, 0, 0, 5
DB 0, 80, 0, 0, 80, 0, 0, 5, 0, 10, 0, 10
DB 0, 80, 0, 0, 160, 0, 80, 0, 0, 10, 160, 0
DB 16, 160, 0, 0, 10, 0, 5, 0, 160, 0, 144, 0
DB 145, 1, 10, 0, 5, 0, 10, 0, 144, 0, 9, 0
DB 145, 1, 165, 0, 160, 0, 9, 0, 153, 144, 0, 0
DB 145, 1, 160, 170, 170, 154, 25, 151, 153, 23, 0, 0
DB 16, 25, 145, 89, 170, 154, 113, 151, 153, 23, 0, 0
DB 16, 25, 17, 89, 170, 153, 113, 153, 121, 23, 0, 0
DB 16, 25, 145, 153, 149, 25, 113, 153, 119, 1, 0, 0
DB 81, 17, 89, 153, 25, 17, 151, 153, 23, 0, 0, 0
DB 165, 26, 89, 149, 1, 16, 151, 121, 1, 0, 0, 0
DB 165, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 170, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 26, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 1, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0
DB 0, 16, 169, 25, 1, 0, 113, 23, 0, 0, 0, 0
DB 0, 0, 145, 85, 21, 0, 16, 151, 1, 0, 0, 0
DB 0, 0, 145, 149, 26, 0, 16, 119, 25, 0, 0, 0
DB 0, 0, 16, 154, 26, 0, 0, 113, 151, 1, 0, 0
DB 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 10, 0, 5, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 5, 0, 160, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 10, 10, 10, 0, 0, 0
DB 0, 0, 0, 0, 80, 0, 0, 160, 0, 0, 0, 0
DB 0, 0, 0, 160, 0, 0, 0, 0, 10, 0, 0, 0
DB 0, 0, 0, 10, 10, 80, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0
DB 0, 0, 160, 0, 0, 5, 80, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 5, 16, 1, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 81, 21, 0, 0
DB 0, 0, 0, 0, 0, 0, 17, 17, 165, 169, 1, 0
DB 0, 0, 5, 0, 17, 17, 89, 149, 154, 25, 1, 0
DB 0, 0, 0, 16, 149, 89, 170, 170, 153, 26, 0, 0
DB 0, 0, 0, 81, 57, 165, 170, 169, 170, 26, 0, 0
DB 0, 160, 16, 165, 51, 170, 122, 170, 170, 25, 0, 0
DB 0, 0, 16, 153, 19, 26, 122, 154, 170, 26, 0, 0
DB 0, 0, 0, 145, 17, 169, 25, 169, 153, 25, 161, 0
DB 0, 0, 0, 16, 16, 25, 25, 153, 153, 169, 1, 0
DB 0, 10, 0, 0, 0, 17, 1, 17, 161, 26, 0, 0
DB 0, 10, 0, 0, 0, 0, 0, 0, 16, 1, 0, 0
DB 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0
DB 0, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 144, 0, 0, 0, 0, 0, 0, 0, 160, 0, 0
DB 0, 0, 9, 0, 0, 0, 0, 0, 0, 10, 0, 0
DB 0, 0, 144, 0, 0, 0, 0, 0, 153, 0, 0, 0
DB 0, 0, 153, 153, 9, 0, 144, 153, 9, 0, 0, 0
DB 0, 0, 169, 154, 153, 153, 153, 169, 10, 0, 0, 0
DB 0, 144, 153, 154, 154, 153, 153, 169, 170, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 16, 1, 16, 1, 0, 0, 0
DB 0, 0, 0, 0, 0, 81, 1, 16, 21, 0, 0, 0
DB 0, 0, 0, 0, 16, 21, 0, 0, 169, 1, 0, 0
DB 0, 0, 0, 0, 81, 154, 17, 17, 81, 26, 0, 0
DB 0, 0, 0, 0, 81, 165, 89, 165, 154, 26, 0, 0
DB 0, 0, 0, 0, 16, 165, 89, 170, 170, 1, 0, 0
DB 0, 0, 0, 0, 0, 145, 165, 154, 154, 1, 0, 0
DB 0, 0, 0, 0, 0, 81, 154, 170, 169, 1, 0, 0
DB 0, 0, 0, 0, 144, 81, 170, 119, 17, 0, 0, 0
DB 0, 0, 0, 0, 170, 81, 170, 170, 153, 1, 0, 0
DB 0, 0, 0, 144, 169, 145, 170, 26, 26, 1, 0, 0
DB 0, 0, 0, 153, 170, 17, 169, 170, 153, 1, 0, 0
DB 0, 0, 0, 169, 154, 26, 154, 119, 17, 0, 144, 0
DB 0, 0, 144, 170, 169, 26, 169, 154, 19, 0, 169, 10
DB 0, 144, 170, 170, 153, 154, 17, 17, 51, 17, 153, 154
DB 0, 153, 154, 154, 153, 154, 153, 153, 49, 51, 145, 169
|
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0xca_notsx.log_7559_2.asm | ljhsiun2/medusa | 9 | 165959 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x13c09, %rsi
lea addresses_normal_ht+0x44c9, %rdi
xor %rax, %rax
mov $36, %rcx
rep movsw
nop
nop
nop
nop
nop
add $49382, %rdi
lea addresses_D_ht+0x9fe9, %rbx
nop
nop
inc %rcx
movb (%rbx), %r12b
sub %rdi, %rdi
lea addresses_normal_ht+0x19409, %rsi
lea addresses_WT_ht+0x1ad19, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
xor %r12, %r12
mov $110, %rcx
rep movsw
nop
add %rax, %rax
lea addresses_normal_ht+0x5dd9, %rax
nop
nop
nop
dec %rbp
movb $0x61, (%rax)
nop
nop
nop
nop
add $54700, %rbx
lea addresses_WC_ht+0x198d0, %rcx
nop
nop
and %rbp, %rbp
movups (%rcx), %xmm2
vpextrq $1, %xmm2, %rdi
and %rbp, %rbp
lea addresses_normal_ht+0xb9, %rax
nop
cmp $5233, %rcx
movb $0x61, (%rax)
nop
sub %rdi, %rdi
lea addresses_WC_ht+0x18c09, %r12
cmp %rbp, %rbp
movb $0x61, (%r12)
nop
xor $9849, %rdi
lea addresses_UC_ht+0xd0c1, %rdi
nop
nop
and $61784, %rcx
movb (%rdi), %r12b
nop
nop
nop
xor %r12, %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_D+0x9589, %rbp
nop
nop
nop
and $9765, %r10
movb $0x51, (%rbp)
nop
nop
nop
nop
nop
cmp %rbp, %rbp
// Store
lea addresses_D+0x5c09, %r10
nop
and %rdx, %rdx
mov $0x5152535455565758, %r9
movq %r9, %xmm3
vmovups %ymm3, (%r10)
inc %rbp
// Store
lea addresses_UC+0x1e109, %rbp
dec %rdx
movl $0x51525354, (%rbp)
cmp $54804, %rsi
// REPMOV
lea addresses_D+0x5c09, %rsi
lea addresses_WC+0x4d69, %rdi
add %r9, %r9
mov $7, %rcx
rep movsw
nop
nop
nop
and %rsi, %rsi
// Store
lea addresses_PSE+0x1419, %rcx
nop
nop
nop
sub %rdx, %rdx
movb $0x51, (%rcx)
nop
nop
nop
cmp $19113, %rcx
// Store
lea addresses_WC+0x16609, %r9
nop
nop
nop
nop
nop
and $40027, %r8
movl $0x51525354, (%r9)
nop
nop
nop
inc %rbp
// Store
lea addresses_D+0x9589, %r10
and $197, %rbp
mov $0x5152535455565758, %r11
movq %r11, (%r10)
inc %rcx
// Store
lea addresses_UC+0x12b09, %r10
nop
nop
nop
xor $37658, %r9
movw $0x5152, (%r10)
nop
nop
nop
nop
nop
xor %r8, %r8
// Load
lea addresses_D+0x5c09, %r9
nop
xor %r10, %r10
vmovups (%r9), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $0, %xmm2, %r8
nop
nop
cmp $52454, %r11
// Load
lea addresses_RW+0x16809, %r8
nop
and $2551, %r11
vmovups (%r8), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %rcx
nop
nop
nop
inc %rcx
// Store
lea addresses_UC+0x12409, %rsi
sub $40254, %rbp
mov $0x5152535455565758, %rcx
movq %rcx, %xmm1
vmovaps %ymm1, (%rsi)
nop
nop
nop
nop
nop
add %r11, %r11
// Faulty Load
lea addresses_D+0x5c09, %rdi
nop
nop
add $50829, %r9
vmovups (%rdi), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $0, %xmm2, %r8
lea oracles, %r10
and $0xff, %r8
shlq $12, %r8
mov (%r10,%r8,1), %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'}
{'src': {'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_WC'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
{'dst': {'NT': True, 'AVXalign': True, 'size': 2, 'congruent': 7, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 11, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 4, 'same': True, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 3, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'58': 7559}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
init.asm | unagi11/xv6 | 0 | 89550 |
_init: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
char *argv[] = { "sh", 0 };
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
int pid, wpid;
if(open("console", O_RDWR) < 0){
f: 83 ec 08 sub $0x8,%esp
12: 6a 02 push $0x2
14: 68 28 08 00 00 push $0x828
19: e8 64 03 00 00 call 382 <open>
1e: 83 c4 10 add $0x10,%esp
21: 85 c0 test %eax,%eax
23: 0f 88 9f 00 00 00 js c8 <main+0xc8>
mknod("console", 1, 1);
open("console", O_RDWR);
}
dup(0); // stdout
29: 83 ec 0c sub $0xc,%esp
2c: 6a 00 push $0x0
2e: e8 87 03 00 00 call 3ba <dup>
dup(0); // stderr
33: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3a: e8 7b 03 00 00 call 3ba <dup>
3f: 83 c4 10 add $0x10,%esp
42: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(;;){
printf(1, "init: starting sh\n");
48: 83 ec 08 sub $0x8,%esp
4b: 68 30 08 00 00 push $0x830
50: 6a 01 push $0x1
52: e8 79 04 00 00 call 4d0 <printf>
pid = fork();
57: e8 de 02 00 00 call 33a <fork>
if(pid < 0){
5c: 83 c4 10 add $0x10,%esp
5f: 85 c0 test %eax,%eax
pid = fork();
61: 89 c3 mov %eax,%ebx
if(pid < 0){
63: 78 2c js 91 <main+0x91>
printf(1, "init: fork failed\n");
exit();
}
if(pid == 0){
65: 74 3d je a4 <main+0xa4>
67: 89 f6 mov %esi,%esi
69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
exec("sh", argv);
printf(1, "init: exec sh failed\n");
exit();
}
while((wpid=wait()) >= 0 && wpid != pid)
70: e8 d5 02 00 00 call 34a <wait>
75: 85 c0 test %eax,%eax
77: 78 cf js 48 <main+0x48>
79: 39 c3 cmp %eax,%ebx
7b: 74 cb je 48 <main+0x48>
printf(1, "zombie!\n");
7d: 83 ec 08 sub $0x8,%esp
80: 68 6f 08 00 00 push $0x86f
85: 6a 01 push $0x1
87: e8 44 04 00 00 call 4d0 <printf>
8c: 83 c4 10 add $0x10,%esp
8f: eb df jmp 70 <main+0x70>
printf(1, "init: fork failed\n");
91: 53 push %ebx
92: 53 push %ebx
93: 68 43 08 00 00 push $0x843
98: 6a 01 push $0x1
9a: e8 31 04 00 00 call 4d0 <printf>
exit();
9f: e8 9e 02 00 00 call 342 <exit>
exec("sh", argv);
a4: 50 push %eax
a5: 50 push %eax
a6: 68 28 0b 00 00 push $0xb28
ab: 68 56 08 00 00 push $0x856
b0: e8 c5 02 00 00 call 37a <exec>
printf(1, "init: exec sh failed\n");
b5: 5a pop %edx
b6: 59 pop %ecx
b7: 68 59 08 00 00 push $0x859
bc: 6a 01 push $0x1
be: e8 0d 04 00 00 call 4d0 <printf>
exit();
c3: e8 7a 02 00 00 call 342 <exit>
mknod("console", 1, 1);
c8: 50 push %eax
c9: 6a 01 push $0x1
cb: 6a 01 push $0x1
cd: 68 28 08 00 00 push $0x828
d2: e8 b3 02 00 00 call 38a <mknod>
open("console", O_RDWR);
d7: 58 pop %eax
d8: 5a pop %edx
d9: 6a 02 push $0x2
db: 68 28 08 00 00 push $0x828
e0: e8 9d 02 00 00 call 382 <open>
e5: 83 c4 10 add $0x10,%esp
e8: e9 3c ff ff ff jmp 29 <main+0x29>
ed: 66 90 xchg %ax,%ax
ef: 90 nop
000000f0 <strcpy>:
f0: 55 push %ebp
f1: 89 e5 mov %esp,%ebp
f3: 53 push %ebx
f4: 8b 45 08 mov 0x8(%ebp),%eax
f7: 8b 4d 0c mov 0xc(%ebp),%ecx
fa: 89 c2 mov %eax,%edx
fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
100: 83 c1 01 add $0x1,%ecx
103: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
107: 83 c2 01 add $0x1,%edx
10a: 84 db test %bl,%bl
10c: 88 5a ff mov %bl,-0x1(%edx)
10f: 75 ef jne 100 <strcpy+0x10>
111: 5b pop %ebx
112: 5d pop %ebp
113: c3 ret
114: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
11a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000120 <strcmp>:
120: 55 push %ebp
121: 89 e5 mov %esp,%ebp
123: 53 push %ebx
124: 8b 55 08 mov 0x8(%ebp),%edx
127: 8b 4d 0c mov 0xc(%ebp),%ecx
12a: 0f b6 02 movzbl (%edx),%eax
12d: 0f b6 19 movzbl (%ecx),%ebx
130: 84 c0 test %al,%al
132: 75 1c jne 150 <strcmp+0x30>
134: eb 2a jmp 160 <strcmp+0x40>
136: 8d 76 00 lea 0x0(%esi),%esi
139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
140: 83 c2 01 add $0x1,%edx
143: 0f b6 02 movzbl (%edx),%eax
146: 83 c1 01 add $0x1,%ecx
149: 0f b6 19 movzbl (%ecx),%ebx
14c: 84 c0 test %al,%al
14e: 74 10 je 160 <strcmp+0x40>
150: 38 d8 cmp %bl,%al
152: 74 ec je 140 <strcmp+0x20>
154: 29 d8 sub %ebx,%eax
156: 5b pop %ebx
157: 5d pop %ebp
158: c3 ret
159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
160: 31 c0 xor %eax,%eax
162: 29 d8 sub %ebx,%eax
164: 5b pop %ebx
165: 5d pop %ebp
166: c3 ret
167: 89 f6 mov %esi,%esi
169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000170 <strlen>:
170: 55 push %ebp
171: 89 e5 mov %esp,%ebp
173: 8b 4d 08 mov 0x8(%ebp),%ecx
176: 80 39 00 cmpb $0x0,(%ecx)
179: 74 15 je 190 <strlen+0x20>
17b: 31 d2 xor %edx,%edx
17d: 8d 76 00 lea 0x0(%esi),%esi
180: 83 c2 01 add $0x1,%edx
183: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
187: 89 d0 mov %edx,%eax
189: 75 f5 jne 180 <strlen+0x10>
18b: 5d pop %ebp
18c: c3 ret
18d: 8d 76 00 lea 0x0(%esi),%esi
190: 31 c0 xor %eax,%eax
192: 5d pop %ebp
193: c3 ret
194: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
19a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000001a0 <memset>:
1a0: 55 push %ebp
1a1: 89 e5 mov %esp,%ebp
1a3: 57 push %edi
1a4: 8b 55 08 mov 0x8(%ebp),%edx
1a7: 8b 4d 10 mov 0x10(%ebp),%ecx
1aa: 8b 45 0c mov 0xc(%ebp),%eax
1ad: 89 d7 mov %edx,%edi
1af: fc cld
1b0: f3 aa rep stos %al,%es:(%edi)
1b2: 89 d0 mov %edx,%eax
1b4: 5f pop %edi
1b5: 5d pop %ebp
1b6: c3 ret
1b7: 89 f6 mov %esi,%esi
1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001c0 <strchr>:
1c0: 55 push %ebp
1c1: 89 e5 mov %esp,%ebp
1c3: 53 push %ebx
1c4: 8b 45 08 mov 0x8(%ebp),%eax
1c7: 8b 5d 0c mov 0xc(%ebp),%ebx
1ca: 0f b6 10 movzbl (%eax),%edx
1cd: 84 d2 test %dl,%dl
1cf: 74 1d je 1ee <strchr+0x2e>
1d1: 38 d3 cmp %dl,%bl
1d3: 89 d9 mov %ebx,%ecx
1d5: 75 0d jne 1e4 <strchr+0x24>
1d7: eb 17 jmp 1f0 <strchr+0x30>
1d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1e0: 38 ca cmp %cl,%dl
1e2: 74 0c je 1f0 <strchr+0x30>
1e4: 83 c0 01 add $0x1,%eax
1e7: 0f b6 10 movzbl (%eax),%edx
1ea: 84 d2 test %dl,%dl
1ec: 75 f2 jne 1e0 <strchr+0x20>
1ee: 31 c0 xor %eax,%eax
1f0: 5b pop %ebx
1f1: 5d pop %ebp
1f2: c3 ret
1f3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000200 <gets>:
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 57 push %edi
204: 56 push %esi
205: 53 push %ebx
206: 31 f6 xor %esi,%esi
208: 89 f3 mov %esi,%ebx
20a: 83 ec 1c sub $0x1c,%esp
20d: 8b 7d 08 mov 0x8(%ebp),%edi
210: eb 2f jmp 241 <gets+0x41>
212: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
218: 8d 45 e7 lea -0x19(%ebp),%eax
21b: 83 ec 04 sub $0x4,%esp
21e: 6a 01 push $0x1
220: 50 push %eax
221: 6a 00 push $0x0
223: e8 32 01 00 00 call 35a <read>
228: 83 c4 10 add $0x10,%esp
22b: 85 c0 test %eax,%eax
22d: 7e 1c jle 24b <gets+0x4b>
22f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
233: 83 c7 01 add $0x1,%edi
236: 88 47 ff mov %al,-0x1(%edi)
239: 3c 0a cmp $0xa,%al
23b: 74 23 je 260 <gets+0x60>
23d: 3c 0d cmp $0xd,%al
23f: 74 1f je 260 <gets+0x60>
241: 83 c3 01 add $0x1,%ebx
244: 3b 5d 0c cmp 0xc(%ebp),%ebx
247: 89 fe mov %edi,%esi
249: 7c cd jl 218 <gets+0x18>
24b: 89 f3 mov %esi,%ebx
24d: 8b 45 08 mov 0x8(%ebp),%eax
250: c6 03 00 movb $0x0,(%ebx)
253: 8d 65 f4 lea -0xc(%ebp),%esp
256: 5b pop %ebx
257: 5e pop %esi
258: 5f pop %edi
259: 5d pop %ebp
25a: c3 ret
25b: 90 nop
25c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
260: 8b 75 08 mov 0x8(%ebp),%esi
263: 8b 45 08 mov 0x8(%ebp),%eax
266: 01 de add %ebx,%esi
268: 89 f3 mov %esi,%ebx
26a: c6 03 00 movb $0x0,(%ebx)
26d: 8d 65 f4 lea -0xc(%ebp),%esp
270: 5b pop %ebx
271: 5e pop %esi
272: 5f pop %edi
273: 5d pop %ebp
274: c3 ret
275: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000280 <stat>:
280: 55 push %ebp
281: 89 e5 mov %esp,%ebp
283: 56 push %esi
284: 53 push %ebx
285: 83 ec 08 sub $0x8,%esp
288: 6a 00 push $0x0
28a: ff 75 08 pushl 0x8(%ebp)
28d: e8 f0 00 00 00 call 382 <open>
292: 83 c4 10 add $0x10,%esp
295: 85 c0 test %eax,%eax
297: 78 27 js 2c0 <stat+0x40>
299: 83 ec 08 sub $0x8,%esp
29c: ff 75 0c pushl 0xc(%ebp)
29f: 89 c3 mov %eax,%ebx
2a1: 50 push %eax
2a2: e8 f3 00 00 00 call 39a <fstat>
2a7: 89 1c 24 mov %ebx,(%esp)
2aa: 89 c6 mov %eax,%esi
2ac: e8 b9 00 00 00 call 36a <close>
2b1: 83 c4 10 add $0x10,%esp
2b4: 8d 65 f8 lea -0x8(%ebp),%esp
2b7: 89 f0 mov %esi,%eax
2b9: 5b pop %ebx
2ba: 5e pop %esi
2bb: 5d pop %ebp
2bc: c3 ret
2bd: 8d 76 00 lea 0x0(%esi),%esi
2c0: be ff ff ff ff mov $0xffffffff,%esi
2c5: eb ed jmp 2b4 <stat+0x34>
2c7: 89 f6 mov %esi,%esi
2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000002d0 <atoi>:
2d0: 55 push %ebp
2d1: 89 e5 mov %esp,%ebp
2d3: 53 push %ebx
2d4: 8b 4d 08 mov 0x8(%ebp),%ecx
2d7: 0f be 11 movsbl (%ecx),%edx
2da: 8d 42 d0 lea -0x30(%edx),%eax
2dd: 3c 09 cmp $0x9,%al
2df: b8 00 00 00 00 mov $0x0,%eax
2e4: 77 1f ja 305 <atoi+0x35>
2e6: 8d 76 00 lea 0x0(%esi),%esi
2e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
2f0: 8d 04 80 lea (%eax,%eax,4),%eax
2f3: 83 c1 01 add $0x1,%ecx
2f6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
2fa: 0f be 11 movsbl (%ecx),%edx
2fd: 8d 5a d0 lea -0x30(%edx),%ebx
300: 80 fb 09 cmp $0x9,%bl
303: 76 eb jbe 2f0 <atoi+0x20>
305: 5b pop %ebx
306: 5d pop %ebp
307: c3 ret
308: 90 nop
309: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000310 <memmove>:
310: 55 push %ebp
311: 89 e5 mov %esp,%ebp
313: 56 push %esi
314: 53 push %ebx
315: 8b 5d 10 mov 0x10(%ebp),%ebx
318: 8b 45 08 mov 0x8(%ebp),%eax
31b: 8b 75 0c mov 0xc(%ebp),%esi
31e: 85 db test %ebx,%ebx
320: 7e 14 jle 336 <memmove+0x26>
322: 31 d2 xor %edx,%edx
324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
328: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
32c: 88 0c 10 mov %cl,(%eax,%edx,1)
32f: 83 c2 01 add $0x1,%edx
332: 39 d3 cmp %edx,%ebx
334: 75 f2 jne 328 <memmove+0x18>
336: 5b pop %ebx
337: 5e pop %esi
338: 5d pop %ebp
339: c3 ret
0000033a <fork>:
33a: b8 01 00 00 00 mov $0x1,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <exit>:
342: b8 02 00 00 00 mov $0x2,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <wait>:
34a: b8 03 00 00 00 mov $0x3,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <pipe>:
352: b8 04 00 00 00 mov $0x4,%eax
357: cd 40 int $0x40
359: c3 ret
0000035a <read>:
35a: b8 05 00 00 00 mov $0x5,%eax
35f: cd 40 int $0x40
361: c3 ret
00000362 <write>:
362: b8 10 00 00 00 mov $0x10,%eax
367: cd 40 int $0x40
369: c3 ret
0000036a <close>:
36a: b8 15 00 00 00 mov $0x15,%eax
36f: cd 40 int $0x40
371: c3 ret
00000372 <kill>:
372: b8 06 00 00 00 mov $0x6,%eax
377: cd 40 int $0x40
379: c3 ret
0000037a <exec>:
37a: b8 07 00 00 00 mov $0x7,%eax
37f: cd 40 int $0x40
381: c3 ret
00000382 <open>:
382: b8 0f 00 00 00 mov $0xf,%eax
387: cd 40 int $0x40
389: c3 ret
0000038a <mknod>:
38a: b8 11 00 00 00 mov $0x11,%eax
38f: cd 40 int $0x40
391: c3 ret
00000392 <unlink>:
392: b8 12 00 00 00 mov $0x12,%eax
397: cd 40 int $0x40
399: c3 ret
0000039a <fstat>:
39a: b8 08 00 00 00 mov $0x8,%eax
39f: cd 40 int $0x40
3a1: c3 ret
000003a2 <link>:
3a2: b8 13 00 00 00 mov $0x13,%eax
3a7: cd 40 int $0x40
3a9: c3 ret
000003aa <mkdir>:
3aa: b8 14 00 00 00 mov $0x14,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <chdir>:
3b2: b8 09 00 00 00 mov $0x9,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <dup>:
3ba: b8 0a 00 00 00 mov $0xa,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <getpid>:
3c2: b8 0b 00 00 00 mov $0xb,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <sbrk>:
3ca: b8 0c 00 00 00 mov $0xc,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <sleep>:
3d2: b8 0d 00 00 00 mov $0xd,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <uptime>:
3da: b8 0e 00 00 00 mov $0xe,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <hello>:
3e2: b8 16 00 00 00 mov $0x16,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <hello_name>:
3ea: b8 17 00 00 00 mov $0x17,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <get_num_proc>:
3f2: b8 18 00 00 00 mov $0x18,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <get_max_pid>:
3fa: b8 19 00 00 00 mov $0x19,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <get_proc_info>:
402: b8 1a 00 00 00 mov $0x1a,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <cps>:
40a: b8 1b 00 00 00 mov $0x1b,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <get_prio>:
412: b8 1c 00 00 00 mov $0x1c,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <set_prio>:
41a: b8 1d 00 00 00 mov $0x1d,%eax
41f: cd 40 int $0x40
421: c3 ret
422: 66 90 xchg %ax,%ax
424: 66 90 xchg %ax,%ax
426: 66 90 xchg %ax,%ax
428: 66 90 xchg %ax,%ax
42a: 66 90 xchg %ax,%ax
42c: 66 90 xchg %ax,%ax
42e: 66 90 xchg %ax,%ax
00000430 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
430: 55 push %ebp
431: 89 e5 mov %esp,%ebp
433: 57 push %edi
434: 56 push %esi
435: 53 push %ebx
436: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
439: 85 d2 test %edx,%edx
{
43b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
43e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
440: 79 76 jns 4b8 <printint+0x88>
442: f6 45 08 01 testb $0x1,0x8(%ebp)
446: 74 70 je 4b8 <printint+0x88>
x = -xx;
448: f7 d8 neg %eax
neg = 1;
44a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
451: 31 f6 xor %esi,%esi
453: 8d 5d d7 lea -0x29(%ebp),%ebx
456: eb 0a jmp 462 <printint+0x32>
458: 90 nop
459: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
460: 89 fe mov %edi,%esi
462: 31 d2 xor %edx,%edx
464: 8d 7e 01 lea 0x1(%esi),%edi
467: f7 f1 div %ecx
469: 0f b6 92 80 08 00 00 movzbl 0x880(%edx),%edx
}while((x /= base) != 0);
470: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
472: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
475: 75 e9 jne 460 <printint+0x30>
if(neg)
477: 8b 45 c4 mov -0x3c(%ebp),%eax
47a: 85 c0 test %eax,%eax
47c: 74 08 je 486 <printint+0x56>
buf[i++] = '-';
47e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
483: 8d 7e 02 lea 0x2(%esi),%edi
486: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
48a: 8b 7d c0 mov -0x40(%ebp),%edi
48d: 8d 76 00 lea 0x0(%esi),%esi
490: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
493: 83 ec 04 sub $0x4,%esp
496: 83 ee 01 sub $0x1,%esi
499: 6a 01 push $0x1
49b: 53 push %ebx
49c: 57 push %edi
49d: 88 45 d7 mov %al,-0x29(%ebp)
4a0: e8 bd fe ff ff call 362 <write>
while(--i >= 0)
4a5: 83 c4 10 add $0x10,%esp
4a8: 39 de cmp %ebx,%esi
4aa: 75 e4 jne 490 <printint+0x60>
putc(fd, buf[i]);
}
4ac: 8d 65 f4 lea -0xc(%ebp),%esp
4af: 5b pop %ebx
4b0: 5e pop %esi
4b1: 5f pop %edi
4b2: 5d pop %ebp
4b3: c3 ret
4b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
4b8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
4bf: eb 90 jmp 451 <printint+0x21>
4c1: eb 0d jmp 4d0 <printf>
4c3: 90 nop
4c4: 90 nop
4c5: 90 nop
4c6: 90 nop
4c7: 90 nop
4c8: 90 nop
4c9: 90 nop
4ca: 90 nop
4cb: 90 nop
4cc: 90 nop
4cd: 90 nop
4ce: 90 nop
4cf: 90 nop
000004d0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
4d0: 55 push %ebp
4d1: 89 e5 mov %esp,%ebp
4d3: 57 push %edi
4d4: 56 push %esi
4d5: 53 push %ebx
4d6: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
4d9: 8b 75 0c mov 0xc(%ebp),%esi
4dc: 0f b6 1e movzbl (%esi),%ebx
4df: 84 db test %bl,%bl
4e1: 0f 84 b3 00 00 00 je 59a <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
4e7: 8d 45 10 lea 0x10(%ebp),%eax
4ea: 83 c6 01 add $0x1,%esi
state = 0;
4ed: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
4ef: 89 45 d4 mov %eax,-0x2c(%ebp)
4f2: eb 2f jmp 523 <printf+0x53>
4f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
4f8: 83 f8 25 cmp $0x25,%eax
4fb: 0f 84 a7 00 00 00 je 5a8 <printf+0xd8>
write(fd, &c, 1);
501: 8d 45 e2 lea -0x1e(%ebp),%eax
504: 83 ec 04 sub $0x4,%esp
507: 88 5d e2 mov %bl,-0x1e(%ebp)
50a: 6a 01 push $0x1
50c: 50 push %eax
50d: ff 75 08 pushl 0x8(%ebp)
510: e8 4d fe ff ff call 362 <write>
515: 83 c4 10 add $0x10,%esp
518: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
51b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
51f: 84 db test %bl,%bl
521: 74 77 je 59a <printf+0xca>
if(state == 0){
523: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
525: 0f be cb movsbl %bl,%ecx
528: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
52b: 74 cb je 4f8 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
52d: 83 ff 25 cmp $0x25,%edi
530: 75 e6 jne 518 <printf+0x48>
if(c == 'd'){
532: 83 f8 64 cmp $0x64,%eax
535: 0f 84 05 01 00 00 je 640 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
53b: 81 e1 f7 00 00 00 and $0xf7,%ecx
541: 83 f9 70 cmp $0x70,%ecx
544: 74 72 je 5b8 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
546: 83 f8 73 cmp $0x73,%eax
549: 0f 84 99 00 00 00 je 5e8 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
54f: 83 f8 63 cmp $0x63,%eax
552: 0f 84 08 01 00 00 je 660 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
558: 83 f8 25 cmp $0x25,%eax
55b: 0f 84 ef 00 00 00 je 650 <printf+0x180>
write(fd, &c, 1);
561: 8d 45 e7 lea -0x19(%ebp),%eax
564: 83 ec 04 sub $0x4,%esp
567: c6 45 e7 25 movb $0x25,-0x19(%ebp)
56b: 6a 01 push $0x1
56d: 50 push %eax
56e: ff 75 08 pushl 0x8(%ebp)
571: e8 ec fd ff ff call 362 <write>
576: 83 c4 0c add $0xc,%esp
579: 8d 45 e6 lea -0x1a(%ebp),%eax
57c: 88 5d e6 mov %bl,-0x1a(%ebp)
57f: 6a 01 push $0x1
581: 50 push %eax
582: ff 75 08 pushl 0x8(%ebp)
585: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
588: 31 ff xor %edi,%edi
write(fd, &c, 1);
58a: e8 d3 fd ff ff call 362 <write>
for(i = 0; fmt[i]; i++){
58f: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
593: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
596: 84 db test %bl,%bl
598: 75 89 jne 523 <printf+0x53>
}
}
}
59a: 8d 65 f4 lea -0xc(%ebp),%esp
59d: 5b pop %ebx
59e: 5e pop %esi
59f: 5f pop %edi
5a0: 5d pop %ebp
5a1: c3 ret
5a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
5a8: bf 25 00 00 00 mov $0x25,%edi
5ad: e9 66 ff ff ff jmp 518 <printf+0x48>
5b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
5b8: 83 ec 0c sub $0xc,%esp
5bb: b9 10 00 00 00 mov $0x10,%ecx
5c0: 6a 00 push $0x0
5c2: 8b 7d d4 mov -0x2c(%ebp),%edi
5c5: 8b 45 08 mov 0x8(%ebp),%eax
5c8: 8b 17 mov (%edi),%edx
5ca: e8 61 fe ff ff call 430 <printint>
ap++;
5cf: 89 f8 mov %edi,%eax
5d1: 83 c4 10 add $0x10,%esp
state = 0;
5d4: 31 ff xor %edi,%edi
ap++;
5d6: 83 c0 04 add $0x4,%eax
5d9: 89 45 d4 mov %eax,-0x2c(%ebp)
5dc: e9 37 ff ff ff jmp 518 <printf+0x48>
5e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
5e8: 8b 45 d4 mov -0x2c(%ebp),%eax
5eb: 8b 08 mov (%eax),%ecx
ap++;
5ed: 83 c0 04 add $0x4,%eax
5f0: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
5f3: 85 c9 test %ecx,%ecx
5f5: 0f 84 8e 00 00 00 je 689 <printf+0x1b9>
while(*s != 0){
5fb: 0f b6 01 movzbl (%ecx),%eax
state = 0;
5fe: 31 ff xor %edi,%edi
s = (char*)*ap;
600: 89 cb mov %ecx,%ebx
while(*s != 0){
602: 84 c0 test %al,%al
604: 0f 84 0e ff ff ff je 518 <printf+0x48>
60a: 89 75 d0 mov %esi,-0x30(%ebp)
60d: 89 de mov %ebx,%esi
60f: 8b 5d 08 mov 0x8(%ebp),%ebx
612: 8d 7d e3 lea -0x1d(%ebp),%edi
615: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
618: 83 ec 04 sub $0x4,%esp
s++;
61b: 83 c6 01 add $0x1,%esi
61e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
621: 6a 01 push $0x1
623: 57 push %edi
624: 53 push %ebx
625: e8 38 fd ff ff call 362 <write>
while(*s != 0){
62a: 0f b6 06 movzbl (%esi),%eax
62d: 83 c4 10 add $0x10,%esp
630: 84 c0 test %al,%al
632: 75 e4 jne 618 <printf+0x148>
634: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
637: 31 ff xor %edi,%edi
639: e9 da fe ff ff jmp 518 <printf+0x48>
63e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
640: 83 ec 0c sub $0xc,%esp
643: b9 0a 00 00 00 mov $0xa,%ecx
648: 6a 01 push $0x1
64a: e9 73 ff ff ff jmp 5c2 <printf+0xf2>
64f: 90 nop
write(fd, &c, 1);
650: 83 ec 04 sub $0x4,%esp
653: 88 5d e5 mov %bl,-0x1b(%ebp)
656: 8d 45 e5 lea -0x1b(%ebp),%eax
659: 6a 01 push $0x1
65b: e9 21 ff ff ff jmp 581 <printf+0xb1>
putc(fd, *ap);
660: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
663: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
666: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
668: 6a 01 push $0x1
ap++;
66a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
66d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
670: 8d 45 e4 lea -0x1c(%ebp),%eax
673: 50 push %eax
674: ff 75 08 pushl 0x8(%ebp)
677: e8 e6 fc ff ff call 362 <write>
ap++;
67c: 89 7d d4 mov %edi,-0x2c(%ebp)
67f: 83 c4 10 add $0x10,%esp
state = 0;
682: 31 ff xor %edi,%edi
684: e9 8f fe ff ff jmp 518 <printf+0x48>
s = "(null)";
689: bb 78 08 00 00 mov $0x878,%ebx
while(*s != 0){
68e: b8 28 00 00 00 mov $0x28,%eax
693: e9 72 ff ff ff jmp 60a <printf+0x13a>
698: 66 90 xchg %ax,%ax
69a: 66 90 xchg %ax,%ax
69c: 66 90 xchg %ax,%ax
69e: 66 90 xchg %ax,%ax
000006a0 <free>:
6a0: 55 push %ebp
6a1: a1 30 0b 00 00 mov 0xb30,%eax
6a6: 89 e5 mov %esp,%ebp
6a8: 57 push %edi
6a9: 56 push %esi
6aa: 53 push %ebx
6ab: 8b 5d 08 mov 0x8(%ebp),%ebx
6ae: 8d 4b f8 lea -0x8(%ebx),%ecx
6b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
6b8: 39 c8 cmp %ecx,%eax
6ba: 8b 10 mov (%eax),%edx
6bc: 73 32 jae 6f0 <free+0x50>
6be: 39 d1 cmp %edx,%ecx
6c0: 72 04 jb 6c6 <free+0x26>
6c2: 39 d0 cmp %edx,%eax
6c4: 72 32 jb 6f8 <free+0x58>
6c6: 8b 73 fc mov -0x4(%ebx),%esi
6c9: 8d 3c f1 lea (%ecx,%esi,8),%edi
6cc: 39 fa cmp %edi,%edx
6ce: 74 30 je 700 <free+0x60>
6d0: 89 53 f8 mov %edx,-0x8(%ebx)
6d3: 8b 50 04 mov 0x4(%eax),%edx
6d6: 8d 34 d0 lea (%eax,%edx,8),%esi
6d9: 39 f1 cmp %esi,%ecx
6db: 74 3a je 717 <free+0x77>
6dd: 89 08 mov %ecx,(%eax)
6df: a3 30 0b 00 00 mov %eax,0xb30
6e4: 5b pop %ebx
6e5: 5e pop %esi
6e6: 5f pop %edi
6e7: 5d pop %ebp
6e8: c3 ret
6e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
6f0: 39 d0 cmp %edx,%eax
6f2: 72 04 jb 6f8 <free+0x58>
6f4: 39 d1 cmp %edx,%ecx
6f6: 72 ce jb 6c6 <free+0x26>
6f8: 89 d0 mov %edx,%eax
6fa: eb bc jmp 6b8 <free+0x18>
6fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
700: 03 72 04 add 0x4(%edx),%esi
703: 89 73 fc mov %esi,-0x4(%ebx)
706: 8b 10 mov (%eax),%edx
708: 8b 12 mov (%edx),%edx
70a: 89 53 f8 mov %edx,-0x8(%ebx)
70d: 8b 50 04 mov 0x4(%eax),%edx
710: 8d 34 d0 lea (%eax,%edx,8),%esi
713: 39 f1 cmp %esi,%ecx
715: 75 c6 jne 6dd <free+0x3d>
717: 03 53 fc add -0x4(%ebx),%edx
71a: a3 30 0b 00 00 mov %eax,0xb30
71f: 89 50 04 mov %edx,0x4(%eax)
722: 8b 53 f8 mov -0x8(%ebx),%edx
725: 89 10 mov %edx,(%eax)
727: 5b pop %ebx
728: 5e pop %esi
729: 5f pop %edi
72a: 5d pop %ebp
72b: c3 ret
72c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000730 <malloc>:
730: 55 push %ebp
731: 89 e5 mov %esp,%ebp
733: 57 push %edi
734: 56 push %esi
735: 53 push %ebx
736: 83 ec 0c sub $0xc,%esp
739: 8b 45 08 mov 0x8(%ebp),%eax
73c: 8b 15 30 0b 00 00 mov 0xb30,%edx
742: 8d 78 07 lea 0x7(%eax),%edi
745: c1 ef 03 shr $0x3,%edi
748: 83 c7 01 add $0x1,%edi
74b: 85 d2 test %edx,%edx
74d: 0f 84 9d 00 00 00 je 7f0 <malloc+0xc0>
753: 8b 02 mov (%edx),%eax
755: 8b 48 04 mov 0x4(%eax),%ecx
758: 39 cf cmp %ecx,%edi
75a: 76 6c jbe 7c8 <malloc+0x98>
75c: 81 ff 00 10 00 00 cmp $0x1000,%edi
762: bb 00 10 00 00 mov $0x1000,%ebx
767: 0f 43 df cmovae %edi,%ebx
76a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
771: eb 0e jmp 781 <malloc+0x51>
773: 90 nop
774: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
778: 8b 02 mov (%edx),%eax
77a: 8b 48 04 mov 0x4(%eax),%ecx
77d: 39 f9 cmp %edi,%ecx
77f: 73 47 jae 7c8 <malloc+0x98>
781: 39 05 30 0b 00 00 cmp %eax,0xb30
787: 89 c2 mov %eax,%edx
789: 75 ed jne 778 <malloc+0x48>
78b: 83 ec 0c sub $0xc,%esp
78e: 56 push %esi
78f: e8 36 fc ff ff call 3ca <sbrk>
794: 83 c4 10 add $0x10,%esp
797: 83 f8 ff cmp $0xffffffff,%eax
79a: 74 1c je 7b8 <malloc+0x88>
79c: 89 58 04 mov %ebx,0x4(%eax)
79f: 83 ec 0c sub $0xc,%esp
7a2: 83 c0 08 add $0x8,%eax
7a5: 50 push %eax
7a6: e8 f5 fe ff ff call 6a0 <free>
7ab: 8b 15 30 0b 00 00 mov 0xb30,%edx
7b1: 83 c4 10 add $0x10,%esp
7b4: 85 d2 test %edx,%edx
7b6: 75 c0 jne 778 <malloc+0x48>
7b8: 8d 65 f4 lea -0xc(%ebp),%esp
7bb: 31 c0 xor %eax,%eax
7bd: 5b pop %ebx
7be: 5e pop %esi
7bf: 5f pop %edi
7c0: 5d pop %ebp
7c1: c3 ret
7c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
7c8: 39 cf cmp %ecx,%edi
7ca: 74 54 je 820 <malloc+0xf0>
7cc: 29 f9 sub %edi,%ecx
7ce: 89 48 04 mov %ecx,0x4(%eax)
7d1: 8d 04 c8 lea (%eax,%ecx,8),%eax
7d4: 89 78 04 mov %edi,0x4(%eax)
7d7: 89 15 30 0b 00 00 mov %edx,0xb30
7dd: 8d 65 f4 lea -0xc(%ebp),%esp
7e0: 83 c0 08 add $0x8,%eax
7e3: 5b pop %ebx
7e4: 5e pop %esi
7e5: 5f pop %edi
7e6: 5d pop %ebp
7e7: c3 ret
7e8: 90 nop
7e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
7f0: c7 05 30 0b 00 00 34 movl $0xb34,0xb30
7f7: 0b 00 00
7fa: c7 05 34 0b 00 00 34 movl $0xb34,0xb34
801: 0b 00 00
804: b8 34 0b 00 00 mov $0xb34,%eax
809: c7 05 38 0b 00 00 00 movl $0x0,0xb38
810: 00 00 00
813: e9 44 ff ff ff jmp 75c <malloc+0x2c>
818: 90 nop
819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
820: 8b 08 mov (%eax),%ecx
822: 89 0a mov %ecx,(%edx)
824: eb b1 jmp 7d7 <malloc+0xa7>
|
source/compiler/compiler-field_descriptors.ads | mgrojo/protobuf | 12 | 11632 | -- MIT License
--
-- Copyright (c) 2020 <NAME>
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
with Ada_Pretty;
with League.Strings;
with Google.Protobuf.Descriptor;
with Compiler.Context;
package Compiler.Field_Descriptors is
procedure Dependency
(Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto;
Result : in out Compiler.Context.String_Sets.Set);
-- Append dependency names to Result
function Component
(Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto;
Pkg : League.Strings.Universal_String;
Tipe : League.Strings.Universal_String;
Fake : Compiler.Context.String_Sets.Set)
return Ada_Pretty.Node_Access;
function Read_Case
(Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto;
Pkg : League.Strings.Universal_String;
Tipe : League.Strings.Universal_String;
Fake : Compiler.Context.String_Sets.Set;
Oneof : League.Strings.Universal_String)
return Ada_Pretty.Node_Access;
function Case_Path
(Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto;
Pkg : League.Strings.Universal_String;
Tipe : League.Strings.Universal_String;
Fake : Compiler.Context.String_Sets.Set)
return Ada_Pretty.Node_Access;
function Write_Call
(Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto;
Pkg : League.Strings.Universal_String;
Tipe : League.Strings.Universal_String;
Fake : Compiler.Context.String_Sets.Set)
return Ada_Pretty.Node_Access;
procedure Get_Used_Types
(Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto;
Result : in out Compiler.Context.String_Sets.Set);
function Unique_Id
(Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto;
Pkg : League.Strings.Universal_String;
Tipe : League.Strings.Universal_String)
return League.Strings.Universal_String;
end Compiler.Field_Descriptors;
|
src/Fragment/Algebra/Homomorphism/Base.agda | yallop/agda-fragment | 18 | 13684 | <reponame>yallop/agda-fragment
{-# OPTIONS --without-K --exact-split --safe #-}
open import Fragment.Algebra.Signature
module Fragment.Algebra.Homomorphism.Base (Σ : Signature) where
open import Fragment.Algebra.Algebra Σ
open import Fragment.Algebra.Homomorphism.Definitions Σ
open import Fragment.Setoid.Morphism as Morphism
hiding (id; ∣_∣; ∣_∣-cong)
open import Level using (Level; _⊔_)
open import Function using (_∘_; _$_)
open import Data.Vec using (map)
open import Data.Vec.Properties using (map-id; map-∘)
import Data.Vec.Relation.Binary.Equality.Setoid as VecSetoid
open import Relation.Binary using (IsEquivalence)
import Relation.Binary.Reasoning.Setoid as Reasoning
private
variable
a b c ℓ₁ ℓ₂ ℓ₃ : Level
module _
(A : Algebra {a} {ℓ₁})
(B : Algebra {b} {ℓ₂})
where
infixr 1 _⟿_
record _⟿_ : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where
field
∣_∣⃗ : ∥ A ∥/≈ ↝ ∥ B ∥/≈
∣_∣-hom : Homomorphic A B (Morphism.∣_∣ ∣_∣⃗)
∣_∣ : ∥ A ∥ → ∥ B ∥
∣_∣ = Morphism.∣_∣ ∣_∣⃗
∣_∣-cong : Congruent ≈[ A ] ≈[ B ] ∣_∣
∣_∣-cong = Morphism.∣_∣-cong ∣_∣⃗
open _⟿_ public
module _ {A : Algebra {a} {ℓ₁}} where
private
∣id∣-hom : Homomorphic A A (λ x → x)
∣id∣-hom {n} f xs = A ⟦ f ⟧-cong $ reflexive (map-id xs)
where open VecSetoid ∥ A ∥/≈
open IsEquivalence (≋-isEquivalence n) using (reflexive)
id : A ⟿ A
id = record { ∣_∣⃗ = Morphism.id
; ∣_∣-hom = ∣id∣-hom
}
module _
{A : Algebra {a} {ℓ₁}}
{B : Algebra {b} {ℓ₂}}
{C : Algebra {c} {ℓ₃}}
(g : B ⟿ C)
(f : A ⟿ B)
where
private
⊙-hom : Homomorphic A C (∣ g ∣ ∘ ∣ f ∣)
⊙-hom {n} op xs = begin
C ⟦ op ⟧ (map (∣ g ∣ ∘ ∣ f ∣) xs)
≈⟨ C ⟦ op ⟧-cong $ reflexive (map-∘ ∣ g ∣ ∣ f ∣ xs) ⟩
C ⟦ op ⟧ (map ∣ g ∣ (map ∣ f ∣ xs))
≈⟨ ∣ g ∣-hom op (map ∣ f ∣ xs) ⟩
∣ g ∣ (B ⟦ op ⟧ (map ∣ f ∣ xs))
≈⟨ ∣ g ∣-cong (∣ f ∣-hom op xs) ⟩
∣ g ∣ (∣ f ∣ (A ⟦ op ⟧ xs))
∎
where open Reasoning ∥ C ∥/≈
open VecSetoid ∥ C ∥/≈
open IsEquivalence (≋-isEquivalence n) using (reflexive)
infixr 9 _⊙_
_⊙_ : A ⟿ C
_⊙_ = record { ∣_∣⃗ = ∣ g ∣⃗ · ∣ f ∣⃗
; ∣_∣-hom = ⊙-hom
}
|
src/hypro/parser/antlr4-cif/InputOutput.g4 | hypro/hypro | 22 | 1169 | <gh_stars>10-100
/*exported from CIF3 Sytax*/
grammar InputOutput;
import Expressions;
optIoDecls: ioDecls*;
ioDecls: svgFile
| svgCopy
| svgMove
| svgOut
| svgIn
| printFile
| print;
svgFile: 'svgFile' stringToken ';';
optSvgFile: ('file' stringToken)?;
svgCopy: 'svgCopy' 'id' expression optSvgCopyPre optSvgCopyPost optSvgFile ';';
optSvgCopyPre: ('pre' expression)?;
optSvgCopyPost: ('post' expression)?;
svgMove: 'svgmove' 'id' expression 'to' expression ',' expression ';'
| 'svgmove' 'id' expression 'to' expression ',' expression ':' svgFile 'end';
svgOut: 'svgout' 'id' expression svgAttr 'value' expression optSvgFile ';';
svgAttr: 'attr' stringToken
| 'text';
svgIn: 'svgin' 'id' expression 'event' svgInEvent optSvgFile ';';
svgInEvent: name
| 'if' expression ':' name optSvgInEventElifs 'else' name 'end'
| 'if' expression ':' name svgInEventElifs 'end';
optSvgInEventElifs: svgInEventElifs?;
svgInEventElifs: ('elif' expression ':' name)+;
printFile: 'printFile' stringToken ';';
print: 'print' printTxt optPrintFors optPrintWhen optPrintFile';';
printTxt: expression
| 'pre' expression
| 'post' expression
| 'pre' expression 'post' expression;
optPrintFors: ('for' printFors)?;
printFors: printFor (',' printFor)*;
printFor: 'event'
| 'time'
| name
| 'initial'
| 'final';
optPrintWhen: ( 'when' expression
| 'when' 'pre' expression
| 'when' 'post' expression
| 'when' 'pre' expression 'post' expression)?;
optPrintFile: ('file' stringToken)?;
|
data/pokemon/dex_entries/rampardos.asm | AtmaBuster/pokeplat-gen2 | 6 | 166986 | db "HEAD BUTT@" ; species name
db "Its skull can"
next "withstand impacts"
next "of any magnitude."
page "As a result, its"
next "brain never gets a"
next "chance to grow.@"
|
ffight/lcs/1p/54.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 162400 | <filename>ffight/lcs/1p/54.asm<gh_stars>1-10
copyright zengfr site:http://github.com/zengfr/romhack
00307C ext.l D0 [1p+54, boss+54, weapon+54]
00A2C6 dbra D0, $a2c0
00A32C clr.w ($54,A4)
00A330 clr.w ($56,A4)
00A97C move.w #$fa00, ($54,A6)
00A982 move.w #$48, ($56,A6) [1p+54]
00AB8A move.w #$600, ($54,A6) [1p+ E, 1p+10]
00AB90 move.w #$48, ($56,A6) [1p+54]
00AE3E move.w #$380, ($54,A6) [1p+50]
00AE44 move.w #$0, ($52,A6) [1p+54]
00AE9E move.w ($a,A6), D0
00AECA move.w #$280, ($54,A6) [1p+50]
00AED0 move.w #$0, ($52,A6) [1p+54]
00B0E6 move.w #$600, ($54,A6) [1p+50]
00B0EC move.w #$0, ($52,A6) [1p+54]
00B16E move.w #$400, ($54,A6) [1p+50]
00B174 move.w #$0, ($52,A6) [1p+54]
00B25E move.w #$600, ($54,A6) [1p+ E, 1p+10]
00B264 move.w #$55, ($56,A6) [1p+54]
00E5EE move.w #$48, ($56,A6) [1p+54]
00F3F6 move.w ($2,A0), ($54,A6) [1p+50]
00F3FC rts [1p+54]
copyright zengfr site:http://github.com/zengfr/romhack
|
proglangs-learning/Agda/sv20/assign2/Second_old2.agda | helq/old_code | 0 | 17112 | module sv20.assign2.Second_old2 where
-- ------------------------------------------------------------------------
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong)
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.Nat.Properties using (≡-decSetoid)
open import Data.List using (List; []; _∷_; _++_)
open import Relation.Binary using (Setoid; DecSetoid)
open import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩)
open import Relation.Nullary using (¬_; Dec; yes; no)
-- ℕsetoid : Setoid lzero lzero
-- ℕsetoid = record {
-- Carrier = ℕ
-- ; _≈_ = _≡_
-- ; isEquivalence = record {
-- refl = refl
-- ; sym = sym
-- ; trans = trans
-- }
-- }
-- open import Data.Product.Relation.Binary.Pointwise.NonDependent as Pointwise
-- using (Pointwise)
--
-- ℕ×ℕdecsetoid : DecSetoid lzero lzero
-- ℕ×ℕdecsetoid = record {
-- Carrier = ℕ × ℕ
-- ; _≈_ = _≡_
-- ; isDecEquivalence = record
-- { isEquivalence = record { refl = refl ; sym = sym ; trans = trans }
-- ; _≟_ = ? -- _≟_
-- }
-- }
import Data.List.Relation.Binary.Subset.Setoid as SubSetoid
open SubSetoid (DecSetoid.setoid ≡-decSetoid) using (_⊆_)
--import Data.List.Membership.Setoid
--module ListSetoid = Data.List.Membership.Setoid (ℕsetoid)
--open ListSetoid using (_∈_)
open import Data.List.Membership.DecSetoid (≡-decSetoid) using () renaming (_∈?_ to _∈ℕ?_)
--open import Data.List.Membership.DecSetoid (ℕ×ℕdecsetoid) using () renaming (_∈?_ to _∈ℕ×ℕ?_)
open import Data.List.Relation.Unary.Any using (Any; index; map; here; there)
--simple : [] ⊆ (2 ∷ [])
--simple ()
--
--simple₂ : (1 ∷ []) ⊆ (2 ∷ 1 ∷ [])
--simple₂ (here px) = there (here px)
--Look at:
-- https://agda.github.io/agda-stdlib/Data.List.Relation.Binary.Subset.Propositional.Properties.html
-- https://agda.github.io/agda-stdlib/Data.List.Relation.Binary.Subset.Setoid.html#692
-- https://agda.github.io/agda-stdlib/Relation.Binary.Structures.html#1522
--simple₃ : 1 ∈ (2 ∷ 1 ∷ [])
--simple₃ = ?
-- ⟨Set⟩ are basically lists in Athena. Which is not what a set should be but
-- the professor doesn't care about this, so I can implement this using lists
-- data relation {a b : Set} (A : ⟨Set⟩ a) (B : ⟨Set⟩ b) : ⟨Set⟩ (a × b) where
--
--relation = _×_
--
--range-theorem-2 : ∀ {a b} {A : ⟨Set⟩ a} {B : ⟨Set⟩ b}
-- (F G : ⟨Set⟩ (a × b))
-- → Range (F intersect G) ⊆ (Range F) intersect (Range G)
--
--range-theorem-2 : ∀ {a b} {A : ⟨Set⟩ a} {B : ⟨Set⟩ b}
-- (F G : ⟨Set⟩ (a × b))
-- → Range (F ∩ G) ⊆ (Range F) ∩ (Range G)
--
--dom-theorem-3 : ∀ {A B : ⟨Set⟩}
-- (F G : A × B)
-- → (Dom F) diff (Dom G) ⊆ Dom (F diff G)
--
--range-theorem-3 : ∀ {a b} {A : ⟨Set⟩ a} {B : ⟨Set⟩ b}
-- (F G : A × B)
-- → (Range F) diff (Range G) ⊆ Range (F diff G)
dom : ∀ {A B : Set} → List (A × B) → List A
dom [] = []
dom (⟨ x , _ ⟩ ∷ ls) = x ∷ dom ls
range : ∀ {A B : Set} → List (A × B) → List B
range [] = []
range (⟨ _ , y ⟩ ∷ ls) = y ∷ range ls
_∩ℕ_ : List ℕ → List ℕ → List ℕ
--_∩ : List A → List A → List A
[] ∩ℕ _ = []
--xs ∩ ys = ?
(x ∷ xs) ∩ℕ ys with x ∈ℕ? ys
... | yes _ = x ∷ (xs ∩ℕ ys)
... | no _ = xs ∩ℕ ys
--_intersectℕ×ℕ_ : List (ℕ × ℕ) → List (ℕ × ℕ) → List (ℕ × ℕ)
----_intersect_ : List A → List A → List A
--[] intersectℕ×ℕ _ = []
----xs intersect ys = ?
--(x ∷ xs) intersectℕ×ℕ ys with x ∈ℕ×ℕ? ys
--... | yes _ = x ∷ (xs intersectℕ×ℕ ys)
--... | no _ = xs intersectℕ×ℕ ys
simple-theorem : (F G : List ℕ)
→ (F ∩ℕ G) ⊆ F
simple-theorem [] _ p = p
simple-theorem (x ∷ xs) ys = ? -- NO IDEA HOW TO PROCEDE EVEN WITH THE "SIMPLEST" OF CASES
--simple-theorem (x ∷ xs) ys = ?
-- λ x xs ys x₁ → x₁ ListSetoid.∈ ((x ∷ xs) intersectℕ ys) → x₁ ListSetoid.∈ x ∷ xs}
--simple-theorem [] _ p = p
--simple-theorem (x ∷ xs) [] = ?
--simple-theorem (x ∷ xs) (y ∷ ys) = ?
-- (2 ∷ 3 ∷ 60 ∷ []) intersectℕ (1 ∷ 3 ∷ 2 ∷ [])
-- (⟨ 2 , 0 ⟩ ∷ ⟨ 3 , 2 ⟩ ∷ ⟨ 60 , 1 ⟩ ∷ []) intersectℕ (1 ∷ 3 ∷ 2 ∷ [])
--module Intersect {a ℓ} (DS : DecSetoid a ℓ) where
-- open import Data.List.Membership.DecSetoid (DS) using (_∈?_)
-- --open DecSetoid DS using (_≟_)
--
-- A = DecSetoid.Carrier DS
--
-- --_intersect_ : List ℕ → List ℕ → List ℕ
-- _intersect_ : List A → List A → List A
-- [] intersect ys = ys
-- --xs intersect ys = ?
-- (x ∷ xs) intersect ys with x ∈? ys
-- ... | yes _ = x ∷ (xs intersect ys)
-- ... | no _ = xs intersect ys
--
--
--import Data.List.Relation.Binary.Subset.Setoid as SubSetoid
--
--module Range-Theorem-2 {a ℓ} (DS₁ : DecSetoid a ℓ) (DS₂ : DecSetoid a ℓ) where
-- A = DecSetoid.Carrier DS₁
-- B = DecSetoid.Carrier DS₂
--
-- DSboth : DecSetoid a ℓ
-- DSboth = record {
-- Carrier = A × B
-- ; _≈_ = ?
-- ; isDecEquivalence = ?
-- }
--
-- open Intersect (DSboth) using (_intersect_)
-- open Intersect (DS₂) using () renaming (_intersect_ to _intersect₂_)
--
-- S₂setoid : Setoid a ℓ
-- S₂setoid = record {
-- Carrier = B
-- ; _≈_ = DecSetoid._≈_ DS₂
-- ; isEquivalence = Setoid.isEquivalence (DecSetoid.setoid DS₂)
-- }
-- open SubSetoid (S₂setoid) using (_⊆_)
--
-- range-theorem-2 : --∀ {A B : Set}
-- (F G : List (A × B))
-- --(F G : List (ℕ × ℕ))
-- → range (F intersect G) ⊆ (range F) intersect₂ (range G)
-- range-theorem-2 [] _ p = p
-- range-theorem-2 (x ∷ xs) [] = ?
-- range-theorem-2 (x ∷ xs) (y ∷ ys) = ?
--open import Data.AVL.Sets using (⟨Set⟩; empty; insert; delete)
|
Bootloader/Stage2/Filesystem.asm | Archlisk/fos2 | 0 | 13386 | %include "BIOS_Drive.asm"
[BITS 16]
struc FS_VolumeDescriptor
fsvd_signature resb 8
fsvd_version_major resb 1
fsvd_version_minor resb 1
fsvd_vol_name resb 24
fsvd_os_name resb 16
fsvd_block_size resb 4
fsvd_vol_start_lba resb 8
fsvd_vol_end_lba resb 8
fsvd_root_dir_block resb 8
FSVD_SIZE equ $
endstruc
struc FS_DirectoryDescriptor
fsdd_entries resb 4
fsdd_start_block resb 8
fsdd_next_block resb 8
FSDD_SIZE equ $
endstruc
struc FS_DirectoryEntryDescriptor
fsded_type resb 1
fsded_block resb 8
fsded_name resb 24
FSDED_SIZE equ $
FSDED_TYPE_FILE equ 0
FSDED_TYPE_DIR equ 1
endstruc
struc FS_FileDescriptor
fsfd_blocks resb 8
fsfd_start_block resb 8
fsfd_next_block resb 8
FSFD_SIZE equ $
endstruc
SECTION .data
fsvd_ptr: dw 0
fs_drive: db 0
SECTION .text
fs_load_fsvd:
mov [fsvd_ptr], ax
mov [fs_drive], dl
ret
cmp_filename:
push si
push bx
.loop:
mov al, [bx]
cmp [si], al
je .skip
cmp byte [si], '/'
jne .is_neq
cmp al, 0
jne .is_neq
.skip:
cmp byte [si], 0
je .is_eq
cmp byte [si], '/'
je .is_eq
inc bx
inc si
jmp .loop
.is_eq:
mov ax, 1
jmp .end
.is_neq:
mov ax, 0
jmp .end
.end:
pop bx
pop si
ret
len_filename:
push si
xor ax, ax
.loop:
cmp byte [si], 0
je .end
cmp byte [si], '/'
je .end
inc si
inc ax
jmp .loop
.end:
pop si
ret
fs_file_not_found_error:
print "File not found"
jmp fs_error_hlt
fs_expected_dir_error:
print "Expected a directory"
jmp fs_error_hlt
fs_expected_file_error:
print "Expected a file"
jmp fs_error_hlt
fs_error_hlt:
cli
hlt
fs_load_file:
push ebx
push cx
push si
push bp
push dx
mov dl, [fs_drive]
mov bx, [fsvd_ptr]
mov ebx, [bx + fsvd_root_dir_block]
call read_sector
.loop:
xor ebx, ebx
mov bx, ax
mov cx, [bx + fsdd_entries]
mov ebx, [bx + fsdd_start_block]
call read_sector
mov bx, ax
.cmp_loop:
cmp cx, 0
jle fs_file_not_found_error
dec cx
push ax
add bx, fsded_name
call cmp_filename
sub bx, fsded_name
cmp ax, 0
pop ax
jne .cmp_end
add bx, FSDED_SIZE
jmp .cmp_loop
.cmp_end:
push ax
call len_filename
add si, ax
pop ax
cmp byte [si], 0
je .end
mov cl, [bx + fsded_type]
cmp cl, FSDED_TYPE_DIR
jne fs_expected_dir_error
mov ebx, [bx + fsded_block]
call read_sector
inc si
jmp .loop
.end:
mov cl, [bx + fsded_type]
cmp cl, FSDED_TYPE_FILE
jne fs_expected_file_error
mov ebx, [bx + fsded_block]
call read_sector
xor ebx, ebx
mov bx, ax
mov cx, [bx + fsfd_blocks]
mov ebx, [bx + fsfd_start_block]
call read_sectors
mov ax, cx
pop dx
pop bp
pop si
pop cx
pop ebx
ret
|
add8bit.asm | suriya-1403/Assemble-language | 0 | 240396 | code segment
assume cs:code
mov ax, 0000H
mov bx, 0000H
mov al,05h
mov bl,03h
add al,bl
hlt
code ends
end |
Transynther/x86/_processed/NC/_ht_zr_un_/i9-9900K_12_0xa0.log_21829_322.asm | ljhsiun2/medusa | 9 | 100320 | <filename>Transynther/x86/_processed/NC/_ht_zr_un_/i9-9900K_12_0xa0.log_21829_322.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r15
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x60d6, %r10
cmp $22183, %rcx
mov (%r10), %rsi
nop
nop
add %rcx, %rcx
lea addresses_D_ht+0x5796, %rdx
nop
nop
nop
nop
nop
cmp %r15, %r15
vmovups (%rdx), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $0, %xmm2, %r11
and $60530, %r10
lea addresses_UC_ht+0x34d6, %rcx
sub %r15, %r15
mov $0x6162636465666768, %r11
movq %r11, %xmm7
movups %xmm7, (%rcx)
nop
nop
nop
nop
inc %r10
lea addresses_normal_ht+0x19cd6, %rsi
nop
nop
nop
and %rdi, %rdi
vmovups (%rsi), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %rdx
nop
nop
dec %rsi
lea addresses_UC_ht+0x10ae6, %r11
nop
add $54839, %r15
mov (%r11), %esi
nop
add %r15, %r15
lea addresses_WC_ht+0x2a4e, %r11
nop
nop
nop
nop
inc %rdx
movl $0x61626364, (%r11)
nop
nop
nop
add %rsi, %rsi
lea addresses_WC_ht+0x1dcd6, %rsi
lea addresses_UC_ht+0xd6, %rdi
nop
nop
nop
nop
add $9248, %r11
mov $46, %rcx
rep movsl
nop
nop
nop
nop
inc %r15
lea addresses_D_ht+0xab52, %rsi
lea addresses_normal_ht+0x7e6f, %rdi
nop
nop
sub %r11, %r11
mov $74, %rcx
rep movsl
nop
add $9216, %rcx
lea addresses_normal_ht+0x8940, %r10
nop
nop
nop
nop
nop
sub %rcx, %rcx
movb (%r10), %dl
nop
nop
inc %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r15
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r9
push %rax
push %rcx
push %rdi
push %rsi
// Store
lea addresses_A+0x6040, %r9
nop
nop
nop
nop
nop
sub $55476, %rcx
movl $0x51525354, (%r9)
nop
and %rdi, %rdi
// Store
lea addresses_UC+0x9c76, %rdi
nop
nop
add %r10, %r10
mov $0x5152535455565758, %rcx
movq %rcx, %xmm2
movups %xmm2, (%rdi)
nop
nop
nop
xor %r9, %r9
// Faulty Load
mov $0x29acdb00000000d6, %rsi
nop
nop
nop
xor %rax, %rax
vmovups (%rsi), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $0, %xmm5, %r13
lea oracles, %r10
and $0xff, %r13
shlq $12, %r13
mov (%r10,%r13,1), %r13
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': True, 'size': 2}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_A', 'AVXalign': False, 'size': 4}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_UC', 'AVXalign': False, 'size': 16}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 8}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16}}
{'src': {'NT': False, 'same': True, 'congruent': 9, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}}
{'src': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}}
{'src': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_normal_ht'}}
{'src': {'NT': True, 'same': False, 'congruent': 0, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
{'44': 262, '46': 314, '9e': 1, 'b3': 1, '00': 21246, '86': 2, 'a7': 1, 'ef': 1, '08': 1}
44 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 44 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
block-2/pp/block2/cc/ll/If.g4 | tcoenraad/compiler-construction | 1 | 2097 | <filename>block-2/pp/block2/cc/ll/If.g4<gh_stars>1-10
lexer grammar If;
@header{package pp.block2.cc.ll;}
IF : 'if' ;
THEN : 'then' ;
COND : 'cond' ;
ELSE : 'else' ;
ASSIGN : 'assign' ;
// ignore whitespace
WS : [ \t\n\r] -> skip;
// everything else is a typo
TYPO : (~(' ' | '\t' | '\n' | '\r'))+;
|
source/Cosmos.Core.DebugStub/TracerEntry.asm | Geramy/Cosmos | 207 | 18117 | ; Generated at 6/14/2016 12:11:29 PM
DebugStub_TracerEntry:
cli
Pushad
mov dword [DebugStub_PushAllPtr], ESP
mov dword [DebugStub_CallerEBP], EBP
mov dword EBP, ESP
add dword EBP, 0x20
mov dword EAX, [EBP]
add dword EBP, 0xC
mov dword [DebugStub_CallerESP], EBP
mov dword EBX, EAX
MOV EAX, DR6
and dword EAX, 0x4000
cmp dword EAX, 0x4000
JE near DebugStub_TracerEntry_Block1_End
dec dword EBX
DebugStub_TracerEntry_Block1_End:
mov dword EAX, EBX
mov dword [DebugStub_CallerEIP], EAX
Call DebugStub_Executing
Popad
sti
DebugStub_TracerEntry_Exit:
iret
|
uuu/src/cells/io/mouse/microsoft/microsoft.asm | ekscrypto/Unununium | 7 | 244763 | <reponame>ekscrypto/Unununium<filename>uuu/src/cells/io/mouse/microsoft/microsoft.asm
;====----------------------------------------------------------------------====
; Microsoft Serial Compatible Mouse Driver (c)2001 <NAME>
; MSLogitech Driver Cell Distributed under BSD License
;====----------------------------------------------------------------------====
[bits 32]
section .c_info
version: db 0,0,1,'a'
dd str_cellname
dd str_author
dd str_copyrights
str_cellname: db "Microsoft Serial Mouse Driver",0
str_author: db "<NAME> (Raptor-32) - <EMAIL>",0
str_copyrights: db "Distributed under BSD license.",0
section .c_init
mov esi, incoming_data
xor ebx, ebx
mov bl, 0x60 ;baud rate divisor for 1200baud (serial mouse)
mov bh, 0x00
xor eax, eax
mov al, 1 ;com1
mov cl, 1
;; externfunc com.enable_port TODO: BROKEN! Fix Me! DevFS enabled code!!
section .text
incoming_data:
;mouse data looks like this:
; 7 6 5 4 3 2 1 0 bits
; 0 1 LB RB Y7 Y6 X7 X6
; 0 0 X5 X4 X3 X2 X1 X0
; 0 0 Y5 Y4 Y3 Y2 Y1 Y0
;byte is in AL, start by syncing driver with mouse
movzx ebx, byte [sync]
or ebx, 0
jnz .synced
;gotta sync it
mov bl, al
and bl, 01000000b
jz near .not_first
;we have first byte, sync this puppy
mov [byte_num], byte 1
mov [sync], byte 1
.synced:
movzx ebx, byte [byte_num]
cmp ebx, 2
jb .byte1
je near .byte2
.byte3:
;once 3rd byte is in, thats when you start doing major stuff
;al already = bits 0-5 of Y increment
mov [byte_num], byte 1
cmp dword [client], -1
je .get_out
mov bh, [byte_2] ;bh = bits 0-5 of X increment
mov bl, [byte_1] ;we have buttons already, so all we need to worry about is:
;- bits 6,7 for bits 6 and 7 of Y increment
;- bits 4, 5 for bits 6 and 7 of X increment
;mouse data looks like this:
; 7 6 5 4 3 2 1 0 bits
; 0 1 LB RB Y7 Y6 X7 X6 bl
; 0 0 X5 X4 X3 X2 X1 X0 bh
; 0 0 Y5 Y4 Y3 Y2 Y1 Y0 al
;we will use ah for X and bl for Y
mov ah, bl ;carbon copy of byte 1
and ah, 00000011b
shl ah, 6
or ah, bh
; now AH is X
and bl, 00001100b
shl bl, 4
or bl, al
; now BL is Y
movsx ecx, bl
movsx ebx, al
xor edx, edx
movzx eax, byte [right_button]
rol al, 1
and al, [left_button]
call [client]
.get_out:
retn
.byte1:
mov [byte_1], al
;set the buttons so we can ignore that later
mov bl, al ;check if it really is byte 1
and bl, 01000000b
jz .not_synced
mov bl, al
mov cl, al
and bl, 00100000b
;shr bl, 5
rol bl, 3
mov [left_button], byte bl
and cl, 00010000b
shr cl, 4
mov [right_button], cl
inc byte [byte_num]
retn
.not_synced:
mov [byte_num], byte 0
mov [sync], byte 0
retn
.byte2:
mov [byte_2], al
mov [byte_num], byte 3
.not_first:
retn
;===----[VARIABLES]-----===
right_button: db 0
left_button: db 0
byte_num: db 0
sync: db 0
byte_1: db 0
byte_2: db 0
byte_3: db 0
client: dd -1
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2541.asm | ljhsiun2/medusa | 9 | 81099 | <filename>Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2541.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r12
push %r13
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x15a71, %rsi
lea addresses_A_ht+0x2551, %rdi
nop
and %r10, %r10
mov $124, %rcx
rep movsb
nop
nop
cmp $51314, %rax
lea addresses_normal_ht+0xb2f1, %rsi
lea addresses_A_ht+0x8ae9, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
cmp %r13, %r13
mov $83, %rcx
rep movsb
nop
nop
cmp $34723, %r13
lea addresses_A_ht+0x18f91, %r13
nop
nop
nop
nop
xor $26559, %rdi
mov $0x6162636465666768, %rcx
movq %rcx, %xmm2
movups %xmm2, (%r13)
nop
dec %r13
lea addresses_A_ht+0x182b9, %rdi
nop
nop
nop
nop
nop
xor $58123, %r12
mov (%rdi), %ecx
nop
nop
xor %r13, %r13
lea addresses_D_ht+0x18671, %rsi
lea addresses_WT_ht+0x175f, %rdi
nop
nop
nop
nop
nop
add %r11, %r11
mov $87, %rcx
rep movsw
dec %rax
lea addresses_D_ht+0x17521, %r12
cmp $41598, %r10
movb (%r12), %al
nop
cmp $19012, %r11
lea addresses_D_ht+0x16fb1, %r12
nop
nop
nop
nop
cmp %rsi, %rsi
movl $0x61626364, (%r12)
nop
nop
nop
nop
sub $28241, %r12
lea addresses_UC_ht+0x10d71, %r12
nop
nop
nop
nop
nop
sub %rdi, %rdi
mov (%r12), %r13
add %r13, %r13
lea addresses_WT_ht+0x93b1, %r11
nop
nop
and %rax, %rax
movl $0x61626364, (%r11)
nop
nop
xor $9917, %r11
lea addresses_normal_ht+0x1b371, %rsi
lea addresses_WT_ht+0x6ff1, %rdi
nop
nop
inc %r10
mov $9, %rcx
rep movsw
nop
nop
nop
and $23177, %r12
lea addresses_WT_ht+0xdb9e, %r11
nop
inc %rdi
and $0xffffffffffffffc0, %r11
movaps (%r11), %xmm4
vpextrq $0, %xmm4, %r12
nop
nop
add $919, %r13
lea addresses_UC_ht+0xd4a1, %rsi
lea addresses_A_ht+0x1053d, %rdi
nop
nop
nop
nop
nop
and %r13, %r13
mov $52, %rcx
rep movsq
cmp $472, %rdi
lea addresses_WC_ht+0x1aec1, %r10
nop
nop
and %r12, %r12
mov (%r10), %edi
nop
sub %r10, %r10
lea addresses_UC_ht+0x1271, %rcx
nop
and %r13, %r13
movw $0x6162, (%rcx)
nop
nop
nop
nop
nop
cmp $63540, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r13
pop %r12
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r15
push %rax
push %rdx
// Faulty Load
lea addresses_WT+0xe771, %r13
nop
nop
nop
nop
cmp %rdx, %rdx
mov (%r13), %r10w
lea oracles, %r13
and $0xff, %r10
shlq $12, %r10
mov (%r13,%r10,1), %r10
pop %rdx
pop %rax
pop %r15
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WT', 'same': False, 'size': 32, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_WT', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A_ht', 'same': True, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 4, 'congruent': 3, 'NT': True, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 4, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
oeis/054/A054877.asm | neoneye/loda-programs | 11 | 241168 | ; A054877: Closed walks of length n along the edges of a pentagon based at a vertex.
; Submitted by <NAME>
; 1,0,2,0,6,2,20,14,70,72,254,330,948,1430,3614,6008,13990,24786,54740,101118,215766,409640,854702,1652090,3396916,6643782,13530350,26667864,53971350,106914242,215492564,428292590,860941798,1714834440,3441074654,6863694378,13757249460,27466183286,55010542910,109894593848,219993856006,439656551730,879848932052,1758830875230,3519064567926,7035859329512,14075391282830,28144840135514,56299295324980,112583033165862,225191238869774,450341747717400,900749397994998,1801392163407650,3602956861957844
mov $1,-1
mov $3,1
lpb $0
sub $0,1
add $1,$3
mul $3,2
mov $2,$3
mov $3,$4
mov $4,$1
add $4,$2
lpe
mov $0,$3
|
notes/FOT/FOTC/Data/Nat/AddPartialRightIdentity.agda | asr/fotc | 11 | 203 | ------------------------------------------------------------------------------
-- Reasoning partially about functions
------------------------------------------------------------------------------
{-# OPTIONS --allow-unsolved-metas #-}
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- We cannot reasoning partially about partial functions intended to
-- operate in total values.
module FOT.FOTC.Data.Nat.AddPartialRightIdentity where
open import FOTC.Base
open import FOTC.Data.Nat
------------------------------------------------------------------------------
-- How proceed?
+-partialRightIdentity : ∀ n → n + zero ≡ n
+-partialRightIdentity n = {!!}
|
copper/copper_asm/jump-example.asm | dcliche/Xosera | 24 | 178168 | <gh_stars>10-100
; A slightly less basic example of using copper assembler, including
; skip and jmp instructions. In this example, instead of waiting for
; specific line positions, we use conditional logic and direct jumps
; to decide what color to set.
;
; Copyright (c) 2021 <NAME> - https://github.com/roscopeco
;
; See top-level LICENSE file for license information. (Hint: MIT)
#include "copper.casm"
copperlist:
skip 0, 160, 0b00010 ; Skip next if we've hit line 160
jmp .gored ; ... else, jump to set red
skip 0, 320, 0b00010 ; Skip next if we've hit line 320
jmp .gogreen ; ... else jump to set green
; If here, we're above 320, so set blue
movep 0x0, 0x000F ; Make background blue
movep 0xA, 0x0004 ; Make foreground dark blue
nextf ; And we're done for this frame
.gogreen:
movep 0x0, 0x00F0 ; Make background green
movep 0xA, 0x0040 ; Make foreground dark green
jmp copperlist ; and restart
.gored:
movep 0x0, 0x0F00 ; Make background red
movep 0xA, 0x0400 ; Make foreground dark red
jmp copperlist ; and restart
|
tests/polymorphism/src/generic_sensor.ads | TUM-EI-RCS/StratoX | 12 | 6846 | <reponame>TUM-EI-RCS/StratoX<gh_stars>10-100
-- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: <NAME> (<EMAIL>)
-- <NAME> (<EMAIL>)
-- with Ada.Real_Time;
with Generic_Signal;
-- those are required for LSP
with MS5611.Driver;
with ublox8.Driver;
with MPU6000.Driver;
with HMC5883L.Driver;
-- @summary Generic sensor template. No dispatching here!
-- FIXME: for the sake of polymorphism, dispatching should
-- be added some day.
generic
type Data_Type is private;
package Generic_Sensor with SPARK_Mode
--,Abstract_State => Sensor_State -- implementations may have a state
is
package Sensor_Signal is new Generic_Signal( Data_Type );
subtype Sample_Type is Sensor_Signal.Sample_Type;
type Sensor_State_Type is (UNINITIALIZED, OFF, READY, MEASURING, NEW_DATA, ERROR) with Default_Value => UNINITIALIZED;
type State_Type is record
Initialized : Boolean := False;
Active : Boolean := False;
Busy : Boolean := False;
Error : Boolean := False;
end record;
-- null procedures don't make sense here. It is legal to not override them,
-- which makes it pointless defining them in an abstract type.
-- however, SPARK refuses to specify the Global aspect for abstract procedures,
-- unlike for null procedures. So we go for null again...
type Sensor_Tag is abstract tagged record
state : Sensor_State_Type; -- to be set by sensor
sample : Sample_Type; -- sensor-specific, most recent measurement
end record;
-- procedure initialize(Self : in out Sensor_Tag) is null with Global => (Output => (MS5611.Driver.Coefficients, MS5611.Driver.State));
-- In_Out => ( Ada.Real_Time.Clock_Time,
-- MS5611.Driver.State, ublox8.Driver.State, MPU6000.Driver.State, HMC5883L.Driver.State));
--
-- trigger start of the measurement
--procedure start_Measurement(Self : in out Sensor_Tag) is abstract;
-- read the result from the sensor, possibly includes some pre-processing
--procedure read_Measurement(Self : in out Sensor_Tag) is abstract;
--with Global => (In_Out => Sensor_State);
-- with Global => (In_Out => (MS5611.Driver.State, MS5611.Driver.Coefficients, MPU6000.Driver.State, ublox8.Driver.State, HMC5883L.Driver.State));
-- procedure tick(Self : in out Sensor_Tag) is abstract; -- !!NULL!!
-- update state, wait for finished conversion
function new_Sample(Self : in Sensor_Tag) return Boolean is
( Self.state = NEW_DATA );
-- check whether we have a new sample
function get_Sample(Self : in Sensor_Tag) return Sample_Type is
( Self.sample );
-- get new sample
--function get_State(Self : Sensor_Tag) return Sensor_State_Type;
end Generic_Sensor;
|
py2.asm | lestersantos/Assembly2019 | 0 | 86315 | ;UNIVERSIDAD DE <NAME>
;FACULTAD DE INGENIERIA
;ARQUITECTURA DE COMPUTADORAS Y ENSAMBLADORES 1
;PROYECTO
;<NAME>
;201504510
ORG 100h
;--------------- MY MACROS --------------------
%macro print 1 ;this macro will print to screen
push ax
push dx
mov dx, %1 ;refers to the first parameter to the macro call
mov ah, 09h ;09h function write string
int 21h ;call the interruption
pop dx
pop ax
%endmacro
%macro printAt 3 ;PRINT A CHAR AT ROW,COL IN TEXT MODE 03H
; cursor x, cursor y , string
; column , line , data to write
push ax
push bx
push dx
mov bh,00h ;Video page
mov dh,%2 ;set cursor line/row/y
mov dl,%1 ;set cursor column/col/x
mov ah,02h
int 10h
mov dx, %3 ;offset addres of string
mov ah, 09h ;request write string
int 21h ;call interruption
pop dx
pop bx
pop ax
%endmacro
%macro printChar 1 ;this macro will print to screen
push ax
push dx
mov dl,%1 ;refers to the first parameter to the macro call
mov ah, 06h ;09h function write string
int 21h ;call the interruption
pop dx
pop ax
%endmacro
%macro printChar2 1 ;this macro will print to screen
push ax
push dx
push bx
push cx
mov bx,1
mov cx,1
mov dx, %1 ;refers to the first parameter to the macro call
mov ah, 40h ;40h function write
int 21h ;call the interruption
pop cx
pop bx
pop dx
pop ax
%endmacro
%macro readInputChar 0
mov ah, 01h ;Return AL with the ASCII of the read char
int 21h ;call the interruption
%endmacro
;|- - - - - - - - - - - - - FILE FUNCTIONS - - - - - - - - - - - - - - - - - - - - - - - - - - -
%macro CreateFile 1
;%1 ASCIZ filename
mov cx,00h ;file attribute 00h = normal file or maybe read only
mov dx,%1 ;dx = ASCIZ filename
mov ah,3ch ;request create file
int 21h
%endmacro
%macro openFile 1
;%1 ASCIZ filename
mov al, 0h ;access mode (000b = 0h only read)
mov dx, %1 ;offset of ascii file name
mov ah, 3dh ;request open File interruption
int 21h ;call interruption 21h
%endmacro
%macro openWriteFile 1
;%1 ASCIZ filename
mov al, 02h ;access mode (000b = 0h only read)
mov dx, %1 ;offset of ascii file name
mov ah, 3dh ;request open File interruption
int 21h ;call interruption 21h
%endmacro
%macro readFile 2
;%1 Handle from open File, %2 Buffer to store data
mov bx, %1 ;handle
mov cx, 400h ;bytes to read UPDATE: may give an error
;if smaller than the bytes in the input file
mov dx, %2 ;buffer
mov ah, 3fh ;request reading interruption
int 21h
%endmacro
%macro closeFile 1
;%1 Handle of file to get close
;mov bh,[%1] ;copy the high order(8 bits more significant)of handle
;mov bl,[%1+1] ;copy the low order(8 bits less significant)of handle
mov bx, %1
mov ah,3eh ;request close file interruption
int 21h ;call 21h interruption
%endmacro
%macro writeInFile 3
;macro to write in the file
;parameters: %1 data to write, %2 handle, %3 num bytes to write
;mov bh,[%2] ;copy the high order(8 bits more significant)of handle
;mov bl,[%2+1] ;copy the low order(8 bits less significant)of handle
;push ax
;push bx
;push cx
;push dx
mov bx,%2 ;Handle
mov cx,%3 ;copy num of bytes to write
mov dx,%1 ;copy the data to write
mov ah,40h ;request write to file interruption
int 21h ;call interruption
;pop dx
;pop cx
;pop bx
;pop ax
%endmacro
;------------------ GRAPHIC FUNCTIONS -------------------------------------------
%macro setVideoMode 1
mov ah,00h
mov al,%1
int 10h
%endmacro
%macro plotPixel 3
;%1 color, %2 x ,%3 y
;x = x axis Plane (max 320 pixels) ______ x
;y = y axi Planes (max 200 pixels)|
; y|
push ax
push di
push bx
;lexical maph..
;P(x,y) = x + y(320)
mov ax,%3 ;ax = %3 = Y (coordinate)
mov bx, 320 ;140h = 320 decimal
mul bx ;ax*bx = y*320
;dx ax = result
mov bx,%2 ;bx = x
add ax,bx ;ax = x + y*320
mov di,ax
mov es,word[vgaStartAddr] ;es ->extra segment =0a000h
mov ax,%1 ;color of the pixel
mov [es:di],ax
pop bx
pop di
pop ax
%endmacro
%macro pixel 3
push ax
push bx
push dx
push di
mov ax, %3
mov bx, 140h
mul bx
add ax, %2
mov di, ax
mov es, word[vgaStartAddr]
mov ax, %1
mov[es:di], ax
pop di
pop dx
pop bx
pop ax
%endmacro
%macro DrawArea 5 ;DRAW AN AREA IN VIDEO MODE 13H
;%1 , %2 , %3 , %4 , %5
;x,width,y,height,color
; x , y , width , height , color
;di , si , , %5
push ax
push bx
push si
push di
mov si,%3 ;y coordinate
mov bx,si ;di = Yindex starting at = y
add bx,%4 ;bx = Yend = Ystart + height
mov di,%1 ; di = x coordinate
mov ax,di ; ax = x
add ax,%2 ; ax = Xend = Xstart + width
%%Height: ;Y coordinate
push di
cmp si,bx ;si = height ? -> Yindex = Yend ?
je %%EndHeight
%%Width: ;X coordinate
cmp di,ax ;si = width ? -> Xindex = Xend ?
je %%EndWidth
; plotPixel %1 color, %2 x ,%3 y
plotPixel %5,di,si
inc di ;x = x + 1
jmp %%Width
%%EndWidth:
inc si ;y = y + 1
pop di
jmp %%Height
%%EndHeight:
pop di
pop si
pop bx
pop ax
%endmacro
%macro PrintArray 1 ;DRAW AN AREA IN VIDEO MODE 13H
;%1 ,
; bitArray
; x , y ,
;di , si
push ax
push bx
push si
push di
mov si,0h ;y coordinate
mov bx,00h ;di = Yindex starting at = y
add bx,05h ;bx = Yend = Ystart + height
mov di,0h ; di = x coordinate
mov ax,0h ; ax = x
add ax,04h ; ax = Xend = Xstart + width
%%Height: ;si = Y coordinate
push di
cmp si,bx ;si = height ? -> Yindex = Yend ?
je %%EndHeight
%%Width: ;di = X coordinate
cmp di,ax ;si = width ? -> Xindex = Xend ?
je %%EndWidth
;LEXICAL MAP for matrix 5*4 -> vector 20 positions
;P(x,y) = x + y(4)
push ax
push bx
push di
mov ax,si ;ax = si = Y (coordinate)
mov bx,4 ;04h = 4 decimal
mul bx ;ax*bx = y*4
;dx ax = result
mov bx,di ;bx = x = di
add ax,bx ;ax = x + y*4
mov di,ax
mov al,[%1+di]
cmp al,01h
jne %%PaintBlack
printChar 01h
jmp %%End
%%PaintBlack:
printChar 0h
;printChar al
%%End:
pop di
pop bx
pop ax
;push ax
;printChar 49
;pop ax
inc di ;x = x + 1
jmp %%Width
%%EndWidth:
inc si ;y = y + 1
pop di
jmp %%Height
%%EndHeight:
pop di
pop si
pop bx
pop ax
%endmacro
%macro DrawChar 3
;DrawChar bitArray,row,column
; %1 , %2, %3
; di = x, si = y
; x , y ,
;di , si
;push ax
;push bx
;push si
;push di
mov si,0h ;y coordinate
mov bx,00h ;di = Yindex starting at = y
add bx,05h ;bx = Yend = Ystart + height
mov di,0h ; di = x coordinate
mov ax,0h ; ax = x
add ax,04h ; ax = Xend = Xstart + width
%%Height: ;si = Y coordinate
push di
;print newline
mov [indexI],si
;printChar [indexI]
cmp si,bx ;si = height ? -> Yindex = Yend ?
je %%EndHeight
;printChar [indexI]
%%Width: ;di = X coordinate
mov [indexJ],di
cmp di,ax ;si = width ? -> Xindex = Xend ?
je %%EndWidth
;printChar [indexJ]
;LEXICAL MAP for matrix 5*4 -> vector 20 positions
;P(x,y) = x + y(4)
push ax
push bx
push di
push si
mov ax,si ;ax = si = Y (coordinate)
mov bx,4 ;04h = 4 decimal
mul bx ;ax*bx = y*4
;dx ax = result
mov bx,di ;bx = x = di
add ax,bx ;ax = x + y*4
mov di,ax
mov al,[%1+di]
cmp al,01h
jne %%PaintBlack
mov ax,%2 ;ax = row
mov bx,5 ;bx = 5
mul bx ;ax = ax*bx = row*5
mov si,ax
mov bx,0h
mov bl,[indexI]
add si,bx
mov ax,%3 ;ax = col
mov bx,4 ;bx = 4
mul bx ;ax = ax*bx = col*4
mov di,ax
mov bx,0h
mov bl,[indexJ]
add di,bx
;printChar 01h
; plotPixel %1 color, %2 x ,%3 y
plotPixel 15,di,si
jmp %%End
%%PaintBlack:
mov ax,%2 ;ax = row
mov bx,5 ;bx = 5
mul bx ;ax = ax*bx = row*5
mov si,ax
mov bx,0h
mov bl,[indexI]
add si,bx
mov ax,%3 ;ax = col
mov bx,4 ;bx = 4
mul bx ;ax = ax*bx = col*4
mov di,ax
mov bx,0h
mov bl,[indexJ]
add di,bx
;printChar 01h
; plotPixel %1 color, %2 x ,%3 y
plotPixel 104,di,si
;printChar 0h
;printChar al
%%End:
pop si
pop di
pop bx
pop ax
inc di ;x = x + 1
jmp %%Width
%%EndWidth:
inc si ;y = y + 1
pop di
jmp %%Height
%%EndHeight:
;pop di
;pop si
;pop bx
;pop ax
%endmacro
%macro PlotChar 3
; row, column,
; %1 , %2 , %3
;push ax
mov al,%3
%%SearchChar:
cmp al,41h
je %%lA
cmp al,42h
je %%lB
cmp al,43h
je %%lC
cmp al,44h
je %%lD
cmp al,45h
je %%lE
cmp al,46h
je %%lF
cmp al,47h
je %%lG
cmp al,48h
je %%lH
cmp al,49h
je %%lI
cmp al,4ah
je %%lJ
cmp al,4bh
je %%lK
cmp al,4ch
je %%lL
cmp al,4dh
je %%lM
cmp al,4eh
je %%lN
cmp al,4fh
je %%lO
cmp al,50h
je %%lP
cmp al,51h
je %%lQ
cmp al,52h
je %%lR
cmp al,53h
je %%lS
cmp al,54h
je %%lT
cmp al,55h
je %%lU
cmp al,56h
je %%lV
cmp al,57h
je %%lW
cmp al,58h
je %%lX
cmp al,59h
je %%lY
cmp al,5ah
je %%lZ
cmp al,30h
je %%cero
cmp al,31h
je %%uno
cmp al,32h
je %%dos
cmp al,33h
je %%tres
cmp al,34h
je %%cuatro
cmp al,35h
je %%cinco
cmp al,36h
je %%seis
cmp al,37h
je %%siete
cmp al,38h
je %%ocho
cmp al,39h
je %%nueve
cmp al,3ah
je %%dospuntos
jmp %%End
%%lA:
DrawChar A,%1,%2
jmp %%End
%%lB:
DrawChar B,%1,%2
jmp %%End
%%lC:
DrawChar C,%1,%2
jmp %%End
%%lD:
DrawChar D,%1,%2
jmp %%End
%%lE:
DrawChar E,%1,%2
jmp %%End
%%lF:
DrawChar F,%1,%2
jmp %%End
%%lG:
DrawChar G,%1,%2
jmp %%End
%%lH:
DrawChar H,%1,%2
jmp %%End
%%lI:
DrawChar I,%1,%2
jmp %%End
%%lJ:
DrawChar J,%1,%2
jmp %%End
%%lK:
DrawChar K,%1,%2
jmp %%End
%%lL:
DrawChar L,%1,%2
jmp %%End
%%lM:
DrawChar M,%1,%2
jmp %%End
%%lN:
DrawChar N,%1,%2
jmp %%End
%%lO:
DrawChar O,%1,%2
jmp %%End
%%lP:
DrawChar P,%1,%2
jmp %%End
%%lQ:
DrawChar Q,%1,%2
jmp %%End
%%lR:
DrawChar R,%1,%2
jmp %%End
%%lS:
DrawChar S,%1,%2
jmp %%End
%%lT:
DrawChar T,%1,%2
jmp %%End
%%lU:
DrawChar U,%1,%2
jmp %%End
%%lV:
DrawChar V,%1,%2
jmp %%End
%%lW:
DrawChar W,%1,%2
jmp %%End
%%lX:
DrawChar X,%1,%2
jmp %%End
%%lY:
DrawChar Y,%1,%2
jmp %%End
%%lZ:
DrawChar Z,%1,%2
jmp %%End
%%cero:
DrawChar ZERO,%1,%2
jmp %%End
%%uno:
DrawChar ONE,%1,%2
jmp %%End
%%dos:
DrawChar TWO,%1,%2
jmp %%End
%%tres:
DrawChar THREE,%1,%2
jmp %%End
%%cuatro:
DrawChar FOUR,%1,%2
jmp %%End
%%cinco:
DrawChar FIVE,%1,%2
jmp %%End
%%seis:
DrawChar SIX,%1,%2
jmp %%End
%%siete:
DrawChar SEVEN,%1,%2
jmp %%End
%%ocho:
DrawChar EIGHT,%1,%2
jmp %%End
%%nueve:
DrawChar NINE,%1,%2
jmp %%End
%%dospuntos:
DrawChar COLON,%1,%2
jmp %%End
%%End:
;pop ax
%endmacro
%macro pixelarea 5
push ax
push bx
push si
push di
mov si, %2
mov bx, si
add bx, %3
%%x:
cmp si, bx
je %%finx
mov di, %4
mov ax, di
add ax, %5
%%y:
cmp di, ax
je %%finy
pixel %1, si, di
inc di
jmp %%y
%%finy:
inc si
jmp %%x
%%finx:
pop si
pop di
pop bx
pop ax
%endmacro
%macro DecToAscii 1
;DecToAscii DecNumberToConvert
push ax
push bx
push dx
mov ax,%1
cmp ax,0ah ;ax < 10 (One Digit Number)
jl %%OneDigit
cmp ax,63h ;ax > 99 (Three Digit Number)
jg %%ThreeDigit
;if not the number is a two digit number
%%TwoDigit:
xor bx,bx
xor dx,dx
mov bh,0ah ; bh = 10 (Divisor)
div bh ; ax / bh = al(quotient) ah(remainder)
add al,30h
add ah,30h
mov [numberBf],al
mov [numberBf+1],ah
mov al,'$'
mov [numberBf+2],al
jmp %%End
%%OneDigit:
add ax,30h
mov [numberBf],al
mov ah,'$'
mov [numberBf+1],ah
jmp %%End
%%ThreeDigit:
xor dx,dx
mov bx,64h
div bx
add al,30h
mov [numberBf],al
mov ax,dx
xor dx,dx
mov bx,0ah
div bx
add ax,30h
mov [numberBf+1],ax
add dx,30h
mov [numberBf+2],dx
mov bx,'$'
mov [numberBf+3],bx
%%End:
pop dx
pop bx
pop ax
%endmacro
%macro print_car 1
push ax
push cx
xor cx, cx;
mov cl, %1;
; pixlearea color,x,ancho,y,alto
pixelarea 0h, cx, 5, 140, 35 ;Contorno iz
add cl, 5
pixelarea 0h, cx, 5, 140, 35 ;contorno iz
pixelarea 7h, cx, 5, 145, 8 ;llanta superior iz
pixelarea 7h, cx, 5, 161, 8 ;llanta inferior iz
add cl, 5
pixelarea 01h, cx, 20,140, 35 ;carro
add cl, 20
pixelarea 0h, cx, 5, 140, 35 ;contorno derecho
pixelarea 7h, cx, 5, 145, 8 ;llanta superior der
pixelarea 7h, cx, 5, 161, 8 ;llanta inferior der
add cl, 5
pixelarea 0h, cx, 5, 140, 35 ;contorno derecho
pop cx
pop ax
%endmacro
%macro print_Obstacle 2
push ax
push cx
xor cx, cx;
xor dx,dx
mov cl, %1;
mov dl, %2
; pixlearea color,x,ancho,y,alto
pixelarea 0, cx, 5, dx, 25 ;Contorno iz
;---outside star---
add dx,10
pixelarea 14, cx, 5,dx, 5 ;middel rectangel H
add cl,5
sub dx,10
pixelarea 0, cx, 5, dx, 25 ;Contorno iz
add dx,5
pixelarea 14, cx, 5,dx,15 ;left rectangle V
add dx,5
pixelarea 43, cx, 5,dx,5 ;middle rectangle H
add cl,5
sub dx, 10
pixelarea 0, cx, 5, dx, 25 ;Contorno medio
pixelarea 14, cx, 5, dx,25 ;middle rectangle V
add dx,5
pixelarea 43, cx,5,dx,15 ;middle rectangle V
add cl,5
sub dx,5
pixelarea 0, cx, 5, dx, 25 ;Contorno der
add dx,5
pixelarea 14, cx, 5, dx, 15 ;right rectangle V
add dx,5
pixelarea 43, cx, 5,dx,5 ;middle rectangle H
add cl,5
sub dx,10
pixelarea 0, cx, 5, dx, 25 ;Contorno der
add dx,10
pixelarea 14, cx, 5, dx, 5 ;middel rectangel H
pop cx
pop ax
%endmacro
%macro print_Obstacle2 2
push ax
push cx
xor cx, cx;
xor dx,dx
mov cl, %1;
mov dl, %2
; pixlearea color,x,ancho,y,alto
pixelarea 0, cx, 5, dx, 25 ;Contorno iz
;---outside star---
add dx,10
pixelarea 02, cx, 5,dx, 5 ;middel rectangel H
add cl,5
sub dx,10
pixelarea 0, cx, 5, dx, 25 ;Contorno iz
add dx,5
pixelarea 02, cx, 5,dx,15 ;left rectangle V
add dx,5
pixelarea 45, cx, 5,dx,5 ;middle rectangle H
add cl,5
sub dx, 10
pixelarea 0, cx, 5, dx, 25 ;Contorno medio
pixelarea 02, cx, 5, dx,25 ;middle rectangle V
add dx,5
pixelarea 45, cx,5,dx,15 ;middle rectangle V
add cl,5
sub dx,5
pixelarea 0, cx, 5, dx, 25 ;Contorno der
add dx,5
pixelarea 02, cx, 5, dx, 15 ;right rectangle V
add dx,5
pixelarea 45, cx, 5,dx,5 ;middle rectangle H
add cl,5
sub dx,10
pixelarea 0, cx, 5, dx, 25 ;Contorno der
add dx,10
pixelarea 02, cx, 5, dx, 5 ;middel rectangel H
pop cx
pop ax
%endmacro
%macro sleep 1
push si
mov si, %1
%%b1:
dec si
jnz %%b1
pop si
%endmacro
%macro PreOrder 0
;------------------ DO OPERATIONES IN PREORDER AND SAVE RESULT--------------------
push ax
push bx
push cx
push dx
push si
push di
push bp
mov al,0h
mov [counter],al
mov [indexOp],al
mov [indexNum],al
xor si,si ;clean si
xor di,di ;clean di
xor bp,bp ;clean bp
xor ax,ax ;clean ax
%%Operation:
mov ah,[operationsBf+si] ;ah = number/operator
;printChar ah
cmp ah,3bh
je %%LastCheck
mov al,[operators]
cmp ah,al
je %%StackOperator
mov al,[operators+1]
cmp ah,al
je %%StackOperator
mov al,[operators+2]
cmp ah,al
je %%StackOperator
mov al,[operators+3]
cmp ah,al
je %%StackOperator
cmp ah,39h
jg %%Operation
cmp ah,30h
jl %%Operation
%%StackNumber:
;printChar ah
mov al,ah
xor ah,ah
sub al,30h
mov [numStack+bp],ah
mov [numStack+bp+1],al
mov al,'$'
mov [numStack+bp+2],al
add bp,02h
mov al,[counter]
inc al
mov [counter],al
inc si
mov al,[counter]
cmp al,2 ;Two numbers counted send To Operation
je %%DoOperation
jmp %%Operation
%%DoOperation:
mov aL,[numStack+bp-3]
mov ah,[numStack+bp-4]
mov bl,[numStack+bp-1]
mov bh,[numStack+bp-2]
mov cl,[opStack+di-1]
cmp cl,2ah ;cl = * (2ah)
je %%Multiply
cmp cl,2fh ;cl = / (2fh)
je %%Division
cmp cl,2bh ;cl = + (2bh)
je %%Sum
cmp cl,2dh ;cl = - (2dh)
je %%Subtract
%%Multiply:
mul bx
sub bp,4
mov [numStack+bp],ah
mov [numStack+bp+1],al
mov al,'$'
mov [numStack+bp+2],al
add bp,02h
dec di
mov al,'$'
mov [opStack+di],al
mov al,[counter]
dec al
mov [counter],al
jmp %%End
%%Division:
xor dx,dx
div bx
sub bp,4
mov [numStack+bp],ah
mov [numStack+bp+1],al
mov al,'$'
mov [numStack+bp+2],al
add bp,02h
dec di
mov al,'$'
mov [opStack+di],al
mov al,[counter]
dec al
mov [counter],al
jmp %%End
%%Sum:
add ax,bx
sub bp,4
mov [numStack+bp],ah
mov [numStack+bp+1],al
mov al,'$'
mov [numStack+bp+2],al
add bp,02h
dec di
mov al,'$'
mov [opStack+di],al
mov al,[counter]
dec al
mov [counter],al
jmp %%End
%%Subtract:
sub ax,bx
sub bp,4
mov [numStack+bp],ah
mov [numStack+bp+1],al
mov al,'$'
mov [numStack+bp+2],al
add bp,02h
dec di
mov al,'$'
mov [opStack+di],al
mov al,[counter]
dec al
mov [counter],al
jmp %%End
%%LastCheck:
cmp bp,03h
jg %%DoOperation
jmp %%PrintResult
%%StackOperator:
;printChar ah
mov [opStack+di],ah
mov al,'$'
mov [opStack+di+1],al
inc di
mov al,0
mov [counter],al
inc si
jmp %%Operation
%%End:
mov al,[counter]
cmp al,0h
jg %%Operation
%%PrintResult:
mov al,[numStack+1]
mov ah,[numStack]
mov [resultBf],ah
mov [resultBf+1],al
;print newline
DecToAscii ax
;print numberBf
;print newline
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
;------------------------------------ END PREORDER OPERATIONS---------------------------
%endmacro
%macro CopyResult 2
;CopyResult bf, bfToCopy
mov al,[%2]
mov [%1],al
mov al,[%2+1]
mov [%1+1],al
mov al,[%2+2]
mov [%1+2],al
mov al,[%2+3]
mov [%1+3],al
mov al,'$'
mov [%1+4],al
%endmacro
global Main
;========================== SECTION .TEXT ======================================================|
;MY CODE GOES HERE. If I left a blank line
;between this line and "segment .text" gives error |
segment .text
;Program Start
Main:
print mainMenu
print newline
print optionLabel
.readOption:
readInputChar
cmp al, 49
je Option1 ;Log In (1)
cmp al, 50
je Option2 ;Sing up (2)
cmp al, 51
je Option3 ;Exit (3)
cmp al, 52
je Option4 ;Debuggin (4)
jmp Main
AdminMenu: ;-------------------- ADMIN MENU ---------
print adminMenu
print newline
print optionLabel
.readOption:
readInputChar
cmp al, 49
je .Option1 ;Top 10 Puntos (1)
cmp al, 50
je Main ;Salir Y Menu Principal (2)
jmp Main
.Option1: ;-----> CREATE TOP 10 FILE
call ClearScreen
; printAt column, line, string
printAt 24 ,1 ,topTenLb
;------------ CREATE FILE --------------
;CreateFile reportPathFile
;jc .errorCreateFile
;------------- CLOSE FILE ---------------
;closeFile ax
;jc .errorCloseFile
;print createFileMsg
;------------- OPEN FILE ----------------
; openFile ASCIZ_file_name
openFile reportPathFile
jc .errorOpenFile
print openFileMsg
;------------- READ FILE ----------------
; readFile Handle, BufferToStoreData
readFile ax, fileReadBf
jc .errorReadFile
print readFileMsg
;------------- CLOSE FILE ---------------
closeFile bx
jc .errorCloseFile
print fileReadBf
jmp AdminMenu
.errorCreateFile:
print errCreateFileMsg
jmp Main
.errorOpenFile:
print errOpenMsg
jmp Main
.errorReadFile:
print errReadFileMsg
jmp Main
.errorCloseFile:
print errCloseFileMsg
jmp Main
UserMenu: ;--------------- MENU DE USUARIOS --------------
print headerLabel
print userMenu
print newline
print optionLabel
.readOption:
readInputChar
cmp al, 49
je .Option1 ;Cargar Archivo (1) also file with results created
cmp al, 50
je .Option2 ;Jugar (2)
cmp al, 51
je Main ;Exit (3)
cmp al,52
je .Option3 ;Crear Archivo Configuraciones
jmp Main
.Option1: ;-------------------CARGAR ARCHIVO-----------
call ClearScreen
; printAt column, line, string
printAt 24 ,1 ,loadFileLb
xor si,si
xor ax,ax
print newline
print inputPathLabel
;------------------ GET CONFIG PATH INPUT --------------------
.GetUserInput:
readInputChar ;read a new char from keyboard
cmp al, 0dh ; al = CR (carriage return) if key enter
je .EndUserInput
mov [confPathFile+si],al
inc si
jmp .GetUserInput
.EndUserInput:
mov al,0
mov cx,si
mov [counter],cl
mov [confPathFile+si],al
mov al,'$'
mov [confPathFile+si+1],al
print confPathFile
print newline
;------------- OPEN FILE CONFIGURATIONS ----------------
; openFile ASCIZ_file_name
openFile confPathFile
jc .errorOpenFile
;------------- READ FILE CONFIGURATIONS ----------------
; readFile Handle, BufferToStoreData
readFile ax, confReadBf
jc .errorReadFile
mov [bytesTr],ah
mov [bytesTr+1],al
;------------- CLOSE FILE CONFIGURATIONS ---------------
closeFile bx
jc .errorCloseFile
print confReadBf
;------------------- GET CONFIG DATA --------------------
mov al,0h
mov [counter],al
xor ax,ax
xor bx,bx
xor si,si
xor di,di
xor bp,bp
.Analisis:
mov al,[counter]
cmp al,02h ;counter = 2 (;) start to get operations
je .GetOperation
mov al,[confReadBf+si]
cmp al, 04h ; al = end of trasmision
je .EndFile
;cmp al, 10 ; al = CR (carriage return) if key enter
;je .EndFile
cmp al,3bh ;al = ; (3bh)
je .CountSC
inc si
jmp .Analisis
.CountSC: ;count semicolon
mov al,[counter]
inc al
mov [counter],al
inc si
jmp .Analisis
.GetOperation:
mov al,[confReadBf+si]
;printChar al
;cmp al, 13 ; al = CR (carriage return) if key enter
;je .EndFile
;cmp al, 10 ; al = CR (carriage return) if key enter
;je .EndFile
cmp al, 3bh ; al = ;
je .EndOperationInput
mov [operationsBf+di],al
inc si
inc di
jmp .GetOperation
.EndOperationInput:
mov [operationsBf+di],al
inc di
inc si
;mov cx,di
;mov [counter],cl
mov al,'$'
mov [operationsBf+di],al
print newline
print operationsBf
print newline
PreOrder
xor di,di ;clean index for operationsBf
;jmp .GetOperation
;-------------------- WHERE TO SAVE -----------------
mov al,[counterA] ;Level Counter
cmp al,00h
je .SaveIn1 ;Save al level 1 values
cmp al,01
je .SaveIn2 ;Save al level 2 values
cmp al,02
je .SaveIn3 ;Save al level 3 values
cmp al,03
je .SaveIn4 ;Save al level 4 values
cmp al,04
je .SaveIn5 ;Save al level 5 values
;---------------------------------------- SAVE VALUES CONF FOR LEVEL 1 ---------------------
.SaveIn1:
mov al,[counterB] ;Operation counter
cmp al,00h
je .Obstacle1
cmp al,01h
je .Premio1
cmp al,02h
je .Level1
cmp al,03h
je .Select1
cmp al,04h
je .Avoid1
.Obstacle1:
;mov al,[numberBf]
;mov [obst1Bf],al
; CopyResult bf, bfToCopy
CopyResult obst1Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Premio1:
;mov al,[numberBf]
;mov [pr1Bf],al
; CopyResult bf, bfToCopy
CopyResult pr1Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Level1:
;mov al,[numberBf]
;mov [lvl1Bf],al
; CopyResult bf, bfToCopy
CopyResult lvl1Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Select1:
;mov al,[numberBf]
;mov [ptsSe1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsSe1Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Avoid1:
;mov al,[numberBf]
;mov [ptsEs1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsEs1Bf,numberBf
mov al,[counterB]
mov al,0h ;clean counter B
mov [counterB],al
.GetColor:
mov al,[confReadBf+si]
;printChar al
cmp al, 04h ; al = end of trasmision
je .EndColorInput
cmp al, 13 ; al = CR (carriage return) if key enter
je .EndColorInput
cmp al, 10 ; al = CR (carriage return) if key enter
je .EndColorInput
mov [color1+di],al
inc si
inc di
jmp .GetColor
.EndColorInput:
mov al,'$'
mov [color1+di],al
xor di,di ;clean di for next buffer to fill
;inc si
print newline
print color1
print newline
mov al,[counterA] ;increment to next save next level values
inc al
mov [counterA],al
mov al,0
mov [counter],al ;clean counter of ;
jmp .Analisis
;---------------------------------------- SAVE VALUES CONF FOR LEVEL 2 ---------------------
.SaveIn2:
mov al,[counterB] ;Operation counter
cmp al,00h
je .Obstacle2
cmp al,01h
je .Premio2
cmp al,02h
je .Level2
cmp al,03h
je .Select2
cmp al,04h
je .Avoid2
.Obstacle2:
;mov al,[numberBf]
;mov [obst1Bf],al
; CopyResult bf, bfToCopy
CopyResult obst2Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Premio2:
;mov al,[numberBf]
;mov [pr1Bf],al
; CopyResult bf, bfToCopy
CopyResult pr2Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Level2:
;mov al,[numberBf]
;mov [lvl1Bf],al
; CopyResult bf, bfToCopy
CopyResult lvl2Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Select2:
;mov al,[numberBf]
;mov [ptsSe1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsSe2Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Avoid2:
;mov al,[numberBf]
;mov [ptsEs1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsEs2Bf,numberBf
mov al,[counterB]
mov al,0h ;clean counter B
mov [counterB],al
.GetColor2:
mov al,[confReadBf+si]
;printChar al
cmp al, 04h ; al = end of trasmision
je .EndColorInput2
cmp al, 13 ; al = CR (carriage return) if key enter
je .EndColorInput2
cmp al, 10 ; al = CR (carriage return) if key enter
je .EndColorInput2
mov [color2+di],al
inc si
inc di
jmp .GetColor2
.EndColorInput2:
mov al,'$'
mov [color2+di],al
xor di,di ;clean di for next buffer to fill
;inc si
print newline
print color2
print newline
;jmp Main
mov al,[counterA] ;increment to next save next level values
inc al
mov [counterA],al
mov al,0
mov [counter],al ;clean counter of ;
jmp .Analisis
;---------------------------------------- SAVE VALUES CONF FOR LEVEL 3 ---------------------
.SaveIn3:
mov al,[counterB] ;Operation counter
cmp al,00h
je .Obstacle3
cmp al,01h
je .Premio3
cmp al,02h
je .Level3
cmp al,03h
je .Select3
cmp al,04h
je .Avoid3
.Obstacle3:
;mov al,[numberBf]
;mov [obst1Bf],al
; CopyResult bf, bfToCopy
CopyResult obst3Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Premio3:
;mov al,[numberBf]
;mov [pr1Bf],al
; CopyResult bf, bfToCopy
CopyResult pr3Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Level3:
;mov al,[numberBf]
;mov [lvl1Bf],al
; CopyResult bf, bfToCopy
CopyResult lvl3Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Select3:
;mov al,[numberBf]
;mov [ptsSe1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsSe3Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Avoid3:
;mov al,[numberBf]
;mov [ptsEs1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsEs3Bf,numberBf
mov al,[counterB]
mov al,0h ;clean counter B
mov [counterB],al
.GetColor3:
mov al,[confReadBf+si]
;printChar al
cmp al, 04h ; al = end of trasmision
je .EndColorInput3
;cmp al, 13 ; al = CR (carriage return) if key enter
;je .EndColorInput3
cmp al, 10 ; al = CR (carriage return) if key enter
je .EndColorInput3
mov [color3+di],al
inc si
inc di
jmp .GetColor3
.EndColorInput3:
mov al,'$'
mov [color3+di],al
xor di,di ;clean di for next buffer to fill
;inc si
print newline
print color3
print newline
;jmp Main
mov al,[counterA] ;increment to next save next level values
inc al
mov [counterA],al
mov al,0
mov [counter],al ;clean counter of ;
jmp .Analisis
;-----------------------------------------------------END LEVEL 3---------------------------------------------------
;---------------------------------------- SAVE VALUES CONF FOR LEVEL 4 ---------------------
.SaveIn4:
mov al,[counterB] ;Operation counter
cmp al,00h
je .Obstacle4
cmp al,01h
je .Premio4
cmp al,02h
je .Level4
cmp al,03h
je .Select4
cmp al,04h
je .Avoid4
.Obstacle4:
;mov al,[numberBf]
;mov [obst1Bf],al
; CopyResult bf, bfToCopy
CopyResult obst4Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Premio4:
;mov al,[numberBf]
;mov [pr1Bf],al
; CopyResult bf, bfToCopy
CopyResult pr4Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Level4:
;mov al,[numberBf]
;mov [lvl1Bf],al
; CopyResult bf, bfToCopy
CopyResult lvl4Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Select4:
;mov al,[numberBf]
;mov [ptsSe1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsSe4Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Avoid4:
;mov al,[numberBf]
;mov [ptsEs1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsEs4Bf,numberBf
mov al,[counterB]
mov al,0h ;clean counter B
mov [counterB],al
.GetColor4:
mov al,[confReadBf+si]
;printChar al
cmp al, 04h ; al = end of trasmision
je .EndColorInput4
cmp al, 13 ; al = CR (carriage return) if key enter
je .EndColorInput4
cmp al, 10 ; al = CR (carriage return) if key enter
je .EndColorInput4
mov [color4+di],al
inc si
inc di
jmp .GetColor4
.EndColorInput4:
mov al,'$'
mov [color4+di],al
xor di,di ;clean di for next buffer to fill
;inc si
print newline
print color4
print newline
;jmp Main
mov al,[counterA] ;increment to next save next level values
inc al
mov [counterA],al
mov al,0
mov [counter],al ;clean counter of ;
jmp .Analisis
;-----------------------------------------------------END LEVEL 4---------------------------------------------------
;---------------------------------------- SAVE VALUES CONF FOR LEVEL 5 ---------------------
.SaveIn5:
mov al,[counterB] ;Operation counter
cmp al,00h
je .Obstacle5
cmp al,01h
je .Premio5
cmp al,02h
je .Level5
cmp al,03h
je .Select5
cmp al,04h
je .Avoid5
.Obstacle5:
;mov al,[numberBf]
;mov [obst1Bf],al
; CopyResult bf, bfToCopy
CopyResult obst5Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Premio5:
;mov al,[numberBf]
;mov [pr1Bf],al
; CopyResult bf, bfToCopy
CopyResult pr5Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Level5:
;mov al,[numberBf]
;mov [lvl1Bf],al
; CopyResult bf, bfToCopy
CopyResult lvl5Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Select5:
;mov al,[numberBf]
;mov [ptsSe1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsSe5Bf,numberBf
mov al,[counterB]
inc al
mov [counterB],al
jmp .GetOperation
.Avoid5:
;mov al,[numberBf]
;mov [ptsEs1Bf],al
; CopyResult bf, bfToCopy
CopyResult ptsEs5Bf,numberBf
mov al,[counterB]
mov al,0h ;clean counter B
mov [counterB],al
.GetColor5:
mov al,[confReadBf+si]
;printChar al
cmp al, 04h ; al = end of trasmision
je .EndColorInput5
cmp al, 10 ; al = CR (carriage return) if key enter
je .EndColorInput5
mov [color5+di],al
inc si
inc di
jmp .GetColor5
.EndColorInput5:
mov al,'$'
mov [color5+di],al
xor di,di ;clean di for next buffer to fill
;inc si
print newline
print color5
print newline
;jmp Main
mov al,[counterA] ;increment to next save next level values
inc al
mov [counterA],al
mov al,0
mov [counter],al ;clean counter of ;
;jmp .Analisis
;-----------------------------------------------------END LEVEL 5---------------------------------------------------
;jmp Main
;jmp .GetOperation
;print newline
;print obst1Bf
;print newline
;print pr1Bf
;print newline
;print lvl1Bf
;print newline
;print ptsSe1Bf
;print newline
;print ptsEs1Bf
;print newline
;jmp Main
.EndFile: ;----------- USE THIS FOR CREATE THE FILE CONTAINING ALL VALUES
;print newline
print obst1Bf
print newline
;print pr2Bf
;print newline
;print lvl2Bf
;print newline
;print ptsSe1Bf
;print newline
;print ptsEs1Bf
;print newline
;-------- CREATE FILE (MY CONFIGURATIONS) -------------
; CreateFile %1 ASCIZ filename
;CreateFile myconfPathFile
;jc .errCreateFile
;print createFileMsg
;------------- CLOSE (MY CONFIGURATIONS)---------------
;closeFile ax
;jc .errorCloseFile
;-------- OPEN FILE (MY CONFIGURATIONS) ------
;openWriteFile myconfPathFile
;jc .errorOpenFile
;print openFileMsg
;-------- WRITE IN FILE (MY CONFIGURATIONS)------------------
;writeInFile data,handle,numBytes
;writeInFile level1Tg,ax,07h
;mov bl,3bh ;al = ; (Ascii 3bh)
;mov [char], bl
;writeInFile char,ax,01h
;jc .errorWriteFile
;------------- CLOSE FILE (SING UP)---------------
;closeFile bx
;jc .errorCloseFile
jmp UserMenu
;--------------------------------------------------------------------------------
;--------------------------------------------USER MENU CREATE MY CONFIG FILE -----------------------
.Option3:
;----level 1----
print newline
print level1Tg
print newline
print tmObsTg
print obst1Bf
print newline
print tmPrTg
print pr1Bf
print newline
print tmLvlTg
print lvl1Bf
print newline
print ptsSlTg
print ptsSe1Bf
print newline
print ptsEsTg
print ptsEs1Bf
print newline
print colorTg
print color1
print newline
readInputChar
;----level 2 ---
print newline
print level2Tg
print newline
print tmObsTg
print obst2Bf
print newline
print tmPrTg
print pr2Bf
print newline
print tmLvlTg
print lvl2Bf
print newline
print ptsSlTg
print ptsSe2Bf
print newline
print ptsEsTg
print ptsEs2Bf
print newline
print colorTg
print color2
print newline
readInputChar
;------------ level 3----------
print newline
print level3Tg
print newline
print tmObsTg
print obst3Bf
print newline
print tmPrTg
print pr3Bf
print newline
print tmLvlTg
print lvl3Bf
print newline
print ptsSlTg
print ptsSe3Bf
print newline
print ptsEsTg
print ptsEs3Bf
print newline
print colorTg
print color3
print newline
readInputChar
;------------ level 4----------
print newline
print level4Tg
print newline
print tmObsTg
print obst4Bf
print newline
print tmPrTg
print pr4Bf
print newline
print tmLvlTg
print lvl4Bf
print newline
print ptsSlTg
print ptsSe4Bf
print newline
print ptsEsTg
print ptsEs4Bf
print newline
print colorTg
print color4
print newline
readInputChar
;------------ level 5----------
print newline
print level5Tg
print newline
print tmObsTg
print obst5Bf
print newline
print tmPrTg
print pr5Bf
print newline
print tmLvlTg
print lvl5Bf
print newline
print ptsSlTg
print ptsSe5Bf
print newline
print ptsEsTg
print ptsEs5Bf
print newline
print colorTg
print color5
print newline
jmp UserMenu
;--------------------------------------------------------------------------------
jmp UserMenu
.errorWriteFile:
print errWriteFileMsg
jmp UserMenu
.errorOpenFile:
print errOpenMsg
jmp UserMenu
.errorReadFile:
print errReadFileMsg
jmp Main
.errorCloseFile:
print errCloseFileMsg
jmp Main
.errorPathInput:
print errPathMsg
jmp Main
.errorCreateFile:
print errCreateFileMsg
jmp Main
jmp UserMenu
.Option2:;-------------------------------------JUGAR --------------
call ClearScreen
; printAt column, line, string
printAt 17 ,1 ,gameLb
setVideoMode 13h
;------------------------------ DRAW GAME FRAME ---------------------
; plotPixel %1 color, %2 x ,%3 y
plotPixel 14,0,100
plotPixel 14,0,0
plotPixel 14,160,0
plotPixel 14,319,0
plotPixel 14,160,100
plotPixel 14,319,100
plotPixel 14,319,199
plotPixel 14,160,199
plotPixel 14,0,199
; DrawArea x,width,y,height,color
; DrawArea 80,20,50,30,02h
;-------- DRAW CONTOUR --------------------------
DrawArea 80,5,30,150,02h ;LEFT
DrawArea 80,160,25,5,02h ;TOP
DrawArea 235,5,30,150,02h ;RIGHT
DrawArea 80,160,180,5,02h ;BOTTOM
;----------------------------- PRINT HEADER ---------------------------------
; printAt column, line, string
printAt 2 ,0 ,currentUser
DrawChar N,1,25
DrawChar ONE,1,26
DrawChar ZERO,1,35
DrawChar ZERO,1,36
DrawChar ZERO,1,37
;---------------- PRINT TIME OF SYSTEM -----------------
mov al, [dir]
;pintar inicial mente el carro
print_car al
;mov al,[dirXObs]
;mov ah,[dirYObs]
print_Obstacle [dirXObs],[dirYObs]
mov al,[dirXObs]
add al, 30
mov [dirXObs],al
print_Obstacle [dirXObs],[dirYObs]
mov al,[dirXObs]
add al, 30
mov [dirXObs],al
mov al,[dirYObs]
add al,30
mov [dirYObs],al
print_Obstacle2 [dirXObs],[dirYObs]
.while:
mov ah,2ch
int 21h
mov [hour],ch
mov [minute],cl
mov [seconds],dh
mov dh,0h
mov dl,[hour]
DecToAscii dx
; printAt column, line, string
printAt 27,0,numberBf
mov dh,0h
mov dl,[minute]
DecToAscii dx
; printAt column, line, string
printAt 30,0,numberBf
mov dh,0h
mov dl,[seconds]
DecToAscii dx
; printAt column, line, string
printAt 33,0,numberBf
; leer el teclado
call keystatus
; manejar los obstaculos(no programado)
;call obstacles
; retarndo general
sleep 100h
jmp .while
jmp Main
.SetTextMode:
setVideoMode 03h
jmp Main
;this part of code tell when a key is pressed
keystatus:
;lee si se ha presionado una tecla o no
mov ah, 01h
int 16h
je .return
;si se presiona una tecla lee que tecla se ha presionado
;las teclas de direccion son combinaciones de dos teclas por eso se lee dos
;veces la tecla que se presiono
.keypress:
mov ah, 08h
int 21h
mov ah, 08h
int 21h
cmp al, 1bh
je UserMenu.SetTextMode
cmp al, 4bh
je .movleft
cmp al, 4dh
je .movright
;segun la tecla que se presiono se elije una accion
.movleft:
mov al, [dir]
sub al, 5h
;si sale de los limites del escenario no permite el movimiento
cmp al, 85
jb .return
mov [dir], al
print_car al
jmp .return
.movright:
mov al, [dir]
add al, 5h
;lo mismo si sale de los limites nel perro
cmp al, 194
ja .return
mov [dir], al
print_car al
je .return
mov al, 01h
mov [dir], al
.return:
ret
exit:
mov ah, 4ch
int 21h
Option1: ;LOG IN OPTION
call ClearScreen
; printAt column, line, string
printAt 24 ,1 ,logInLb
print userlb
xor si,si
xor ax,ax
;------------------ GET INPUT USER --------------------
.GetUserInput:
readInputChar ;read a new char from keyboard
cmp al, 0dh ; al = CR (carriage return) if key enter
je .EndUserInput
mov [usersBf+si],al
mov [currentUser+si],al
inc si
jmp .GetUserInput
.EndUserInput:
mov al,'$'
mov cx,si
mov [counter],cl
mov [usersBf+si],al
mov [currentUser+si],al
print usersBf
print newline
;------------- OPEN FILE ----------------
; openFile ASCIZ_file_name
openFile usersPathFile
jc .errorOpenFile
;------------- READ FILE ----------------
; readFile Handle, BufferToStoreData
readFile ax, fileReadBf
jc .errorReadFile
;------------- CLOSE FILE ---------------
closeFile bx
jc .errorCloseFile
;jmp Main
;print fileReadBf
;------------------ SEARCH FOR USER --------------------
xor si,si ;clean si
xor di,di ;clean di
xor bp,bp ;clean bp
xor ax,ax ;clean ax
.searchUser:
mov al, [usersBf+di] ;input user name
mov ah, [fileReadBf+si] ;current data
cmp ah, '$' ;ah = $ (Ascii 24h) end of users file
je .userNotFound
cmp ah, 2ch ;ah = , (Ascii 2ch)
je .userFound ;if , it's been reach then user matches
cmp al,ah ;if inputUser match current user in buffer
jne .userNotMatch
inc si ;then increment si
inc di ;also increment di
jmp .searchUser ;return and keep searching...
.userNotFound:
print errUserMsg
jmp Main
.userNotMatch: ;if failed at matching user with current in buffer
;print errUserMatch
xor di,di ;clean userinput index
mov ah, [fileReadBf+si] ;move forward till find a comma
push ax
push dx
mov dl,ah ;refers to the first parameter to the macro call
mov ah, 06h ;09h function write string
;int 21h ;call the interruption
pop dx
pop ax
cmp ah,2ch ;ah = , (Ascii 3bh)
je .NextUser ;if comma jump NextUser
inc si
jmp .userNotMatch
.NextUser:
add si,08h ;increment si till next User in database
jmp .searchUser
.userFound:
;------------------------------ CHECK IF ADMIN CREDENTIALS -------------------------
xor di,di
mov al, [usersBf+di] ;input user name
cmp al,'a'
jne .NotAdmin
inc di
mov al, [usersBf+di] ;input user name
cmp al,'d'
jne .NotAdmin
inc di
mov al, [usersBf+di] ;input user name
cmp al,'m'
jne .NotAdmin
inc di
mov al, [usersBf+di] ;input user name
cmp al,'i'
jne .NotAdmin
inc di
mov al, [usersBf+di] ;input user name
cmp al,'n'
jne .NotAdmin
inc di
mov al, [usersBf+di] ;input user name
cmp al,'N'
jne .NotAdmin
inc di
mov al, [usersBf+di] ;input user name
cmp al,'P'
jne .NotAdmin
inc di
mov al, [usersBf+di] ;input user name
cmp al,'$'
jne .NotAdmin
mov al,01h
mov [isAdmin],al
jmp .EndUserFound
.NotAdmin:
mov al,00h
mov [isAdmin],al
.EndUserFound:
inc si ;last char found it in [fileReadBf] was a comma inc to passw first number
print userFoundMsg
print newline
;------------------ GET INPUT PASSWORD --------------------
;mov di,si ;save current fileReadBf index
;mov bp,si
.ReadPassword:
push si
mov di,si
print passlb
xor si,si
xor ax,ax
.GetPasswordInput:
cmp si,04h
je .EndPasswordInput
readInputChar ;read a new char from keyboard
cmp al, 0dh ; al = CR (carriage return) if key enter
je .ErrPassword
mov [usersBf+si],al
inc si
jmp .GetPasswordInput
.ErrPassword:
print errPasswMsg
print newline
pop si
jmp .ReadPassword
.EndPasswordInput:
mov al,'$'
mov [usersBf+si],al
print newline
print usersBf
print newline
;jmp Main
;------------------ SEARCH FOR PASSWORD --------------------
mov si,di ;restore fileReadBf index
xor di,di ;clean di
xor ax,ax ;clean ax
.searchPassword:
mov al, [usersBf+di] ;input user password
mov ah, [fileReadBf+si] ;current data
cmp ah, 3bh ;ah = ; (Ascii 2ch)
je .passwFound ;if ; it's been reach then password matches
cmp al,ah ;if inputPassword match current password in buffer
jne .passwNotMatch
inc si ;then increment si
inc di ;also increment di
jmp .searchPassword ;return and keep searching...
.passwNotMatch: ;if failed at matching passw with current in buffer
print errPasswMsg
print newline
pop si
jmp .ReadPassword
.passwFound:
print userFoundMsg
print newline
mov al,[isAdmin]
cmp al,01h
je .IsAdmin
print myuserlb
print newline
jmp UserMenu ;---------> USER IS CORRECT CHANGE TO USER MENU
.IsAdmin:
print adminlb
print newline
jmp AdminMenu
.errorOpenFile:
print errOpenMsg
jmp Main
.errorReadFile:
print errReadFileMsg
jmp Main
.errorCloseFile:
print errCloseFileMsg
jmp Main
Option2: ;---------- SING UP OPTION ----------
call ClearScreen
printAt 24 ,1 ,singUpLb
print userSingLb
xor si,si
xor ax,ax
xor cx,cx ;user name characters counter
;------------------ GET INPUT USER (SING UP) --------------------
.GetUserInput:
cmp si,07h
je .EndUserInput
readInputChar ;read a new char from keyboard
cmp al, 0dh ; al = CR (carriage return) if key enter
je .EndUserInput
mov [usersBf+si],al
inc si
jmp .GetUserInput
.EndUserInput:
mov cx,si
mov [counter],cl
mov al,'$'
mov [usersBf+si],al
print newline
print usersBf
print newline
;push cx ;save counter
;------------- OPEN FILE (SING UP) ----------------
; openFile ASCIZ_file_name
openFile usersPathFile
jc .errorOpenFile
;------------- READ FILE (SING UP)----------------
; readFile Handle, BufferToStoreData
readFile ax, fileReadBf
jc .errorReadFile
;------------- CLOSE FILE (SING UP)---------------
closeFile bx
jc .errorCloseFile
;jmp Main
print fileReadBf
;pop cx ;restore counter
;------------------ SEARCH FOR USER (SING UP)--------------------
xor si,si ;clean si
xor di,di ;clean di
xor bp,bp ;clean bp
xor ax,ax ;clean ax
.searchUser:
mov al, [usersBf+di] ;input user name
mov ah, [fileReadBf+si] ;current data
cmp ah, '$' ;ah = $ (Ascii 24h) end of users file
je .userNotFound
cmp ah, 2ch ;ah = , (Ascii 2ch)
je .userFound ;if , it's been reach then user matches
cmp al,ah ;if inputUser match current user in buffer
jne .userNotMatch
inc si ;then increment si
inc di ;also increment di
jmp .searchUser ;return and keep searching...
.userNotFound:
print errUserMsg
;---------------------------------------------OPEN REPORT FILE ------------------------------------------------------
;-------- OPEN FILE (REPORT FILE) ------
openWriteFile reportPathFile
jc .errorOpenFile
print openFileMsg
;push cx ;save counter
;------- READ FILE (REPORT FILE) -------
; readFile Handle, BufferToStoreData
readFile ax, fileReadBf
jc .errorReadFile
;-------- SET CURRENT FILE POSITION (FOR REPOR FILE )----------
dec ax
mov dx,ax
mov ah, 42h
mov al,00h
mov cx,0h
;mov dx,0ah
int 21h
;pop cx ;restore counter
;-------- WRITE IN FILE (REPORT FILE)------------------
;writeInFile usersBf,bx,0ah
mov cl,[counter]
writeInFile usersBf,bx,cx
mov al,2ch ;al = , (Ascii 2ch)
mov [char], al
writeInFile char,bx,01h
mov al,30h ;al = 0 (Ascii 30h)
mov [char], al
writeInFile char,bx,01h
mov al,2ch ;al = , (Ascii 2ch)
mov [char], al
writeInFile char,bx,01h
mov al,30h ;al = 0 (Ascii 30h)
mov [char], al
writeInFile char,bx,01h
mov al,2ch ;al = , (Ascii 2ch)
mov [char], al
writeInFile char,bx,01h
mov al,30h ;al = 0 (Ascii 30h)
mov [char], al
writeInFile char,bx,01h
mov al,3bh ;al = ; (Ascii 3bh)
mov [char], al
writeInFile char,bx,01h
mov al,0ah ;al = linefeed (Ascii 0ah)
mov [char], al
writeInFile char,bx,01h
mov al,0dh ;al = carriage return (Ascii 0dh)
mov [char], al
writeInFile char,bx,01h
mov al,24h ;al = $ (24h)
mov [char], al
writeInFile char,bx,01h
jc .errorWriteFile
;------------- CLOSE FILE (SING UP-PASSWORD)---------------
closeFile bx
jc .errorCloseFile
;---------------------------------------------------------------------------------------------------------------------
;-------- OPEN FILE (SIGN UP ADD IN DATABASE) ------
openWriteFile usersPathFile
jc .errorOpenFile
print openFileMsg
;push cx ;save counter
;------- READ FILE (SIGN UP ADD IN DATABASE) -------
; readFile Handle, BufferToStoreData
readFile ax, fileReadBf
jc .errorReadFile
;-------- SET CURRENT FILE POSITION (SIGN UP ADD IN DATABASE)----------
dec ax
mov dx,ax
mov ah, 42h
mov al,00h
mov cx,0h
;mov dx,0ah
int 21h
;pop cx ;restore counter
;-------- WRITE IN FILE (SIGN UP ADD IN DATABASE)------------------
;writeInFile data,handle,numBytes
mov cl,[counter]
writeInFile usersBf,bx,cx ;username
mov al,2ch ;al = , (Ascii 2ch)
mov [char], al
writeInFile char,bx,01h
jc .errorWriteFile
;------------- CLOSE FILE (SING UP)---------------
closeFile bx
jc .errorCloseFile
jmp .ReadPassword
;jmp Main
.userNotMatch: ;if failed at matching user with current in buffer
;print errUserMatch
xor di,di ;clean userinput index
mov ah, [fileReadBf+si] ;move forward till find a comma
push ax
push dx
mov dl,ah ;refers to the first parameter to the macro call
mov ah, 06h ;09h function write string
int 21h ;call the interruption
pop dx
pop ax
cmp ah,2ch ;ah = , (Ascii 3bh)
je .NextUser ;if comma jump NextUser
inc si
jmp .userNotMatch
.NextUser:
add si,08h ;increment si till next User in database
jmp .searchUser
.userFound:
inc si ;last char found it was a comma inc to passw first number
print UserExistMsg
print newline
jmp Main
;------------------ GET INPUT PASSWORD (SIGN UP) --------------------
.ReadPassword:
print passwSingLb
xor si,si
xor ax,ax
.GetPasswordInput:
cmp si,04h
je .EndPasswordInput
readInputChar ;read a new char from keyboard
cmp al, 0dh ; al = CR (carriage return) if key enter
je .ErrPassWord
mov [usersBf+si],al
inc si
jmp .GetPasswordInput
.ErrPassWord:
print errPasswMsg
print newline
jmp .ReadPassword
.EndPasswordInput:
mov cx,si
mov [counter],cl
mov al,'$'
mov [usersBf+si],al
;print newline
;print usersBf
print newline
;-------- OPEN FILE (SIGN UP ADD IN DATABASE-PASSWORD) ------
openWriteFile usersPathFile
jc .errorOpenFile
print openFileMsg
;push cx ;save counter
;------- READ FILE (SIGN UP ADD IN DATABASE-PASSWORD) -------
; readFile Handle, BufferToStoreData
readFile ax, fileReadBf
jc .errorReadFile
;-------- SET CURRENT FILE POSITION (SIGN UP ADD IN DATABASE-PASSWORD)----------
;dec ax
mov dx,ax
mov ah, 42h
mov al,00h
mov cx,0h
;mov dx,0ah
int 21h
;pop cx ;restore counter
;-------- WRITE IN FILE (SIGN UP ADD IN DATABASE-PASSWORD)------------------
;writeInFile usersBf,bx,0ah
mov cl,[counter]
writeInFile usersBf,bx,cx
mov al,3bh ;al = ; (Ascii 3bh)
mov [char], al
writeInFile char,bx,01h
mov al,0ah ;al = linefeed (Ascii 0ah)
mov [char], al
writeInFile char,bx,01h
mov al,0dh ;al = carriage return (Ascii 0dh)
mov [char], al
writeInFile char,bx,01h
mov al,24h ;al = $ (24h)
mov [char], al
writeInFile char,bx,01h
jc .errorWriteFile
;------------- CLOSE FILE (SING UP-PASSWORD)---------------
closeFile bx
jc .errorCloseFile
jmp Main
.errorOpenFile:
print errOpenMsg
jmp Main
.errorWriteFile:
print errWriteFileMsg
jmp Main
.errorReadFile:
print errReadFileMsg
jmp Main
.errorCloseFile:
print errCloseFileMsg
jmp Main
;-------------------OPTION 2 -- END SIGN UP -----------------------------
Option3:
jmp exit
Option4:
ClearScreen:
;SCROLL SCREEN UP
mov ah, 06h ;request scroll up
mov al, 00h ;number of lines to scroll up
mov bh, 07h ;black background
mov cx,0000h ;starting row:column
mov dx, 194Fh;ending row:column
int 10h
;SET CURSOR POSITION
mov ah,02h ;request set cursor position
mov bh,00h ;number of page
mov dh,01h ;row/y = 0
mov dl,0h ;column/x = 0
int 10h ;call interruption
ret
;========================== SECTION .DATA ====================
segment .data
vgaStartAddr dw 0A000h ;start positon of vga memory
;0a0000h - bffffh
dir db 90,'$'
dirXObs db 100,'$'
dirYObs db 30,'$'
headerLabel db 13,13,10
db 'UNIVERSIDAD DE <NAME>',13,10
db 'FACULTAD DE INGENIERIA ',13,10
db 'CIENCIAS Y SISTEMAS',13,10
db 'ARQUITECTURA DE COMPUTADORAS Y ENSAMBLADORES 1 B',13,10
db 'VACACIONES JUNIO 2019',13,10
db 'NOMBRE: <NAME>',13,10
db 'CARNET: 201504510',13,10
db 'PROYECTO ',13,10,'$'
mainMenu db '', 13, 10
db ' _________________________', 13, 10
db '|_________ MENU __________|', 13, 10
db '| 1. Ingresar |', 13, 10
db '| 2. Registrar |', 13, 10
db '| 3. Salir |', 13, 10
db '| 4. Debugger |', 13, 10
db '|_________________________|',13,10,'$'
userMenu db '', 13, 10
db ' _________________________', 13, 10
db '|_______ CRASH CAR _______|', 13, 10
db '| 1. Cargar Archivo |', 13, 10
db '| 2. Jugar |', 13, 10
db '| 3. Salir |', 13, 10
db '| 4. Mostrar Configura |', 13, 10
db '|_________________________|',13,10,'$'
adminMenu db '', 13, 10
db ' _________________________', 13, 10
db '|_______ CRASH CAR _______|', 13, 10
db '| 1. Top 10 Puntos |', 13, 10
db '| 2. Menu Principal |', 13, 10
db '|_________________________|',13,10,'$'
logInLb db '_________ LOG IN __________',10,'$'
singUpLb db '_________ SIGN UP __________',10,'$'
topTenLb db '_________ TOP TEN __________',10,'$'
loadFileLb db '_________ LOAD FILE __________',10,'$'
gameLb db '____________ G A M E ____________',10,'$'
userlb db 'User: ','$'
passlb db 'Password: ','$'
adminlb db 'Administrador','$'
myuserlb db 'Mi User','$'
videoModeMsg db 'Video Mode: ','$'
name db 'pawz',10
inputPathLabel db 'Ingrese Ruta: ','$'
optionLabel db 'Escoja Opcion: ','$'
userSingLb db 'User (max 7 characters): ','$'
passwSingLb db 'Password (max 4 numbers): ','$'
errWriteFileMsg db 13,10,'Error al escribir en archivo',13,10,'$'
errPathMsg db 13,10,'Error ruta archivo Intente de nuevo',13,10,'$'
errOpenMsg db 13,10,'Error No se puedo Abrir el Archivo',13,10,'$'
openFileMsg db 13,10,'Archivo Abierto correctamente',13,10,'$'
readFileMsg db 13,10,'Archivo Leido correctamente',13,10,'$'
createFileMsg db 13,10,'Archivo Creado correctamente',13,10,'$'
errReadFileMsg db 13,10,'Error No se puedo Leer el Archivo',13,10,'$'
errCreateFileMsg db 13,10,'Error No se puedo Crear el Archivo',13,10,'$'
errCloseFileMsg db 13,10,'Error No se puedo Cerrar el Archivo',13,10,'$'
errUserMsg db 13,10,'Usuario No encontrado ','$' ;29 characters
errUserMatch db 13,10,'Usuario No existe ','$'
UserExistMsg db 13,10,'El usuario ya existe ','$'
userFoundMsg db 13,10,'Usuario correcto','$' ;29 characters
errPasswMsg db 13,10,'Password Incorrecto ','$' ;29 characters
errMaxPasswMsg db 13,10,'Password Incorrecto Solo numeros max 4 ','$' ;29 characters
newline db 13,10,'$'
blankSpace db 20h,'$'
usersBf times 20 db '$'
currentUser times 20 db '$'
counter db 0,'$'
filePath db 50
fileReadBf times 600 db '$'
confReadBf times 600 db '$'
usersPathFile db 'users.txt',0
confPathFile times 15 db '$'
reportPathFile db 'topten.txt',0
myconfPathFile db 'myconf.txt',0
fileHandle times 5 db '$'
char db '$$$'
isAdmin db '$$'
numberBf times 5 db '$'
reportHandle db 0,0,'$'
indexI db 0,'$'
indexJ db 0,'$'
hour db 0,'$','$'
minute db 0,'$','$'
seconds db 0,'$','$'
colors db 0,0,0,0,0,'$'
red db 'rojo','$'
blue db 'azul','$'
yellow db 'amarillo','$'
green db 'verde','$'
operationsBf times 20 db '$'
inputOpLabel db 'Ingrese Operacion: ','$'
opStack times 20 db '$'
numStack times 100 db '$'
resultBf times 4 db '$'
operators db '*','/','+','-','$'
indexOp db 0,'$'
indexNum db 0,'$'
counterB db 0,'$'
counterA db 0,'$'
obst1Bf times 5 db '$'
obst2Bf times 5 db '$'
obst3Bf times 5 db '$'
obst4Bf times 5 db '$'
obst5Bf times 5 db '$'
pr1Bf times 5 db '$'
pr2Bf times 5 db '$'
pr3Bf times 5 db '$'
pr4Bf times 5 db '$'
pr5Bf times 5 db '$'
lvl1Bf times 5 db '$'
lvl2Bf times 5 db '$'
lvl3Bf times 5 db '$'
lvl4Bf times 5 db '$'
lvl5Bf times 5 db '$'
ptsSe1Bf times 5 db '$'
ptsSe2Bf times 5 db '$'
ptsSe3Bf times 5 db '$'
ptsSe4Bf times 5 db '$'
ptsSe5Bf times 5 db '$'
ptsEs1Bf times 5 db '$'
ptsEs2Bf times 5 db '$'
ptsEs3Bf times 5 db '$'
ptsEs4Bf times 5 db '$'
ptsEs5Bf times 5 db '$'
color1 times 10 db '$'
color2 times 10 db '$'
color3 times 10 db '$'
color4 times 10 db '$'
color5 times 10 db '$'
level1Tg db 'NIVEL1:','$' ;Nivel label (7 bytes)
level2Tg db 'NIVEL2:','$' ;Nivel label (7 bytes)
level3Tg db 'NIVEL3:','$' ;Nivel label (7 bytes)
level4Tg db 'NIVEL4:','$' ;Nivel label (7 bytes)
level5Tg db 'NIVEL5:','$' ;Nivel label (7 bytes)
tmObsTg db 'tiempo_Obstaculos: ','$' ;tiempo obstaculos (18 bytes)
tmPrTg db 'tiempo_Premios: ','$' ;tiempo premios (15 bytes)
tmLvlTg db 'tiempo_Nivel: ','$' ;tiempo nivel (13 bytes)
ptsSlTg db 'puntos_Seleccion: ','$' ;puntos seleccion (17 bytes)
ptsEsTg db 'puntos_Esquivar: ','$' ;puntos esquivar (16 bytes)
colorTg db 'color: ','$' ;color (6 bytes)
bytesTr db 0,0,'$'
A db 0,0,1,0
db 0,1,0,1
db 0,1,1,1
db 0,1,0,1
db 0,1,0,1,'$'
B db 0,1,1,0
db 0,1,0,1
db 0,1,1,0
db 0,1,0,1
db 0,1,1,0,'$'
C db 0,0,1,0
db 0,1,0,1
db 0,1,0,0
db 0,1,0,1
db 0,0,1,0,'$'
D db 0,1,1,0
db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,1,1,0,'$'
E db 0,1,1,1
db 0,1,0,0
db 0,1,1,0
db 0,1,0,0
db 0,1,1,1,'$'
F db 0,1,1,1
db 0,1,0,0
db 0,1,1,1
db 0,1,0,0
db 0,1,0,0,'$'
G db 0,0,1,0
db 0,1,0,1
db 0,1,0,0
db 0,1,1,1
db 0,1,1,0,'$'
H db 0,1,0,1
db 0,1,0,1
db 0,1,1,1
db 0,1,0,1
db 0,1,0,1,'$'
I db 0,0,1,0
db 0,0,1,0
db 0,0,1,0
db 0,0,1,0
db 0,0,1,0,'$'
J db 0,0,0,1
db 0,0,0,1
db 0,0,0,1
db 0,1,0,1
db 0,0,1,0,'$'
K db 0,1,0,1
db 0,1,0,1
db 0,1,1,0
db 0,1,0,1
db 0,1,0,1,'$'
L db 0,1,0,0
db 0,1,0,0
db 0,1,0,0
db 0,1,0,0
db 0,1,1,1,'$'
M db 0,1,0,1
db 0,1,0,1
db 0,1,1,1
db 0,1,0,1
db 0,1,0,1,'$'
N db 1,0,0,1
db 1,1,0,1
db 1,1,0,1
db 1,0,1,1
db 1,0,0,1,'$'
O db 0,0,1,0
db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,0,1,0,'$'
P db 0,1,1,1
db 0,1,0,1
db 0,1,1,1
db 0,1,0,0
db 0,1,0,0,'$'
Q db 0,0,1,0
db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,0,1,1,'$'
R db 0,1,1,1
db 0,1,0,1
db 0,1,1,0
db 0,1,0,1
db 0,1,0,1,'$'
S db 0,0,1,0
db 0,1,0,1
db 0,0,1,0
db 0,1,0,1
db 0,0,1,0,'$'
T db 0,1,1,1
db 0,0,1,0
db 0,0,1,0
db 0,0,1,0
db 0,0,1,0,'$'
U db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,1,1,1,'$'
V db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,0,1,0,'$'
W db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,1,1,1
db 0,1,0,1,'$'
X db 0,1,0,1
db 0,1,0,1
db 0,0,1,0
db 0,1,0,1
db 0,1,0,1,'$'
Y db 0,1,0,1
db 0,1,0,1
db 0,0,1,0
db 0,0,1,0
db 0,0,1,0,'$'
Z db 0,1,1,1
db 0,0,0,1
db 0,0,1,0
db 0,1,0,0
db 0,1,1,1,'$'
ONE db 0,0,1,0
db 0,1,1,0
db 0,0,1,0
db 0,0,1,0
db 0,0,1,0,'$'
TWO db 0,1,1,1
db 0,0,0,1
db 0,1,1,1
db 0,1,0,0
db 0,1,1,1,'$'
THREE db 0,1,1,0
db 0,0,0,1
db 0,0,1,0
db 0,0,0,1
db 0,1,1,0,'$'
FOUR db 0,1,0,1
db 0,1,0,1
db 0,1,1,1
db 0,0,0,1
db 0,0,0,1,'$'
FIVE db 0,1,1,1
db 0,1,0,0
db 0,1,1,1
db 0,0,0,1
db 0,1,1,1,'$'
SIX db 0,0,1,1
db 0,1,0,0
db 0,1,1,1
db 0,1,0,1
db 0,0,1,0,'$'
SEVEN db 0,1,1,0
db 0,0,1,0
db 0,1,1,1
db 0,0,1,0
db 0,0,1,0,'$'
EIGHT db 0,0,1,0
db 0,1,0,1
db 0,0,1,0
db 0,1,0,1
db 0,0,1,0,'$'
NINE db 0,1,1,1
db 0,1,0,1
db 0,1,1,1
db 0,0,0,1
db 0,0,0,1,'$'
ZERO db 0,1,1,1
db 0,1,0,1
db 0,1,0,1
db 0,1,0,1
db 0,1,1,1,'$'
COLON db 0,0,1,0
db 0,0,1,0
db 0,0,0,0
db 0,0,1,0
db 0,0,1,0,'$'
;************************** END SECTION DATA***********************************
;************************** END SECTION DATA***********************************
;========================== SECTION .BSS =================================================|
;uninitialized-data sections |
segment .bss
;************************** END SECTION BSS **********************************************
|
setoid-cats/Relation/Relation.agda | heades/AUGL | 0 | 1421 | module Relation.Relation where
open import Level renaming (suc to lsuc)
open import Data.Product
-- Partial equivalence relations.
record ParRel {l l' : Level}{A : Set l}(R : A → A → Set l') : Set (l ⊔ l') where
field
symPf : ∀{x y} → R x y → R y x
transPf : ∀{x y z} → R x y → R y z → R x z
-- (Total) equivalence relation.
record EqRel {l l' : Level}{A : Set l}(R : A → A → Set l') : Set (l ⊔ l') where
field
parEqPf : ParRel R
refPf : ∀{x} → R x x
open ParRel public
open EqRel public
-- The product of two relations.
ProductRel : {l l' : Level}{A : Set l}{B : Set l'}
→ (R : A → A → Set l)
→ (R' : B → B → Set l')
→ (A × B → A × B → Set (l ⊔ l'))
ProductRel R R' a b = (R (proj₁ a) (proj₁ b)) × (R' (proj₂ a) (proj₂ b))
-- The product of two partial equivalence relations is also a partial
-- equivalence relation.
ProductRelIsParRel : {l l' : Level}{A : Set l}{B : Set l'}
→ (R : A → A → Set l)
→ (R' : B → B → Set l')
→ ParRel R
→ ParRel R'
→ ParRel (ProductRel R R')
ProductRelIsParRel R R' erPF₁ erPF₂ =
record { symPf = λ x₁ → symPf erPF₁ (proj₁ x₁) , symPf erPF₂ (proj₂ x₁);
transPf = λ x₁ x₂ → (transPf erPF₁ (proj₁ x₁) (proj₁ x₂)) , (transPf erPF₂ (proj₂ x₁) (proj₂ x₂)) }
-- The product of two (total) equivalence relations is also a (total)
-- equivalence relation.
ProductRelIsEqRel : {l l' : Level}{A : Set l}{B : Set l'}
→ (R : A → A → Set l)
→ (R' : B → B → Set l')
→ EqRel R
→ EqRel R'
→ EqRel (ProductRel R R')
ProductRelIsEqRel R R' erPF₁ erPF₂ =
record { parEqPf = ProductRelIsParRel R R' (parEqPf erPF₁) (parEqPf erPF₂);
refPf = λ {x} → (refPf erPF₁ {proj₁ x}) , (refPf erPF₂ {proj₂ x}) }
-- The restriction of a relation by a predicate.
_↓_ : {l l' : Level}
{A : Set l}
→ (R : A → A → Set l)
→ (P : A → Set l')
→ Set (l ⊔ l')
_↓_ {A = A} R P = Σ[ f ∈ A ] (P f)
-- The restriction of a paritial equivalence is also a partial
-- equivalence.
↓ParRel : {l l' : Level}
{A : Set l}
→ (R : A → A → Set l)
→ (P : A → Set l')
→ ParRel R
→ ParRel (λ (f g : R ↓ P) → R (proj₁ f) (proj₁ g))
↓ParRel R P prPF = record { symPf = λ x₁ → symPf prPF x₁; transPf = λ x₁ x₂ → transPf prPF x₁ x₂ }
-- The restriction of an equivalence relation is also an equivalence
-- relation.
↓EqRel : {l l' : Level}
{A : Set l}
→ (R : A → A → Set l)
→ (P : A → Set l')
→ EqRel R
→ EqRel (λ (f g : R ↓ P) → R (proj₁ f) (proj₁ g))
↓EqRel R P eqrPF = record { parEqPf = ↓ParRel R P (parEqPf eqrPF); refPf = refPf eqrPF }
|
oeis/334/A334854.asm | neoneye/loda-programs | 11 | 90163 | <filename>oeis/334/A334854.asm
; A334854: E.g.f. A(x) satisfies: A(x) = arctan(x * exp(A(x))).
; Submitted by <NAME>(w3)
; 1,2,7,32,149,240,-12725,-378880,-8550135,-178474240,-3550577425,-65428992000,-985800819875,-4641229465600,548638404441075,36708748623872000,1716785996161588625,69798035394846720000,2571598453132219756375,84313566554397999104000
lpb $0
sub $0,1
add $2,$3
add $3,1
mov $1,$3
mul $1,$0
add $2,$1
add $1,$3
mul $1,-1
mul $1,$0
add $4,1
mul $3,$4
add $3,$2
mov $2,$1
lpe
mov $0,$3
add $0,1
|
src/grammars/Post.g4 | CorvusPrudens/Cp | 0 | 5807 | <filename>src/grammars/Post.g4<gh_stars>0
grammar Post;
import Corax;
// Technically, these shouldn't be present after the
// precompiler runs, but this makes testing easy
PRECOMPILER : '#' .*? [\n\r] -> skip;
WHITESPACE : [ \t\n\r] -> skip; |
programs/oeis/026/A026599.asm | neoneye/loda | 22 | 16633 | <reponame>neoneye/loda<filename>programs/oeis/026/A026599.asm<gh_stars>10-100
; A026599: a(n) = Sum_{0<=j<=2*i, 0<=i<=n} A026584(i,j).
; 1,3,9,23,61,155,401,1023,2629,6723,17241,44135,113101,289643,742049,1900623,4868821,12471315,31946601,81831863,209618269,536945723,1375418801,3523201695,9024876901,23117683683,59217191289,151687926023
add $0,2
seq $0,26597 ; Expansion of (1+x)/(1-x-4*x^2).
div $0,4
|
ASM_minilibc_2018/src/strcasecmp.asm | ltabis/epitech-projects | 0 | 20276 | <filename>ASM_minilibc_2018/src/strcasecmp.asm
bits 64 ; set architecture
global strcasecmp:function ; export strcasecmp
;; RDI RSI arguments
strcasecmp:
xor R8, R8 ; set char container to null
xor R9, R9 ; set char container to null
xor RAX, RAX ; set return value to null
cmp RDI, 0 ; check if string parameter null
je .end
cmp RSI, 0 ; check if string parameter null
je .end
.loop: ; loop label
mov R8B, [RDI] ; Stocking next s1 char value into R8B
mov R9B, [RSI] ; Stocking next s2 char value into R9B
cmp byte [RDI], 0 ; check if end of string
je .end ; checking if value is 0 (null terminated string)
cmp byte [RSI], 0 ; check if end of string
je .end ; checking if value is 0 (null terminated string)
inc RSI ; pointer incrementation
inc RDI ; pointer incrementation
cmp R8B, 97 ; are lowercase charaters equal ?
jge .lowercase
cmp R8B, 65 ; are charaters sup A ?
jge .uppercase
.continue:
cmp R8B, R9B ; are lowercase charaters equal ?
je .loop
jmp .end ; end of comparison
.lowercase: ; check >= a && <= z
cmp R8B, 122
jle .lowercasebis
jmp .continue ; check regular
.uppercase:
cmp R8B, 90 ; check >= A && <= Z
jle .uppercasebis
jmp .continue
.lowercasebis:
sub R8B, 32 ; check if the other character is also uppercase
cmp R8B, R9B
je .loop
add R8B, 32 ; Failed, check regular characters just in case
jmp .continue
.uppercasebis:
add R8B, 32 ; check if the other character is also lowercased
cmp R8B, R9B
je .loop
sub R8B, 32 ; Failed, check regular characters just in case
jmp .continue
.end:
sub R8, R9 ; subtract the two chars values
mov RAX, R8 ; assign result to return value
ret ; returning result (end of stack) / resume execution flow
|
sys/stats.nasm | DerickEddington/cabna | 0 | 160259 | <gh_stars>0
bits 64
default rel
%include "cabna/sys/conv.nasm"
global print_stats
global used_max
global in_use
extern threads_strucs
extern thread_aligned_size
extern printf
section .text
proc print_stats:
; Print collected statistics for each thread, and print the totals of all
; threads. Called directly via call not via exec_avail, so the things having
; statistics collected are not used to execute it.
; Temporary struc for the totals of all threads.
sub rsp, thread_size
; [rsp + thread.exec_s_max] not totaled.
; [rsp + thread.exec_s_size] not totaled.
mov qword [rsp + thread.execute_calls], 0
mov qword [rsp + thread.executed_mine], 0
mov qword [rsp + thread.needy], 0
mov qword [rsp + thread.sched_calls], 0
mov qword [rsp + thread.sched_mine], 0
; [rsp + thread.alloc_s_max] not totaled.
; [rsp + thread.alloc_s_size] not totaled.
mov qword [rsp + thread.allocate_calls], 0
mov qword [rsp + thread.alloc_orphans], 0
mov qword [rsp + thread.freed], 0
mov qword [rsp + thread.freed_orphans], 0
mov qword [rsp + thread.mmap], 0
mov ebx, amount_threads - 1
.loop:
mov esi, ebx
mov edi, stats_tid_fmtstr
mov eax, 0
call printf
; Calculate the pointer to the thread struc from the thread ID.
mov eax, thread_aligned_size
mul ebx
add eax, threads_strucs
mov ebx, eax
mov rsi, [ebx + thread.exec_s_max]
mov edi, stats_exec_s_max_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.exec_s_size]
mov edi, stats_exec_s_size_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.execute_calls]
add [rsp + thread.execute_calls], rsi
mov edi, stats_execute_calls_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.executed_mine]
add [rsp + thread.executed_mine], rsi
mov edi, stats_executed_mine_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.needy]
add [rsp + thread.needy], rsi
mov edi, stats_needy_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.sched_calls]
add [rsp + thread.sched_calls], rsi
mov edi, stats_sched_calls_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.sched_mine]
add [rsp + thread.sched_mine], rsi
mov edi, stats_sched_mine_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.alloc_s_max]
mov edi, stats_alloc_s_max_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.alloc_s_size]
mov edi, stats_alloc_s_size_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.allocate_calls]
add [rsp + thread.allocate_calls], rsi
mov edi, stats_allocate_calls_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.alloc_orphans]
add [rsp + thread.alloc_orphans], rsi
mov edi, stats_alloc_orphans_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.freed]
add [rsp + thread.freed], rsi
mov edi, stats_freed_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.freed_orphans]
add [rsp + thread.freed_orphans], rsi
mov edi, stats_freed_orphans_fmtstr
mov eax, 0
call printf
mov rsi, [ebx + thread.mmap]
add [rsp + thread.mmap], rsi
mov edi, stats_mmap_fmtstr
mov eax, 0
call printf
mov eax, mmap_tasks * task_size / 1024
mov rsi, [ebx + thread.mmap]
mul rsi
mov rsi, rdx
mov rdx, rax
mov edi, stats_mmap_kb_fmtstr
mov eax, 0
call printf
; Calculate the thread ID from the pointer to the thread struc.
mov eax, ebx
sub eax, threads_strucs
xor edx, edx
mov ebx, thread_aligned_size
div ebx
mov ebx, eax
sub ebx, 1
jnc .loop
mov esi, amount_threads
mov edi, stats_total_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.execute_calls]
mov edi, stats_execute_calls_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.executed_mine]
mov edi, stats_executed_mine_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.needy]
mov edi, stats_needy_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.sched_calls]
mov edi, stats_sched_calls_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.sched_mine]
mov edi, stats_sched_mine_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.allocate_calls]
mov edi, stats_allocate_calls_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.alloc_orphans]
mov edi, stats_alloc_orphans_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.freed]
mov edi, stats_freed_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.freed_orphans]
mov edi, stats_freed_orphans_fmtstr
mov eax, 0
call printf
mov rsi, [used_max]
mov edi, stats_used_max_fmtstr
mov eax, 0
call printf
mov rsi, [in_use]
mov edi, stats_in_use_fmtstr
mov eax, 0
call printf
mov rsi, [rsp + thread.mmap]
mov edi, stats_mmap_fmtstr
mov eax, 0
call printf
mov eax, mmap_tasks * task_size / 1024
mov rsi, [rsp + thread.mmap]
mul rsi
mov rsi, rdx
mov rdx, rax
mov edi, stats_mmap_kb_fmtstr
mov eax, 0
call printf
add rsp, thread_size
ret
section .data align=128
used_max: dq 0
in_use: dq 0
align 128, db 0 ; Not a serious necessity, but why not.
stats_tid_fmtstr: db `Thread %u:\n`,0
stats_exec_s_max_fmtstr: db ` exec_s max: %15lu\n`,0
stats_exec_s_size_fmtstr: db ` exec_s size: %15lu\n`,0
stats_execute_calls_fmtstr: db ` execute calls: %15lu\n`,0
stats_executed_mine_fmtstr: db ` executed mine: %15lu\n`,0
stats_needy_fmtstr: db ` needy: %15lu\n`,0
stats_sched_calls_fmtstr: db ` sched calls: %15lu\n`,0
stats_sched_mine_fmtstr: db ` sched mine: %15lu\n`,0
stats_alloc_s_max_fmtstr: db ` alloc_s max: %15lu\n`,0
stats_alloc_s_size_fmtstr: db ` alloc_s size: %15lu\n`,0
stats_allocate_calls_fmtstr: db ` allocate calls:%15lu\n`,0
stats_alloc_orphans_fmtstr: db ` alloc orphans: %15lu\n`,0
stats_freed_fmtstr: db ` freed: %15lu\n`,0
stats_freed_orphans_fmtstr: db ` freed orphans: %15lu\n`,0
stats_used_max_fmtstr: db ` used max: %15lu\n`,0
stats_in_use_fmtstr: db ` in use: %15lu\n`,0
stats_mmap_fmtstr: db ` mmaps: %15lu\n`,0
stats_mmap_kb_fmtstr: db ` KB mmaped: %lu,%lu\n`,0
stats_total_fmtstr: db `Totals of %u threads:\n`,0
|
oeis/083/A083694.asm | neoneye/loda-programs | 11 | 175546 | ; A083694: a(n)= 2*A002532(n).
; Submitted by <NAME>
; 0,2,4,18,56,202,684,2378,8176,28242,97364,335938,1158696,3997082,13787644,47560698,164059616,565922722,1952143524,6733900658,23228518936,80126541162,276395677004,953424059818,3288826504656
mov $3,1
lpb $0
sub $0,1
mov $2,$3
mul $2,6
add $3,$1
add $1,$2
lpe
mov $0,$1
div $0,3
|
Driver/Mouse/PS2/ps2.asm | steakknife/pcgeos | 504 | 245485 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1989 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: MOUSE DRIVER -- Any Mouse in IBM PS/2 port
FILE: ps2.asm
AUTHOR: <NAME>, September 29, 1989
ROUTINES:
Name Description
---- -----------
MouseDevInit Initialize device
MouseDevExit Exit device
MouseDevHandler Interrupt routine
MouseDevSetRate Routine to change rate.
REVISION HISTORY:
Name Date Description
---- ---- -----------
Adam 9/29/89 Initial revision
DESCRIPTION:
Device-dependent support for PS2 mouse port. The PS2 BIOS defines
a protocol that all mice connected to the port employ. Rather
than interpreting it ourselves, we trust the BIOS to be efficient
and just register a routine with it. Keeps the driver smaller and
avoids problems with incompatibility etc.
$Id: ps2.asm,v 1.1 97/04/18 11:47:57 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;
MOUSE_NUM_BUTTONS = 2 ; Most have only 2
MOUSE_MIN_BUTTONS = 1 ; Maybe something has 1...Better give us
; the state on the left button...
MOUSE_IM_MAX_BUTTONS = 3 ; This be all we can handle.
MOUSE_SEPARATE_INIT = 1 ; We use a separate Init resource
include ../mouseCommon.asm ; Include common definitions/code.
include Internal/interrup.def
include Internal/dos.def ; for equipment configuration...
include system.def
ifdef CHECK_MOUSE_AFTER_POWER_RESUME
include Internal/powerDr.def
include ui.def
CHECK_MOUSE_AFTER_POWER_RESUME_DELAY equ 6 ; # ticks
endif
LOG_EVENTS = FALSE
if LOG_EVENTS
%out EVENT LOGGING IS ON. ARE YOU SURE YOU WANT THAT?
endif
;------------------------------------------------------------------------------
; DEVICE STRINGS
;------------------------------------------------------------------------------
MouseExtendedInfoSeg segment lmem LMEM_TYPE_GENERAL
mouseExtendedInfo DriverExtendedInfoTable <
{}, ; lmem header added by Esp
length mouseNameTable, ; Number of supported devices
offset mouseNameTable,
offset mouseInfoTable
>
if PZ_PCGEOS
mouseNameTable lptr.char msps2
lptr.char 0 ; null-terminator
LocalDefString msps2 <'Microsoft PS/2 Mouse', 0>
mouseInfoTable MouseExtendedInfo \
0 ; msps2
else
mouseNameTable lptr.char ibmPS2Mouse,
int12Mouse,
auxPortMouse,
ps2StyleMouse,
logips2,
logiSeries2,
msps2,
logiPS2TrackMan
lptr.char 0 ; null-terminator
LocalDefString ibmPS2Mouse <'IBM PS/2 Mouse', 0>
LocalDefString int12Mouse <'Interrupt-12-type Mouse', 0>
LocalDefString auxPortMouse <'Auxiliary Port Mouse', 0>
LocalDefString ps2StyleMouse <'PS/2-style Mouse', 0>
LocalDefString logips2 <'Logitech PS/2 Mouse', 0>
LocalDefString logiSeries2 <'Logitech Series 2 Mouse', 0>
LocalDefString msps2 <'Microsoft PS/2 Mouse', 0>
LocalDefString logiPS2TrackMan <'Logitech TrackMan Portable (PS/2-style)', 0>
mouseInfoTable MouseExtendedInfo \
0, ; ibmPS2Mouse
0, ; int12Mouse
0, ; auxPortMouse
0, ; ps2StyleMouse
0, ; logips2
0, ; logiSeries2
0, ; msps2
0 ; logiPS2TrackMan
ifdef CHECK_MOUSE_AFTER_POWER_RESUME
;
; The following strings actually have nothing to do with the driver extended
; info. They are placed here only because they need to be localizable and
; need to be in an lmem resource. Creating a separate lmem resource for them
; seems overkill, so we put them in MouseExtendedInfoSeg to save some bytes.
;
LocalDefString mouseNotConnectedErrorStr <'The mouse is not connected. Please turn off your PC, re-connect the mouse, then turn on the PC again. (Or, you can press the Enter key to continue using Ensemble without a mouse.)', 0>
localize "This is the string that is displayed when the mouse is not connected during power-on. The user must power-off and on for the mouse to work."
LocalDefString mouseNotConnectedErrorReconnectStr <'The mouse is not connected. Please re-connect the mouse and then press the Enter key. (Or, you can press the Esc key to continue using Ensemble without a mouse.)', 0>
localize "This is the string that is displayed when the mouse is not connected during power resume. The user doesn't need to power-off and on for the mouse to work again."
endif ; CHECK_MOUSE_AFTER_POWER_RESUME
endif
MouseExtendedInfoSeg ends
;------------------------------------------------------------------------------
; VARIABLES/DATA/CONSTANTS
;------------------------------------------------------------------------------
idata segment
;
; All the mouse BIOS calls are through interrupt 15h, function c2h.
; All functions return CF set on error, ah = MouseStatus
;
MOUSE_ENABLE_DISABLE equ 0c200h ; Enable or disable the mouse.
; BH = 0 to disable, 1 to enable
MOUSE_RESET equ 0c201h ; Reset the mouse.
MAX_NUM_RESETS equ 3 ; # times we will send MOUSE_RESET
; command
MOUSE_SET_RATE equ 0c202h ; Set sample rate:
MOUSE_RATE_10 equ 0
MOUSE_RATE_20 equ 1
MOUSE_RATE_40 equ 2
MOUSE_RATE_60 equ 3
MOUSE_RATE_80 equ 4
MOUSE_RATE_100 equ 5
MOUSE_RATE_200 equ 6
MOUSE_SET_RESOLUTION equ 0c203h ; Set device resolution BH =
MOUSE_RES_1_PER_MM equ 0 ; 1 count per mm
MOUSE_RES_2_PER_MM equ 1 ; 2 counts per mm
MOUSE_RES_4_PER_MM equ 2 ; 4 counts per mm
MOUSE_RES_8_PER_MM equ 3 ; 8 counts per mm
MOUSE_GET_TYPE equ 0c204h ; Get device ID.
MOUSE_INIT equ 0c205h ; Set interface parameters
; BH = # bytes per packet.
MOUSE_EXTENDED_CMD equ 0c206h ; Extended command. BH =
MOUSE_EXTC_STATUS equ 0 ; Get device status
MOUSE_EXTC_SINGLE_SCALE equ 1 ; Set scaling to 1:1
MOUSE_EXTC_DOUBLE_SCALE equ 2 ; Set scaling to 2:1
MOUSE_SET_HANDLER equ 0c207h ; Set mouse handler.
; ES:BX is address of routine
MouseStatus etype byte
MS_SUCCESSFUL enum MouseStatus, 0
MS_INVALID_FUNC enum MouseStatus, 1
MS_INVALID_INPUT enum MouseStatus, 2
MS_INTERFACE_ERROR enum MouseStatus, 3
MS_NEED_TO_RESEND enum MouseStatus, 4
MS_NO_HANDLER_INSTALLED enum MouseStatus, 5
mouseRates byte 10, 20, 40, 60, 80, 100, 200, 255
MOUSE_NUM_RATES equ size mouseRates
mouseRateCmds byte MOUSE_RATE_10, MOUSE_RATE_20, MOUSE_RATE_40
byte MOUSE_RATE_60, MOUSE_RATE_80, MOUSE_RATE_100
byte MOUSE_RATE_200, MOUSE_RATE_200
idata ends
udata segment
ifdef CHECK_MOUSE_AFTER_POWER_RESUME
errorDialogOnScreen BooleanByte BB_FALSE
endif
udata ends
MDHStatus record
MDHS_Y_OVERFLOW:1, ; Y overflow
MDHS_X_OVERFLOW:1, ; X overflow
MDHS_Y_NEGATIVE:1, ; Y delta is negative (just need to
; sign-extend, as delta is already in
; single-byte two's complement form)
MDHS_X_NEGATIVE:1, ; X delta is negative
MDHS_MUST_BE_ONE:1=1,
MDHS_MIDDLE_DOWN:1, ; Middle button is down
MDHS_RIGHT_DOWN:1, ; Right button is down
MDHS_LEFT_DOWN:1, ; Left button is down
MDHStatus end
if LOG_EVENTS
udata segment
xdeltas byte 1024 dup (?)
ydeltas byte 1024 dup (?)
statii MDHStatus 1024 dup (?)
index word 0
udata ends
endif
;------------------------------------------------------------------------------
; INITIALIZATION/EXIT CODE
;
;------------------------------------------------------------------------------
Resident segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseDevHandler
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: HandleMem the receipt of an interrupt
CALLED BY: BIOS
PASS: ON STACK:
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
Overflow is ignored.
For delta Y, positive => up, which is the opposite of what we think
KNOWN BUGS/SIDE EFFECTS/IDEAS:
Some BIOSes rely on DS not being altered, while others do not.
To err on the side of safety, we save everything we biff.
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 10/12/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MouseDevHandler proc far deltaZ:sbyte,
:byte, ; For future expansion
deltaY:sbyte,
:byte, ; FFE
deltaX:sbyte,
:byte, ; FFE
status:MDHStatus
uses ds, ax, bx, cx, dx, si, di
.enter
;
; Prevent switch while sending
;
call SysEnterInterrupt
if LOG_EVENTS
segmov ds, dgroup, bx
mov bx, ds:[index]
mov al, ss:[deltaY]
mov ds:ydeltas[bx], al
mov al, ss:[deltaX]
mov ds:xdeltas[bx], al
mov al, ss:[status]
mov ds:statii[bx], al
inc bx
andnf bx, length ydeltas - 1
mov ds:[index], bx
endif
;
; The deltas are already two's-complement, so just sign extend them
; ourselves.
; XXX: verify sign against bits in status byte to confirm its validity?
; what if overflow bit is set?
;
mov al, ss:[deltaY]
cbw
xchg dx, ax ; (1-byte inst)
mov al, ss:[deltaX]
cbw
xchg cx, ax ; (1-byte inst)
;
; Fetch the status, copying the middle and right button bits
; into BH.
;
mov al, ss:[status]
test al, mask MDHS_Y_OVERFLOW or mask MDHS_X_OVERFLOW
jnz packetDone ; if overflow, drop the packet on the
; floor, since the semantics for such
; an event are undefined...
mov bh, al
and bh, 00000110b
;
; Make sure the packet makes sense by checking the ?_NEGATIVE bits
; against the actual signs of their respective deltas. If the two
; don't match (as indicated by the XOR of the sign bit of the delta
; with the ?_NEGATIVE bit resulting in a one), then hooey this packet.
;
shl al
shl al
tst dx
lahf
xor ah, al
js packetDone
shl al
tst cx
lahf
xor ah, al
js packetDone
;
; Mask out all but the left button and merge it into the
; middle and right buttons that are in BH. We then have
; 0000LMR0
; in BH, which is one bit off from what we need (and also
; the wrong polarity), so shift it right once and complement
; the thing.
;
and al, mask MDHS_LEFT_DOWN shl 3
or bh, al
shr bh, 1
not bh
;
; Make delta Y be positive if going down, rather than
; positive if up, as the BIOS provides it.
;
neg dx
;
; Point ds at our data for MouseSendEvents
;
mov ax, segment dgroup
mov ds, ax
;
; Registers now all loaded properly -- send the event.
;
call MouseSendEvents
;
; Allow context switches.
;
packetDone:
call SysExitInterrupt
;
; Recover and return.
;
.leave
ret
MouseDevHandler endp
Init segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseDevInit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Turn on the device.
CALLED BY: MouseSetDevice, MouseCheckDevAfterResumeStep3
PASS: nothing
RETURN: CF set on error
ah = MouseStatus
DESTROYED: al, bx, es
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ayuen 10/17/00 Initial version (moved code from
MouseSetDevice)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MouseDevInit proc far
call SysLockBIOS
;
; These are all done in this order by the Microsoft PS/2 mouse
; driver. I suspect the really important one is setting the
; report rate to 60, else RESEND bytes get inserted into the
; packet stream...
;
mov ax, MOUSE_SET_RESOLUTION
mov bh, MOUSE_RES_8_PER_MM
int 15h
segmov es, <segment Resident>
mov bx, offset Resident:MouseDevHandler
mov ax, MOUSE_SET_HANDLER
int 15h
mov ax, MOUSE_ENABLE_DISABLE
mov bh, 1 ; Enable it please
int 15h
mov ax, MOUSE_EXTENDED_CMD
mov bh, MOUSE_EXTC_SINGLE_SCALE
int 15h
mov ax, MOUSE_SET_RATE
mov bh, MOUSE_RATE_60
int 15h
call SysUnlockBIOS
ret
MouseDevInit endp
Init ends
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseDevExit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Finish things out
CALLED BY: MouseExit
PASS: DS=ES=CS
RETURN: Carry clear
DESTROYED: BX, AX
PSEUDO CODE/STRATEGY:
Just calls the serial driver to close down the port
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 5/20/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MouseDevExit proc near
ifdef CHECK_MOUSE_AFTER_POWER_RESUME
;
; Unhook from power driver for on/off notification.
;
push di
mov di, DR_POWER_ON_OFF_UNREGISTER
call OnOffNotifyRegUnreg
pop di
endif ; CHECK_MOUSE_AFTER_POWER_RESUME
;
; Disable the mouse by setting the handler to 0
; XXX: How can we restore it? Do we need to?
;
mov ax, MOUSE_ENABLE_DISABLE
mov bh, 0 ; Disable it please
int 15h
clr bx
mov es, bx
mov ax, MOUSE_SET_HANDLER
int 15h
ret
MouseDevExit endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseSetDevice
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Turn on the device.
CALLED BY: DRE_SET_DEVICE
PASS: dx:si = pointer to null-terminated device name string
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 9/27/90 Initial version
ayuen 10/17/00 Moved most of the code to MouseDevInit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MouseSetDevice proc near uses es, bx, ax
.enter
call MouseDevInit
ifdef CHECK_MOUSE_AFTER_POWER_RESUME
;
; Hook up to the power driver, so that we get on/off notified on a
; power resume.
;
push di
mov di, DR_POWER_ON_OFF_NOTIFY
call OnOffNotifyRegUnreg
pop di
endif ; CHECK_MOUSE_AFTER_POWER_RESUME
.leave
ret
MouseSetDevice endp
ifdef CHECK_MOUSE_AFTER_POWER_RESUME
Init segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OnOffNotifyRegUnreg
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Register/unregister with the PM driver for on/off notification
CALLED BY: MouseSetDevice, MouseDevExit
PASS: di = DR_POWER_ON_OFF_NOTIFY / DR_POWER_ON_OFF_UNREGISTER
RETURN: CF set if driver not present or too many callbacks registered
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ayuen 10/16/00 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
OnOffNotifyRegUnreg proc far
uses ds
.enter
pusha
mov ax, GDDT_POWER_MANAGEMENT
call GeodeGetDefaultDriver ; ax = driver handle
tst ax
stc ; assume not present
jz afterRegister ; => driver not present
mov_tr bx, ax ; bx = driver handle
call GeodeInfoDriver ; ds:si = DriverInfoStruct
mov dx, segment MouseCheckDevAfterResume
mov cx, offset MouseCheckDevAfterResume
call ds:[si].DIS_strategy ; CF set on error
afterRegister:
popa
.leave
ret
OnOffNotifyRegUnreg endp
Init ends
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseCheckDevAfterResume
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Callback routine for on/off notification
CALLED BY: Power driver
PASS: ax = PowerNotifyChange
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
Here's the scenario:
If the mouse is not connected, both MOUSE_ENABLE_DISABLE(BH=1) and
MOUSE_GET_TYPE return MS_INTERACE_ERROR.
If the mouse was disconnected and then re-connected, it defaults to
disabled state. At this point Both MOUSE_GET_TYPE and
MOUSE_ENABLE_DISABLE(BH=1) return no error.
We can use MOUSE_GET_TYPE to check if the mouse is connected without
touching its state, and inform the user if it's not. But if we find
that it is connected, we then have no way to check if it is enabled or
not. Then we still have to enable it again to make sure it is
enabled.
So, to simplify things, we just re-eanble the mouse and check for any
errors. The downside is that we will be re-enabling an enabled mouse
which *may* re-initialize the mouse (I'm not sure), but I think that's
okay.
REVISION HISTORY:
Name Date Description
---- ---- -----------
ayuen 10/16/00 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MouseCheckDevAfterResume proc far
uses es
.enter
pusha
CheckHack <PNC_POWER_TURNING_ON eq 1>
CheckHack <PNC_POWER_TURNED_OFF_AND_ON eq 2>
CheckHack <PowerNotifyChange eq 4>
or ax, ax
jp done ; => _SHUTTING_OFF or _AUTO_OFF
;
; It seems like If we try to enable the mouse right away during a
; resume notification, it doesn't always work. Sometimes BIOS
; returns MS_INTERFACE_ERROR and the mouse acts funny afterwards.
; Delaying the enable calls seems to solve the problem. So we set a
; timer to do it on the UI thread later. 0.1 sec seems to work fine.
;
; We can't call BIOS in a timer routine because it'll be in interrupt
; time. So we use the UI thread to call our routine to do the work.
; But then we can't use MSG_PROCESS_CALL_ROUTINE to set up an event
; timer either, because there's no way to pass parameters to a timer
; event. So, we have to use a routine timer to send the message to
; the UI thread to call our routine. On well ...
;
mov al, TIMER_ROUTINE_ONE_SHOT
mov bx, segment MouseCheckDevAfterResumeStep2
mov si, offset MouseCheckDevAfterResumeStep2
mov cx, CHECK_MOUSE_AFTER_POWER_RESUME_DELAY
mov bp, handle 0
call TimerStartSetOwner
; Timer is short enough that we don't need to worry about stopping it
; on the next resume or on shutdown.
done:
popa
.leave
ret
MouseCheckDevAfterResume endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseCheckDevAfterResumeStep2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check the mouse after a power resume.
CALLED BY: MouseCheckDevAfterResume via TimerStartSetOwner
PASS: nothing
RETURN: nothing
DESTROYED: ax, bx, dx, di, bp (everything allowed)
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ayuen 10/17/00 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MouseCheckDevAfterResumeStep2 proc far
;
; Can't call BIOS during interrupt time, so do it on the UI thread.
;
mov ax, SGIT_UI_PROCESS
call SysGetInfo ;ax = ui handle
mov_tr bx, ax
push vseg MouseCheckDevAfterResumeStep3
push offset MouseCheckDevAfterResumeStep3
mov bp, sp ; ss:bp = PCRP_address
mov ax, MSG_PROCESS_CALL_ROUTINE
mov di, mask MF_STACK or mask MF_FORCE_QUEUE
mov dx, size ProcessCallRoutineParams
call ObjMessage
popdw axax ; discard PCRP_address
ret
MouseCheckDevAfterResumeStep2 endp
Init segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseCheckDevAfterResumeStep3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check the mouse after a power resume.
CALLED BY: MouseCheckDevAfterResumeStep2 via MSG_PROCESS_CALL_ROUTINE
PASS: nothing
RETURN: nothing
DESTROYED: ax, bp, ds (everything allowed)
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ayuen 10/17/00 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
triggerTable StandardDialogResponseTriggerTable <2>
StandardDialogResponseTriggerEntry <NULL, IC_OK>
StandardDialogResponseTriggerEntry <NULL, IC_DISMISS>
MouseCheckDevAfterResumeStep3 proc far
checkAgain:
call MouseDevInit ; CF set on error, ah = MouseStatus
jnc done
;
; If the user hits On/Off button again while the dialog is still on
; screen, this routine will be called on the UI thread again. This
; is because when the thread is blocked in UserStandardDialogOptr,
; it can actually watch its message queue and keeps on processing
; messages. So this routine can be called again while the first call
; is still blocked inside UserStandardDialogOptr. In order to
; prevent putting up two error dialogs on screen, we keep a flag
; around, and skip putting up a dialog if one is already on screen.
;
segmov ds, dgroup
tst ds:[errorDialogOnScreen]
jnz done ; => already on screen
dec ds:[errorDialogOnScreen]; BB_TRUE
;
; Display the dialog.
;
sub sp, size StandardDialogOptrParams
mov bp, sp
mov ss:[bp].SDOP_customFlags, CustomDialogBoxFlags \
<1, CDT_ERROR, GIT_MULTIPLE_RESPONSE, >
mov ss:[bp].SDOP_customString.handle, \
handle mouseNotConnectedErrorReconnectStr
mov ss:[bp].SDOP_customString.chunk, \
offset mouseNotConnectedErrorReconnectStr
clr ax ; for czr below
czr ax, ss:[bp].SDOP_stringArg1.handle, \
ss:[bp].SDOP_stringArg2.handle, \
ss:[bp].SDOP_helpContext.segment
mov ss:[bp].SDOP_customTriggers.segment, cs
mov ss:[bp].SDOP_customTriggers.offset, offset triggerTable
call UserStandardDialogOptr ; ax = InteractionCommand
inc ds:[errorDialogOnScreen]; BB_FALSE
;
; If the user pressed Enter, check the mouse again.
;
cmp ax, IC_OK
je checkAgain
done:
ret
MouseCheckDevAfterResumeStep3 endp
Init ends
endif ; CHECK_MOUSE_AFTER_POWER_RESUME
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseTestDevice
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if the device specified is present.
CALLED BY: DRE_TEST_DEVICE
PASS: dx:si = null-terminated name of device (ignored, here)
RETURN: ax = DevicePresent enum
carry set if string invalid, clear otherwise
DESTROYED: di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 9/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MouseTestDevice proc near uses bx, es, cx
.enter
mov ax, BIOS_DATA_SEG
mov es, ax
test es:[BIOS_EQUIPMENT], mask EC_POINTER
jz notPresent
mov ax, MOUSE_INIT ; Assume 3-byte packets
mov bh, 3
int 15h
mov cx, MAX_NUM_RESETS ;# times we will resend this
; command
resetLoop:
mov ax, MOUSE_RESET
int 15h
jnc noerror ;If no error, branch
cmp ah, MS_NEED_TO_RESEND
jne notPresent ;If not "resend" error, just exit with
; carry set.
loop resetLoop ;
notPresent:
ifdef CHECK_MOUSE_AFTER_POWER_RESUME
call DisplayMouseNotConnectedDialog
endif ; CHECK_MOUSE_AFTER_POWER_RESUME
mov ax, DP_NOT_PRESENT
jmp done
noerror:
mov ax, DP_PRESENT
done:
clc
.leave
ret
MouseTestDevice endp
ifdef CHECK_MOUSE_AFTER_POWER_RESUME
Init segment
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DisplayMouseNotConnectedDialog
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Display the mouse not connected error dialog.
CALLED BY: MouseTestDevice
PASS: nothing
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ayuen 10/19/00 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DisplayMouseNotConnectedDialog proc far
pusha
sub sp, size StandardDialogOptrParams
mov bp, sp
mov ss:[bp].SDOP_customFlags, CustomDialogBoxFlags \
<1, CDT_ERROR, GIT_NOTIFICATION, >
mov ss:[bp].SDOP_customString.handle, \
handle mouseNotConnectedErrorStr
mov ss:[bp].SDOP_customString.chunk, \
offset mouseNotConnectedErrorStr
clr ax ; for czr below
czr ax, ss:[bp].SDOP_stringArg1.handle, \
ss:[bp].SDOP_stringArg2.handle, \
ss:[bp].SDOP_helpContext.segment
call UserStandardDialogOptr
popa
ret
DisplayMouseNotConnectedDialog endp
Init ends
endif ; CHECK_MOUSE_AFTER_POWER_RESUME
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MouseDevSetRate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the report rate for the mouse
CALLED BY: MouseSetRate
PASS: CX = index of rate to set
RETURN: carry clear if successful
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 10/12/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MouseDevSetRate proc near
push ax, bx, cx, si
mov si, cx
mov bh, ds:mouseRateCmds[si]
mov ax, MOUSE_SET_RATE
int 15h
pop ax, bx, cx, si
ret
MouseDevSetRate endp
Resident ends
end
|
util/menus/yesno.asm | olifink/smsqe | 0 | 243787 | <gh_stars>0
; yes/no selection 1991 <NAME> V001
section utility
include dev8_keys_thg
include dev8_mac_xref
include dev8_keys_menu
xdef mu_yesno
;+++
; This routine pops up a menu, displays a message and waits for a yes or
; no user selection.
;
; Entry Exit
; D0.l error, 0 or +1 for ESC
; D1.l origin or -1 preserved
; D2.b colourways preserved
; D3.l set if default yes 0 no, 1 yes
; A0 window title preserved
; A2 window message preserved
;---
mu_yesno
stk.frm equ $44
yno_reg reg d4/a0-a2/a4-a5
movem.l yno_reg,-(sp)
sub.l #stk.frm,sp
move.l sp,a5 ; prepare workspace
movem.l d1-d3,-(sp)
move.l #'ITSL',d2
xbsr ut_usmen
movem.l (sp)+,d1-d3
bne.s yno_error ; cannot use menu
move.l a1,a4 ; that's the Thing
move.l #(thp.call+thp.str)<<16,d4
move.l d4,is_mentp(a5)
move.l a0,is_mennm(a5) ; window title
move.l d4,is_prmtp(a5)
move.l a2,is_prmpt(a5) ; request string
xlea met_no,a0
xlea met_yes,a2
tst.b d3
beq.s def_no
exg a0,a2
def_no
move.l d4,is_item1-4(a5)
move.l a0,is_item1(a5) ; first item
move.l d4,is_item2-4(a5)
move.l a2,is_item2(a5) ; second item
clr.l is_item3(a5) ; no third item
swap d1
move.l d1,is_xpos(a5) ; x-origin
swap d1
move.l d1,is_ypos(a5) ; y-origin
and.l #$ff,d2 ; only low byte
move.l d2,is_mainc(a5) ; main colourway
move.l #(thp.ret+thp.ulng)<<16,is_itnum-4(a5)
lea $40(a5),a0
move.l a0,is_itnum(a5)
move.l a5,a1 ; the parameter table
jsr thh_code(a4) ; get filename via menu
move.b d3,d2 ; check default
move.l $40(a5),d3 ; return parameter
subq.b #1,d3 ; this gives 0 and 1
tst.b d2 ; right order?
beq.s no_error
bchg #0,d3 ; toggle state
no_error
xbsr ut_frmen ; free menu
yno_error
add.l #stk.frm,sp ; adjust stack
movem.l (sp)+,yno_reg
tst.l d0
rts
end
|
programs/oeis/191/A191489.asm | karttu/loda | 1 | 174215 | ; A191489: Number of compositions of even natural numbers into 6 parts <= n.
; 1,32,365,2048,7813,23328,58825,131072,265721,500000,885781,1492992,2413405,3764768,5695313,8388608,12068785,17006112,23522941,32000000,42883061,56689952,74017945,95551488,122070313,154457888,193710245,240945152,297411661,364500000,443751841,536870912,645733985,772402208,919132813,1088391168,1282863205,1505468192,1759371881,2048000000,2375052121,2744515872,3160681525,3628156928,4151882813,4737148448,5389607665,6115295232,6920643601,7812500000,8798143901,9885304832,11082180565,12397455648,13840320313,15420489728,17148223625,19034346272,21090266821,23328000000,25760187181,28400117792,31261751105,34359738368,37709445313,41326975008,45229191085,49433741312,53959081541,58824500000,64050141961,69657034752,75667113145,82103245088,88989257813,96349964288,104211190045,112599800352,121543727761,131072000000,141214768241,152003335712,163470186685,175649015808,188574757813,202283617568,216813100505,232202043392,248490645481,265720500000,283934626021,303177500672,323495091725,344934890528,367545945313,391378894848,416486002465,442921190432,470740074701,500000000000,530760075301,563081209632,597026148265,632659509248,670047820313,709259556128,750365175925,793437161472,838550055421,885780500000,935207276081,986911342592,1040975876305,1097486311968,1156530382813,1218198161408,1282582100885,1349777076512,1419880427641,1492992000000,1569214188361,1648651979552,1731412995845,1817607538688,1907348632813,2000752070688,2097936457345,2199023255552,2304136831361,2413404500000,2526956572141,2644926400512,2767450426885,2894668229408,3026722570313,3163759443968,3305928125305,3453381218592,3606274706581,3764768000000,3929023987421,4099209085472,4275493289425,4458050224128,4647057195313,4842695241248,5045149184765,5254607685632,5471263293301,5695312500000,5926955794201,6166397714432,6413846903465,6669516162848,6933622507813,7206387222528,7488035915725,7778798576672,8078909631521,8388608000000,8708137152481,9037745167392,9377684789005,9728213485568,10089593507813,10462091947808,10845980798185,11241537011712,11649042561241,12068784500000,12501055022261,12946151524352,13404376666045,13876038432288,14361450195313,14860930777088,15374804512145,15903401310752,16447056722461,17006112000000,17580914163541,18171816065312,18779176454585,19403360043008,20044737570313,20703685870368,21380587937605,22075832993792,22789816555181,23522940500000,24275613136321,25048249270272,25841270274625,26655104157728,27490185632813,28346956187648,29225864154565,30127364780832,31051920299401,32000000000000,32972080300601,33968644819232,34990184446165,36037197416448,37110189382813,38209673488928,39336170443025,40490208591872,41672323995121,42883060500000,44122969816381,45392611592192,46692553489205,48023371259168,49385648820313,50779978334208,52206960282985,53667203546912,55161325482341,56689952000000,58253717643661,59853265669152,61489248123745,63162325925888,64873168945313,66622456083488,68410875354445,70239123965952,72107908401061,74017944500000,75969957542441,77964682330112,80002863269785,82085254456608,84212619757813,86385732896768,88605377537405,90872347368992,93187446191281,95551488000000,97965297072721,100429708055072,102945566047325,105513726691328,108135056257813,110810431734048,113540740911865,116326882476032,119169766093001,122070312500000
mov $1,1
add $1,$0
pow $1,6
add $1,1
div $1,2
|
libsrc/enterprise/exos_reset_font.asm | RC2014Z80/z88dk | 8 | 101370 | ;
; Enterprise 64/128 specific routines
; by <NAME>, 2011
;
; exos_reset_font();
;
;
; $Id: exos_reset_font.asm,v 1.4 2016-06-19 20:17:32 dom Exp $
;
SECTION code_clib
PUBLIC exos_reset_font
PUBLIC _exos_reset_font
INCLUDE "enterprise.def"
exos_reset_font:
_exos_reset_font:
; __FASTCALL_
ld a,l ; channel
ld b,FN_FONT ; special fn code
rst 30h
defb 11 ; call special device dependent exos functions
ld h,0
ld l,a
ret
|
contrib/ayacc/src/ayacc_file_names.ads | faelys/gela-asis | 4 | 17589 | <filename>contrib/ayacc/src/ayacc_file_names.ads
-- $Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/file_names.a,v 1.2 88/11/28 13:38:59 arcadia Exp $
-- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were <NAME> and <NAME>.
-- Enhancements were made by <NAME>.
--
-- Send requests for ayacc information to <EMAIL>
-- Send bug reports for ayacc to <EMAIL>
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : file_names.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:29:16
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxfile_names.ada
-- $Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/file_names.a,v 1.2 88/11/28 13:38:59 arcadia Exp $
-- $Log: file_names.a,v $
--Revision 1.2 88/11/28 13:38:59 arcadia
--Modified Get_Unit_Name function to accept legal Ada identifiers.
--
--Revision 1.1 88/08/08 12:11:56 arcadia
--Initial revision
--
-- Revision 0,2 88/03/16
-- Set file names modified to include a file extension parameter.
-- Revision 0.1 86/04/01 15:04:19 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:36:22 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by <NAME> and <NAME>.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
-- The collection of all file names used by Ayacc --
with Ada.Characters.Handling; use Ada.Characters.Handling;
package Ayacc_File_Names is
procedure Set_File_Names(Input_File, Extension: in String);
-- Sets the initial value of the file names
-- according to the INPUT_FILE.
function Get_Source_File_Name return String;
function Get_Out_File_Name return String;
function Get_Verbose_File_Name return String;
function Get_Template_File_Name return String;
function Get_Actions_File_Name return String;
function Get_Shift_Reduce_File_Name return String;
function Get_Goto_File_Name return String;
function Get_Tokens_File_Name return String;
-- UMASS CODES :
function Get_Error_Report_File_Name return String;
function Get_Listing_File_Name return String;
-- END OF UMASS CODES.
function Get_C_Lex_File_Name return String;
function Get_Include_File_Name return String;
--RJS ==========================================
function C_Lex_Unit_Name return String;
function Goto_Tables_Unit_Name return String;
function Shift_Reduce_Tables_Unit_Name return String;
function Tokens_Unit_Name return String;
function Main_Unit_Name return String;
-- UMASS CODES :
function Error_Report_Unit_Name return String;
-- END OF UMASS CODES.
--RJS ==========================================
Illegal_File_Name: exception;
-- Raised if the file name does not end with ".y"
end Ayacc_File_Names;
|
sw/552tests/rand_simple/t_3_jal.asm | JPShen-UWM/ThreadKraken | 1 | 28334 | // seed 3
jal 4 // icount 0
nop // icount 1
nop // icount 2
jal 10 // icount 3
nop // icount 4
nop // icount 5
nop // icount 6
nop // icount 7
nop // icount 8
jal 20 // icount 9
nop // icount 10
nop // icount 11
nop // icount 12
nop // icount 13
nop // icount 14
nop // icount 15
nop // icount 16
nop // icount 17
nop // icount 18
nop // icount 19
jal 22 // icount 20
nop // icount 21
nop // icount 22
nop // icount 23
nop // icount 24
nop // icount 25
nop // icount 26
nop // icount 27
nop // icount 28
nop // icount 29
nop // icount 30
nop // icount 31
jal 2 // icount 32
nop // icount 33
jal 8 // icount 34
nop // icount 35
nop // icount 36
nop // icount 37
nop // icount 38
jal 4 // icount 39
nop // icount 40
nop // icount 41
jal 2 // icount 42
nop // icount 43
jal 2 // icount 44
nop // icount 45
jal 12 // icount 46
nop // icount 47
nop // icount 48
nop // icount 49
nop // icount 50
nop // icount 51
nop // icount 52
jal 12 // icount 53
nop // icount 54
nop // icount 55
nop // icount 56
nop // icount 57
nop // icount 58
nop // icount 59
jal 32 // icount 60
nop // icount 61
nop // icount 62
nop // icount 63
nop // icount 64
nop // icount 65
nop // icount 66
nop // icount 67
nop // icount 68
nop // icount 69
nop // icount 70
nop // icount 71
nop // icount 72
nop // icount 73
nop // icount 74
nop // icount 75
nop // icount 76
jal 14 // icount 77
nop // icount 78
nop // icount 79
nop // icount 80
nop // icount 81
nop // icount 82
nop // icount 83
nop // icount 84
jal 6 // icount 85
nop // icount 86
nop // icount 87
nop // icount 88
jal 28 // icount 89
nop // icount 90
nop // icount 91
nop // icount 92
nop // icount 93
nop // icount 94
nop // icount 95
nop // icount 96
nop // icount 97
nop // icount 98
nop // icount 99
nop // icount 100
nop // icount 101
nop // icount 102
nop // icount 103
jal 14 // icount 104
nop // icount 105
nop // icount 106
nop // icount 107
nop // icount 108
nop // icount 109
nop // icount 110
nop // icount 111
halt // icount 112
|
Cubical/Data/SumFin.agda | limemloh/cubical | 0 | 8565 | <filename>Cubical/Data/SumFin.agda
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.SumFin where
open import Cubical.Data.SumFin.Base public
|
test/Fail/Sections-14.agda | shlevy/agda | 1,989 | 5321 | <reponame>shlevy/agda
∙_ : Set₁ → Set₁
∙ X = X
Foo : Set
Foo = ∙ Set
|
archive/agda-3/src/Oscar/Class/HasEquivalence.agda | m0davis/oscar | 0 | 2109 | <gh_stars>0
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.IsEquivalence
open import Oscar.Data.𝟙
module Oscar.Class.HasEquivalence where
module _
{𝔬} (𝔒 : Ø 𝔬) ℓ
where
𝔥asEquivalence : Rℭlass 𝟙
𝔥asEquivalence = ∁ (𝔒 → 𝔒 → Ø ℓ) IsEquivalence
open Rℭlass 𝔥asEquivalence using () renaming (GET-CLASS to HasEquivalence) public
module _
{𝔬} (𝔒 : Ø 𝔬) {ℓ}
where
open Rℭlass (𝔥asEquivalence 𝔒 ℓ) using () renaming (GET-METHOD to Equivalence[_]) public
infix 4 ≈-syntax
≈-syntax = Equivalence[_]
syntax ≈-syntax 𝔒 x y = x ≈[ 𝔒 ] y
module _
{𝔬} {𝔒 : Ø 𝔬} {ℓ}
where
open Rℭlass (𝔥asEquivalence 𝔒 ℓ) using () renaming (GET-METHOD to Equivalence) public
infix 4 _≈_
_≈_ = Equivalence
|
oeis/072/A072262.asm | neoneye/loda-programs | 11 | 97939 | <gh_stars>10-100
; A072262: a(n) = 4*a(n-1) + 1, a(1)=11.
; 11,45,181,725,2901,11605,46421,185685,742741,2970965,11883861,47535445,190141781,760567125,3042268501,12169074005,48676296021,194705184085,778820736341,3115282945365,12461131781461,49844527125845,199378108503381,797512434013525,3190049736054101,12760198944216405,51040795776865621,204163183107462485,816652732429849941,3266610929719399765,13066443718877599061,52265774875510396245,209063099502041584981,836252398008166339925,3345009592032665359701,13380038368130661438805,53520153472522645755221
mov $1,4
pow $1,$0
div $1,3
mul $1,34
add $1,11
mov $0,$1
|
thirdparty/ffmpeg/libavcodec/x86/lossless_videoencdsp.asm | yashrajsingh1998/ApraPipes1 | 2,151 | 161430 | ;************************************************************************
;* SIMD-optimized lossless video encoding functions
;* Copyright (c) 2000, 2001 <NAME>
;* Copyright (c) 2002-2004 <NAME> <<EMAIL>>
;*
;* MMX optimization by <NAME> <<EMAIL>>
;* Conversion to NASM format by Tiancheng "<NAME> <<EMAIL>>
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg 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.
;*
;* FFmpeg 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 FFmpeg; if not, write to the Free Software
;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;******************************************************************************
%include "libavutil/x86/x86util.asm"
cextern pb_80
SECTION .text
; void ff_diff_bytes(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
; intptr_t w);
%macro DIFF_BYTES_PROLOGUE 0
%if ARCH_X86_32
cglobal diff_bytes, 3,5,2, dst, src1, src2
%define wq r4q
DECLARE_REG_TMP 3
mov wq, r3mp
%else
cglobal diff_bytes, 4,5,2, dst, src1, src2, w
DECLARE_REG_TMP 4
%endif ; ARCH_X86_32
%define i t0q
%endmacro
; labels to jump to if w < regsize and w < 0
%macro DIFF_BYTES_LOOP_PREP 2
mov i, wq
and i, -2 * regsize
js %2
jz %1
add dstq, i
add src1q, i
add src2q, i
neg i
%endmacro
; mov type used for src1q, dstq, first reg, second reg
%macro DIFF_BYTES_LOOP_CORE 4
%if mmsize != 16
mov%1 %3, [src1q + i]
mov%1 %4, [src1q + i + regsize]
psubb %3, [src2q + i]
psubb %4, [src2q + i + regsize]
mov%2 [dstq + i], %3
mov%2 [regsize + dstq + i], %4
%else
; SSE enforces alignment of psubb operand
mov%1 %3, [src1q + i]
movu %4, [src2q + i]
psubb %3, %4
mov%2 [dstq + i], %3
mov%1 %3, [src1q + i + regsize]
movu %4, [src2q + i + regsize]
psubb %3, %4
mov%2 [regsize + dstq + i], %3
%endif
%endmacro
%macro DIFF_BYTES_BODY 2 ; mov type used for src1q, for dstq
%define regsize mmsize
.loop_%1%2:
DIFF_BYTES_LOOP_CORE %1, %2, m0, m1
add i, 2 * regsize
jl .loop_%1%2
.skip_main_%1%2:
and wq, 2 * regsize - 1
jz .end_%1%2
%if mmsize > 16
; fall back to narrower xmm
%define regsize (mmsize / 2)
DIFF_BYTES_LOOP_PREP .setup_loop_gpr_aa, .end_aa
.loop2_%1%2:
DIFF_BYTES_LOOP_CORE %1, %2, xm0, xm1
add i, 2 * regsize
jl .loop2_%1%2
.setup_loop_gpr_%1%2:
and wq, 2 * regsize - 1
jz .end_%1%2
%endif
add dstq, wq
add src1q, wq
add src2q, wq
neg wq
.loop_gpr_%1%2:
mov t0b, [src1q + wq]
sub t0b, [src2q + wq]
mov [dstq + wq], t0b
inc wq
jl .loop_gpr_%1%2
.end_%1%2:
REP_RET
%endmacro
%if ARCH_X86_32
INIT_MMX mmx
DIFF_BYTES_PROLOGUE
%define regsize mmsize
DIFF_BYTES_LOOP_PREP .skip_main_aa, .end_aa
DIFF_BYTES_BODY a, a
%undef i
%endif
INIT_XMM sse2
DIFF_BYTES_PROLOGUE
%define regsize mmsize
DIFF_BYTES_LOOP_PREP .skip_main_aa, .end_aa
test dstq, regsize - 1
jnz .loop_uu
test src1q, regsize - 1
jnz .loop_ua
DIFF_BYTES_BODY a, a
DIFF_BYTES_BODY u, a
DIFF_BYTES_BODY u, u
%undef i
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
DIFF_BYTES_PROLOGUE
%define regsize mmsize
; Directly using unaligned SSE2 version is marginally faster than
; branching based on arguments.
DIFF_BYTES_LOOP_PREP .skip_main_uu, .end_uu
test dstq, regsize - 1
jnz .loop_uu
test src1q, regsize - 1
jnz .loop_ua
DIFF_BYTES_BODY a, a
DIFF_BYTES_BODY u, a
DIFF_BYTES_BODY u, u
%undef i
%endif
;--------------------------------------------------------------------------------------------------
;void sub_left_predict(uint8_t *dst, uint8_t *src, ptrdiff_t stride, ptrdiff_t width, int height)
;--------------------------------------------------------------------------------------------------
INIT_XMM avx
cglobal sub_left_predict, 5,6,5, dst, src, stride, width, height, x
mova m1, [pb_80] ; prev initial
add dstq, widthq
add srcq, widthq
lea xd, [widthq-1]
neg widthq
and xd, 15
pinsrb m4, m1, xd, 15
mov xq, widthq
.loop:
movu m0, [srcq + widthq]
palignr m2, m0, m1, 15
movu m1, [srcq + widthq + 16]
palignr m3, m1, m0, 15
psubb m2, m0, m2
psubb m3, m1, m3
movu [dstq + widthq], m2
movu [dstq + widthq + 16], m3
add widthq, 2 * 16
jl .loop
add srcq, strideq
sub dstq, xq ; dst + width
test xd, 16
jz .mod32
mova m1, m0
.mod32:
pshufb m1, m4
mov widthq, xq
dec heightd
jg .loop
RET
|
boards/feather_wb55/src/stm32-board.ads | morbos/Ada_Drivers_Library | 2 | 18227 | <filename>boards/feather_wb55/src/stm32-board.ads
with STM32.Device; use STM32.Device;
with STM32.GPIO; use STM32.GPIO;
package STM32.Board is
pragma Elaborate_Body;
subtype User_LED is GPIO_Point;
Red_LED : User_LED renames PB2;
LCH_LED : User_LED renames PB2;
procedure Initialize_Board;
procedure Initialize_LEDs;
procedure Turn_On (This : in out User_LED) renames STM32.GPIO.Set;
procedure Turn_Off (This : in out User_LED) renames STM32.GPIO.Clear;
procedure All_LEDs_Off;
end STM32.Board;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/warn6.adb | best08618/asylo | 7 | 12244 | -- { dg-do compile }
-- { dg-options "-O2" }
with Unchecked_Conversion;
with System;
package body Warn6 is
function Conv is new Unchecked_Conversion (System.Address, Q_T);
procedure Dummy is begin null; end;
end Warn6;
|
deBruijn/Substitution/Data/Application/Application222.agda | nad/dependently-typed-syntax | 5 | 7841 | ------------------------------------------------------------------------
-- Lemmas related to application of substitutions
------------------------------------------------------------------------
open import Data.Universe.Indexed
module deBruijn.Substitution.Data.Application.Application222
{i u e} {Uni : IndexedUniverse i u e}
where
import deBruijn.Context; open deBruijn.Context Uni
open import deBruijn.Substitution.Data.Application.Application221
open import deBruijn.Substitution.Data.Basics
open import deBruijn.Substitution.Data.Map
open import deBruijn.Substitution.Data.Simple
open import Function using (_$_)
open import Level using (_⊔_)
import Relation.Binary.PropositionalEquality as P
open P.≡-Reasoning
-- Lemmas related to application.
record Application₂₂₂
{t₁} {T₁ : Term-like t₁}
{t₂} {T₂ : Term-like t₂}
-- Simple substitutions for the first kind of terms.
(simple₁ : Simple T₁)
-- Simple substitutions for the second kind of terms.
(simple₂ : Simple T₂)
-- A translation from the first to the second kind of terms.
(trans : [ T₁ ⟶⁼ T₂ ])
: Set (i ⊔ u ⊔ e ⊔ t₁ ⊔ t₂) where
open Term-like T₁ using () renaming (_⊢_ to _⊢₁_)
open Term-like T₂ using ([_]) renaming (_⊢_ to _⊢₂_; _≅-⊢_ to _≅-⊢₂_)
open Simple simple₁
using ()
renaming ( id to id₁; sub to sub₁; var to var₁
; wk to wk₁; wk[_] to wk₁[_]
; _↑ to _↑₁; _↑_ to _↑₁_; _↑⁺_ to _↑⁺₁_; _↑₊_ to _↑₊₁_
; _↑⋆ to _↑⋆₁; _↑⁺⋆_ to _↑⁺⋆₁_
)
open Simple simple₂
using ()
renaming ( var to var₂
; weaken to weaken₂; weaken[_] to weaken₂[_]; wk⁺ to wk⁺₂
; wk-subst to wk-subst₂; wk-subst[_] to wk-subst₂[_]
; _↑ to _↑₂; _↑_ to _↑₂_; _↑⁺_ to _↑⁺₂_; _↑₊_ to _↑₊₂_
)
field
application₂₂₁ : Application₂₂₁ simple₁ simple₂ trans
open Application₂₂₁ application₂₂₁ public
abstract
-- A variant of suc-/∋-↑.
suc-/⊢⋆-↑⋆ :
∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ}
σ {τ} (x : Γ ∋ τ) (ρs : Subs T₁ ρ̂) →
var₂ · suc[ σ ] x /⊢⋆ ρs ↑⋆₁ ≅-⊢₂
var₂ · x /⊢⋆ (ρs ▻ wk₁[ σ /⋆ ρs ])
suc-/⊢⋆-↑⋆ σ x ε = begin
[ var₂ · suc x ] ≡⟨ P.sym $ var-/⊢-wk-↑⁺ ε x ⟩
[ var₂ · x /⊢ wk₁ ] ∎
suc-/⊢⋆-↑⋆ σ x (ρs ▻ ρ) = begin
[ var₂ · suc[ σ ] x /⊢⋆ ρs ↑⋆₁ /⊢ ρ ↑₁ ] ≡⟨ /⊢-cong (suc-/⊢⋆-↑⋆ σ x ρs) (P.refl {x = [ ρ ↑₁ ]}) ⟩
[ var₂ · x /⊢⋆ ρs /⊢ wk₁[ σ /⋆ ρs ] /⊢ ρ ↑₁ ] ≡⟨ P.sym $ /⊢-/⊢-wk (σ /⋆ ρs) (var₂ · x /⊢⋆ ρs) ρ ⟩
[ var₂ · x /⊢⋆ ρs /⊢ ρ /⊢ wk₁ ] ∎
-- The antecedent of var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ follows from a less
-- complicated statement.
var-/⊢⋆-⇒-var-/⊢⋆-↑⁺⋆ :
∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} {ρs₁ : Subs T₁ ρ̂} {ρs₂ : Subs T₁ ρ̂} →
(∀ {σ} (x : Γ ∋ σ) → var₂ · x /⊢⋆ ρs₁ ≅-⊢₂ var₂ · x /⊢⋆ ρs₂) →
∀ Γ⁺ {σ} (x : Γ ++⁺ Γ⁺ ∋ σ) →
var₂ · x /⊢⋆ ρs₁ ↑⁺⋆₁ Γ⁺ ≅-⊢₂ var₂ · x /⊢⋆ ρs₂ ↑⁺⋆₁ Γ⁺
var-/⊢⋆-⇒-var-/⊢⋆-↑⁺⋆ hyp ε x = hyp x
var-/⊢⋆-⇒-var-/⊢⋆-↑⁺⋆ {ρs₁ = ρs₁} {ρs₂} hyp (Γ⁺ ▻ σ) zero = begin
[ var₂ · zero /⊢⋆ ρs₁ ↑⁺⋆₁ (Γ⁺ ▻ σ) ] ≡⟨ zero-/⊢⋆-↑⋆ σ (ρs₁ ↑⁺⋆₁ Γ⁺) ⟩
[ var₂ · zero ] ≡⟨ P.sym $ zero-/⊢⋆-↑⋆ σ (ρs₂ ↑⁺⋆₁ Γ⁺) ⟩
[ var₂ · zero /⊢⋆ ρs₂ ↑⁺⋆₁ (Γ⁺ ▻ σ) ] ∎
var-/⊢⋆-⇒-var-/⊢⋆-↑⁺⋆ {ρs₁ = ρs₁} {ρs₂} hyp (Γ⁺ ▻ σ) (suc x) = begin
[ var₂ · suc x /⊢⋆ ρs₁ ↑⁺⋆₁ (Γ⁺ ▻ σ) ] ≡⟨ suc-/⊢⋆-↑⋆ σ x (ρs₁ ↑⁺⋆₁ Γ⁺) ⟩
[ var₂ · x /⊢⋆ ρs₁ ↑⁺⋆₁ Γ⁺ /⊢ wk₁ ] ≡⟨ /⊢-cong (var-/⊢⋆-⇒-var-/⊢⋆-↑⁺⋆ hyp Γ⁺ x) (P.refl {x = [ wk₁ ]}) ⟩
[ var₂ · x /⊢⋆ ρs₂ ↑⁺⋆₁ Γ⁺ /⊢ wk₁ ] ≡⟨ P.sym $ suc-/⊢⋆-↑⋆ σ x (ρs₂ ↑⁺⋆₁ Γ⁺) ⟩
[ var₂ · suc x /⊢⋆ ρs₂ ↑⁺⋆₁ (Γ⁺ ▻ σ) ] ∎
-- Variants of var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ which may be easier to use.
var-/⊢⋆-⇒-/⊢⋆-↑⁺⋆ :
∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρs₁ : Subs T₁ ρ̂) (ρs₂ : Subs T₁ ρ̂) →
(∀ {σ} (x : Γ ∋ σ) → var₂ · x /⊢⋆ ρs₁ ≅-⊢₂ var₂ · x /⊢⋆ ρs₂) →
∀ Γ⁺ {σ} (t : Γ ++⁺ Γ⁺ ⊢₂ σ) →
t /⊢⋆ ρs₁ ↑⁺⋆₁ Γ⁺ ≅-⊢₂ t /⊢⋆ ρs₂ ↑⁺⋆₁ Γ⁺
var-/⊢⋆-⇒-/⊢⋆-↑⁺⋆ ρs₁ ρs₂ hyp =
var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ ρs₁ ρs₂ (var-/⊢⋆-⇒-var-/⊢⋆-↑⁺⋆ hyp)
var-/⊢⋆-⇒-/⊢⋆ :
∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρs₁ : Subs T₁ ρ̂) (ρs₂ : Subs T₁ ρ̂) →
(∀ {σ} (x : Γ ∋ σ) → var₂ · x /⊢⋆ ρs₁ ≅-⊢₂ var₂ · x /⊢⋆ ρs₂) →
∀ {σ} (t : Γ ⊢₂ σ) → t /⊢⋆ ρs₁ ≅-⊢₂ t /⊢⋆ ρs₂
var-/⊢⋆-⇒-/⊢⋆ ρs₁ ρs₂ hyp = var-/⊢⋆-⇒-/⊢⋆-↑⁺⋆ ρs₁ ρs₂ hyp ε
-- The identity substitution has no effect.
/⊢-id : ∀ {Γ σ} (t : Γ ⊢₂ σ) → t /⊢ id₁ ≅-⊢₂ t
/⊢-id = var-/⊢⋆-⇒-/⊢⋆ (ε ▻ id₁) ε var-/⊢-id
-- id is a right identity of _∘_.
∘-id : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T₂ ρ̂) → ρ ∘ id₁ ≅-⇨ ρ
∘-id ρ = extensionality P.refl λ x → begin
[ x /∋ ρ ∘ id₁ ] ≡⟨ /∋-∘ x ρ id₁ ⟩
[ x /∋ ρ /⊢ id₁ ] ≡⟨ /⊢-id (x /∋ ρ) ⟩
[ x /∋ ρ ] ∎
-- Lifting distributes over composition.
∘-↑ : ∀ {Γ Δ Ε} σ {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε}
(ρ₁ : Sub T₂ ρ̂₁) (ρ₂ : Sub T₁ ρ̂₂) →
(ρ₁ ∘ ρ₂) ↑₂ σ ≅-⇨ ρ₁ ↑₂ σ ∘ ρ₂ ↑₁
∘-↑ σ ρ₁ ρ₂ =
let ρ₂↑ = ρ₂ ↑₁ (σ / ρ₁)
lemma₁ = begin
[ wk-subst₂ (ρ₁ ∘ ρ₂) ] ≡⟨ P.refl ⟩
[ map weaken₂ (map (app ρ₂) ρ₁) ] ≡⟨ P.sym $ map-[∘] weaken₂ (app ρ₂) ρ₁ ⟩
[ map (weaken₂ [∘] app ρ₂) ρ₁ ] ≡⟨ map-cong-ext₁ P.refl
(λ t → begin
[ weaken₂ · (t /⊢ ρ₂) ] ≡⟨ P.sym $ /⊢-wk (t /⊢ ρ₂) ⟩
[ t /⊢ ρ₂ /⊢ wk₁ ] ≡⟨ /⊢-/⊢-wk (σ / ρ₁) t ρ₂ ⟩
[ t /⊢ wk₁ /⊢ ρ₂↑ ] ≡⟨ /⊢-cong (/⊢-wk t) P.refl ⟩
[ weaken₂ · t /⊢ ρ₂↑ ] ∎)
(P.refl {x = [ ρ₁ ]}) ⟩
[ map (app ρ₂↑ [∘] weaken₂) ρ₁ ] ≡⟨ map-[∘] (app ρ₂↑) weaken₂ ρ₁ ⟩
[ map (app ρ₂↑) (map (weaken₂) ρ₁) ] ∎
lemma₂ = begin
[ var₂ · zero ] ≡⟨ P.sym $ trans-var zero ⟩
[ trans · (var₁ · zero) ] ≡⟨ trans-cong (P.sym $ Simple.zero-/∋-↑ simple₁ (σ / ρ₁) ρ₂) ⟩
[ trans · (zero /∋ ρ₂↑) ] ≡⟨ P.sym $ var-/⊢ zero ρ₂↑ ⟩
[ var₂ · zero /⊢ ρ₂↑ ] ∎
in begin
[ (ρ₁ ∘ ρ₂) ↑₂ ] ≡⟨ Simple.unfold-↑ simple₂ (ρ₁ ∘ ρ₂) ⟩
[ wk-subst₂ (ρ₁ ∘ ρ₂) ▻ var₂ · zero ] ≡⟨ ▻⇨-cong P.refl lemma₁ lemma₂ ⟩
[ map (app ρ₂↑) (map weaken₂[ σ / ρ₁ ] ρ₁) ▻ var₂ · zero /⊢ ρ₂↑ ] ≡⟨ P.sym $
map-▻ (app ρ₂↑) (wk-subst₂[ σ / ρ₁ ] ρ₁) (var₂ · zero) ⟩
[ map (app ρ₂↑) (wk-subst₂[ σ / ρ₁ ] ρ₁ ▻ var₂ · zero) ] ≡⟨ map-cong (app ρ₂↑ ∎-⟶)
(P.sym $ Simple.unfold-↑ simple₂ ρ₁) ⟩
[ map (app ρ₂↑) (ρ₁ ↑₂) ] ≡⟨ P.refl ⟩
[ ρ₁ ↑₂ ∘ ρ₂ ↑₁ ] ∎
-- N-ary lifting distributes over composition.
∘-↑⁺ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε}
(ρ₁ : Sub T₂ ρ̂₁) (ρ₂ : Sub T₁ ρ̂₂) Γ⁺ →
(ρ₁ ∘ ρ₂) ↑⁺₂ Γ⁺ ≅-⇨ ρ₁ ↑⁺₂ Γ⁺ ∘ ρ₂ ↑⁺₁ (Γ⁺ /⁺ ρ₁)
∘-↑⁺ ρ₁ ρ₂ ε = P.refl
∘-↑⁺ ρ₁ ρ₂ (Γ⁺ ▻ σ) = begin
[ ((ρ₁ ∘ ρ₂) ↑⁺₂ Γ⁺) ↑₂ ] ≡⟨ Simple.↑-cong simple₂ (∘-↑⁺ ρ₁ ρ₂ Γ⁺) P.refl ⟩
[ (ρ₁ ↑⁺₂ Γ⁺ ∘ ρ₂ ↑⁺₁ (Γ⁺ /⁺ ρ₁)) ↑₂ ] ≡⟨ ∘-↑ σ (ρ₁ ↑⁺₂ Γ⁺) (ρ₂ ↑⁺₁ (Γ⁺ /⁺ ρ₁)) ⟩
[ (ρ₁ ↑⁺₂ Γ⁺) ↑₂ ∘ (ρ₂ ↑⁺₁ (Γ⁺ /⁺ ρ₁)) ↑₁ ] ∎
∘-↑₊ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε}
(ρ₁ : Sub T₂ ρ̂₁) (ρ₂ : Sub T₁ ρ̂₂) Γ₊ →
(ρ₁ ∘ ρ₂) ↑₊₂ Γ₊ ≅-⇨ ρ₁ ↑₊₂ Γ₊ ∘ ρ₂ ↑₊₁ (Γ₊ /₊ ρ₁)
∘-↑₊ ρ₁ ρ₂ ε = P.refl
∘-↑₊ ρ₁ ρ₂ (σ ◅ Γ₊) = begin
[ (ρ₁ ∘ ρ₂ ) ↑₂ σ ↑₊₂ Γ₊ ] ≡⟨ Simple.↑₊-cong simple₂ (∘-↑ σ ρ₁ ρ₂) (P.refl {x = [ Γ₊ ]}) ⟩
[ (ρ₁ ↑₂ σ ∘ ρ₂ ↑₁) ↑₊₂ Γ₊ ] ≡⟨ ∘-↑₊ (ρ₁ ↑₂ σ) (ρ₂ ↑₁) Γ₊ ⟩
[ ρ₁ ↑₊₂ (σ ◅ Γ₊) ∘ ρ₂ ↑₊₁ ((σ ◅ Γ₊) /₊ ρ₁) ] ∎
-- First weakening and then substituting something for the first
-- variable is equivalent to doing nothing.
/⊢-wk-/⊢-sub : ∀ {Γ σ τ} (t : Γ ⊢₂ τ) (t′ : Γ ⊢₁ σ) →
t /⊢ wk₁ /⊢ sub₁ t′ ≅-⊢₂ t
/⊢-wk-/⊢-sub t t′ = var-/⊢⋆-⇒-/⊢⋆ (ε ▻ wk₁ ▻ sub₁ t′) ε (λ x → begin
[ var₂ · x /⊢ wk₁ /⊢ sub₁ t′ ] ≡⟨ /⊢-cong (/∋-≅-⊢-var x wk₁ (Simple./∋-wk simple₁ x)) P.refl ⟩
[ var₂ · suc x /⊢ sub₁ t′ ] ≡⟨ suc-/⊢-sub x t′ ⟩
[ var₂ · x ] ∎) t
-- Weakening a substitution and composing with sub is the same as
-- doing nothing.
wk-subst-∘-sub : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T₂ ρ̂) (t : Δ ⊢₁ σ) →
wk-subst₂ ρ ∘ sub₁ t ≅-⇨ ρ
wk-subst-∘-sub ρ t = extensionality P.refl λ x →
let lemma = begin
[ x /∋ wk-subst₂ ρ ] ≡⟨ Simple./∋-wk-subst simple₂ x ρ ⟩
[ weaken₂ · (x /∋ ρ) ] ≡⟨ P.sym $ /⊢-wk (x /∋ ρ) ⟩
[ x /∋ ρ /⊢ wk₁ ] ∎
in begin
[ x /∋ wk-subst₂ ρ ∘ sub₁ t ] ≡⟨ /∋-∘ x (wk-subst₂ ρ) (sub₁ t) ⟩
[ x /∋ wk-subst₂ ρ /⊢ sub₁ t ] ≡⟨ /⊢-cong lemma P.refl ⟩
[ x /∋ ρ /⊢ wk₁ /⊢ sub₁ t ] ≡⟨ /⊢-wk-/⊢-sub (x /∋ ρ) t ⟩
[ x /∋ ρ ] ∎
-- Unfolding lemma for wk⁺.
wk⁺-▻ : ∀ {Γ} (Γ⁺ : Ctxt⁺ Γ) {σ} →
wk⁺₂ (Γ⁺ ▻ σ) ≅-⇨ wk⁺₂ Γ⁺ ∘ wk₁[ σ ]
wk⁺-▻ Γ⁺ {σ = σ} = begin
[ wk⁺₂ (Γ⁺ ▻ σ) ] ≡⟨ P.refl ⟩
[ wk-subst₂ (wk⁺₂ Γ⁺) ] ≡⟨ P.sym $ ∘-wk (wk⁺₂ Γ⁺) ⟩
[ wk⁺₂ Γ⁺ ∘ wk₁ ] ∎
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/noreturn1.adb | best08618/asylo | 7 | 1691 | -- { dg-do compile }
package body Noreturn1 is
procedure Error (E : in Exception_Occurrence) is
Occurrence_Message : constant String := Exception_Message (E);
begin
if Occurrence_Message = "$" then
raise Program_Error;
else
raise Constraint_Error;
end if;
end;
end Noreturn1;
|
sources/md/markdown-common_patterns.ads | reznikmm/markdown | 0 | 18195 | <gh_stars>0
-- SPDX-FileCopyrightText: 2020 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with League.Regexps;
with League.Strings;
package Markdown.Common_Patterns is
Blank_Pattern : constant League.Regexps.Regexp_Pattern :=
League.Regexps.Compile
(League.Strings.To_Universal_String
("^[\ \t]*$"));
Link_Label : constant Wide_Wide_String :=
"\[[\ \t\n\v\f\r]*((\\\[|[^\]\ \t\n\v\f\r])[\ \t\n\v\f\r\>]*)+\]";
-- [ space *((\ [| [^]space ]) space *)+ ]
-- Groups: 12
Link_Title : constant Wide_Wide_String :=
"\""[^\""]*(\"")?" & -- Group: 1
"|\'[^\']*(\')?" & -- Group: 2
"|\(([^\(\)]|\\[\(\)])*(\))?"; -- Group: 3, 4
procedure Parse_Link_Destination
(Line : League.Strings.Universal_String;
Last : out Natural;
URL : out League.Strings.Universal_String);
-- Parse Line ad link destination and result its length in Last if found,
-- or zero otherwise. Set URL to link destination stripping <> if needed.
end Markdown.Common_Patterns;
|
programs/oeis/007/A007598.asm | karttu/loda | 0 | 103496 | ; A007598: Squared Fibonacci numbers: F(n)^2 where F = A000045.
; 0,1,1,4,9,25,64,169,441,1156,3025,7921,20736,54289,142129,372100,974169,2550409,6677056,17480761,45765225,119814916,313679521,821223649,2149991424,5628750625,14736260449,38580030724,101003831721,264431464441,692290561600,1812440220361,4745030099481,12422650078084,32522920134769,85146110326225,222915410843904,583600122205489,1527884955772561,4000054745112196
mov $2,1
lpb $0,1
sub $0,1
mov $1,$2
add $3,2
mov $2,$3
sub $3,1
add $4,$2
sub $2,$1
add $3,$4
lpe
|
vbox/src/VBox/Runtime/common/math/RTUInt128MulByU64.asm | Nurzamal/rest_api_docker | 0 | 17771 | <reponame>Nurzamal/rest_api_docker
; $Id: RTUInt128MulByU64.asm 69219 2017-10-24 15:01:30Z vboxsync $
;; @file
; IPRT - RTUInt128MulByU64 - AMD64 implementation.
;
;
; Copyright (C) 2006-2017 Oracle Corporation
;
; This file is part of VirtualBox Open Source Edition (OSE), as
; available from http://www.virtualbox.org. This file is free software;
; you can redistribute it and/or modify it under the terms of the GNU
; General Public License (GPL) as published by the Free Software
; Foundation, in version 2 as it comes in the "COPYING" file of the
; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
;
; The contents of this file may alternatively be used under the terms
; of the Common Development and Distribution License Version 1.0
; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
; VirtualBox OSE distribution, in which case the provisions of the
; CDDL are applicable instead of those of the GPL.
;
; You may elect to license modified versions of this file under the
; terms and conditions of either the GPL or the CDDL or both.
;
%define RT_ASM_WITH_SEH64
%include "iprt/asmdefs.mac"
%include "internal/bignum.mac"
BEGINCODE
;;
; Multiplies a 128-bit number with a 64-bit one.
;
; @returns puResult.
; @param puResult x86:[ebp + 8] gcc:rdi msc:rcx
; @param puValue1 x86:[ebp + 12] gcc:rsi msc:rdx
; @param uValue2 x86:[ebp + 16] gcc:rdx msc:r8
;
BEGINPROC_EXPORTED RTUInt128MulByU64
; SEH64_SET_FRAME_xSP 0
SEH64_END_PROLOGUE
%ifdef RT_ARCH_AMD64
%ifdef ASM_CALL64_GCC
%define puResult rdi
%define puValue1 rsi
%define uValue2 r8
mov r8, rdx
%else
%define puResult rcx
%define puValue1 r9
%define uValue2 r8
mov r9, rdx
%endif
; puValue1->s.Lo * uValue2
mov rax, [puValue1]
mul uValue2
mov [puResult], rax
mov r11, rdx ; Store the lower half of the result.
; puValue1->s.Hi * uValue2
mov rax, [puValue1 + 8]
mul uValue2
add r11, rax ; Calc the second half of the result.
mov [puResult + 8], r11 ; Store the high half of the result.
mov rax, puResult
;%elifdef RT_ARCH_X86
%else
%error "unsupported arch"
%endif
ret
ENDPROC RTUInt128MulByU64
|
src/examples/fill_ram_demo.asm | glitchland/DLW-2 | 0 | 93912 | <reponame>glitchland/DLW-2
add D, 255, D
LOOP: add B, 1, B
add D, 1, D
sub C, 1, C
store B, #C
store B, #D
jump LOOP |
drivers/henon_heiles.adb | sciencylab/lagrangian-solver | 0 | 914 | <reponame>sciencylab/lagrangian-solver
with Numerics, Ada.Text_IO, Chebyshev, Dense_AD, Dense_AD.Integrator;
use Numerics, Ada.Text_IO, Chebyshev;
procedure Henon_Heiles is
use Int_IO, Real_IO, Real_Functions;
N : constant Nat := 2;
K : constant Nat := 13;
package AD_Package is new Dense_AD (2 * N);
package Integrator is new AD_Package.Integrator (K);
use AD_Package, Integrator;
-----------------------------------------------
Control : Control_Type := New_Control_Type (Tol => 1.0e-7);
function KE (Q : in AD_Vector) return AD_Type is
begin
return 0.5 * (Q (3) ** 2 + Q (4) ** 2);
end KE;
function PE (Q : in AD_Vector) return AD_Type is
begin
return 0.5 * (Q (1) ** 2 + Q (2) ** 2)
+ Q (1) ** 2 * Q (2) - Q (2) ** 3 / 3.0;
end PE;
function Lagrangian (T : in Real;
X : in Vector) return AD_Type is
Q : constant AD_Vector := Var (X);
begin
return KE (Q) - PE (Q);
end Lagrangian;
function Hamiltonian (T : in Real;
X : in Vector) return AD_Type is
Q : constant AD_Vector := Var (X);
begin
return KE (Q) + PE (Q);
end Hamiltonian;
-----------------------------------------------
function Get_IC (X : in Vector;
E : in Real) return Vector is
use Real_IO;
Y : Vector := X;
G : Vector;
H : AD_Type;
F, Dw : Real := 1.0;
W : Real renames Y (3); -- Y(3) is ω_t
begin
-- use Newton's method to solve for E - H = 0
W := 1.0;
while abs (F) > 1.0e-14 loop
H := Hamiltonian (0.0, Y);
F := E - Val (H);
G := Grad (H);
Dw := (E - Val (H)) / G (3); -- G(3) is \partial H / \partial ω_t
W := W + Dw;
end loop;
H := Hamiltonian (0.0, Y);
F := E - Val (H);
return Y;
end Get_IC;
function Func (X : in Vector) return Real is
begin
return X (1);
end Func;
function Sgn (X : in Real) return Real is
begin
if X >= 0.0 then return 1.0;
else return -1.0;
end if;
end Sgn;
function Find_State_At_Level (Level : in Real;
A : in Array_Of_Vectors;
T : in Real;
Dt : in Real;
Lower : in out Real;
Upper : in out Real;
Func : not null access function (X : Vector)
return Real) return Variable is
Guess : Variable;
Est : Real := 1.0e10;
Sign : constant Real := Sgn (Func (Interpolate (A, Upper, T, T + Dt)) -
Func (Interpolate (A, Lower, T, T + Dt)));
begin
while abs (Est - Level) > 1.0e-10 loop
Guess.T := 0.5 * (Lower + Upper);
Guess.X := Interpolate (A, Guess.T, T, T + Dt);
Est := Func (Guess.X);
if Est * sign > 0.0 then Upper := Guess.T;
else Lower := Guess.T; end if;
end loop;
return Guess;
end Find_State_At_Level;
-- Initial Conditions ----
Var, State, Guess : Variable := (0.0, (0.0, -0.1, 1.0, 0.0));
X : Vector renames Var.X;
T : Real renames Var.T;
-------------------------------
Y : Real_Vector (1 .. 2 * N * K);
A, Q : Array_Of_Vectors;
Fcsv : File_Type;
H0 : constant Real := 1.0 / 8.0;
T_Final : constant Real := 400_000.0;
Lower, Upper : Real;
AD : AD_Type;
begin
Control.Max_Dt := 10.0;
X := Get_IC (X, H0);
AD := Hamiltonian (0.0, X);
State := Var;
for Item of X loop
Put (Item); New_Line;
end loop;
Put (Val (AD)); New_Line;
Create (Fcsv, Name => "out.csv");
Put_Line (Fcsv, "t, q1, q2, q_dot1, q_dot2, p1, p2, E");
Print_Lagrangian (Fcsv, Var, Lagrangian'Access);
while T < T_Final loop
Put (Var.T); Put (" "); Put (Control.Dt); New_Line;
Y := Update (Lagrangian'Access, Var, Control, Sparse);
A := Chebyshev_Transform (Y);
Q := Split (Y);
for I in 2 .. K loop
if Q (1) (I - 1) * Q (1) (I) < 0.0 then -- If there's a zero, bisect
Lower := Var.T + Control.Dt * Grid (I - 1);
Upper := Var.T + Control.Dt * Grid (I);
Guess := Find_State_At_Level
(0.0, A, Var.T, Control.Dt, Lower, Upper, Func'Access);
----------------------------------------------------------------
if Guess.X (3) > 0.0 then
Print_Lagrangian (Fcsv, Guess, Lagrangian'Access);
end if;
end if;
end loop;
-- Put (Var.T); New_Line;
-- Print_Lagrangian (Fcsv, Var, Lagrangian'Access);
Update (Var => Var, Y => Y, Dt => Control.Dt); -- Update variable Var
end loop;
Close (Fcsv);
end Henon_Heiles;
|
Appl/FileMgrs/CommonDesktop/CUtil/cutilFileOpLow.asm | steakknife/pcgeos | 504 | 85476 | <reponame>steakknife/pcgeos<filename>Appl/FileMgrs/CommonDesktop/CUtil/cutilFileOpLow.asm
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1994 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Desktop/Util
FILE: cutilFileOpLow.asm
ROUTINES:
INT CopyMoveFileToDir - common routine to do high-level move/copy
INT DeskFileCopy - copy file or directory!!
INT FileCopyFile - copy single file
INT DeskFileMove - move file or directory!!
INT FileMoveFile - move single file
INT FileCopyMoveDir - recursively move/copy directory
INT GetNextFilename - parse filename list
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 10/10/94 Broken out of cutilFileOp.asm
DESCRIPTION:
This file contains desktop utility routines.
$Id: cutilFileOpLow.asm,v 1.1 97/04/04 15:02:16 newdeal Exp $
------------------------------------------------------------------------------@
FileOpLow segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckSystemFolderDestruction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: check if operation is about to be performed on a GEOS
system folder (DOCUMENT, SYSTEM, SYSAPPL, etc.). If so,
return and signal error.
CALLED BY: INTERNAL
FileDeleteFileDirCommon
RenameWithOverwrite
PASS: ds:dx = source name
RETURN: carry set if error
AX - error code
carry clear if no error
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 08/16/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckSystemFolderDestruction proc far
uses bx, cx, dx, si, di, bp, ds, es
.enter
; create full for full path
mov cx, size PathName
sub sp, cx
mov di, sp
segmov es, ss
mov si, dx ;ds:si = tail
clr bx, dx
push di
; call FileConstructFullPath ; bx <- disk handle
;this works for links
call FileConstructActualPath ; bx <- disk handle
pop di
call FileParseStandardPath ;ax = StandardPath
if GPC_PRESERVE_DIRECTORIES
call CheckIniSpecialFolder
jc error
endif
;
; See if the remainder of the path is either NULL, or
; BACKSLASH,NULL.
;
SBCS < cmp {byte} es:[di], 0 >
DBCS < cmp {wchar}es:[di], 0 >
je error
SBCS < cmp {word} es:[di], C_BACKSLASH or (0 shl 8) >
DBCS < cmp {wchar}es:[di], C_BACKSLASH >
clc
jne done
DBCS < cmp {wchar}es:[di], 0 >
DBCS < jne done ;branch (carry clear) >
error:
stc
mov ax, ERROR_SYSTEM_FOLDER_DESTRUCTION
done:
mov di, sp
lea sp, ss:[di][size PathName]
.leave
ret
CheckSystemFolderDestruction endp
if 0 ; now read from .ini file
if GPC_PRESERVE_DIRECTORIES
cardGamesDir TCHAR "Card Games"
CARD_GAMES_DIR_LENGTH equ 10
gamesDir TCHAR "Games"
GAMES_DIR_LENGTH equ 5
homeOfficeDir TCHAR "Home Office"
HOME_OFFICE_DIR_LENGTH equ 11
strategyGamesDir TCHAR "Strategy Games"
STRATEGY_GAMES_DIR_LENGTH equ 14
toolsDir TCHAR "Tools"
TOOLS_DIR_LENGTH equ 5
endif
endif
if GPC_PRESERVE_DIRECTORIES
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckSpecialFolder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: check if directory is special folder (Home Office, Tools,
Games, etc.)
CALLED BY: INTERNAL
CreateNewFolderWindowCommon
PASS: cx:dx = pathname
bp = disk handle
RETURN: carry set if special folder
carry clear if not
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 12/28/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckSpecialFolder proc far
uses ax, bx, cx, dx, si, di, bp, ds, es
.enter
; create full for full path
mov ds, cx
mov si, dx
mov bx, bp
mov cx, size PathName
sub sp, cx
mov di, sp
segmov es, ss
clr dx
push di
call FileConstructActualPath ; bx <- disk handle
pop di
call FileParseStandardPath ;ax = StandardPath
call CheckIniSpecialFolder
mov ax, ERROR_SYSTEM_FOLDER_DESTRUCTION ; in case special folder
done::
mov di, sp
lea sp, ss:[di][size PathName]
.leave
ret
CheckSpecialFolder endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckIniSpecialFolder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: check if directory is special folder specified in .ini
file
CALLED BY: INTERNAL
CheckSystemFolderDestruction
CheckSpecialFolder
PASS: ax = StandardPath/disk handle
es:di = path tail
RETURN: carry set if .ini special folder
carry clear if not
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 1/2/99 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CISFParams struct
CISFP_diskHandle word
CISFP_path fptr
CISFParams ends
CheckIniSpecialFolder proc near
uses ax, bx, cx, dx, si, di, ds, es
cisfParams local CISFParams
.enter
mov cisfParams.CISFP_diskHandle, ax
movdw cisfParams.CISFP_path, esdi
;
; enumerate .ini special folder string section
;
segmov es, ss, bx
lea bx, cisfParams
segmov ds, cs, cx
mov si, offset specialFolderCat
mov dx, offset specialFolderKey
mov di, SEGMENT_CS
mov ax, offset CISFCallback
push bp
mov bp, 0
call InitFileEnumStringSection
pop bp
.leave
ret
CheckIniSpecialFolder endp
specialFolderCat char 'fileManager', 0
specialFolderKey char 'cuiFolders', 0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CISFCallback
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: callback to check if directory is special folder specified
in .ini file
CALLED BY: CheckIniSpecialFolder via InitFileEnumStringSection
PASS: ds:si = string section (<SP>,<path>)
es:bx = CISFParams
dx = section #
cx = section length
RETURN: carry set if .ini special folder (stop enumeration)
carry clear if not (continue enumeration)
DESTROYED: ax, cx, dx, di, si, bp, ds
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 1/2/99 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CISFCallback proc far
uses es
.enter
SBCS < clr ah >
LocalGetChar ax, dssi
LocalCmpChar ax, '0'
jb notIniPath ; bad disk handle
LocalCmpChar ax, '9'
ja notIniPath ; bad disk handle
sub ax, '0'
mov cx, ax
SBCS < clr ah >
LocalGetChar ax, dssi
LocalCmpChar ax, ',' ; single digit disk handle?
je doCompare ; yes
LocalCmpChar ax, '0'
jb notIniPath
LocalCmpChar ax, '9'
ja notIniPath
sub ax, '0'
mov dl, 10
mul dl
add cx, ax ; cx = two digit disk handle
LocalGetChar ax, dssi
LocalCmpChar ax, ','
jne notIniPath ; max two-digit disk handle
doCompare:
mov dx, es:[bx].CISFP_diskHandle
mov di, es:[bx].CISFP_path.offset
mov es, es:[bx].CISFP_path.segment
call FileComparePaths
cmp al, PCT_EQUAL
stc ; assume equal
je done
notIniPath:
clc ; else, not equal
done:
.leave
ret
CISFCallback endp
endif ; GPC_PRESERVE_DIRECTORIES
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CompareTransferSrcDest
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: check if source and destination of quick transfer is
same or different disk
CALLED BY: INTERNAL
FolderEndMoveCopy
TreeEndMoveCopy
DriveToolEndMoveCopy
PASS: bx:ax = destination
dx:cx = source
RETURN: carry clear if same
carry set if different
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 01/02/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CompareTransferSrcDest proc far
uses ax, bx, cx, dx, ds, si, es, di
diskInfo local DiskInfoStruct
.enter
;
; get disk info from destination
;
push dx, cx ; save source
mov si, ax ; bx:si = dest.
mov ax, MSG_GET_DISK_INFO
mov dx, ss
push bp
lea bp, diskInfo
call ObjMessageCall
pop bp
;
; get disk info from source
;
pop bx, si ; bx:si = source
push ax ; save dest disk handle
mov ax, MSG_GET_DISK_INFO
mov dx, ss
push bp
lea bp, diskInfo
call ObjMessageCall
pop bp
;
; See if the disk handles match. If they do, the src & dest are
; the same. If they don't, they aren't...
;
pop dx
call CompareDiskHandles
clc
je done
stc ; signal mismatch
done:
.leave
ret
CompareTransferSrcDest endp
;
; clear create folder name field
;
; called by:
; FolderStartCreateDir
; TreeStartCreateDir
; pass:
; nothing
; return:
; nothing
;
CreateDirStuff proc far
NOFXIP< mov dx, cs >
NOFXIP< mov bp, offset createDirNullString >
FXIP < clr bx >
FXIP < push bx >
FXIP < mov dx, ss >
FXIP < mov bp, sp ;dx:bp = null str on stack >
mov bx, handle CreateDirNameEntry
mov si, offset CreateDirNameEntry
call CallSetText
FXIP < pop bp >
ret
CreateDirStuff endp
if not _FXIP
SBCS <createDirNullString byte 0 >
DBCS <createDirNullString wchar 0 >
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetFileOpProgressBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put up file-operation progress box
CALLED BY: WastebasketDeleteFiles
ProcessDragFilesCommon
PASS: ax - FileOperationProgressTypes
FOPT_DELETE
FOPT_THROW_AWAY
FOPT_MOVE
FOPT_COPY
RETURN: ss:[fileOpProgressType] - set to progress type
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 05/19/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetFileOpProgressBox proc far
uses ax, bx, cx, dx, si, di, bp
.enter
EC < cmp ax, LAST_FOPT_TABLE_ENTRY >
EC < ERROR_AE BAD_FILE_OP_PROGRESS_TYPE >
EC < test ax, 1 ; check odd >
EC < ERROR_NZ BAD_FILE_OP_PROGRESS_TYPE >
EC < cmp ax, FOPT_NONE >
EC < ERROR_Z BAD_FILE_OP_PROGRESS_TYPE >
mov ss:[fileOpProgressType], ax ; store progress type
;
; set correct moniker for file operation progress box
; (if move or copy)
; ax = progress type
;
mov si, ax
mov ss:[cancelOperation], 0 ; clear cancel flag
mov dx, cs:[FileOpProgressMonikerObjTable][si]
mov ss:[cancelMonikerToChange], dx
mov cx, cs:[FileOpProgressMonikerTable][si]
jcxz skipMoniker ; do not replace moniker
push si
mov bx, handle ProgressUI
mov si, dx ; moniker object
mov ax, MSG_GEN_USE_VIS_MONIKER
mov dl, VUM_NOW
call ObjMessageCall
pop si
mov ax, MSG_GEN_SET_ENABLED
; for BA, make a throw away non-stoppable. This was done because when
; you stop a throw away of a folder, half of its contents may reside
; in the wastebasket, but the other half in the original location.
; if you try to recover that folder, it will (if you don't know what
; you are doing and click 'OK' to overwrite the original) delete the
; half that wasn't thrown away when it overwrites. This way if they
; throw away a folder with multiple items, they must wait until it is
; done being thrown away, and then they can recover the entire thing
; should they choose to. The better solution, merging similarly named
; folders when recovering (or providing this option in all potential
; overwrite situations) is more work than I have time to do right now.
; dlitwin 6/9/93
BA< cmp si, FOPT_THROW_AWAY >
BA< jne gotMsg >
BA< mov ax, MSG_GEN_SET_NOT_ENABLED >
BA<gotMsg: >
mov bx, handle ProgressUI
mov si, cs:[FileOpProgressStopTriggerTable][si]
mov dl, VUM_NOW
call ObjMessageCall
skipMoniker:
mov ss:[fileOpProgressBoxUp], FALSE ; box not up yet
.leave
ret
SetFileOpProgressBox endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ClearFileOpProgressBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: take down file-operation progress box
CALLED BY: WastebasketDeleteFiles
ProcessDragFilesCommon
PASS: nothing
RETURN: ss:[fileOpProgressType] - set to FOPT_NONE
flags preserved
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 05/19/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ClearFileOpProgressBox proc far
uses si
.enter
pushf ; save flags
mov si, FOPT_NONE
xchg ss:[fileOpProgressType], si ; clear progress type
; si = old progress type
call TakeDownFileOpBox ; bring down box
popf ; retrieve flags
.leave
ret
ClearFileOpProgressBox endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RemoveFileOpProgressBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: take down file-op progress box
CALLED BY: INTERNAL
;; DesktopYesNoBox
;; DesktopOKErrorBox
DeleteFileWarning
PASS: nothing
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 05/22/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RemoveFileOpProgressBox proc near
uses si
.enter
mov si, ss:[fileOpProgressType]
cmp si, FOPT_NONE
je done
call TakeDownFileOpBox
done:
.leave
ret
RemoveFileOpProgressBox endp
;
; pass:
; si = curent fileOpProgresType
;
TakeDownFileOpBox proc near
uses ax, bx, cx, dx, si, di, bp
.enter
cmp ss:[fileOpProgressBoxUp], TRUE ; box up?
jne done ; nope
;
; clear filenames
;
EC < cmp si, LAST_FOPT_TABLE_ENTRY >
EC < ERROR_AE BAD_FILE_OP_PROGRESS_TYPE >
EC < test si, 1 ; check odd >
EC < ERROR_NZ BAD_FILE_OP_PROGRESS_TYPE >
EC < cmp si, FOPT_NONE >
EC < ERROR_Z BAD_FILE_OP_PROGRESS_TYPE >
NOFXIP< mov dx, cs >
NOFXIP< mov bp, offset nullFileOpProgressName >
FXIP < clr dx >
FXIP < push dx >
FXIP < mov dx, ss >
FXIP < mov bp, sp ;dx:bp = ptr to null >
push dx, bp
mov ax, -1
call SetFileOpProgressSrcName ; preserves si
pop dx, bp
mov ax, -1
call SetFileOpProgressDestName
FXIP < pop dx >
;
; clear monikers in detach-while-active box, if needed
; also, update attention needed string
;
cmp ss:[detachActiveHandling], TRUE ; detach-while-active box up?
jne afterActiveBoxUpdate ; nope
cmp ss:[activeType], ACTIVE_TYPE_FILE_OPERATION
jne afterActiveBoxUpdate ; nope
push si ; save fileOpProgressType
call ClearActiveFileOpMonikers
pop si
cmp ss:[hackModalBoxUp], TRUE ; file-op-app-active box up?
jne afterActiveBoxUpdate ; nope
call InformActiveBoxOfAttention ; change to attn-req'd string
; (in PseudoResident resource)
afterActiveBoxUpdate:
;
; take down box
;
mov bx, handle ProgressUI
mov si, cs:[FileOpProgressBoxTable][si]
mov ax, MSG_GEN_GUP_INTERACTION_COMMAND
mov cx, IC_DISMISS
call ObjMessageCall ; take down box
mov ss:[fileOpProgressBoxUp], FALSE ; box not up anymore
done:
.leave
ret
TakeDownFileOpBox endp
if not _FXIP
SBCS <nullFileOpProgressName byte 0 >
DBCS <nullFileOpProgressName wchar 0 >
endif
ClearActiveFileOpMonikers proc far
mov cx, offset ActiveEmptyMoniker
mov dx, cx
push ds
segmov ds, ss ; needed for FIXUP_DS
call SetActiveFileOpMonikers ; clear monikers
pop ds
ret
ClearActiveFileOpMonikers endp
;
; called by:
; ClearActiveFileOpMonikers (same segment)
; DeskApplicationActiveAttention (diff. segment)
; DeskApplicationDetachConfirm (diff. segment)
; pass:
; cx, dx - monikers for source, destination progress strings
; in file operation active box
;
SetActiveFileOpMonikers proc far
push bp
push dx ; save destination moniker
mov ax, MSG_GEN_USE_VIS_MONIKER
mov dl, VUM_NOW
mov bx, handle ActiveUI
mov si, offset ActiveFileOpSourceGroup
call ObjMessageCallFixup
pop cx ; cx = destination moniker
mov ax, MSG_GEN_USE_VIS_MONIKER
mov dl, VUM_NOW
mov si, offset ActiveFileOpDestinationGroup
call ObjMessageCallFixup
pop bp
ret
SetActiveFileOpMonikers endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateProgress
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: update file-operation progress boxes
CALLED BY: FileCopyMoveDir
FileMoveFile
FileCopyFile
FileCheckAndDelete
FileDeleteDirWithError
PASS: ds:si = FileOperationInfoEntry for source
ds:0 = FileQuickTransferHeader for source
es:di = destination name, if needed
destination directory is current directory
RETURN: carry clear to continue
carry set cancel operation
ax - YESNO_CANCEL
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 05/19/90 Initial version
brianc 06/27/90 added cancel support
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateProgressCommon proc near
uses bx, cx, dx, si, di, ds, es, bp
.enter
if _AVOID_POWER_OFF
;
; Avoid powering off during a long file operation
; because of user-inactivity, bump the mouse - brianc 6/15/93
;
push di
clr di
call ImGetMousePos ; cx, dx - scr pos
neg ss:[mouseBumpAmt] ; negate for next time
add cx, ss:[mouseBumpAmt] ; add 1 or -1 to X dir
call ImPtrJump
pop di
endif
clr al
xchg ss:[cancelOperation], al
tst al ; cancel?
jz 10$ ; nope
mov ax, YESNO_CANCEL ; return cancel
stc
jmp short exit
10$:
cmp ss:[fileOpProgressType], FOPT_NONE
je done ; progress box is not up
EC < test ss:[fileOpProgressType], 1 >
EC < ERROR_NZ BAD_FILE_OP_PROGRESS_TYPE >
EC < cmp ss:[fileOpProgressType], LAST_FOPT_TABLE_ENTRY >
EC < ERROR_AE BAD_FILE_OP_PROGRESS_TYPE >
cmp ss:[fileOpProgressType], FOPT_DELETE
jne notDeleteHack
cmp ss:[showDeleteProgress], TRUE ; show delete progress?
jne done ; nope, skip
notDeleteHack:
;
; Call specific routine to update the box.
;
call UpdateProgressForFOPT
;
; put up box, if not already up
;
cmp ss:[fileOpProgressBoxUp], TRUE ; box up yet?
je done ; yes
mov ss:[fileOpProgressBoxUp], TRUE ; indicate box up
mov bx, handle ProgressUI
mov si, ss:[fileOpProgressType] ; get progress type
mov si, cs:[FileOpProgressBoxTable][si]
mov ax, MSG_GEN_INTERACTION_INITIATE
call ObjMessageCall ; put up box
done:
clc ; continue
exit:
.leave
ret
UpdateProgressCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateProgressForFOPT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets up for:
FOPT_DELETE, FOPT_THROW_AWAY, FOPT_MOVE, FOPT_COPY
CALLED BY: UpdateProgress
PASS: ds:si = FileOperationInfoEntry of source
ds:0 = FileQuickTransferHeader
if FOPT_DELETE or FOPT_THROW_AWAY:
current dir is dir holding FOIE
if FOPT_MOVE or FOPT_COPY
es:di = destination name
current dir is destination dir
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
XXX: WANT FULL PATH NAME HERE, BUT IT'S SLOW TO BUILD EACH TIME, SO
PROBABLY (YECH) NEED GLOBAL VARIABLE, OR BUILD IT INTO THE FQTH AT
THE START AND USE THAT.
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 5/28/92 combined UpdateProgressForMoveorCopy
with UpdateProgressForDelete
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateProgressForFOPT proc near
.enter
mov ax, ss:[fileOpProgressType] ; ax = progress type
cmp ax, FOPT_NONE
je exit
CheckHack <offset FOIE_name eq 0>
mov dx, ds
mov bp, si
mov si, ax
clr ax ; assume default disk handle
cmp si, FOPT_DELETE
je gotDiskHandle
;no!, if we are throwing away, we are doing a move, so we need to use the
;disk handle in FQTH_diskHandle as the source! - brianc 6/25/92
; cmp si, FOPT_THROW_AWAY
; je gotDiskHandle
mov ax, ds:[FQTH_diskHandle] ; otherwise its a MoveCopy
gotDiskHandle:
push es, di
;
; If we have a null destination name, don't bother with dest progress
; name. This can happen if we pass null because we are doing a
; FileCheckAndDelete to overwrite a file on a move or copy.
; (See FileCheckAndDelete) - brianc 12/2/92
;
SBCS < tst <{byte} es:[di]> ; check if null >
DBCS < tst {wchar}es:[di] ; check if null >
pushf ; save null status
call SetFileOpProgressSrcName ; preserves si
popf
pop dx, bp
jz exit ; if null destination name, done
cmp si, FOPT_DELETE
je exit
cmp si, FOPT_THROW_AWAY
je exit
clr ax
call SetFileOpProgressDestName
exit:
.leave
ret
UpdateProgressForFOPT endp
;
; dx:00 = FileQuickTransferHeader
; dx:bp = source name (GEOS char set)
; ax = source disk handle
; (0 to use current disk)
; (-1 to use no disk)
;
SetFileOpProgressSrcName proc near
uses si
.enter
mov si, cs:[FileOpProgressSrcNameTable][si]
mov di, offset ActiveFileOpSource
call SetProgressAndUpdateActiveFileOpIfNeeded
.leave
ret
SetFileOpProgressSrcName endp
;
; dx:00 = FileQuickTransferHeader
; dx:bp = destination name (GEOS char set)
; ax = destination disk handle
; (0 to use current disk)
; (-1 to use no disk)
;
SetFileOpProgressDestName proc near
uses si
.enter
mov si, cs:[FileOpProgressDestNameTable][si]
tst si
jz done
mov di, offset ActiveFileOpDestination
call SetProgressAndUpdateActiveFileOpIfNeeded
done:
.leave
ret
SetFileOpProgressDestName endp
SPAUAFOIN_BUFFER_SIZE equ PATH_BUFFER_SIZE + FILE_LONGNAME_BUFFER_SIZE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetProgressAndUpdateActiveFileOpIfNeeded
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets up progress box strings correctly
CALLED BY:
PASS: dx:00 = FileQuickTransferHeader
dx:bp = progress text (GEOS char set)
si = progress text field
di = active file op text field
ax = disk handle of operation
(ax = 0 to use current disk handle)
(ax = -1 to use no disk)
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 6/19/92 added this header, rewrote to add full paths
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetProgressAndUpdateActiveFileOpIfNeeded proc near
uses ax, bx, cx, dx, bp, di, si, ds, es
.enter
sub sp, SPAUAFOIN_BUFFER_SIZE
mov cx, sp
push di ; save active file text field
push si ; save progress text field
cmp ax, -1
je gotPath
push dx, bp ; save progress text
segmov es, ss, di
mov di, cx ; es:di points to
;
; when setting up the tail for FileConstructFullPath (ds:si), we use
; FQTH_pathname if are passing in a disk handle (very likely a
; standard path). But if we are using the current directory (ax=0),
; we don't want to use FQTH_pathname. Instead, we just pass a
; null, as the current directory is the full path we desire
; - brianc 6/25/92
; Modified to be just null, instead of slash-null (also updated
; comment above to remove slash-null reference) - brianc 12/2/92
;
mov ds, dx
mov si, offset FQTH_pathname ; ds:si is trailing path
tst ax ; using current path?
jnz notCurPath ; no, use FQTH_pathname
NOFXIP< segmov ds, cs >
FXIP< GetResourceSegmentNS dgroup, ds, TRASH_BX >
mov si, offset progressNullPath
notCurPath:
mov dx, -1 ; non-zero so we put in <XX:>
mov bx, ax
mov cx, SPAUAFOIN_BUFFER_SIZE
mov ax, di ; ax = start of buffer
if GPC_FILE_OP_DIALOG_PATHNAME
push ax
call FileConstructActualPath
pop ax
LocalStrLength
LocalPrevChar esdi ; point at null-term
else
call FileConstructFullPath
endif
; XXX: this probably isn't
; needed as we'll have
; at least the drive
; letter and colon
cmp di, ax ; did we store anything?
je needSep ; nope, force seperator
SBCS < cmp {byte} es:[di-1], C_BACKSLASH ; already got seperator? >
DBCS < cmp {wchar} es:[di-2], C_BACKSLASH ; already got separator? >
je haveSep ; yes, don't stick on another
needSep:
SBCS < mov al, C_BACKSLASH >
DBCS < mov ax, C_BACKSLASH >
LocalPutChar esdi, ax
haveSep:
pop ds, si ; restore progress text
mov cx, FILE_LONGNAME_BUFFER_SIZE/2
rep movsw ; copy file name onto end
mov dx, es
mov bp, sp
add bp, 4 ; make up for pushes
gotPath: ; dx:bp is path
if GPC_FILE_OP_DIALOG_PATHNAME
call NormalizeProgressPath ; may be new buffer (dx:bp)
endif
mov bx, handle ProgressUI
pop si ; restore progress text field
push dx, bp
call CallSetText
pop dx, bp ; retrieve source name
mov bx, handle ActiveUI ; bx:si = active text field
pop si
cmp ss:[detachActiveHandling], TRUE ; detach-while-active box up?
jne done ; nope
cmp ss:[activeType], ACTIVE_TYPE_FILE_OPERATION
jne done ; nope
call CallSetText
done:
if GPC_FILE_OP_DIALOG_PATHNAME
call ClearProgressPathBuffer ; clear new buffer, if any
endif
add sp, SPAUAFOIN_BUFFER_SIZE ; remove stack buffer
.leave
ret
SetProgressAndUpdateActiveFileOpIfNeeded endp
if _FXIP
idata segment
endif
SBCS <progressNullPath char 0 >
DBCS <progressNullPath wchar 0 >
if _FXIP
idata ends
endif
if GPC_FILE_OP_DIALOG_PATHNAME
idata segment
progressPathBuffer hptr 0
idata ends
;
; pass: dx:bp = progress path
; return: ss:[progressPathBuffer]
;
NormalizeProgressPath proc near
uses ax, bx, cx, si, di, ds, es
.enter
mov es, dx
mov di, bp ; es:di = path
clr bx ; path contains drive name
call FileParseStandardPath
mov cx, ax ; save SP constant
GetResourceHandleNS FileOpDialogStrings, bx
call MemLock
mov ds, ax ; ds <- FileOpDialogString resource
mov ax, cx ; ax <- SP constant
cmp ax, SP_DOCUMENT
jne notDoc
mov si, offset docDirText
mov si, ds:[si]
call getStrLen ; cx <- len (with slash)
spCommon:
mov dx, ds
cmp {TCHAR}es:[di], 0
jne haveSlash
dec cx ; no tail, no slash
haveSlash:
push cx
mov ax, SPAUAFOIN_BUFFER_SIZE
mov cx, (mask HAF_ZERO_INIT shl 8) or ALLOC_DYNAMIC_LOCK
call MemAlloc
pop cx
jc done ; mem error, no normalize
pushdw esdi ; save tail offset
mov ss:[progressPathBuffer], bx
mov es, ax
clr di
LocalCopyNString
popdw dssi ; ds:si = tail, or just null
LocalCopyString
mov dx, es
clr bp
jmp short done
notDoc:
cmp ax, SP_APPLICATION
jne notAppDoc
mov si, offset appDirText
mov si, ds:[si]
call getStrLen ; assume tail, need slash
jmp short spCommon
notAppDoc:
cmp ax, SP_WASTE_BASKET
jne notWaste
mov si, offset wasteDirText
mov si, ds:[si]
call getStrLen ; assume tail, need slash
jmp short spCommon
notWaste:
cmp ax, STANDARD_PATH_OF_DESKTOP_VOLUME
jne notAppDocDesktop
push si
mov si, offset desktopPath
mov si, ds:[si]
call getStrLen
call LocalCmpStringsNoCase
pop si
jne notAppDocDesktop
mov bx, cx
cmp {TCHAR}es:[di][bx], 0
je gotDesktop
cmp {TCHAR}es:[di][bx], '\\'
jne notAppDocDesktop
inc di ; skip past "desktop\" in path
gotDesktop:
add di, bx ; skip past "desktop" in path
mov si, offset desktopText
mov si, ds:[si]
call getStrLen
jmp short spCommon
notAppDocDesktop:
done:
GetResourceHandleNS FileOpDialogStrings, bx
call MemUnlock
.leave
ret
getStrLen:
SBCS < clr al >
DBCS < clr ax >
pushdw esdi
segmov es, ds, cx
mov cx, -1
mov di, si
SBCS < repne scasb >
DBCS < repne scasw >
not cx
dec cx
popdw esdi
retn
NormalizeProgressPath endp
ClearProgressPathBuffer proc near
uses bx
.enter
clr bx
xchg bx, ss:[progressPathBuffer]
tst bx
jz done
call MemFree
done:
.leave
ret
ClearProgressPathBuffer endp
endif
;
; FileOperationProgressTypes must match this table
;
FileOpProgressBoxTable label word
word 0 ; FOPT_NONE
word offset DeleteProgressBox ; FOPT_DELETE
word offset DeleteProgressBox ; FOPT_THROW_AWAY
word offset MoveCopyProgressBox ; FOPT_COPY
word offset MoveCopyProgressBox ; FOPT_MOVE
LAST_FOPT_TABLE_ENTRY = ($-FileOpProgressBoxTable)
FileOpProgressSrcNameTable label word
word 0 ; FOPT_NONE
word offset DeleteProgressName ; FOPT_DELETE
word offset DeleteProgressName ; FOPT_THROW_AWAY
word offset MoveCopyProgressFrom ; FOPT_COPY
word offset MoveCopyProgressFrom ; FOPT_MOVE
FileOpProgressDestNameTable label word
word 0 ; FOPT_NONE
word 0 ; FOPT_DELETE
word 0 ; FOPT_THROW_AWAY
word offset MoveCopyProgressTo ; FOPT_COPY
word offset MoveCopyProgressTo ; FOPT_MOVE
FileOpProgressMonikerTable label word
word 0 ; FOPT_NONE
word offset DeleteProgressMoniker ; FOPT_DELETE
word offset ThrowAwayProgressMoniker ; FOPT_THROW_AWAY
word offset CopyProgressMoniker ; FOPT_COPY
word offset MoveProgressMoniker ; FOPT_MOVE
FileOpProgressMonikerObjTable label word
word 0 ; FOPT_NONE
word offset DeleteProgressNameGroup ; FOPT_DELETE
word offset DeleteProgressNameGroup ; FOPT_THROW_AWAY
word offset MoveCopyProgressFromGroup; FOPT_COPY
word offset MoveCopyProgressFromGroup; FOPT_MOVE
FileOpProgressStopTriggerTable label word
word 0 ; FOPT_NONE
word offset DeleteProgressCancel ; FOPT_DELETE
word offset DeleteProgressCancel ; FOPT_THROW_AWAY
word offset MoveCopyProgressCancel ; FOPT_COPY
word offset MoveCopyProgressCancel ; FOPT_MOVE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilCheckInfoEntrySubdir
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if the FileOperationInfoEntry at ds:si is in fact
a subdirectory
CALLED BY: INTERNAL
PASS: ds:si - FileOperationInfoEntry
RETURN: IF SUBDIR
carry flag set
ELSE
CF clear
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 9/24/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilCheckInfoEntrySubdir proc near
.enter
;
; Both "test" instructions clear the carry
;
test ds:[si].FOIE_attrs, mask FA_LINK
jnz done
test ds:[si].FOIE_attrs, mask FA_SUBDIR
jz done
stc
done:
.leave
ret
UtilCheckInfoEntrySubdir endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TryCloseOrSaveFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: try to close or save file to rename (close), move (save),
delete (close) file that is in-use
CALLED BY:
PASS: ds:dx = filename
correct path asserted
cx = 0 to close file
ax - error code
cx <> 0 to save file
RETURN: carry clear if file closed/saved, can try operation again
carry set if couldn't close
ax - error code unchanged
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 6/2/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if TRY_CLOSE_ON_IN_USE_ERROR
TCFExtAttrBuf struct
TEAB_attr FileAttrs
TEAB_type GeosFileType
TEAB_creator GeodeToken
TEAB_fileID FileID
TEAB_disk word
TCFExtAttrBuf ends
TCFExtAttrDesc struct
TEAD_attr FileExtAttrDesc
TEAD_type FileExtAttrDesc
TEAD_creator FileExtAttrDesc
TEAD_fileID FileExtAttrDesc
TEAD_disk FileExtAttrDesc
TCFExtAttrDesc ends
TryCloseOrSaveFile proc far
uses ax, bx, cx, dx, es, di, si
filenameOff local word push dx
eaBuf local TCFExtAttrBuf
eaDesc local TCFExtAttrDesc
iacpConnection local word
closeSaveMsg local word
.enter
mov closeSaveMsg, MSG_GEN_DOCUMENT_CLOSE
jcxz haveMsg
mov closeSaveMsg, MSG_GEN_DOCUMENT_SAVE
jmp short tryClose ; skip checking error code
haveMsg:
cmp ax, ERROR_SHARING_VIOLATION
je tryClose
cmp ax, ERROR_FILE_IN_USE
je tryClose
cmp ax, ERROR_ACCESS_DENIED
LONG jne noClose
tryClose:
mov eaDesc.TEAD_attr.FEAD_attr, FEA_FILE_ATTR
mov eaDesc.TEAD_attr.FEAD_size, size FileAttrs
mov eaDesc.TEAD_attr.FEAD_value.segment, ss
lea ax, eaBuf.TEAB_attr
mov eaDesc.TEAD_attr.FEAD_value.offset, ax
mov eaDesc.TEAD_type.FEAD_attr, FEA_FILE_TYPE
mov eaDesc.TEAD_type.FEAD_size, size GeosFileType
mov eaDesc.TEAD_type.FEAD_value.segment, ss
lea ax, eaBuf.TEAB_type
mov eaDesc.TEAD_type.FEAD_value.offset, ax
mov eaDesc.TEAD_creator.FEAD_attr, FEA_CREATOR
mov eaDesc.TEAD_creator.FEAD_size, size GeodeToken
mov eaDesc.TEAD_creator.FEAD_value.segment, ss
lea ax, eaBuf.TEAB_creator
mov eaDesc.TEAD_creator.FEAD_value.offset, ax
mov eaDesc.TEAD_fileID.FEAD_attr, FEA_FILE_ID
mov eaDesc.TEAD_fileID.FEAD_size, size FileID
mov eaDesc.TEAD_fileID.FEAD_value.segment, ss
lea ax, eaBuf.TEAB_fileID
mov eaDesc.TEAD_fileID.FEAD_value.offset, ax
mov eaDesc.TEAD_disk.FEAD_attr, FEA_DISK
mov eaDesc.TEAD_disk.FEAD_size, size word
mov eaDesc.TEAD_disk.FEAD_value.segment, ss
lea ax, eaBuf.TEAB_disk
mov eaDesc.TEAD_disk.FEAD_value.offset, ax
mov ax, FEA_MULTIPLE
segmov es, ss
lea di, eaDesc
mov cx, (size TCFExtAttrDesc)/(size FileExtAttrDesc)
call FileGetPathExtAttributes
LONG jc noClose ; couldn't fetch attrs
; -> not closable
test eaBuf.TEAB_attr, mask FA_SUBDIR
LONG jnz noClose
cmp eaBuf.TEAB_type, GFT_VM
LONG jne noClose
mov ax, {word} eaBuf.TEAB_creator.GT_chars
or ax, {word} eaBuf.TEAB_creator.GT_chars+2
or ax, eaBuf.TEAB_creator.GT_manufID
LONG jz noClose ; no creator
;
; Check if really in-use by this system (could be in-use by remote
; system!) A necessity for the save-for-copy.
;
mov ax, eaBuf.TEAB_disk ; ax = disk
movdw cxdx, eaBuf.TEAB_fileID ; cxdx = file ID
mov di, SEGMENT_CS
mov si, offset TCFCallback
clr bx ; process all files
call FileForEach
LONG jnc noClose ; not in use, don't bother
cmp closeSaveMsg, MSG_GEN_DOCUMENT_SAVE
je afterAsk ; don't ask for save
mov dx, filenameOff ; ds:dx = filename
mov ax, WARNING_OPERATION_FILE_IN_USE
call DesktopYesNoWarning
cmp ax, YESNO_YES
LONG jne noClose
afterAsk:
lea di, eaBuf.TEAB_creator
mov ax, mask IACPCF_FIRST_ONLY or \
(IACPSM_USER_INTERACTIBLE shl offset IACPCF_SERVER_MODE)
clr bx ; don't launch server, just
; find an existing one
push bp
call IACPConnect
mov bx, bp
pop bp
jnc 30$
cmp ax, IACPCE_NO_SERVER
LONG je wasClosed ; if we can't find the server,
; (and it was in-use),
; assume that the server
; went away in the mean-
; time -> file was closed
jmp noClose ; else, didn't close
30$:
mov iacpConnection, bx
; 1) allocate a queue
call GeodeAllocQueue
; OK, first, before trying to close/save, make sure the document has
; finished opening. Send the document a bogus message, w/a completion
; message so we know when its done being opened/aborted somehow(?)
; We can't "call" the server, only send it a message, and it can
; send us one back. However, we can't go on until we're sure the
; document is ready. Through the magic of the IACP completion message,
; we can do all this.
;
; 2) record a junk message to be send to this queue; this is the
; completion message we give to IACP
; 3) Build the dummy message
; 4) call IACPSendMessage to send the request. When it's done, the
; server (or IACP if the server has decided to vanish) will send
; the message recorded in #2 to our unattached event queue.
; 5) call QueueGetMessage to pluck the first message from the head
; of the queue. This will block until the server has done its thing.
; 6) nuke the junk message.
;
; bx = queue (dest for completion msg)
push bx ; save queue handle
mov ax, MSG_META_NOTIFY
mov cx, MANUFACTURER_ID_GEOWORKS
mov dx, GWNT_DOCUMENT_OPEN_COMPLETE
mov di, mask MF_RECORD
call ObjMessage
mov cx, di ; cx <- completion msg
push cx, bp
mov ax, MSG_META_DUMMY
mov bx, segment GenDocumentClass ; ClassedEvent
mov si, offset GenDocumentClass
mov di, mask MF_RECORD
call ObjMessage
pop cx, bp
mov bx, di ; bx <- msg to send
mov dx, TO_APP_MODEL ; send to model document
mov ax, IACPS_CLIENT
;
; PASS: bp = local vars
; bx = recorded message to send
; dx = TravelOption, -1 if recorded message
; contains the proper destination already
; cx = completionMsg, 0 if none
; ax = IACPSide doing the sending.
; RETURN: ax = number of servers to which message was sent
;
push bp
mov bp, iacpConnection
call IACPSendMessage
pop bp
pop bx ; get queue handle
call QueueGetMessage ; wait for junk completion msg to arrive
push bx
mov_tr bx, ax ; bx <- junk completion msg
call ObjFreeMessage ; nuke it
pop bx
;
; Send the document a message to close/save. There's a
; bit of fun, here, as we need to block until the server has
; processed the request. We can't "call" the server, only send it
; a message, and it can send us one back. However, we're not supposed
; to return from this routine until the print has either finished or
; been aborted. Through the magic of the IACP completion message,
; we can do all this.
;
; 2) record a junk message to be send to this queue; this is the
; completion message we give to IACP
; 3) Build the Print message
; 4) call IACPSendMessage to send the request. When it's done, the
; server (or IACP if the server has decided to vanish) will send
; the message recorded in #2 to our unattached event queue.
; 5) call QueueGetMessage to pluck the first message from the head
; of the queue. This will block until the server has done its thing.
; 6) nuke the the junk message.
;
; bx = queue (dest for completion msg)
push bx ; save queue handle
mov ax, MSG_META_DUMMY
mov di, mask MF_RECORD
call ObjMessage
mov cx, di ; cx <- completion msg
push cx, bp
mov ax, closeSaveMsg
mov bp, 0
mov bx, segment GenDocumentClass ; ClassedEvent
mov si, offset GenDocumentClass
mov di, mask MF_RECORD
call ObjMessage
pop cx, bp
mov bx, di ; bx <- msg to send
mov dx, TO_APP_MODEL ; send to model document
mov ax, IACPS_CLIENT
;
; PASS: bp = local vars
; bx = recorded message to send
; dx = TravelOption, -1 if recorded message
; contains the proper destination already
; cx = completionMsg, 0 if none
; ax = IACPSide doing the sending.
; RETURN: ax = number of servers to which message was sent
;
push bp
mov bp, iacpConnection
call IACPSendMessage
pop bp
pop bx ; get queue handle
call QueueGetMessage ; wait for junk completion msg to arrive
push bx
mov_tr bx, ax ; bx <- junk completion msg
call ObjFreeMessage ; nuke it
pop bx
;
; send dummy message to app model (document group -- document may be
; gone) to effectively flush queue for server and actually get the
; document closed/saved
;
; bx = queue (dest for completion msg)
push bx ; save queue handle
mov ax, MSG_META_DUMMY
mov di, mask MF_RECORD
call ObjMessage
mov cx, di ; cx <- completion msg
push cx, bp
mov bp, 0
mov ax, MSG_META_DUMMY
mov bx, segment GenDocumentGroupClass ; ClassedEvent
mov si, offset GenDocumentGroupClass
mov di, mask MF_RECORD
call ObjMessage
pop cx, bp
mov bx, di ; bx <- msg to send
mov dx, TO_APP_MODEL ; send to model document
mov ax, IACPS_CLIENT
;
; PASS: bp = local vars
; bx = recorded message to send
; dx = TravelOption, -1 if recorded message
; contains the proper destination already
; cx = completionMsg, 0 if none
; ax = IACPSide doing the sending.
; RETURN: ax = number of servers to which message was sent
;
push bp
mov bp, iacpConnection
call IACPSendMessage
pop bp
pop bx ; get queue handle
call QueueGetMessage ; wait for junk completion msg to arrive
push bx
mov_tr bx, ax ; bx <- junk completion msg
call ObjFreeMessage ; nuke it
pop bx
; 7) nuke the queue
; bx = queue
call GeodeFreeQueue ; nuke the queue (no further need)
push bp
clr cx, dx ; shutting down the client.
mov bp, iacpConnection
call IACPShutdown
pop bp
wasClosed:
clc ; indicate success
jmp short done
noClose:
stc
done:
.leave
ret
TryCloseOrSaveFile endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TCFCallback
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: callback function to check if file is in-use
CALLED BY: FileForEach (from TryCloseOrSaveFile)
PASS: ax - disk handle of file in question
cxdx - FileID of file in question
bx - handle of opened file
RETURN: carry set if file matches (i.e. file is in use)
carry clear otherwise
DESTROYED: di, es
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
may be broken out as a FileInUse? routine
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 6/3/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
TCFCBExtAttrBuf struct
TCBEAB_fileID FileID
TCBEAB_disk word
TCFCBExtAttrBuf ends
TCFCBExtAttrDesc struct
TCBEAD_fileID FileExtAttrDesc
TCBEAD_disk FileExtAttrDesc
TCFCBExtAttrDesc ends
TCFCallback proc far
uses ax, bx, cx, dx
fileDisk local word \
push ax
fileID local FileID
eaBuf local TCFCBExtAttrBuf
eaDesc local TCFCBExtAttrDesc
.enter
movdw fileID, cxdx
mov eaDesc.TCBEAD_fileID.FEAD_attr, FEA_FILE_ID
mov eaDesc.TCBEAD_fileID.FEAD_size, size FileID
mov eaDesc.TCBEAD_fileID.FEAD_value.segment, ss
lea ax, eaBuf.TCBEAB_fileID
mov eaDesc.TCBEAD_fileID.FEAD_value.offset, ax
mov eaDesc.TCBEAD_disk.FEAD_attr, FEA_DISK
mov eaDesc.TCBEAD_disk.FEAD_size, size word
mov eaDesc.TCBEAD_disk.FEAD_value.segment, ss
lea ax, eaBuf.TCBEAB_disk
mov eaDesc.TCBEAD_disk.FEAD_value.offset, ax
mov ax, FEA_MULTIPLE
segmov es, ss
lea di, eaDesc
mov cx, (size TCFCBExtAttrDesc)/(size FileExtAttrDesc)
call FileGetHandleExtAttributes
jc noMatch ; couldn't fetch attrs
; -> no match
mov ax, eaBuf.TCBEAB_disk ; ax = disk
cmp ax, fileDisk
jne noMatch
movdw cxdx, eaBuf.TCBEAB_fileID ; cxdx = file ID
cmpdw cxdx, fileID
jne noMatch
stc ; indicate match
jmp short done
noMatch:
clc
done:
.leave
ret
TCFCallback endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
EnsureLocalStandardPathSubdirs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: ensure that the destination directory of a copy, move or
create dir exists locally
CALLED BY: INTERNAL
CopyMoveFileOrDir
PASS: current directory is destination directory
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
do non-disk accessing stuff first
KNOWN BUGS/SIDE EFFECTS/IDEAS:
assumes that only one level of non-standard paths exists
below standard paths need be ensured
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 6/7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if ENSURE_LOCAL_SP_SUBDIRS
EnsureLocalStandardPathSubdirs proc far
pathBuf local PathName
dirPathInfo local DirPathInfo
uses ax, bx, cx, dx, ds, si, es, di
.enter
segmov ds, ss
lea si, pathBuf
mov cx, size pathBuf
call FileGetCurrentPath ; bx = disk handle (might be SP)
test bx, DISK_IS_STD_PATH_MASK
jz done ; not SP, nothing to do
SBCS < cmp {byte} pathBuf[0], 0 ; any tail? >
DBCS < cmp {wchar} pathBuf[0], 0 ; any tail? >
jz done ; nope, system will ensure full SP
;
; okay, we have SP with tail -- we assume tail is just one component,
; so we'll just do a create-dir and let the system ensure the local
; SP before creating the local tail
;
; let's actually check to see it the tail is one component, if not,
; then we must've been ensured previously
;
segmov es, ss
lea di, pathBuf
SBCS < mov al, 0 >
DBCS < clr ax >
mov cx, -1
SBCS < repne scasb >
DBCS < repne scasw >
not cx ; cx = length w/null
LocalLoadChar ax, C_BACKSLASH
lea di, pathBuf
SBCS < repne scasb >
DBCS < repne scasw >
je done ; found a '\\', more than 1 component
;
; one more check to see if current path exists locally
;
segmov ds, cs
mov dx, offset curPathPath
mov ax, FEA_PATH_INFO
segmov es, ss
lea di, dirPathInfo
mov cx, size dirPathInfo
call FileGetPathExtAttributes
test dirPathInfo, mask DPI_EXISTS_LOCALLY
jnz done ; exists locally, all done
;
; now create tail, letting system ensure SPs
;
call ShellPushToRoot
segmov ds, ss
lea dx, pathBuf
call FileCreateDir
call FilePopDir
jc done ; error create dir, leave at popped dir
segmov ds, ss
lea dx, pathBuf
call FileSetCurrentPath ; else, switch to newly created dir
done:
.leave
ret
EnsureLocalStandardPathSubdirs endp
LocalDefNLString curPathPath <'.'>
LocalDefNLString elspsNullPath <0>
endif
FileOpLow ends
|
src-checkers/ada_toml_decode.adb | pmderodat/ada-toml | 19 | 22950 | -- Test program. Read bytes on the standard input as a TOML document.
--
-- If it's a valid TOML document, parse it and emit on the standard output a
-- JSON representation of it.
--
-- If it's not a valid TOML document, print an error message on the standard
-- output.
with Ada.Command_Line;
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Interfaces;
with TOML;
with TOML.Generic_Parse;
procedure Ada_TOML_Decode is
use type TOML.Any_Value_Kind;
package Cmd renames Ada.Command_Line;
package IO renames Ada.Text_IO;
type Stdin_Stream is null record;
procedure Get
(Stream : in out Stdin_Stream; EOF : out Boolean; Byte : out Character);
-- Callback for TOML.Generic_Parse
subtype Wrapped_Kind is TOML.Any_Value_Kind
with Static_Predicate =>
Wrapped_Kind in TOML.TOML_Array .. TOML.TOML_Boolean
| TOML.TOML_Offset_Datetime | TOML.TOML_Local_Datetime
| TOML.TOML_Local_Date | TOML.TOML_Local_Time
| TOML.TOML_Float;
function Kind_Name (Kind : Wrapped_Kind) return String;
-- Return the name expected in the JSON output for the given kind
function Strip_Number (Image : String) return String;
-- If the first character in Image is a space, return the rest of Image
function Pad_Number (Image : String; Digit_Count : Positive) return String;
-- Return Strip_Number (Image) left-padded with 0 so that the result is
-- Digit_Count long.
procedure Dump_String (Value : TOML.Unbounded_UTF8_String);
-- Dump the given string as a JSON string literal
procedure Dump_Array (Value : TOML.TOML_Value)
with Pre => TOML."=" (Value.Kind, TOML.TOML_Array);
-- Dump the given TOML array as a JSON array
procedure Dump (Value : TOML.TOML_Value);
-- Dump the given TOML value using the expected JSON output format.
-- Toplevel must be true for the root table, root table children and table
-- arrays.
---------------
-- Kind_Name --
---------------
function Kind_Name (Kind : Wrapped_Kind) return String is
begin
return (case Kind is
when TOML.TOML_Array => "array",
when TOML.TOML_String => "string",
when TOML.TOML_Integer => "integer",
when TOML.TOML_Float => "float",
when TOML.TOML_Boolean => "bool",
when TOML.TOML_Offset_Datetime => "datetime",
when TOML.TOML_Local_Datetime => "datetime-local",
when TOML.TOML_Local_Date => "date-local",
when TOML.TOML_Local_Time => "time-local");
end Kind_Name;
------------------
-- Strip_Number --
------------------
function Strip_Number (Image : String) return String is
begin
if Image'Length > 0 and then Image (Image'First) = ' ' then
return Image (Image'First + 1 .. Image'Last);
else
return Image;
end if;
end Strip_Number;
----------------
-- Pad_Number --
----------------
function Pad_Number (Image : String; Digit_Count : Positive) return String
is
Result : constant String := Strip_Number (Image);
begin
pragma Assert (Result'Length <= Digit_Count);
return (Result'Length + 1 .. Digit_Count => '0') & Result;
end Pad_Number;
-----------------
-- Dump_String --
-----------------
procedure Dump_String (Value : TOML.Unbounded_UTF8_String) is
use Ada.Strings.Unbounded;
begin
IO.Put ("""");
declare
S : constant Wide_Wide_String :=
Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode
(To_String (Value));
begin
for C of S loop
if C in '"' | '\' then
IO.Put ("\" & Character'Val (Wide_Wide_Character'Pos (C)));
elsif C in ' ' .. '~' then
IO.Put ((1 => Character'Val (Wide_Wide_Character'Pos (C))));
else
declare
use type Interfaces.Unsigned_32;
Codepoint : Interfaces.Unsigned_32 :=
Wide_Wide_Character'Pos (C);
Digits_Count : constant Positive :=
(if Codepoint <= 16#FFFF# then 4 else 8);
CP_Digits : String (1 .. Digits_Count);
begin
if Digits_Count = 4 then
IO.Put ("\u");
else
IO.Put ("\U");
end if;
for D of reverse CP_Digits loop
declare
subtype Hex_Digit is
Interfaces.Unsigned_32 range 0 .. 15;
Digit : constant Hex_Digit := Codepoint mod 16;
begin
case Digit is
when 0 .. 9 =>
D := Character'Val (Character'Pos ('0') + Digit);
when 10 .. 15 =>
D := Character'Val
(Character'Pos ('A') + Digit - 10);
end case;
Codepoint := Codepoint / 16;
end;
end loop;
IO.Put (CP_Digits);
end;
end if;
end loop;
end;
IO.Put ("""");
end Dump_String;
----------------
-- Dump_Array --
----------------
procedure Dump_Array (Value : TOML.TOML_Value) is
begin
IO.Put_Line ("[");
for I in 1 .. Value.Length loop
if I > 1 then
IO.Put_Line (",");
end if;
Dump (Value.Item (I));
end loop;
IO.Put_Line ("]");
end Dump_Array;
----------
-- Dump --
----------
procedure Dump (Value : TOML.TOML_Value) is
use all type TOML.Any_Value_Kind;
procedure Put (Datetime : TOML.Any_Local_Datetime);
procedure Put (Date : TOML.Any_Local_Date);
procedure Put (Time : TOML.Any_Local_Time);
---------
-- Put --
---------
procedure Put (Datetime : TOML.Any_Local_Datetime) is
begin
Put (Datetime.Date);
IO.Put ("T");
Put (Datetime.Time);
end Put;
procedure Put (Date : TOML.Any_Local_Date) is
begin
IO.Put (Pad_Number (Date.Year'Image, 4)
& "-" & Pad_Number (Date.Month'Image, 2)
& "-" & Pad_Number (Date.Day'Image, 2));
end Put;
procedure Put (Time : TOML.Any_Local_Time) is
use type TOML.Any_Millisecond;
begin
IO.Put (Pad_Number (Time.Hour'Image, 2)
& ":" & Pad_Number (Time.Minute'Image, 2)
& ":" & Pad_Number (Time.Second'Image, 2));
if Time.Millisecond /= 0 then
IO.Put ("." & Pad_Number (Time.Millisecond'Image, 3));
end if;
end Put;
begin
if Value.Kind = TOML_Table then
IO.Put_Line ("{");
declare
Keys : constant TOML.Key_Array := Value.Keys;
begin
for I in Keys'Range loop
if I > Keys'First then
IO.Put_Line (",");
end if;
Dump_String (Keys (I));
IO.Put_Line (":");
Dump (Value.Get (Keys (I)));
end loop;
end;
IO.Put_Line ("}");
elsif Value.Kind = TOML.TOML_Array
and then (for all I in 1 .. Value.Length =>
Value.Item (I).Kind = TOML_Table)
then
Dump_Array (Value);
else
IO.Put_Line
("{""type"": """ & Kind_Name (Value.Kind) & """, ""value"":");
case Wrapped_Kind (Value.Kind) is
when TOML_Array =>
Dump_Array (Value);
when TOML_String =>
Dump_String (Value.As_Unbounded_String);
IO.New_Line;
when TOML_Integer =>
IO.Put_Line ("""" & Strip_Number (Value.As_Integer'Image)
& """");
when TOML_Float =>
declare
V : constant TOML.Any_Float := Value.As_Float;
begin
IO.Put ("""");
case V.Kind is
when TOML.Regular =>
IO.Put (Strip_Number (V.Value'Image));
when TOML.NaN =>
IO.Put (if V.Positive then "+" else "-");
IO.Put ("nan");
when TOML.Infinity =>
IO.Put (if V.Positive then "+" else "-");
IO.Put ("inf");
end case;
IO.Put_Line ("""");
end;
when TOML_Boolean =>
if Value.As_Boolean then
IO.Put_Line ("""true""");
else
IO.Put_Line ("""false""");
end if;
when TOML_Offset_Datetime =>
declare
use type TOML.Any_Local_Offset;
V : constant TOML.Any_Offset_Datetime :=
Value.As_Offset_Datetime;
Absolute_Offset : constant TOML.Any_Local_Offset :=
(if V.Offset < 0
then -V.Offset
else V.Offset);
Hour_Offset : constant TOML.Any_Local_Offset :=
Absolute_Offset / 60;
Minute_Offset : constant TOML.Any_Local_Offset :=
Absolute_Offset mod 60;
begin
IO.Put ("""");
Put (V.Datetime);
if V.Offset = 0 and then not V.Unknown_Offset then
IO.Put ("Z");
else
if V.Offset <= 0 then
IO.Put ("-");
else
IO.Put ("+");
end if;
IO.Put (Pad_Number (Hour_Offset'Image, 2)
& ":" & Pad_Number (Minute_Offset'Image, 2));
end if;
IO.Put_Line ("""");
end;
when TOML_Local_Datetime =>
IO.Put ("""");
Put (Value.As_Local_Datetime);
IO.Put_Line ("""");
when TOML_Local_Date =>
IO.Put ("""");
Put (Value.As_Local_Date);
IO.Put_Line ("""");
when TOML_Local_Time =>
IO.Put ("""");
Put (Value.As_Local_Time);
IO.Put_Line ("""");
end case;
IO.Put_Line ("}");
end if;
end Dump;
---------
-- Get --
---------
procedure Get
(Stream : in out Stdin_Stream; EOF : out Boolean; Byte : out Character)
is
pragma Unreferenced (Stream);
Available : Boolean;
begin
IO.Get_Immediate (Byte, Available);
EOF := not Available;
exception
when IO.End_Error =>
EOF := True;
end Get;
function Parse_File is new TOML.Generic_Parse (Stdin_Stream, Get);
Stdin : Stdin_Stream := (null record);
Result : constant TOML.Read_Result := Parse_File (Stdin);
begin
if Result.Success then
Dump (Result.Value);
else
IO.Put_Line (TOML.Format_Error (Result));
Cmd.Set_Exit_Status (Cmd.Failure);
end if;
end Ada_TOML_Decode;
|
programs/oeis/217/A217831.asm | neoneye/loda | 22 | 95685 | <reponame>neoneye/loda
; A217831: Triangle read by rows: label the entries T(0,0), T(1,0), T(0,1), T(2,0), T(1,1), T(0,2), T(3,0), ... Then T(n,k)=T(k,n), T(0,0)=0, T(1,0)=1, and for n>1, T(n,0)=0 and T(n,in+j)=T(n-j,j) (i,j >= 0, not both 0).
; 0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,1,1,1,0,0,1,0,0,0,1,0,0,1,1,1,1,1,1,0,0,1,0,1,0,1,0,1,0,0,1,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,1,1,1,1
lpb $0
mov $1,$0
add $2,1
sub $0,$2
gcd $1,$2
cmp $1,1
lpe
mov $0,$1
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/alignment13.adb | best08618/asylo | 7 | 13714 | -- { dg-do run }
-- { dg-options "-gnatws" }
procedure Alignment13 is
type Rec is record
I1 : aliased Short_Integer;
I2 : Integer;
end record;
for Rec use record
I1 at 0 range 0 .. 15;
end record;
R : Rec;
begin
if R.I2'Bit_Position /= 32 then
raise Program_Error;
end if;
end;
|
CPU/cpu_test/test_storage/test6_sw_R.asm | SilenceX12138/MIPS-Microsystems | 55 | 6865 | <gh_stars>10-100
ori $2,$0,1
ori $3,$0,3
addu $1,$2,$3
sw $2,-4($1)
ori $4,$0,9394
ori $5,$0,7337
addu $6,$4,$5
sw $6,4($0)
ori $8,$0,5
ori $9,$0,3
addu $7,$8,$9
nop
sw $7,0($7)
ori $11,$0,7
ori $12,$0,5
addu $10,$11,$12
nop
nop
sw $10,0($10) |
programs/oeis/069/A069010.asm | neoneye/loda | 22 | 84928 | <gh_stars>10-100
; A069010: Number of runs of 1's in binary representation of n.
; 0,1,1,1,1,2,1,1,1,2,2,2,1,2,1,1,1,2,2,2,2,3,2,2,1,2,2,2,1,2,1,1,1,2,2,2,2,3,2,2,2,3,3,3,2,3,2,2,1,2,2,2,2,3,2,2,1,2,2,2,1,2,1,1,1,2,2,2,2,3,2,2,2,3,3,3,2,3,2,2,2,3,3,3,3,4,3,3,2,3,3,3,2,3,2,2,1,2,2,2
lpb $0,3
add $1,$0
mod $1,2
add $2,$1
mov $1,$0
div $0,2
lpe
mov $1,$2
div $1,2
mov $0,$1
|
programs/oeis/141/A141726.asm | karttu/loda | 1 | 98709 | ; A141726: Sawtooth with period length 9: repeat 8, 7, 6, 5, 4, 3, 2, 1, 0.
; 8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,8,7,6,5,4,3
mod $0,9
sub $1,$0
add $1,8
|
DivideEtImpera.agda | NAMEhzj/Divide-and-Conquer-in-Agda | 0 | 979 | <filename>DivideEtImpera.agda
{-# OPTIONS --no-universe-polymorphism #-}
open import Induction.WellFounded as WF
open import Data.Product
open import Relation.Binary.Core
open import Relation.Unary as U using (Decidable)
open import Relation.Nullary
import Level as L using (zero)
module DivideEtImpera where
{-- This module implements a quite general version of Divide and Conquer as desribed by <NAME> in his paper
"The Design of Divide and Conquer Algorithms" 1984. the function makeD&C requires a well founded relation, a decidable proposition
of whether a given input is primitive, a composition and a decomposition function, a special function g and a function dirSolve.
All of these functions have to fullfill certain conditions and lastly you also need an "induction principle" that describes that these
functions work well together. After putting in all this work, you can finally reap your reward: an algorithm that does what you want:
takes inputs that satisfy the input condition and returns results that satisfy the output condition.
--}
{-- these 2 functions should be somewhere in the agda standard libraries but i couln't find them so i just wrote them again --}
foldAcc : {A : Set} → {_<_ : Rel A L.zero} → {R : A → Set} →
(step : (x : A) → ((y : A) → _<_ y x → R y) → R x) →
(z : A) → Acc _<_ z → R z
foldAcc step z (acc a) = step z (λ y y<z → foldAcc step y (a y y<z))
wfInd : {A : Set} {_<_ : Rel A _} → (WellFounded _<_) →
{R : A → Set} →
(step : (x : A) → ((y : A) → _<_ y x → R y) → R x) →
(z : A) → R z
wfInd wf step z = foldAcc step z (wf z)
{- the algorithm itself as one huge function:
instead of requiring all the functions and then five axioms describing their behaiviour, i use
dependent types to embedd four of the axions in therespective function they describe and
only the last one (called "lemma" here) as an extra. See the paper for details -}
makeD&C1 : {D₁ R₁ D₂ R₂ : Set} {I₁ : D₁ → Set} {O₁ : D₁ → R₁ → Set} {I₂ : D₂ → Set}
{O₂ : D₂ → R₂ → Set} {O₃ : D₁ → (D₂ × D₁) → Set} {O₄ : (R₂ × R₁) → R₁ → Set}
{_<_ : Rel D₁ _} → (wf : Well-founded _<_) → {Prim : D₁ → Set} → (pDec : U.Decidable Prim) →
(decomp : (x : D₁) → I₁ x → ¬ Prim x → Σ (D₂ × D₁)
λ y → I₂ (proj₁ y) × (I₁ (proj₂ y)) × (_<_ (proj₂ y) x) × (O₃ x y) ) →
(comp : (u : (R₂ × R₁)) → Σ R₁ (O₄ u)) →
(g : (x : D₂) → I₂ x → Σ R₂ (O₂ x)) →
(dirSolve : (x : D₁) → I₁ x → Prim x → Σ R₁ (O₁ x)) →
(lemma : ∀{x₀ x₁ x₂ z₀ z₁ z₂} → O₃ x₀ (x₁ , x₂) → O₂ x₁ z₁ → O₁ x₂ z₂ → O₄ (z₁ , z₂) z₀ → O₁ x₀ z₀) →
(x : D₁) → I₁ x → Σ R₁ (O₁ x)
makeD&C1 {D₁ = D₁} {R₁ = R₁} {I₁ = I₁} {O₁ = O₁} {_<_ = _<_} wf {Prim} pDec decomp comp g dirSolve lemma x = wfInd wf step x where
step : (x : D₁) → ((y : D₁) → _<_ y x → I₁ y → Σ R₁ (O₁ y)) → I₁ x → Σ R₁ (O₁ x)
step x rec ix with (pDec x)
step x rec ix | (yes pfY) = dirSolve x ix pfY
step x rec ix | (no pfN) = let dec = decomp x ix pfN
decV = proj₁ dec
decV1 = proj₁ decV
decV2 = proj₂ decV
decP = proj₂ dec
decP1 = proj₁ decP
decP2 = proj₁ (proj₂ decP)
decP3 = proj₁ (proj₂ (proj₂ decP))
decP4 = proj₂ (proj₂ (proj₂ decP))
gRes = g decV1 decP1
gV = proj₁ gRes
gP = proj₂ gRes
fRes = rec decV2 decP3 decP2
fV = proj₁ fRes
fP = proj₂ fRes
com = comp (gV , fV)
comV = proj₁ com
comP = proj₂ com
proof = lemma decP4 gP fP comP
in (comV , proof)
{- it occurred to me, that a proper Divide and conquer algorithm should make (at least) two recursive calls,
the algorithm describen inthe pape, however, only makes one! So slightly modified it to fit in that extra
recursive calls but left the basic principle exactly the same in this second version -}
makeD&C2 : {D₁ R₁ D₂ R₂ : Set} {I₁ : D₁ → Set} {O₁ : D₁ → R₁ → Set} {I₂ : D₂ → Set}
{O₂ : D₂ → R₂ → Set} {O₃ : D₁ → (D₂ × (D₁ × D₁)) → Set} {O₄ : (R₂ × (R₁ × R₁)) → R₁ → Set}
{_<_ : Rel D₁ _} → (wf : Well-founded _<_) → {Prim : D₁ → Set} → (pDec : U.Decidable Prim) →
(decomp : (x : D₁) → I₁ x → ¬ Prim x → Σ (D₂ × (D₁ × D₁))
λ y → (I₂ (proj₁ y)) × (I₁ (proj₁ (proj₂ y))) × (I₁ (proj₂ (proj₂ y))) ×
(_<_ (proj₁ (proj₂ y)) x) × (_<_ (proj₂ (proj₂ y)) x) × (O₃ x y) ) →
(comp : (u : (R₂ × (R₁ × R₁)) ) → Σ R₁ (O₄ u)) →
(g : (x : D₂) → I₂ x → Σ R₂ (O₂ x)) →
(dirSolve : (x : D₁) → I₁ x → Prim x → Σ R₁ (O₁ x)) →
(lemma : ∀{x₀ x₁ x₂ x₃ z₀ z₁ z₂ z₃} → O₃ x₀ (x₁ , (x₂ , x₃ )) → O₂ x₁ z₁ → O₁ x₂ z₂
→ O₁ x₃ z₃ → O₄ (z₁ , (z₂ , z₃)) z₀ → O₁ x₀ z₀) →
(x : D₁) → I₁ x → Σ R₁ (O₁ x)
makeD&C2 {D₁ = D₁} {R₁ = R₁} {I₁ = I₁} {O₁ = O₁} {_<_ = _<_} wf {Prim} pDec decomp comp g dirSolve lemma x = wfInd wf step x where
step : (x : D₁) → ((y : D₁) → _<_ y x → I₁ y → Σ R₁ (O₁ y)) → I₁ x → Σ R₁ (O₁ x)
step x rec ix with (pDec x)
step x rec ix | (yes pfY) = dirSolve x ix pfY
step x rec ix | (no pfN) = let dec = decomp x ix pfN
decV = proj₁ dec
decV1 = proj₁ decV
decV2 = proj₁ (proj₂ decV)
decV3 = proj₂ (proj₂ decV)
decP = proj₂ dec
decP1 = proj₁ decP
decP2 = proj₁ (proj₂ decP)
decP3 = proj₁ (proj₂ (proj₂ decP))
decP4 = proj₁ (proj₂ (proj₂ (proj₂ decP)))
decP5 = proj₁ (proj₂ (proj₂ (proj₂ (proj₂ decP))))
decP6 = proj₂ (proj₂ (proj₂ (proj₂ (proj₂ decP))))
gRes = g decV1 decP1
gV = proj₁ gRes
gP = proj₂ gRes
f1Res = rec decV2 decP4 decP2
f1V = proj₁ f1Res
f1P = proj₂ f1Res
f2Res = rec decV3 decP5 decP3
f2V = proj₁ f2Res
f2P = proj₂ f2Res
com = comp (gV , (f1V , f2V))
comV = proj₁ com
comP = proj₂ com
proof = lemma decP6 gP f1P f2P comP
in (comV , proof)
|
programs/oeis/244/A244728.asm | neoneye/loda | 22 | 105029 | <reponame>neoneye/loda
; A244728: a(n) = 9*n^3.
; 0,9,72,243,576,1125,1944,3087,4608,6561,9000,11979,15552,19773,24696,30375,36864,44217,52488,61731,72000,83349,95832,109503,124416,140625,158184,177147,197568,219501,243000,268119,294912,323433,353736,385875,419904,455877,493848,533871,576000,620289,666792,715563,766656,820125,876024,934407,995328,1058841,1125000,1193859,1265472,1339893,1417176,1497375,1580544,1666737,1756008,1848411,1944000,2042829,2144952,2250423,2359296,2471625,2587464,2706867,2829888,2956581,3087000,3221199,3359232,3501153,3647016,3796875,3950784,4108797,4270968,4437351,4608000,4782969,4962312,5146083,5334336,5527125,5724504,5926527,6133248,6344721,6561000,6782139,7008192,7239213,7475256,7716375,7962624,8214057,8470728,8732691
pow $0,3
mul $0,9
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/sem_ch6.adb | djamal2727/Main-Bearing-Analytical-Model | 0 | 26208 | <gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ C H 6 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Aspects; use Aspects;
with Atree; use Atree;
with Checks; use Checks;
with Contracts; use Contracts;
with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
with Expander; use Expander;
with Exp_Ch3; use Exp_Ch3;
with Exp_Ch6; use Exp_Ch6;
with Exp_Ch7; use Exp_Ch7;
with Exp_Ch9; use Exp_Ch9;
with Exp_Dbug; use Exp_Dbug;
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Freeze; use Freeze;
with Ghost; use Ghost;
with Inline; use Inline;
with Itypes; use Itypes;
with Lib.Xref; use Lib.Xref;
with Layout; use Layout;
with Namet; use Namet;
with Lib; use Lib;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Output; use Output;
with Restrict; use Restrict;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Cat; use Sem_Cat;
with Sem_Ch3; use Sem_Ch3;
with Sem_Ch4; use Sem_Ch4;
with Sem_Ch5; use Sem_Ch5;
with Sem_Ch8; use Sem_Ch8;
with Sem_Ch9; use Sem_Ch9;
with Sem_Ch10; use Sem_Ch10;
with Sem_Ch12; use Sem_Ch12;
with Sem_Ch13; use Sem_Ch13;
with Sem_Dim; use Sem_Dim;
with Sem_Disp; use Sem_Disp;
with Sem_Dist; use Sem_Dist;
with Sem_Elim; use Sem_Elim;
with Sem_Eval; use Sem_Eval;
with Sem_Mech; use Sem_Mech;
with Sem_Prag; use Sem_Prag;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sem_Type; use Sem_Type;
with Sem_Warn; use Sem_Warn;
with Sinput; use Sinput;
with Stand; use Stand;
with Sinfo; use Sinfo;
with Sinfo.CN; use Sinfo.CN;
with Snames; use Snames;
with Stringt; use Stringt;
with Style;
with Stylesw; use Stylesw;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
with Urealp; use Urealp;
with Validsw; use Validsw;
package body Sem_Ch6 is
May_Hide_Profile : Boolean := False;
-- This flag is used to indicate that two formals in two subprograms being
-- checked for conformance differ only in that one is an access parameter
-- while the other is of a general access type with the same designated
-- type. In this case, if the rest of the signatures match, a call to
-- either subprogram may be ambiguous, which is worth a warning. The flag
-- is set in Compatible_Types, and the warning emitted in
-- New_Overloaded_Entity.
-----------------------
-- Local Subprograms --
-----------------------
procedure Analyze_Function_Return (N : Node_Id);
-- Subsidiary to Analyze_Return_Statement. Called when the return statement
-- applies to a [generic] function.
procedure Analyze_Generic_Subprogram_Body (N : Node_Id; Gen_Id : Entity_Id);
-- Analyze a generic subprogram body. N is the body to be analyzed, and
-- Gen_Id is the defining entity Id for the corresponding spec.
procedure Analyze_Null_Procedure
(N : Node_Id;
Is_Completion : out Boolean);
-- A null procedure can be a declaration or (Ada 2012) a completion
procedure Analyze_Return_Statement (N : Node_Id);
-- Common processing for simple and extended return statements
procedure Analyze_Return_Type (N : Node_Id);
-- Subsidiary to Process_Formals: analyze subtype mark in function
-- specification in a context where the formals are visible and hide
-- outer homographs.
procedure Analyze_Subprogram_Body_Helper (N : Node_Id);
-- Does all the real work of Analyze_Subprogram_Body. This is split out so
-- that we can use RETURN but not skip the debug output at the end.
function Can_Override_Operator (Subp : Entity_Id) return Boolean;
-- Returns true if Subp can override a predefined operator.
procedure Check_Conformance
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Ctype : Conformance_Type;
Errmsg : Boolean;
Conforms : out Boolean;
Err_Loc : Node_Id := Empty;
Get_Inst : Boolean := False;
Skip_Controlling_Formals : Boolean := False);
-- Given two entities, this procedure checks that the profiles associated
-- with these entities meet the conformance criterion given by the third
-- parameter. If they conform, Conforms is set True and control returns
-- to the caller. If they do not conform, Conforms is set to False, and
-- in addition, if Errmsg is True on the call, proper messages are output
-- to complain about the conformance failure. If Err_Loc is non_Empty
-- the error messages are placed on Err_Loc, if Err_Loc is empty, then
-- error messages are placed on the appropriate part of the construct
-- denoted by New_Id. If Get_Inst is true, then this is a mode conformance
-- against a formal access-to-subprogram type so Get_Instance_Of must
-- be called.
procedure Check_Formal_Subprogram_Conformance
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id;
Errmsg : Boolean;
Conforms : out Boolean);
-- Core implementation of Check_Formal_Subprogram_Conformance from spec.
-- Errmsg can be set to False to not emit error messages.
-- Conforms is set to True if there is conformance, False otherwise.
procedure Check_Limited_Return
(N : Node_Id;
Expr : Node_Id;
R_Type : Entity_Id);
-- Check the appropriate (Ada 95 or Ada 2005) rules for returning limited
-- types. Used only for simple return statements. Expr is the expression
-- returned.
procedure Check_Subprogram_Order (N : Node_Id);
-- N is the N_Subprogram_Body node for a subprogram. This routine applies
-- the alpha ordering rule for N if this ordering requirement applicable.
procedure Check_Returns
(HSS : Node_Id;
Mode : Character;
Err : out Boolean;
Proc : Entity_Id := Empty);
-- Called to check for missing return statements in a function body, or for
-- returns present in a procedure body which has No_Return set. HSS is the
-- handled statement sequence for the subprogram body. This procedure
-- checks all flow paths to make sure they either have return (Mode = 'F',
-- used for functions) or do not have a return (Mode = 'P', used for
-- No_Return procedures). The flag Err is set if there are any control
-- paths not explicitly terminated by a return in the function case, and is
-- True otherwise. Proc is the entity for the procedure case and is used
-- in posting the warning message.
procedure Check_Untagged_Equality (Eq_Op : Entity_Id);
-- In Ada 2012, a primitive equality operator on an untagged record type
-- must appear before the type is frozen, and have the same visibility as
-- that of the type. This procedure checks that this rule is met, and
-- otherwise emits an error on the subprogram declaration and a warning
-- on the earlier freeze point if it is easy to locate. In Ada 2012 mode,
-- this routine outputs errors (or warnings if -gnatd.E is set). In earlier
-- versions of Ada, warnings are output if Warn_On_Ada_2012_Incompatibility
-- is set, otherwise the call has no effect.
procedure Enter_Overloaded_Entity (S : Entity_Id);
-- This procedure makes S, a new overloaded entity, into the first visible
-- entity with that name.
function Is_Non_Overriding_Operation
(Prev_E : Entity_Id;
New_E : Entity_Id) return Boolean;
-- Enforce the rule given in 12.3(18): a private operation in an instance
-- overrides an inherited operation only if the corresponding operation
-- was overriding in the generic. This needs to be checked for primitive
-- operations of types derived (in the generic unit) from formal private
-- or formal derived types.
procedure Make_Inequality_Operator (S : Entity_Id);
-- Create the declaration for an inequality operator that is implicitly
-- created by a user-defined equality operator that yields a boolean.
procedure Preanalyze_Formal_Expression (N : Node_Id; T : Entity_Id);
-- Preanalysis of default expressions of subprogram formals. N is the
-- expression to be analyzed and T is the expected type.
procedure Set_Formal_Validity (Formal_Id : Entity_Id);
-- Formal_Id is an formal parameter entity. This procedure deals with
-- setting the proper validity status for this entity, which depends on
-- the kind of parameter and the validity checking mode.
---------------------------------------------
-- Analyze_Abstract_Subprogram_Declaration --
---------------------------------------------
procedure Analyze_Abstract_Subprogram_Declaration (N : Node_Id) is
Scop : constant Entity_Id := Current_Scope;
Subp_Id : constant Entity_Id :=
Analyze_Subprogram_Specification (Specification (N));
begin
Generate_Definition (Subp_Id);
-- Set the SPARK mode from the current context (may be overwritten later
-- with explicit pragma).
Set_SPARK_Pragma (Subp_Id, SPARK_Mode_Pragma);
Set_SPARK_Pragma_Inherited (Subp_Id);
-- Preserve relevant elaboration-related attributes of the context which
-- are no longer available or very expensive to recompute once analysis,
-- resolution, and expansion are over.
Mark_Elaboration_Attributes
(N_Id => Subp_Id,
Checks => True,
Warnings => True);
Set_Is_Abstract_Subprogram (Subp_Id);
New_Overloaded_Entity (Subp_Id);
Check_Delayed_Subprogram (Subp_Id);
Set_Categorization_From_Scope (Subp_Id, Scop);
if Ekind (Scope (Subp_Id)) = E_Protected_Type then
Error_Msg_N ("abstract subprogram not allowed in protected type", N);
-- Issue a warning if the abstract subprogram is neither a dispatching
-- operation nor an operation that overrides an inherited subprogram or
-- predefined operator, since this most likely indicates a mistake.
elsif Warn_On_Redundant_Constructs
and then not Is_Dispatching_Operation (Subp_Id)
and then not Present (Overridden_Operation (Subp_Id))
and then (not Is_Operator_Symbol_Name (Chars (Subp_Id))
or else Scop /= Scope (Etype (First_Formal (Subp_Id))))
then
Error_Msg_N
("abstract subprogram is not dispatching or overriding?r?", N);
end if;
Generate_Reference_To_Formals (Subp_Id);
Check_Eliminated (Subp_Id);
if Has_Aspects (N) then
Analyze_Aspect_Specifications (N, Subp_Id);
end if;
end Analyze_Abstract_Subprogram_Declaration;
---------------------------------
-- Analyze_Expression_Function --
---------------------------------
procedure Analyze_Expression_Function (N : Node_Id) is
Expr : constant Node_Id := Expression (N);
Loc : constant Source_Ptr := Sloc (N);
LocX : constant Source_Ptr := Sloc (Expr);
Spec : constant Node_Id := Specification (N);
-- Local variables
Asp : Node_Id;
New_Body : Node_Id;
New_Spec : Node_Id;
Orig_N : Node_Id;
Ret : Node_Id;
Def_Id : Entity_Id := Empty;
Prev : Entity_Id;
-- If the expression is a completion, Prev is the entity whose
-- declaration is completed. Def_Id is needed to analyze the spec.
begin
-- This is one of the occasions on which we transform the tree during
-- semantic analysis. If this is a completion, transform the expression
-- function into an equivalent subprogram body, and analyze it.
-- Expression functions are inlined unconditionally. The back-end will
-- determine whether this is possible.
Inline_Processing_Required := True;
-- Create a specification for the generated body. This must be done
-- prior to the analysis of the initial declaration.
New_Spec := Copy_Subprogram_Spec (Spec);
Prev := Current_Entity_In_Scope (Defining_Entity (Spec));
-- If there are previous overloadable entities with the same name,
-- check whether any of them is completed by the expression function.
-- In a generic context a formal subprogram has no completion.
if Present (Prev)
and then Is_Overloadable (Prev)
and then not Is_Formal_Subprogram (Prev)
then
Def_Id := Analyze_Subprogram_Specification (Spec);
Prev := Find_Corresponding_Spec (N);
-- The previous entity may be an expression function as well, in
-- which case the redeclaration is illegal.
if Present (Prev)
and then Nkind (Original_Node (Unit_Declaration_Node (Prev))) =
N_Expression_Function
then
Error_Msg_Sloc := Sloc (Prev);
Error_Msg_N ("& conflicts with declaration#", Def_Id);
return;
end if;
end if;
Ret := Make_Simple_Return_Statement (LocX, Expr);
New_Body :=
Make_Subprogram_Body (Loc,
Specification => New_Spec,
Declarations => Empty_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (LocX,
Statements => New_List (Ret)));
Set_Was_Expression_Function (New_Body);
-- If the expression completes a generic subprogram, we must create a
-- separate node for the body, because at instantiation the original
-- node of the generic copy must be a generic subprogram body, and
-- cannot be a expression function. Otherwise we just rewrite the
-- expression with the non-generic body.
if Present (Prev) and then Ekind (Prev) = E_Generic_Function then
Insert_After (N, New_Body);
-- Propagate any aspects or pragmas that apply to the expression
-- function to the proper body when the expression function acts
-- as a completion.
if Has_Aspects (N) then
Move_Aspects (N, To => New_Body);
end if;
Relocate_Pragmas_To_Body (New_Body);
Rewrite (N, Make_Null_Statement (Loc));
Set_Has_Completion (Prev, False);
Analyze (N);
Analyze (New_Body);
Set_Is_Inlined (Prev);
-- If the expression function is a completion, the previous declaration
-- must come from source. We know already that it appears in the current
-- scope. The entity itself may be internally created if within a body
-- to be inlined.
elsif Present (Prev)
and then Is_Overloadable (Prev)
and then not Is_Formal_Subprogram (Prev)
and then Comes_From_Source (Parent (Prev))
then
Set_Has_Completion (Prev, False);
Set_Is_Inlined (Prev);
-- AI12-0103: Expression functions that are a completion freeze their
-- expression but don't freeze anything else (unlike regular bodies).
-- Note that we cannot defer this freezing to the analysis of the
-- expression itself, because a freeze node might appear in a nested
-- scope, leading to an elaboration order issue in gigi.
-- As elsewhere, we do not emit freeze nodes within a generic unit.
if not Inside_A_Generic then
Freeze_Expr_Types
(Def_Id => Def_Id,
Typ => Etype (Def_Id),
Expr => Expr,
N => N);
end if;
-- For navigation purposes, indicate that the function is a body
Generate_Reference (Prev, Defining_Entity (N), 'b', Force => True);
Rewrite (N, New_Body);
-- Remove any existing aspects from the original node because the act
-- of rewriting causes the list to be shared between the two nodes.
Orig_N := Original_Node (N);
Remove_Aspects (Orig_N);
-- Propagate any pragmas that apply to expression function to the
-- proper body when the expression function acts as a completion.
-- Aspects are automatically transfered because of node rewriting.
Relocate_Pragmas_To_Body (N);
Analyze (N);
-- Prev is the previous entity with the same name, but it is can
-- be an unrelated spec that is not completed by the expression
-- function. In that case the relevant entity is the one in the body.
-- Not clear that the backend can inline it in this case ???
if Has_Completion (Prev) then
-- The formals of the expression function are body formals,
-- and do not appear in the ali file, which will only contain
-- references to the formals of the original subprogram spec.
declare
F1 : Entity_Id;
F2 : Entity_Id;
begin
F1 := First_Formal (Def_Id);
F2 := First_Formal (Prev);
while Present (F1) loop
Set_Spec_Entity (F1, F2);
Next_Formal (F1);
Next_Formal (F2);
end loop;
end;
else
Set_Is_Inlined (Defining_Entity (New_Body));
end if;
-- If this is not a completion, create both a declaration and a body, so
-- that the expression can be inlined whenever possible.
else
-- An expression function that is not a completion is not a
-- subprogram declaration, and thus cannot appear in a protected
-- definition.
if Nkind (Parent (N)) = N_Protected_Definition then
Error_Msg_N
("an expression function is not a legal protected operation", N);
end if;
Rewrite (N, Make_Subprogram_Declaration (Loc, Specification => Spec));
-- Remove any existing aspects from the original node because the act
-- of rewriting causes the list to be shared between the two nodes.
Orig_N := Original_Node (N);
Remove_Aspects (Orig_N);
Analyze (N);
-- If aspect SPARK_Mode was specified on the body, it needs to be
-- repeated both on the generated spec and the body.
Asp := Find_Aspect (Defining_Unit_Name (Spec), Aspect_SPARK_Mode);
if Present (Asp) then
Asp := New_Copy_Tree (Asp);
Set_Analyzed (Asp, False);
Set_Aspect_Specifications (New_Body, New_List (Asp));
end if;
Def_Id := Defining_Entity (N);
Set_Is_Inlined (Def_Id);
-- Establish the linkages between the spec and the body. These are
-- used when the expression function acts as the prefix of attribute
-- 'Access in order to freeze the original expression which has been
-- moved to the generated body.
Set_Corresponding_Body (N, Defining_Entity (New_Body));
Set_Corresponding_Spec (New_Body, Def_Id);
-- Within a generic preanalyze the original expression for name
-- capture. The body is also generated but plays no role in
-- this because it is not part of the original source.
-- If this is an ignored Ghost entity, analysis of the generated
-- body is needed to hide external references (as is done in
-- Analyze_Subprogram_Body) after which the the subprogram profile
-- can be frozen, which is needed to expand calls to such an ignored
-- Ghost subprogram.
if Inside_A_Generic then
Set_Has_Completion (Def_Id, not Is_Ignored_Ghost_Entity (Def_Id));
Push_Scope (Def_Id);
Install_Formals (Def_Id);
Preanalyze_Spec_Expression (Expr, Etype (Def_Id));
End_Scope;
end if;
-- To prevent premature freeze action, insert the new body at the end
-- of the current declarations, or at the end of the package spec.
-- However, resolve usage names now, to prevent spurious visibility
-- on later entities. Note that the function can now be called in
-- the current declarative part, which will appear to be prior to
-- the presence of the body in the code. There are nevertheless no
-- order of elaboration issues because all name resolution has taken
-- place at the point of declaration.
declare
Decls : List_Id := List_Containing (N);
Expr : constant Node_Id := Expression (Ret);
Par : constant Node_Id := Parent (Decls);
Typ : constant Entity_Id := Etype (Def_Id);
begin
-- If this is a wrapper created for in an instance for a formal
-- subprogram, insert body after declaration, to be analyzed when
-- the enclosing instance is analyzed.
if GNATprove_Mode
and then Is_Generic_Actual_Subprogram (Def_Id)
then
Insert_After (N, New_Body);
else
if Nkind (Par) = N_Package_Specification
and then Decls = Visible_Declarations (Par)
and then Present (Private_Declarations (Par))
and then not Is_Empty_List (Private_Declarations (Par))
then
Decls := Private_Declarations (Par);
end if;
Insert_After (Last (Decls), New_Body);
-- Preanalyze the expression if not already done above
if not Inside_A_Generic then
Push_Scope (Def_Id);
Install_Formals (Def_Id);
Preanalyze_Formal_Expression (Expr, Typ);
Check_Limited_Return (Original_Node (N), Expr, Typ);
End_Scope;
end if;
-- In the case of an expression function marked with the
-- aspect Static, we need to check the requirement that the
-- function's expression is a potentially static expression.
-- This is done by making a full copy of the expression tree
-- and performing a special preanalysis on that tree with
-- the global flag Checking_Potentially_Static_Expression
-- enabled. If the resulting expression is static, then it's
-- OK, but if not, that means the expression violates the
-- requirements of the Ada 202x RM in 4.9(3.2/5-3.4/5) and
-- we flag an error.
if Is_Static_Function (Def_Id) then
if not Is_Static_Expression (Expr) then
declare
Exp_Copy : constant Node_Id := New_Copy_Tree (Expr);
begin
Set_Checking_Potentially_Static_Expression (True);
Preanalyze_Formal_Expression (Exp_Copy, Typ);
if not Is_Static_Expression (Exp_Copy) then
Error_Msg_N
("static expression function requires "
& "potentially static expression", Expr);
end if;
Set_Checking_Potentially_Static_Expression (False);
end;
end if;
-- We also make an additional copy of the expression and
-- replace the expression of the expression function with
-- this copy, because the currently present expression is
-- now associated with the body created for the static
-- expression function, which will later be analyzed and
-- possibly rewritten, and we need to have the separate
-- unanalyzed copy available for use with later static
-- calls.
Set_Expression
(Original_Node (Subprogram_Spec (Def_Id)),
New_Copy_Tree (Expr));
-- Mark static expression functions as inlined, to ensure
-- that even calls with nonstatic actuals will be inlined.
Set_Has_Pragma_Inline (Def_Id);
Set_Is_Inlined (Def_Id);
end if;
end if;
end;
end if;
-- Check incorrect use of dynamically tagged expression. This doesn't
-- fall out automatically when analyzing the generated function body,
-- because Check_Dynamically_Tagged_Expression deliberately ignores
-- nodes that don't come from source.
if Present (Def_Id)
and then Nkind (Def_Id) in N_Has_Etype
and then Is_Tagged_Type (Etype (Def_Id))
then
Check_Dynamically_Tagged_Expression
(Expr => Expr,
Typ => Etype (Def_Id),
Related_Nod => Original_Node (N));
end if;
-- We must enforce checks for unreferenced formals in our newly
-- generated function, so we propagate the referenced flag from the
-- original spec to the new spec as well as setting Comes_From_Source.
if Present (Parameter_Specifications (New_Spec)) then
declare
Form_New_Def : Entity_Id;
Form_New_Spec : Entity_Id;
Form_Old_Def : Entity_Id;
Form_Old_Spec : Entity_Id;
begin
Form_New_Spec := First (Parameter_Specifications (New_Spec));
Form_Old_Spec := First (Parameter_Specifications (Spec));
while Present (Form_New_Spec) and then Present (Form_Old_Spec) loop
Form_New_Def := Defining_Identifier (Form_New_Spec);
Form_Old_Def := Defining_Identifier (Form_Old_Spec);
Set_Comes_From_Source (Form_New_Def, True);
-- Because of the usefulness of unreferenced controlling
-- formals we exempt them from unreferenced warnings by marking
-- them as always referenced.
Set_Referenced (Form_Old_Def,
(Is_Formal (Form_Old_Def)
and then Is_Controlling_Formal (Form_Old_Def))
or else Referenced (Form_Old_Def));
Next (Form_New_Spec);
Next (Form_Old_Spec);
end loop;
end;
end if;
end Analyze_Expression_Function;
---------------------------------------
-- Analyze_Extended_Return_Statement --
---------------------------------------
procedure Analyze_Extended_Return_Statement (N : Node_Id) is
begin
Check_Compiler_Unit ("extended return statement", N);
Analyze_Return_Statement (N);
end Analyze_Extended_Return_Statement;
----------------------------
-- Analyze_Function_Call --
----------------------------
procedure Analyze_Function_Call (N : Node_Id) is
Actuals : constant List_Id := Parameter_Associations (N);
Func_Nam : constant Node_Id := Name (N);
Actual : Node_Id;
begin
Analyze (Func_Nam);
-- A call of the form A.B (X) may be an Ada 2005 call, which is
-- rewritten as B (A, X). If the rewriting is successful, the call
-- has been analyzed and we just return.
if Nkind (Func_Nam) = N_Selected_Component
and then Name (N) /= Func_Nam
and then Is_Rewrite_Substitution (N)
and then Present (Etype (N))
then
return;
end if;
-- If error analyzing name, then set Any_Type as result type and return
if Etype (Func_Nam) = Any_Type then
Set_Etype (N, Any_Type);
return;
end if;
-- Otherwise analyze the parameters
if Present (Actuals) then
Actual := First (Actuals);
while Present (Actual) loop
Analyze (Actual);
Check_Parameterless_Call (Actual);
Next (Actual);
end loop;
end if;
Analyze_Call (N);
end Analyze_Function_Call;
-----------------------------
-- Analyze_Function_Return --
-----------------------------
procedure Analyze_Function_Return (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Stm_Entity : constant Entity_Id := Return_Statement_Entity (N);
Scope_Id : constant Entity_Id := Return_Applies_To (Stm_Entity);
R_Type : constant Entity_Id := Etype (Scope_Id);
-- Function result subtype
procedure Check_No_Return_Expression (Return_Expr : Node_Id);
-- Ada 2020: Check that the return expression in a No_Return function
-- meets the conditions specified by RM 6.5.1(5.1/5).
procedure Check_Return_Construct_Accessibility (Return_Stmt : Node_Id);
-- Apply legality rule of 6.5 (5.9) to the access discriminants of an
-- aggregate in a return statement.
procedure Check_Return_Subtype_Indication (Obj_Decl : Node_Id);
-- Check that the return_subtype_indication properly matches the result
-- subtype of the function, as required by RM-6.5(5.1/2-5.3/2).
--------------------------------
-- Check_No_Return_Expression --
--------------------------------
procedure Check_No_Return_Expression (Return_Expr : Node_Id) is
Kind : constant Node_Kind := Nkind (Return_Expr);
begin
if Kind = N_Raise_Expression then
return;
elsif Kind = N_Function_Call
and then Is_Entity_Name (Name (Return_Expr))
and then Ekind (Entity (Name (Return_Expr))) in
E_Function | E_Generic_Function
and then No_Return (Entity (Name (Return_Expr)))
then
return;
end if;
Error_Msg_N
("illegal expression in RETURN statement of No_Return function",
Return_Expr);
Error_Msg_N
("\must be raise expression or call to No_Return (RM 6.5.1(5.1/5))",
Return_Expr);
end Check_No_Return_Expression;
------------------------------------------
-- Check_Return_Construct_Accessibility --
------------------------------------------
procedure Check_Return_Construct_Accessibility (Return_Stmt : Node_Id) is
Assoc : Node_Id;
Agg : Node_Id := Empty;
Discr : Entity_Id;
Expr : Node_Id;
Obj : Node_Id;
Process_Exprs : Boolean := False;
Return_Con : Node_Id;
begin
-- Only perform checks on record types with access discriminants and
-- non-internally generated functions.
if not Is_Record_Type (R_Type)
or else not Has_Discriminants (R_Type)
or else not Comes_From_Source (Return_Stmt)
then
return;
end if;
-- We are only interested in return statements
if Nkind (Return_Stmt) not in
N_Extended_Return_Statement | N_Simple_Return_Statement
then
return;
end if;
-- Fetch the object from the return statement, in the case of a
-- simple return statement the expression is part of the node.
if Nkind (Return_Stmt) = N_Extended_Return_Statement then
-- Obtain the object definition from the expanded extended return
Return_Con := First (Return_Object_Declarations (Return_Stmt));
while Present (Return_Con) loop
-- Inspect the original node to avoid object declarations
-- expanded into renamings.
if Nkind (Original_Node (Return_Con)) = N_Object_Declaration
and then Comes_From_Source (Original_Node (Return_Con))
then
exit;
end if;
Nlists.Next (Return_Con);
end loop;
pragma Assert (Present (Return_Con));
-- Could be dealing with a renaming
Return_Con := Original_Node (Return_Con);
else
Return_Con := Return_Stmt;
end if;
-- We may need to check an aggregate or a subtype indication
-- depending on how the discriminants were specified and whether
-- we are looking at an extended return statement.
if Nkind (Return_Con) = N_Object_Declaration
and then Nkind (Object_Definition (Return_Con))
= N_Subtype_Indication
then
Assoc := Original_Node
(First
(Constraints
(Constraint (Object_Definition (Return_Con)))));
else
-- Qualified expressions may be nested
Agg := Original_Node (Expression (Return_Con));
while Nkind (Agg) = N_Qualified_Expression loop
Agg := Original_Node (Expression (Agg));
end loop;
-- If we are looking at an aggregate instead of a function call we
-- can continue checking accessibility for the supplied
-- discriminant associations.
if Nkind (Agg) = N_Aggregate then
if Present (Expressions (Agg)) then
Assoc := First (Expressions (Agg));
Process_Exprs := True;
else
Assoc := First (Component_Associations (Agg));
end if;
-- Otherwise the expression is not of interest ???
else
return;
end if;
end if;
-- Move through the discriminants checking the accessibility level
-- of each co-extension's associated expression.
Discr := First_Discriminant (R_Type);
while Present (Discr) loop
if Ekind (Etype (Discr)) = E_Anonymous_Access_Type then
if Nkind (Assoc) = N_Attribute_Reference then
Expr := Assoc;
elsif Nkind (Assoc) in
N_Component_Association | N_Discriminant_Association
then
Expr := Expression (Assoc);
else
Expr := Empty;
end if;
-- This anonymous access discriminant has an associated
-- expression which needs checking.
if Present (Expr)
and then Nkind (Expr) = N_Attribute_Reference
and then Attribute_Name (Expr) /= Name_Unrestricted_Access
then
-- Obtain the object to perform static checks on by moving
-- up the prefixes in the expression taking into account
-- named access types and renamed objects within the
-- expression.
-- Note, this loop duplicates some of the logic in
-- Object_Access_Level since we have to check special rules
-- based on the context we are in (a return aggregate)
-- relating to formals of the current function.
Obj := Original_Node (Prefix (Expr));
loop
while Nkind (Obj) in N_Explicit_Dereference
| N_Indexed_Component
| N_Selected_Component
loop
-- When we encounter a named access type then we can
-- ignore accessibility checks on the dereference.
if Ekind (Etype (Original_Node (Prefix (Obj))))
in E_Access_Type ..
E_Access_Protected_Subprogram_Type
then
if Nkind (Obj) = N_Selected_Component then
Obj := Selector_Name (Obj);
else
Obj := Original_Node (Prefix (Obj));
end if;
exit;
end if;
Obj := Original_Node (Prefix (Obj));
end loop;
if Nkind (Obj) = N_Selected_Component then
Obj := Selector_Name (Obj);
end if;
-- Check for renamings
pragma Assert (Is_Entity_Name (Obj));
if Present (Renamed_Object (Entity (Obj))) then
Obj := Renamed_Object (Entity (Obj));
else
exit;
end if;
end loop;
-- Do not check aliased formals statically
if Is_Formal (Entity (Obj))
and then (Is_Aliased (Entity (Obj))
or else Ekind (Etype (Entity (Obj))) =
E_Anonymous_Access_Type)
then
null;
-- Otherwise, handle the expression normally, avoiding the
-- special logic above, and call Object_Access_Level with
-- the original expression.
elsif Object_Access_Level (Expr) >
Scope_Depth (Scope (Scope_Id))
then
Error_Msg_N
("access discriminant in return aggregate would "
& "be a dangling reference", Obj);
end if;
end if;
end if;
Next_Discriminant (Discr);
if not Is_List_Member (Assoc) then
Assoc := Empty;
else
Nlists.Next (Assoc);
end if;
-- After aggregate expressions, examine component associations if
-- present.
if No (Assoc) then
if Present (Agg)
and then Process_Exprs
and then Present (Component_Associations (Agg))
then
Assoc := First (Component_Associations (Agg));
Process_Exprs := False;
else
exit;
end if;
end if;
end loop;
end Check_Return_Construct_Accessibility;
-------------------------------------
-- Check_Return_Subtype_Indication --
-------------------------------------
procedure Check_Return_Subtype_Indication (Obj_Decl : Node_Id) is
Return_Obj : constant Node_Id := Defining_Identifier (Obj_Decl);
R_Stm_Type : constant Entity_Id := Etype (Return_Obj);
-- Subtype given in the extended return statement (must match R_Type)
Subtype_Ind : constant Node_Id :=
Object_Definition (Original_Node (Obj_Decl));
procedure Error_No_Match (N : Node_Id);
-- Output error messages for case where types do not statically
-- match. N is the location for the messages.
--------------------
-- Error_No_Match --
--------------------
procedure Error_No_Match (N : Node_Id) is
begin
Error_Msg_N
("subtype must statically match function result subtype", N);
if not Predicates_Match (R_Stm_Type, R_Type) then
Error_Msg_Node_2 := R_Type;
Error_Msg_NE
("\predicate of& does not match predicate of&",
N, R_Stm_Type);
end if;
end Error_No_Match;
-- Start of processing for Check_Return_Subtype_Indication
begin
-- First, avoid cascaded errors
if Error_Posted (Obj_Decl) or else Error_Posted (Subtype_Ind) then
return;
end if;
-- "return access T" case; check that the return statement also has
-- "access T", and that the subtypes statically match:
-- if this is an access to subprogram the signatures must match.
if Is_Anonymous_Access_Type (R_Type) then
if Is_Anonymous_Access_Type (R_Stm_Type) then
if Ekind (Designated_Type (R_Stm_Type)) /= E_Subprogram_Type
then
if Base_Type (Designated_Type (R_Stm_Type)) /=
Base_Type (Designated_Type (R_Type))
or else not Subtypes_Statically_Match (R_Stm_Type, R_Type)
then
Error_No_Match (Subtype_Mark (Subtype_Ind));
end if;
else
-- For two anonymous access to subprogram types, the types
-- themselves must be type conformant.
if not Conforming_Types
(R_Stm_Type, R_Type, Fully_Conformant)
then
Error_No_Match (Subtype_Ind);
end if;
end if;
else
Error_Msg_N ("must use anonymous access type", Subtype_Ind);
end if;
-- If the return object is of an anonymous access type, then report
-- an error if the function's result type is not also anonymous.
elsif Is_Anonymous_Access_Type (R_Stm_Type) then
pragma Assert (not Is_Anonymous_Access_Type (R_Type));
Error_Msg_N
("anonymous access not allowed for function with named access "
& "result", Subtype_Ind);
-- Subtype indication case: check that the return object's type is
-- covered by the result type, and that the subtypes statically match
-- when the result subtype is constrained. Also handle record types
-- with unknown discriminants for which we have built the underlying
-- record view. Coverage is needed to allow specific-type return
-- objects when the result type is class-wide (see AI05-32).
elsif Covers (Base_Type (R_Type), Base_Type (R_Stm_Type))
or else (Is_Underlying_Record_View (Base_Type (R_Stm_Type))
and then
Covers
(Base_Type (R_Type),
Underlying_Record_View (Base_Type (R_Stm_Type))))
then
-- A null exclusion may be present on the return type, on the
-- function specification, on the object declaration or on the
-- subtype itself.
if Is_Access_Type (R_Type)
and then
(Can_Never_Be_Null (R_Type)
or else Null_Exclusion_Present (Parent (Scope_Id))) /=
Can_Never_Be_Null (R_Stm_Type)
then
Error_No_Match (Subtype_Ind);
end if;
-- AI05-103: for elementary types, subtypes must statically match
if Is_Constrained (R_Type) or else Is_Access_Type (R_Type) then
if not Subtypes_Statically_Match (R_Stm_Type, R_Type) then
Error_No_Match (Subtype_Ind);
end if;
end if;
-- All remaining cases are illegal
-- Note: previous versions of this subprogram allowed the return
-- value to be the ancestor of the return type if the return type
-- was a null extension. This was plainly incorrect.
else
Error_Msg_N
("wrong type for return_subtype_indication", Subtype_Ind);
end if;
end Check_Return_Subtype_Indication;
---------------------
-- Local Variables --
---------------------
Expr : Node_Id;
Obj_Decl : Node_Id := Empty;
-- Start of processing for Analyze_Function_Return
begin
Set_Return_Present (Scope_Id);
if Nkind (N) = N_Simple_Return_Statement then
Expr := Expression (N);
-- Guard against a malformed expression. The parser may have tried to
-- recover but the node is not analyzable.
if Nkind (Expr) = N_Error then
Set_Etype (Expr, Any_Type);
Expander_Mode_Save_And_Set (False);
return;
else
-- The resolution of a controlled [extension] aggregate associated
-- with a return statement creates a temporary which needs to be
-- finalized on function exit. Wrap the return statement inside a
-- block so that the finalization machinery can detect this case.
-- This early expansion is done only when the return statement is
-- not part of a handled sequence of statements.
if Nkind (Expr) in N_Aggregate | N_Extension_Aggregate
and then Needs_Finalization (R_Type)
and then Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
then
Rewrite (N,
Make_Block_Statement (Loc,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (Relocate_Node (N)))));
Analyze (N);
return;
end if;
Analyze (Expr);
-- Ada 2005 (AI-251): If the type of the returned object is
-- an access to an interface type then we add an implicit type
-- conversion to force the displacement of the "this" pointer to
-- reference the secondary dispatch table. We cannot delay the
-- generation of this implicit conversion until the expansion
-- because in this case the type resolution changes the decoration
-- of the expression node to match R_Type; by contrast, if the
-- returned object is a class-wide interface type then it is too
-- early to generate here the implicit conversion since the return
-- statement may be rewritten by the expander into an extended
-- return statement whose expansion takes care of adding the
-- implicit type conversion to displace the pointer to the object.
if Expander_Active
and then Serious_Errors_Detected = 0
and then Is_Access_Type (R_Type)
and then Nkind (Expr) not in N_Null | N_Raise_Expression
and then Is_Interface (Designated_Type (R_Type))
and then Is_Progenitor (Designated_Type (R_Type),
Designated_Type (Etype (Expr)))
then
Rewrite (Expr, Convert_To (R_Type, Relocate_Node (Expr)));
Analyze (Expr);
end if;
Resolve (Expr, R_Type);
Check_Limited_Return (N, Expr, R_Type);
Check_Return_Construct_Accessibility (N);
-- Ada 2020 (AI12-0269): Any return statement that applies to a
-- nonreturning function shall be a simple_return_statement with
-- an expression that is a raise_expression, or else a call on a
-- nonreturning function, or else a parenthesized expression of
-- one of these.
if Ada_Version >= Ada_2020
and then No_Return (Scope_Id)
and then Comes_From_Source (N)
then
Check_No_Return_Expression (Original_Node (Expr));
end if;
end if;
else
Obj_Decl := Last (Return_Object_Declarations (N));
-- Analyze parts specific to extended_return_statement:
declare
Has_Aliased : constant Boolean := Aliased_Present (Obj_Decl);
HSS : constant Node_Id := Handled_Statement_Sequence (N);
begin
Expr := Expression (Obj_Decl);
-- Note: The check for OK_For_Limited_Init will happen in
-- Analyze_Object_Declaration; we treat it as a normal
-- object declaration.
Set_Is_Return_Object (Defining_Identifier (Obj_Decl));
-- Returning a build-in-place unconstrained array type we defer
-- the full analysis of the returned object to avoid generating
-- the corresponding constrained subtype; otherwise the bounds
-- would be created in the stack and a dangling reference would
-- be returned pointing to the bounds. We perform its preanalysis
-- to report errors on the initializing aggregate now (if any);
-- we also ensure its activation chain and Master variable are
-- defined (if tasks are being declared) since they are generated
-- as part of the analysis and expansion of the object declaration
-- at this stage.
if Is_Array_Type (R_Type)
and then not Is_Constrained (R_Type)
and then Is_Build_In_Place_Function (Scope_Id)
and then Needs_BIP_Alloc_Form (Scope_Id)
and then Nkind (Expr) in N_Aggregate | N_Extension_Aggregate
then
Preanalyze (Obj_Decl);
if Expander_Active then
Ensure_Activation_Chain_And_Master (Obj_Decl);
end if;
else
Analyze (Obj_Decl);
end if;
Check_Return_Subtype_Indication (Obj_Decl);
if Present (HSS) then
Analyze (HSS);
if Present (Exception_Handlers (HSS)) then
-- ???Has_Nested_Block_With_Handler needs to be set.
-- Probably by creating an actual N_Block_Statement.
-- Probably in Expand.
null;
end if;
end if;
-- Mark the return object as referenced, since the return is an
-- implicit reference of the object.
Set_Referenced (Defining_Identifier (Obj_Decl));
Check_References (Stm_Entity);
Check_Return_Construct_Accessibility (N);
-- Check RM 6.5 (5.9/3)
if Has_Aliased then
if Ada_Version < Ada_2012 then
-- Shouldn't this test Warn_On_Ada_2012_Compatibility ???
-- Can it really happen (extended return???)
Error_Msg_N
("aliased only allowed for limited return objects "
& "in Ada 2012??", N);
elsif not Is_Limited_View (R_Type) then
Error_Msg_N
("aliased only allowed for limited return objects", N);
end if;
end if;
-- Ada 2020 (AI12-0269): Any return statement that applies to a
-- nonreturning function shall be a simple_return_statement.
if Ada_Version >= Ada_2020
and then No_Return (Scope_Id)
and then Comes_From_Source (N)
then
Error_Msg_N
("extended RETURN statement not allowed in No_Return "
& "function", N);
end if;
end;
end if;
-- Case of Expr present
if Present (Expr) then
-- Defend against previous errors
if Nkind (Expr) = N_Empty
or else No (Etype (Expr))
then
return;
end if;
-- Apply constraint check. Note that this is done before the implicit
-- conversion of the expression done for anonymous access types to
-- ensure correct generation of the null-excluding check associated
-- with null-excluding expressions found in return statements. We
-- don't need a check if the subtype of the return object is the
-- same as the result subtype of the function.
if Nkind (N) /= N_Extended_Return_Statement
or else Nkind (Obj_Decl) /= N_Object_Declaration
or else Nkind (Object_Definition (Obj_Decl)) not in N_Has_Entity
or else Entity (Object_Definition (Obj_Decl)) /= R_Type
then
Apply_Constraint_Check (Expr, R_Type);
end if;
-- The return value is converted to the return type of the function,
-- which implies a predicate check if the return type is predicated.
-- We do not apply the check for an extended return statement because
-- Analyze_Object_Declaration has already done it on Obj_Decl above.
-- We do not apply the check to a case expression because it will
-- be expanded into a series of return statements, each of which
-- will receive a predicate check.
if Nkind (N) /= N_Extended_Return_Statement
and then Nkind (Expr) /= N_Case_Expression
then
Apply_Predicate_Check (Expr, R_Type);
end if;
-- Ada 2005 (AI-318-02): When the result type is an anonymous access
-- type, apply an implicit conversion of the expression to that type
-- to force appropriate static and run-time accessibility checks.
-- But we want to apply the checks to an extended return statement
-- only once, i.e. not to the simple return statement generated at
-- the end of its expansion because, prior to leaving the function,
-- the accessibility level of the return object changes to be a level
-- determined by the point of call (RM 3.10.2(10.8/3)).
if Ada_Version >= Ada_2005
and then Ekind (R_Type) = E_Anonymous_Access_Type
and then (Nkind (N) = N_Extended_Return_Statement
or else not Comes_From_Extended_Return_Statement (N))
then
Rewrite (Expr, Convert_To (R_Type, Relocate_Node (Expr)));
Analyze_And_Resolve (Expr, R_Type);
-- If this is a local anonymous access to subprogram, the
-- accessibility check can be applied statically. The return is
-- illegal if the access type of the return expression is declared
-- inside of the subprogram (except if it is the subtype indication
-- of an extended return statement).
elsif Ekind (R_Type) = E_Anonymous_Access_Subprogram_Type then
if not Comes_From_Source (Current_Scope)
or else Ekind (Current_Scope) = E_Return_Statement
then
null;
elsif
Scope_Depth (Scope (Etype (Expr))) >= Scope_Depth (Scope_Id)
then
Error_Msg_N ("cannot return local access to subprogram", N);
end if;
-- The expression cannot be of a formal incomplete type
elsif Ekind (Etype (Expr)) = E_Incomplete_Type
and then Is_Generic_Type (Etype (Expr))
then
Error_Msg_N
("cannot return expression of a formal incomplete type", N);
end if;
-- If the result type is class-wide, then check that the return
-- expression's type is not declared at a deeper level than the
-- function (RM05-6.5(5.6/2)).
if Ada_Version >= Ada_2005
and then Is_Class_Wide_Type (R_Type)
then
if Type_Access_Level (Etype (Expr)) >
Subprogram_Access_Level (Scope_Id)
then
Error_Msg_N
("level of return expression type is deeper than "
& "class-wide function!", Expr);
end if;
end if;
-- Check incorrect use of dynamically tagged expression
if Is_Tagged_Type (R_Type) then
Check_Dynamically_Tagged_Expression
(Expr => Expr,
Typ => R_Type,
Related_Nod => N);
end if;
-- ??? A real run-time accessibility check is needed in cases
-- involving dereferences of access parameters. For now we just
-- check the static cases.
if (Ada_Version < Ada_2005 or else Debug_Flag_Dot_L)
and then Is_Limited_View (Etype (Scope_Id))
and then Object_Access_Level (Expr) >
Subprogram_Access_Level (Scope_Id)
then
-- Suppress the message in a generic, where the rewriting
-- is irrelevant.
if Inside_A_Generic then
null;
else
Rewrite (N,
Make_Raise_Program_Error (Loc,
Reason => PE_Accessibility_Check_Failed));
Analyze (N);
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N ("cannot return a local value by reference<<", N);
Error_Msg_NE ("\& [<<", N, Standard_Program_Error);
end if;
end if;
if Known_Null (Expr)
and then Nkind (Parent (Scope_Id)) = N_Function_Specification
and then Null_Exclusion_Present (Parent (Scope_Id))
then
Apply_Compile_Time_Constraint_Error
(N => Expr,
Msg => "(Ada 2005) null not allowed for "
& "null-excluding return??",
Reason => CE_Null_Not_Allowed);
end if;
-- RM 6.5 (5.4/3): accessibility checks also apply if the return object
-- has no initializing expression.
elsif Ada_Version > Ada_2005 and then Is_Class_Wide_Type (R_Type) then
if Type_Access_Level (Etype (Defining_Identifier (Obj_Decl))) >
Subprogram_Access_Level (Scope_Id)
then
Error_Msg_N
("level of return expression type is deeper than "
& "class-wide function!", Obj_Decl);
end if;
end if;
end Analyze_Function_Return;
-------------------------------------
-- Analyze_Generic_Subprogram_Body --
-------------------------------------
procedure Analyze_Generic_Subprogram_Body
(N : Node_Id;
Gen_Id : Entity_Id)
is
Gen_Decl : constant Node_Id := Unit_Declaration_Node (Gen_Id);
Kind : constant Entity_Kind := Ekind (Gen_Id);
Body_Id : Entity_Id;
New_N : Node_Id;
Spec : Node_Id;
begin
-- Copy body and disable expansion while analyzing the generic For a
-- stub, do not copy the stub (which would load the proper body), this
-- will be done when the proper body is analyzed.
if Nkind (N) /= N_Subprogram_Body_Stub then
New_N := Copy_Generic_Node (N, Empty, Instantiating => False);
Rewrite (N, New_N);
-- Once the contents of the generic copy and the template are
-- swapped, do the same for their respective aspect specifications.
Exchange_Aspects (N, New_N);
-- Collect all contract-related source pragmas found within the
-- template and attach them to the contract of the subprogram body.
-- This contract is used in the capture of global references within
-- annotations.
Create_Generic_Contract (N);
Start_Generic;
end if;
Spec := Specification (N);
-- Within the body of the generic, the subprogram is callable, and
-- behaves like the corresponding non-generic unit.
Body_Id := Defining_Entity (Spec);
if Kind = E_Generic_Procedure
and then Nkind (Spec) /= N_Procedure_Specification
then
Error_Msg_N ("invalid body for generic procedure ", Body_Id);
return;
elsif Kind = E_Generic_Function
and then Nkind (Spec) /= N_Function_Specification
then
Error_Msg_N ("invalid body for generic function ", Body_Id);
return;
end if;
Set_Corresponding_Body (Gen_Decl, Body_Id);
if Has_Completion (Gen_Id)
and then Nkind (Parent (N)) /= N_Subunit
then
Error_Msg_N ("duplicate generic body", N);
return;
else
Set_Has_Completion (Gen_Id);
end if;
if Nkind (N) = N_Subprogram_Body_Stub then
Set_Ekind (Defining_Entity (Specification (N)), Kind);
else
Set_Corresponding_Spec (N, Gen_Id);
end if;
if Nkind (Parent (N)) = N_Compilation_Unit then
Set_Cunit_Entity (Current_Sem_Unit, Defining_Entity (N));
end if;
-- Make generic parameters immediately visible in the body. They are
-- needed to process the formals declarations. Then make the formals
-- visible in a separate step.
Push_Scope (Gen_Id);
declare
E : Entity_Id;
First_Ent : Entity_Id;
begin
First_Ent := First_Entity (Gen_Id);
E := First_Ent;
while Present (E) and then not Is_Formal (E) loop
Install_Entity (E);
Next_Entity (E);
end loop;
Set_Use (Generic_Formal_Declarations (Gen_Decl));
-- Now generic formals are visible, and the specification can be
-- analyzed, for subsequent conformance check.
Body_Id := Analyze_Subprogram_Specification (Spec);
-- Make formal parameters visible
if Present (E) then
-- E is the first formal parameter, we loop through the formals
-- installing them so that they will be visible.
Set_First_Entity (Gen_Id, E);
while Present (E) loop
Install_Entity (E);
Next_Formal (E);
end loop;
end if;
-- Visible generic entity is callable within its own body
Set_Ekind (Gen_Id, Ekind (Body_Id));
Set_Ekind (Body_Id, E_Subprogram_Body);
Set_Convention (Body_Id, Convention (Gen_Id));
Set_Is_Obsolescent (Body_Id, Is_Obsolescent (Gen_Id));
Set_Scope (Body_Id, Scope (Gen_Id));
Check_Fully_Conformant (Body_Id, Gen_Id, Body_Id);
if Nkind (N) = N_Subprogram_Body_Stub then
-- No body to analyze, so restore state of generic unit
Set_Ekind (Gen_Id, Kind);
Set_Ekind (Body_Id, Kind);
if Present (First_Ent) then
Set_First_Entity (Gen_Id, First_Ent);
end if;
End_Scope;
return;
end if;
-- If this is a compilation unit, it must be made visible explicitly,
-- because the compilation of the declaration, unlike other library
-- unit declarations, does not. If it is not a unit, the following
-- is redundant but harmless.
Set_Is_Immediately_Visible (Gen_Id);
Reference_Body_Formals (Gen_Id, Body_Id);
if Is_Child_Unit (Gen_Id) then
Generate_Reference (Gen_Id, Scope (Gen_Id), 'k', False);
end if;
Set_Actual_Subtypes (N, Current_Scope);
Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma);
Set_SPARK_Pragma_Inherited (Body_Id);
-- Analyze any aspect specifications that appear on the generic
-- subprogram body.
if Has_Aspects (N) then
Analyze_Aspects_On_Subprogram_Body_Or_Stub (N);
end if;
Analyze_Declarations (Declarations (N));
Check_Completion;
-- Process the contract of the subprogram body after all declarations
-- have been analyzed. This ensures that any contract-related pragmas
-- are available through the N_Contract node of the body.
Analyze_Entry_Or_Subprogram_Body_Contract (Body_Id);
Analyze (Handled_Statement_Sequence (N));
Save_Global_References (Original_Node (N));
-- Prior to exiting the scope, include generic formals again (if any
-- are present) in the set of local entities.
if Present (First_Ent) then
Set_First_Entity (Gen_Id, First_Ent);
end if;
Check_References (Gen_Id);
end;
Process_End_Label (Handled_Statement_Sequence (N), 't', Current_Scope);
Update_Use_Clause_Chain;
Validate_Categorization_Dependency (N, Gen_Id);
End_Scope;
Check_Subprogram_Order (N);
-- Outside of its body, unit is generic again
Set_Ekind (Gen_Id, Kind);
Generate_Reference (Gen_Id, Body_Id, 'b', Set_Ref => False);
if Style_Check then
Style.Check_Identifier (Body_Id, Gen_Id);
end if;
End_Generic;
end Analyze_Generic_Subprogram_Body;
----------------------------
-- Analyze_Null_Procedure --
----------------------------
-- WARNING: This routine manages Ghost regions. Return statements must be
-- replaced by gotos that jump to the end of the routine and restore the
-- Ghost mode.
procedure Analyze_Null_Procedure
(N : Node_Id;
Is_Completion : out Boolean)
is
Loc : constant Source_Ptr := Sloc (N);
Spec : constant Node_Id := Specification (N);
Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
Saved_ISMP : constant Boolean :=
Ignore_SPARK_Mode_Pragmas_In_Instance;
-- Save the Ghost and SPARK mode-related data to restore on exit
Designator : Entity_Id;
Form : Node_Id;
Null_Body : Node_Id := Empty;
Null_Stmt : Node_Id := Null_Statement (Spec);
Prev : Entity_Id;
begin
Prev := Current_Entity_In_Scope (Defining_Entity (Spec));
-- A null procedure is Ghost when it is stand-alone and is subject to
-- pragma Ghost, or when the corresponding spec is Ghost. Set the mode
-- now, to ensure that any nodes generated during analysis and expansion
-- are properly marked as Ghost.
if Present (Prev) then
Mark_And_Set_Ghost_Body (N, Prev);
end if;
-- Capture the profile of the null procedure before analysis, for
-- expansion at the freeze point and at each point of call. The body is
-- used if the procedure has preconditions, or if it is a completion. In
-- the first case the body is analyzed at the freeze point, in the other
-- it replaces the null procedure declaration.
-- For a null procedure that comes from source, a NULL statement is
-- provided by the parser, which carries the source location of the
-- NULL keyword, and has Comes_From_Source set. For a null procedure
-- from expansion, create one now.
if No (Null_Stmt) then
Null_Stmt := Make_Null_Statement (Loc);
end if;
Null_Body :=
Make_Subprogram_Body (Loc,
Specification => New_Copy_Tree (Spec),
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (Null_Stmt)));
-- Create new entities for body and formals
Set_Defining_Unit_Name (Specification (Null_Body),
Make_Defining_Identifier
(Sloc (Defining_Entity (N)),
Chars (Defining_Entity (N))));
Form := First (Parameter_Specifications (Specification (Null_Body)));
while Present (Form) loop
Set_Defining_Identifier (Form,
Make_Defining_Identifier
(Sloc (Defining_Identifier (Form)),
Chars (Defining_Identifier (Form))));
Next (Form);
end loop;
-- Determine whether the null procedure may be a completion of a generic
-- suprogram, in which case we use the new null body as the completion
-- and set minimal semantic information on the original declaration,
-- which is rewritten as a null statement.
if Present (Prev) and then Is_Generic_Subprogram (Prev) then
Insert_Before (N, Null_Body);
Set_Ekind (Defining_Entity (N), Ekind (Prev));
Rewrite (N, Make_Null_Statement (Loc));
Analyze_Generic_Subprogram_Body (Null_Body, Prev);
Is_Completion := True;
goto Leave;
else
-- Resolve the types of the formals now, because the freeze point may
-- appear in a different context, e.g. an instantiation.
Form := First (Parameter_Specifications (Specification (Null_Body)));
while Present (Form) loop
if Nkind (Parameter_Type (Form)) /= N_Access_Definition then
Find_Type (Parameter_Type (Form));
elsif No (Access_To_Subprogram_Definition
(Parameter_Type (Form)))
then
Find_Type (Subtype_Mark (Parameter_Type (Form)));
-- The case of a null procedure with a formal that is an
-- access-to-subprogram type, and that is used as an actual
-- in an instantiation is left to the enthusiastic reader.
else
null;
end if;
Next (Form);
end loop;
end if;
-- If there are previous overloadable entities with the same name, check
-- whether any of them is completed by the null procedure.
if Present (Prev) and then Is_Overloadable (Prev) then
Designator := Analyze_Subprogram_Specification (Spec);
Prev := Find_Corresponding_Spec (N);
end if;
if No (Prev) or else not Comes_From_Source (Prev) then
Designator := Analyze_Subprogram_Specification (Spec);
Set_Has_Completion (Designator);
-- Signal to caller that this is a procedure declaration
Is_Completion := False;
-- Null procedures are always inlined, but generic formal subprograms
-- which appear as such in the internal instance of formal packages,
-- need no completion and are not marked Inline.
if Expander_Active
and then Nkind (N) /= N_Formal_Concrete_Subprogram_Declaration
then
Set_Corresponding_Body (N, Defining_Entity (Null_Body));
Set_Body_To_Inline (N, Null_Body);
Set_Is_Inlined (Designator);
end if;
else
-- The null procedure is a completion. We unconditionally rewrite
-- this as a null body (even if expansion is not active), because
-- there are various error checks that are applied on this body
-- when it is analyzed (e.g. correct aspect placement).
if Has_Completion (Prev) then
Error_Msg_Sloc := Sloc (Prev);
Error_Msg_NE ("duplicate body for & declared#", N, Prev);
end if;
Check_Previous_Null_Procedure (N, Prev);
Is_Completion := True;
Rewrite (N, Null_Body);
Analyze (N);
end if;
<<Leave>>
Ignore_SPARK_Mode_Pragmas_In_Instance := Saved_ISMP;
Restore_Ghost_Region (Saved_GM, Saved_IGR);
end Analyze_Null_Procedure;
-----------------------------
-- Analyze_Operator_Symbol --
-----------------------------
-- An operator symbol such as "+" or "and" may appear in context where the
-- literal denotes an entity name, such as "+"(x, y) or in context when it
-- is just a string, as in (conjunction = "or"). In these cases the parser
-- generates this node, and the semantics does the disambiguation. Other
-- such case are actuals in an instantiation, the generic unit in an
-- instantiation, and pragma arguments.
procedure Analyze_Operator_Symbol (N : Node_Id) is
Par : constant Node_Id := Parent (N);
begin
if (Nkind (Par) = N_Function_Call and then N = Name (Par))
or else Nkind (Par) = N_Function_Instantiation
or else (Nkind (Par) = N_Indexed_Component and then N = Prefix (Par))
or else (Nkind (Par) = N_Pragma_Argument_Association
and then not Is_Pragma_String_Literal (Par))
or else Nkind (Par) = N_Subprogram_Renaming_Declaration
or else (Nkind (Par) = N_Attribute_Reference
and then Attribute_Name (Par) /= Name_Value)
then
Find_Direct_Name (N);
else
Change_Operator_Symbol_To_String_Literal (N);
Analyze (N);
end if;
end Analyze_Operator_Symbol;
-----------------------------------
-- Analyze_Parameter_Association --
-----------------------------------
procedure Analyze_Parameter_Association (N : Node_Id) is
begin
Analyze (Explicit_Actual_Parameter (N));
end Analyze_Parameter_Association;
----------------------------
-- Analyze_Procedure_Call --
----------------------------
-- WARNING: This routine manages Ghost regions. Return statements must be
-- replaced by gotos that jump to the end of the routine and restore the
-- Ghost mode.
procedure Analyze_Procedure_Call (N : Node_Id) is
procedure Analyze_Call_And_Resolve;
-- Do Analyze and Resolve calls for procedure call. At the end, check
-- for illegal order dependence.
-- ??? where is the check for illegal order dependencies?
------------------------------
-- Analyze_Call_And_Resolve --
------------------------------
procedure Analyze_Call_And_Resolve is
begin
if Nkind (N) = N_Procedure_Call_Statement then
Analyze_Call (N);
Resolve (N, Standard_Void_Type);
else
Analyze (N);
end if;
end Analyze_Call_And_Resolve;
-- Local variables
Actuals : constant List_Id := Parameter_Associations (N);
Loc : constant Source_Ptr := Sloc (N);
P : constant Node_Id := Name (N);
Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
-- Save the Ghost-related attributes to restore on exit
Actual : Node_Id;
New_N : Node_Id;
-- Start of processing for Analyze_Procedure_Call
begin
-- The syntactic construct: PREFIX ACTUAL_PARAMETER_PART can denote
-- a procedure call or an entry call. The prefix may denote an access
-- to subprogram type, in which case an implicit dereference applies.
-- If the prefix is an indexed component (without implicit dereference)
-- then the construct denotes a call to a member of an entire family.
-- If the prefix is a simple name, it may still denote a call to a
-- parameterless member of an entry family. Resolution of these various
-- interpretations is delicate.
-- Do not analyze machine code statements to avoid rejecting them in
-- CodePeer mode.
if CodePeer_Mode and then Nkind (P) = N_Qualified_Expression then
Set_Etype (P, Standard_Void_Type);
else
Analyze (P);
end if;
-- If this is a call of the form Obj.Op, the call may have been analyzed
-- and possibly rewritten into a block, in which case we are done.
if Analyzed (N) then
return;
-- If there is an error analyzing the name (which may have been
-- rewritten if the original call was in prefix notation) then error
-- has been emitted already, mark node and return.
elsif Error_Posted (N) or else Etype (Name (N)) = Any_Type then
Set_Etype (N, Any_Type);
return;
end if;
-- A procedure call is Ghost when its name denotes a Ghost procedure.
-- Set the mode now to ensure that any nodes generated during analysis
-- and expansion are properly marked as Ghost.
Mark_And_Set_Ghost_Procedure_Call (N);
-- Otherwise analyze the parameters
if Present (Actuals) then
Actual := First (Actuals);
while Present (Actual) loop
Analyze (Actual);
Check_Parameterless_Call (Actual);
Next (Actual);
end loop;
end if;
-- Special processing for Elab_Spec, Elab_Body and Elab_Subp_Body calls
if Nkind (P) = N_Attribute_Reference
and then Attribute_Name (P) in Name_Elab_Spec
| Name_Elab_Body
| Name_Elab_Subp_Body
then
if Present (Actuals) then
Error_Msg_N
("no parameters allowed for this call", First (Actuals));
goto Leave;
end if;
Set_Etype (N, Standard_Void_Type);
Set_Analyzed (N);
elsif Is_Entity_Name (P)
and then Is_Record_Type (Etype (Entity (P)))
and then Remote_AST_I_Dereference (P)
then
goto Leave;
elsif Is_Entity_Name (P)
and then Ekind (Entity (P)) /= E_Entry_Family
then
if Is_Access_Type (Etype (P))
and then Ekind (Designated_Type (Etype (P))) = E_Subprogram_Type
and then No (Actuals)
and then Comes_From_Source (N)
then
Error_Msg_N ("missing explicit dereference in call", N);
elsif Ekind (Entity (P)) = E_Operator then
Error_Msg_Name_1 := Chars (P);
Error_Msg_N ("operator % cannot be used as a procedure", N);
end if;
Analyze_Call_And_Resolve;
-- If the prefix is the simple name of an entry family, this is a
-- parameterless call from within the task body itself.
elsif Is_Entity_Name (P)
and then Nkind (P) = N_Identifier
and then Ekind (Entity (P)) = E_Entry_Family
and then Present (Actuals)
and then No (Next (First (Actuals)))
then
-- Can be call to parameterless entry family. What appears to be the
-- sole argument is in fact the entry index. Rewrite prefix of node
-- accordingly. Source representation is unchanged by this
-- transformation.
New_N :=
Make_Indexed_Component (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (Scope (Entity (P)), Loc),
Selector_Name => New_Occurrence_Of (Entity (P), Loc)),
Expressions => Actuals);
Set_Name (N, New_N);
Set_Etype (New_N, Standard_Void_Type);
Set_Parameter_Associations (N, No_List);
Analyze_Call_And_Resolve;
elsif Nkind (P) = N_Explicit_Dereference then
if Ekind (Etype (P)) = E_Subprogram_Type then
Analyze_Call_And_Resolve;
else
Error_Msg_N ("expect access to procedure in call", P);
end if;
-- The name can be a selected component or an indexed component that
-- yields an access to subprogram. Such a prefix is legal if the call
-- has parameter associations.
elsif Is_Access_Type (Etype (P))
and then Ekind (Designated_Type (Etype (P))) = E_Subprogram_Type
then
if Present (Actuals) then
Analyze_Call_And_Resolve;
else
Error_Msg_N ("missing explicit dereference in call ", N);
end if;
-- If not an access to subprogram, then the prefix must resolve to the
-- name of an entry, entry family, or protected operation.
-- For the case of a simple entry call, P is a selected component where
-- the prefix is the task and the selector name is the entry. A call to
-- a protected procedure will have the same syntax. If the protected
-- object contains overloaded operations, the entity may appear as a
-- function, the context will select the operation whose type is Void.
elsif Nkind (P) = N_Selected_Component
and then Ekind (Entity (Selector_Name (P)))
in E_Entry | E_Function | E_Procedure
then
-- When front-end inlining is enabled, as with SPARK_Mode, a call
-- in prefix notation may still be missing its controlling argument,
-- so perform the transformation now.
if SPARK_Mode = On and then In_Inlined_Body then
declare
Subp : constant Entity_Id := Entity (Selector_Name (P));
Typ : constant Entity_Id := Etype (Prefix (P));
begin
if Is_Tagged_Type (Typ)
and then Present (First_Formal (Subp))
and then (Etype (First_Formal (Subp)) = Typ
or else
Class_Wide_Type (Etype (First_Formal (Subp))) = Typ)
and then Try_Object_Operation (P)
then
return;
else
Analyze_Call_And_Resolve;
end if;
end;
else
Analyze_Call_And_Resolve;
end if;
elsif Nkind (P) = N_Selected_Component
and then Ekind (Entity (Selector_Name (P))) = E_Entry_Family
and then Present (Actuals)
and then No (Next (First (Actuals)))
then
-- Can be call to parameterless entry family. What appears to be the
-- sole argument is in fact the entry index. Rewrite prefix of node
-- accordingly. Source representation is unchanged by this
-- transformation.
New_N :=
Make_Indexed_Component (Loc,
Prefix => New_Copy (P),
Expressions => Actuals);
Set_Name (N, New_N);
Set_Etype (New_N, Standard_Void_Type);
Set_Parameter_Associations (N, No_List);
Analyze_Call_And_Resolve;
-- For the case of a reference to an element of an entry family, P is
-- an indexed component whose prefix is a selected component (task and
-- entry family), and whose index is the entry family index.
elsif Nkind (P) = N_Indexed_Component
and then Nkind (Prefix (P)) = N_Selected_Component
and then Ekind (Entity (Selector_Name (Prefix (P)))) = E_Entry_Family
then
Analyze_Call_And_Resolve;
-- If the prefix is the name of an entry family, it is a call from
-- within the task body itself.
elsif Nkind (P) = N_Indexed_Component
and then Nkind (Prefix (P)) = N_Identifier
and then Ekind (Entity (Prefix (P))) = E_Entry_Family
then
New_N :=
Make_Selected_Component (Loc,
Prefix =>
New_Occurrence_Of (Scope (Entity (Prefix (P))), Loc),
Selector_Name => New_Occurrence_Of (Entity (Prefix (P)), Loc));
Rewrite (Prefix (P), New_N);
Analyze (P);
Analyze_Call_And_Resolve;
-- In Ada 2012. a qualified expression is a name, but it cannot be a
-- procedure name, so the construct can only be a qualified expression.
elsif Nkind (P) = N_Qualified_Expression
and then Ada_Version >= Ada_2012
then
Rewrite (N, Make_Code_Statement (Loc, Expression => P));
Analyze (N);
-- Anything else is an error
else
Error_Msg_N ("invalid procedure or entry call", N);
end if;
<<Leave>>
Restore_Ghost_Region (Saved_GM, Saved_IGR);
end Analyze_Procedure_Call;
------------------------------
-- Analyze_Return_Statement --
------------------------------
procedure Analyze_Return_Statement (N : Node_Id) is
pragma Assert
(Nkind (N) in N_Extended_Return_Statement | N_Simple_Return_Statement);
Returns_Object : constant Boolean :=
Nkind (N) = N_Extended_Return_Statement
or else
(Nkind (N) = N_Simple_Return_Statement
and then Present (Expression (N)));
-- True if we're returning something; that is, "return <expression>;"
-- or "return Result : T [:= ...]". False for "return;". Used for error
-- checking: If Returns_Object is True, N should apply to a function
-- body; otherwise N should apply to a procedure body, entry body,
-- accept statement, or extended return statement.
function Find_What_It_Applies_To return Entity_Id;
-- Find the entity representing the innermost enclosing body, accept
-- statement, or extended return statement. If the result is a callable
-- construct or extended return statement, then this will be the value
-- of the Return_Applies_To attribute. Otherwise, the program is
-- illegal. See RM-6.5(4/2).
-----------------------------
-- Find_What_It_Applies_To --
-----------------------------
function Find_What_It_Applies_To return Entity_Id is
Result : Entity_Id := Empty;
begin
-- Loop outward through the Scope_Stack, skipping blocks, loops,
-- and postconditions.
for J in reverse 0 .. Scope_Stack.Last loop
Result := Scope_Stack.Table (J).Entity;
exit when Ekind (Result) not in E_Block | E_Loop
and then Chars (Result) /= Name_uPostconditions;
end loop;
pragma Assert (Present (Result));
return Result;
end Find_What_It_Applies_To;
-- Local declarations
Scope_Id : constant Entity_Id := Find_What_It_Applies_To;
Kind : constant Entity_Kind := Ekind (Scope_Id);
Loc : constant Source_Ptr := Sloc (N);
Stm_Entity : constant Entity_Id :=
New_Internal_Entity
(E_Return_Statement, Current_Scope, Loc, 'R');
-- Start of processing for Analyze_Return_Statement
begin
Set_Return_Statement_Entity (N, Stm_Entity);
Set_Etype (Stm_Entity, Standard_Void_Type);
Set_Return_Applies_To (Stm_Entity, Scope_Id);
-- Place Return entity on scope stack, to simplify enforcement of 6.5
-- (4/2): an inner return statement will apply to this extended return.
if Nkind (N) = N_Extended_Return_Statement then
Push_Scope (Stm_Entity);
end if;
-- Check that pragma No_Return is obeyed. Don't complain about the
-- implicitly-generated return that is placed at the end.
if No_Return (Scope_Id)
and then Kind in E_Procedure | E_Generic_Procedure
and then Comes_From_Source (N)
then
Error_Msg_N
("RETURN statement not allowed in No_Return procedure", N);
end if;
-- Warn on any unassigned OUT parameters if in procedure
if Ekind (Scope_Id) = E_Procedure then
Warn_On_Unassigned_Out_Parameter (N, Scope_Id);
end if;
-- Check that functions return objects, and other things do not
if Kind in E_Function | E_Generic_Function then
if not Returns_Object then
Error_Msg_N ("missing expression in return from function", N);
end if;
elsif Kind in E_Procedure | E_Generic_Procedure then
if Returns_Object then
Error_Msg_N ("procedure cannot return value (use function)", N);
end if;
elsif Kind in E_Entry | E_Entry_Family then
if Returns_Object then
if Is_Protected_Type (Scope (Scope_Id)) then
Error_Msg_N ("entry body cannot return value", N);
else
Error_Msg_N ("accept statement cannot return value", N);
end if;
end if;
elsif Kind = E_Return_Statement then
-- We are nested within another return statement, which must be an
-- extended_return_statement.
if Returns_Object then
if Nkind (N) = N_Extended_Return_Statement then
Error_Msg_N
("extended return statement cannot be nested (use `RETURN;`)",
N);
-- Case of a simple return statement with a value inside extended
-- return statement.
else
Error_Msg_N
("return nested in extended return statement cannot return "
& "value (use `RETURN;`)", N);
end if;
end if;
else
Error_Msg_N ("illegal context for return statement", N);
end if;
if Kind in E_Function | E_Generic_Function then
Analyze_Function_Return (N);
elsif Kind in E_Procedure | E_Generic_Procedure then
Set_Return_Present (Scope_Id);
end if;
if Nkind (N) = N_Extended_Return_Statement then
End_Scope;
end if;
Kill_Current_Values (Last_Assignment_Only => True);
Check_Unreachable_Code (N);
Analyze_Dimension (N);
end Analyze_Return_Statement;
-------------------------------------
-- Analyze_Simple_Return_Statement --
-------------------------------------
procedure Analyze_Simple_Return_Statement (N : Node_Id) is
begin
if Present (Expression (N)) then
Mark_Coextensions (N, Expression (N));
end if;
Analyze_Return_Statement (N);
end Analyze_Simple_Return_Statement;
-------------------------
-- Analyze_Return_Type --
-------------------------
procedure Analyze_Return_Type (N : Node_Id) is
Designator : constant Entity_Id := Defining_Entity (N);
Typ : Entity_Id := Empty;
begin
-- Normal case where result definition does not indicate an error
if Result_Definition (N) /= Error then
if Nkind (Result_Definition (N)) = N_Access_Definition then
-- Ada 2005 (AI-254): Handle anonymous access to subprograms
declare
AD : constant Node_Id :=
Access_To_Subprogram_Definition (Result_Definition (N));
begin
if Present (AD) and then Protected_Present (AD) then
Typ := Replace_Anonymous_Access_To_Protected_Subprogram (N);
else
Typ := Access_Definition (N, Result_Definition (N));
end if;
end;
Set_Parent (Typ, Result_Definition (N));
Set_Is_Local_Anonymous_Access (Typ);
Set_Etype (Designator, Typ);
-- Ada 2005 (AI-231): Ensure proper usage of null exclusion
Null_Exclusion_Static_Checks (N);
-- Subtype_Mark case
else
Find_Type (Result_Definition (N));
Typ := Entity (Result_Definition (N));
Set_Etype (Designator, Typ);
-- Ada 2005 (AI-231): Ensure proper usage of null exclusion
Null_Exclusion_Static_Checks (N);
-- If a null exclusion is imposed on the result type, then create
-- a null-excluding itype (an access subtype) and use it as the
-- function's Etype. Note that the null exclusion checks are done
-- right before this, because they don't get applied to types that
-- do not come from source.
if Is_Access_Type (Typ) and then Null_Exclusion_Present (N) then
Set_Etype (Designator,
Create_Null_Excluding_Itype
(T => Typ,
Related_Nod => N,
Scope_Id => Scope (Current_Scope)));
-- The new subtype must be elaborated before use because
-- it is visible outside of the function. However its base
-- type may not be frozen yet, so the reference that will
-- force elaboration must be attached to the freezing of
-- the base type.
-- If the return specification appears on a proper body,
-- the subtype will have been created already on the spec.
if Is_Frozen (Typ) then
if Nkind (Parent (N)) = N_Subprogram_Body
and then Nkind (Parent (Parent (N))) = N_Subunit
then
null;
else
Build_Itype_Reference (Etype (Designator), Parent (N));
end if;
else
Ensure_Freeze_Node (Typ);
declare
IR : constant Node_Id := Make_Itype_Reference (Sloc (N));
begin
Set_Itype (IR, Etype (Designator));
Append_Freeze_Actions (Typ, New_List (IR));
end;
end if;
else
Set_Etype (Designator, Typ);
end if;
if Ekind (Typ) = E_Incomplete_Type
or else (Is_Class_Wide_Type (Typ)
and then Ekind (Root_Type (Typ)) = E_Incomplete_Type)
then
-- AI05-0151: Tagged incomplete types are allowed in all formal
-- parts. Untagged incomplete types are not allowed in bodies.
-- As a consequence, limited views cannot appear in a basic
-- declaration that is itself within a body, because there is
-- no point at which the non-limited view will become visible.
if Ada_Version >= Ada_2012 then
if From_Limited_With (Typ) and then In_Package_Body then
Error_Msg_NE
("invalid use of incomplete type&",
Result_Definition (N), Typ);
-- The return type of a subprogram body cannot be of a
-- formal incomplete type.
elsif Is_Generic_Type (Typ)
and then Nkind (Parent (N)) = N_Subprogram_Body
then
Error_Msg_N
("return type cannot be a formal incomplete type",
Result_Definition (N));
elsif Is_Class_Wide_Type (Typ)
and then Is_Generic_Type (Root_Type (Typ))
and then Nkind (Parent (N)) = N_Subprogram_Body
then
Error_Msg_N
("return type cannot be a formal incomplete type",
Result_Definition (N));
elsif Is_Tagged_Type (Typ) then
null;
-- Use is legal in a thunk generated for an operation
-- inherited from a progenitor.
elsif Is_Thunk (Designator)
and then Present (Non_Limited_View (Typ))
then
null;
elsif Nkind (Parent (N)) = N_Subprogram_Body
or else Nkind (Parent (Parent (N))) in
N_Accept_Statement | N_Entry_Body
then
Error_Msg_NE
("invalid use of untagged incomplete type&",
Designator, Typ);
end if;
-- The type must be completed in the current package. This
-- is checked at the end of the package declaration when
-- Taft-amendment types are identified. If the return type
-- is class-wide, there is no required check, the type can
-- be a bona fide TAT.
if Ekind (Scope (Current_Scope)) = E_Package
and then In_Private_Part (Scope (Current_Scope))
and then not Is_Class_Wide_Type (Typ)
then
Append_Elmt (Designator, Private_Dependents (Typ));
end if;
else
Error_Msg_NE
("invalid use of incomplete type&", Designator, Typ);
end if;
end if;
end if;
-- Case where result definition does indicate an error
else
Set_Etype (Designator, Any_Type);
end if;
end Analyze_Return_Type;
-----------------------------
-- Analyze_Subprogram_Body --
-----------------------------
procedure Analyze_Subprogram_Body (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Body_Spec : constant Node_Id := Specification (N);
Body_Id : constant Entity_Id := Defining_Entity (Body_Spec);
begin
if Debug_Flag_C then
Write_Str ("==> subprogram body ");
Write_Name (Chars (Body_Id));
Write_Str (" from ");
Write_Location (Loc);
Write_Eol;
Indent;
end if;
Trace_Scope (N, Body_Id, " Analyze subprogram: ");
-- The real work is split out into the helper, so it can do "return;"
-- without skipping the debug output:
Analyze_Subprogram_Body_Helper (N);
if Debug_Flag_C then
Outdent;
Write_Str ("<== subprogram body ");
Write_Name (Chars (Body_Id));
Write_Str (" from ");
Write_Location (Loc);
Write_Eol;
end if;
end Analyze_Subprogram_Body;
------------------------------------
-- Analyze_Subprogram_Body_Helper --
------------------------------------
-- This procedure is called for regular subprogram bodies, generic bodies,
-- and for subprogram stubs of both kinds. In the case of stubs, only the
-- specification matters, and is used to create a proper declaration for
-- the subprogram, or to perform conformance checks.
-- WARNING: This routine manages Ghost regions. Return statements must be
-- replaced by gotos that jump to the end of the routine and restore the
-- Ghost mode.
procedure Analyze_Subprogram_Body_Helper (N : Node_Id) is
Body_Spec : Node_Id := Specification (N);
Body_Id : Entity_Id := Defining_Entity (Body_Spec);
Loc : constant Source_Ptr := Sloc (N);
Prev_Id : constant Entity_Id := Current_Entity_In_Scope (Body_Id);
Conformant : Boolean;
Desig_View : Entity_Id := Empty;
Exch_Views : Elist_Id := No_Elist;
HSS : Node_Id;
Mask_Types : Elist_Id := No_Elist;
Prot_Typ : Entity_Id := Empty;
Spec_Decl : Node_Id := Empty;
Spec_Id : Entity_Id;
Last_Real_Spec_Entity : Entity_Id := Empty;
-- When we analyze a separate spec, the entity chain ends up containing
-- the formals, as well as any itypes generated during analysis of the
-- default expressions for parameters, or the arguments of associated
-- precondition/postcondition pragmas (which are analyzed in the context
-- of the spec since they have visibility on formals).
--
-- These entities belong with the spec and not the body. However we do
-- the analysis of the body in the context of the spec (again to obtain
-- visibility to the formals), and all the entities generated during
-- this analysis end up also chained to the entity chain of the spec.
-- But they really belong to the body, and there is circuitry to move
-- them from the spec to the body.
--
-- However, when we do this move, we don't want to move the real spec
-- entities (first para above) to the body. The Last_Real_Spec_Entity
-- variable points to the last real spec entity, so we only move those
-- chained beyond that point. It is initialized to Empty to deal with
-- the case where there is no separate spec.
function Body_Has_Contract return Boolean;
-- Check whether unanalyzed body has an aspect or pragma that may
-- generate a SPARK contract.
function Body_Has_SPARK_Mode_On return Boolean;
-- Check whether SPARK_Mode On applies to the subprogram body, either
-- because it is specified directly on the body, or because it is
-- inherited from the enclosing subprogram or package.
function Build_Internal_Protected_Declaration
(N : Node_Id) return Entity_Id;
-- A subprogram body without a previous spec that appears in a protected
-- body must be expanded separately to create a subprogram declaration
-- for it, in order to resolve internal calls to it from other protected
-- operations.
--
-- Possibly factor this with Exp_Dist.Copy_Specification ???
procedure Build_Subprogram_Declaration;
-- Create a matching subprogram declaration for subprogram body N
procedure Check_Anonymous_Return;
-- Ada 2005: if a function returns an access type that denotes a task,
-- or a type that contains tasks, we must create a master entity for
-- the anonymous type, which typically will be used in an allocator
-- in the body of the function.
procedure Check_Inline_Pragma (Spec : in out Node_Id);
-- Look ahead to recognize a pragma that may appear after the body.
-- If there is a previous spec, check that it appears in the same
-- declarative part. If the pragma is Inline_Always, perform inlining
-- unconditionally, otherwise only if Front_End_Inlining is requested.
-- If the body acts as a spec, and inlining is required, we create a
-- subprogram declaration for it, in order to attach the body to inline.
-- If pragma does not appear after the body, check whether there is
-- an inline pragma before any local declarations.
procedure Check_Missing_Return;
-- Checks for a function with a no return statements, and also performs
-- the warning checks implemented by Check_Returns. In formal mode, also
-- verify that a function ends with a RETURN and that a procedure does
-- not contain any RETURN.
function Disambiguate_Spec return Entity_Id;
-- When a primitive is declared between the private view and the full
-- view of a concurrent type which implements an interface, a special
-- mechanism is used to find the corresponding spec of the primitive
-- body.
function Exchange_Limited_Views (Subp_Id : Entity_Id) return Elist_Id;
-- Ada 2012 (AI05-0151): Detect whether the profile of Subp_Id contains
-- incomplete types coming from a limited context and replace their
-- limited views with the non-limited ones. Return the list of changes
-- to be used to undo the transformation.
function Is_Private_Concurrent_Primitive
(Subp_Id : Entity_Id) return Boolean;
-- Determine whether subprogram Subp_Id is a primitive of a concurrent
-- type that implements an interface and has a private view.
function Mask_Unfrozen_Types (Spec_Id : Entity_Id) return Elist_Id;
-- N is the body generated for an expression function that is not a
-- completion and Spec_Id the defining entity of its spec. Mark all
-- the not-yet-frozen types referenced by the simple return statement
-- of the function as formally frozen.
procedure Move_Pragmas (From : Node_Id; To : Node_Id);
-- Find all suitable source pragmas at the top of subprogram body
-- From's declarations and move them after arbitrary node To.
-- One exception is pragma SPARK_Mode which is copied rather than moved,
-- as it applies to the body too.
procedure Restore_Limited_Views (Restore_List : Elist_Id);
-- Undo the transformation done by Exchange_Limited_Views.
procedure Set_Trivial_Subprogram (N : Node_Id);
-- Sets the Is_Trivial_Subprogram flag in both spec and body of the
-- subprogram whose body is being analyzed. N is the statement node
-- causing the flag to be set, if the following statement is a return
-- of an entity, we mark the entity as set in source to suppress any
-- warning on the stylized use of function stubs with a dummy return.
procedure Unmask_Unfrozen_Types (Unmask_List : Elist_Id);
-- Undo the transformation done by Mask_Unfrozen_Types
procedure Verify_Overriding_Indicator;
-- If there was a previous spec, the entity has been entered in the
-- current scope previously. If the body itself carries an overriding
-- indicator, check that it is consistent with the known status of the
-- entity.
-----------------------
-- Body_Has_Contract --
-----------------------
function Body_Has_Contract return Boolean is
Decls : constant List_Id := Declarations (N);
Item : Node_Id;
begin
-- Check for aspects that may generate a contract
if Present (Aspect_Specifications (N)) then
Item := First (Aspect_Specifications (N));
while Present (Item) loop
if Is_Subprogram_Contract_Annotation (Item) then
return True;
end if;
Next (Item);
end loop;
end if;
-- Check for pragmas that may generate a contract
if Present (Decls) then
Item := First (Decls);
while Present (Item) loop
if Nkind (Item) = N_Pragma
and then Is_Subprogram_Contract_Annotation (Item)
then
return True;
end if;
Next (Item);
end loop;
end if;
return False;
end Body_Has_Contract;
----------------------------
-- Body_Has_SPARK_Mode_On --
----------------------------
function Body_Has_SPARK_Mode_On return Boolean is
Decls : constant List_Id := Declarations (N);
Item : Node_Id;
begin
-- Check for SPARK_Mode aspect
if Present (Aspect_Specifications (N)) then
Item := First (Aspect_Specifications (N));
while Present (Item) loop
if Get_Aspect_Id (Item) = Aspect_SPARK_Mode then
return Get_SPARK_Mode_From_Annotation (Item) = On;
end if;
Next (Item);
end loop;
end if;
-- Check for SPARK_Mode pragma
if Present (Decls) then
Item := First (Decls);
while Present (Item) loop
-- Pragmas that apply to a subprogram body are usually grouped
-- together. Look for a potential pragma SPARK_Mode among them.
if Nkind (Item) = N_Pragma then
if Get_Pragma_Id (Item) = Pragma_SPARK_Mode then
return Get_SPARK_Mode_From_Annotation (Item) = On;
end if;
-- Otherwise the first non-pragma declarative item terminates
-- the region where pragma SPARK_Mode may appear.
else
exit;
end if;
Next (Item);
end loop;
end if;
-- Otherwise, the applicable SPARK_Mode is inherited from the
-- enclosing subprogram or package.
return SPARK_Mode = On;
end Body_Has_SPARK_Mode_On;
------------------------------------------
-- Build_Internal_Protected_Declaration --
------------------------------------------
function Build_Internal_Protected_Declaration
(N : Node_Id) return Entity_Id
is
procedure Analyze_Pragmas (From : Node_Id);
-- Analyze all pragmas which follow arbitrary node From
---------------------
-- Analyze_Pragmas --
---------------------
procedure Analyze_Pragmas (From : Node_Id) is
Decl : Node_Id;
begin
Decl := Next (From);
while Present (Decl) loop
if Nkind (Decl) = N_Pragma then
Analyze_Pragma (Decl);
-- No candidate pragmas are available for analysis
else
exit;
end if;
Next (Decl);
end loop;
end Analyze_Pragmas;
-- Local variables
Body_Id : constant Entity_Id := Defining_Entity (N);
Loc : constant Source_Ptr := Sloc (N);
Decl : Node_Id;
Formal : Entity_Id;
Formals : List_Id;
Spec : Node_Id;
Spec_Id : Entity_Id;
-- Start of processing for Build_Internal_Protected_Declaration
begin
Formal := First_Formal (Body_Id);
-- The protected operation always has at least one formal, namely the
-- object itself, but it is only placed in the parameter list if
-- expansion is enabled.
if Present (Formal) or else Expander_Active then
Formals := Copy_Parameter_List (Body_Id);
else
Formals := No_List;
end if;
Spec_Id :=
Make_Defining_Identifier (Sloc (Body_Id),
Chars => Chars (Body_Id));
-- Indicate that the entity comes from source, to ensure that cross-
-- reference information is properly generated. The body itself is
-- rewritten during expansion, and the body entity will not appear in
-- calls to the operation.
Set_Comes_From_Source (Spec_Id, True);
if Nkind (Specification (N)) = N_Procedure_Specification then
Spec :=
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Spec_Id,
Parameter_Specifications => Formals);
else
Spec :=
Make_Function_Specification (Loc,
Defining_Unit_Name => Spec_Id,
Parameter_Specifications => Formals,
Result_Definition =>
New_Occurrence_Of (Etype (Body_Id), Loc));
end if;
Decl := Make_Subprogram_Declaration (Loc, Specification => Spec);
Set_Corresponding_Body (Decl, Body_Id);
Set_Corresponding_Spec (N, Spec_Id);
Insert_Before (N, Decl);
-- Associate all aspects and pragmas of the body with the spec. This
-- ensures that these annotations apply to the initial declaration of
-- the subprogram body.
Move_Aspects (From => N, To => Decl);
Move_Pragmas (From => N, To => Decl);
Analyze (Decl);
-- The analysis of the spec may generate pragmas which require manual
-- analysis. Since the generation of the spec and the relocation of
-- the annotations is driven by the expansion of the stand-alone
-- body, the pragmas will not be analyzed in a timely manner. Do this
-- now.
Analyze_Pragmas (Decl);
-- This subprogram has convention Intrinsic as per RM 6.3.1(10/2)
-- ensuring in particular that 'Access is illegal.
Set_Convention (Spec_Id, Convention_Intrinsic);
Set_Has_Completion (Spec_Id);
return Spec_Id;
end Build_Internal_Protected_Declaration;
----------------------------------
-- Build_Subprogram_Declaration --
----------------------------------
procedure Build_Subprogram_Declaration is
Decl : Node_Id;
Subp_Decl : Node_Id;
begin
-- Create a matching subprogram spec using the profile of the body.
-- The structure of the tree is identical, but has new entities for
-- the defining unit name and formal parameters.
Subp_Decl :=
Make_Subprogram_Declaration (Loc,
Specification => Copy_Subprogram_Spec (Body_Spec));
Set_Comes_From_Source (Subp_Decl, True);
-- Also mark parameters as coming from source
if Present (Parameter_Specifications (Specification (Subp_Decl))) then
declare
Form : Entity_Id;
begin
Form :=
First (Parameter_Specifications (Specification (Subp_Decl)));
while Present (Form) loop
Set_Comes_From_Source (Defining_Identifier (Form), True);
Next (Form);
end loop;
end;
end if;
-- Relocate the aspects and relevant pragmas from the subprogram body
-- to the generated spec because it acts as the initial declaration.
Insert_Before (N, Subp_Decl);
Move_Aspects (N, To => Subp_Decl);
Move_Pragmas (N, To => Subp_Decl);
-- Ensure that the generated corresponding spec and original body
-- share the same SPARK_Mode pragma or aspect. As a result, both have
-- the same SPARK_Mode attributes, and the global SPARK_Mode value is
-- correctly set for local subprograms.
Copy_SPARK_Mode_Aspect (Subp_Decl, To => N);
Analyze (Subp_Decl);
-- Propagate the attributes Rewritten_For_C and Corresponding_Proc to
-- the body since the expander may generate calls using that entity.
-- Required to ensure that Expand_Call rewrites calls to this
-- function by calls to the built procedure.
if Modify_Tree_For_C
and then Nkind (Body_Spec) = N_Function_Specification
and then
Rewritten_For_C (Defining_Entity (Specification (Subp_Decl)))
then
Set_Rewritten_For_C (Defining_Entity (Body_Spec));
Set_Corresponding_Procedure (Defining_Entity (Body_Spec),
Corresponding_Procedure
(Defining_Entity (Specification (Subp_Decl))));
end if;
-- Analyze any relocated source pragmas or pragmas created for aspect
-- specifications.
Decl := Next (Subp_Decl);
while Present (Decl) loop
-- Stop the search for pragmas once the body has been reached as
-- this terminates the region where pragmas may appear.
if Decl = N then
exit;
elsif Nkind (Decl) = N_Pragma then
Analyze (Decl);
end if;
Next (Decl);
end loop;
Spec_Id := Defining_Entity (Subp_Decl);
Set_Corresponding_Spec (N, Spec_Id);
-- Mark the generated spec as a source construct to ensure that all
-- calls to it are properly registered in ALI files for GNATprove.
Set_Comes_From_Source (Spec_Id, True);
-- Ensure that the specs of the subprogram declaration and its body
-- are identical, otherwise they will appear non-conformant due to
-- rewritings in the default values of formal parameters.
Body_Spec := Copy_Subprogram_Spec (Body_Spec);
Set_Specification (N, Body_Spec);
Body_Id := Analyze_Subprogram_Specification (Body_Spec);
end Build_Subprogram_Declaration;
----------------------------
-- Check_Anonymous_Return --
----------------------------
procedure Check_Anonymous_Return is
Decl : Node_Id;
Par : Node_Id;
Scop : Entity_Id;
begin
if Present (Spec_Id) then
Scop := Spec_Id;
else
Scop := Body_Id;
end if;
if Ekind (Scop) = E_Function
and then Ekind (Etype (Scop)) = E_Anonymous_Access_Type
and then not Is_Thunk (Scop)
-- Skip internally built functions which handle the case of
-- a null access (see Expand_Interface_Conversion)
and then not (Is_Interface (Designated_Type (Etype (Scop)))
and then not Comes_From_Source (Parent (Scop)))
and then (Has_Task (Designated_Type (Etype (Scop)))
or else
(Is_Class_Wide_Type (Designated_Type (Etype (Scop)))
and then
Is_Limited_Record (Designated_Type (Etype (Scop)))))
and then Expander_Active
then
Decl := Build_Master_Declaration (Loc);
if Present (Declarations (N)) then
Prepend (Decl, Declarations (N));
else
Set_Declarations (N, New_List (Decl));
end if;
Set_Master_Id (Etype (Scop), Defining_Identifier (Decl));
Set_Has_Master_Entity (Scop);
-- Now mark the containing scope as a task master
Par := N;
while Nkind (Par) /= N_Compilation_Unit loop
Par := Parent (Par);
pragma Assert (Present (Par));
-- If we fall off the top, we are at the outer level, and
-- the environment task is our effective master, so nothing
-- to mark.
if Nkind (Par)
in N_Task_Body | N_Block_Statement | N_Subprogram_Body
then
Set_Is_Task_Master (Par, True);
exit;
end if;
end loop;
end if;
end Check_Anonymous_Return;
-------------------------
-- Check_Inline_Pragma --
-------------------------
procedure Check_Inline_Pragma (Spec : in out Node_Id) is
Prag : Node_Id;
Plist : List_Id;
function Is_Inline_Pragma (N : Node_Id) return Boolean;
-- True when N is a pragma Inline or Inline_Always that applies
-- to this subprogram.
-----------------------
-- Is_Inline_Pragma --
-----------------------
function Is_Inline_Pragma (N : Node_Id) return Boolean is
begin
if Nkind (N) = N_Pragma
and then
(Pragma_Name_Unmapped (N) = Name_Inline_Always
or else (Pragma_Name_Unmapped (N) = Name_Inline
and then
(Front_End_Inlining or else Optimization_Level > 0)))
and then Present (Pragma_Argument_Associations (N))
then
declare
Pragma_Arg : Node_Id :=
Expression (First (Pragma_Argument_Associations (N)));
begin
if Nkind (Pragma_Arg) = N_Selected_Component then
Pragma_Arg := Selector_Name (Pragma_Arg);
end if;
return Chars (Pragma_Arg) = Chars (Body_Id);
end;
else
return False;
end if;
end Is_Inline_Pragma;
-- Start of processing for Check_Inline_Pragma
begin
if not Expander_Active then
return;
end if;
if Is_List_Member (N)
and then Present (Next (N))
and then Is_Inline_Pragma (Next (N))
then
Prag := Next (N);
elsif Nkind (N) /= N_Subprogram_Body_Stub
and then Present (Declarations (N))
and then Is_Inline_Pragma (First (Declarations (N)))
then
Prag := First (Declarations (N));
else
Prag := Empty;
end if;
if Present (Prag) then
if Present (Spec_Id) then
if Is_List_Member (N)
and then Is_List_Member (Unit_Declaration_Node (Spec_Id))
and then In_Same_List (N, Unit_Declaration_Node (Spec_Id))
then
Analyze (Prag);
end if;
else
-- Create a subprogram declaration, to make treatment uniform.
-- Make the sloc of the subprogram name that of the entity in
-- the body, so that style checks find identical strings.
declare
Subp : constant Entity_Id :=
Make_Defining_Identifier
(Sloc (Body_Id), Chars (Body_Id));
Decl : constant Node_Id :=
Make_Subprogram_Declaration (Loc,
Specification =>
New_Copy_Tree (Specification (N)));
begin
-- Link the body and the generated spec
Set_Corresponding_Body (Decl, Body_Id);
Set_Corresponding_Spec (N, Subp);
Set_Defining_Unit_Name (Specification (Decl), Subp);
-- To ensure proper coverage when body is inlined, indicate
-- whether the subprogram comes from source.
Preserve_Comes_From_Source (Subp, N);
if Present (First_Formal (Body_Id)) then
Plist := Copy_Parameter_List (Body_Id);
Set_Parameter_Specifications
(Specification (Decl), Plist);
end if;
-- Move aspects to the new spec
if Has_Aspects (N) then
Move_Aspects (N, To => Decl);
end if;
Insert_Before (N, Decl);
Analyze (Decl);
Analyze (Prag);
Set_Has_Pragma_Inline (Subp);
if Pragma_Name (Prag) = Name_Inline_Always then
Set_Is_Inlined (Subp);
Set_Has_Pragma_Inline_Always (Subp);
end if;
-- Prior to copying the subprogram body to create a template
-- for it for subsequent inlining, remove the pragma from
-- the current body so that the copy that will produce the
-- new body will start from a completely unanalyzed tree.
if Nkind (Parent (Prag)) = N_Subprogram_Body then
Rewrite (Prag, Make_Null_Statement (Sloc (Prag)));
end if;
Spec := Subp;
end;
end if;
end if;
end Check_Inline_Pragma;
--------------------------
-- Check_Missing_Return --
--------------------------
procedure Check_Missing_Return is
Id : Entity_Id;
Missing_Ret : Boolean;
begin
if Nkind (Body_Spec) = N_Function_Specification then
if Present (Spec_Id) then
Id := Spec_Id;
else
Id := Body_Id;
end if;
if Return_Present (Id) then
Check_Returns (HSS, 'F', Missing_Ret);
if Missing_Ret then
Set_Has_Missing_Return (Id);
end if;
-- Within a premature instantiation of a package with no body, we
-- build completions of the functions therein, with a Raise
-- statement. No point in complaining about a missing return in
-- this case.
elsif Ekind (Id) = E_Function
and then In_Instance
and then Present (Statements (HSS))
and then Nkind (First (Statements (HSS))) = N_Raise_Program_Error
then
null;
elsif Is_Generic_Subprogram (Id)
or else not Is_Machine_Code_Subprogram (Id)
then
Error_Msg_N ("missing RETURN statement in function body", N);
end if;
-- If procedure with No_Return, check returns
elsif Nkind (Body_Spec) = N_Procedure_Specification then
if Present (Spec_Id) then
Id := Spec_Id;
else
Id := Body_Id;
end if;
if No_Return (Id) then
Check_Returns (HSS, 'P', Missing_Ret, Id);
end if;
end if;
end Check_Missing_Return;
-----------------------
-- Disambiguate_Spec --
-----------------------
function Disambiguate_Spec return Entity_Id is
Priv_Spec : Entity_Id;
Spec_N : Entity_Id;
procedure Replace_Types (To_Corresponding : Boolean);
-- Depending on the flag, replace the type of formal parameters of
-- Body_Id if it is a concurrent type implementing interfaces with
-- the corresponding record type or the other way around.
procedure Replace_Types (To_Corresponding : Boolean) is
Formal : Entity_Id;
Formal_Typ : Entity_Id;
begin
Formal := First_Formal (Body_Id);
while Present (Formal) loop
Formal_Typ := Etype (Formal);
if Is_Class_Wide_Type (Formal_Typ) then
Formal_Typ := Root_Type (Formal_Typ);
end if;
-- From concurrent type to corresponding record
if To_Corresponding then
if Is_Concurrent_Type (Formal_Typ)
and then Present (Corresponding_Record_Type (Formal_Typ))
and then
Present (Interfaces
(Corresponding_Record_Type (Formal_Typ)))
then
Set_Etype (Formal,
Corresponding_Record_Type (Formal_Typ));
end if;
-- From corresponding record to concurrent type
else
if Is_Concurrent_Record_Type (Formal_Typ)
and then Present (Interfaces (Formal_Typ))
then
Set_Etype (Formal,
Corresponding_Concurrent_Type (Formal_Typ));
end if;
end if;
Next_Formal (Formal);
end loop;
end Replace_Types;
-- Start of processing for Disambiguate_Spec
begin
-- Try to retrieve the specification of the body as is. All error
-- messages are suppressed because the body may not have a spec in
-- its current state.
Spec_N := Find_Corresponding_Spec (N, False);
-- It is possible that this is the body of a primitive declared
-- between a private and a full view of a concurrent type. The
-- controlling parameter of the spec carries the concurrent type,
-- not the corresponding record type as transformed by Analyze_
-- Subprogram_Specification. In such cases, we undo the change
-- made by the analysis of the specification and try to find the
-- spec again.
-- Note that wrappers already have their corresponding specs and
-- bodies set during their creation, so if the candidate spec is
-- a wrapper, then we definitely need to swap all types to their
-- original concurrent status.
if No (Spec_N)
or else Is_Primitive_Wrapper (Spec_N)
then
-- Restore all references of corresponding record types to the
-- original concurrent types.
Replace_Types (To_Corresponding => False);
Priv_Spec := Find_Corresponding_Spec (N, False);
-- The current body truly belongs to a primitive declared between
-- a private and a full view. We leave the modified body as is,
-- and return the true spec.
if Present (Priv_Spec)
and then Is_Private_Primitive (Priv_Spec)
then
return Priv_Spec;
end if;
-- In case that this is some sort of error, restore the original
-- state of the body.
Replace_Types (To_Corresponding => True);
end if;
return Spec_N;
end Disambiguate_Spec;
----------------------------
-- Exchange_Limited_Views --
----------------------------
function Exchange_Limited_Views (Subp_Id : Entity_Id) return Elist_Id is
Result : Elist_Id := No_Elist;
procedure Detect_And_Exchange (Id : Entity_Id);
-- Determine whether Id's type denotes an incomplete type associated
-- with a limited with clause and exchange the limited view with the
-- non-limited one when available. Note that the non-limited view
-- may exist because of a with_clause in another unit in the context,
-- but cannot be used because the current view of the enclosing unit
-- is still a limited view.
-------------------------
-- Detect_And_Exchange --
-------------------------
procedure Detect_And_Exchange (Id : Entity_Id) is
Typ : constant Entity_Id := Etype (Id);
begin
if From_Limited_With (Typ)
and then Has_Non_Limited_View (Typ)
and then not From_Limited_With (Scope (Typ))
then
if No (Result) then
Result := New_Elmt_List;
end if;
Prepend_Elmt (Typ, Result);
Prepend_Elmt (Id, Result);
Set_Etype (Id, Non_Limited_View (Typ));
end if;
end Detect_And_Exchange;
-- Local variables
Formal : Entity_Id;
-- Start of processing for Exchange_Limited_Views
begin
-- Do not process subprogram bodies as they already use the non-
-- limited view of types.
if Ekind (Subp_Id) not in E_Function | E_Procedure then
return No_Elist;
end if;
-- Examine all formals and swap views when applicable
Formal := First_Formal (Subp_Id);
while Present (Formal) loop
Detect_And_Exchange (Formal);
Next_Formal (Formal);
end loop;
-- Process the return type of a function
if Ekind (Subp_Id) = E_Function then
Detect_And_Exchange (Subp_Id);
end if;
return Result;
end Exchange_Limited_Views;
-------------------------------------
-- Is_Private_Concurrent_Primitive --
-------------------------------------
function Is_Private_Concurrent_Primitive
(Subp_Id : Entity_Id) return Boolean
is
Formal_Typ : Entity_Id;
begin
if Present (First_Formal (Subp_Id)) then
Formal_Typ := Etype (First_Formal (Subp_Id));
if Is_Concurrent_Record_Type (Formal_Typ) then
if Is_Class_Wide_Type (Formal_Typ) then
Formal_Typ := Root_Type (Formal_Typ);
end if;
Formal_Typ := Corresponding_Concurrent_Type (Formal_Typ);
end if;
-- The type of the first formal is a concurrent tagged type with
-- a private view.
return
Is_Concurrent_Type (Formal_Typ)
and then Is_Tagged_Type (Formal_Typ)
and then Has_Private_Declaration (Formal_Typ);
end if;
return False;
end Is_Private_Concurrent_Primitive;
-------------------------
-- Mask_Unfrozen_Types --
-------------------------
function Mask_Unfrozen_Types (Spec_Id : Entity_Id) return Elist_Id is
Result : Elist_Id := No_Elist;
function Mask_Type_Refs (Node : Node_Id) return Traverse_Result;
-- Mask all types referenced in the subtree rooted at Node
--------------------
-- Mask_Type_Refs --
--------------------
function Mask_Type_Refs (Node : Node_Id) return Traverse_Result is
procedure Mask_Type (Typ : Entity_Id);
-- ??? what does this do?
---------------
-- Mask_Type --
---------------
procedure Mask_Type (Typ : Entity_Id) is
begin
-- Skip Itypes created by the preanalysis
if Is_Itype (Typ)
and then Scope_Within_Or_Same (Scope (Typ), Spec_Id)
then
return;
end if;
if not Is_Frozen (Typ) then
if Scope (Typ) /= Current_Scope then
Set_Is_Frozen (Typ);
Append_New_Elmt (Typ, Result);
else
Freeze_Before (N, Typ);
end if;
end if;
end Mask_Type;
-- Start of processing for Mask_Type_Refs
begin
if Is_Entity_Name (Node) and then Present (Entity (Node)) then
Mask_Type (Etype (Entity (Node)));
if Ekind (Entity (Node)) in E_Component | E_Discriminant then
Mask_Type (Scope (Entity (Node)));
end if;
elsif Nkind (Node) in N_Aggregate | N_Null | N_Type_Conversion
and then Present (Etype (Node))
then
Mask_Type (Etype (Node));
end if;
return OK;
end Mask_Type_Refs;
procedure Mask_References is new Traverse_Proc (Mask_Type_Refs);
-- Local variables
Return_Stmt : constant Node_Id :=
First (Statements (Handled_Statement_Sequence (N)));
-- Start of processing for Mask_Unfrozen_Types
begin
pragma Assert (Nkind (Return_Stmt) = N_Simple_Return_Statement);
Mask_References (Expression (Return_Stmt));
return Result;
end Mask_Unfrozen_Types;
------------------
-- Move_Pragmas --
------------------
procedure Move_Pragmas (From : Node_Id; To : Node_Id) is
Decl : Node_Id;
Insert_Nod : Node_Id;
Next_Decl : Node_Id;
begin
pragma Assert (Nkind (From) = N_Subprogram_Body);
-- The pragmas are moved in an order-preserving fashion
Insert_Nod := To;
-- Inspect the declarations of the subprogram body and relocate all
-- candidate pragmas.
Decl := First (Declarations (From));
while Present (Decl) loop
-- Preserve the following declaration for iteration purposes, due
-- to possible relocation of a pragma.
Next_Decl := Next (Decl);
if Nkind (Decl) = N_Pragma then
-- Copy pragma SPARK_Mode if present in the declarative list
-- of subprogram body From and insert it after node To. This
-- pragma should not be moved, as it applies to the body too.
if Pragma_Name_Unmapped (Decl) = Name_SPARK_Mode then
Insert_After (Insert_Nod, New_Copy_Tree (Decl));
-- Move relevant pragmas to the spec
elsif Pragma_Name_Unmapped (Decl) in Name_Depends
| Name_Ghost
| Name_Global
| Name_Pre
| Name_Precondition
| Name_Post
| Name_Refined_Depends
| Name_Refined_Global
| Name_Refined_Post
| Name_Inline
| Name_Pure_Function
| Name_Volatile_Function
then
Remove (Decl);
Insert_After (Insert_Nod, Decl);
Insert_Nod := Decl;
end if;
-- Skip internally generated code
elsif not Comes_From_Source (Decl) then
null;
-- No candidate pragmas are available for relocation
else
exit;
end if;
Decl := Next_Decl;
end loop;
end Move_Pragmas;
---------------------------
-- Restore_Limited_Views --
---------------------------
procedure Restore_Limited_Views (Restore_List : Elist_Id) is
Elmt : Elmt_Id := First_Elmt (Restore_List);
Id : Entity_Id;
begin
while Present (Elmt) loop
Id := Node (Elmt);
Next_Elmt (Elmt);
Set_Etype (Id, Node (Elmt));
Next_Elmt (Elmt);
end loop;
end Restore_Limited_Views;
----------------------------
-- Set_Trivial_Subprogram --
----------------------------
procedure Set_Trivial_Subprogram (N : Node_Id) is
Nxt : constant Node_Id := Next (N);
begin
Set_Is_Trivial_Subprogram (Body_Id);
if Present (Spec_Id) then
Set_Is_Trivial_Subprogram (Spec_Id);
end if;
if Present (Nxt)
and then Nkind (Nxt) = N_Simple_Return_Statement
and then No (Next (Nxt))
and then Present (Expression (Nxt))
and then Is_Entity_Name (Expression (Nxt))
then
Set_Never_Set_In_Source (Entity (Expression (Nxt)), False);
end if;
end Set_Trivial_Subprogram;
---------------------------
-- Unmask_Unfrozen_Types --
---------------------------
procedure Unmask_Unfrozen_Types (Unmask_List : Elist_Id) is
Elmt : Elmt_Id := First_Elmt (Unmask_List);
begin
while Present (Elmt) loop
Set_Is_Frozen (Node (Elmt), False);
Next_Elmt (Elmt);
end loop;
end Unmask_Unfrozen_Types;
---------------------------------
-- Verify_Overriding_Indicator --
---------------------------------
procedure Verify_Overriding_Indicator is
begin
if Must_Override (Body_Spec) then
if Nkind (Spec_Id) = N_Defining_Operator_Symbol
and then Operator_Matches_Spec (Spec_Id, Spec_Id)
then
null;
-- Overridden controlled primitives may have had their
-- Overridden_Operation field cleared according to the setting of
-- the Is_Hidden flag. An issue arises, however, when analyzing
-- an instance that may have manipulated the flag during
-- expansion. As a result, we add an exception for this case.
elsif not Present (Overridden_Operation (Spec_Id))
and then not (Chars (Spec_Id) in Name_Adjust
| Name_Finalize
| Name_Initialize
and then In_Instance)
then
Error_Msg_NE
("subprogram& is not overriding", Body_Spec, Spec_Id);
-- Overriding indicators aren't allowed for protected subprogram
-- bodies (see the Confirmation in Ada Comment AC95-00213). Change
-- this to a warning if -gnatd.E is enabled.
elsif Ekind (Scope (Spec_Id)) = E_Protected_Type then
Error_Msg_Warn := Error_To_Warning;
Error_Msg_N
("<<overriding indicator not allowed for protected "
& "subprogram body", Body_Spec);
end if;
elsif Must_Not_Override (Body_Spec) then
if Present (Overridden_Operation (Spec_Id)) then
Error_Msg_NE
("subprogram& overrides inherited operation",
Body_Spec, Spec_Id);
elsif Nkind (Spec_Id) = N_Defining_Operator_Symbol
and then Operator_Matches_Spec (Spec_Id, Spec_Id)
then
Error_Msg_NE
("subprogram& overrides predefined operator ",
Body_Spec, Spec_Id);
-- Overriding indicators aren't allowed for protected subprogram
-- bodies (see the Confirmation in Ada Comment AC95-00213). Change
-- this to a warning if -gnatd.E is enabled.
elsif Ekind (Scope (Spec_Id)) = E_Protected_Type then
Error_Msg_Warn := Error_To_Warning;
Error_Msg_N
("<<overriding indicator not allowed "
& "for protected subprogram body", Body_Spec);
-- If this is not a primitive operation, then the overriding
-- indicator is altogether illegal.
elsif not Is_Primitive (Spec_Id) then
Error_Msg_N
("overriding indicator only allowed "
& "if subprogram is primitive", Body_Spec);
end if;
-- If checking the style rule and the operation overrides, then
-- issue a warning about a missing overriding_indicator. Protected
-- subprogram bodies are excluded from this style checking, since
-- they aren't primitives (even though their declarations can
-- override) and aren't allowed to have an overriding_indicator.
elsif Style_Check
and then Present (Overridden_Operation (Spec_Id))
and then Ekind (Scope (Spec_Id)) /= E_Protected_Type
then
pragma Assert (Unit_Declaration_Node (Body_Id) = N);
Style.Missing_Overriding (N, Body_Id);
elsif Style_Check
and then Can_Override_Operator (Spec_Id)
and then not In_Predefined_Unit (Spec_Id)
then
pragma Assert (Unit_Declaration_Node (Body_Id) = N);
Style.Missing_Overriding (N, Body_Id);
end if;
end Verify_Overriding_Indicator;
-- Local variables
Body_Nod : Node_Id := Empty;
Minimum_Acc_Objs : List_Id := No_List;
Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
Saved_EA : constant Boolean := Expander_Active;
Saved_ISMP : constant Boolean :=
Ignore_SPARK_Mode_Pragmas_In_Instance;
-- Save the Ghost and SPARK mode-related data to restore on exit
-- Start of processing for Analyze_Subprogram_Body_Helper
begin
-- A [generic] subprogram body freezes the contract of the nearest
-- enclosing package body and all other contracts encountered in the
-- same declarative part up to and excluding the subprogram body:
-- package body Nearest_Enclosing_Package
-- with Refined_State => (State => Constit)
-- is
-- Constit : ...;
-- procedure Freezes_Enclosing_Package_Body
-- with Refined_Depends => (Input => Constit) ...
-- This ensures that any annotations referenced by the contract of the
-- [generic] subprogram body are available. This form of freezing is
-- decoupled from the usual Freeze_xxx mechanism because it must also
-- work in the context of generics where normal freezing is disabled.
-- Only bodies coming from source should cause this type of freezing.
-- Expression functions that act as bodies and complete an initial
-- declaration must be included in this category, hence the use of
-- Original_Node.
if Comes_From_Source (Original_Node (N)) then
Freeze_Previous_Contracts (N);
end if;
-- Generic subprograms are handled separately. They always have a
-- generic specification. Determine whether current scope has a
-- previous declaration.
-- If the subprogram body is defined within an instance of the same
-- name, the instance appears as a package renaming, and will be hidden
-- within the subprogram.
if Present (Prev_Id)
and then not Is_Overloadable (Prev_Id)
and then (Nkind (Parent (Prev_Id)) /= N_Package_Renaming_Declaration
or else Comes_From_Source (Prev_Id))
then
if Is_Generic_Subprogram (Prev_Id) then
Spec_Id := Prev_Id;
-- A subprogram body is Ghost when it is stand-alone and subject
-- to pragma Ghost or when the corresponding spec is Ghost. Set
-- the mode now to ensure that any nodes generated during analysis
-- and expansion are properly marked as Ghost.
Mark_And_Set_Ghost_Body (N, Spec_Id);
-- If the body completes the initial declaration of a compilation
-- unit which is subject to pragma Elaboration_Checks, set the
-- model specified by the pragma because it applies to all parts
-- of the unit.
Install_Elaboration_Model (Spec_Id);
Set_Is_Compilation_Unit (Body_Id, Is_Compilation_Unit (Spec_Id));
Set_Is_Child_Unit (Body_Id, Is_Child_Unit (Spec_Id));
Analyze_Generic_Subprogram_Body (N, Spec_Id);
if Nkind (N) = N_Subprogram_Body then
HSS := Handled_Statement_Sequence (N);
Check_Missing_Return;
end if;
goto Leave;
-- Otherwise a previous entity conflicts with the subprogram name.
-- Attempting to enter name will post error.
else
Enter_Name (Body_Id);
goto Leave;
end if;
-- Non-generic case, find the subprogram declaration, if one was seen,
-- or enter new overloaded entity in the current scope. If the
-- Current_Entity is the Body_Id itself, the unit is being analyzed as
-- part of the context of one of its subunits. No need to redo the
-- analysis.
elsif Prev_Id = Body_Id and then Has_Completion (Body_Id) then
goto Leave;
else
Body_Id := Analyze_Subprogram_Specification (Body_Spec);
if Nkind (N) = N_Subprogram_Body_Stub
or else No (Corresponding_Spec (N))
then
if Is_Private_Concurrent_Primitive (Body_Id) then
Spec_Id := Disambiguate_Spec;
-- A subprogram body is Ghost when it is stand-alone and
-- subject to pragma Ghost or when the corresponding spec is
-- Ghost. Set the mode now to ensure that any nodes generated
-- during analysis and expansion are properly marked as Ghost.
Mark_And_Set_Ghost_Body (N, Spec_Id);
-- If the body completes a compilation unit which is subject
-- to pragma Elaboration_Checks, set the model specified by
-- the pragma because it applies to all parts of the unit.
Install_Elaboration_Model (Spec_Id);
else
Spec_Id := Find_Corresponding_Spec (N);
-- A subprogram body is Ghost when it is stand-alone and
-- subject to pragma Ghost or when the corresponding spec is
-- Ghost. Set the mode now to ensure that any nodes generated
-- during analysis and expansion are properly marked as Ghost.
Mark_And_Set_Ghost_Body (N, Spec_Id);
-- If the body completes a compilation unit which is subject
-- to pragma Elaboration_Checks, set the model specified by
-- the pragma because it applies to all parts of the unit.
Install_Elaboration_Model (Spec_Id);
-- In GNATprove mode, if the body has no previous spec, create
-- one so that the inlining machinery can operate properly.
-- Transfer aspects, if any, to the new spec, so that they
-- are legal and can be processed ahead of the body.
-- We make two copies of the given spec, one for the new
-- declaration, and one for the body.
-- ??? This should be conditioned on front-end inlining rather
-- than GNATprove_Mode.
if No (Spec_Id) and then GNATprove_Mode
-- Inlining does not apply during preanalysis of code
and then Full_Analysis
-- Inlining only applies to full bodies, not stubs
and then Nkind (N) /= N_Subprogram_Body_Stub
-- Inlining only applies to bodies in the source code, not to
-- those generated by the compiler. In particular, expression
-- functions, whose body is generated by the compiler, are
-- treated specially by GNATprove.
and then Comes_From_Source (Body_Id)
-- This cannot be done for a compilation unit, which is not
-- in a context where we can insert a new spec.
and then Is_List_Member (N)
-- Inlining only applies to subprograms without contracts,
-- as a contract is a sign that GNATprove should perform a
-- modular analysis of the subprogram instead of a contextual
-- analysis at each call site. The same test is performed in
-- Inline.Can_Be_Inlined_In_GNATprove_Mode. It is repeated
-- here in another form (because the contract has not been
-- attached to the body) to avoid front-end errors in case
-- pragmas are used instead of aspects, because the
-- corresponding pragmas in the body would not be transferred
-- to the spec, leading to legality errors.
and then not Body_Has_Contract
and then not Inside_A_Generic
then
Build_Subprogram_Declaration;
-- If this is a function that returns a constrained array, and
-- we are generating C code, create subprogram declaration
-- to simplify subsequent C generation.
elsif No (Spec_Id)
and then Modify_Tree_For_C
and then Nkind (Body_Spec) = N_Function_Specification
and then Is_Array_Type (Etype (Body_Id))
and then Is_Constrained (Etype (Body_Id))
then
Build_Subprogram_Declaration;
end if;
end if;
-- If this is a duplicate body, no point in analyzing it
if Error_Posted (N) then
goto Leave;
end if;
-- A subprogram body should cause freezing of its own declaration,
-- but if there was no previous explicit declaration, then the
-- subprogram will get frozen too late (there may be code within
-- the body that depends on the subprogram having been frozen,
-- such as uses of extra formals), so we force it to be frozen
-- here. Same holds if the body and spec are compilation units.
-- Finally, if the return type is an anonymous access to protected
-- subprogram, it must be frozen before the body because its
-- expansion has generated an equivalent type that is used when
-- elaborating the body.
-- An exception in the case of Ada 2012, AI05-177: The bodies
-- created for expression functions do not freeze.
if No (Spec_Id)
and then Nkind (Original_Node (N)) /= N_Expression_Function
then
Freeze_Before (N, Body_Id);
elsif Nkind (Parent (N)) = N_Compilation_Unit then
Freeze_Before (N, Spec_Id);
elsif Is_Access_Subprogram_Type (Etype (Body_Id)) then
Freeze_Before (N, Etype (Body_Id));
end if;
else
Spec_Id := Corresponding_Spec (N);
-- A subprogram body is Ghost when it is stand-alone and subject
-- to pragma Ghost or when the corresponding spec is Ghost. Set
-- the mode now to ensure that any nodes generated during analysis
-- and expansion are properly marked as Ghost.
Mark_And_Set_Ghost_Body (N, Spec_Id);
-- If the body completes the initial declaration of a compilation
-- unit which is subject to pragma Elaboration_Checks, set the
-- model specified by the pragma because it applies to all parts
-- of the unit.
Install_Elaboration_Model (Spec_Id);
end if;
end if;
-- Deactivate expansion inside the body of ignored Ghost entities,
-- as this code will ultimately be ignored. This avoids requiring the
-- presence of run-time units which are not needed. Only do this for
-- user entities, as internally generated entitities might still need
-- to be expanded (e.g. those generated for types).
if Present (Ignored_Ghost_Region)
and then Comes_From_Source (Body_Id)
then
Expander_Active := False;
end if;
-- Previously we scanned the body to look for nested subprograms, and
-- rejected an inline directive if nested subprograms were present,
-- because the back-end would generate conflicting symbols for the
-- nested bodies. This is now unnecessary.
-- Look ahead to recognize a pragma Inline that appears after the body
Check_Inline_Pragma (Spec_Id);
-- Deal with special case of a fully private operation in the body of
-- the protected type. We must create a declaration for the subprogram,
-- in order to attach the subprogram that will be used in internal
-- calls. We exclude compiler generated bodies from the expander since
-- the issue does not arise for those cases.
if No (Spec_Id)
and then Comes_From_Source (N)
and then Is_Protected_Type (Current_Scope)
then
Spec_Id := Build_Internal_Protected_Declaration (N);
end if;
-- If we are generating C and this is a function returning a constrained
-- array type for which we must create a procedure with an extra out
-- parameter, build and analyze the body now. The procedure declaration
-- has already been created. We reuse the source body of the function,
-- because in an instance it may contain global references that cannot
-- be reanalyzed. The source function itself is not used any further,
-- so we mark it as having a completion. If the subprogram is a stub the
-- transformation is done later, when the proper body is analyzed.
if Expander_Active
and then Modify_Tree_For_C
and then Present (Spec_Id)
and then Ekind (Spec_Id) = E_Function
and then Nkind (N) /= N_Subprogram_Body_Stub
and then Rewritten_For_C (Spec_Id)
then
Set_Has_Completion (Spec_Id);
Rewrite (N, Build_Procedure_Body_Form (Spec_Id, N));
Analyze (N);
-- The entity for the created procedure must remain invisible, so it
-- does not participate in resolution of subsequent references to the
-- function.
Set_Is_Immediately_Visible (Corresponding_Spec (N), False);
goto Leave;
end if;
-- If a separate spec is present, then deal with freezing issues
if Present (Spec_Id) then
Spec_Decl := Unit_Declaration_Node (Spec_Id);
Verify_Overriding_Indicator;
-- In general, the spec will be frozen when we start analyzing the
-- body. However, for internally generated operations, such as
-- wrapper functions for inherited operations with controlling
-- results, the spec may not have been frozen by the time we expand
-- the freeze actions that include the bodies. In particular, extra
-- formals for accessibility or for return-in-place may need to be
-- generated. Freeze nodes, if any, are inserted before the current
-- body. These freeze actions are also needed in Compile_Only mode to
-- enable the proper back-end type annotations.
-- They are necessary in any case to ensure proper elaboration order
-- in gigi.
if Nkind (N) = N_Subprogram_Body
and then Was_Expression_Function (N)
and then not Has_Completion (Spec_Id)
and then Serious_Errors_Detected = 0
and then (Expander_Active
or else Operating_Mode = Check_Semantics
or else Is_Ignored_Ghost_Entity (Spec_Id))
then
-- The body generated for an expression function that is not a
-- completion is a freeze point neither for the profile nor for
-- anything else. That's why, in order to prevent any freezing
-- during analysis, we need to mask types declared outside the
-- expression (and in an outer scope) that are not yet frozen.
-- This also needs to be done in the case of an ignored Ghost
-- expression function, where the expander isn't active.
Set_Is_Frozen (Spec_Id);
Mask_Types := Mask_Unfrozen_Types (Spec_Id);
elsif not Is_Frozen (Spec_Id)
and then Serious_Errors_Detected = 0
then
Set_Has_Delayed_Freeze (Spec_Id);
Freeze_Before (N, Spec_Id);
end if;
end if;
-- If the subprogram has a class-wide clone, build its body as a copy
-- of the original body, and rewrite body of original subprogram as a
-- wrapper that calls the clone. If N is a stub, this construction will
-- take place when the proper body is analyzed. No action needed if this
-- subprogram has been eliminated.
if Present (Spec_Id)
and then Present (Class_Wide_Clone (Spec_Id))
and then (Comes_From_Source (N) or else Was_Expression_Function (N))
and then Nkind (N) /= N_Subprogram_Body_Stub
and then not (Expander_Active and then Is_Eliminated (Spec_Id))
then
Build_Class_Wide_Clone_Body (Spec_Id, N);
-- This is the new body for the existing primitive operation
Rewrite (N, Build_Class_Wide_Clone_Call
(Sloc (N), New_List, Spec_Id, Parent (Spec_Id)));
Set_Has_Completion (Spec_Id, False);
Analyze (N);
return;
end if;
-- Place subprogram on scope stack, and make formals visible. If there
-- is a spec, the visible entity remains that of the spec.
if Present (Spec_Id) then
Generate_Reference (Spec_Id, Body_Id, 'b', Set_Ref => False);
if Is_Child_Unit (Spec_Id) then
Generate_Reference (Spec_Id, Scope (Spec_Id), 'k', False);
end if;
if Style_Check then
Style.Check_Identifier (Body_Id, Spec_Id);
end if;
Set_Is_Compilation_Unit (Body_Id, Is_Compilation_Unit (Spec_Id));
Set_Is_Child_Unit (Body_Id, Is_Child_Unit (Spec_Id));
if Is_Abstract_Subprogram (Spec_Id) then
Error_Msg_N ("an abstract subprogram cannot have a body", N);
goto Leave;
else
Set_Convention (Body_Id, Convention (Spec_Id));
Set_Has_Completion (Spec_Id);
if Is_Protected_Type (Scope (Spec_Id)) then
Prot_Typ := Scope (Spec_Id);
end if;
-- If this is a body generated for a renaming, do not check for
-- full conformance. The check is redundant, because the spec of
-- the body is a copy of the spec in the renaming declaration,
-- and the test can lead to spurious errors on nested defaults.
if Present (Spec_Decl)
and then not Comes_From_Source (N)
and then
(Nkind (Original_Node (Spec_Decl)) =
N_Subprogram_Renaming_Declaration
or else (Present (Corresponding_Body (Spec_Decl))
and then
Nkind (Unit_Declaration_Node
(Corresponding_Body (Spec_Decl))) =
N_Subprogram_Renaming_Declaration))
then
Conformant := True;
-- Conversely, the spec may have been generated for specless body
-- with an inline pragma. The entity comes from source, which is
-- both semantically correct and necessary for proper inlining.
-- The subprogram declaration itself is not in the source.
elsif Comes_From_Source (N)
and then Present (Spec_Decl)
and then not Comes_From_Source (Spec_Decl)
and then Has_Pragma_Inline (Spec_Id)
then
Conformant := True;
else
Check_Conformance
(Body_Id, Spec_Id,
Fully_Conformant, True, Conformant, Body_Id);
end if;
-- If the body is not fully conformant, we have to decide if we
-- should analyze it or not. If it has a really messed up profile
-- then we probably should not analyze it, since we will get too
-- many bogus messages.
-- Our decision is to go ahead in the non-fully conformant case
-- only if it is at least mode conformant with the spec. Note
-- that the call to Check_Fully_Conformant has issued the proper
-- error messages to complain about the lack of conformance.
if not Conformant
and then not Mode_Conformant (Body_Id, Spec_Id)
then
goto Leave;
end if;
end if;
-- In the case we are dealing with an expression function we check
-- the formals attached to the spec instead of the body - so we don't
-- reference body formals.
if Spec_Id /= Body_Id
and then not Is_Expression_Function (Spec_Id)
then
Reference_Body_Formals (Spec_Id, Body_Id);
end if;
Set_Ekind (Body_Id, E_Subprogram_Body);
if Nkind (N) = N_Subprogram_Body_Stub then
Set_Corresponding_Spec_Of_Stub (N, Spec_Id);
-- Regular body
else
Set_Corresponding_Spec (N, Spec_Id);
-- Ada 2005 (AI-345): If the operation is a primitive operation
-- of a concurrent type, the type of the first parameter has been
-- replaced with the corresponding record, which is the proper
-- run-time structure to use. However, within the body there may
-- be uses of the formals that depend on primitive operations
-- of the type (in particular calls in prefixed form) for which
-- we need the original concurrent type. The operation may have
-- several controlling formals, so the replacement must be done
-- for all of them.
if Comes_From_Source (Spec_Id)
and then Present (First_Entity (Spec_Id))
and then Ekind (Etype (First_Entity (Spec_Id))) = E_Record_Type
and then Is_Tagged_Type (Etype (First_Entity (Spec_Id)))
and then Present (Interfaces (Etype (First_Entity (Spec_Id))))
and then Present (Corresponding_Concurrent_Type
(Etype (First_Entity (Spec_Id))))
then
declare
Typ : constant Entity_Id := Etype (First_Entity (Spec_Id));
Form : Entity_Id;
begin
Form := First_Formal (Spec_Id);
while Present (Form) loop
if Etype (Form) = Typ then
Set_Etype (Form, Corresponding_Concurrent_Type (Typ));
end if;
Next_Formal (Form);
end loop;
end;
end if;
-- Make the formals visible, and place subprogram on scope stack.
-- This is also the point at which we set Last_Real_Spec_Entity
-- to mark the entities which will not be moved to the body.
Install_Formals (Spec_Id);
Last_Real_Spec_Entity := Last_Entity (Spec_Id);
-- Within an instance, add local renaming declarations so that
-- gdb can retrieve the values of actuals more easily. This is
-- only relevant if generating code.
if Is_Generic_Instance (Spec_Id)
and then Is_Wrapper_Package (Current_Scope)
and then Expander_Active
then
Build_Subprogram_Instance_Renamings (N, Current_Scope);
end if;
Push_Scope (Spec_Id);
-- Make sure that the subprogram is immediately visible. For
-- child units that have no separate spec this is indispensable.
-- Otherwise it is safe albeit redundant.
Set_Is_Immediately_Visible (Spec_Id);
end if;
Set_Corresponding_Body (Unit_Declaration_Node (Spec_Id), Body_Id);
Set_Is_Obsolescent (Body_Id, Is_Obsolescent (Spec_Id));
Set_Scope (Body_Id, Scope (Spec_Id));
-- Case of subprogram body with no previous spec
else
-- Check for style warning required
if Style_Check
-- Only apply check for source level subprograms for which checks
-- have not been suppressed.
and then Comes_From_Source (Body_Id)
and then not Suppress_Style_Checks (Body_Id)
-- No warnings within an instance
and then not In_Instance
-- No warnings for expression functions
and then Nkind (Original_Node (N)) /= N_Expression_Function
then
Style.Body_With_No_Spec (N);
end if;
New_Overloaded_Entity (Body_Id);
if Nkind (N) /= N_Subprogram_Body_Stub then
Set_Acts_As_Spec (N);
Generate_Definition (Body_Id);
Generate_Reference
(Body_Id, Body_Id, 'b', Set_Ref => False, Force => True);
-- If the body is an entry wrapper created for an entry with
-- preconditions, it must be compiled in the context of the
-- enclosing synchronized object, because it may mention other
-- operations of the type.
if Is_Entry_Wrapper (Body_Id) then
declare
Prot : constant Entity_Id := Etype (First_Entity (Body_Id));
begin
Push_Scope (Prot);
Install_Declarations (Prot);
end;
end if;
Install_Formals (Body_Id);
Push_Scope (Body_Id);
end if;
-- For stubs and bodies with no previous spec, generate references to
-- formals.
Generate_Reference_To_Formals (Body_Id);
end if;
-- Entry barrier functions are generated outside the protected type and
-- should not carry the SPARK_Mode of the enclosing context.
if Nkind (N) = N_Subprogram_Body
and then Is_Entry_Barrier_Function (N)
then
null;
-- The body is generated as part of expression function expansion. When
-- the expression function appears in the visible declarations of a
-- package, the body is added to the private declarations. Since both
-- declarative lists may be subject to a different SPARK_Mode, inherit
-- the mode of the spec.
-- package P with SPARK_Mode is
-- function Expr_Func ... is (...); -- original
-- [function Expr_Func ...;] -- generated spec
-- -- mode is ON
-- private
-- pragma SPARK_Mode (Off);
-- [function Expr_Func ... is return ...;] -- generated body
-- end P; -- mode is ON
elsif not Comes_From_Source (N)
and then Present (Spec_Id)
and then Is_Expression_Function (Spec_Id)
then
Set_SPARK_Pragma (Body_Id, SPARK_Pragma (Spec_Id));
Set_SPARK_Pragma_Inherited
(Body_Id, SPARK_Pragma_Inherited (Spec_Id));
-- Set the SPARK_Mode from the current context (may be overwritten later
-- with explicit pragma). Exclude the case where the SPARK_Mode appears
-- initially on a stand-alone subprogram body, but is then relocated to
-- a generated corresponding spec. In this scenario the mode is shared
-- between the spec and body.
elsif No (SPARK_Pragma (Body_Id)) then
Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma);
Set_SPARK_Pragma_Inherited (Body_Id);
end if;
-- A subprogram body may be instantiated or inlined at a later pass.
-- Restore the state of Ignore_SPARK_Mode_Pragmas_In_Instance when it
-- applied to the initial declaration of the body.
if Present (Spec_Id) then
if Ignore_SPARK_Mode_Pragmas (Spec_Id) then
Ignore_SPARK_Mode_Pragmas_In_Instance := True;
end if;
else
-- Save the state of flag Ignore_SPARK_Mode_Pragmas_In_Instance in
-- case the body is instantiated or inlined later and out of context.
-- The body uses this attribute to restore the value of the global
-- flag.
if Ignore_SPARK_Mode_Pragmas_In_Instance then
Set_Ignore_SPARK_Mode_Pragmas (Body_Id);
elsif Ignore_SPARK_Mode_Pragmas (Body_Id) then
Ignore_SPARK_Mode_Pragmas_In_Instance := True;
end if;
end if;
-- Preserve relevant elaboration-related attributes of the context which
-- are no longer available or very expensive to recompute once analysis,
-- resolution, and expansion are over.
if No (Spec_Id) then
Mark_Elaboration_Attributes
(N_Id => Body_Id,
Checks => True,
Warnings => True);
end if;
-- If this is the proper body of a stub, we must verify that the stub
-- conforms to the body, and to the previous spec if one was present.
-- We know already that the body conforms to that spec. This test is
-- only required for subprograms that come from source.
if Nkind (Parent (N)) = N_Subunit
and then Comes_From_Source (N)
and then not Error_Posted (Body_Id)
and then Nkind (Corresponding_Stub (Parent (N))) =
N_Subprogram_Body_Stub
then
declare
Old_Id : constant Entity_Id :=
Defining_Entity
(Specification (Corresponding_Stub (Parent (N))));
Conformant : Boolean := False;
begin
if No (Spec_Id) then
Check_Fully_Conformant (Body_Id, Old_Id);
else
Check_Conformance
(Body_Id, Old_Id, Fully_Conformant, False, Conformant);
if not Conformant then
-- The stub was taken to be a new declaration. Indicate that
-- it lacks a body.
Set_Has_Completion (Old_Id, False);
end if;
end if;
end;
end if;
Set_Has_Completion (Body_Id);
Check_Eliminated (Body_Id);
-- Analyze any aspect specifications that appear on the subprogram body
-- stub. Stop the analysis now as the stub does not have a declarative
-- or a statement part, and it cannot be inlined.
if Nkind (N) = N_Subprogram_Body_Stub then
if Has_Aspects (N) then
Analyze_Aspects_On_Subprogram_Body_Or_Stub (N);
end if;
goto Leave;
end if;
-- Handle inlining
if Expander_Active
and then Serious_Errors_Detected = 0
and then Present (Spec_Id)
and then Has_Pragma_Inline (Spec_Id)
then
-- Legacy implementation (relying on front-end inlining)
if not Back_End_Inlining then
if Has_Pragma_Inline_Always (Spec_Id)
or else (Front_End_Inlining
and then not Opt.Disable_FE_Inline)
then
Build_Body_To_Inline (N, Spec_Id);
end if;
-- New implementation (relying on back-end inlining)
else
if Has_Pragma_Inline_Always (Spec_Id)
or else Optimization_Level > 0
then
-- Handle function returning an unconstrained type
if Comes_From_Source (Body_Id)
and then Ekind (Spec_Id) = E_Function
and then Returns_Unconstrained_Type (Spec_Id)
-- If function builds in place, i.e. returns a limited type,
-- inlining cannot be done.
and then not Is_Limited_Type (Etype (Spec_Id))
then
Check_And_Split_Unconstrained_Function (N, Spec_Id, Body_Id);
else
declare
Subp_Body : constant Node_Id :=
Unit_Declaration_Node (Body_Id);
Subp_Decl : constant List_Id := Declarations (Subp_Body);
begin
-- Do not pass inlining to the backend if the subprogram
-- has declarations or statements which cannot be inlined
-- by the backend. This check is done here to emit an
-- error instead of the generic warning message reported
-- by the GCC backend (ie. "function might not be
-- inlinable").
if Present (Subp_Decl)
and then Has_Excluded_Declaration (Spec_Id, Subp_Decl)
then
null;
elsif Has_Excluded_Statement
(Spec_Id,
Statements
(Handled_Statement_Sequence (Subp_Body)))
then
null;
-- If the backend inlining is available then at this
-- stage we only have to mark the subprogram as inlined.
-- The expander will take care of registering it in the
-- table of subprograms inlined by the backend a part of
-- processing calls to it (cf. Expand_Call)
else
Set_Is_Inlined (Spec_Id);
end if;
end;
end if;
end if;
end if;
-- In GNATprove mode, inline only when there is a separate subprogram
-- declaration for now, as inlining of subprogram bodies acting as
-- declarations, or subprogram stubs, are not supported by front-end
-- inlining. This inlining should occur after analysis of the body, so
-- that it is known whether the value of SPARK_Mode, which can be
-- defined by a pragma inside the body, is applicable to the body.
-- Inlining can be disabled with switch -gnatdm
elsif GNATprove_Mode
and then Full_Analysis
and then not Inside_A_Generic
and then Present (Spec_Id)
and then
Nkind (Unit_Declaration_Node (Spec_Id)) = N_Subprogram_Declaration
and then Body_Has_SPARK_Mode_On
and then Can_Be_Inlined_In_GNATprove_Mode (Spec_Id, Body_Id)
and then not Body_Has_Contract
and then not Debug_Flag_M
then
Build_Body_To_Inline (N, Spec_Id);
end if;
-- When generating code, inherited pre/postconditions are handled when
-- expanding the corresponding contract.
-- Ada 2005 (AI-262): In library subprogram bodies, after the analysis
-- of the specification we have to install the private withed units.
-- This holds for child units as well.
if Is_Compilation_Unit (Body_Id)
or else Nkind (Parent (N)) = N_Compilation_Unit
then
Install_Private_With_Clauses (Body_Id);
end if;
Check_Anonymous_Return;
-- Set the Protected_Formal field of each extra formal of the protected
-- subprogram to reference the corresponding extra formal of the
-- subprogram that implements it. For regular formals this occurs when
-- the protected subprogram's declaration is expanded, but the extra
-- formals don't get created until the subprogram is frozen. We need to
-- do this before analyzing the protected subprogram's body so that any
-- references to the original subprogram's extra formals will be changed
-- refer to the implementing subprogram's formals (see Expand_Formal).
if Present (Spec_Id)
and then Is_Protected_Type (Scope (Spec_Id))
and then Present (Protected_Body_Subprogram (Spec_Id))
then
declare
Impl_Subp : constant Entity_Id :=
Protected_Body_Subprogram (Spec_Id);
Prot_Ext_Formal : Entity_Id := Extra_Formals (Spec_Id);
Impl_Ext_Formal : Entity_Id := Extra_Formals (Impl_Subp);
begin
while Present (Prot_Ext_Formal) loop
pragma Assert (Present (Impl_Ext_Formal));
Set_Protected_Formal (Prot_Ext_Formal, Impl_Ext_Formal);
Next_Formal_With_Extras (Prot_Ext_Formal);
Next_Formal_With_Extras (Impl_Ext_Formal);
end loop;
end;
end if;
-- Generate minimum accessibility local objects to correspond with
-- any extra formal added for anonymous access types. This new local
-- object can then be used instead of the formal in case it is used
-- in an actual to a call to a nested subprogram.
-- This method is used to supplement our "small integer model" for
-- accessibility-check generation (for more information see
-- Dynamic_Accessibility_Level).
-- Because we allow accessibility values greater than our expected value
-- passing along the same extra accessibility formal as an actual
-- to a nested subprogram becomes a problem because high values mean
-- different things to the callee even though they are the same to the
-- caller. So, as described in the first section, we create a local
-- object representing the minimum of the accessibility level value that
-- is passed in and the accessibility level of the callee's parameter
-- and locals and use it in the case of a call to a nested subprogram.
-- This generated object is refered to as a "minimum accessiblity
-- level."
if Present (Spec_Id) or else Present (Body_Id) then
Body_Nod := Unit_Declaration_Node (Body_Id);
declare
Form : Entity_Id;
begin
-- Grab the appropriate formal depending on whether there exists
-- an actual spec for the subprogram or whether we are dealing
-- with a protected subprogram.
if Present (Spec_Id) then
if Present (Protected_Body_Subprogram (Spec_Id)) then
Form := First_Formal (Protected_Body_Subprogram (Spec_Id));
else
Form := First_Formal (Spec_Id);
end if;
else
Form := First_Formal (Body_Id);
end if;
-- Loop through formals if the subprogram is capable of accepting
-- a generated local object. If it is not then it is also not
-- capable of having local subprograms meaning it would not need
-- a minimum accessibility level object anyway.
if Present (Body_Nod)
and then Has_Declarations (Body_Nod)
and then Nkind (Body_Nod) /= N_Package_Specification
then
while Present (Form) loop
if Present (Extra_Accessibility (Form))
and then No (Minimum_Accessibility (Form))
then
-- Generate the minimum accessibility level object
-- A60b : natural := natural'min(1, paramL);
declare
Loc : constant Source_Ptr := Sloc (Body_Nod);
Obj_Node : constant Node_Id :=
Make_Object_Declaration (Loc,
Defining_Identifier =>
Make_Temporary
(Loc, 'A', Extra_Accessibility (Form)),
Object_Definition => New_Occurrence_Of
(Standard_Natural, Loc),
Expression =>
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of
(Standard_Natural, Loc),
Attribute_Name => Name_Min,
Expressions => New_List (
Make_Integer_Literal (Loc,
Object_Access_Level (Form)),
New_Occurrence_Of
(Extra_Accessibility (Form), Loc))));
begin
-- Add the new local object to the Minimum_Acc_Obj to
-- be later prepended to the subprogram's list of
-- declarations after we are sure all expansion is
-- done.
if Present (Minimum_Acc_Objs) then
Prepend (Obj_Node, Minimum_Acc_Objs);
else
Minimum_Acc_Objs := New_List (Obj_Node);
end if;
-- Register the object and analyze it
Set_Minimum_Accessibility
(Form, Defining_Identifier (Obj_Node));
Analyze (Obj_Node);
end;
end if;
Next_Formal (Form);
end loop;
end if;
end;
end if;
-- Now we can go on to analyze the body
HSS := Handled_Statement_Sequence (N);
Set_Actual_Subtypes (N, Current_Scope);
-- Add a declaration for the Protection object, renaming declarations
-- for discriminals and privals and finally a declaration for the entry
-- family index (if applicable). This form of early expansion is done
-- when the Expander is active because Install_Private_Data_Declarations
-- references entities which were created during regular expansion. The
-- subprogram entity must come from source, and not be an internally
-- generated subprogram.
if Expander_Active
and then Present (Prot_Typ)
and then Present (Spec_Id)
and then Comes_From_Source (Spec_Id)
and then not Is_Eliminated (Spec_Id)
then
Install_Private_Data_Declarations
(Sloc (N), Spec_Id, Prot_Typ, N, Declarations (N));
end if;
-- Ada 2012 (AI05-0151): Incomplete types coming from a limited context
-- may now appear in parameter and result profiles. Since the analysis
-- of a subprogram body may use the parameter and result profile of the
-- spec, swap any limited views with their non-limited counterpart.
if Ada_Version >= Ada_2012 and then Present (Spec_Id) then
Exch_Views := Exchange_Limited_Views (Spec_Id);
end if;
-- If the return type is an anonymous access type whose designated type
-- is the limited view of a class-wide type and the non-limited view is
-- available, update the return type accordingly.
if Ada_Version >= Ada_2005 and then Present (Spec_Id) then
declare
Etyp : Entity_Id;
Rtyp : Entity_Id;
begin
Rtyp := Etype (Spec_Id);
if Ekind (Rtyp) = E_Anonymous_Access_Type then
Etyp := Directly_Designated_Type (Rtyp);
if Is_Class_Wide_Type (Etyp)
and then From_Limited_With (Etyp)
then
Desig_View := Etyp;
Set_Directly_Designated_Type (Rtyp, Available_View (Etyp));
end if;
end if;
end;
end if;
-- Analyze any aspect specifications that appear on the subprogram body
if Has_Aspects (N) then
Analyze_Aspects_On_Subprogram_Body_Or_Stub (N);
end if;
Analyze_Declarations (Declarations (N));
-- Verify that the SPARK_Mode of the body agrees with that of its spec
if Present (Spec_Id) and then Present (SPARK_Pragma (Body_Id)) then
if Present (SPARK_Pragma (Spec_Id)) then
if Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Spec_Id)) = Off
and then
Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Body_Id)) = On
then
Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id));
Error_Msg_N ("incorrect application of SPARK_Mode#", N);
Error_Msg_Sloc := Sloc (SPARK_Pragma (Spec_Id));
Error_Msg_NE
("\value Off was set for SPARK_Mode on & #", N, Spec_Id);
end if;
elsif Nkind (Parent (Parent (Spec_Id))) = N_Subprogram_Body_Stub then
null;
-- SPARK_Mode Off could complete no SPARK_Mode in a generic, either
-- as specified in source code, or because SPARK_Mode On is ignored
-- in an instance where the context is SPARK_Mode Off/Auto.
elsif Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Body_Id)) = Off
and then (Is_Generic_Unit (Spec_Id) or else In_Instance)
then
null;
else
Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id));
Error_Msg_N ("incorrect application of SPARK_Mode #", N);
Error_Msg_Sloc := Sloc (Spec_Id);
Error_Msg_NE
("\no value was set for SPARK_Mode on & #", N, Spec_Id);
end if;
end if;
-- A subprogram body freezes its own contract. Analyze the contract
-- after the declarations of the body have been processed as pragmas
-- are now chained on the contract of the subprogram body.
Analyze_Entry_Or_Subprogram_Body_Contract (Body_Id);
-- Check completion, and analyze the statements
Check_Completion;
Inspect_Deferred_Constant_Completion (Declarations (N));
Analyze (HSS);
-- Add the generated minimum accessibility objects to the subprogram
-- body's list of declarations after analysis of the statements and
-- contracts.
while Is_Non_Empty_List (Minimum_Acc_Objs) loop
if Present (Declarations (Body_Nod)) then
Prepend (Remove_Head (Minimum_Acc_Objs), Declarations (Body_Nod));
else
Set_Declarations
(Body_Nod, New_List (Remove_Head (Minimum_Acc_Objs)));
end if;
end loop;
-- Deal with end of scope processing for the body
Process_End_Label (HSS, 't', Current_Scope);
Update_Use_Clause_Chain;
End_Scope;
-- If we are compiling an entry wrapper, remove the enclosing
-- synchronized object from the stack.
if Is_Entry_Wrapper (Body_Id) then
End_Scope;
end if;
Check_Subprogram_Order (N);
Set_Analyzed (Body_Id);
-- If we have a separate spec, then the analysis of the declarations
-- caused the entities in the body to be chained to the spec id, but
-- we want them chained to the body id. Only the formal parameters
-- end up chained to the spec id in this case.
if Present (Spec_Id) then
-- We must conform to the categorization of our spec
Validate_Categorization_Dependency (N, Spec_Id);
-- And if this is a child unit, the parent units must conform
if Is_Child_Unit (Spec_Id) then
Validate_Categorization_Dependency
(Unit_Declaration_Node (Spec_Id), Spec_Id);
end if;
-- Here is where we move entities from the spec to the body
-- Case where there are entities that stay with the spec
if Present (Last_Real_Spec_Entity) then
-- No body entities (happens when the only real spec entities come
-- from precondition and postcondition pragmas).
if No (Last_Entity (Body_Id)) then
Set_First_Entity (Body_Id, Next_Entity (Last_Real_Spec_Entity));
-- Body entities present (formals), so chain stuff past them
else
Link_Entities
(Last_Entity (Body_Id), Next_Entity (Last_Real_Spec_Entity));
end if;
Set_Next_Entity (Last_Real_Spec_Entity, Empty);
Set_Last_Entity (Body_Id, Last_Entity (Spec_Id));
Set_Last_Entity (Spec_Id, Last_Real_Spec_Entity);
-- Case where there are no spec entities, in this case there can be
-- no body entities either, so just move everything.
-- If the body is generated for an expression function, it may have
-- been preanalyzed already, if 'access was applied to it.
else
if Nkind (Original_Node (Unit_Declaration_Node (Spec_Id))) /=
N_Expression_Function
then
pragma Assert (No (Last_Entity (Body_Id)));
null;
end if;
Set_First_Entity (Body_Id, First_Entity (Spec_Id));
Set_Last_Entity (Body_Id, Last_Entity (Spec_Id));
Set_First_Entity (Spec_Id, Empty);
Set_Last_Entity (Spec_Id, Empty);
end if;
-- Otherwise the body does not complete a previous declaration. Check
-- the categorization of the body against the units it withs.
else
Validate_Categorization_Dependency (N, Body_Id);
end if;
Check_Missing_Return;
-- Now we are going to check for variables that are never modified in
-- the body of the procedure. But first we deal with a special case
-- where we want to modify this check. If the body of the subprogram
-- starts with a raise statement or its equivalent, or if the body
-- consists entirely of a null statement, then it is pretty obvious that
-- it is OK to not reference the parameters. For example, this might be
-- the following common idiom for a stubbed function: statement of the
-- procedure raises an exception. In particular this deals with the
-- common idiom of a stubbed function, which appears something like:
-- function F (A : Integer) return Some_Type;
-- X : Some_Type;
-- begin
-- raise Program_Error;
-- return X;
-- end F;
-- Here the purpose of X is simply to satisfy the annoying requirement
-- in Ada that there be at least one return, and we certainly do not
-- want to go posting warnings on X that it is not initialized. On
-- the other hand, if X is entirely unreferenced that should still
-- get a warning.
-- What we do is to detect these cases, and if we find them, flag the
-- subprogram as being Is_Trivial_Subprogram and then use that flag to
-- suppress unwanted warnings. For the case of the function stub above
-- we have a special test to set X as apparently assigned to suppress
-- the warning.
declare
Stm : Node_Id;
begin
-- Skip call markers installed by the ABE mechanism, labels, and
-- Push_xxx_Error_Label to find the first real statement.
Stm := First (Statements (HSS));
while Nkind (Stm) in N_Call_Marker | N_Label | N_Push_xxx_Label loop
Next (Stm);
end loop;
-- Do the test on the original statement before expansion
declare
Ostm : constant Node_Id := Original_Node (Stm);
begin
-- If explicit raise statement, turn on flag
if Nkind (Ostm) = N_Raise_Statement then
Set_Trivial_Subprogram (Stm);
-- If null statement, and no following statements, turn on flag
elsif Nkind (Stm) = N_Null_Statement
and then Comes_From_Source (Stm)
and then No (Next (Stm))
then
Set_Trivial_Subprogram (Stm);
-- Check for explicit call cases which likely raise an exception
elsif Nkind (Ostm) = N_Procedure_Call_Statement then
if Is_Entity_Name (Name (Ostm)) then
declare
Ent : constant Entity_Id := Entity (Name (Ostm));
begin
-- If the procedure is marked No_Return, then likely it
-- raises an exception, but in any case it is not coming
-- back here, so turn on the flag.
if Present (Ent)
and then Ekind (Ent) = E_Procedure
and then No_Return (Ent)
then
Set_Trivial_Subprogram (Stm);
end if;
end;
end if;
end if;
end;
end;
-- Check for variables that are never modified
declare
E1 : Entity_Id;
E2 : Entity_Id;
begin
-- If there is a separate spec, then transfer Never_Set_In_Source
-- flags from out parameters to the corresponding entities in the
-- body. The reason we do that is we want to post error flags on
-- the body entities, not the spec entities.
if Present (Spec_Id) then
E1 := First_Entity (Spec_Id);
while Present (E1) loop
if Ekind (E1) = E_Out_Parameter then
E2 := First_Entity (Body_Id);
while Present (E2) loop
exit when Chars (E1) = Chars (E2);
Next_Entity (E2);
end loop;
if Present (E2) then
Set_Never_Set_In_Source (E2, Never_Set_In_Source (E1));
end if;
end if;
Next_Entity (E1);
end loop;
end if;
-- Check references of the subprogram spec when we are dealing with
-- an expression function due to it having a generated body.
-- Otherwise, we simply check the formals of the subprogram body.
if Present (Spec_Id)
and then Is_Expression_Function (Spec_Id)
then
Check_References (Spec_Id);
else
Check_References (Body_Id);
end if;
end;
-- Check for nested subprogram, and mark outer level subprogram if so
declare
Ent : Entity_Id;
begin
if Present (Spec_Id) then
Ent := Spec_Id;
else
Ent := Body_Id;
end if;
loop
Ent := Enclosing_Subprogram (Ent);
exit when No (Ent) or else Is_Subprogram (Ent);
end loop;
if Present (Ent) then
Set_Has_Nested_Subprogram (Ent);
end if;
end;
-- Restore the limited views in the spec, if any, to let the back end
-- process it without running into circularities.
if Exch_Views /= No_Elist then
Restore_Limited_Views (Exch_Views);
end if;
if Mask_Types /= No_Elist then
Unmask_Unfrozen_Types (Mask_Types);
end if;
if Present (Desig_View) then
Set_Directly_Designated_Type (Etype (Spec_Id), Desig_View);
end if;
<<Leave>>
if Present (Ignored_Ghost_Region) then
Expander_Active := Saved_EA;
end if;
Ignore_SPARK_Mode_Pragmas_In_Instance := Saved_ISMP;
Restore_Ghost_Region (Saved_GM, Saved_IGR);
end Analyze_Subprogram_Body_Helper;
------------------------------------
-- Analyze_Subprogram_Declaration --
------------------------------------
procedure Analyze_Subprogram_Declaration (N : Node_Id) is
Scop : constant Entity_Id := Current_Scope;
Designator : Entity_Id;
Is_Completion : Boolean;
-- Indicates whether a null procedure declaration is a completion
begin
-- Null procedures are not allowed in SPARK
if Nkind (Specification (N)) = N_Procedure_Specification
and then Null_Present (Specification (N))
then
-- Null procedures are allowed in protected types, following the
-- recent AI12-0147.
if Is_Protected_Type (Current_Scope)
and then Ada_Version < Ada_2012
then
Error_Msg_N ("protected operation cannot be a null procedure", N);
end if;
Analyze_Null_Procedure (N, Is_Completion);
-- The null procedure acts as a body, nothing further is needed
if Is_Completion then
return;
end if;
end if;
Designator := Analyze_Subprogram_Specification (Specification (N));
-- A reference may already have been generated for the unit name, in
-- which case the following call is redundant. However it is needed for
-- declarations that are the rewriting of an expression function.
Generate_Definition (Designator);
-- Set the SPARK mode from the current context (may be overwritten later
-- with explicit pragma). This is not done for entry barrier functions
-- because they are generated outside the protected type and should not
-- carry the mode of the enclosing context.
if Nkind (N) = N_Subprogram_Declaration
and then Is_Entry_Barrier_Function (N)
then
null;
else
Set_SPARK_Pragma (Designator, SPARK_Mode_Pragma);
Set_SPARK_Pragma_Inherited (Designator);
end if;
-- Save the state of flag Ignore_SPARK_Mode_Pragmas_In_Instance in case
-- the body of this subprogram is instantiated or inlined later and out
-- of context. The body uses this attribute to restore the value of the
-- global flag.
if Ignore_SPARK_Mode_Pragmas_In_Instance then
Set_Ignore_SPARK_Mode_Pragmas (Designator);
end if;
-- Preserve relevant elaboration-related attributes of the context which
-- are no longer available or very expensive to recompute once analysis,
-- resolution, and expansion are over.
Mark_Elaboration_Attributes
(N_Id => Designator,
Checks => True,
Warnings => True);
if Debug_Flag_C then
Write_Str ("==> subprogram spec ");
Write_Name (Chars (Designator));
Write_Str (" from ");
Write_Location (Sloc (N));
Write_Eol;
Indent;
end if;
Validate_RCI_Subprogram_Declaration (N);
New_Overloaded_Entity (Designator);
Check_Delayed_Subprogram (Designator);
-- If the type of the first formal of the current subprogram is a non-
-- generic tagged private type, mark the subprogram as being a private
-- primitive. Ditto if this is a function with controlling result, and
-- the return type is currently private. In both cases, the type of the
-- controlling argument or result must be in the current scope for the
-- operation to be primitive.
if Has_Controlling_Result (Designator)
and then Is_Private_Type (Etype (Designator))
and then Scope (Etype (Designator)) = Current_Scope
and then not Is_Generic_Actual_Type (Etype (Designator))
then
Set_Is_Private_Primitive (Designator);
elsif Present (First_Formal (Designator)) then
declare
Formal_Typ : constant Entity_Id :=
Etype (First_Formal (Designator));
begin
Set_Is_Private_Primitive (Designator,
Is_Tagged_Type (Formal_Typ)
and then Scope (Formal_Typ) = Current_Scope
and then Is_Private_Type (Formal_Typ)
and then not Is_Generic_Actual_Type (Formal_Typ));
end;
end if;
-- Ada 2005 (AI-251): Abstract interface primitives must be abstract
-- or null.
if Ada_Version >= Ada_2005
and then Comes_From_Source (N)
and then Is_Dispatching_Operation (Designator)
then
declare
E : Entity_Id;
Etyp : Entity_Id;
begin
if Has_Controlling_Result (Designator) then
Etyp := Etype (Designator);
else
E := First_Entity (Designator);
while Present (E)
and then Is_Formal (E)
and then not Is_Controlling_Formal (E)
loop
Next_Entity (E);
end loop;
Etyp := Etype (E);
end if;
if Is_Access_Type (Etyp) then
Etyp := Directly_Designated_Type (Etyp);
end if;
if Is_Interface (Etyp)
and then not Is_Abstract_Subprogram (Designator)
and then not (Ekind (Designator) = E_Procedure
and then Null_Present (Specification (N)))
then
Error_Msg_Name_1 := Chars (Defining_Entity (N));
-- Specialize error message based on procedures vs. functions,
-- since functions can't be null subprograms.
if Ekind (Designator) = E_Procedure then
Error_Msg_N
("interface procedure % must be abstract or null", N);
else
Error_Msg_N
("interface function % must be abstract", N);
end if;
end if;
end;
end if;
-- What is the following code for, it used to be
-- ??? Set_Suppress_Elaboration_Checks
-- ??? (Designator, Elaboration_Checks_Suppressed (Designator));
-- The following seems equivalent, but a bit dubious
if Elaboration_Checks_Suppressed (Designator) then
Set_Kill_Elaboration_Checks (Designator);
end if;
-- For a compilation unit, set body required. This flag will only be
-- reset if a valid Import or Interface pragma is processed later on.
if Nkind (Parent (N)) = N_Compilation_Unit then
Set_Body_Required (Parent (N), True);
if Ada_Version >= Ada_2005
and then Nkind (Specification (N)) = N_Procedure_Specification
and then Null_Present (Specification (N))
then
Error_Msg_N
("null procedure cannot be declared at library level", N);
end if;
end if;
Generate_Reference_To_Formals (Designator);
Check_Eliminated (Designator);
if Debug_Flag_C then
Outdent;
Write_Str ("<== subprogram spec ");
Write_Name (Chars (Designator));
Write_Str (" from ");
Write_Location (Sloc (N));
Write_Eol;
end if;
-- Indicate that this is a protected operation, because it may be used
-- in subsequent declarations within the protected type.
if Is_Protected_Type (Current_Scope) then
Set_Convention (Designator, Convention_Protected);
end if;
List_Inherited_Pre_Post_Aspects (Designator);
-- Process the aspects before establishing the proper categorization in
-- case the subprogram is a compilation unit and one of its aspects is
-- converted into a categorization pragma.
if Has_Aspects (N) then
Analyze_Aspect_Specifications (N, Designator);
end if;
if Scop /= Standard_Standard and then not Is_Child_Unit (Designator) then
Set_Categorization_From_Scope (Designator, Scop);
-- Otherwise the unit is a compilation unit and/or a child unit. Set the
-- proper categorization of the unit based on its pragmas.
else
Push_Scope (Designator);
Set_Categorization_From_Pragmas (N);
Validate_Categorization_Dependency (N, Designator);
Pop_Scope;
end if;
end Analyze_Subprogram_Declaration;
--------------------------------------
-- Analyze_Subprogram_Specification --
--------------------------------------
-- Reminder: N here really is a subprogram specification (not a subprogram
-- declaration). This procedure is called to analyze the specification in
-- both subprogram bodies and subprogram declarations (specs).
function Analyze_Subprogram_Specification (N : Node_Id) return Entity_Id is
function Is_Invariant_Procedure_Or_Body (E : Entity_Id) return Boolean;
-- Determine whether entity E denotes the spec or body of an invariant
-- procedure.
------------------------------------
-- Is_Invariant_Procedure_Or_Body --
------------------------------------
function Is_Invariant_Procedure_Or_Body (E : Entity_Id) return Boolean is
Decl : constant Node_Id := Unit_Declaration_Node (E);
Spec : Entity_Id;
begin
if Nkind (Decl) = N_Subprogram_Body then
Spec := Corresponding_Spec (Decl);
else
Spec := E;
end if;
return
Present (Spec)
and then Ekind (Spec) = E_Procedure
and then (Is_Partial_Invariant_Procedure (Spec)
or else Is_Invariant_Procedure (Spec));
end Is_Invariant_Procedure_Or_Body;
-- Local variables
Designator : constant Entity_Id := Defining_Entity (N);
Formals : constant List_Id := Parameter_Specifications (N);
-- Start of processing for Analyze_Subprogram_Specification
begin
-- Proceed with analysis. Do not emit a cross-reference entry if the
-- specification comes from an expression function, because it may be
-- the completion of a previous declaration. If it is not, the cross-
-- reference entry will be emitted for the new subprogram declaration.
if Nkind (Parent (N)) /= N_Expression_Function then
Generate_Definition (Designator);
end if;
if Nkind (N) = N_Function_Specification then
Set_Ekind (Designator, E_Function);
Set_Mechanism (Designator, Default_Mechanism);
else
Set_Ekind (Designator, E_Procedure);
Set_Etype (Designator, Standard_Void_Type);
end if;
-- Flag Is_Inlined_Always is True by default, and reversed to False for
-- those subprograms which could be inlined in GNATprove mode (because
-- Body_To_Inline is non-Empty) but should not be inlined.
if GNATprove_Mode then
Set_Is_Inlined_Always (Designator);
end if;
-- Introduce new scope for analysis of the formals and the return type
Set_Scope (Designator, Current_Scope);
if Present (Formals) then
Push_Scope (Designator);
Process_Formals (Formals, N);
-- Check dimensions in N for formals with default expression
Analyze_Dimension_Formals (N, Formals);
-- Ada 2005 (AI-345): If this is an overriding operation of an
-- inherited interface operation, and the controlling type is
-- a synchronized type, replace the type with its corresponding
-- record, to match the proper signature of an overriding operation.
-- Same processing for an access parameter whose designated type is
-- derived from a synchronized interface.
-- This modification is not done for invariant procedures because
-- the corresponding record may not necessarely be visible when the
-- concurrent type acts as the full view of a private type.
-- package Pack is
-- type Prot is private with Type_Invariant => ...;
-- procedure ConcInvariant (Obj : Prot);
-- private
-- protected type Prot is ...;
-- type Concurrent_Record_Prot is record ...;
-- procedure ConcInvariant (Obj : Prot) is
-- ...
-- end ConcInvariant;
-- end Pack;
-- In the example above, both the spec and body of the invariant
-- procedure must utilize the private type as the controlling type.
if Ada_Version >= Ada_2005
and then not Is_Invariant_Procedure_Or_Body (Designator)
then
declare
Formal : Entity_Id;
Formal_Typ : Entity_Id;
Rec_Typ : Entity_Id;
Desig_Typ : Entity_Id;
begin
Formal := First_Formal (Designator);
while Present (Formal) loop
Formal_Typ := Etype (Formal);
if Is_Concurrent_Type (Formal_Typ)
and then Present (Corresponding_Record_Type (Formal_Typ))
then
Rec_Typ := Corresponding_Record_Type (Formal_Typ);
if Present (Interfaces (Rec_Typ)) then
Set_Etype (Formal, Rec_Typ);
end if;
elsif Ekind (Formal_Typ) = E_Anonymous_Access_Type then
Desig_Typ := Designated_Type (Formal_Typ);
if Is_Concurrent_Type (Desig_Typ)
and then Present (Corresponding_Record_Type (Desig_Typ))
then
Rec_Typ := Corresponding_Record_Type (Desig_Typ);
if Present (Interfaces (Rec_Typ)) then
Set_Directly_Designated_Type (Formal_Typ, Rec_Typ);
end if;
end if;
end if;
Next_Formal (Formal);
end loop;
end;
end if;
End_Scope;
-- The subprogram scope is pushed and popped around the processing of
-- the return type for consistency with call above to Process_Formals
-- (which itself can call Analyze_Return_Type), and to ensure that any
-- itype created for the return type will be associated with the proper
-- scope.
elsif Nkind (N) = N_Function_Specification then
Push_Scope (Designator);
Analyze_Return_Type (N);
End_Scope;
end if;
-- Function case
if Nkind (N) = N_Function_Specification then
-- Deal with operator symbol case
if Nkind (Designator) = N_Defining_Operator_Symbol then
Valid_Operator_Definition (Designator);
end if;
May_Need_Actuals (Designator);
-- Ada 2005 (AI-251): If the return type is abstract, verify that
-- the subprogram is abstract also. This does not apply to renaming
-- declarations, where abstractness is inherited, and to subprogram
-- bodies generated for stream operations, which become renamings as
-- bodies.
-- In case of primitives associated with abstract interface types
-- the check is applied later (see Analyze_Subprogram_Declaration).
if Nkind (Original_Node (Parent (N))) not in
N_Abstract_Subprogram_Declaration |
N_Formal_Abstract_Subprogram_Declaration |
N_Subprogram_Renaming_Declaration
then
if Is_Abstract_Type (Etype (Designator)) then
Error_Msg_N
("function that returns abstract type must be abstract", N);
-- Ada 2012 (AI-0073): Extend this test to subprograms with an
-- access result whose designated type is abstract.
elsif Ada_Version >= Ada_2012
and then Nkind (Result_Definition (N)) = N_Access_Definition
and then
not Is_Class_Wide_Type (Designated_Type (Etype (Designator)))
and then Is_Abstract_Type (Designated_Type (Etype (Designator)))
then
Error_Msg_N
("function whose access result designates abstract type "
& "must be abstract", N);
end if;
end if;
end if;
return Designator;
end Analyze_Subprogram_Specification;
-----------------------
-- Check_Conformance --
-----------------------
procedure Check_Conformance
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Ctype : Conformance_Type;
Errmsg : Boolean;
Conforms : out Boolean;
Err_Loc : Node_Id := Empty;
Get_Inst : Boolean := False;
Skip_Controlling_Formals : Boolean := False)
is
procedure Conformance_Error (Msg : String; N : Node_Id := New_Id);
-- Sets Conforms to False. If Errmsg is False, then that's all it does.
-- If Errmsg is True, then processing continues to post an error message
-- for conformance error on given node. Two messages are output. The
-- first message points to the previous declaration with a general "no
-- conformance" message. The second is the detailed reason, supplied as
-- Msg. The parameter N provide information for a possible & insertion
-- in the message, and also provides the location for posting the
-- message in the absence of a specified Err_Loc location.
function Conventions_Match (Id1, Id2 : Entity_Id) return Boolean;
-- True if the conventions of entities Id1 and Id2 match.
function Null_Exclusions_Match (F1, F2 : Entity_Id) return Boolean;
-- True if the null exclusions of two formals of anonymous access type
-- match.
-----------------------
-- Conformance_Error --
-----------------------
procedure Conformance_Error (Msg : String; N : Node_Id := New_Id) is
Enode : Node_Id;
begin
Conforms := False;
if Errmsg then
if No (Err_Loc) then
Enode := N;
else
Enode := Err_Loc;
end if;
Error_Msg_Sloc := Sloc (Old_Id);
case Ctype is
when Type_Conformant =>
Error_Msg_N -- CODEFIX
("not type conformant with declaration#!", Enode);
when Mode_Conformant =>
if Nkind (Parent (Old_Id)) = N_Full_Type_Declaration then
Error_Msg_N
("not mode conformant with operation inherited#!",
Enode);
else
Error_Msg_N
("not mode conformant with declaration#!", Enode);
end if;
when Subtype_Conformant =>
if Nkind (Parent (Old_Id)) = N_Full_Type_Declaration then
Error_Msg_N
("not subtype conformant with operation inherited#!",
Enode);
else
Error_Msg_N
("not subtype conformant with declaration#!", Enode);
end if;
when Fully_Conformant =>
if Nkind (Parent (Old_Id)) = N_Full_Type_Declaration then
Error_Msg_N -- CODEFIX
("not fully conformant with operation inherited#!",
Enode);
else
Error_Msg_N -- CODEFIX
("not fully conformant with declaration#!", Enode);
end if;
end case;
Error_Msg_NE (Msg, Enode, N);
end if;
end Conformance_Error;
-----------------------
-- Conventions_Match --
-----------------------
function Conventions_Match
(Id1 : Entity_Id;
Id2 : Entity_Id) return Boolean
is
begin
-- Ignore the conventions of anonymous access-to-subprogram types
-- and subprogram types because these are internally generated and
-- the only way these may receive a convention is if they inherit
-- the convention of a related subprogram.
if Ekind (Id1) in E_Anonymous_Access_Subprogram_Type
| E_Subprogram_Type
or else
Ekind (Id2) in E_Anonymous_Access_Subprogram_Type
| E_Subprogram_Type
then
return True;
-- Otherwise compare the conventions directly
else
return Convention (Id1) = Convention (Id2);
end if;
end Conventions_Match;
---------------------------
-- Null_Exclusions_Match --
---------------------------
function Null_Exclusions_Match (F1, F2 : Entity_Id) return Boolean is
begin
if not Is_Anonymous_Access_Type (Etype (F1))
or else not Is_Anonymous_Access_Type (Etype (F2))
then
return True;
end if;
-- AI12-0289-1: Case of controlling access parameter; False if the
-- partial view is untagged, the full view is tagged, and no explicit
-- "not null". Note that at this point, we're processing the package
-- body, so private/full types have been swapped. The Sloc test below
-- is to detect the (legal) case where F1 comes after the full type
-- declaration. This part is disabled pre-2005, because "not null" is
-- not allowed on those language versions.
if Ada_Version >= Ada_2005
and then Is_Controlling_Formal (F1)
and then not Null_Exclusion_Present (Parent (F1))
and then not Null_Exclusion_Present (Parent (F2))
then
declare
D : constant Entity_Id := Directly_Designated_Type (Etype (F1));
Partial_View_Of_Desig : constant Entity_Id :=
Incomplete_Or_Partial_View (D);
begin
return No (Partial_View_Of_Desig)
or else Is_Tagged_Type (Partial_View_Of_Desig)
or else Sloc (D) < Sloc (F1);
end;
-- Not a controlling parameter, or one or both views have an explicit
-- "not null".
else
return Null_Exclusion_Present (Parent (F1)) =
Null_Exclusion_Present (Parent (F2));
end if;
end Null_Exclusions_Match;
-- Local Variables
Old_Type : constant Entity_Id := Etype (Old_Id);
New_Type : constant Entity_Id := Etype (New_Id);
Old_Formal : Entity_Id;
New_Formal : Entity_Id;
Old_Formal_Base : Entity_Id;
New_Formal_Base : Entity_Id;
-- Start of processing for Check_Conformance
begin
Conforms := True;
-- We need a special case for operators, since they don't appear
-- explicitly.
if Ctype = Type_Conformant then
if Ekind (New_Id) = E_Operator
and then Operator_Matches_Spec (New_Id, Old_Id)
then
return;
end if;
end if;
-- If both are functions/operators, check return types conform
if Old_Type /= Standard_Void_Type
and then
New_Type /= Standard_Void_Type
then
-- If we are checking interface conformance we omit controlling
-- arguments and result, because we are only checking the conformance
-- of the remaining parameters.
if Has_Controlling_Result (Old_Id)
and then Has_Controlling_Result (New_Id)
and then Skip_Controlling_Formals
then
null;
elsif not Conforming_Types (Old_Type, New_Type, Ctype, Get_Inst) then
if Ctype >= Subtype_Conformant
and then not Predicates_Match (Old_Type, New_Type)
then
Conformance_Error
("\predicate of return type does not match!", New_Id);
else
Conformance_Error
("\return type does not match!", New_Id);
end if;
return;
end if;
-- Ada 2005 (AI-231): In case of anonymous access types check the
-- null-exclusion and access-to-constant attributes match.
if Ada_Version >= Ada_2005
and then Ekind (Etype (Old_Type)) = E_Anonymous_Access_Type
and then
(Can_Never_Be_Null (Old_Type) /= Can_Never_Be_Null (New_Type)
or else Is_Access_Constant (Etype (Old_Type)) /=
Is_Access_Constant (Etype (New_Type)))
then
Conformance_Error ("\return type does not match!", New_Id);
return;
end if;
-- If either is a function/operator and the other isn't, error
elsif Old_Type /= Standard_Void_Type
or else New_Type /= Standard_Void_Type
then
Conformance_Error ("\functions can only match functions!", New_Id);
return;
end if;
-- In subtype conformant case, conventions must match (RM 6.3.1(16)).
-- If this is a renaming as body, refine error message to indicate that
-- the conflict is with the original declaration. If the entity is not
-- frozen, the conventions don't have to match, the one of the renamed
-- entity is inherited.
if Ctype >= Subtype_Conformant then
if not Conventions_Match (Old_Id, New_Id) then
if not Is_Frozen (New_Id) then
null;
elsif Present (Err_Loc)
and then Nkind (Err_Loc) = N_Subprogram_Renaming_Declaration
and then Present (Corresponding_Spec (Err_Loc))
then
Error_Msg_Name_1 := Chars (New_Id);
Error_Msg_Name_2 :=
Name_Ada + Convention_Id'Pos (Convention (New_Id));
Conformance_Error ("\prior declaration for% has convention %!");
return;
else
Conformance_Error ("\calling conventions do not match!");
return;
end if;
else
Check_Formal_Subprogram_Conformance
(New_Id, Old_Id, Err_Loc, Errmsg, Conforms);
if not Conforms then
return;
end if;
end if;
end if;
-- Deal with parameters
-- Note: we use the entity information, rather than going directly
-- to the specification in the tree. This is not only simpler, but
-- absolutely necessary for some cases of conformance tests between
-- operators, where the declaration tree simply does not exist.
Old_Formal := First_Formal (Old_Id);
New_Formal := First_Formal (New_Id);
while Present (Old_Formal) and then Present (New_Formal) loop
if Is_Controlling_Formal (Old_Formal)
and then Is_Controlling_Formal (New_Formal)
and then Skip_Controlling_Formals
then
-- The controlling formals will have different types when
-- comparing an interface operation with its match, but both
-- or neither must be access parameters.
if Is_Access_Type (Etype (Old_Formal))
=
Is_Access_Type (Etype (New_Formal))
then
goto Skip_Controlling_Formal;
else
Conformance_Error
("\access parameter does not match!", New_Formal);
end if;
end if;
-- Ada 2012: Mode conformance also requires that formal parameters
-- be both aliased, or neither.
if Ctype >= Mode_Conformant and then Ada_Version >= Ada_2012 then
if Is_Aliased (Old_Formal) /= Is_Aliased (New_Formal) then
Conformance_Error
("\aliased parameter mismatch!", New_Formal);
end if;
end if;
if Ctype = Fully_Conformant then
-- Names must match. Error message is more accurate if we do
-- this before checking that the types of the formals match.
if Chars (Old_Formal) /= Chars (New_Formal) then
Conformance_Error ("\name& does not match!", New_Formal);
-- Set error posted flag on new formal as well to stop
-- junk cascaded messages in some cases.
Set_Error_Posted (New_Formal);
return;
end if;
-- Null exclusion must match
if not Null_Exclusions_Match (Old_Formal, New_Formal) then
Conformance_Error
("\null exclusion for& does not match", New_Formal);
-- Mark error posted on the new formal to avoid duplicated
-- complaint about types not matching.
Set_Error_Posted (New_Formal);
end if;
end if;
-- Ada 2005 (AI-423): Possible access [sub]type and itype match. This
-- case occurs whenever a subprogram is being renamed and one of its
-- parameters imposes a null exclusion. For example:
-- type T is null record;
-- type Acc_T is access T;
-- subtype Acc_T_Sub is Acc_T;
-- procedure P (Obj : not null Acc_T_Sub); -- itype
-- procedure Ren_P (Obj : Acc_T_Sub) -- subtype
-- renames P;
Old_Formal_Base := Etype (Old_Formal);
New_Formal_Base := Etype (New_Formal);
if Get_Inst then
Old_Formal_Base := Get_Instance_Of (Old_Formal_Base);
New_Formal_Base := Get_Instance_Of (New_Formal_Base);
end if;
-- Types must always match. In the visible part of an instance,
-- usual overloading rules for dispatching operations apply, and
-- we check base types (not the actual subtypes).
if In_Instance_Visible_Part
and then Is_Dispatching_Operation (New_Id)
then
if not Conforming_Types
(T1 => Base_Type (Etype (Old_Formal)),
T2 => Base_Type (Etype (New_Formal)),
Ctype => Ctype,
Get_Inst => Get_Inst)
then
Conformance_Error ("\type of & does not match!", New_Formal);
return;
end if;
elsif not Conforming_Types
(T1 => Old_Formal_Base,
T2 => New_Formal_Base,
Ctype => Ctype,
Get_Inst => Get_Inst)
then
-- Don't give error message if old type is Any_Type. This test
-- avoids some cascaded errors, e.g. in case of a bad spec.
if Errmsg and then Old_Formal_Base = Any_Type then
Conforms := False;
else
if Ctype >= Subtype_Conformant
and then
not Predicates_Match (Old_Formal_Base, New_Formal_Base)
then
Conformance_Error
("\predicate of & does not match!", New_Formal);
else
Conformance_Error
("\type of & does not match!", New_Formal);
if not Dimensions_Match (Old_Formal_Base, New_Formal_Base)
then
Error_Msg_N ("\dimensions mismatch!", New_Formal);
end if;
end if;
end if;
return;
end if;
-- For mode conformance, mode must match
if Ctype >= Mode_Conformant then
if Parameter_Mode (Old_Formal) /= Parameter_Mode (New_Formal) then
if Ekind (New_Id) not in E_Function | E_Procedure
or else not Is_Primitive_Wrapper (New_Id)
then
Conformance_Error ("\mode of & does not match!", New_Formal);
else
declare
T : constant Entity_Id := Find_Dispatching_Type (New_Id);
begin
if Is_Protected_Type (Corresponding_Concurrent_Type (T))
then
Conforms := False;
if Errmsg then
Error_Msg_PT (New_Id, Ultimate_Alias (Old_Id));
end if;
else
Conformance_Error
("\mode of & does not match!", New_Formal);
end if;
end;
end if;
return;
elsif Is_Access_Type (Old_Formal_Base)
and then Is_Access_Type (New_Formal_Base)
and then Is_Access_Constant (Old_Formal_Base) /=
Is_Access_Constant (New_Formal_Base)
then
Conformance_Error
("\constant modifier does not match!", New_Formal);
return;
end if;
end if;
if Ctype >= Subtype_Conformant then
-- Ada 2005 (AI-231): In case of anonymous access types check
-- the null-exclusion and access-to-constant attributes must
-- match. For null exclusion, we test the types rather than the
-- formals themselves, since the attribute is only set reliably
-- on the formals in the Ada 95 case, and we exclude the case
-- where Old_Formal is marked as controlling, to avoid errors
-- when matching completing bodies with dispatching declarations
-- (access formals in the bodies aren't marked Can_Never_Be_Null).
if Ada_Version >= Ada_2005
and then Is_Anonymous_Access_Type (Etype (Old_Formal))
and then Is_Anonymous_Access_Type (Etype (New_Formal))
and then
((Can_Never_Be_Null (Etype (Old_Formal)) /=
Can_Never_Be_Null (Etype (New_Formal))
and then
not Is_Controlling_Formal (Old_Formal))
or else
Is_Access_Constant (Etype (Old_Formal)) /=
Is_Access_Constant (Etype (New_Formal)))
-- Do not complain if error already posted on New_Formal. This
-- avoids some redundant error messages.
and then not Error_Posted (New_Formal)
then
-- It is allowed to omit the null-exclusion in case of stream
-- attribute subprograms. We recognize stream subprograms
-- through their TSS-generated suffix.
declare
TSS_Name : constant TSS_Name_Type := Get_TSS_Name (New_Id);
begin
if TSS_Name /= TSS_Stream_Read
and then TSS_Name /= TSS_Stream_Write
and then TSS_Name /= TSS_Stream_Input
and then TSS_Name /= TSS_Stream_Output
then
-- Here we have a definite conformance error. It is worth
-- special casing the error message for the case of a
-- controlling formal (which excludes null).
if Is_Controlling_Formal (New_Formal) then
Error_Msg_Node_2 := Scope (New_Formal);
Conformance_Error
("\controlling formal & of & excludes null, "
& "declaration must exclude null as well",
New_Formal);
-- Normal case (couldn't we give more detail here???)
else
Conformance_Error
("\type of & does not match!", New_Formal);
end if;
return;
end if;
end;
end if;
end if;
-- Full conformance checks
if Ctype = Fully_Conformant then
-- We have checked already that names match
if Parameter_Mode (Old_Formal) = E_In_Parameter then
-- Check default expressions for in parameters
declare
NewD : constant Boolean :=
Present (Default_Value (New_Formal));
OldD : constant Boolean :=
Present (Default_Value (Old_Formal));
begin
if NewD or OldD then
-- The old default value has been analyzed because the
-- current full declaration will have frozen everything
-- before. The new default value has not been analyzed,
-- so analyze it now before we check for conformance.
if NewD then
Push_Scope (New_Id);
Preanalyze_Spec_Expression
(Default_Value (New_Formal), Etype (New_Formal));
End_Scope;
end if;
if not (NewD and OldD)
or else not Fully_Conformant_Expressions
(Default_Value (Old_Formal),
Default_Value (New_Formal))
then
Conformance_Error
("\default expression for & does not match!",
New_Formal);
return;
end if;
end if;
end;
end if;
end if;
-- A couple of special checks for Ada 83 mode. These checks are
-- skipped if either entity is an operator in package Standard,
-- or if either old or new instance is not from the source program.
if Ada_Version = Ada_83
and then Sloc (Old_Id) > Standard_Location
and then Sloc (New_Id) > Standard_Location
and then Comes_From_Source (Old_Id)
and then Comes_From_Source (New_Id)
then
declare
Old_Param : constant Node_Id := Declaration_Node (Old_Formal);
New_Param : constant Node_Id := Declaration_Node (New_Formal);
begin
-- Explicit IN must be present or absent in both cases. This
-- test is required only in the full conformance case.
if In_Present (Old_Param) /= In_Present (New_Param)
and then Ctype = Fully_Conformant
then
Conformance_Error
("\(Ada 83) IN must appear in both declarations",
New_Formal);
return;
end if;
-- Grouping (use of comma in param lists) must be the same
-- This is where we catch a misconformance like:
-- A, B : Integer
-- A : Integer; B : Integer
-- which are represented identically in the tree except
-- for the setting of the flags More_Ids and Prev_Ids.
if More_Ids (Old_Param) /= More_Ids (New_Param)
or else Prev_Ids (Old_Param) /= Prev_Ids (New_Param)
then
Conformance_Error
("\grouping of & does not match!", New_Formal);
return;
end if;
end;
end if;
-- This label is required when skipping controlling formals
<<Skip_Controlling_Formal>>
Next_Formal (Old_Formal);
Next_Formal (New_Formal);
end loop;
if Present (Old_Formal) then
Conformance_Error ("\too few parameters!");
return;
elsif Present (New_Formal) then
Conformance_Error ("\too many parameters!", New_Formal);
return;
end if;
end Check_Conformance;
-----------------------
-- Check_Conventions --
-----------------------
procedure Check_Conventions (Typ : Entity_Id) is
Ifaces_List : Elist_Id;
procedure Check_Convention (Op : Entity_Id);
-- Verify that the convention of inherited dispatching operation Op is
-- consistent among all subprograms it overrides. In order to minimize
-- the search, Search_From is utilized to designate a specific point in
-- the list rather than iterating over the whole list once more.
----------------------
-- Check_Convention --
----------------------
procedure Check_Convention (Op : Entity_Id) is
Op_Conv : constant Convention_Id := Convention (Op);
Iface_Conv : Convention_Id;
Iface_Elmt : Elmt_Id;
Iface_Prim_Elmt : Elmt_Id;
Iface_Prim : Entity_Id;
begin
Iface_Elmt := First_Elmt (Ifaces_List);
while Present (Iface_Elmt) loop
Iface_Prim_Elmt :=
First_Elmt (Primitive_Operations (Node (Iface_Elmt)));
while Present (Iface_Prim_Elmt) loop
Iface_Prim := Node (Iface_Prim_Elmt);
Iface_Conv := Convention (Iface_Prim);
if Is_Interface_Conformant (Typ, Iface_Prim, Op)
and then Iface_Conv /= Op_Conv
then
Error_Msg_N
("inconsistent conventions in primitive operations", Typ);
Error_Msg_Name_1 := Chars (Op);
Error_Msg_Name_2 := Get_Convention_Name (Op_Conv);
Error_Msg_Sloc := Sloc (Op);
if Comes_From_Source (Op) or else No (Alias (Op)) then
if not Present (Overridden_Operation (Op)) then
Error_Msg_N ("\\primitive % defined #", Typ);
else
Error_Msg_N
("\\overriding operation % with "
& "convention % defined #", Typ);
end if;
else pragma Assert (Present (Alias (Op)));
Error_Msg_Sloc := Sloc (Alias (Op));
Error_Msg_N ("\\inherited operation % with "
& "convention % defined #", Typ);
end if;
Error_Msg_Name_1 := Chars (Op);
Error_Msg_Name_2 := Get_Convention_Name (Iface_Conv);
Error_Msg_Sloc := Sloc (Iface_Prim);
Error_Msg_N ("\\overridden operation % with "
& "convention % defined #", Typ);
-- Avoid cascading errors
return;
end if;
Next_Elmt (Iface_Prim_Elmt);
end loop;
Next_Elmt (Iface_Elmt);
end loop;
end Check_Convention;
-- Local variables
Prim_Op : Entity_Id;
Prim_Op_Elmt : Elmt_Id;
-- Start of processing for Check_Conventions
begin
if not Has_Interfaces (Typ) then
return;
end if;
Collect_Interfaces (Typ, Ifaces_List);
-- The algorithm checks every overriding dispatching operation against
-- all the corresponding overridden dispatching operations, detecting
-- differences in conventions.
Prim_Op_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Op_Elmt) loop
Prim_Op := Node (Prim_Op_Elmt);
-- A small optimization: skip the predefined dispatching operations
-- since they always have the same convention.
if not Is_Predefined_Dispatching_Operation (Prim_Op) then
Check_Convention (Prim_Op);
end if;
Next_Elmt (Prim_Op_Elmt);
end loop;
end Check_Conventions;
------------------------------
-- Check_Delayed_Subprogram --
------------------------------
procedure Check_Delayed_Subprogram (Designator : Entity_Id) is
procedure Possible_Freeze (T : Entity_Id);
-- T is the type of either a formal parameter or of the return type. If
-- T is not yet frozen and needs a delayed freeze, then the subprogram
-- itself must be delayed.
---------------------
-- Possible_Freeze --
---------------------
procedure Possible_Freeze (T : Entity_Id) is
Scop : constant Entity_Id := Scope (Designator);
begin
-- If the subprogram appears within a package instance (which may be
-- the wrapper package of a subprogram instance) the freeze node for
-- that package will freeze the subprogram at the proper place, so
-- do not emit a freeze node for the subprogram, given that it may
-- appear in the wrong scope.
if Ekind (Scop) = E_Package
and then not Comes_From_Source (Scop)
and then Is_Generic_Instance (Scop)
then
null;
elsif Has_Delayed_Freeze (T) and then not Is_Frozen (T) then
Set_Has_Delayed_Freeze (Designator);
elsif Is_Access_Type (T)
and then Has_Delayed_Freeze (Designated_Type (T))
and then not Is_Frozen (Designated_Type (T))
then
Set_Has_Delayed_Freeze (Designator);
end if;
end Possible_Freeze;
-- Local variables
F : Entity_Id;
-- Start of processing for Check_Delayed_Subprogram
begin
-- All subprograms, including abstract subprograms, may need a freeze
-- node if some formal type or the return type needs one.
Possible_Freeze (Etype (Designator));
Possible_Freeze (Base_Type (Etype (Designator))); -- needed ???
-- Need delayed freeze if any of the formal types themselves need a
-- delayed freeze and are not yet frozen.
F := First_Formal (Designator);
while Present (F) loop
Possible_Freeze (Etype (F));
Possible_Freeze (Base_Type (Etype (F))); -- needed ???
Next_Formal (F);
end loop;
-- Mark functions that return by reference. Note that it cannot be done
-- for delayed_freeze subprograms because the underlying returned type
-- may not be known yet (for private types).
if not Has_Delayed_Freeze (Designator) and then Expander_Active then
declare
Typ : constant Entity_Id := Etype (Designator);
Utyp : constant Entity_Id := Underlying_Type (Typ);
begin
if Is_Limited_View (Typ) then
Set_Returns_By_Ref (Designator);
elsif Present (Utyp) and then CW_Or_Has_Controlled_Part (Utyp) then
Set_Returns_By_Ref (Designator);
end if;
end;
end if;
end Check_Delayed_Subprogram;
------------------------------------
-- Check_Discriminant_Conformance --
------------------------------------
procedure Check_Discriminant_Conformance
(N : Node_Id;
Prev : Entity_Id;
Prev_Loc : Node_Id)
is
Old_Discr : Entity_Id := First_Discriminant (Prev);
New_Discr : Node_Id := First (Discriminant_Specifications (N));
New_Discr_Id : Entity_Id;
New_Discr_Type : Entity_Id;
procedure Conformance_Error (Msg : String; N : Node_Id);
-- Post error message for conformance error on given node. Two messages
-- are output. The first points to the previous declaration with a
-- general "no conformance" message. The second is the detailed reason,
-- supplied as Msg. The parameter N provide information for a possible
-- & insertion in the message.
-----------------------
-- Conformance_Error --
-----------------------
procedure Conformance_Error (Msg : String; N : Node_Id) is
begin
Error_Msg_Sloc := Sloc (Prev_Loc);
Error_Msg_N -- CODEFIX
("not fully conformant with declaration#!", N);
Error_Msg_NE (Msg, N, N);
end Conformance_Error;
-- Start of processing for Check_Discriminant_Conformance
begin
while Present (Old_Discr) and then Present (New_Discr) loop
New_Discr_Id := Defining_Identifier (New_Discr);
-- The subtype mark of the discriminant on the full type has not
-- been analyzed so we do it here. For an access discriminant a new
-- type is created.
if Nkind (Discriminant_Type (New_Discr)) = N_Access_Definition then
New_Discr_Type :=
Access_Definition (N, Discriminant_Type (New_Discr));
else
Find_Type (Discriminant_Type (New_Discr));
New_Discr_Type := Etype (Discriminant_Type (New_Discr));
-- Ada 2005: if the discriminant definition carries a null
-- exclusion, create an itype to check properly for consistency
-- with partial declaration.
if Is_Access_Type (New_Discr_Type)
and then Null_Exclusion_Present (New_Discr)
then
New_Discr_Type :=
Create_Null_Excluding_Itype
(T => New_Discr_Type,
Related_Nod => New_Discr,
Scope_Id => Current_Scope);
end if;
end if;
if not Conforming_Types
(Etype (Old_Discr), New_Discr_Type, Fully_Conformant)
then
Conformance_Error ("type of & does not match!", New_Discr_Id);
return;
else
-- Treat the new discriminant as an occurrence of the old one,
-- for navigation purposes, and fill in some semantic
-- information, for completeness.
Generate_Reference (Old_Discr, New_Discr_Id, 'r');
Set_Etype (New_Discr_Id, Etype (Old_Discr));
Set_Scope (New_Discr_Id, Scope (Old_Discr));
end if;
-- Names must match
if Chars (Old_Discr) /= Chars (Defining_Identifier (New_Discr)) then
Conformance_Error ("name & does not match!", New_Discr_Id);
return;
end if;
-- Default expressions must match
declare
NewD : constant Boolean :=
Present (Expression (New_Discr));
OldD : constant Boolean :=
Present (Expression (Parent (Old_Discr)));
begin
if NewD or OldD then
-- The old default value has been analyzed and expanded,
-- because the current full declaration will have frozen
-- everything before. The new default values have not been
-- expanded, so expand now to check conformance.
if NewD then
Preanalyze_Spec_Expression
(Expression (New_Discr), New_Discr_Type);
end if;
if not (NewD and OldD)
or else not Fully_Conformant_Expressions
(Expression (Parent (Old_Discr)),
Expression (New_Discr))
then
Conformance_Error
("default expression for & does not match!",
New_Discr_Id);
return;
end if;
end if;
end;
-- In Ada 83 case, grouping must match: (A,B : X) /= (A : X; B : X)
if Ada_Version = Ada_83 then
declare
Old_Disc : constant Node_Id := Declaration_Node (Old_Discr);
begin
-- Grouping (use of comma in param lists) must be the same
-- This is where we catch a misconformance like:
-- A, B : Integer
-- A : Integer; B : Integer
-- which are represented identically in the tree except
-- for the setting of the flags More_Ids and Prev_Ids.
if More_Ids (Old_Disc) /= More_Ids (New_Discr)
or else Prev_Ids (Old_Disc) /= Prev_Ids (New_Discr)
then
Conformance_Error
("grouping of & does not match!", New_Discr_Id);
return;
end if;
end;
end if;
Next_Discriminant (Old_Discr);
Next (New_Discr);
end loop;
if Present (Old_Discr) then
Conformance_Error ("too few discriminants!", Defining_Identifier (N));
return;
elsif Present (New_Discr) then
Conformance_Error
("too many discriminants!", Defining_Identifier (New_Discr));
return;
end if;
end Check_Discriminant_Conformance;
-----------------------------------------
-- Check_Formal_Subprogram_Conformance --
-----------------------------------------
procedure Check_Formal_Subprogram_Conformance
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id;
Errmsg : Boolean;
Conforms : out Boolean)
is
N : Node_Id;
begin
Conforms := True;
if Is_Formal_Subprogram (Old_Id)
or else Is_Formal_Subprogram (New_Id)
or else (Is_Subprogram (New_Id)
and then Present (Alias (New_Id))
and then Is_Formal_Subprogram (Alias (New_Id)))
then
if Present (Err_Loc) then
N := Err_Loc;
else
N := New_Id;
end if;
Conforms := False;
if Errmsg then
Error_Msg_Sloc := Sloc (Old_Id);
Error_Msg_N ("not subtype conformant with declaration#!", N);
Error_Msg_NE
("\formal subprograms are not subtype conformant "
& "(RM 6.3.1 (17/3))", N, New_Id);
end if;
end if;
end Check_Formal_Subprogram_Conformance;
procedure Check_Formal_Subprogram_Conformance
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty)
is
Ignore : Boolean;
begin
Check_Formal_Subprogram_Conformance
(New_Id, Old_Id, Err_Loc, True, Ignore);
end Check_Formal_Subprogram_Conformance;
----------------------------
-- Check_Fully_Conformant --
----------------------------
procedure Check_Fully_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty)
is
Result : Boolean;
pragma Warnings (Off, Result);
begin
Check_Conformance
(New_Id, Old_Id, Fully_Conformant, True, Result, Err_Loc);
end Check_Fully_Conformant;
--------------------------
-- Check_Limited_Return --
--------------------------
procedure Check_Limited_Return
(N : Node_Id;
Expr : Node_Id;
R_Type : Entity_Id)
is
begin
-- Ada 2005 (AI-318-02): Return-by-reference types have been removed and
-- replaced by anonymous access results. This is an incompatibility with
-- Ada 95. Not clear whether this should be enforced yet or perhaps
-- controllable with special switch. ???
-- A limited interface that is not immutably limited is OK
if Is_Limited_Interface (R_Type)
and then
not (Is_Task_Interface (R_Type)
or else Is_Protected_Interface (R_Type)
or else Is_Synchronized_Interface (R_Type))
then
null;
elsif Is_Limited_Type (R_Type)
and then not Is_Interface (R_Type)
and then Comes_From_Source (N)
and then not In_Instance_Body
and then not OK_For_Limited_Init_In_05 (R_Type, Expr)
then
-- Error in Ada 2005
if Ada_Version >= Ada_2005
and then not Debug_Flag_Dot_L
and then not GNAT_Mode
then
Error_Msg_N
("(Ada 2005) cannot copy object of a limited type "
& "(RM-2005 6.5(5.5/2))", Expr);
if Is_Limited_View (R_Type) then
Error_Msg_N
("\return by reference not permitted in Ada 2005", Expr);
end if;
-- Warn in Ada 95 mode, to give folks a heads up about this
-- incompatibility.
-- In GNAT mode, this is just a warning, to allow it to be evilly
-- turned off. Otherwise it is a real error.
-- In a generic context, simplify the warning because it makes no
-- sense to discuss pass-by-reference or copy.
elsif Warn_On_Ada_2005_Compatibility or GNAT_Mode then
if Inside_A_Generic then
Error_Msg_N
("return of limited object not permitted in Ada 2005 "
& "(RM-2005 6.5(5.5/2))?y?", Expr);
elsif Is_Limited_View (R_Type) then
Error_Msg_N
("return by reference not permitted in Ada 2005 "
& "(RM-2005 6.5(5.5/2))?y?", Expr);
else
Error_Msg_N
("cannot copy object of a limited type in Ada 2005 "
& "(RM-2005 6.5(5.5/2))?y?", Expr);
end if;
-- Ada 95 mode, and compatibility warnings disabled
else
pragma Assert (Ada_Version <= Ada_95);
pragma Assert (not (Warn_On_Ada_2005_Compatibility or GNAT_Mode));
return; -- skip continuation messages below
end if;
if not Inside_A_Generic then
Error_Msg_N
("\consider switching to return of access type", Expr);
Explain_Limited_Type (R_Type, Expr);
end if;
end if;
end Check_Limited_Return;
---------------------------
-- Check_Mode_Conformant --
---------------------------
procedure Check_Mode_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty;
Get_Inst : Boolean := False)
is
Result : Boolean;
pragma Warnings (Off, Result);
begin
Check_Conformance
(New_Id, Old_Id, Mode_Conformant, True, Result, Err_Loc, Get_Inst);
end Check_Mode_Conformant;
--------------------------------
-- Check_Overriding_Indicator --
--------------------------------
procedure Check_Overriding_Indicator
(Subp : Entity_Id;
Overridden_Subp : Entity_Id;
Is_Primitive : Boolean)
is
Decl : Node_Id;
Spec : Node_Id;
begin
-- No overriding indicator for literals
if Ekind (Subp) = E_Enumeration_Literal then
return;
elsif Ekind (Subp) = E_Entry then
Decl := Parent (Subp);
-- No point in analyzing a malformed operator
elsif Nkind (Subp) = N_Defining_Operator_Symbol
and then Error_Posted (Subp)
then
return;
else
Decl := Unit_Declaration_Node (Subp);
end if;
if Nkind (Decl) in N_Subprogram_Body
| N_Subprogram_Body_Stub
| N_Subprogram_Declaration
| N_Abstract_Subprogram_Declaration
| N_Subprogram_Renaming_Declaration
then
Spec := Specification (Decl);
elsif Nkind (Decl) = N_Entry_Declaration then
Spec := Decl;
else
return;
end if;
-- An overriding indication is illegal on a subprogram declared
-- in a protected body, where there is no operation to override.
if (Must_Override (Spec) or else Must_Not_Override (Spec))
and then Is_List_Member (Decl)
and then Present (Parent (List_Containing (Decl)))
and then Nkind (Parent (List_Containing (Decl))) = N_Protected_Body
then
Error_Msg_N
("illegal overriding indication in protected body", Decl);
return;
end if;
-- The overriding operation is type conformant with the overridden one,
-- but the names of the formals are not required to match. If the names
-- appear permuted in the overriding operation, this is a possible
-- source of confusion that is worth diagnosing. Controlling formals
-- often carry names that reflect the type, and it is not worthwhile
-- requiring that their names match.
if Present (Overridden_Subp)
and then Nkind (Subp) /= N_Defining_Operator_Symbol
then
declare
Form1 : Entity_Id;
Form2 : Entity_Id;
begin
Form1 := First_Formal (Subp);
Form2 := First_Formal (Overridden_Subp);
-- If the overriding operation is a synchronized operation, skip
-- the first parameter of the overridden operation, which is
-- implicit in the new one. If the operation is declared in the
-- body it is not primitive and all formals must match.
if Is_Concurrent_Type (Scope (Subp))
and then Is_Tagged_Type (Scope (Subp))
and then not Has_Completion (Scope (Subp))
then
Form2 := Next_Formal (Form2);
end if;
if Present (Form1) then
Form1 := Next_Formal (Form1);
Form2 := Next_Formal (Form2);
end if;
while Present (Form1) loop
if not Is_Controlling_Formal (Form1)
and then Present (Next_Formal (Form2))
and then Chars (Form1) = Chars (Next_Formal (Form2))
then
Error_Msg_Node_2 := Alias (Overridden_Subp);
Error_Msg_Sloc := Sloc (Error_Msg_Node_2);
Error_Msg_NE
("& does not match corresponding formal of&#",
Form1, Form1);
exit;
end if;
Next_Formal (Form1);
Next_Formal (Form2);
end loop;
end;
end if;
-- If there is an overridden subprogram, then check that there is no
-- "not overriding" indicator, and mark the subprogram as overriding.
-- This is not done if the overridden subprogram is marked as hidden,
-- which can occur for the case of inherited controlled operations
-- (see Derive_Subprogram), unless the inherited subprogram's parent
-- subprogram is not itself hidden or we are within a generic instance,
-- in which case the hidden flag may have been modified for the
-- expansion of the instance.
-- (Note: This condition could probably be simplified, leaving out the
-- testing for the specific controlled cases, but it seems safer and
-- clearer this way, and echoes similar special-case tests of this
-- kind in other places.)
if Present (Overridden_Subp)
and then (not Is_Hidden (Overridden_Subp)
or else
(Chars (Overridden_Subp) in Name_Initialize
| Name_Adjust
| Name_Finalize
and then Present (Alias (Overridden_Subp))
and then (not Is_Hidden (Alias (Overridden_Subp))
or else In_Instance)))
then
if Must_Not_Override (Spec) then
Error_Msg_Sloc := Sloc (Overridden_Subp);
if Ekind (Subp) = E_Entry then
Error_Msg_NE
("entry & overrides inherited operation #", Spec, Subp);
else
Error_Msg_NE
("subprogram & overrides inherited operation #", Spec, Subp);
end if;
-- Special-case to fix a GNAT oddity: Limited_Controlled is declared
-- as an extension of Root_Controlled, and thus has a useless Adjust
-- operation. This operation should not be inherited by other limited
-- controlled types. An explicit Adjust for them is not overriding.
elsif Must_Override (Spec)
and then Chars (Overridden_Subp) = Name_Adjust
and then Is_Limited_Type (Etype (First_Formal (Subp)))
and then Present (Alias (Overridden_Subp))
and then In_Predefined_Unit (Alias (Overridden_Subp))
then
Get_Name_String
(Unit_File_Name (Get_Source_Unit (Alias (Overridden_Subp))));
Error_Msg_NE ("subprogram & is not overriding", Spec, Subp);
elsif Is_Subprogram (Subp) then
if Is_Init_Proc (Subp) then
null;
elsif No (Overridden_Operation (Subp)) then
-- For entities generated by Derive_Subprograms the overridden
-- operation is the inherited primitive (which is available
-- through the attribute alias)
if (Is_Dispatching_Operation (Subp)
or else Is_Dispatching_Operation (Overridden_Subp))
and then not Comes_From_Source (Overridden_Subp)
and then Find_Dispatching_Type (Overridden_Subp) =
Find_Dispatching_Type (Subp)
and then Present (Alias (Overridden_Subp))
and then Comes_From_Source (Alias (Overridden_Subp))
then
Set_Overridden_Operation (Subp, Alias (Overridden_Subp));
Inherit_Subprogram_Contract (Subp, Alias (Overridden_Subp));
else
Set_Overridden_Operation (Subp, Overridden_Subp);
Inherit_Subprogram_Contract (Subp, Overridden_Subp);
end if;
end if;
end if;
-- If primitive flag is set or this is a protected operation, then
-- the operation is overriding at the point of its declaration, so
-- warn if necessary. Otherwise it may have been declared before the
-- operation it overrides and no check is required.
if Style_Check
and then not Must_Override (Spec)
and then (Is_Primitive
or else Ekind (Scope (Subp)) = E_Protected_Type)
then
Style.Missing_Overriding (Decl, Subp);
end if;
-- If Subp is an operator, it may override a predefined operation, if
-- it is defined in the same scope as the type to which it applies.
-- In that case Overridden_Subp is empty because of our implicit
-- representation for predefined operators. We have to check whether the
-- signature of Subp matches that of a predefined operator. Note that
-- first argument provides the name of the operator, and the second
-- argument the signature that may match that of a standard operation.
-- If the indicator is overriding, then the operator must match a
-- predefined signature, because we know already that there is no
-- explicit overridden operation.
elsif Nkind (Subp) = N_Defining_Operator_Symbol then
if Must_Not_Override (Spec) then
-- If this is not a primitive or a protected subprogram, then
-- "not overriding" is illegal.
if not Is_Primitive
and then Ekind (Scope (Subp)) /= E_Protected_Type
then
Error_Msg_N ("overriding indicator only allowed "
& "if subprogram is primitive", Subp);
elsif Can_Override_Operator (Subp) then
Error_Msg_NE
("subprogram& overrides predefined operator ", Spec, Subp);
end if;
elsif Must_Override (Spec) then
if No (Overridden_Operation (Subp))
and then not Can_Override_Operator (Subp)
then
Error_Msg_NE ("subprogram & is not overriding", Spec, Subp);
end if;
elsif not Error_Posted (Subp)
and then Style_Check
and then Can_Override_Operator (Subp)
and then not In_Predefined_Unit (Subp)
then
-- If style checks are enabled, indicate that the indicator is
-- missing. However, at the point of declaration, the type of
-- which this is a primitive operation may be private, in which
-- case the indicator would be premature.
if Has_Private_Declaration (Etype (Subp))
or else Has_Private_Declaration (Etype (First_Formal (Subp)))
then
null;
else
Style.Missing_Overriding (Decl, Subp);
end if;
end if;
elsif Must_Override (Spec) then
if Ekind (Subp) = E_Entry then
Error_Msg_NE ("entry & is not overriding", Spec, Subp);
else
Error_Msg_NE ("subprogram & is not overriding", Spec, Subp);
end if;
-- If the operation is marked "not overriding" and it's not primitive
-- then an error is issued, unless this is an operation of a task or
-- protected type (RM05-8.3.1(3/2-4/2)). Error cases where "overriding"
-- has been specified have already been checked above.
elsif Must_Not_Override (Spec)
and then not Is_Primitive
and then Ekind (Subp) /= E_Entry
and then Ekind (Scope (Subp)) /= E_Protected_Type
then
Error_Msg_N
("overriding indicator only allowed if subprogram is primitive",
Subp);
return;
end if;
end Check_Overriding_Indicator;
-------------------
-- Check_Returns --
-------------------
-- Note: this procedure needs to know far too much about how the expander
-- messes with exceptions. The use of the flag Exception_Junk and the
-- incorporation of knowledge of Exp_Ch11.Expand_Local_Exception_Handlers
-- works, but is not very clean. It would be better if the expansion
-- routines would leave Original_Node working nicely, and we could use
-- Original_Node here to ignore all the peculiar expander messing ???
procedure Check_Returns
(HSS : Node_Id;
Mode : Character;
Err : out Boolean;
Proc : Entity_Id := Empty)
is
Handler : Node_Id;
procedure Check_Statement_Sequence (L : List_Id);
-- Internal recursive procedure to check a list of statements for proper
-- termination by a return statement (or a transfer of control or a
-- compound statement that is itself internally properly terminated).
------------------------------
-- Check_Statement_Sequence --
------------------------------
procedure Check_Statement_Sequence (L : List_Id) is
Last_Stm : Node_Id;
Stm : Node_Id;
Kind : Node_Kind;
function Assert_False return Boolean;
-- Returns True if Last_Stm is a pragma Assert (False) that has been
-- rewritten as a null statement when assertions are off. The assert
-- is not active, but it is still enough to kill the warning.
------------------
-- Assert_False --
------------------
function Assert_False return Boolean is
Orig : constant Node_Id := Original_Node (Last_Stm);
begin
if Nkind (Orig) = N_Pragma
and then Pragma_Name (Orig) = Name_Assert
and then not Error_Posted (Orig)
then
declare
Arg : constant Node_Id :=
First (Pragma_Argument_Associations (Orig));
Exp : constant Node_Id := Expression (Arg);
begin
return Nkind (Exp) = N_Identifier
and then Chars (Exp) = Name_False;
end;
else
return False;
end if;
end Assert_False;
-- Local variables
Raise_Exception_Call : Boolean;
-- Set True if statement sequence terminated by Raise_Exception call
-- or a Reraise_Occurrence call.
-- Start of processing for Check_Statement_Sequence
begin
Raise_Exception_Call := False;
-- Get last real statement
Last_Stm := Last (L);
-- Deal with digging out exception handler statement sequences that
-- have been transformed by the local raise to goto optimization.
-- See Exp_Ch11.Expand_Local_Exception_Handlers for details. If this
-- optimization has occurred, we are looking at something like:
-- begin
-- original stmts in block
-- exception \
-- when excep1 => |
-- goto L1; | omitted if No_Exception_Propagation
-- when excep2 => |
-- goto L2; /
-- end;
-- goto L3; -- skip handler when exception not raised
-- <<L1>> -- target label for local exception
-- begin
-- estmts1
-- end;
-- goto L3;
-- <<L2>>
-- begin
-- estmts2
-- end;
-- <<L3>>
-- and what we have to do is to dig out the estmts1 and estmts2
-- sequences (which were the original sequences of statements in
-- the exception handlers) and check them.
if Nkind (Last_Stm) = N_Label and then Exception_Junk (Last_Stm) then
Stm := Last_Stm;
loop
Prev (Stm);
exit when No (Stm);
exit when Nkind (Stm) /= N_Block_Statement;
exit when not Exception_Junk (Stm);
Prev (Stm);
exit when No (Stm);
exit when Nkind (Stm) /= N_Label;
exit when not Exception_Junk (Stm);
Check_Statement_Sequence
(Statements (Handled_Statement_Sequence (Next (Stm))));
Prev (Stm);
Last_Stm := Stm;
exit when No (Stm);
exit when Nkind (Stm) /= N_Goto_Statement;
exit when not Exception_Junk (Stm);
end loop;
end if;
-- Don't count pragmas
while Nkind (Last_Stm) = N_Pragma
-- Don't count call to SS_Release (can happen after Raise_Exception)
or else
(Nkind (Last_Stm) = N_Procedure_Call_Statement
and then
Nkind (Name (Last_Stm)) = N_Identifier
and then
Is_RTE (Entity (Name (Last_Stm)), RE_SS_Release))
-- Don't count exception junk
or else
(Nkind (Last_Stm) in
N_Goto_Statement | N_Label | N_Object_Declaration
and then Exception_Junk (Last_Stm))
or else Nkind (Last_Stm) in N_Push_xxx_Label | N_Pop_xxx_Label
-- Inserted code, such as finalization calls, is irrelevant: we only
-- need to check original source.
or else Is_Rewrite_Insertion (Last_Stm)
loop
Prev (Last_Stm);
end loop;
-- Here we have the "real" last statement
Kind := Nkind (Last_Stm);
-- Transfer of control, OK. Note that in the No_Return procedure
-- case, we already diagnosed any explicit return statements, so
-- we can treat them as OK in this context.
if Is_Transfer (Last_Stm) then
return;
-- Check cases of explicit non-indirect procedure calls
elsif Kind = N_Procedure_Call_Statement
and then Is_Entity_Name (Name (Last_Stm))
then
-- Check call to Raise_Exception procedure which is treated
-- specially, as is a call to Reraise_Occurrence.
-- We suppress the warning in these cases since it is likely that
-- the programmer really does not expect to deal with the case
-- of Null_Occurrence, and thus would find a warning about a
-- missing return curious, and raising Program_Error does not
-- seem such a bad behavior if this does occur.
-- Note that in the Ada 2005 case for Raise_Exception, the actual
-- behavior will be to raise Constraint_Error (see AI-329).
if Is_RTE (Entity (Name (Last_Stm)), RE_Raise_Exception)
or else
Is_RTE (Entity (Name (Last_Stm)), RE_Reraise_Occurrence)
then
Raise_Exception_Call := True;
-- For Raise_Exception call, test first argument, if it is
-- an attribute reference for a 'Identity call, then we know
-- that the call cannot possibly return.
declare
Arg : constant Node_Id :=
Original_Node (First_Actual (Last_Stm));
begin
if Nkind (Arg) = N_Attribute_Reference
and then Attribute_Name (Arg) = Name_Identity
then
return;
end if;
end;
end if;
-- If statement, need to look inside if there is an else and check
-- each constituent statement sequence for proper termination.
elsif Kind = N_If_Statement
and then Present (Else_Statements (Last_Stm))
then
Check_Statement_Sequence (Then_Statements (Last_Stm));
Check_Statement_Sequence (Else_Statements (Last_Stm));
if Present (Elsif_Parts (Last_Stm)) then
declare
Elsif_Part : Node_Id := First (Elsif_Parts (Last_Stm));
begin
while Present (Elsif_Part) loop
Check_Statement_Sequence (Then_Statements (Elsif_Part));
Next (Elsif_Part);
end loop;
end;
end if;
return;
-- Case statement, check each case for proper termination
elsif Kind = N_Case_Statement then
declare
Case_Alt : Node_Id;
begin
Case_Alt := First_Non_Pragma (Alternatives (Last_Stm));
while Present (Case_Alt) loop
Check_Statement_Sequence (Statements (Case_Alt));
Next_Non_Pragma (Case_Alt);
end loop;
end;
return;
-- Block statement, check its handled sequence of statements
elsif Kind = N_Block_Statement then
declare
Err1 : Boolean;
begin
Check_Returns
(Handled_Statement_Sequence (Last_Stm), Mode, Err1);
if Err1 then
Err := True;
end if;
return;
end;
-- Loop statement. If there is an iteration scheme, we can definitely
-- fall out of the loop. Similarly if there is an exit statement, we
-- can fall out. In either case we need a following return.
elsif Kind = N_Loop_Statement then
if Present (Iteration_Scheme (Last_Stm))
or else Has_Exit (Entity (Identifier (Last_Stm)))
then
null;
-- A loop with no exit statement or iteration scheme is either
-- an infinite loop, or it has some other exit (raise/return).
-- In either case, no warning is required.
else
return;
end if;
-- Timed entry call, check entry call and delay alternatives
-- Note: in expanded code, the timed entry call has been converted
-- to a set of expanded statements on which the check will work
-- correctly in any case.
elsif Kind = N_Timed_Entry_Call then
declare
ECA : constant Node_Id := Entry_Call_Alternative (Last_Stm);
DCA : constant Node_Id := Delay_Alternative (Last_Stm);
begin
-- If statement sequence of entry call alternative is missing,
-- then we can definitely fall through, and we post the error
-- message on the entry call alternative itself.
if No (Statements (ECA)) then
Last_Stm := ECA;
-- If statement sequence of delay alternative is missing, then
-- we can definitely fall through, and we post the error
-- message on the delay alternative itself.
-- Note: if both ECA and DCA are missing the return, then we
-- post only one message, should be enough to fix the bugs.
-- If not we will get a message next time on the DCA when the
-- ECA is fixed.
elsif No (Statements (DCA)) then
Last_Stm := DCA;
-- Else check both statement sequences
else
Check_Statement_Sequence (Statements (ECA));
Check_Statement_Sequence (Statements (DCA));
return;
end if;
end;
-- Conditional entry call, check entry call and else part
-- Note: in expanded code, the conditional entry call has been
-- converted to a set of expanded statements on which the check
-- will work correctly in any case.
elsif Kind = N_Conditional_Entry_Call then
declare
ECA : constant Node_Id := Entry_Call_Alternative (Last_Stm);
begin
-- If statement sequence of entry call alternative is missing,
-- then we can definitely fall through, and we post the error
-- message on the entry call alternative itself.
if No (Statements (ECA)) then
Last_Stm := ECA;
-- Else check statement sequence and else part
else
Check_Statement_Sequence (Statements (ECA));
Check_Statement_Sequence (Else_Statements (Last_Stm));
return;
end if;
end;
end if;
-- If we fall through, issue appropriate message
if Mode = 'F' then
-- Kill warning if last statement is a raise exception call,
-- or a pragma Assert (False). Note that with assertions enabled,
-- such a pragma has been converted into a raise exception call
-- already, so the Assert_False is for the assertions off case.
if not Raise_Exception_Call and then not Assert_False then
-- In GNATprove mode, it is an error to have a missing return
Error_Msg_Warn := SPARK_Mode /= On;
-- Issue error message or warning
Error_Msg_N
("RETURN statement missing following this statement<<!",
Last_Stm);
Error_Msg_N
("\Program_Error ]<<!", Last_Stm);
end if;
-- Note: we set Err even though we have not issued a warning
-- because we still have a case of a missing return. This is
-- an extremely marginal case, probably will never be noticed
-- but we might as well get it right.
Err := True;
-- Otherwise we have the case of a procedure marked No_Return
else
if not Raise_Exception_Call then
if GNATprove_Mode then
Error_Msg_N
("implied return after this statement would have raised "
& "Program_Error", Last_Stm);
-- In normal compilation mode, do not warn on a generated call
-- (e.g. in the body of a renaming as completion).
elsif Comes_From_Source (Last_Stm) then
Error_Msg_N
("implied return after this statement will raise "
& "Program_Error??", Last_Stm);
end if;
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_NE
("\procedure & is marked as No_Return<<!", Last_Stm, Proc);
end if;
declare
RE : constant Node_Id :=
Make_Raise_Program_Error (Sloc (Last_Stm),
Reason => PE_Implicit_Return);
begin
Insert_After (Last_Stm, RE);
Analyze (RE);
end;
end if;
end Check_Statement_Sequence;
-- Start of processing for Check_Returns
begin
Err := False;
Check_Statement_Sequence (Statements (HSS));
if Present (Exception_Handlers (HSS)) then
Handler := First_Non_Pragma (Exception_Handlers (HSS));
while Present (Handler) loop
Check_Statement_Sequence (Statements (Handler));
Next_Non_Pragma (Handler);
end loop;
end if;
end Check_Returns;
----------------------------
-- Check_Subprogram_Order --
----------------------------
procedure Check_Subprogram_Order (N : Node_Id) is
function Subprogram_Name_Greater (S1, S2 : String) return Boolean;
-- This is used to check if S1 > S2 in the sense required by this test,
-- for example nameab < namec, but name2 < name10.
-----------------------------
-- Subprogram_Name_Greater --
-----------------------------
function Subprogram_Name_Greater (S1, S2 : String) return Boolean is
L1, L2 : Positive;
N1, N2 : Natural;
begin
-- Deal with special case where names are identical except for a
-- numerical suffix. These are handled specially, taking the numeric
-- ordering from the suffix into account.
L1 := S1'Last;
while S1 (L1) in '0' .. '9' loop
L1 := L1 - 1;
end loop;
L2 := S2'Last;
while S2 (L2) in '0' .. '9' loop
L2 := L2 - 1;
end loop;
-- If non-numeric parts non-equal, do straight compare
if S1 (S1'First .. L1) /= S2 (S2'First .. L2) then
return S1 > S2;
-- If non-numeric parts equal, compare suffixed numeric parts. Note
-- that a missing suffix is treated as numeric zero in this test.
else
N1 := 0;
while L1 < S1'Last loop
L1 := L1 + 1;
N1 := N1 * 10 + Character'Pos (S1 (L1)) - Character'Pos ('0');
end loop;
N2 := 0;
while L2 < S2'Last loop
L2 := L2 + 1;
N2 := N2 * 10 + Character'Pos (S2 (L2)) - Character'Pos ('0');
end loop;
return N1 > N2;
end if;
end Subprogram_Name_Greater;
-- Start of processing for Check_Subprogram_Order
begin
-- Check body in alpha order if this is option
if Style_Check
and then Style_Check_Order_Subprograms
and then Nkind (N) = N_Subprogram_Body
and then Comes_From_Source (N)
and then In_Extended_Main_Source_Unit (N)
then
declare
LSN : String_Ptr
renames Scope_Stack.Table
(Scope_Stack.Last).Last_Subprogram_Name;
Body_Id : constant Entity_Id :=
Defining_Entity (Specification (N));
begin
Get_Decoded_Name_String (Chars (Body_Id));
if LSN /= null then
if Subprogram_Name_Greater
(LSN.all, Name_Buffer (1 .. Name_Len))
then
Style.Subprogram_Not_In_Alpha_Order (Body_Id);
end if;
Free (LSN);
end if;
LSN := new String'(Name_Buffer (1 .. Name_Len));
end;
end if;
end Check_Subprogram_Order;
------------------------------
-- Check_Subtype_Conformant --
------------------------------
procedure Check_Subtype_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty;
Skip_Controlling_Formals : Boolean := False;
Get_Inst : Boolean := False)
is
Result : Boolean;
pragma Warnings (Off, Result);
begin
Check_Conformance
(New_Id, Old_Id, Subtype_Conformant, True, Result, Err_Loc,
Skip_Controlling_Formals => Skip_Controlling_Formals,
Get_Inst => Get_Inst);
end Check_Subtype_Conformant;
-----------------------------------
-- Check_Synchronized_Overriding --
-----------------------------------
procedure Check_Synchronized_Overriding
(Def_Id : Entity_Id;
Overridden_Subp : out Entity_Id)
is
Ifaces_List : Elist_Id;
In_Scope : Boolean;
Typ : Entity_Id;
function Is_Valid_Formal (F : Entity_Id) return Boolean;
-- Predicate for legality rule in 9.4 (11.9/2): If an inherited
-- subprogram is implemented by a protected procedure or entry,
-- its first parameter must be out, in out, or access-to-variable.
function Matches_Prefixed_View_Profile
(Prim_Params : List_Id;
Iface_Params : List_Id) return Boolean;
-- Determine whether a subprogram's parameter profile Prim_Params
-- matches that of a potentially overridden interface subprogram
-- Iface_Params. Also determine if the type of first parameter of
-- Iface_Params is an implemented interface.
----------------------
-- Is_Valid_Formal --
----------------------
function Is_Valid_Formal (F : Entity_Id) return Boolean is
begin
return
Ekind (F) in E_In_Out_Parameter | E_Out_Parameter
or else
(Nkind (Parameter_Type (Parent (F))) = N_Access_Definition
and then not Constant_Present (Parameter_Type (Parent (F))));
end Is_Valid_Formal;
-----------------------------------
-- Matches_Prefixed_View_Profile --
-----------------------------------
function Matches_Prefixed_View_Profile
(Prim_Params : List_Id;
Iface_Params : List_Id) return Boolean
is
function Is_Implemented
(Ifaces_List : Elist_Id;
Iface : Entity_Id) return Boolean;
-- Determine if Iface is implemented by the current task or
-- protected type.
--------------------
-- Is_Implemented --
--------------------
function Is_Implemented
(Ifaces_List : Elist_Id;
Iface : Entity_Id) return Boolean
is
Iface_Elmt : Elmt_Id;
begin
Iface_Elmt := First_Elmt (Ifaces_List);
while Present (Iface_Elmt) loop
if Node (Iface_Elmt) = Iface then
return True;
end if;
Next_Elmt (Iface_Elmt);
end loop;
return False;
end Is_Implemented;
-- Local variables
Iface_Id : Entity_Id;
Iface_Param : Node_Id;
Iface_Typ : Entity_Id;
Prim_Id : Entity_Id;
Prim_Param : Node_Id;
Prim_Typ : Entity_Id;
-- Start of processing for Matches_Prefixed_View_Profile
begin
Iface_Param := First (Iface_Params);
Iface_Typ := Etype (Defining_Identifier (Iface_Param));
if Is_Access_Type (Iface_Typ) then
Iface_Typ := Designated_Type (Iface_Typ);
end if;
Prim_Param := First (Prim_Params);
-- The first parameter of the potentially overridden subprogram must
-- be an interface implemented by Prim.
if not Is_Interface (Iface_Typ)
or else not Is_Implemented (Ifaces_List, Iface_Typ)
then
return False;
end if;
-- The checks on the object parameters are done, so move on to the
-- rest of the parameters.
if not In_Scope then
Next (Prim_Param);
end if;
Next (Iface_Param);
while Present (Iface_Param) and then Present (Prim_Param) loop
Iface_Id := Defining_Identifier (Iface_Param);
Iface_Typ := Find_Parameter_Type (Iface_Param);
Prim_Id := Defining_Identifier (Prim_Param);
Prim_Typ := Find_Parameter_Type (Prim_Param);
if Ekind (Iface_Typ) = E_Anonymous_Access_Type
and then Ekind (Prim_Typ) = E_Anonymous_Access_Type
and then Is_Concurrent_Type (Designated_Type (Prim_Typ))
then
Iface_Typ := Designated_Type (Iface_Typ);
Prim_Typ := Designated_Type (Prim_Typ);
end if;
-- Case of multiple interface types inside a parameter profile
-- (Obj_Param : in out Iface; ...; Param : Iface)
-- If the interface type is implemented, then the matching type in
-- the primitive should be the implementing record type.
if Ekind (Iface_Typ) = E_Record_Type
and then Is_Interface (Iface_Typ)
and then Is_Implemented (Ifaces_List, Iface_Typ)
then
if Prim_Typ /= Typ then
return False;
end if;
-- The two parameters must be both mode and subtype conformant
elsif Ekind (Iface_Id) /= Ekind (Prim_Id)
or else not
Conforming_Types (Iface_Typ, Prim_Typ, Subtype_Conformant)
then
return False;
end if;
Next (Iface_Param);
Next (Prim_Param);
end loop;
-- One of the two lists contains more parameters than the other
if Present (Iface_Param) or else Present (Prim_Param) then
return False;
end if;
return True;
end Matches_Prefixed_View_Profile;
-- Start of processing for Check_Synchronized_Overriding
begin
Overridden_Subp := Empty;
-- Def_Id must be an entry or a subprogram. We should skip predefined
-- primitives internally generated by the front end; however at this
-- stage predefined primitives are still not fully decorated. As a
-- minor optimization we skip here internally generated subprograms.
if (Ekind (Def_Id) /= E_Entry
and then Ekind (Def_Id) /= E_Function
and then Ekind (Def_Id) /= E_Procedure)
or else not Comes_From_Source (Def_Id)
then
return;
end if;
-- Search for the concurrent declaration since it contains the list of
-- all implemented interfaces. In this case, the subprogram is declared
-- within the scope of a protected or a task type.
if Present (Scope (Def_Id))
and then Is_Concurrent_Type (Scope (Def_Id))
and then not Is_Generic_Actual_Type (Scope (Def_Id))
then
Typ := Scope (Def_Id);
In_Scope := True;
-- The enclosing scope is not a synchronized type and the subprogram
-- has no formals.
elsif No (First_Formal (Def_Id)) then
return;
-- The subprogram has formals and hence it may be a primitive of a
-- concurrent type.
else
Typ := Etype (First_Formal (Def_Id));
if Is_Access_Type (Typ) then
Typ := Directly_Designated_Type (Typ);
end if;
if Is_Concurrent_Type (Typ)
and then not Is_Generic_Actual_Type (Typ)
then
In_Scope := False;
-- This case occurs when the concurrent type is declared within a
-- generic unit. As a result the corresponding record has been built
-- and used as the type of the first formal, we just have to retrieve
-- the corresponding concurrent type.
elsif Is_Concurrent_Record_Type (Typ)
and then not Is_Class_Wide_Type (Typ)
and then Present (Corresponding_Concurrent_Type (Typ))
then
Typ := Corresponding_Concurrent_Type (Typ);
In_Scope := False;
else
return;
end if;
end if;
-- There is no overriding to check if this is an inherited operation in
-- a type derivation for a generic actual.
Collect_Interfaces (Typ, Ifaces_List);
if Is_Empty_Elmt_List (Ifaces_List) then
return;
end if;
-- Determine whether entry or subprogram Def_Id overrides a primitive
-- operation that belongs to one of the interfaces in Ifaces_List.
declare
Candidate : Entity_Id := Empty;
Hom : Entity_Id := Empty;
Subp : Entity_Id := Empty;
begin
-- Traverse the homonym chain, looking for a potentially overridden
-- subprogram that belongs to an implemented interface.
Hom := Current_Entity_In_Scope (Def_Id);
while Present (Hom) loop
Subp := Hom;
if Subp = Def_Id
or else not Is_Overloadable (Subp)
or else not Is_Primitive (Subp)
or else not Is_Dispatching_Operation (Subp)
or else not Present (Find_Dispatching_Type (Subp))
or else not Is_Interface (Find_Dispatching_Type (Subp))
then
null;
-- Entries and procedures can override abstract or null interface
-- procedures.
elsif Ekind (Def_Id) in E_Entry | E_Procedure
and then Ekind (Subp) = E_Procedure
and then Matches_Prefixed_View_Profile
(Parameter_Specifications (Parent (Def_Id)),
Parameter_Specifications (Parent (Subp)))
then
Candidate := Subp;
-- For an overridden subprogram Subp, check whether the mode
-- of its first parameter is correct depending on the kind of
-- synchronized type.
declare
Formal : constant Node_Id := First_Formal (Candidate);
begin
-- In order for an entry or a protected procedure to
-- override, the first parameter of the overridden routine
-- must be of mode "out", "in out", or access-to-variable.
if Ekind (Candidate) in E_Entry | E_Procedure
and then Is_Protected_Type (Typ)
and then not Is_Valid_Formal (Formal)
then
null;
-- All other cases are OK since a task entry or routine does
-- not have a restriction on the mode of the first parameter
-- of the overridden interface routine.
else
Overridden_Subp := Candidate;
return;
end if;
end;
-- Functions can override abstract interface functions. Return
-- types must be subtype conformant.
elsif Ekind (Def_Id) = E_Function
and then Ekind (Subp) = E_Function
and then Matches_Prefixed_View_Profile
(Parameter_Specifications (Parent (Def_Id)),
Parameter_Specifications (Parent (Subp)))
and then Conforming_Types
(Etype (Def_Id), Etype (Subp), Subtype_Conformant)
then
Candidate := Subp;
-- If an inherited subprogram is implemented by a protected
-- function, then the first parameter of the inherited
-- subprogram shall be of mode in, but not an access-to-
-- variable parameter (RM 9.4(11/9)).
if Present (First_Formal (Subp))
and then Ekind (First_Formal (Subp)) = E_In_Parameter
and then
(not Is_Access_Type (Etype (First_Formal (Subp)))
or else
Is_Access_Constant (Etype (First_Formal (Subp))))
then
Overridden_Subp := Subp;
return;
end if;
end if;
Hom := Homonym (Hom);
end loop;
-- After examining all candidates for overriding, we are left with
-- the best match, which is a mode-incompatible interface routine.
if In_Scope and then Present (Candidate) then
Error_Msg_PT (Def_Id, Candidate);
end if;
Overridden_Subp := Candidate;
return;
end;
end Check_Synchronized_Overriding;
---------------------------
-- Check_Type_Conformant --
---------------------------
procedure Check_Type_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty)
is
Result : Boolean;
pragma Warnings (Off, Result);
begin
Check_Conformance
(New_Id, Old_Id, Type_Conformant, True, Result, Err_Loc);
end Check_Type_Conformant;
---------------------------
-- Can_Override_Operator --
---------------------------
function Can_Override_Operator (Subp : Entity_Id) return Boolean is
Typ : Entity_Id;
begin
if Nkind (Subp) /= N_Defining_Operator_Symbol then
return False;
else
Typ := Base_Type (Etype (First_Formal (Subp)));
-- Check explicitly that the operation is a primitive of the type
return Operator_Matches_Spec (Subp, Subp)
and then not Is_Generic_Type (Typ)
and then Scope (Subp) = Scope (Typ)
and then not Is_Class_Wide_Type (Typ);
end if;
end Can_Override_Operator;
----------------------
-- Conforming_Types --
----------------------
function Conforming_Types
(T1 : Entity_Id;
T2 : Entity_Id;
Ctype : Conformance_Type;
Get_Inst : Boolean := False) return Boolean
is
function Base_Types_Match
(Typ_1 : Entity_Id;
Typ_2 : Entity_Id) return Boolean;
-- If neither Typ_1 nor Typ_2 are generic actual types, or if they are
-- in different scopes (e.g. parent and child instances), then verify
-- that the base types are equal. Otherwise Typ_1 and Typ_2 must be on
-- the same subtype chain. The whole purpose of this procedure is to
-- prevent spurious ambiguities in an instantiation that may arise if
-- two distinct generic types are instantiated with the same actual.
function Find_Designated_Type (Typ : Entity_Id) return Entity_Id;
-- An access parameter can designate an incomplete type. If the
-- incomplete type is the limited view of a type from a limited_
-- with_clause, check whether the non-limited view is available.
-- If it is a (non-limited) incomplete type, get the full view.
function Matches_Limited_With_View
(Typ_1 : Entity_Id;
Typ_2 : Entity_Id) return Boolean;
-- Returns True if and only if either Typ_1 denotes a limited view of
-- Typ_2 or Typ_2 denotes a limited view of Typ_1. This can arise when
-- the limited with view of a type is used in a subprogram declaration
-- and the subprogram body is in the scope of a regular with clause for
-- the same unit. In such a case, the two type entities are considered
-- identical for purposes of conformance checking.
----------------------
-- Base_Types_Match --
----------------------
function Base_Types_Match
(Typ_1 : Entity_Id;
Typ_2 : Entity_Id) return Boolean
is
Base_1 : constant Entity_Id := Base_Type (Typ_1);
Base_2 : constant Entity_Id := Base_Type (Typ_2);
begin
if Typ_1 = Typ_2 then
return True;
elsif Base_1 = Base_2 then
-- The following is too permissive. A more precise test should
-- check that the generic actual is an ancestor subtype of the
-- other ???.
-- See code in Find_Corresponding_Spec that applies an additional
-- filter to handle accidental amiguities in instances.
return
not Is_Generic_Actual_Type (Typ_1)
or else not Is_Generic_Actual_Type (Typ_2)
or else Scope (Typ_1) /= Scope (Typ_2);
-- If Typ_2 is a generic actual type it is declared as the subtype of
-- the actual. If that actual is itself a subtype we need to use its
-- own base type to check for compatibility.
elsif Ekind (Base_2) = Ekind (Typ_2)
and then Base_1 = Base_Type (Base_2)
then
return True;
elsif Ekind (Base_1) = Ekind (Typ_1)
and then Base_2 = Base_Type (Base_1)
then
return True;
else
return False;
end if;
end Base_Types_Match;
--------------------------
-- Find_Designated_Type --
--------------------------
function Find_Designated_Type (Typ : Entity_Id) return Entity_Id is
Desig : Entity_Id;
begin
Desig := Directly_Designated_Type (Typ);
if Ekind (Desig) = E_Incomplete_Type then
-- If regular incomplete type, get full view if available
if Present (Full_View (Desig)) then
Desig := Full_View (Desig);
-- If limited view of a type, get non-limited view if available,
-- and check again for a regular incomplete type.
elsif Present (Non_Limited_View (Desig)) then
Desig := Get_Full_View (Non_Limited_View (Desig));
end if;
end if;
return Desig;
end Find_Designated_Type;
-------------------------------
-- Matches_Limited_With_View --
-------------------------------
function Matches_Limited_With_View
(Typ_1 : Entity_Id;
Typ_2 : Entity_Id) return Boolean
is
function Is_Matching_Limited_View
(Typ : Entity_Id;
View : Entity_Id) return Boolean;
-- Determine whether non-limited view View denotes type Typ in some
-- conformant fashion.
------------------------------
-- Is_Matching_Limited_View --
------------------------------
function Is_Matching_Limited_View
(Typ : Entity_Id;
View : Entity_Id) return Boolean
is
Root_Typ : Entity_Id;
Root_View : Entity_Id;
begin
-- The non-limited view directly denotes the type
if Typ = View then
return True;
-- The type is a subtype of the non-limited view
elsif Is_Subtype_Of (Typ, View) then
return True;
-- Both the non-limited view and the type denote class-wide types
elsif Is_Class_Wide_Type (Typ)
and then Is_Class_Wide_Type (View)
then
Root_Typ := Root_Type (Typ);
Root_View := Root_Type (View);
if Root_Typ = Root_View then
return True;
-- An incomplete tagged type and its full view may receive two
-- distinct class-wide types when the related package has not
-- been analyzed yet.
-- package Pack is
-- type T is tagged; -- CW_1
-- type T is tagged null record; -- CW_2
-- end Pack;
-- This is because the package lacks any semantic information
-- that may eventually link both views of T. As a consequence,
-- a client of the limited view of Pack will see CW_2 while a
-- client of the non-limited view of Pack will see CW_1.
elsif Is_Incomplete_Type (Root_Typ)
and then Present (Full_View (Root_Typ))
and then Full_View (Root_Typ) = Root_View
then
return True;
elsif Is_Incomplete_Type (Root_View)
and then Present (Full_View (Root_View))
and then Full_View (Root_View) = Root_Typ
then
return True;
end if;
end if;
return False;
end Is_Matching_Limited_View;
-- Start of processing for Matches_Limited_With_View
begin
-- In some cases a type imported through a limited_with clause, and
-- its non-limited view are both visible, for example in an anonymous
-- access-to-class-wide type in a formal, or when building the body
-- for a subprogram renaming after the subprogram has been frozen.
-- In these cases both entities designate the same type. In addition,
-- if one of them is an actual in an instance, it may be a subtype of
-- the non-limited view of the other.
if From_Limited_With (Typ_1)
and then From_Limited_With (Typ_2)
and then Available_View (Typ_1) = Available_View (Typ_2)
then
return True;
elsif From_Limited_With (Typ_1) then
return Is_Matching_Limited_View (Typ_2, Available_View (Typ_1));
elsif From_Limited_With (Typ_2) then
return Is_Matching_Limited_View (Typ_1, Available_View (Typ_2));
else
return False;
end if;
end Matches_Limited_With_View;
-- Local variables
Are_Anonymous_Access_To_Subprogram_Types : Boolean := False;
Type_1 : Entity_Id := T1;
Type_2 : Entity_Id := T2;
-- Start of processing for Conforming_Types
begin
-- The context is an instance association for a formal access-to-
-- subprogram type; the formal parameter types require mapping because
-- they may denote other formal parameters of the generic unit.
if Get_Inst then
Type_1 := Get_Instance_Of (T1);
Type_2 := Get_Instance_Of (T2);
end if;
-- If one of the types is a view of the other introduced by a limited
-- with clause, treat these as conforming for all purposes.
if Matches_Limited_With_View (T1, T2) then
return True;
elsif Base_Types_Match (Type_1, Type_2) then
if Ctype <= Mode_Conformant then
return True;
else
return
Subtypes_Statically_Match (Type_1, Type_2)
and then Dimensions_Match (Type_1, Type_2);
end if;
elsif Is_Incomplete_Or_Private_Type (Type_1)
and then Present (Full_View (Type_1))
and then Base_Types_Match (Full_View (Type_1), Type_2)
then
return
Ctype <= Mode_Conformant
or else Subtypes_Statically_Match (Full_View (Type_1), Type_2);
elsif Ekind (Type_2) = E_Incomplete_Type
and then Present (Full_View (Type_2))
and then Base_Types_Match (Type_1, Full_View (Type_2))
then
return
Ctype <= Mode_Conformant
or else Subtypes_Statically_Match (Type_1, Full_View (Type_2));
elsif Is_Private_Type (Type_2)
and then In_Instance
and then Present (Full_View (Type_2))
and then Base_Types_Match (Type_1, Full_View (Type_2))
then
return
Ctype <= Mode_Conformant
or else Subtypes_Statically_Match (Type_1, Full_View (Type_2));
-- Another confusion between views in a nested instance with an
-- actual private type whose full view is not in scope.
elsif Ekind (Type_2) = E_Private_Subtype
and then In_Instance
and then Etype (Type_2) = Type_1
then
return True;
-- In Ada 2012, incomplete types (including limited views) can appear
-- as actuals in instantiations, where they are conformant to the
-- corresponding incomplete formal.
elsif Is_Incomplete_Type (Type_1)
and then Is_Incomplete_Type (Type_2)
and then In_Instance
and then (Used_As_Generic_Actual (Type_1)
or else Used_As_Generic_Actual (Type_2))
then
return True;
end if;
-- Ada 2005 (AI-254): Anonymous access-to-subprogram types must be
-- treated recursively because they carry a signature. As far as
-- conformance is concerned, convention plays no role, and either
-- or both could be access to protected subprograms.
Are_Anonymous_Access_To_Subprogram_Types :=
Ekind (Type_1) in E_Anonymous_Access_Subprogram_Type
| E_Anonymous_Access_Protected_Subprogram_Type
and then
Ekind (Type_2) in E_Anonymous_Access_Subprogram_Type
| E_Anonymous_Access_Protected_Subprogram_Type;
-- Test anonymous access type case. For this case, static subtype
-- matching is required for mode conformance (RM 6.3.1(15)). We check
-- the base types because we may have built internal subtype entities
-- to handle null-excluding types (see Process_Formals).
if (Ekind (Base_Type (Type_1)) = E_Anonymous_Access_Type
and then
Ekind (Base_Type (Type_2)) = E_Anonymous_Access_Type)
-- Ada 2005 (AI-254)
or else Are_Anonymous_Access_To_Subprogram_Types
then
declare
Desig_1 : Entity_Id;
Desig_2 : Entity_Id;
begin
-- In Ada 2005, access constant indicators must match for
-- subtype conformance.
if Ada_Version >= Ada_2005
and then Ctype >= Subtype_Conformant
and then
Is_Access_Constant (Type_1) /= Is_Access_Constant (Type_2)
then
return False;
end if;
Desig_1 := Find_Designated_Type (Type_1);
Desig_2 := Find_Designated_Type (Type_2);
-- If the context is an instance association for a formal
-- access-to-subprogram type; formal access parameter designated
-- types require mapping because they may denote other formal
-- parameters of the generic unit.
if Get_Inst then
Desig_1 := Get_Instance_Of (Desig_1);
Desig_2 := Get_Instance_Of (Desig_2);
end if;
-- It is possible for a Class_Wide_Type to be introduced for an
-- incomplete type, in which case there is a separate class_ wide
-- type for the full view. The types conform if their Etypes
-- conform, i.e. one may be the full view of the other. This can
-- only happen in the context of an access parameter, other uses
-- of an incomplete Class_Wide_Type are illegal.
if Is_Class_Wide_Type (Desig_1)
and then
Is_Class_Wide_Type (Desig_2)
then
return
Conforming_Types
(Etype (Base_Type (Desig_1)),
Etype (Base_Type (Desig_2)), Ctype);
elsif Are_Anonymous_Access_To_Subprogram_Types then
if Ada_Version < Ada_2005 then
return
Ctype = Type_Conformant
or else Subtypes_Statically_Match (Desig_1, Desig_2);
-- We must check the conformance of the signatures themselves
else
declare
Conformant : Boolean;
begin
Check_Conformance
(Desig_1, Desig_2, Ctype, False, Conformant);
return Conformant;
end;
end if;
-- A limited view of an actual matches the corresponding
-- incomplete formal.
elsif Ekind (Desig_2) = E_Incomplete_Subtype
and then From_Limited_With (Desig_2)
and then Used_As_Generic_Actual (Etype (Desig_2))
then
return True;
else
return Base_Type (Desig_1) = Base_Type (Desig_2)
and then (Ctype = Type_Conformant
or else
Subtypes_Statically_Match (Desig_1, Desig_2));
end if;
end;
-- Otherwise definitely no match
else
if ((Ekind (Type_1) = E_Anonymous_Access_Type
and then Is_Access_Type (Type_2))
or else (Ekind (Type_2) = E_Anonymous_Access_Type
and then Is_Access_Type (Type_1)))
and then
Conforming_Types
(Designated_Type (Type_1), Designated_Type (Type_2), Ctype)
then
May_Hide_Profile := True;
end if;
return False;
end if;
end Conforming_Types;
--------------------------
-- Create_Extra_Formals --
--------------------------
procedure Create_Extra_Formals (E : Entity_Id) is
First_Extra : Entity_Id := Empty;
Formal : Entity_Id;
Last_Extra : Entity_Id := Empty;
function Add_Extra_Formal
(Assoc_Entity : Entity_Id;
Typ : Entity_Id;
Scope : Entity_Id;
Suffix : String) return Entity_Id;
-- Add an extra formal to the current list of formals and extra formals.
-- The extra formal is added to the end of the list of extra formals,
-- and also returned as the result. These formals are always of mode IN.
-- The new formal has the type Typ, is declared in Scope, and its name
-- is given by a concatenation of the name of Assoc_Entity and Suffix.
-- The following suffixes are currently used. They should not be changed
-- without coordinating with CodePeer, which makes use of these to
-- provide better messages.
-- O denotes the Constrained bit.
-- L denotes the accessibility level.
-- BIP_xxx denotes an extra formal for a build-in-place function. See
-- the full list in exp_ch6.BIP_Formal_Kind.
----------------------
-- Add_Extra_Formal --
----------------------
function Add_Extra_Formal
(Assoc_Entity : Entity_Id;
Typ : Entity_Id;
Scope : Entity_Id;
Suffix : String) return Entity_Id
is
EF : constant Entity_Id :=
Make_Defining_Identifier (Sloc (Assoc_Entity),
Chars => New_External_Name (Chars (Assoc_Entity),
Suffix => Suffix));
begin
-- A little optimization. Never generate an extra formal for the
-- _init operand of an initialization procedure, since it could
-- never be used.
if Chars (Formal) = Name_uInit then
return Empty;
end if;
Set_Ekind (EF, E_In_Parameter);
Set_Actual_Subtype (EF, Typ);
Set_Etype (EF, Typ);
Set_Scope (EF, Scope);
Set_Mechanism (EF, Default_Mechanism);
Set_Formal_Validity (EF);
if No (First_Extra) then
First_Extra := EF;
Set_Extra_Formals (Scope, EF);
end if;
if Present (Last_Extra) then
Set_Extra_Formal (Last_Extra, EF);
end if;
Last_Extra := EF;
return EF;
end Add_Extra_Formal;
-- Local variables
Formal_Type : Entity_Id;
P_Formal : Entity_Id := Empty;
-- Start of processing for Create_Extra_Formals
begin
-- We never generate extra formals if expansion is not active because we
-- don't need them unless we are generating code.
if not Expander_Active then
return;
end if;
-- No need to generate extra formals in interface thunks whose target
-- primitive has no extra formals.
if Is_Thunk (E) and then No (Extra_Formals (Thunk_Entity (E))) then
return;
end if;
-- If this is a derived subprogram then the subtypes of the parent
-- subprogram's formal parameters will be used to determine the need
-- for extra formals.
if Is_Overloadable (E) and then Present (Alias (E)) then
P_Formal := First_Formal (Alias (E));
end if;
Formal := First_Formal (E);
while Present (Formal) loop
Last_Extra := Formal;
Next_Formal (Formal);
end loop;
-- If Extra_Formals were already created, don't do it again. This
-- situation may arise for subprogram types created as part of
-- dispatching calls (see Expand_Dispatching_Call).
if Present (Last_Extra) and then Present (Extra_Formal (Last_Extra)) then
return;
end if;
-- If the subprogram is a predefined dispatching subprogram then don't
-- generate any extra constrained or accessibility level formals. In
-- general we suppress these for internal subprograms (by not calling
-- Freeze_Subprogram and Create_Extra_Formals at all), but internally
-- generated stream attributes do get passed through because extra
-- build-in-place formals are needed in some cases (limited 'Input).
if Is_Predefined_Internal_Operation (E) then
goto Test_For_Func_Result_Extras;
end if;
Formal := First_Formal (E);
while Present (Formal) loop
-- Create extra formal for supporting the attribute 'Constrained.
-- The case of a private type view without discriminants also
-- requires the extra formal if the underlying type has defaulted
-- discriminants.
if Ekind (Formal) /= E_In_Parameter then
if Present (P_Formal) then
Formal_Type := Etype (P_Formal);
else
Formal_Type := Etype (Formal);
end if;
-- Do not produce extra formals for Unchecked_Union parameters.
-- Jump directly to the end of the loop.
if Is_Unchecked_Union (Base_Type (Formal_Type)) then
goto Skip_Extra_Formal_Generation;
end if;
if not Has_Discriminants (Formal_Type)
and then Ekind (Formal_Type) in Private_Kind
and then Present (Underlying_Type (Formal_Type))
then
Formal_Type := Underlying_Type (Formal_Type);
end if;
-- Suppress the extra formal if formal's subtype is constrained or
-- indefinite, or we're compiling for Ada 2012 and the underlying
-- type is tagged and limited. In Ada 2012, a limited tagged type
-- can have defaulted discriminants, but 'Constrained is required
-- to return True, so the formal is never needed (see AI05-0214).
-- Note that this ensures consistency of calling sequences for
-- dispatching operations when some types in a class have defaults
-- on discriminants and others do not (and requiring the extra
-- formal would introduce distributed overhead).
-- If the type does not have a completion yet, treat as prior to
-- Ada 2012 for consistency.
if Has_Discriminants (Formal_Type)
and then not Is_Constrained (Formal_Type)
and then Is_Definite_Subtype (Formal_Type)
and then (Ada_Version < Ada_2012
or else No (Underlying_Type (Formal_Type))
or else not
(Is_Limited_Type (Formal_Type)
and then
(Is_Tagged_Type
(Underlying_Type (Formal_Type)))))
then
Set_Extra_Constrained
(Formal, Add_Extra_Formal (Formal, Standard_Boolean, E, "O"));
end if;
end if;
-- Create extra formal for supporting accessibility checking. This
-- is done for both anonymous access formals and formals of named
-- access types that are marked as controlling formals. The latter
-- case can occur when Expand_Dispatching_Call creates a subprogram
-- type and substitutes the types of access-to-class-wide actuals
-- for the anonymous access-to-specific-type of controlling formals.
-- Base_Type is applied because in cases where there is a null
-- exclusion the formal may have an access subtype.
-- This is suppressed if we specifically suppress accessibility
-- checks at the package level for either the subprogram, or the
-- package in which it resides. However, we do not suppress it
-- simply if the scope has accessibility checks suppressed, since
-- this could cause trouble when clients are compiled with a
-- different suppression setting. The explicit checks at the
-- package level are safe from this point of view.
if (Ekind (Base_Type (Etype (Formal))) = E_Anonymous_Access_Type
or else (Is_Controlling_Formal (Formal)
and then Is_Access_Type (Base_Type (Etype (Formal)))))
and then not
(Explicit_Suppress (E, Accessibility_Check)
or else
Explicit_Suppress (Scope (E), Accessibility_Check))
and then
(No (P_Formal)
or else Present (Extra_Accessibility (P_Formal)))
then
Set_Extra_Accessibility
(Formal, Add_Extra_Formal (Formal, Standard_Natural, E, "L"));
end if;
-- This label is required when skipping extra formal generation for
-- Unchecked_Union parameters.
<<Skip_Extra_Formal_Generation>>
if Present (P_Formal) then
Next_Formal (P_Formal);
end if;
Next_Formal (Formal);
end loop;
<<Test_For_Func_Result_Extras>>
-- Ada 2012 (AI05-234): "the accessibility level of the result of a
-- function call is ... determined by the point of call ...".
if Needs_Result_Accessibility_Level (E) then
Set_Extra_Accessibility_Of_Result
(E, Add_Extra_Formal (E, Standard_Natural, E, "L"));
end if;
-- Ada 2005 (AI-318-02): In the case of build-in-place functions, add
-- appropriate extra formals. See type Exp_Ch6.BIP_Formal_Kind.
if Is_Build_In_Place_Function (E) then
declare
Result_Subt : constant Entity_Id := Etype (E);
Formal_Typ : Entity_Id;
Subp_Decl : Node_Id;
Discard : Entity_Id;
begin
-- In the case of functions with unconstrained result subtypes,
-- add a 4-state formal indicating whether the return object is
-- allocated by the caller (1), or should be allocated by the
-- callee on the secondary stack (2), in the global heap (3), or
-- in a user-defined storage pool (4). For the moment we just use
-- Natural for the type of this formal. Note that this formal
-- isn't usually needed in the case where the result subtype is
-- constrained, but it is needed when the function has a tagged
-- result, because generally such functions can be called in a
-- dispatching context and such calls must be handled like calls
-- to a class-wide function.
if Needs_BIP_Alloc_Form (E) then
Discard :=
Add_Extra_Formal
(E, Standard_Natural,
E, BIP_Formal_Suffix (BIP_Alloc_Form));
-- Add BIP_Storage_Pool, in case BIP_Alloc_Form indicates to
-- use a user-defined pool. This formal is not added on
-- ZFP as those targets do not support pools.
if RTE_Available (RE_Root_Storage_Pool_Ptr) then
Discard :=
Add_Extra_Formal
(E, RTE (RE_Root_Storage_Pool_Ptr),
E, BIP_Formal_Suffix (BIP_Storage_Pool));
end if;
end if;
-- In the case of functions whose result type needs finalization,
-- add an extra formal which represents the finalization master.
if Needs_BIP_Finalization_Master (E) then
Discard :=
Add_Extra_Formal
(E, RTE (RE_Finalization_Master_Ptr),
E, BIP_Formal_Suffix (BIP_Finalization_Master));
end if;
-- When the result type contains tasks, add two extra formals: the
-- master of the tasks to be created, and the caller's activation
-- chain.
if Needs_BIP_Task_Actuals (E) then
Discard :=
Add_Extra_Formal
(E, RTE (RE_Master_Id),
E, BIP_Formal_Suffix (BIP_Task_Master));
Set_Has_Master_Entity (E);
Discard :=
Add_Extra_Formal
(E, RTE (RE_Activation_Chain_Access),
E, BIP_Formal_Suffix (BIP_Activation_Chain));
end if;
-- All build-in-place functions get an extra formal that will be
-- passed the address of the return object within the caller.
Formal_Typ :=
Create_Itype (E_Anonymous_Access_Type, E, Scope_Id => Scope (E));
-- Incomplete_View_From_Limited_With is needed here because
-- gigi gets confused if the designated type is the full view
-- coming from a limited-with'ed package. In the normal case,
-- (no limited with) Incomplete_View_From_Limited_With
-- returns Result_Subt.
Set_Directly_Designated_Type
(Formal_Typ, Incomplete_View_From_Limited_With (Result_Subt));
Set_Etype (Formal_Typ, Formal_Typ);
Set_Depends_On_Private
(Formal_Typ, Has_Private_Component (Formal_Typ));
Set_Is_Public (Formal_Typ, Is_Public (Scope (Formal_Typ)));
Set_Is_Access_Constant (Formal_Typ, False);
-- Ada 2005 (AI-50217): Propagate the attribute that indicates
-- the designated type comes from the limited view (for back-end
-- purposes).
Set_From_Limited_With
(Formal_Typ, From_Limited_With (Result_Subt));
Layout_Type (Formal_Typ);
-- Force the definition of the Itype in case of internal function
-- calls within the same or nested scope.
if Is_Subprogram_Or_Generic_Subprogram (E) then
Subp_Decl := Parent (E);
-- The insertion point for an Itype reference should be after
-- the unit declaration node of the subprogram. An exception
-- to this are inherited operations from a parent type in which
-- case the derived type acts as their parent.
if Nkind (Subp_Decl) in N_Function_Specification
| N_Procedure_Specification
then
Subp_Decl := Parent (Subp_Decl);
end if;
Build_Itype_Reference (Formal_Typ, Subp_Decl);
end if;
Discard :=
Add_Extra_Formal
(E, Formal_Typ, E, BIP_Formal_Suffix (BIP_Object_Access));
end;
end if;
-- If this is an instance of a generic, we need to have extra formals
-- for the Alias.
if Is_Generic_Instance (E) and then Present (Alias (E)) then
Set_Extra_Formals (Alias (E), Extra_Formals (E));
end if;
end Create_Extra_Formals;
-----------------------------
-- Enter_Overloaded_Entity --
-----------------------------
procedure Enter_Overloaded_Entity (S : Entity_Id) is
function Matches_Predefined_Op return Boolean;
-- This returns an approximation of whether S matches a predefined
-- operator, based on the operator symbol, and the parameter and result
-- types. The rules are scattered throughout chapter 4 of the Ada RM.
---------------------------
-- Matches_Predefined_Op --
---------------------------
function Matches_Predefined_Op return Boolean is
Formal_1 : constant Entity_Id := First_Formal (S);
Formal_2 : constant Entity_Id := Next_Formal (Formal_1);
Op : constant Name_Id := Chars (S);
Result_Type : constant Entity_Id := Base_Type (Etype (S));
Type_1 : constant Entity_Id := Base_Type (Etype (Formal_1));
begin
-- Binary operator
if Present (Formal_2) then
declare
Type_2 : constant Entity_Id := Base_Type (Etype (Formal_2));
begin
-- All but "&" and "**" have same-types parameters
case Op is
when Name_Op_Concat
| Name_Op_Expon
=>
null;
when others =>
if Type_1 /= Type_2 then
return False;
end if;
end case;
-- Check parameter and result types
case Op is
when Name_Op_And
| Name_Op_Or
| Name_Op_Xor
=>
return
Is_Boolean_Type (Result_Type)
and then Result_Type = Type_1;
when Name_Op_Mod
| Name_Op_Rem
=>
return
Is_Integer_Type (Result_Type)
and then Result_Type = Type_1;
when Name_Op_Add
| Name_Op_Divide
| Name_Op_Multiply
| Name_Op_Subtract
=>
return
Is_Numeric_Type (Result_Type)
and then Result_Type = Type_1;
when Name_Op_Eq
| Name_Op_Ne
=>
return
Is_Boolean_Type (Result_Type)
and then not Is_Limited_Type (Type_1);
when Name_Op_Ge
| Name_Op_Gt
| Name_Op_Le
| Name_Op_Lt
=>
return
Is_Boolean_Type (Result_Type)
and then (Is_Array_Type (Type_1)
or else Is_Scalar_Type (Type_1));
when Name_Op_Concat =>
return Is_Array_Type (Result_Type);
when Name_Op_Expon =>
return
(Is_Integer_Type (Result_Type)
or else Is_Floating_Point_Type (Result_Type))
and then Result_Type = Type_1
and then Type_2 = Standard_Integer;
when others =>
raise Program_Error;
end case;
end;
-- Unary operator
else
case Op is
when Name_Op_Abs
| Name_Op_Add
| Name_Op_Subtract
=>
return
Is_Numeric_Type (Result_Type)
and then Result_Type = Type_1;
when Name_Op_Not =>
return
Is_Boolean_Type (Result_Type)
and then Result_Type = Type_1;
when others =>
raise Program_Error;
end case;
end if;
end Matches_Predefined_Op;
-- Local variables
E : Entity_Id := Current_Entity_In_Scope (S);
C_E : Entity_Id := Current_Entity (S);
-- Start of processing for Enter_Overloaded_Entity
begin
if Present (E) then
Set_Has_Homonym (E);
Set_Has_Homonym (S);
end if;
Set_Is_Immediately_Visible (S);
Set_Scope (S, Current_Scope);
-- Chain new entity if front of homonym in current scope, so that
-- homonyms are contiguous.
if Present (E) and then E /= C_E then
while Homonym (C_E) /= E loop
C_E := Homonym (C_E);
end loop;
Set_Homonym (C_E, S);
else
E := C_E;
Set_Current_Entity (S);
end if;
Set_Homonym (S, E);
if Is_Inherited_Operation (S) then
Append_Inherited_Subprogram (S);
else
Append_Entity (S, Current_Scope);
end if;
Set_Public_Status (S);
if Debug_Flag_E then
Write_Str ("New overloaded entity chain: ");
Write_Name (Chars (S));
E := S;
while Present (E) loop
Write_Str (" "); Write_Int (Int (E));
E := Homonym (E);
end loop;
Write_Eol;
end if;
-- Generate warning for hiding
if Warn_On_Hiding
and then Comes_From_Source (S)
and then In_Extended_Main_Source_Unit (S)
then
E := S;
loop
E := Homonym (E);
exit when No (E);
-- Warn unless genuine overloading. Do not emit warning on
-- hiding predefined operators in Standard (these are either an
-- artifact of our implicit declarations, or simple noise) but
-- keep warning on a operator defined on a local subtype, because
-- of the real danger that different operators may be applied in
-- various parts of the program.
-- Note that if E and S have the same scope, there is never any
-- hiding. Either the two conflict, and the program is illegal,
-- or S is overriding an implicit inherited subprogram.
if Scope (E) /= Scope (S)
and then (not Is_Overloadable (E)
or else Subtype_Conformant (E, S))
and then (Is_Immediately_Visible (E)
or else Is_Potentially_Use_Visible (S))
then
if Scope (E) = Standard_Standard then
if Nkind (S) = N_Defining_Operator_Symbol
and then Scope (Base_Type (Etype (First_Formal (S)))) /=
Scope (S)
and then Matches_Predefined_Op
then
Error_Msg_N
("declaration of & hides predefined operator?h?", S);
end if;
-- E not immediately within Standard
else
Error_Msg_Sloc := Sloc (E);
Error_Msg_N ("declaration of & hides one #?h?", S);
end if;
end if;
end loop;
end if;
end Enter_Overloaded_Entity;
-----------------------------
-- Check_Untagged_Equality --
-----------------------------
procedure Check_Untagged_Equality (Eq_Op : Entity_Id) is
Typ : constant Entity_Id := Etype (First_Formal (Eq_Op));
Decl : constant Node_Id := Unit_Declaration_Node (Eq_Op);
Obj_Decl : Node_Id;
begin
-- This check applies only if we have a subprogram declaration with an
-- untagged record type that is conformant to the predefined op.
if Nkind (Decl) /= N_Subprogram_Declaration
or else not Is_Record_Type (Typ)
or else Is_Tagged_Type (Typ)
or else Etype (Next_Formal (First_Formal (Eq_Op))) /= Typ
then
return;
end if;
-- In Ada 2012 case, we will output errors or warnings depending on
-- the setting of debug flag -gnatd.E.
if Ada_Version >= Ada_2012 then
Error_Msg_Warn := Debug_Flag_Dot_EE;
-- In earlier versions of Ada, nothing to do unless we are warning on
-- Ada 2012 incompatibilities (Warn_On_Ada_2012_Incompatibility set).
else
if not Warn_On_Ada_2012_Compatibility then
return;
end if;
end if;
-- Cases where the type has already been frozen
if Is_Frozen (Typ) then
-- The check applies to a primitive operation, so check that type
-- and equality operation are in the same scope.
if Scope (Typ) /= Current_Scope then
return;
-- If the type is a generic actual (sub)type, the operation is not
-- primitive either because the base type is declared elsewhere.
elsif Is_Generic_Actual_Type (Typ) then
return;
-- Here we have a definite error of declaration after freezing
else
if Ada_Version >= Ada_2012 then
Error_Msg_NE
("equality operator must be declared before type & is "
& "frozen (RM 4.5.2 (9.8)) (Ada 2012)<<", Eq_Op, Typ);
-- In Ada 2012 mode with error turned to warning, output one
-- more warning to warn that the equality operation may not
-- compose. This is the consequence of ignoring the error.
if Error_Msg_Warn then
Error_Msg_N ("\equality operation may not compose??", Eq_Op);
end if;
else
Error_Msg_NE
("equality operator must be declared before type& is "
& "frozen (RM 4.5.2 (9.8)) (Ada 2012)?y?", Eq_Op, Typ);
end if;
-- If we are in the package body, we could just move the
-- declaration to the package spec, so add a message saying that.
if In_Package_Body (Scope (Typ)) then
if Ada_Version >= Ada_2012 then
Error_Msg_N
("\move declaration to package spec<<", Eq_Op);
else
Error_Msg_N
("\move declaration to package spec (Ada 2012)?y?", Eq_Op);
end if;
-- Otherwise try to find the freezing point for better message.
else
Obj_Decl := Next (Parent (Typ));
while Present (Obj_Decl) and then Obj_Decl /= Decl loop
if Nkind (Obj_Decl) = N_Object_Declaration
and then Etype (Defining_Identifier (Obj_Decl)) = Typ
then
-- Freezing point, output warnings
if Ada_Version >= Ada_2012 then
Error_Msg_NE
("type& is frozen by declaration??", Obj_Decl, Typ);
Error_Msg_N
("\an equality operator cannot be declared after "
& "this point??",
Obj_Decl);
else
Error_Msg_NE
("type& is frozen by declaration (Ada 2012)?y?",
Obj_Decl, Typ);
Error_Msg_N
("\an equality operator cannot be declared after "
& "this point (Ada 2012)?y?",
Obj_Decl);
end if;
exit;
-- If we reach generated code for subprogram declaration
-- or body, it is the body that froze the type and the
-- declaration is legal.
elsif Sloc (Obj_Decl) = Sloc (Decl) then
return;
end if;
Next (Obj_Decl);
end loop;
end if;
end if;
-- Here if type is not frozen yet. It is illegal to have a primitive
-- equality declared in the private part if the type is visible.
elsif not In_Same_List (Parent (Typ), Decl)
and then not Is_Limited_Type (Typ)
then
-- Shouldn't we give an RM reference here???
if Ada_Version >= Ada_2012 then
Error_Msg_N
("equality operator appears too late<<", Eq_Op);
else
Error_Msg_N
("equality operator appears too late (Ada 2012)?y?", Eq_Op);
end if;
-- Finally check for AI12-0352: declaration of a user-defined primitive
-- equality operation for a record type T is illegal if it occurs after
-- a type has been derived from T.
else
Obj_Decl := Next (Parent (Typ));
while Present (Obj_Decl) and then Obj_Decl /= Decl loop
if Nkind (Obj_Decl) = N_Full_Type_Declaration
and then Etype (Defining_Identifier (Obj_Decl)) = Typ
then
Error_Msg_N
("equality operator cannot appear after derivation", Eq_Op);
Error_Msg_NE
("an equality operator for& cannot be declared after "
& "this point??",
Obj_Decl, Typ);
end if;
Next (Obj_Decl);
end loop;
end if;
end Check_Untagged_Equality;
-----------------------------
-- Find_Corresponding_Spec --
-----------------------------
function Find_Corresponding_Spec
(N : Node_Id;
Post_Error : Boolean := True) return Entity_Id
is
Spec : constant Node_Id := Specification (N);
Designator : constant Entity_Id := Defining_Entity (Spec);
E : Entity_Id;
function Different_Generic_Profile (E : Entity_Id) return Boolean;
-- Even if fully conformant, a body may depend on a generic actual when
-- the spec does not, or vice versa, in which case they were distinct
-- entities in the generic.
-------------------------------
-- Different_Generic_Profile --
-------------------------------
function Different_Generic_Profile (E : Entity_Id) return Boolean is
F1, F2 : Entity_Id;
function Same_Generic_Actual (T1, T2 : Entity_Id) return Boolean;
-- Check that the types of corresponding formals have the same
-- generic actual if any. We have to account for subtypes of a
-- generic formal, declared between a spec and a body, which may
-- appear distinct in an instance but matched in the generic, and
-- the subtype may be used either in the spec or the body of the
-- subprogram being checked.
-------------------------
-- Same_Generic_Actual --
-------------------------
function Same_Generic_Actual (T1, T2 : Entity_Id) return Boolean is
function Is_Declared_Subtype (S1, S2 : Entity_Id) return Boolean;
-- Predicate to check whether S1 is a subtype of S2 in the source
-- of the instance.
-------------------------
-- Is_Declared_Subtype --
-------------------------
function Is_Declared_Subtype (S1, S2 : Entity_Id) return Boolean is
begin
return Comes_From_Source (Parent (S1))
and then Nkind (Parent (S1)) = N_Subtype_Declaration
and then Is_Entity_Name (Subtype_Indication (Parent (S1)))
and then Entity (Subtype_Indication (Parent (S1))) = S2;
end Is_Declared_Subtype;
-- Start of processing for Same_Generic_Actual
begin
return Is_Generic_Actual_Type (T1) = Is_Generic_Actual_Type (T2)
or else Is_Declared_Subtype (T1, T2)
or else Is_Declared_Subtype (T2, T1);
end Same_Generic_Actual;
-- Start of processing for Different_Generic_Profile
begin
if not In_Instance then
return False;
elsif Ekind (E) = E_Function
and then not Same_Generic_Actual (Etype (E), Etype (Designator))
then
return True;
end if;
F1 := First_Formal (Designator);
F2 := First_Formal (E);
while Present (F1) loop
if not Same_Generic_Actual (Etype (F1), Etype (F2)) then
return True;
end if;
Next_Formal (F1);
Next_Formal (F2);
end loop;
return False;
end Different_Generic_Profile;
-- Start of processing for Find_Corresponding_Spec
begin
E := Current_Entity (Designator);
while Present (E) loop
-- We are looking for a matching spec. It must have the same scope,
-- and the same name, and either be type conformant, or be the case
-- of a library procedure spec and its body (which belong to one
-- another regardless of whether they are type conformant or not).
if Scope (E) = Current_Scope then
if Current_Scope = Standard_Standard
or else (Ekind (E) = Ekind (Designator)
and then Type_Conformant (E, Designator))
then
-- Within an instantiation, we know that spec and body are
-- subtype conformant, because they were subtype conformant in
-- the generic. We choose the subtype-conformant entity here as
-- well, to resolve spurious ambiguities in the instance that
-- were not present in the generic (i.e. when two different
-- types are given the same actual). If we are looking for a
-- spec to match a body, full conformance is expected.
if In_Instance then
-- Inherit the convention and "ghostness" of the matching
-- spec to ensure proper full and subtype conformance.
Set_Convention (Designator, Convention (E));
-- Skip past subprogram bodies and subprogram renamings that
-- may appear to have a matching spec, but that aren't fully
-- conformant with it. That can occur in cases where an
-- actual type causes unrelated homographs in the instance.
if Nkind (N) in N_Subprogram_Body
| N_Subprogram_Renaming_Declaration
and then Present (Homonym (E))
and then not Fully_Conformant (Designator, E)
then
goto Next_Entity;
elsif not Subtype_Conformant (Designator, E) then
goto Next_Entity;
elsif Different_Generic_Profile (E) then
goto Next_Entity;
end if;
end if;
-- Ada 2012 (AI05-0165): For internally generated bodies of
-- null procedures locate the internally generated spec. We
-- enforce mode conformance since a tagged type may inherit
-- from interfaces several null primitives which differ only
-- in the mode of the formals.
if not (Comes_From_Source (E))
and then Is_Null_Procedure (E)
and then not Mode_Conformant (Designator, E)
then
null;
-- For null procedures coming from source that are completions,
-- analysis of the generated body will establish the link.
elsif Comes_From_Source (E)
and then Nkind (Spec) = N_Procedure_Specification
and then Null_Present (Spec)
then
return E;
-- Expression functions can be completions, but cannot be
-- completed by an explicit body.
elsif Comes_From_Source (E)
and then Comes_From_Source (N)
and then Nkind (N) = N_Subprogram_Body
and then Nkind (Original_Node (Unit_Declaration_Node (E))) =
N_Expression_Function
then
Error_Msg_Sloc := Sloc (E);
Error_Msg_N ("body conflicts with expression function#", N);
return Empty;
elsif not Has_Completion (E) then
if Nkind (N) /= N_Subprogram_Body_Stub then
Set_Corresponding_Spec (N, E);
end if;
Set_Has_Completion (E);
return E;
elsif Nkind (Parent (N)) = N_Subunit then
-- If this is the proper body of a subunit, the completion
-- flag is set when analyzing the stub.
return E;
-- If E is an internal function with a controlling result that
-- was created for an operation inherited by a null extension,
-- it may be overridden by a body without a previous spec (one
-- more reason why these should be shunned). In that case we
-- remove the generated body if present, because the current
-- one is the explicit overriding.
elsif Ekind (E) = E_Function
and then Ada_Version >= Ada_2005
and then not Comes_From_Source (E)
and then Has_Controlling_Result (E)
and then Is_Null_Extension (Etype (E))
and then Comes_From_Source (Spec)
then
Set_Has_Completion (E, False);
if Expander_Active
and then Nkind (Parent (E)) = N_Function_Specification
then
Remove
(Unit_Declaration_Node
(Corresponding_Body (Unit_Declaration_Node (E))));
return E;
-- If expansion is disabled, or if the wrapper function has
-- not been generated yet, this a late body overriding an
-- inherited operation, or it is an overriding by some other
-- declaration before the controlling result is frozen. In
-- either case this is a declaration of a new entity.
else
return Empty;
end if;
-- If the body already exists, then this is an error unless
-- the previous declaration is the implicit declaration of a
-- derived subprogram. It is also legal for an instance to
-- contain type conformant overloadable declarations (but the
-- generic declaration may not), per 8.3(26/2).
elsif No (Alias (E))
and then not Is_Intrinsic_Subprogram (E)
and then not In_Instance
and then Post_Error
then
Error_Msg_Sloc := Sloc (E);
if Is_Imported (E) then
Error_Msg_NE
("body not allowed for imported subprogram & declared#",
N, E);
else
Error_Msg_NE ("duplicate body for & declared#", N, E);
end if;
end if;
-- Child units cannot be overloaded, so a conformance mismatch
-- between body and a previous spec is an error.
elsif Is_Child_Unit (E)
and then
Nkind (Unit_Declaration_Node (Designator)) = N_Subprogram_Body
and then
Nkind (Parent (Unit_Declaration_Node (Designator))) =
N_Compilation_Unit
and then Post_Error
then
Error_Msg_N
("body of child unit does not match previous declaration", N);
end if;
end if;
<<Next_Entity>>
E := Homonym (E);
end loop;
-- On exit, we know that no previous declaration of subprogram exists
return Empty;
end Find_Corresponding_Spec;
----------------------
-- Fully_Conformant --
----------------------
function Fully_Conformant (New_Id, Old_Id : Entity_Id) return Boolean is
Result : Boolean;
begin
Check_Conformance (New_Id, Old_Id, Fully_Conformant, False, Result);
return Result;
end Fully_Conformant;
----------------------------------
-- Fully_Conformant_Expressions --
----------------------------------
function Fully_Conformant_Expressions
(Given_E1 : Node_Id;
Given_E2 : Node_Id;
Report : Boolean := False) return Boolean
is
E1 : constant Node_Id := Original_Node (Given_E1);
E2 : constant Node_Id := Original_Node (Given_E2);
-- We always test conformance on original nodes, since it is possible
-- for analysis and/or expansion to make things look as though they
-- conform when they do not, e.g. by converting 1+2 into 3.
function FCE (Given_E1 : Node_Id; Given_E2 : Node_Id) return Boolean;
-- ???
function FCL (L1 : List_Id; L2 : List_Id) return Boolean;
-- Compare elements of two lists for conformance. Elements have to be
-- conformant, and actuals inserted as default parameters do not match
-- explicit actuals with the same value.
function FCO (Op_Node : Node_Id; Call_Node : Node_Id) return Boolean;
-- Compare an operator node with a function call
---------
-- FCE --
---------
function FCE (Given_E1 : Node_Id; Given_E2 : Node_Id) return Boolean is
begin
return Fully_Conformant_Expressions (Given_E1, Given_E2, Report);
end FCE;
---------
-- FCL --
---------
function FCL (L1 : List_Id; L2 : List_Id) return Boolean is
N1 : Node_Id;
N2 : Node_Id;
begin
if L1 = No_List then
N1 := Empty;
else
N1 := First (L1);
end if;
if L2 = No_List then
N2 := Empty;
else
N2 := First (L2);
end if;
-- Compare two lists, skipping rewrite insertions (we want to compare
-- the original trees, not the expanded versions).
loop
if Is_Rewrite_Insertion (N1) then
Next (N1);
elsif Is_Rewrite_Insertion (N2) then
Next (N2);
elsif No (N1) then
return No (N2);
elsif No (N2) then
return False;
elsif not FCE (N1, N2) then
return False;
else
Next (N1);
Next (N2);
end if;
end loop;
end FCL;
---------
-- FCO --
---------
function FCO (Op_Node : Node_Id; Call_Node : Node_Id) return Boolean is
Actuals : constant List_Id := Parameter_Associations (Call_Node);
Act : Node_Id;
begin
if No (Actuals)
or else Entity (Op_Node) /= Entity (Name (Call_Node))
then
return False;
else
Act := First (Actuals);
if Nkind (Op_Node) in N_Binary_Op then
if not FCE (Left_Opnd (Op_Node), Act) then
return False;
end if;
Next (Act);
end if;
return Present (Act)
and then FCE (Right_Opnd (Op_Node), Act)
and then No (Next (Act));
end if;
end FCO;
function User_Defined_Numeric_Literal_Mismatch return Boolean;
-- Usually literals with the same value like 12345 and 12_345
-- or 123.0 and 123.00 conform, but not if they are
-- user-defined literals.
-------------------------------------------
-- User_Defined_Numeric_Literal_Mismatch --
-------------------------------------------
function User_Defined_Numeric_Literal_Mismatch return Boolean is
E1_Is_User_Defined : constant Boolean :=
Nkind (Given_E1) not in N_Integer_Literal | N_Real_Literal;
E2_Is_User_Defined : constant Boolean :=
Nkind (Given_E2) not in N_Integer_Literal | N_Real_Literal;
begin
pragma Assert (E1_Is_User_Defined = E2_Is_User_Defined);
return E1_Is_User_Defined and then
not String_Equal (String_From_Numeric_Literal (E1),
String_From_Numeric_Literal (E2));
end User_Defined_Numeric_Literal_Mismatch;
-- Local variables
Result : Boolean;
-- Start of processing for Fully_Conformant_Expressions
begin
Result := True;
-- Nonconformant if paren count does not match. Note: if some idiot
-- complains that we don't do this right for more than 3 levels of
-- parentheses, they will be treated with the respect they deserve.
if Paren_Count (E1) /= Paren_Count (E2) then
return False;
-- If same entities are referenced, then they are conformant even if
-- they have different forms (RM 8.3.1(19-20)).
elsif Is_Entity_Name (E1) and then Is_Entity_Name (E2) then
if Present (Entity (E1)) then
Result := Entity (E1) = Entity (E2)
-- One may be a discriminant that has been replaced by the
-- corresponding discriminal.
or else
(Chars (Entity (E1)) = Chars (Entity (E2))
and then Ekind (Entity (E1)) = E_Discriminant
and then Ekind (Entity (E2)) = E_In_Parameter)
-- The discriminant of a protected type is transformed into
-- a local constant and then into a parameter of a protected
-- operation.
or else
(Ekind (Entity (E1)) = E_Constant
and then Ekind (Entity (E2)) = E_In_Parameter
and then Present (Discriminal_Link (Entity (E1)))
and then Discriminal_Link (Entity (E1)) =
Discriminal_Link (Entity (E2)))
-- AI12-050: The loop variables of quantified expressions match
-- if they have the same identifier, even though they may have
-- different entities.
or else
(Chars (Entity (E1)) = Chars (Entity (E2))
and then Ekind (Entity (E1)) = E_Loop_Parameter
and then Ekind (Entity (E2)) = E_Loop_Parameter)
-- A call to an instantiation of Unchecked_Conversion is
-- rewritten with the name of the generated function created for
-- the instance, and this must be special-cased.
or else
(Ekind (Entity (E1)) = E_Function
and then Is_Intrinsic_Subprogram (Entity (E1))
and then Is_Generic_Instance (Entity (E1))
and then Entity (E2) = Alias (Entity (E1)));
if Report and not Result then
Error_Msg_Sloc :=
Text_Ptr'Max (Sloc (Entity (E1)), Sloc (Entity (E2)));
Error_Msg_NE
("Meaning of& differs because of declaration#", E1, E2);
end if;
return Result;
elsif Nkind (E1) = N_Expanded_Name
and then Nkind (E2) = N_Expanded_Name
and then Nkind (Selector_Name (E1)) = N_Character_Literal
and then Nkind (Selector_Name (E2)) = N_Character_Literal
then
return Chars (Selector_Name (E1)) = Chars (Selector_Name (E2));
else
-- Identifiers in component associations don't always have
-- entities, but their names must conform.
return Nkind (E1) = N_Identifier
and then Nkind (E2) = N_Identifier
and then Chars (E1) = Chars (E2);
end if;
elsif Nkind (E1) = N_Character_Literal
and then Nkind (E2) = N_Expanded_Name
then
return Nkind (Selector_Name (E2)) = N_Character_Literal
and then Chars (E1) = Chars (Selector_Name (E2));
elsif Nkind (E2) = N_Character_Literal
and then Nkind (E1) = N_Expanded_Name
then
return Nkind (Selector_Name (E1)) = N_Character_Literal
and then Chars (E2) = Chars (Selector_Name (E1));
elsif Nkind (E1) in N_Op and then Nkind (E2) = N_Function_Call then
return FCO (E1, E2);
elsif Nkind (E2) in N_Op and then Nkind (E1) = N_Function_Call then
return FCO (E2, E1);
-- Otherwise we must have the same syntactic entity
elsif Nkind (E1) /= Nkind (E2) then
return False;
-- At this point, we specialize by node type
else
case Nkind (E1) is
when N_Aggregate =>
return
FCL (Expressions (E1), Expressions (E2))
and then
FCL (Component_Associations (E1),
Component_Associations (E2));
when N_Allocator =>
if Nkind (Expression (E1)) = N_Qualified_Expression
or else
Nkind (Expression (E2)) = N_Qualified_Expression
then
return FCE (Expression (E1), Expression (E2));
-- Check that the subtype marks and any constraints
-- are conformant
else
declare
Indic1 : constant Node_Id := Expression (E1);
Indic2 : constant Node_Id := Expression (E2);
Elt1 : Node_Id;
Elt2 : Node_Id;
begin
if Nkind (Indic1) /= N_Subtype_Indication then
return
Nkind (Indic2) /= N_Subtype_Indication
and then Entity (Indic1) = Entity (Indic2);
elsif Nkind (Indic2) /= N_Subtype_Indication then
return
Nkind (Indic1) /= N_Subtype_Indication
and then Entity (Indic1) = Entity (Indic2);
else
if Entity (Subtype_Mark (Indic1)) /=
Entity (Subtype_Mark (Indic2))
then
return False;
end if;
Elt1 := First (Constraints (Constraint (Indic1)));
Elt2 := First (Constraints (Constraint (Indic2)));
while Present (Elt1) and then Present (Elt2) loop
if not FCE (Elt1, Elt2) then
return False;
end if;
Next (Elt1);
Next (Elt2);
end loop;
return True;
end if;
end;
end if;
when N_Attribute_Reference =>
return
Attribute_Name (E1) = Attribute_Name (E2)
and then FCL (Expressions (E1), Expressions (E2));
when N_Binary_Op =>
return
Entity (E1) = Entity (E2)
and then FCE (Left_Opnd (E1), Left_Opnd (E2))
and then FCE (Right_Opnd (E1), Right_Opnd (E2));
when N_Membership_Test
| N_Short_Circuit
=>
return
FCE (Left_Opnd (E1), Left_Opnd (E2))
and then
FCE (Right_Opnd (E1), Right_Opnd (E2));
when N_Case_Expression =>
declare
Alt1 : Node_Id;
Alt2 : Node_Id;
begin
if not FCE (Expression (E1), Expression (E2)) then
return False;
else
Alt1 := First (Alternatives (E1));
Alt2 := First (Alternatives (E2));
loop
if Present (Alt1) /= Present (Alt2) then
return False;
elsif No (Alt1) then
return True;
end if;
if not FCE (Expression (Alt1), Expression (Alt2))
or else not FCL (Discrete_Choices (Alt1),
Discrete_Choices (Alt2))
then
return False;
end if;
Next (Alt1);
Next (Alt2);
end loop;
end if;
end;
when N_Character_Literal =>
return
Char_Literal_Value (E1) = Char_Literal_Value (E2);
when N_Component_Association =>
return
FCL (Choices (E1), Choices (E2))
and then
FCE (Expression (E1), Expression (E2));
when N_Explicit_Dereference =>
return
FCE (Prefix (E1), Prefix (E2));
when N_Extension_Aggregate =>
return
FCL (Expressions (E1), Expressions (E2))
and then Null_Record_Present (E1) =
Null_Record_Present (E2)
and then FCL (Component_Associations (E1),
Component_Associations (E2));
when N_Function_Call =>
return
FCE (Name (E1), Name (E2))
and then
FCL (Parameter_Associations (E1),
Parameter_Associations (E2));
when N_If_Expression =>
return
FCL (Expressions (E1), Expressions (E2));
when N_Indexed_Component =>
return
FCE (Prefix (E1), Prefix (E2))
and then
FCL (Expressions (E1), Expressions (E2));
when N_Integer_Literal =>
return (Intval (E1) = Intval (E2))
and then not User_Defined_Numeric_Literal_Mismatch;
when N_Null =>
return True;
when N_Operator_Symbol =>
return
Chars (E1) = Chars (E2);
when N_Others_Choice =>
return True;
when N_Parameter_Association =>
return
Chars (Selector_Name (E1)) = Chars (Selector_Name (E2))
and then FCE (Explicit_Actual_Parameter (E1),
Explicit_Actual_Parameter (E2));
when N_Qualified_Expression
| N_Type_Conversion
| N_Unchecked_Type_Conversion
=>
return
FCE (Subtype_Mark (E1), Subtype_Mark (E2))
and then
FCE (Expression (E1), Expression (E2));
when N_Quantified_Expression =>
if not FCE (Condition (E1), Condition (E2)) then
return False;
end if;
if Present (Loop_Parameter_Specification (E1))
and then Present (Loop_Parameter_Specification (E2))
then
declare
L1 : constant Node_Id :=
Loop_Parameter_Specification (E1);
L2 : constant Node_Id :=
Loop_Parameter_Specification (E2);
begin
return
Reverse_Present (L1) = Reverse_Present (L2)
and then
FCE (Defining_Identifier (L1),
Defining_Identifier (L2))
and then
FCE (Discrete_Subtype_Definition (L1),
Discrete_Subtype_Definition (L2));
end;
elsif Present (Iterator_Specification (E1))
and then Present (Iterator_Specification (E2))
then
declare
I1 : constant Node_Id := Iterator_Specification (E1);
I2 : constant Node_Id := Iterator_Specification (E2);
begin
return
FCE (Defining_Identifier (I1),
Defining_Identifier (I2))
and then
Of_Present (I1) = Of_Present (I2)
and then
Reverse_Present (I1) = Reverse_Present (I2)
and then FCE (Name (I1), Name (I2))
and then FCE (Subtype_Indication (I1),
Subtype_Indication (I2));
end;
-- The quantified expressions used different specifications to
-- walk their respective ranges.
else
return False;
end if;
when N_Range =>
return
FCE (Low_Bound (E1), Low_Bound (E2))
and then
FCE (High_Bound (E1), High_Bound (E2));
when N_Real_Literal =>
return (Realval (E1) = Realval (E2))
and then not User_Defined_Numeric_Literal_Mismatch;
when N_Selected_Component =>
return
FCE (Prefix (E1), Prefix (E2))
and then
FCE (Selector_Name (E1), Selector_Name (E2));
when N_Slice =>
return
FCE (Prefix (E1), Prefix (E2))
and then
FCE (Discrete_Range (E1), Discrete_Range (E2));
when N_String_Literal =>
declare
S1 : constant String_Id := Strval (E1);
S2 : constant String_Id := Strval (E2);
L1 : constant Nat := String_Length (S1);
L2 : constant Nat := String_Length (S2);
begin
if L1 /= L2 then
return False;
else
for J in 1 .. L1 loop
if Get_String_Char (S1, J) /=
Get_String_Char (S2, J)
then
return False;
end if;
end loop;
return True;
end if;
end;
when N_Unary_Op =>
return
Entity (E1) = Entity (E2)
and then
FCE (Right_Opnd (E1), Right_Opnd (E2));
-- All other node types cannot appear in this context. Strictly
-- we should raise a fatal internal error. Instead we just ignore
-- the nodes. This means that if anyone makes a mistake in the
-- expander and mucks an expression tree irretrievably, the result
-- will be a failure to detect a (probably very obscure) case
-- of non-conformance, which is better than bombing on some
-- case where two expressions do in fact conform.
when others =>
return True;
end case;
end if;
end Fully_Conformant_Expressions;
----------------------------------------
-- Fully_Conformant_Discrete_Subtypes --
----------------------------------------
function Fully_Conformant_Discrete_Subtypes
(Given_S1 : Node_Id;
Given_S2 : Node_Id) return Boolean
is
S1 : constant Node_Id := Original_Node (Given_S1);
S2 : constant Node_Id := Original_Node (Given_S2);
function Conforming_Bounds (B1, B2 : Node_Id) return Boolean;
-- Special-case for a bound given by a discriminant, which in the body
-- is replaced with the discriminal of the enclosing type.
function Conforming_Ranges (R1, R2 : Node_Id) return Boolean;
-- Check both bounds
-----------------------
-- Conforming_Bounds --
-----------------------
function Conforming_Bounds (B1, B2 : Node_Id) return Boolean is
begin
if Is_Entity_Name (B1)
and then Is_Entity_Name (B2)
and then Ekind (Entity (B1)) = E_Discriminant
then
return Chars (B1) = Chars (B2);
else
return Fully_Conformant_Expressions (B1, B2);
end if;
end Conforming_Bounds;
-----------------------
-- Conforming_Ranges --
-----------------------
function Conforming_Ranges (R1, R2 : Node_Id) return Boolean is
begin
return
Conforming_Bounds (Low_Bound (R1), Low_Bound (R2))
and then
Conforming_Bounds (High_Bound (R1), High_Bound (R2));
end Conforming_Ranges;
-- Start of processing for Fully_Conformant_Discrete_Subtypes
begin
if Nkind (S1) /= Nkind (S2) then
return False;
elsif Is_Entity_Name (S1) then
return Entity (S1) = Entity (S2);
elsif Nkind (S1) = N_Range then
return Conforming_Ranges (S1, S2);
elsif Nkind (S1) = N_Subtype_Indication then
return
Entity (Subtype_Mark (S1)) = Entity (Subtype_Mark (S2))
and then
Conforming_Ranges
(Range_Expression (Constraint (S1)),
Range_Expression (Constraint (S2)));
else
return True;
end if;
end Fully_Conformant_Discrete_Subtypes;
--------------------
-- Install_Entity --
--------------------
procedure Install_Entity (E : Entity_Id) is
Prev : constant Entity_Id := Current_Entity (E);
begin
Set_Is_Immediately_Visible (E);
Set_Current_Entity (E);
Set_Homonym (E, Prev);
end Install_Entity;
---------------------
-- Install_Formals --
---------------------
procedure Install_Formals (Id : Entity_Id) is
F : Entity_Id;
begin
F := First_Formal (Id);
while Present (F) loop
Install_Entity (F);
Next_Formal (F);
end loop;
end Install_Formals;
-----------------------------
-- Is_Interface_Conformant --
-----------------------------
function Is_Interface_Conformant
(Tagged_Type : Entity_Id;
Iface_Prim : Entity_Id;
Prim : Entity_Id) return Boolean
is
-- The operation may in fact be an inherited (implicit) operation
-- rather than the original interface primitive, so retrieve the
-- ultimate ancestor.
Iface : constant Entity_Id :=
Find_Dispatching_Type (Ultimate_Alias (Iface_Prim));
Typ : constant Entity_Id := Find_Dispatching_Type (Prim);
function Controlling_Formal (Prim : Entity_Id) return Entity_Id;
-- Return the controlling formal of Prim
------------------------
-- Controlling_Formal --
------------------------
function Controlling_Formal (Prim : Entity_Id) return Entity_Id is
E : Entity_Id;
begin
E := First_Entity (Prim);
while Present (E) loop
if Is_Formal (E) and then Is_Controlling_Formal (E) then
return E;
end if;
Next_Entity (E);
end loop;
return Empty;
end Controlling_Formal;
-- Local variables
Iface_Ctrl_F : constant Entity_Id := Controlling_Formal (Iface_Prim);
Prim_Ctrl_F : constant Entity_Id := Controlling_Formal (Prim);
-- Start of processing for Is_Interface_Conformant
begin
pragma Assert (Is_Subprogram (Iface_Prim)
and then Is_Subprogram (Prim)
and then Is_Dispatching_Operation (Iface_Prim)
and then Is_Dispatching_Operation (Prim));
pragma Assert (Is_Interface (Iface)
or else (Present (Alias (Iface_Prim))
and then
Is_Interface
(Find_Dispatching_Type (Ultimate_Alias (Iface_Prim)))));
if Prim = Iface_Prim
or else not Is_Subprogram (Prim)
or else Ekind (Prim) /= Ekind (Iface_Prim)
or else not Is_Dispatching_Operation (Prim)
or else Scope (Prim) /= Scope (Tagged_Type)
or else No (Typ)
or else Base_Type (Typ) /= Base_Type (Tagged_Type)
or else not Primitive_Names_Match (Iface_Prim, Prim)
then
return False;
-- The mode of the controlling formals must match
elsif Present (Iface_Ctrl_F)
and then Present (Prim_Ctrl_F)
and then Ekind (Iface_Ctrl_F) /= Ekind (Prim_Ctrl_F)
then
return False;
-- Case of a procedure, or a function whose result type matches the
-- result type of the interface primitive, or a function that has no
-- controlling result (I or access I).
elsif Ekind (Iface_Prim) = E_Procedure
or else Etype (Prim) = Etype (Iface_Prim)
or else not Has_Controlling_Result (Prim)
then
return Type_Conformant
(Iface_Prim, Prim, Skip_Controlling_Formals => True);
-- Case of a function returning an interface, or an access to one. Check
-- that the return types correspond.
elsif Implements_Interface (Typ, Iface) then
if (Ekind (Etype (Prim)) = E_Anonymous_Access_Type)
/=
(Ekind (Etype (Iface_Prim)) = E_Anonymous_Access_Type)
then
return False;
else
return
Type_Conformant (Prim, Ultimate_Alias (Iface_Prim),
Skip_Controlling_Formals => True);
end if;
else
return False;
end if;
end Is_Interface_Conformant;
---------------------------------
-- Is_Non_Overriding_Operation --
---------------------------------
function Is_Non_Overriding_Operation
(Prev_E : Entity_Id;
New_E : Entity_Id) return Boolean
is
Formal : Entity_Id;
F_Typ : Entity_Id;
G_Typ : Entity_Id := Empty;
function Get_Generic_Parent_Type (F_Typ : Entity_Id) return Entity_Id;
-- If F_Type is a derived type associated with a generic actual subtype,
-- then return its Generic_Parent_Type attribute, else return Empty.
function Types_Correspond
(P_Type : Entity_Id;
N_Type : Entity_Id) return Boolean;
-- Returns true if and only if the types (or designated types in the
-- case of anonymous access types) are the same or N_Type is derived
-- directly or indirectly from P_Type.
-----------------------------
-- Get_Generic_Parent_Type --
-----------------------------
function Get_Generic_Parent_Type (F_Typ : Entity_Id) return Entity_Id is
G_Typ : Entity_Id;
Defn : Node_Id;
Indic : Node_Id;
begin
if Is_Derived_Type (F_Typ)
and then Nkind (Parent (F_Typ)) = N_Full_Type_Declaration
then
-- The tree must be traversed to determine the parent subtype in
-- the generic unit, which unfortunately isn't always available
-- via semantic attributes. ??? (Note: The use of Original_Node
-- is needed for cases where a full derived type has been
-- rewritten.)
-- If the parent type is a scalar type, the derivation creates
-- an anonymous base type for it, and the source type is its
-- first subtype.
if Is_Scalar_Type (F_Typ)
and then not Comes_From_Source (F_Typ)
then
Defn :=
Type_Definition
(Original_Node (Parent (First_Subtype (F_Typ))));
else
Defn := Type_Definition (Original_Node (Parent (F_Typ)));
end if;
if Nkind (Defn) = N_Derived_Type_Definition then
Indic := Subtype_Indication (Defn);
if Nkind (Indic) = N_Subtype_Indication then
G_Typ := Entity (Subtype_Mark (Indic));
else
G_Typ := Entity (Indic);
end if;
if Nkind (Parent (G_Typ)) = N_Subtype_Declaration
and then Present (Generic_Parent_Type (Parent (G_Typ)))
then
return Generic_Parent_Type (Parent (G_Typ));
end if;
end if;
end if;
return Empty;
end Get_Generic_Parent_Type;
----------------------
-- Types_Correspond --
----------------------
function Types_Correspond
(P_Type : Entity_Id;
N_Type : Entity_Id) return Boolean
is
Prev_Type : Entity_Id := Base_Type (P_Type);
New_Type : Entity_Id := Base_Type (N_Type);
begin
if Ekind (Prev_Type) = E_Anonymous_Access_Type then
Prev_Type := Designated_Type (Prev_Type);
end if;
if Ekind (New_Type) = E_Anonymous_Access_Type then
New_Type := Designated_Type (New_Type);
end if;
if Prev_Type = New_Type then
return True;
elsif not Is_Class_Wide_Type (New_Type) then
while Etype (New_Type) /= New_Type loop
New_Type := Etype (New_Type);
if New_Type = Prev_Type then
return True;
end if;
end loop;
end if;
return False;
end Types_Correspond;
-- Start of processing for Is_Non_Overriding_Operation
begin
-- In the case where both operations are implicit derived subprograms
-- then neither overrides the other. This can only occur in certain
-- obscure cases (e.g., derivation from homographs created in a generic
-- instantiation).
if Present (Alias (Prev_E)) and then Present (Alias (New_E)) then
return True;
elsif Ekind (Current_Scope) = E_Package
and then Is_Generic_Instance (Current_Scope)
and then In_Private_Part (Current_Scope)
and then Comes_From_Source (New_E)
then
-- We examine the formals and result type of the inherited operation,
-- to determine whether their type is derived from (the instance of)
-- a generic type. The first such formal or result type is the one
-- tested.
Formal := First_Formal (Prev_E);
F_Typ := Empty;
while Present (Formal) loop
F_Typ := Base_Type (Etype (Formal));
if Ekind (F_Typ) = E_Anonymous_Access_Type then
F_Typ := Designated_Type (F_Typ);
end if;
G_Typ := Get_Generic_Parent_Type (F_Typ);
exit when Present (G_Typ);
Next_Formal (Formal);
end loop;
-- If the function dispatches on result check the result type
if No (G_Typ) and then Ekind (Prev_E) = E_Function then
G_Typ := Get_Generic_Parent_Type (Base_Type (Etype (Prev_E)));
end if;
if No (G_Typ) then
return False;
end if;
-- If the generic type is a private type, then the original operation
-- was not overriding in the generic, because there was no primitive
-- operation to override.
if Nkind (Parent (G_Typ)) = N_Formal_Type_Declaration
and then Nkind (Formal_Type_Definition (Parent (G_Typ))) =
N_Formal_Private_Type_Definition
then
return True;
-- The generic parent type is the ancestor of a formal derived
-- type declaration. We need to check whether it has a primitive
-- operation that should be overridden by New_E in the generic.
else
declare
P_Formal : Entity_Id;
N_Formal : Entity_Id;
P_Typ : Entity_Id;
N_Typ : Entity_Id;
P_Prim : Entity_Id;
Prim_Elt : Elmt_Id := First_Elmt (Primitive_Operations (G_Typ));
begin
while Present (Prim_Elt) loop
P_Prim := Node (Prim_Elt);
if Chars (P_Prim) = Chars (New_E)
and then Ekind (P_Prim) = Ekind (New_E)
then
P_Formal := First_Formal (P_Prim);
N_Formal := First_Formal (New_E);
while Present (P_Formal) and then Present (N_Formal) loop
P_Typ := Etype (P_Formal);
N_Typ := Etype (N_Formal);
if not Types_Correspond (P_Typ, N_Typ) then
exit;
end if;
Next_Entity (P_Formal);
Next_Entity (N_Formal);
end loop;
-- Found a matching primitive operation belonging to the
-- formal ancestor type, so the new subprogram is
-- overriding.
if No (P_Formal)
and then No (N_Formal)
and then (Ekind (New_E) /= E_Function
or else
Types_Correspond
(Etype (P_Prim), Etype (New_E)))
then
return False;
end if;
end if;
Next_Elmt (Prim_Elt);
end loop;
-- If no match found, then the new subprogram does not override
-- in the generic (nor in the instance).
-- If the type in question is not abstract, and the subprogram
-- is, this will be an error if the new operation is in the
-- private part of the instance. Emit a warning now, which will
-- make the subsequent error message easier to understand.
if Present (F_Typ) and then not Is_Abstract_Type (F_Typ)
and then Is_Abstract_Subprogram (Prev_E)
and then In_Private_Part (Current_Scope)
then
Error_Msg_Node_2 := F_Typ;
Error_Msg_NE
("private operation& in generic unit does not override "
& "any primitive operation of& (RM 12.3 (18))??",
New_E, New_E);
end if;
return True;
end;
end if;
else
return False;
end if;
end Is_Non_Overriding_Operation;
-------------------------------------
-- List_Inherited_Pre_Post_Aspects --
-------------------------------------
procedure List_Inherited_Pre_Post_Aspects (E : Entity_Id) is
begin
if Opt.List_Inherited_Aspects
and then Is_Subprogram_Or_Generic_Subprogram (E)
then
declare
Subps : constant Subprogram_List := Inherited_Subprograms (E);
Items : Node_Id;
Prag : Node_Id;
begin
for Index in Subps'Range loop
Items := Contract (Subps (Index));
if Present (Items) then
Prag := Pre_Post_Conditions (Items);
while Present (Prag) loop
Error_Msg_Sloc := Sloc (Prag);
if Class_Present (Prag)
and then not Split_PPC (Prag)
then
if Pragma_Name (Prag) = Name_Precondition then
Error_Msg_N
("info: & inherits `Pre''Class` aspect from "
& "#?L?", E);
else
Error_Msg_N
("info: & inherits `Post''Class` aspect from "
& "#?L?", E);
end if;
end if;
Prag := Next_Pragma (Prag);
end loop;
end if;
end loop;
end;
end if;
end List_Inherited_Pre_Post_Aspects;
------------------------------
-- Make_Inequality_Operator --
------------------------------
-- S is the defining identifier of an equality operator. We build a
-- subprogram declaration with the right signature. This operation is
-- intrinsic, because it is always expanded as the negation of the
-- call to the equality function.
procedure Make_Inequality_Operator (S : Entity_Id) is
Loc : constant Source_Ptr := Sloc (S);
Decl : Node_Id;
Formals : List_Id;
Op_Name : Entity_Id;
FF : constant Entity_Id := First_Formal (S);
NF : constant Entity_Id := Next_Formal (FF);
begin
-- Check that equality was properly defined, ignore call if not
if No (NF) then
return;
end if;
declare
A : constant Entity_Id :=
Make_Defining_Identifier (Sloc (FF),
Chars => Chars (FF));
B : constant Entity_Id :=
Make_Defining_Identifier (Sloc (NF),
Chars => Chars (NF));
begin
Op_Name := Make_Defining_Operator_Symbol (Loc, Name_Op_Ne);
Formals := New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier => A,
Parameter_Type =>
New_Occurrence_Of (Etype (First_Formal (S)),
Sloc (Etype (First_Formal (S))))),
Make_Parameter_Specification (Loc,
Defining_Identifier => B,
Parameter_Type =>
New_Occurrence_Of (Etype (Next_Formal (First_Formal (S))),
Sloc (Etype (Next_Formal (First_Formal (S)))))));
Decl :=
Make_Subprogram_Declaration (Loc,
Specification =>
Make_Function_Specification (Loc,
Defining_Unit_Name => Op_Name,
Parameter_Specifications => Formals,
Result_Definition =>
New_Occurrence_Of (Standard_Boolean, Loc)));
-- Insert inequality right after equality if it is explicit or after
-- the derived type when implicit. These entities are created only
-- for visibility purposes, and eventually replaced in the course
-- of expansion, so they do not need to be attached to the tree and
-- seen by the back-end. Keeping them internal also avoids spurious
-- freezing problems. The declaration is inserted in the tree for
-- analysis, and removed afterwards. If the equality operator comes
-- from an explicit declaration, attach the inequality immediately
-- after. Else the equality is inherited from a derived type
-- declaration, so insert inequality after that declaration.
if No (Alias (S)) then
Insert_After (Unit_Declaration_Node (S), Decl);
elsif Is_List_Member (Parent (S)) then
Insert_After (Parent (S), Decl);
else
Insert_After (Parent (Etype (First_Formal (S))), Decl);
end if;
Mark_Rewrite_Insertion (Decl);
Set_Is_Intrinsic_Subprogram (Op_Name);
Analyze (Decl);
Remove (Decl);
Set_Has_Completion (Op_Name);
Set_Corresponding_Equality (Op_Name, S);
Set_Is_Abstract_Subprogram (Op_Name, Is_Abstract_Subprogram (S));
end;
end Make_Inequality_Operator;
----------------------
-- May_Need_Actuals --
----------------------
procedure May_Need_Actuals (Fun : Entity_Id) is
F : Entity_Id;
B : Boolean;
begin
F := First_Formal (Fun);
B := True;
while Present (F) loop
if No (Default_Value (F)) then
B := False;
exit;
end if;
Next_Formal (F);
end loop;
Set_Needs_No_Actuals (Fun, B);
end May_Need_Actuals;
---------------------
-- Mode_Conformant --
---------------------
function Mode_Conformant (New_Id, Old_Id : Entity_Id) return Boolean is
Result : Boolean;
begin
Check_Conformance (New_Id, Old_Id, Mode_Conformant, False, Result);
return Result;
end Mode_Conformant;
---------------------------
-- New_Overloaded_Entity --
---------------------------
procedure New_Overloaded_Entity
(S : Entity_Id;
Derived_Type : Entity_Id := Empty)
is
Overridden_Subp : Entity_Id := Empty;
-- Set if the current scope has an operation that is type-conformant
-- with S, and becomes hidden by S.
Is_Primitive_Subp : Boolean;
-- Set to True if the new subprogram is primitive
E : Entity_Id;
-- Entity that S overrides
procedure Check_For_Primitive_Subprogram
(Is_Primitive : out Boolean;
Is_Overriding : Boolean := False);
-- If the subprogram being analyzed is a primitive operation of the type
-- of a formal or result, set the Has_Primitive_Operations flag on the
-- type, and set Is_Primitive to True (otherwise set to False). Set the
-- corresponding flag on the entity itself for later use.
function Has_Matching_Entry_Or_Subprogram (E : Entity_Id) return Boolean;
-- True if a) E is a subprogram whose first formal is a concurrent type
-- defined in the scope of E that has some entry or subprogram whose
-- profile matches E, or b) E is an internally built dispatching
-- subprogram of a protected type and there is a matching subprogram
-- defined in the enclosing scope of the protected type, or c) E is
-- an entry of a synchronized type and a matching procedure has been
-- previously defined in the enclosing scope of the synchronized type.
function Is_Private_Declaration (E : Entity_Id) return Boolean;
-- Check that E is declared in the private part of the current package,
-- or in the package body, where it may hide a previous declaration.
-- We can't use In_Private_Part by itself because this flag is also
-- set when freezing entities, so we must examine the place of the
-- declaration in the tree, and recognize wrapper packages as well.
function Is_Overriding_Alias
(Old_E : Entity_Id;
New_E : Entity_Id) return Boolean;
-- Check whether new subprogram and old subprogram are both inherited
-- from subprograms that have distinct dispatch table entries. This can
-- occur with derivations from instances with accidental homonyms. The
-- function is conservative given that the converse is only true within
-- instances that contain accidental overloadings.
procedure Report_Conflict (S : Entity_Id; E : Entity_Id);
-- Report conflict between entities S and E
------------------------------------
-- Check_For_Primitive_Subprogram --
------------------------------------
procedure Check_For_Primitive_Subprogram
(Is_Primitive : out Boolean;
Is_Overriding : Boolean := False)
is
Formal : Entity_Id;
F_Typ : Entity_Id;
B_Typ : Entity_Id;
function Visible_Part_Type (T : Entity_Id) return Boolean;
-- Returns true if T is declared in the visible part of the current
-- package scope; otherwise returns false. Assumes that T is declared
-- in a package.
procedure Check_Private_Overriding (T : Entity_Id);
-- Checks that if a primitive abstract subprogram of a visible
-- abstract type is declared in a private part, then it must override
-- an abstract subprogram declared in the visible part. Also checks
-- that if a primitive function with a controlling result is declared
-- in a private part, then it must override a function declared in
-- the visible part.
------------------------------
-- Check_Private_Overriding --
------------------------------
procedure Check_Private_Overriding (T : Entity_Id) is
function Overrides_Private_Part_Op return Boolean;
-- This detects the special case where the overriding subprogram
-- is overriding a subprogram that was declared in the same
-- private part. That case is illegal by 3.9.3(10).
function Overrides_Visible_Function
(Partial_View : Entity_Id) return Boolean;
-- True if S overrides a function in the visible part. The
-- overridden function could be explicitly or implicitly declared.
-------------------------------
-- Overrides_Private_Part_Op --
-------------------------------
function Overrides_Private_Part_Op return Boolean is
Over_Decl : constant Node_Id :=
Unit_Declaration_Node (Overridden_Operation (S));
Subp_Decl : constant Node_Id := Unit_Declaration_Node (S);
begin
pragma Assert (Is_Overriding);
pragma Assert
(Nkind (Over_Decl) = N_Abstract_Subprogram_Declaration);
pragma Assert
(Nkind (Subp_Decl) = N_Abstract_Subprogram_Declaration);
return In_Same_List (Over_Decl, Subp_Decl);
end Overrides_Private_Part_Op;
--------------------------------
-- Overrides_Visible_Function --
--------------------------------
function Overrides_Visible_Function
(Partial_View : Entity_Id) return Boolean
is
begin
if not Is_Overriding or else not Has_Homonym (S) then
return False;
end if;
if not Present (Partial_View) then
return True;
end if;
-- Search through all the homonyms H of S in the current
-- package spec, and return True if we find one that matches.
-- Note that Parent (H) will be the declaration of the
-- partial view of T for a match.
declare
H : Entity_Id := S;
begin
loop
H := Homonym (H);
exit when not Present (H) or else Scope (H) /= Scope (S);
if Nkind (Parent (H)) in
N_Private_Extension_Declaration |
N_Private_Type_Declaration
and then Defining_Identifier (Parent (H)) = Partial_View
then
return True;
end if;
end loop;
end;
return False;
end Overrides_Visible_Function;
-- Start of processing for Check_Private_Overriding
begin
if Is_Package_Or_Generic_Package (Current_Scope)
and then In_Private_Part (Current_Scope)
and then Visible_Part_Type (T)
and then not In_Instance
then
if Is_Abstract_Type (T)
and then Is_Abstract_Subprogram (S)
and then (not Is_Overriding
or else not Is_Abstract_Subprogram (E)
or else Overrides_Private_Part_Op)
then
Error_Msg_N
("abstract subprograms must be visible (RM 3.9.3(10))!",
S);
elsif Ekind (S) = E_Function then
declare
Partial_View : constant Entity_Id :=
Incomplete_Or_Partial_View (T);
begin
if not Overrides_Visible_Function (Partial_View) then
-- Here, S is "function ... return T;" declared in
-- the private part, not overriding some visible
-- operation. That's illegal in the tagged case
-- (but not if the private type is untagged).
if ((Present (Partial_View)
and then Is_Tagged_Type (Partial_View))
or else (not Present (Partial_View)
and then Is_Tagged_Type (T)))
and then T = Base_Type (Etype (S))
then
Error_Msg_N
("private function with tagged result must"
& " override visible-part function", S);
Error_Msg_N
("\move subprogram to the visible part"
& " (RM 3.9.3(10))", S);
-- Ada 2012 (AI05-0073): Extend this check to the case
-- of a function whose result subtype is defined by an
-- access_definition designating specific tagged type.
elsif Ekind (Etype (S)) = E_Anonymous_Access_Type
and then Is_Tagged_Type (Designated_Type (Etype (S)))
and then
not Is_Class_Wide_Type
(Designated_Type (Etype (S)))
and then Ada_Version >= Ada_2012
then
Error_Msg_N
("private function with controlling access "
& "result must override visible-part function",
S);
Error_Msg_N
("\move subprogram to the visible part"
& " (RM 3.9.3(10))", S);
end if;
end if;
end;
end if;
end if;
end Check_Private_Overriding;
-----------------------
-- Visible_Part_Type --
-----------------------
function Visible_Part_Type (T : Entity_Id) return Boolean is
P : constant Node_Id := Unit_Declaration_Node (Scope (T));
begin
-- If the entity is a private type, then it must be declared in a
-- visible part.
if Ekind (T) in Private_Kind then
return True;
elsif Is_Type (T) and then Has_Private_Declaration (T) then
return True;
elsif Is_List_Member (Declaration_Node (T))
and then List_Containing (Declaration_Node (T)) =
Visible_Declarations (Specification (P))
then
return True;
else
return False;
end if;
end Visible_Part_Type;
-- Start of processing for Check_For_Primitive_Subprogram
begin
Is_Primitive := False;
if not Comes_From_Source (S) then
null;
-- If subprogram is at library level, it is not primitive operation
elsif Current_Scope = Standard_Standard then
null;
elsif (Is_Package_Or_Generic_Package (Current_Scope)
and then not In_Package_Body (Current_Scope))
or else Is_Overriding
then
-- For function, check return type
if Ekind (S) = E_Function then
if Ekind (Etype (S)) = E_Anonymous_Access_Type then
F_Typ := Designated_Type (Etype (S));
else
F_Typ := Etype (S);
end if;
B_Typ := Base_Type (F_Typ);
if Scope (B_Typ) = Current_Scope
and then not Is_Class_Wide_Type (B_Typ)
and then not Is_Generic_Type (B_Typ)
then
Is_Primitive := True;
Set_Has_Primitive_Operations (B_Typ);
Set_Is_Primitive (S);
Check_Private_Overriding (B_Typ);
-- The Ghost policy in effect at the point of declaration
-- or a tagged type and a primitive operation must match
-- (SPARK RM 6.9(16)).
Check_Ghost_Primitive (S, B_Typ);
end if;
end if;
-- For all subprograms, check formals
Formal := First_Formal (S);
while Present (Formal) loop
if Ekind (Etype (Formal)) = E_Anonymous_Access_Type then
F_Typ := Designated_Type (Etype (Formal));
else
F_Typ := Etype (Formal);
end if;
B_Typ := Base_Type (F_Typ);
if Ekind (B_Typ) = E_Access_Subtype then
B_Typ := Base_Type (B_Typ);
end if;
if Scope (B_Typ) = Current_Scope
and then not Is_Class_Wide_Type (B_Typ)
and then not Is_Generic_Type (B_Typ)
then
Is_Primitive := True;
Set_Is_Primitive (S);
Set_Has_Primitive_Operations (B_Typ);
Check_Private_Overriding (B_Typ);
-- The Ghost policy in effect at the point of declaration
-- of a tagged type and a primitive operation must match
-- (SPARK RM 6.9(16)).
Check_Ghost_Primitive (S, B_Typ);
end if;
Next_Formal (Formal);
end loop;
-- Special case: An equality function can be redefined for a type
-- occurring in a declarative part, and won't otherwise be treated as
-- a primitive because it doesn't occur in a package spec and doesn't
-- override an inherited subprogram. It's important that we mark it
-- primitive so it can be returned by Collect_Primitive_Operations
-- and be used in composing the equality operation of later types
-- that have a component of the type.
elsif Chars (S) = Name_Op_Eq
and then Etype (S) = Standard_Boolean
then
B_Typ := Base_Type (Etype (First_Formal (S)));
if Scope (B_Typ) = Current_Scope
and then
Base_Type (Etype (Next_Formal (First_Formal (S)))) = B_Typ
and then not Is_Limited_Type (B_Typ)
then
Is_Primitive := True;
Set_Is_Primitive (S);
Set_Has_Primitive_Operations (B_Typ);
Check_Private_Overriding (B_Typ);
-- The Ghost policy in effect at the point of declaration of a
-- tagged type and a primitive operation must match
-- (SPARK RM 6.9(16)).
Check_Ghost_Primitive (S, B_Typ);
end if;
end if;
end Check_For_Primitive_Subprogram;
--------------------------------------
-- Has_Matching_Entry_Or_Subprogram --
--------------------------------------
function Has_Matching_Entry_Or_Subprogram
(E : Entity_Id) return Boolean
is
function Check_Conforming_Parameters
(E1_Param : Node_Id;
E2_Param : Node_Id;
Ctype : Conformance_Type) return Boolean;
-- Starting from the given parameters, check that all the parameters
-- of two entries or subprograms are conformant. Used to skip
-- the check on the controlling argument.
function Matching_Entry_Or_Subprogram
(Conc_Typ : Entity_Id;
Subp : Entity_Id) return Entity_Id;
-- Return the first entry or subprogram of the given concurrent type
-- whose name matches the name of Subp and has a profile conformant
-- with Subp; return Empty if not found.
function Matching_Dispatching_Subprogram
(Conc_Typ : Entity_Id;
Ent : Entity_Id) return Entity_Id;
-- Return the first dispatching primitive of Conc_Type defined in the
-- enclosing scope of Conc_Type (i.e. before the full definition of
-- this concurrent type) whose name matches the entry Ent and has a
-- profile conformant with the profile of the corresponding (not yet
-- built) dispatching primitive of Ent; return Empty if not found.
function Matching_Original_Protected_Subprogram
(Prot_Typ : Entity_Id;
Subp : Entity_Id) return Entity_Id;
-- Return the first subprogram defined in the enclosing scope of
-- Prot_Typ (before the full definition of this protected type)
-- whose name matches the original name of Subp and has a profile
-- conformant with the profile of Subp; return Empty if not found.
function Normalized_First_Parameter_Type
(E : Entity_Id) return Entity_Id;
-- Return the type of the first parameter unless that type
-- is an anonymous access type, in which case return the
-- designated type. Used to treat anonymous-access-to-synchronized
-- the same as synchronized for purposes of checking for
-- prefixed view profile conflicts.
---------------------------------
-- Check_Conforming_Parameters --
---------------------------------
function Check_Conforming_Parameters
(E1_Param : Node_Id;
E2_Param : Node_Id;
Ctype : Conformance_Type) return Boolean
is
Param_E1 : Node_Id := E1_Param;
Param_E2 : Node_Id := E2_Param;
begin
while Present (Param_E1) and then Present (Param_E2) loop
if (Ctype >= Mode_Conformant) and then
Ekind (Defining_Identifier (Param_E1)) /=
Ekind (Defining_Identifier (Param_E2))
then
return False;
elsif not
Conforming_Types
(Find_Parameter_Type (Param_E1),
Find_Parameter_Type (Param_E2),
Ctype)
then
return False;
end if;
Next (Param_E1);
Next (Param_E2);
end loop;
-- The candidate is not valid if one of the two lists contains
-- more parameters than the other
return No (Param_E1) and then No (Param_E2);
end Check_Conforming_Parameters;
----------------------------------
-- Matching_Entry_Or_Subprogram --
----------------------------------
function Matching_Entry_Or_Subprogram
(Conc_Typ : Entity_Id;
Subp : Entity_Id) return Entity_Id
is
E : Entity_Id;
begin
E := First_Entity (Conc_Typ);
while Present (E) loop
if Chars (Subp) = Chars (E)
and then (Ekind (E) = E_Entry or else Is_Subprogram (E))
and then
Check_Conforming_Parameters
(First (Parameter_Specifications (Parent (E))),
Next (First (Parameter_Specifications (Parent (Subp)))),
Type_Conformant)
then
return E;
end if;
Next_Entity (E);
end loop;
return Empty;
end Matching_Entry_Or_Subprogram;
-------------------------------------
-- Matching_Dispatching_Subprogram --
-------------------------------------
function Matching_Dispatching_Subprogram
(Conc_Typ : Entity_Id;
Ent : Entity_Id) return Entity_Id
is
E : Entity_Id;
begin
-- Search for entities in the enclosing scope of this synchonized
-- type.
pragma Assert (Is_Concurrent_Type (Conc_Typ));
Push_Scope (Scope (Conc_Typ));
E := Current_Entity_In_Scope (Ent);
Pop_Scope;
while Present (E) loop
if Scope (E) = Scope (Conc_Typ)
and then Comes_From_Source (E)
and then Ekind (E) = E_Procedure
and then Present (First_Entity (E))
and then Is_Controlling_Formal (First_Entity (E))
and then Etype (First_Entity (E)) = Conc_Typ
and then
Check_Conforming_Parameters
(First (Parameter_Specifications (Parent (Ent))),
Next (First (Parameter_Specifications (Parent (E)))),
Subtype_Conformant)
then
return E;
end if;
E := Homonym (E);
end loop;
return Empty;
end Matching_Dispatching_Subprogram;
--------------------------------------------
-- Matching_Original_Protected_Subprogram --
--------------------------------------------
function Matching_Original_Protected_Subprogram
(Prot_Typ : Entity_Id;
Subp : Entity_Id) return Entity_Id
is
ICF : constant Boolean :=
Is_Controlling_Formal (First_Entity (Subp));
E : Entity_Id;
begin
-- Temporarily decorate the first parameter of Subp as controlling
-- formal, required to invoke Subtype_Conformant.
Set_Is_Controlling_Formal (First_Entity (Subp));
E :=
Current_Entity_In_Scope (Original_Protected_Subprogram (Subp));
while Present (E) loop
if Scope (E) = Scope (Prot_Typ)
and then Comes_From_Source (E)
and then Ekind (Subp) = Ekind (E)
and then Present (First_Entity (E))
and then Is_Controlling_Formal (First_Entity (E))
and then Etype (First_Entity (E)) = Prot_Typ
and then Subtype_Conformant (Subp, E,
Skip_Controlling_Formals => True)
then
Set_Is_Controlling_Formal (First_Entity (Subp), ICF);
return E;
end if;
E := Homonym (E);
end loop;
Set_Is_Controlling_Formal (First_Entity (Subp), ICF);
return Empty;
end Matching_Original_Protected_Subprogram;
-------------------------------------
-- Normalized_First_Parameter_Type --
-------------------------------------
function Normalized_First_Parameter_Type
(E : Entity_Id) return Entity_Id
is
Result : Entity_Id := Etype (First_Entity (E));
begin
if Ekind (Result) = E_Anonymous_Access_Type then
Result := Designated_Type (Result);
end if;
return Result;
end Normalized_First_Parameter_Type;
-- Start of processing for Has_Matching_Entry_Or_Subprogram
begin
-- Case 1: E is a subprogram whose first formal is a concurrent type
-- defined in the scope of E that has an entry or subprogram whose
-- profile matches E.
if Comes_From_Source (E)
and then Is_Subprogram (E)
and then Present (First_Entity (E))
and then Is_Concurrent_Record_Type
(Normalized_First_Parameter_Type (E))
then
if Scope (E) =
Scope (Corresponding_Concurrent_Type
(Normalized_First_Parameter_Type (E)))
and then
Present
(Matching_Entry_Or_Subprogram
(Corresponding_Concurrent_Type
(Normalized_First_Parameter_Type (E)),
Subp => E))
then
Report_Conflict (E,
Matching_Entry_Or_Subprogram
(Corresponding_Concurrent_Type
(Normalized_First_Parameter_Type (E)),
Subp => E));
return True;
end if;
-- Case 2: E is an internally built dispatching subprogram of a
-- protected type and there is a subprogram defined in the enclosing
-- scope of the protected type that has the original name of E and
-- its profile is conformant with the profile of E. We check the
-- name of the original protected subprogram associated with E since
-- the expander builds dispatching primitives of protected functions
-- and procedures with other names (see Exp_Ch9.Build_Selected_Name).
elsif not Comes_From_Source (E)
and then Is_Subprogram (E)
and then Present (First_Entity (E))
and then Is_Concurrent_Record_Type (Etype (First_Entity (E)))
and then Present (Original_Protected_Subprogram (E))
and then
Present
(Matching_Original_Protected_Subprogram
(Corresponding_Concurrent_Type (Etype (First_Entity (E))),
Subp => E))
then
Report_Conflict (E,
Matching_Original_Protected_Subprogram
(Corresponding_Concurrent_Type (Etype (First_Entity (E))),
Subp => E));
return True;
-- Case 3: E is an entry of a synchronized type and a matching
-- procedure has been previously defined in the enclosing scope
-- of the synchronized type.
elsif Comes_From_Source (E)
and then Ekind (E) = E_Entry
and then
Present (Matching_Dispatching_Subprogram (Current_Scope, E))
then
Report_Conflict (E,
Matching_Dispatching_Subprogram (Current_Scope, E));
return True;
end if;
return False;
end Has_Matching_Entry_Or_Subprogram;
----------------------------
-- Is_Private_Declaration --
----------------------------
function Is_Private_Declaration (E : Entity_Id) return Boolean is
Decl : constant Node_Id := Unit_Declaration_Node (E);
Priv_Decls : List_Id;
begin
if Is_Package_Or_Generic_Package (Current_Scope)
and then In_Private_Part (Current_Scope)
then
Priv_Decls :=
Private_Declarations (Package_Specification (Current_Scope));
return In_Package_Body (Current_Scope)
or else
(Is_List_Member (Decl)
and then List_Containing (Decl) = Priv_Decls)
or else (Nkind (Parent (Decl)) = N_Package_Specification
and then not
Is_Compilation_Unit
(Defining_Entity (Parent (Decl)))
and then List_Containing (Parent (Parent (Decl))) =
Priv_Decls);
else
return False;
end if;
end Is_Private_Declaration;
--------------------------
-- Is_Overriding_Alias --
--------------------------
function Is_Overriding_Alias
(Old_E : Entity_Id;
New_E : Entity_Id) return Boolean
is
AO : constant Entity_Id := Alias (Old_E);
AN : constant Entity_Id := Alias (New_E);
begin
return Scope (AO) /= Scope (AN)
or else No (DTC_Entity (AO))
or else No (DTC_Entity (AN))
or else DT_Position (AO) = DT_Position (AN);
end Is_Overriding_Alias;
---------------------
-- Report_Conflict --
---------------------
procedure Report_Conflict (S : Entity_Id; E : Entity_Id) is
begin
Error_Msg_Sloc := Sloc (E);
-- Generate message, with useful additional warning if in generic
if Is_Generic_Unit (E) then
Error_Msg_N ("previous generic unit cannot be overloaded", S);
Error_Msg_N ("\& conflicts with declaration#", S);
else
Error_Msg_N ("& conflicts with declaration#", S);
end if;
end Report_Conflict;
-- Start of processing for New_Overloaded_Entity
begin
-- We need to look for an entity that S may override. This must be a
-- homonym in the current scope, so we look for the first homonym of
-- S in the current scope as the starting point for the search.
E := Current_Entity_In_Scope (S);
-- Ada 2005 (AI-251): Derivation of abstract interface primitives.
-- They are directly added to the list of primitive operations of
-- Derived_Type, unless this is a rederivation in the private part
-- of an operation that was already derived in the visible part of
-- the current package.
if Ada_Version >= Ada_2005
and then Present (Derived_Type)
and then Present (Alias (S))
and then Is_Dispatching_Operation (Alias (S))
and then Present (Find_Dispatching_Type (Alias (S)))
and then Is_Interface (Find_Dispatching_Type (Alias (S)))
then
-- For private types, when the full-view is processed we propagate to
-- the full view the non-overridden entities whose attribute "alias"
-- references an interface primitive. These entities were added by
-- Derive_Subprograms to ensure that interface primitives are
-- covered.
-- Inside_Freeze_Actions is non zero when S corresponds with an
-- internal entity that links an interface primitive with its
-- covering primitive through attribute Interface_Alias (see
-- Add_Internal_Interface_Entities).
if Inside_Freezing_Actions = 0
and then Is_Package_Or_Generic_Package (Current_Scope)
and then In_Private_Part (Current_Scope)
and then Nkind (Parent (E)) = N_Private_Extension_Declaration
and then Nkind (Parent (S)) = N_Full_Type_Declaration
and then Full_View (Defining_Identifier (Parent (E)))
= Defining_Identifier (Parent (S))
and then Alias (E) = Alias (S)
then
Check_Operation_From_Private_View (S, E);
Set_Is_Dispatching_Operation (S);
-- Common case
else
Enter_Overloaded_Entity (S);
Check_Dispatching_Operation (S, Empty);
Check_For_Primitive_Subprogram (Is_Primitive_Subp);
end if;
return;
end if;
-- For synchronized types check conflicts of this entity with previously
-- defined entities.
if Ada_Version >= Ada_2005
and then Has_Matching_Entry_Or_Subprogram (S)
then
return;
end if;
-- If there is no homonym then this is definitely not overriding
if No (E) then
Enter_Overloaded_Entity (S);
Check_Dispatching_Operation (S, Empty);
Check_For_Primitive_Subprogram (Is_Primitive_Subp);
-- If subprogram has an explicit declaration, check whether it has an
-- overriding indicator.
if Comes_From_Source (S) then
Check_Synchronized_Overriding (S, Overridden_Subp);
-- (Ada 2012: AI05-0125-1): If S is a dispatching operation then
-- it may have overridden some hidden inherited primitive. Update
-- Overridden_Subp to avoid spurious errors when checking the
-- overriding indicator.
if Ada_Version >= Ada_2012
and then No (Overridden_Subp)
and then Is_Dispatching_Operation (S)
and then Present (Overridden_Operation (S))
then
Overridden_Subp := Overridden_Operation (S);
end if;
Check_Overriding_Indicator
(S, Overridden_Subp, Is_Primitive => Is_Primitive_Subp);
-- The Ghost policy in effect at the point of declaration of a
-- parent subprogram and an overriding subprogram must match
-- (SPARK RM 6.9(17)).
Check_Ghost_Overriding (S, Overridden_Subp);
end if;
-- If there is a homonym that is not overloadable, then we have an
-- error, except for the special cases checked explicitly below.
elsif not Is_Overloadable (E) then
-- Check for spurious conflict produced by a subprogram that has the
-- same name as that of the enclosing generic package. The conflict
-- occurs within an instance, between the subprogram and the renaming
-- declaration for the package. After the subprogram, the package
-- renaming declaration becomes hidden.
if Ekind (E) = E_Package
and then Present (Renamed_Object (E))
and then Renamed_Object (E) = Current_Scope
and then Nkind (Parent (Renamed_Object (E))) =
N_Package_Specification
and then Present (Generic_Parent (Parent (Renamed_Object (E))))
then
Set_Is_Hidden (E);
Set_Is_Immediately_Visible (E, False);
Enter_Overloaded_Entity (S);
Set_Homonym (S, Homonym (E));
Check_Dispatching_Operation (S, Empty);
Check_Overriding_Indicator (S, Empty, Is_Primitive => False);
-- If the subprogram is implicit it is hidden by the previous
-- declaration. However if it is dispatching, it must appear in the
-- dispatch table anyway, because it can be dispatched to even if it
-- cannot be called directly.
elsif Present (Alias (S)) and then not Comes_From_Source (S) then
Set_Scope (S, Current_Scope);
if Is_Dispatching_Operation (Alias (S)) then
Check_Dispatching_Operation (S, Empty);
end if;
return;
else
Report_Conflict (S, E);
return;
end if;
-- E exists and is overloadable
else
Check_Synchronized_Overriding (S, Overridden_Subp);
-- Loop through E and its homonyms to determine if any of them is
-- the candidate for overriding by S.
while Present (E) loop
-- Definitely not interesting if not in the current scope
if Scope (E) /= Current_Scope then
null;
-- A function can overload the name of an abstract state. The
-- state can be viewed as a function with a profile that cannot
-- be matched by anything.
elsif Ekind (S) = E_Function
and then Ekind (E) = E_Abstract_State
then
Enter_Overloaded_Entity (S);
return;
-- Ada 2012 (AI05-0165): For internally generated bodies of null
-- procedures locate the internally generated spec. We enforce
-- mode conformance since a tagged type may inherit from
-- interfaces several null primitives which differ only in
-- the mode of the formals.
elsif not Comes_From_Source (S)
and then Is_Null_Procedure (S)
and then not Mode_Conformant (E, S)
then
null;
-- Check if we have type conformance
elsif Type_Conformant (E, S) then
-- If the old and new entities have the same profile and one
-- is not the body of the other, then this is an error, unless
-- one of them is implicitly declared.
-- There are some cases when both can be implicit, for example
-- when both a literal and a function that overrides it are
-- inherited in a derivation, or when an inherited operation
-- of a tagged full type overrides the inherited operation of
-- a private extension. Ada 83 had a special rule for the
-- literal case. In Ada 95, the later implicit operation hides
-- the former, and the literal is always the former. In the
-- odd case where both are derived operations declared at the
-- same point, both operations should be declared, and in that
-- case we bypass the following test and proceed to the next
-- part. This can only occur for certain obscure cases in
-- instances, when an operation on a type derived from a formal
-- private type does not override a homograph inherited from
-- the actual. In subsequent derivations of such a type, the
-- DT positions of these operations remain distinct, if they
-- have been set.
if Present (Alias (S))
and then (No (Alias (E))
or else Comes_From_Source (E)
or else Is_Abstract_Subprogram (S)
or else
(Is_Dispatching_Operation (E)
and then Is_Overriding_Alias (E, S)))
and then Ekind (E) /= E_Enumeration_Literal
then
-- When an derived operation is overloaded it may be due to
-- the fact that the full view of a private extension
-- re-inherits. It has to be dealt with.
if Is_Package_Or_Generic_Package (Current_Scope)
and then In_Private_Part (Current_Scope)
then
Check_Operation_From_Private_View (S, E);
end if;
-- In any case the implicit operation remains hidden by the
-- existing declaration, which is overriding. Indicate that
-- E overrides the operation from which S is inherited.
if Present (Alias (S)) then
Set_Overridden_Operation (E, Alias (S));
Inherit_Subprogram_Contract (E, Alias (S));
else
Set_Overridden_Operation (E, S);
Inherit_Subprogram_Contract (E, S);
end if;
-- When a dispatching operation overrides an inherited
-- subprogram, it shall be subtype conformant with the
-- inherited subprogram (RM 3.9.2 (10.2)).
if Comes_From_Source (E)
and then Is_Dispatching_Operation (E)
and then Find_Dispatching_Type (S)
= Find_Dispatching_Type (E)
then
Check_Subtype_Conformant (E, S);
end if;
if Comes_From_Source (E) then
Check_Overriding_Indicator (E, S, Is_Primitive => False);
-- The Ghost policy in effect at the point of declaration
-- of a parent subprogram and an overriding subprogram
-- must match (SPARK RM 6.9(17)).
Check_Ghost_Overriding (E, S);
end if;
return;
-- Within an instance, the renaming declarations for actual
-- subprograms may become ambiguous, but they do not hide each
-- other.
elsif Ekind (E) /= E_Entry
and then not Comes_From_Source (E)
and then not Is_Generic_Instance (E)
and then (Present (Alias (E))
or else Is_Intrinsic_Subprogram (E))
and then (not In_Instance
or else No (Parent (E))
or else Nkind (Unit_Declaration_Node (E)) /=
N_Subprogram_Renaming_Declaration)
then
-- A subprogram child unit is not allowed to override an
-- inherited subprogram (10.1.1(20)).
if Is_Child_Unit (S) then
Error_Msg_N
("child unit overrides inherited subprogram in parent",
S);
return;
end if;
if Is_Non_Overriding_Operation (E, S) then
Enter_Overloaded_Entity (S);
if No (Derived_Type)
or else Is_Tagged_Type (Derived_Type)
then
Check_Dispatching_Operation (S, Empty);
end if;
return;
end if;
-- E is a derived operation or an internal operator which
-- is being overridden. Remove E from further visibility.
-- Furthermore, if E is a dispatching operation, it must be
-- replaced in the list of primitive operations of its type
-- (see Override_Dispatching_Operation).
Overridden_Subp := E;
-- It is possible for E to be in the current scope and
-- yet not in the entity chain. This can only occur in a
-- generic context where E is an implicit concatenation
-- in the formal part, because in a generic body the
-- entity chain starts with the formals.
-- In GNATprove mode, a wrapper for an operation with
-- axiomatization may be a homonym of another declaration
-- for an actual subprogram (needs refinement ???).
if No (Prev_Entity (E)) then
if In_Instance
and then GNATprove_Mode
and then
Nkind (Original_Node (Unit_Declaration_Node (S))) =
N_Subprogram_Renaming_Declaration
then
return;
else
pragma Assert (Chars (E) = Name_Op_Concat);
null;
end if;
end if;
-- E must be removed both from the entity_list of the
-- current scope, and from the visibility chain.
if Debug_Flag_E then
Write_Str ("Override implicit operation ");
Write_Int (Int (E));
Write_Eol;
end if;
-- If E is a predefined concatenation, it stands for four
-- different operations. As a result, a single explicit
-- declaration does not hide it. In a possible ambiguous
-- situation, Disambiguate chooses the user-defined op,
-- so it is correct to retain the previous internal one.
if Chars (E) /= Name_Op_Concat
or else Ekind (E) /= E_Operator
then
-- For nondispatching derived operations that are
-- overridden by a subprogram declared in the private
-- part of a package, we retain the derived subprogram
-- but mark it as not immediately visible. If the
-- derived operation was declared in the visible part
-- then this ensures that it will still be visible
-- outside the package with the proper signature
-- (calls from outside must also be directed to this
-- version rather than the overriding one, unlike the
-- dispatching case). Calls from inside the package
-- will still resolve to the overriding subprogram
-- since the derived one is marked as not visible
-- within the package.
-- If the private operation is dispatching, we achieve
-- the overriding by keeping the implicit operation
-- but setting its alias to be the overriding one. In
-- this fashion the proper body is executed in all
-- cases, but the original signature is used outside
-- of the package.
-- If the overriding is not in the private part, we
-- remove the implicit operation altogether.
if Is_Private_Declaration (S) then
if not Is_Dispatching_Operation (E) then
Set_Is_Immediately_Visible (E, False);
else
-- Work done in Override_Dispatching_Operation, so
-- nothing else needs to be done here.
null;
end if;
else
Remove_Entity_And_Homonym (E);
end if;
end if;
Enter_Overloaded_Entity (S);
-- For entities generated by Derive_Subprograms the
-- overridden operation is the inherited primitive
-- (which is available through the attribute alias).
if not (Comes_From_Source (E))
and then Is_Dispatching_Operation (E)
and then Find_Dispatching_Type (E) =
Find_Dispatching_Type (S)
and then Present (Alias (E))
and then Comes_From_Source (Alias (E))
then
Set_Overridden_Operation (S, Alias (E));
Inherit_Subprogram_Contract (S, Alias (E));
-- Normal case of setting entity as overridden
-- Note: Static_Initialization and Overridden_Operation
-- attributes use the same field in subprogram entities.
-- Static_Initialization is only defined for internal
-- initialization procedures, where Overridden_Operation
-- is irrelevant. Therefore the setting of this attribute
-- must check whether the target is an init_proc.
elsif not Is_Init_Proc (S) then
Set_Overridden_Operation (S, E);
Inherit_Subprogram_Contract (S, E);
end if;
Check_Overriding_Indicator (S, E, Is_Primitive => True);
-- The Ghost policy in effect at the point of declaration
-- of a parent subprogram and an overriding subprogram
-- must match (SPARK RM 6.9(17)).
Check_Ghost_Overriding (S, E);
-- If S is a user-defined subprogram or a null procedure
-- expanded to override an inherited null procedure, or a
-- predefined dispatching primitive then indicate that E
-- overrides the operation from which S is inherited.
if Comes_From_Source (S)
or else
(Present (Parent (S))
and then Nkind (Parent (S)) = N_Procedure_Specification
and then Null_Present (Parent (S)))
or else
(Present (Alias (E))
and then
Is_Predefined_Dispatching_Operation (Alias (E)))
then
if Present (Alias (E)) then
Set_Overridden_Operation (S, Alias (E));
Inherit_Subprogram_Contract (S, Alias (E));
end if;
end if;
if Is_Dispatching_Operation (E) then
-- An overriding dispatching subprogram inherits the
-- convention of the overridden subprogram (AI-117).
Set_Convention (S, Convention (E));
Check_Dispatching_Operation (S, E);
else
Check_Dispatching_Operation (S, Empty);
end if;
Check_For_Primitive_Subprogram
(Is_Primitive_Subp, Is_Overriding => True);
goto Check_Inequality;
-- Apparent redeclarations in instances can occur when two
-- formal types get the same actual type. The subprograms in
-- in the instance are legal, even if not callable from the
-- outside. Calls from within are disambiguated elsewhere.
-- For dispatching operations in the visible part, the usual
-- rules apply, and operations with the same profile are not
-- legal (B830001).
elsif (In_Instance_Visible_Part
and then not Is_Dispatching_Operation (E))
or else In_Instance_Not_Visible
then
null;
-- Here we have a real error (identical profile)
else
Error_Msg_Sloc := Sloc (E);
-- Avoid cascaded errors if the entity appears in
-- subsequent calls.
Set_Scope (S, Current_Scope);
-- Generate error, with extra useful warning for the case
-- of a generic instance with no completion.
if Is_Generic_Instance (S)
and then not Has_Completion (E)
then
Error_Msg_N
("instantiation cannot provide body for&", S);
Error_Msg_N ("\& conflicts with declaration#", S);
else
Error_Msg_N ("& conflicts with declaration#", S);
end if;
return;
end if;
else
-- If one subprogram has an access parameter and the other
-- a parameter of an access type, calls to either might be
-- ambiguous. Verify that parameters match except for the
-- access parameter.
if May_Hide_Profile then
declare
F1 : Entity_Id;
F2 : Entity_Id;
begin
F1 := First_Formal (S);
F2 := First_Formal (E);
while Present (F1) and then Present (F2) loop
if Is_Access_Type (Etype (F1)) then
if not Is_Access_Type (Etype (F2))
or else not Conforming_Types
(Designated_Type (Etype (F1)),
Designated_Type (Etype (F2)),
Type_Conformant)
then
May_Hide_Profile := False;
end if;
elsif
not Conforming_Types
(Etype (F1), Etype (F2), Type_Conformant)
then
May_Hide_Profile := False;
end if;
Next_Formal (F1);
Next_Formal (F2);
end loop;
if May_Hide_Profile
and then No (F1)
and then No (F2)
then
Error_Msg_NE ("calls to& may be ambiguous??", S, S);
end if;
end;
end if;
end if;
E := Homonym (E);
end loop;
-- On exit, we know that S is a new entity
Enter_Overloaded_Entity (S);
Check_For_Primitive_Subprogram (Is_Primitive_Subp);
Check_Overriding_Indicator
(S, Overridden_Subp, Is_Primitive => Is_Primitive_Subp);
-- The Ghost policy in effect at the point of declaration of a parent
-- subprogram and an overriding subprogram must match
-- (SPARK RM 6.9(17)).
Check_Ghost_Overriding (S, Overridden_Subp);
-- If S is a derived operation for an untagged type then by
-- definition it's not a dispatching operation (even if the parent
-- operation was dispatching), so Check_Dispatching_Operation is not
-- called in that case.
if No (Derived_Type)
or else Is_Tagged_Type (Derived_Type)
then
Check_Dispatching_Operation (S, Empty);
end if;
end if;
-- If this is a user-defined equality operator that is not a derived
-- subprogram, create the corresponding inequality. If the operation is
-- dispatching, the expansion is done elsewhere, and we do not create
-- an explicit inequality operation.
<<Check_Inequality>>
if Chars (S) = Name_Op_Eq
and then Etype (S) = Standard_Boolean
and then Present (Parent (S))
and then not Is_Dispatching_Operation (S)
then
Make_Inequality_Operator (S);
Check_Untagged_Equality (S);
end if;
end New_Overloaded_Entity;
----------------------------------
-- Preanalyze_Formal_Expression --
----------------------------------
procedure Preanalyze_Formal_Expression (N : Node_Id; T : Entity_Id) is
Save_In_Spec_Expression : constant Boolean := In_Spec_Expression;
begin
In_Spec_Expression := True;
Preanalyze_With_Freezing_And_Resolve (N, T);
In_Spec_Expression := Save_In_Spec_Expression;
end Preanalyze_Formal_Expression;
---------------------
-- Process_Formals --
---------------------
procedure Process_Formals
(T : List_Id;
Related_Nod : Node_Id)
is
function Designates_From_Limited_With (Typ : Entity_Id) return Boolean;
-- Determine whether an access type designates a type coming from a
-- limited view.
function Is_Class_Wide_Default (D : Node_Id) return Boolean;
-- Check whether the default has a class-wide type. After analysis the
-- default has the type of the formal, so we must also check explicitly
-- for an access attribute.
----------------------------------
-- Designates_From_Limited_With --
----------------------------------
function Designates_From_Limited_With (Typ : Entity_Id) return Boolean is
Desig : Entity_Id := Typ;
begin
if Is_Access_Type (Desig) then
Desig := Directly_Designated_Type (Desig);
end if;
if Is_Class_Wide_Type (Desig) then
Desig := Root_Type (Desig);
end if;
return
Ekind (Desig) = E_Incomplete_Type
and then From_Limited_With (Desig);
end Designates_From_Limited_With;
---------------------------
-- Is_Class_Wide_Default --
---------------------------
function Is_Class_Wide_Default (D : Node_Id) return Boolean is
begin
return Is_Class_Wide_Type (Designated_Type (Etype (D)))
or else (Nkind (D) = N_Attribute_Reference
and then Attribute_Name (D) = Name_Access
and then Is_Class_Wide_Type (Etype (Prefix (D))));
end Is_Class_Wide_Default;
-- Local variables
Context : constant Node_Id := Parent (Parent (T));
Default : Node_Id;
Formal : Entity_Id;
Formal_Type : Entity_Id;
Param_Spec : Node_Id;
Ptype : Entity_Id;
Num_Out_Params : Nat := 0;
First_Out_Param : Entity_Id := Empty;
-- Used for setting Is_Only_Out_Parameter
-- Start of processing for Process_Formals
begin
-- In order to prevent premature use of the formals in the same formal
-- part, the Ekind is left undefined until all default expressions are
-- analyzed. The Ekind is established in a separate loop at the end.
Param_Spec := First (T);
while Present (Param_Spec) loop
Formal := Defining_Identifier (Param_Spec);
Set_Never_Set_In_Source (Formal, True);
Enter_Name (Formal);
-- Case of ordinary parameters
if Nkind (Parameter_Type (Param_Spec)) /= N_Access_Definition then
Find_Type (Parameter_Type (Param_Spec));
Ptype := Parameter_Type (Param_Spec);
if Ptype = Error then
goto Continue;
end if;
-- Protect against malformed parameter types
if Nkind (Ptype) not in N_Has_Entity then
Formal_Type := Any_Type;
else
Formal_Type := Entity (Ptype);
end if;
if Is_Incomplete_Type (Formal_Type)
or else
(Is_Class_Wide_Type (Formal_Type)
and then Is_Incomplete_Type (Root_Type (Formal_Type)))
then
-- Ada 2005 (AI-326): Tagged incomplete types allowed in
-- primitive operations, as long as their completion is
-- in the same declarative part. If in the private part
-- this means that the type cannot be a Taft-amendment type.
-- Check is done on package exit. For access to subprograms,
-- the use is legal for Taft-amendment types.
-- Ada 2012: tagged incomplete types are allowed as generic
-- formal types. They do not introduce dependencies and the
-- corresponding generic subprogram does not have a delayed
-- freeze, because it does not need a freeze node. However,
-- it is still the case that untagged incomplete types cannot
-- be Taft-amendment types and must be completed in private
-- part, so the subprogram must appear in the list of private
-- dependents of the type.
if Is_Tagged_Type (Formal_Type)
or else (Ada_Version >= Ada_2012
and then not From_Limited_With (Formal_Type)
and then not Is_Generic_Type (Formal_Type))
then
if Ekind (Scope (Current_Scope)) = E_Package
and then not Is_Generic_Type (Formal_Type)
and then not Is_Class_Wide_Type (Formal_Type)
then
if Nkind (Parent (T)) not in
N_Access_Function_Definition |
N_Access_Procedure_Definition
then
Append_Elmt (Current_Scope,
Private_Dependents (Base_Type (Formal_Type)));
-- Freezing is delayed to ensure that Register_Prim
-- will get called for this operation, which is needed
-- in cases where static dispatch tables aren't built.
-- (Note that the same is done for controlling access
-- parameter cases in function Access_Definition.)
if not Is_Thunk (Current_Scope) then
Set_Has_Delayed_Freeze (Current_Scope);
end if;
end if;
end if;
elsif Nkind (Parent (T)) not in N_Access_Function_Definition
| N_Access_Procedure_Definition
then
-- AI05-0151: Tagged incomplete types are allowed in all
-- formal parts. Untagged incomplete types are not allowed
-- in bodies. Limited views of either kind are not allowed
-- if there is no place at which the non-limited view can
-- become available.
-- Incomplete formal untagged types are not allowed in
-- subprogram bodies (but are legal in their declarations).
-- This excludes bodies created for null procedures, which
-- are basic declarations.
if Is_Generic_Type (Formal_Type)
and then not Is_Tagged_Type (Formal_Type)
and then Nkind (Parent (Related_Nod)) = N_Subprogram_Body
then
Error_Msg_N
("invalid use of formal incomplete type", Param_Spec);
elsif Ada_Version >= Ada_2012 then
if Is_Tagged_Type (Formal_Type)
and then (not From_Limited_With (Formal_Type)
or else not In_Package_Body)
then
null;
elsif Nkind (Context) in N_Accept_Statement
| N_Accept_Alternative
| N_Entry_Body
or else (Nkind (Context) = N_Subprogram_Body
and then Comes_From_Source (Context))
then
Error_Msg_NE
("invalid use of untagged incomplete type &",
Ptype, Formal_Type);
end if;
else
Error_Msg_NE
("invalid use of incomplete type&",
Param_Spec, Formal_Type);
-- Further checks on the legality of incomplete types
-- in formal parts are delayed until the freeze point
-- of the enclosing subprogram or access to subprogram.
end if;
end if;
elsif Ekind (Formal_Type) = E_Void then
Error_Msg_NE
("premature use of&",
Parameter_Type (Param_Spec), Formal_Type);
end if;
-- Ada 2012 (AI-142): Handle aliased parameters
if Ada_Version >= Ada_2012
and then Aliased_Present (Param_Spec)
then
Set_Is_Aliased (Formal);
-- AI12-001: All aliased objects are considered to be specified
-- as independently addressable (RM C.6(8.1/4)).
Set_Is_Independent (Formal);
end if;
-- Ada 2005 (AI-231): Create and decorate an internal subtype
-- declaration corresponding to the null-excluding type of the
-- formal in the enclosing scope. Finally, replace the parameter
-- type of the formal with the internal subtype.
if Ada_Version >= Ada_2005
and then Null_Exclusion_Present (Param_Spec)
then
if not Is_Access_Type (Formal_Type) then
Error_Msg_N
("`NOT NULL` allowed only for an access type", Param_Spec);
else
if Can_Never_Be_Null (Formal_Type)
and then Comes_From_Source (Related_Nod)
then
Error_Msg_NE
("`NOT NULL` not allowed (& already excludes null)",
Param_Spec, Formal_Type);
end if;
Formal_Type :=
Create_Null_Excluding_Itype
(T => Formal_Type,
Related_Nod => Related_Nod,
Scope_Id => Scope (Current_Scope));
-- If the designated type of the itype is an itype that is
-- not frozen yet, we set the Has_Delayed_Freeze attribute
-- on the access subtype, to prevent order-of-elaboration
-- issues in the backend.
-- Example:
-- type T is access procedure;
-- procedure Op (O : not null T);
if Is_Itype (Directly_Designated_Type (Formal_Type))
and then
not Is_Frozen (Directly_Designated_Type (Formal_Type))
then
Set_Has_Delayed_Freeze (Formal_Type);
end if;
end if;
end if;
-- An access formal type
else
Formal_Type :=
Access_Definition (Related_Nod, Parameter_Type (Param_Spec));
-- No need to continue if we already notified errors
if not Present (Formal_Type) then
return;
end if;
-- Ada 2005 (AI-254)
declare
AD : constant Node_Id :=
Access_To_Subprogram_Definition
(Parameter_Type (Param_Spec));
begin
if Present (AD) and then Protected_Present (AD) then
Formal_Type :=
Replace_Anonymous_Access_To_Protected_Subprogram
(Param_Spec);
end if;
end;
end if;
Set_Etype (Formal, Formal_Type);
-- Deal with default expression if present
Default := Expression (Param_Spec);
if Present (Default) then
if Out_Present (Param_Spec) then
Error_Msg_N
("default initialization only allowed for IN parameters",
Param_Spec);
end if;
-- Do the special preanalysis of the expression (see section on
-- "Handling of Default Expressions" in the spec of package Sem).
Preanalyze_Formal_Expression (Default, Formal_Type);
-- An access to constant cannot be the default for
-- an access parameter that is an access to variable.
if Ekind (Formal_Type) = E_Anonymous_Access_Type
and then not Is_Access_Constant (Formal_Type)
and then Is_Access_Type (Etype (Default))
and then Is_Access_Constant (Etype (Default))
then
Error_Msg_N
("formal that is access to variable cannot be initialized "
& "with an access-to-constant expression", Default);
end if;
-- Check that the designated type of an access parameter's default
-- is not a class-wide type unless the parameter's designated type
-- is also class-wide.
if Ekind (Formal_Type) = E_Anonymous_Access_Type
and then not Designates_From_Limited_With (Formal_Type)
and then Is_Class_Wide_Default (Default)
and then not Is_Class_Wide_Type (Designated_Type (Formal_Type))
then
Error_Msg_N
("access to class-wide expression not allowed here", Default);
end if;
-- Check incorrect use of dynamically tagged expressions
if Is_Tagged_Type (Formal_Type) then
Check_Dynamically_Tagged_Expression
(Expr => Default,
Typ => Formal_Type,
Related_Nod => Default);
end if;
end if;
-- Ada 2005 (AI-231): Static checks
if Ada_Version >= Ada_2005
and then Is_Access_Type (Etype (Formal))
and then Can_Never_Be_Null (Etype (Formal))
then
Null_Exclusion_Static_Checks (Param_Spec);
end if;
-- The following checks are relevant only when SPARK_Mode is on as
-- these are not standard Ada legality rules.
if SPARK_Mode = On then
if Ekind (Scope (Formal)) in E_Function | E_Generic_Function then
-- A function cannot have a parameter of mode IN OUT or OUT
-- (SPARK RM 6.1).
if Ekind (Formal) in E_In_Out_Parameter | E_Out_Parameter then
Error_Msg_N
("function cannot have parameter of mode `OUT` or "
& "`IN OUT`", Formal);
end if;
-- A procedure cannot have an effectively volatile formal
-- parameter of mode IN because it behaves as a constant
-- (SPARK RM 7.1.3(4)).
elsif Ekind (Scope (Formal)) = E_Procedure
and then Ekind (Formal) = E_In_Parameter
and then Is_Effectively_Volatile (Formal)
then
Error_Msg_N
("formal parameter of mode `IN` cannot be volatile", Formal);
end if;
end if;
-- Deal with aspects on formal parameters. Only Unreferenced is
-- supported for the time being.
if Has_Aspects (Param_Spec) then
declare
Aspect : Node_Id := First (Aspect_Specifications (Param_Spec));
begin
while Present (Aspect) loop
if Chars (Identifier (Aspect)) = Name_Unreferenced then
Set_Has_Pragma_Unreferenced (Formal);
else
Error_Msg_NE
("unsupported aspect& on parameter",
Aspect, Identifier (Aspect));
end if;
Next (Aspect);
end loop;
end;
end if;
<<Continue>>
Next (Param_Spec);
end loop;
-- If this is the formal part of a function specification, analyze the
-- subtype mark in the context where the formals are visible but not
-- yet usable, and may hide outer homographs.
if Nkind (Related_Nod) = N_Function_Specification then
Analyze_Return_Type (Related_Nod);
end if;
-- Now set the kind (mode) of each formal
Param_Spec := First (T);
while Present (Param_Spec) loop
Formal := Defining_Identifier (Param_Spec);
Set_Formal_Mode (Formal);
if Ekind (Formal) = E_In_Parameter then
Set_Default_Value (Formal, Expression (Param_Spec));
if Present (Expression (Param_Spec)) then
Default := Expression (Param_Spec);
if Is_Scalar_Type (Etype (Default)) then
if Nkind (Parameter_Type (Param_Spec)) /=
N_Access_Definition
then
Formal_Type := Entity (Parameter_Type (Param_Spec));
else
Formal_Type :=
Access_Definition
(Related_Nod, Parameter_Type (Param_Spec));
end if;
Apply_Scalar_Range_Check (Default, Formal_Type);
end if;
end if;
elsif Ekind (Formal) = E_Out_Parameter then
Num_Out_Params := Num_Out_Params + 1;
if Num_Out_Params = 1 then
First_Out_Param := Formal;
end if;
elsif Ekind (Formal) = E_In_Out_Parameter then
Num_Out_Params := Num_Out_Params + 1;
end if;
-- Skip remaining processing if formal type was in error
if Etype (Formal) = Any_Type or else Error_Posted (Formal) then
goto Next_Parameter;
end if;
-- Force call by reference if aliased
declare
Conv : constant Convention_Id := Convention (Etype (Formal));
begin
if Is_Aliased (Formal) then
Set_Mechanism (Formal, By_Reference);
-- Warn if user asked this to be passed by copy
if Conv = Convention_Ada_Pass_By_Copy then
Error_Msg_N
("cannot pass aliased parameter & by copy??", Formal);
end if;
-- Force mechanism if type has Convention Ada_Pass_By_Ref/Copy
elsif Conv = Convention_Ada_Pass_By_Copy then
Set_Mechanism (Formal, By_Copy);
elsif Conv = Convention_Ada_Pass_By_Reference then
Set_Mechanism (Formal, By_Reference);
end if;
end;
<<Next_Parameter>>
Next (Param_Spec);
end loop;
if Present (First_Out_Param) and then Num_Out_Params = 1 then
Set_Is_Only_Out_Parameter (First_Out_Param);
end if;
end Process_Formals;
----------------------------
-- Reference_Body_Formals --
----------------------------
procedure Reference_Body_Formals (Spec : Entity_Id; Bod : Entity_Id) is
Fs : Entity_Id;
Fb : Entity_Id;
begin
if Error_Posted (Spec) then
return;
end if;
-- Iterate over both lists. They may be of different lengths if the two
-- specs are not conformant.
Fs := First_Formal (Spec);
Fb := First_Formal (Bod);
while Present (Fs) and then Present (Fb) loop
Generate_Reference (Fs, Fb, 'b');
if Style_Check then
Style.Check_Identifier (Fb, Fs);
end if;
Set_Spec_Entity (Fb, Fs);
Set_Referenced (Fs, False);
Next_Formal (Fs);
Next_Formal (Fb);
end loop;
end Reference_Body_Formals;
-------------------------
-- Set_Actual_Subtypes --
-------------------------
procedure Set_Actual_Subtypes (N : Node_Id; Subp : Entity_Id) is
Decl : Node_Id;
Formal : Entity_Id;
T : Entity_Id;
First_Stmt : Node_Id := Empty;
AS_Needed : Boolean;
begin
-- If this is an empty initialization procedure, no need to create
-- actual subtypes (small optimization).
if Ekind (Subp) = E_Procedure and then Is_Null_Init_Proc (Subp) then
return;
-- Within a predicate function we do not want to generate local
-- subtypes that may generate nested predicate functions.
elsif Is_Subprogram (Subp) and then Is_Predicate_Function (Subp) then
return;
end if;
-- The subtype declarations may freeze the formals. The body generated
-- for an expression function is not a freeze point, so do not emit
-- these declarations (small loss of efficiency in rare cases).
if Nkind (N) = N_Subprogram_Body
and then Was_Expression_Function (N)
then
return;
end if;
Formal := First_Formal (Subp);
while Present (Formal) loop
T := Etype (Formal);
-- We never need an actual subtype for a constrained formal
if Is_Constrained (T) then
AS_Needed := False;
-- If we have unknown discriminants, then we do not need an actual
-- subtype, or more accurately we cannot figure it out. Note that
-- all class-wide types have unknown discriminants.
elsif Has_Unknown_Discriminants (T) then
AS_Needed := False;
-- At this stage we have an unconstrained type that may need an
-- actual subtype. For sure the actual subtype is needed if we have
-- an unconstrained array type. However, in an instance, the type
-- may appear as a subtype of the full view, while the actual is
-- in fact private (in which case no actual subtype is needed) so
-- check the kind of the base type.
elsif Is_Array_Type (Base_Type (T)) then
AS_Needed := True;
-- The only other case needing an actual subtype is an unconstrained
-- record type which is an IN parameter (we cannot generate actual
-- subtypes for the OUT or IN OUT case, since an assignment can
-- change the discriminant values. However we exclude the case of
-- initialization procedures, since discriminants are handled very
-- specially in this context, see the section entitled "Handling of
-- Discriminants" in Einfo.
-- We also exclude the case of Discrim_SO_Functions (functions used
-- in front-end layout mode for size/offset values), since in such
-- functions only discriminants are referenced, and not only are such
-- subtypes not needed, but they cannot always be generated, because
-- of order of elaboration issues.
elsif Is_Record_Type (T)
and then Ekind (Formal) = E_In_Parameter
and then Chars (Formal) /= Name_uInit
and then not Is_Unchecked_Union (T)
and then not Is_Discrim_SO_Function (Subp)
then
AS_Needed := True;
-- All other cases do not need an actual subtype
else
AS_Needed := False;
end if;
-- Generate actual subtypes for unconstrained arrays and
-- unconstrained discriminated records.
if AS_Needed then
if Nkind (N) = N_Accept_Statement then
-- If expansion is active, the formal is replaced by a local
-- variable that renames the corresponding entry of the
-- parameter block, and it is this local variable that may
-- require an actual subtype.
if Expander_Active then
Decl := Build_Actual_Subtype (T, Renamed_Object (Formal));
else
Decl := Build_Actual_Subtype (T, Formal);
end if;
if Present (Handled_Statement_Sequence (N)) then
First_Stmt :=
First (Statements (Handled_Statement_Sequence (N)));
Prepend (Decl, Statements (Handled_Statement_Sequence (N)));
Mark_Rewrite_Insertion (Decl);
else
-- If the accept statement has no body, there will be no
-- reference to the actuals, so no need to compute actual
-- subtypes.
return;
end if;
else
Decl := Build_Actual_Subtype (T, Formal);
Prepend (Decl, Declarations (N));
Mark_Rewrite_Insertion (Decl);
end if;
-- The declaration uses the bounds of an existing object, and
-- therefore needs no constraint checks.
Analyze (Decl, Suppress => All_Checks);
Set_Is_Actual_Subtype (Defining_Identifier (Decl));
-- We need to freeze manually the generated type when it is
-- inserted anywhere else than in a declarative part.
if Present (First_Stmt) then
Insert_List_Before_And_Analyze (First_Stmt,
Freeze_Entity (Defining_Identifier (Decl), N));
-- Ditto if the type has a dynamic predicate, because the
-- generated function will mention the actual subtype. The
-- predicate may come from an explicit aspect of be inherited.
elsif Has_Predicates (T) then
Insert_List_After_And_Analyze (Decl,
Freeze_Entity (Defining_Identifier (Decl), N));
end if;
if Nkind (N) = N_Accept_Statement
and then Expander_Active
then
Set_Actual_Subtype (Renamed_Object (Formal),
Defining_Identifier (Decl));
else
Set_Actual_Subtype (Formal, Defining_Identifier (Decl));
end if;
end if;
Next_Formal (Formal);
end loop;
end Set_Actual_Subtypes;
---------------------
-- Set_Formal_Mode --
---------------------
procedure Set_Formal_Mode (Formal_Id : Entity_Id) is
Spec : constant Node_Id := Parent (Formal_Id);
Id : constant Entity_Id := Scope (Formal_Id);
begin
-- Note: we set Is_Known_Valid for IN parameters and IN OUT parameters
-- since we ensure that corresponding actuals are always valid at the
-- point of the call.
if Out_Present (Spec) then
if Is_Entry (Id)
or else Is_Subprogram_Or_Generic_Subprogram (Id)
then
Set_Has_Out_Or_In_Out_Parameter (Id, True);
end if;
if Ekind (Id) in E_Function | E_Generic_Function then
-- [IN] OUT parameters allowed for functions in Ada 2012
if Ada_Version >= Ada_2012 then
-- Even in Ada 2012 operators can only have IN parameters
if Is_Operator_Symbol_Name (Chars (Scope (Formal_Id))) then
Error_Msg_N ("operators can only have IN parameters", Spec);
end if;
if In_Present (Spec) then
Set_Ekind (Formal_Id, E_In_Out_Parameter);
else
Set_Ekind (Formal_Id, E_Out_Parameter);
end if;
-- But not in earlier versions of Ada
else
Error_Msg_N ("functions can only have IN parameters", Spec);
Set_Ekind (Formal_Id, E_In_Parameter);
end if;
elsif In_Present (Spec) then
Set_Ekind (Formal_Id, E_In_Out_Parameter);
else
Set_Ekind (Formal_Id, E_Out_Parameter);
Set_Never_Set_In_Source (Formal_Id, True);
Set_Is_True_Constant (Formal_Id, False);
Set_Current_Value (Formal_Id, Empty);
end if;
else
Set_Ekind (Formal_Id, E_In_Parameter);
end if;
-- Set Is_Known_Non_Null for access parameters since the language
-- guarantees that access parameters are always non-null. We also set
-- Can_Never_Be_Null, since there is no way to change the value.
if Nkind (Parameter_Type (Spec)) = N_Access_Definition then
-- Ada 2005 (AI-231): In Ada 95, access parameters are always non-
-- null; In Ada 2005, only if then null_exclusion is explicit.
if Ada_Version < Ada_2005
or else Can_Never_Be_Null (Etype (Formal_Id))
then
Set_Is_Known_Non_Null (Formal_Id);
Set_Can_Never_Be_Null (Formal_Id);
end if;
-- Ada 2005 (AI-231): Null-exclusion access subtype
elsif Is_Access_Type (Etype (Formal_Id))
and then Can_Never_Be_Null (Etype (Formal_Id))
then
Set_Is_Known_Non_Null (Formal_Id);
-- We can also set Can_Never_Be_Null (thus preventing some junk
-- access checks) for the case of an IN parameter, which cannot
-- be changed, or for an IN OUT parameter, which can be changed but
-- not to a null value. But for an OUT parameter, the initial value
-- passed in can be null, so we can't set this flag in that case.
if Ekind (Formal_Id) /= E_Out_Parameter then
Set_Can_Never_Be_Null (Formal_Id);
end if;
end if;
Set_Mechanism (Formal_Id, Default_Mechanism);
Set_Formal_Validity (Formal_Id);
end Set_Formal_Mode;
-------------------------
-- Set_Formal_Validity --
-------------------------
procedure Set_Formal_Validity (Formal_Id : Entity_Id) is
begin
-- If no validity checking, then we cannot assume anything about the
-- validity of parameters, since we do not know there is any checking
-- of the validity on the call side.
if not Validity_Checks_On then
return;
-- If validity checking for parameters is enabled, this means we are
-- not supposed to make any assumptions about argument values.
elsif Validity_Check_Parameters then
return;
-- If we are checking in parameters, we will assume that the caller is
-- also checking parameters, so we can assume the parameter is valid.
elsif Ekind (Formal_Id) = E_In_Parameter
and then Validity_Check_In_Params
then
Set_Is_Known_Valid (Formal_Id, True);
-- Similar treatment for IN OUT parameters
elsif Ekind (Formal_Id) = E_In_Out_Parameter
and then Validity_Check_In_Out_Params
then
Set_Is_Known_Valid (Formal_Id, True);
end if;
end Set_Formal_Validity;
------------------------
-- Subtype_Conformant --
------------------------
function Subtype_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Skip_Controlling_Formals : Boolean := False) return Boolean
is
Result : Boolean;
begin
Check_Conformance (New_Id, Old_Id, Subtype_Conformant, False, Result,
Skip_Controlling_Formals => Skip_Controlling_Formals);
return Result;
end Subtype_Conformant;
---------------------
-- Type_Conformant --
---------------------
function Type_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Skip_Controlling_Formals : Boolean := False) return Boolean
is
Result : Boolean;
begin
May_Hide_Profile := False;
Check_Conformance
(New_Id, Old_Id, Type_Conformant, False, Result,
Skip_Controlling_Formals => Skip_Controlling_Formals);
return Result;
end Type_Conformant;
-------------------------------
-- Valid_Operator_Definition --
-------------------------------
procedure Valid_Operator_Definition (Designator : Entity_Id) is
N : Integer := 0;
F : Entity_Id;
Id : constant Name_Id := Chars (Designator);
N_OK : Boolean;
begin
F := First_Formal (Designator);
while Present (F) loop
N := N + 1;
if Present (Default_Value (F)) then
Error_Msg_N
("default values not allowed for operator parameters",
Parent (F));
-- For function instantiations that are operators, we must check
-- separately that the corresponding generic only has in-parameters.
-- For subprogram declarations this is done in Set_Formal_Mode. Such
-- an error could not arise in earlier versions of the language.
elsif Ekind (F) /= E_In_Parameter then
Error_Msg_N ("operators can only have IN parameters", F);
end if;
Next_Formal (F);
end loop;
-- Verify that user-defined operators have proper number of arguments
-- First case of operators which can only be unary
if Id in Name_Op_Not | Name_Op_Abs then
N_OK := (N = 1);
-- Case of operators which can be unary or binary
elsif Id in Name_Op_Add | Name_Op_Subtract then
N_OK := (N in 1 .. 2);
-- All other operators can only be binary
else
N_OK := (N = 2);
end if;
if not N_OK then
Error_Msg_N
("incorrect number of arguments for operator", Designator);
end if;
if Id = Name_Op_Ne
and then Base_Type (Etype (Designator)) = Standard_Boolean
and then not Is_Intrinsic_Subprogram (Designator)
then
Error_Msg_N
("explicit definition of inequality not allowed", Designator);
end if;
end Valid_Operator_Definition;
end Sem_Ch6;
|
source/asis/spec/annex_c/ada-interrupts.ads | faelys/gela-asis | 4 | 213 | ------------------------------------------------------------------------------
-- A d a r u n - t i m e s p e c i f i c a t i o n --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of ada.ads file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
with System;
package Ada.Interrupts is
type Interrupt_ID is (Implementation_Defined);
type Parameterless_Handler is access protected procedure;
function Is_Reserved (Interrupt : in Interrupt_ID) return Boolean;
function Is_Attached (Interrupt : in Interrupt_ID) return Boolean;
function Current_Handler (Interrupt : in Interrupt_ID)
return Parameterless_Handler;
procedure Attach_Handler (New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID);
procedure Exchange_Handler (Old_Handler : out Parameterless_Handler;
New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID);
procedure Detach_Handler (Interrupt : in Interrupt_ID);
function Reference (Interrupt : in Interrupt_ID) return System.Address;
private
end Ada.Interrupts;
|
src/rejuvenation-parameters.ads | TNO/Rejuvenation-Ada | 1 | 9787 | package Rejuvenation.Parameters is
function Param_Expressions
(Nm : Libadalang.Analysis.Name) return Param_Actual_Array with
Pre => not Nm.Is_Null and then Nm.P_Is_Call;
-- Returns the list of Param Expressions of a function call
-- including the default expressions for unspecified parameters
-- including the object name in case of a prefix notation
function Param_Expressions (Stat : Call_Stmt) return Param_Actual_Array;
-- function Param_Expressions (Id: Identifier) return Param_Actual_Array;
-- Returns the list of Param Expressions of a function call
-- including the default expressions for unspecified parameters
function Param_Expressions
(GPI : Generic_Package_Instantiation) return Param_Actual_Array;
-- Returns the list of Param Expressions of a generic package instantiation
-- including the default expressions for unspecified parameters
function Get_Expression
(The_Array : Param_Actual_Array; Name : String) return Expr'Class;
-- Return Expression associate with Name in the Param_Actual_Array.
-- Returns No_Expr when Name is absent in the Param_Actual_Array.
end Rejuvenation.Parameters;
|
oeis/028/A028910.asm | neoneye/loda-programs | 11 | 240846 | ; A028910: Arrange digits of 2^n in descending order.
; Submitted by <NAME>(r1)
; 1,2,4,8,61,32,64,821,652,521,4210,8420,9640,9821,86431,87632,66553,732110,644221,885422,8765410,9752210,9444310,8888630,77766211,55443332,88766410,877432211,866554432,987653210,8774432110,8876444321,9997664422,9998855432,99887764111,98876543333,98777666431,987754433321,998777644420,988887555431,9977766521110,9955553222210,9865444311100,9988763222000,98766544421110,88887543332210,87777666444310,888775544333210,987776665442110,999655443322211,9998866544222110,9988876554322211,9997766554433200
mov $1,2
pow $1,$0
seq $1,4186 ; Arrange digits of n in decreasing order.
mov $0,$1
|
bugs/bug10.ada | daveshields/AdaEd | 3 | 8188 | <gh_stars>1-10
procedure main is
aft : integer := 1;
s, str : string(1..3);
begin
s := "abc";
str((aft)..3) := s(1..3);
end;
|
Transynther/x86/_processed/US/_zr_/i7-7700_9_0x48_notsx.log_26_1553.asm | ljhsiun2/medusa | 9 | 15659 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %rbp
push %rdi
push %rdx
lea addresses_UC_ht+0xd782, %rdi
nop
nop
nop
and %rbp, %rbp
mov $0x6162636465666768, %rdx
movq %rdx, (%rdi)
cmp $55285, %rbp
pop %rdx
pop %rdi
pop %rbp
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r8
push %rax
push %rbp
push %rcx
push %rdi
// Store
lea addresses_normal+0x1e0aa, %rax
nop
nop
nop
nop
xor $12640, %rdi
movw $0x5152, (%rax)
nop
nop
dec %rbp
// Store
mov $0xa0a, %rdi
nop
add %rcx, %rcx
movl $0x51525354, (%rdi)
nop
nop
nop
nop
add %r8, %r8
// Store
lea addresses_US+0x1d22a, %rax
cmp $7650, %r14
movl $0x51525354, (%rax)
nop
nop
dec %rax
// Faulty Load
lea addresses_US+0x1d22a, %rdi
nop
nop
nop
nop
nop
and %rax, %rax
vmovups (%rdi), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %rcx
lea oracles, %r14
and $0xff, %rcx
shlq $12, %rcx
mov (%r14,%rcx,1), %rcx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_US', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_normal', 'congruent': 7}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_P', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_US', 'congruent': 0}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_US', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 1}, 'OP': 'STOR'}
{'00': 26}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
programs/oeis/299/A299283.asm | neoneye/loda | 22 | 245290 | ; A299283: Coordination sequence for "svh" 3D uniform tiling.
; 1,7,22,48,84,130,186,253,330,417,514,622,740,868,1006,1155,1314,1483,1662,1852,2052,2262,2482,2713,2954,3205,3466,3738,4020,4312,4614,4927,5250,5583,5926,6280,6644,7018,7402,7797,8202,8617,9042,9478,9924,10380,10846,11323,11810,12307,12814,13332,13860,14398,14946,15505,16074,16653,17242,17842,18452,19072,19702,20343,20994,21655,22326,23008,23700,24402,25114,25837,26570,27313,28066,28830,29604,30388,31182,31987,32802,33627,34462,35308,36164,37030,37906,38793,39690,40597,41514,42442,43380,44328,45286,46255,47234,48223,49222,50232
mov $4,$0
add $0,2
mov $2,1
lpb $0
mov $3,$0
sub $0,1
sub $1,$3
mul $3,2
trn $1,$3
add $1,$2
mov $3,$2
add $2,1
trn $3,3
lpe
sub $1,$3
sub $1,1
mov $5,$4
mov $7,$4
lpb $7
add $6,$5
sub $7,1
lpe
mov $5,$6
mov $8,5
lpb $8
add $1,$5
sub $8,1
lpe
mov $0,$1
|
Day-16/my_solution_of_problem-2.asm | MasumBhai/50-Day-challenge-with-Assembly-Language | 1 | 99594 | ;id - 201914044
;i tried to implement this (prime number between 1 to 10):
;for (int i=1;i<=10;i++){
; int ctr=0;
; for(int j=2;j<=(i-1);j++){
; if(i%j == 0){
; ctr++;
; break;
; }
; }
; if(ctr == 0 && i != 1){
; printf("%d",i);
; }
;}
;Somehow couldn't succeed
.model small
.stack 100h
include 'emu8086.inc'
.data
n_line db 0ah,0dh,"$" ;for new line
num dw 10d ;this is input
i dw 1d
j dw 2d
p dw ?
ctr db 0d
.code
main proc
mov ax,@data
mov ds,ax
xor cx,cx ;At first,i tried to clear all register
xor bx,bx
xor dx,dx
@procedure:
mov cx,num
cmp i,cx
ja @stop
mov ctr,0d
mov bx,i
dec bx
mov p,bx ;here p = i-1
xor bx,bx ;bx is used later,so i am clearing now
@inside:
mov bx,p
cmp j,bx
jg @inside_out
@main_part:
mov ax,i
cwd
div j
cmp ah,0d ;cheking if not having reminder
inc ctr
je @inside_out
inc j
jmp @inside
@inside_out:
cmp ctr,0d
je @next
jne @further
@next:
cmp i,1d
jne @print
@further:
inc i
jmp @procedure
@stop:
mov ah,4ch
int 21h ;terminate with return code
main endp
@print:
mov dx,i
add dx,48
mov ah,2
int 21h
jmp @further
end main
|
app/hack/cross_wait.asm | USN484259/COFUOS | 1 | 87865 | [bits 64]
get_thread equ 0x0100
wait_for equ 0x0134
create_thread equ 0x0120
exit_process equ 0x0210
section .text
main:
mov eax,get_thread
syscall
mov r8d,eax
mov rdx,waiter
xor r9,r9
mov eax,create_thread
syscall
shr rax,32
xor ecx,ecx
mov edx,eax
mov r8,rcx
mov r9,rcx
mov eax,wait_for
syscall
mov edx,eax
mov eax,exit_process
syscall
waiter:
xor rcx,rcx
; rdx as arg
mov r8,rcx
mov r9,rcx
mov eax,wait_for
syscall
mov edx,eax
mov eax,exit_process
syscall |
applescripts/play-genre.applescript | Tyilo/play-song | 0 | 1759 | -- plays selected genre in iTunes --
-- load workflow configuration
set config to load script POSIX file ((do shell script "pwd") & "/config.scpt")
-- plays all songs by the given genre
on playGenre(genreName)
global config
createWorkflowPlaylist() of config
disableShuffle() of config
set genreName to decodeXmlChars(genreName) of config
set theSongs to getGenreSongs(genreName) of config
playSongs(theSongs) of config
end playGenre
playGenre("{query}")
|
src/Generic/Test/Data/Vec.agda | turion/Generic | 30 | 12076 | <reponame>turion/Generic<gh_stars>10-100
module Generic.Test.Data.Vec where
open import Generic.Main
import Data.Vec as Vec
infixr 5 _∷ᵥ_
Vec : ∀ {α} -> Set α -> ℕ -> Set α
Vec = readData Vec.Vec
-- []ᵥ : ∀ {α} {A : Set α} -> Vec A 0
pattern []ᵥ = #₀ lrefl
-- _∷ᵥ_ : ∀ {n α} {A : Set α} -> A -> Vec A n -> Vec A (suc n)
pattern _∷ᵥ_ {n} x xs = !#₁ (relv n , relv x , xs , lrefl)
elimVec : ∀ {n α π} {A : Set α}
-> (P : ∀ {n} -> Vec A n -> Set π)
-> (∀ {n} {xs : Vec A n} x -> P xs -> P (x ∷ᵥ xs))
-> P []ᵥ
-> (xs : Vec A n)
-> P xs
elimVec P f z []ᵥ = z
elimVec P f z (x ∷ᵥ xs) = f x (elimVec P f z xs)
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_284.asm | ljhsiun2/medusa | 9 | 13267 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x1246f, %r9
nop
nop
nop
add %r11, %r11
movw $0x6162, (%r9)
nop
nop
nop
and $58631, %rbp
lea addresses_normal_ht+0xaf7f, %rcx
clflush (%rcx)
nop
nop
xor $50262, %rdi
vmovups (%rcx), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %r8
nop
nop
inc %rcx
lea addresses_WT_ht+0x3e7, %r8
nop
nop
nop
nop
nop
xor %r12, %r12
mov (%r8), %di
nop
nop
nop
nop
sub %r8, %r8
lea addresses_WC_ht+0x179b, %r8
dec %r12
and $0xffffffffffffffc0, %r8
movntdqa (%r8), %xmm1
vpextrq $1, %xmm1, %r9
nop
and %rbp, %rbp
lea addresses_normal_ht+0x159f, %rsi
lea addresses_WT_ht+0xf1f, %rdi
sub %r11, %r11
mov $18, %rcx
rep movsw
nop
nop
nop
nop
and $31063, %rsi
lea addresses_D_ht+0x1b41f, %r9
sub $31170, %r12
mov (%r9), %edi
nop
nop
nop
nop
nop
add $58788, %rbp
lea addresses_WT_ht+0x4adf, %rsi
lea addresses_A_ht+0x609f, %rdi
nop
nop
nop
sub %r11, %r11
mov $32, %rcx
rep movsq
nop
mfence
lea addresses_WC_ht+0x1b79f, %r12
clflush (%r12)
nop
nop
nop
nop
nop
and %r9, %r9
mov $0x6162636465666768, %rcx
movq %rcx, (%r12)
nop
nop
nop
nop
nop
and $29408, %r8
lea addresses_WC_ht+0x18f1f, %r12
clflush (%r12)
inc %r9
movb (%r12), %r8b
nop
dec %rsi
lea addresses_WT_ht+0x194df, %r11
nop
and %r9, %r9
mov (%r11), %r8w
nop
cmp %r11, %r11
lea addresses_UC_ht+0x5b9f, %r8
nop
nop
nop
nop
nop
inc %rsi
movb (%r8), %cl
nop
and $43141, %r8
lea addresses_D_ht+0xc1f, %rcx
nop
nop
xor $40375, %r9
mov $0x6162636465666768, %rdi
movq %rdi, (%rcx)
nop
nop
nop
and %r8, %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r15
push %r8
push %r9
push %rcx
push %rdi
// Faulty Load
lea addresses_D+0x13b1f, %r15
nop
nop
nop
add $20643, %rcx
vmovups (%r15), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %r8
lea oracles, %rdi
and $0xff, %r8
shlq $12, %r8
mov (%rdi,%r8,1), %r8
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r15
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_D', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 2, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 8, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 6, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': True, 'size': 1, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'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
*/
|
arch/ARM/STM32/driver_demos/demo_crc/src/demo_crc.adb | rocher/Ada_Drivers_Library | 192 | 20939 | <gh_stars>100-1000
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This program demonstrates use of the CRC processor on STM32F4x MCUs. (The
-- STM32F3 MCUs, among others, have additional CRC capabilities.)
-- The checksum for a given block of 32-bit words is calculated two ways and
-- then compared.
-- The checksum is first computed on the data block by calling a routine that
-- transfers the block content to the CRC processor in a loop, which is to say
-- that the CPU does the transfer. In the second approach, a different routine
-- is called. This second routine uses DMA to transfer the data block to
-- the CRC processor. Obviously for a large data block, this second approach
-- is far quicker.
-- The first routine includes a parameter that provides the checksum. The
-- second routine does not have this output parameter since the caller will
-- return before the transfer completes (in practice) and the checksum is
-- computed. Hence after calling the second routine the caller blocks,
-- waiting for the DMA transfer completion interrupt.
-- If the two checksums are equal then the green LED is turned on, otherwise
-- the red LED is turned on. Both checksum values are displayed.
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
with STM32.Device; use STM32.Device;
with STM32.Board; use STM32.Board;
with STM32.CRC; use STM32.CRC;
with STM32.CRC.DMA; use STM32.CRC.DMA;
with LCD_Std_Out; use LCD_Std_Out;
with HAL; use HAL;
with STM32.DMA; use STM32.DMA;
with Ada.Real_Time; use Ada.Real_Time;
with Memory_Transfer; use Memory_Transfer;
with Ada.Unchecked_Conversion;
with System;
procedure Demo_CRC is
Checksum_CPU : UInt32 := 0;
-- the checksum obtained by calling a routine that uses the CPU to transfer
-- the memory block to the CRC processor
Checksum_DMA : UInt32 := 0;
-- the checksum obtained by calling a routine that uses DMA to transfer the
-- memory block to the CRC processor
-- see the STM32Cube_FW_F4_V1.6.0\Projects\ CRC example for data and
-- expected CRC checksum value
Section1 : constant Block_32 :=
(16#00001021#, 16#20423063#, 16#408450A5#, 16#60C670E7#, 16#9129A14A#, 16#B16BC18C#,
16#D1ADE1CE#, 16#F1EF1231#, 16#32732252#, 16#52B54294#, 16#72F762D6#, 16#93398318#,
16#A35AD3BD#, 16#C39CF3FF#, 16#E3DE2462#, 16#34430420#, 16#64E674C7#, 16#44A45485#,
16#A56AB54B#, 16#85289509#, 16#F5CFC5AC#, 16#D58D3653#, 16#26721611#, 16#063076D7#,
16#569546B4#, 16#B75BA77A#, 16#97198738#, 16#F7DFE7FE#, 16#C7BC48C4#, 16#58E56886#,
16#78A70840#, 16#18612802#, 16#C9CCD9ED#, 16#E98EF9AF#, 16#89489969#, 16#A90AB92B#,
16#4AD47AB7#, 16#6A961A71#, 16#0A503A33#, 16#2A12DBFD#, 16#FBBFEB9E#, 16#9B798B58#,
16#BB3BAB1A#, 16#6CA67C87#, 16#5CC52C22#, 16#3C030C60#, 16#1C41EDAE#, 16#FD8FCDEC#,
16#AD2ABD0B#, 16#8D689D49#, 16#7E976EB6#, 16#5ED54EF4#, 16#2E321E51#, 16#0E70FF9F#);
Section2 : constant Block_32 :=
(16#EFBEDFDD#, 16#CFFCBF1B#, 16#9F598F78#, 16#918881A9#, 16#B1CAA1EB#, 16#D10CC12D#,
16#E16F1080#, 16#00A130C2#, 16#20E35004#, 16#40257046#, 16#83B99398#, 16#A3FBB3DA#,
16#C33DD31C#, 16#E37FF35E#, 16#129022F3#, 16#32D24235#, 16#52146277#, 16#7256B5EA#,
16#95A88589#, 16#F56EE54F#, 16#D52CC50D#, 16#34E224C3#, 16#04817466#, 16#64475424#,
16#4405A7DB#, 16#B7FA8799#, 16#E75FF77E#, 16#C71DD73C#, 16#26D336F2#, 16#069116B0#,
16#76764615#, 16#5634D94C#, 16#C96DF90E#, 16#E92F99C8#, 16#B98AA9AB#, 16#58444865#,
16#78066827#, 16#18C008E1#, 16#28A3CB7D#, 16#DB5CEB3F#, 16#FB1E8BF9#, 16#9BD8ABBB#,
16#4A755A54#, 16#6A377A16#, 16#0AF11AD0#, 16#2AB33A92#, 16#ED0FDD6C#, 16#CD4DBDAA#,
16#AD8B9DE8#, 16#8DC97C26#, 16#5C644C45#, 16#3CA22C83#, 16#1CE00CC1#, 16#EF1FFF3E#,
16#DF7CAF9B#, 16#BFBA8FD9#, 16#9FF86E17#, 16#7E364E55#, 16#2E933EB2#, 16#0ED11EF0#);
-- expected CRC value for the data above is 379E9F06 hex, or 933142278 dec
Expected_Checksum : constant UInt32 := 933142278;
Next_DMA_Interrupt : DMA_Interrupt;
procedure Panic with No_Return;
-- flash the on-board LEDs, indefinitely, to indicate a failure
procedure Panic is
begin
loop
Toggle_LEDs (All_LEDs);
delay until Clock + Milliseconds (100);
end loop;
end Panic;
begin
Clear_Screen;
Initialize_LEDs;
Enable_Clock (CRC_Unit);
-- get the checksum using the CPU to transfer memory to the CRC processor;
-- verify it is the expected value
Update_CRC (CRC_Unit, Input => Section1, Output => Checksum_CPU);
Update_CRC (CRC_Unit, Input => Section2, Output => Checksum_CPU);
Put_Line ("CRC:" & Checksum_CPU'Img);
if Checksum_CPU /= Expected_Checksum then
Panic;
end if;
-- get the checksum using DMA to transfer memory to the CRC processor
Enable_Clock (Controller);
Reset (Controller);
Reset_Calculator (CRC_Unit);
Update_CRC (CRC_Unit, Controller'Access, Stream, Input => Section1);
DMA_IRQ_Handler.Await_Event (Next_DMA_Interrupt);
if Next_DMA_Interrupt /= Transfer_Complete_Interrupt then
Panic;
end if;
-- In this code fragment we use the approach suited for the case in which
-- we are calculating the CRC for a section of system memory rather than a
-- block of application data. We pretend that Section2 is a memory section.
-- All we need is a known starting address and a known length. Given that,
-- we can create a view of it as if it is an object of type Block_32 (or
-- whichever block type is appropriate).
declare
subtype Memory_Section is Block_32 (1 .. Section2'Length);
type Section_Pointer is access all Memory_Section with Storage_Size => 0;
function As_Memory_Section_Reference is new Ada.Unchecked_Conversion
(Source => System.Address, Target => Section_Pointer);
begin
Update_CRC
(CRC_Unit,
Controller'Access,
Stream,
Input => As_Memory_Section_Reference (Section2'Address).all);
end;
DMA_IRQ_Handler.Await_Event (Next_DMA_Interrupt);
if Next_DMA_Interrupt /= Transfer_Complete_Interrupt then
Panic;
end if;
Checksum_DMA := Value (CRC_Unit);
Put_Line ("CRC:" & Checksum_DMA'Img);
-- verify the two checksums are identical (one of which is already verified
-- as the expected value)
if Checksum_CPU = Checksum_DMA then
Turn_On (Green_LED);
else
Turn_On (Red_LED);
end if;
loop
delay until Time_Last;
end loop;
end Demo_CRC;
|
src/datatype-util.agda | zmthy/cedille | 0 | 11029 | module datatype-util where
open import constants
open import ctxt
open import syntax-util
open import general-util
open import type-util
open import cedille-types
open import subst
open import rename
open import free-vars
{-# TERMINATING #-}
decompose-arrows : ctxt → type → params × type
decompose-arrows Γ (TpAbs me x atk T) =
let x' = fresh-var-new Γ x in
case decompose-arrows (ctxt-var-decl x' Γ) (rename-var Γ x x' T) of λ where
(ps , T') → Param me x' atk :: ps , T'
decompose-arrows Γ T = [] , T
decompose-ctr-type : ctxt → type → type × params × 𝕃 tmtp
decompose-ctr-type Γ T with decompose-arrows Γ T
...| ps , Tᵣ with decompose-tpapps Tᵣ
...| Tₕ , as = Tₕ , ps , as
{-# TERMINATING #-}
kind-to-indices : ctxt → kind → indices
kind-to-indices Γ (KdAbs x atk k) =
let x' = fresh-var-new Γ x in
Index x' atk :: kind-to-indices (ctxt-var-decl x' Γ) (rename-var Γ x x' k)
kind-to-indices Γ _ = []
rename-indices-h : ctxt → renamectxt → indices → 𝕃 tmtp → indices
rename-indices-h Γ ρ (Index x atk :: is) (ty :: tys) =
Index x' atk' ::
rename-indices-h (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') is tys
where
x' = fresh-var-renamectxt Γ ρ (maybe-else x id (is-var-unqual ty))
atk' = subst-renamectxt Γ ρ -tk atk
rename-indices-h Γ ρ (Index x atk :: is) [] =
let x' = fresh-var-renamectxt Γ ρ x in
Index x' (subst-renamectxt Γ ρ -tk atk) ::
rename-indices-h (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') is []
rename-indices-h _ _ [] _ = []
rename-indices : ctxt → indices → 𝕃 tmtp → indices
rename-indices Γ = rename-indices-h Γ empty-renamectxt
positivity : Set
positivity = 𝔹 × 𝔹 -- occurs positively × occurs negatively
pattern occurs-nil = ff , ff
pattern occurs-pos = tt , ff
pattern occurs-neg = ff , tt
pattern occurs-all = tt , tt
--positivity-inc : positivity → positivity
--positivity-dec : positivity → positivity
positivity-neg : positivity → positivity
positivity-add : positivity → positivity → positivity
--positivity-inc = map-fst λ _ → tt
--positivity-dec = map-snd λ _ → tt
positivity-neg = uncurry $ flip _,_
positivity-add (+ₘ , -ₘ) (+ₙ , -ₙ) = (+ₘ || +ₙ) , (-ₘ || -ₙ)
-- just tt = negative occurrence; just ff = not in the return type; nothing = okay
module positivity (x : var) where
open import conversion
not-free : ∀ {ed} → ⟦ ed ⟧ → maybe 𝔹
not-free = maybe-map (λ _ → tt) ∘' maybe-if ∘' is-free-in x
if-free : ∀ {ed} → ⟦ ed ⟧ → positivity
if-free t with is-free-in x t
...| f = f , f
if-free-args : args → positivity
if-free-args as with stringset-contains (free-vars-args as) x
...| f = f , f
hnf' : ∀ {ed} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧
hnf' Γ T = hnf Γ unfold-no-defs T
mtt = maybe-else tt id
mff = maybe-else ff id
posₒ = fst
negₒ = snd
occurs : positivity → maybe 𝔹
occurs p = maybe-if (negₒ p) >> just tt
{-# TERMINATING #-}
arrs+ : ctxt → type → maybe 𝔹
type+ : ctxt → type → positivity
kind+ : ctxt → kind → positivity
tpkd+ : ctxt → tpkd → positivity
tpapp+ : ctxt → type → positivity
arrs+ Γ (TpAbs me x' atk T) =
let Γ' = ctxt-var-decl x' Γ in
occurs (tpkd+ Γ $ hnf' Γ -tk atk) maybe-or arrs+ Γ' (hnf' Γ' T)
arrs+ Γ (TpApp T tT) = occurs (tpapp+ Γ $ hnf' Γ (TpApp T tT))
--arrs+ Γ T maybe-or (not-free -tT' tT)
arrs+ Γ (TpLam x' atk T) =
let Γ' = ctxt-var-decl x' Γ in
occurs (tpkd+ Γ $ hnf' Γ -tk atk) maybe-or arrs+ Γ' (hnf' Γ' T)
arrs+ Γ (TpVar x') = maybe-if (~ x =string x') >> just ff
arrs+ Γ T = just ff
type+ Γ (TpAbs me x' atk T) =
let Γ' = ctxt-var-decl x' Γ in
positivity-add (positivity-neg $ tpkd+ Γ $ hnf' Γ -tk atk) (type+ Γ' $ hnf' Γ' T)
type+ Γ (TpIota x' T T') =
let Γ' = ctxt-var-decl x' Γ in
positivity-add (type+ Γ $ hnf' Γ T) (type+ Γ' $ hnf' Γ' T')
type+ Γ (TpApp T tT) = tpapp+ Γ $ hnf' Γ $ TpApp T tT
type+ Γ (TpEq tₗ tᵣ) = occurs-nil
type+ Γ (TpHole _) = occurs-nil
type+ Γ (TpLam x' atk T)=
let Γ' = ctxt-var-decl x' Γ in
positivity-add (positivity-neg $ tpkd+ Γ $ hnf' Γ -tk atk) (type+ Γ' (hnf' Γ' T))
type+ Γ (TpVar x') = x =string x' , ff
tpapp+ Γ T with decompose-tpapps T
...| TpVar x' , as =
let f = if-free-args (tmtps-to-args NotErased as) in
if x =string x'
then positivity-add occurs-pos f
else maybe-else' (data-lookup Γ x' as) f
λ {(mk-data-info x'' xₒ'' asₚ asᵢ ps kᵢ k cs csₚₛ eds gds) →
type+ Γ (hnf' Γ $ TpAbs tt x'' (Tkk k) $ foldr (uncurry λ cₓ cₜ → TpAbs ff ignored-var (Tkt cₜ)) (TpVar x'') (inst-ctrs Γ ps asₚ cs))}
...| _ , _ = if-free T
kind+ Γ (KdAbs x' atk k) =
let Γ' = ctxt-var-decl x' Γ in
positivity-add (positivity-neg $ tpkd+ Γ $ hnf' Γ -tk atk) (kind+ Γ' k)
kind+ Γ _ = occurs-nil
tpkd+ Γ (Tkt T) = type+ Γ (hnf' Γ T)
tpkd+ Γ (Tkk k) = kind+ Γ k
ctr-positive : ctxt → type → maybe 𝔹
ctr-positive Γ = arrs+ Γ ∘ hnf' Γ
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.