max_stars_repo_path stringlengths 4 261 | max_stars_repo_name stringlengths 6 106 | max_stars_count int64 0 38.8k | id stringlengths 1 6 | text stringlengths 7 1.05M |
|---|---|---|---|---|
programs/oeis/040/A040131.asm | karttu/loda | 0 | 174090 | <filename>programs/oeis/040/A040131.asm<gh_stars>0
; A040131: Continued fraction for sqrt(143).
; 11,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1
mov $1,11
lpb $0,1
mod $0,2
mul $1,2
lpe
gcd $1,$0
|
Day_1/code/constants.asm | hayrapetyan-armine/Assembly_ITC | 0 | 169798 | <reponame>hayrapetyan-armine/Assembly_ITC
SYS_EXIT equ 1
SYS_WRITE equ 4
STDIN equ 0
STDOUT equ 1
section .text
global _start ;must be declared for using gcc
_start: ;tell linker entry point
mov eax, SYS_WRITE
mov ebx, STDOUT
mov ecx, msg1
mov edx, len1
int 0x80
mov eax, SYS_WRITE
mov ebx, STDOUT
mov ecx, msg2
mov edx, len2
int 0x80
mov eax, SYS_WRITE
mov ebx, STDOUT
mov ecx, msg3
mov edx, len3
int 0x80
mov eax,SYS_EXIT ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg1 db 'Hello, programmers!',0xA,0xD
len1 equ $ - msg1
msg2 db 'Welcome to the world of,', 0xA,0xD
len2 equ $ - msg2
msg3 db 'Linux assembly programming! '
len3 equ $- msg3
|
data/mapHeaders/mtmoon3.asm | adhi-thirumala/EvoYellow | 16 | 90542 | <reponame>adhi-thirumala/EvoYellow
MtMoon3_h:
db CAVERN ; tileset
db MT_MOON_3_HEIGHT, MT_MOON_3_WIDTH ; dimensions (y, x)
dw MtMoon3Blocks, MtMoon3TextPointers, MtMoon3Script ; blocks, texts, scripts
db $00 ; connections
dw MtMoon3Object ; objects
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/exp_ch6.adb | djamal2727/Main-Bearing-Analytical-Model | 0 | 9399 | <filename>Validation/pyFrame3DD-master/gcc-master/gcc/ada/exp_ch6.adb
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ 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 Atree; use Atree;
with Aspects; use Aspects;
with Checks; use Checks;
with Contracts; use Contracts;
with Debug; use Debug;
with Einfo; use Einfo;
with Errout; use Errout;
with Elists; use Elists;
with Expander; use Expander;
with Exp_Aggr; use Exp_Aggr;
with Exp_Atag; use Exp_Atag;
with Exp_Ch2; use Exp_Ch2;
with Exp_Ch3; use Exp_Ch3;
with Exp_Ch7; use Exp_Ch7;
with Exp_Ch9; use Exp_Ch9;
with Exp_Dbug; use Exp_Dbug;
with Exp_Disp; use Exp_Disp;
with Exp_Dist; use Exp_Dist;
with Exp_Intr; use Exp_Intr;
with Exp_Pakd; use Exp_Pakd;
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Freeze; use Freeze;
with Inline; use Inline;
with Itypes; use Itypes;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Restrict; use Restrict;
with Rident; use Rident;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8;
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_Eval; use Sem_Eval;
with Sem_Mech; use Sem_Mech;
with Sem_Res; use Sem_Res;
with Sem_SCIL; use Sem_SCIL;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand; use Stand;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
with Validsw; use Validsw;
package body Exp_Ch6 is
-- Suffix for BIP formals
BIP_Alloc_Suffix : constant String := "BIPalloc";
BIP_Storage_Pool_Suffix : constant String := "BIPstoragepool";
BIP_Finalization_Master_Suffix : constant String := "BIPfinalizationmaster";
BIP_Task_Master_Suffix : constant String := "BIPtaskmaster";
BIP_Activation_Chain_Suffix : constant String := "BIPactivationchain";
BIP_Object_Access_Suffix : constant String := "BIPaccess";
-----------------------
-- Local Subprograms --
-----------------------
procedure Add_Access_Actual_To_Build_In_Place_Call
(Function_Call : Node_Id;
Function_Id : Entity_Id;
Return_Object : Node_Id;
Is_Access : Boolean := False);
-- Ada 2005 (AI-318-02): Apply the Unrestricted_Access attribute to the
-- object name given by Return_Object and add the attribute to the end of
-- the actual parameter list associated with the build-in-place function
-- call denoted by Function_Call. However, if Is_Access is True, then
-- Return_Object is already an access expression, in which case it's passed
-- along directly to the build-in-place function. Finally, if Return_Object
-- is empty, then pass a null literal as the actual.
procedure Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Function_Call : Node_Id;
Function_Id : Entity_Id;
Alloc_Form : BIP_Allocation_Form := Unspecified;
Alloc_Form_Exp : Node_Id := Empty;
Pool_Actual : Node_Id := Make_Null (No_Location));
-- Ada 2005 (AI-318-02): Add the actuals needed for a build-in-place
-- function call that returns a caller-unknown-size result (BIP_Alloc_Form
-- and BIP_Storage_Pool). If Alloc_Form_Exp is present, then use it,
-- otherwise pass a literal corresponding to the Alloc_Form parameter
-- (which must not be Unspecified in that case). Pool_Actual is the
-- parameter to pass to BIP_Storage_Pool.
procedure Add_Finalization_Master_Actual_To_Build_In_Place_Call
(Func_Call : Node_Id;
Func_Id : Entity_Id;
Ptr_Typ : Entity_Id := Empty;
Master_Exp : Node_Id := Empty);
-- Ada 2005 (AI-318-02): If the result type of a build-in-place call needs
-- finalization actions, add an actual parameter which is a pointer to the
-- finalization master of the caller. If Master_Exp is not Empty, then that
-- will be passed as the actual. Otherwise, if Ptr_Typ is left Empty, this
-- will result in an automatic "null" value for the actual.
procedure Add_Task_Actuals_To_Build_In_Place_Call
(Function_Call : Node_Id;
Function_Id : Entity_Id;
Master_Actual : Node_Id;
Chain : Node_Id := Empty);
-- Ada 2005 (AI-318-02): For a build-in-place call, if the result type
-- contains tasks, add two actual parameters: the master, and a pointer to
-- the caller's activation chain. Master_Actual is the actual parameter
-- expression to pass for the master. In most cases, this is the current
-- master (_master). The two exceptions are: If the function call is the
-- initialization expression for an allocator, we pass the master of the
-- access type. If the function call is the initialization expression for a
-- return object, we pass along the master passed in by the caller. In most
-- contexts, the activation chain to pass is the local one, which is
-- indicated by No (Chain). However, in an allocator, the caller passes in
-- the activation Chain. Note: Master_Actual can be Empty, but only if
-- there are no tasks.
procedure Apply_CW_Accessibility_Check (Exp : Node_Id; Func : Entity_Id);
-- Ada 2005 (AI95-344): If the result type is class-wide, insert a check
-- that the level of the return expression's underlying type is not deeper
-- than the level of the master enclosing the function. Always generate the
-- check when the type of the return expression is class-wide, when it's a
-- type conversion, or when it's a formal parameter. Otherwise suppress the
-- check in the case where the return expression has a specific type whose
-- level is known not to be statically deeper than the result type of the
-- function.
function Caller_Known_Size
(Func_Call : Node_Id;
Result_Subt : Entity_Id) return Boolean;
-- True if result subtype is definite, or has a size that does not require
-- secondary stack usage (i.e. no variant part or components whose type
-- depends on discriminants). In particular, untagged types with only
-- access discriminants do not require secondary stack use. Note we must
-- always use the secondary stack for dispatching-on-result calls.
function Check_BIP_Actuals
(Subp_Call : Node_Id;
Subp_Id : Entity_Id) return Boolean;
-- Given a subprogram call to the given subprogram return True if the
-- names of BIP extra actual and formal parameters match.
function Check_Number_Of_Actuals
(Subp_Call : Node_Id;
Subp_Id : Entity_Id) return Boolean;
-- Given a subprogram call to the given subprogram return True if the
-- number of actual parameters (including extra actuals) is correct.
procedure Check_Overriding_Operation (Subp : Entity_Id);
-- Subp is a dispatching operation. Check whether it may override an
-- inherited private operation, in which case its DT entry is that of
-- the hidden operation, not the one it may have received earlier.
-- This must be done before emitting the code to set the corresponding
-- DT to the address of the subprogram. The actual placement of Subp in
-- the proper place in the list of primitive operations is done in
-- Declare_Inherited_Private_Subprograms, which also has to deal with
-- implicit operations. This duplication is unavoidable for now???
procedure Detect_Infinite_Recursion (N : Node_Id; Spec : Entity_Id);
-- This procedure is called only if the subprogram body N, whose spec
-- has the given entity Spec, contains a parameterless recursive call.
-- It attempts to generate runtime code to detect if this a case of
-- infinite recursion.
--
-- The body is scanned to determine dependencies. If the only external
-- dependencies are on a small set of scalar variables, then the values
-- of these variables are captured on entry to the subprogram, and if
-- the values are not changed for the call, we know immediately that
-- we have an infinite recursion.
procedure Expand_Actuals
(N : Node_Id;
Subp : Entity_Id;
Post_Call : out List_Id);
-- Return a list of actions to take place after the call in Post_Call. The
-- call will later be rewritten as an Expression_With_Actions, with the
-- Post_Call actions inserted, and the call inside.
--
-- For each actual of an in-out or out parameter which is a numeric (view)
-- conversion of the form T (A), where A denotes a variable, we insert the
-- declaration:
--
-- Temp : T[ := T (A)];
--
-- prior to the call. Then we replace the actual with a reference to Temp,
-- and append the assignment:
--
-- A := TypeA (Temp);
--
-- after the call. Here TypeA is the actual type of variable A. For out
-- parameters, the initial declaration has no expression. If A is not an
-- entity name, we generate instead:
--
-- Var : TypeA renames A;
-- Temp : T := Var; -- omitting expression for out parameter.
-- ...
-- Var := TypeA (Temp);
--
-- For other in-out parameters, we emit the required constraint checks
-- before and/or after the call.
--
-- For all parameter modes, actuals that denote components and slices of
-- packed arrays are expanded into suitable temporaries.
--
-- For nonscalar objects that are possibly unaligned, add call by copy code
-- (copy in for IN and IN OUT, copy out for OUT and IN OUT).
--
-- For OUT and IN OUT parameters, add predicate checks after the call
-- based on the predicates of the actual type.
procedure Expand_Call_Helper (N : Node_Id; Post_Call : out List_Id);
-- Does the main work of Expand_Call. Post_Call is as for Expand_Actuals.
procedure Expand_Ctrl_Function_Call (N : Node_Id);
-- N is a function call which returns a controlled object. Transform the
-- call into a temporary which retrieves the returned object from the
-- secondary stack using 'reference.
procedure Expand_Non_Function_Return (N : Node_Id);
-- Expand a simple return statement found in a procedure body, entry body,
-- accept statement, or an extended return statement. Note that all non-
-- function returns are simple return statements.
function Expand_Protected_Object_Reference
(N : Node_Id;
Scop : Entity_Id) return Node_Id;
procedure Expand_Protected_Subprogram_Call
(N : Node_Id;
Subp : Entity_Id;
Scop : Entity_Id);
-- A call to a protected subprogram within the protected object may appear
-- as a regular call. The list of actuals must be expanded to contain a
-- reference to the object itself, and the call becomes a call to the
-- corresponding protected subprogram.
procedure Expand_Simple_Function_Return (N : Node_Id);
-- Expand simple return from function. In the case where we are returning
-- from a function body this is called by Expand_N_Simple_Return_Statement.
function Has_BIP_Extra_Formal
(E : Entity_Id;
Kind : BIP_Formal_Kind) return Boolean;
-- Given a frozen subprogram, subprogram type, entry or entry family,
-- return True if E has the BIP extra formal associated with Kind. It must
-- be invoked with a frozen entity or a subprogram type of a dispatching
-- call since we can only rely on the availability of the extra formals
-- on these entities.
procedure Insert_Post_Call_Actions (N : Node_Id; Post_Call : List_Id);
-- Insert the Post_Call list previously produced by routine Expand_Actuals
-- or Expand_Call_Helper into the tree.
procedure Replace_Renaming_Declaration_Id
(New_Decl : Node_Id;
Orig_Decl : Node_Id);
-- Replace the internal identifier of the new renaming declaration New_Decl
-- with the identifier of its original declaration Orig_Decl exchanging the
-- entities containing their defining identifiers to ensure the correct
-- replacement of the object declaration by the object renaming declaration
-- to avoid homograph conflicts (since the object declaration's defining
-- identifier was already entered in the current scope). The Next_Entity
-- links of the two entities are also swapped since the entities are part
-- of the return scope's entity list and the list structure would otherwise
-- be corrupted. The homonym chain is preserved as well.
procedure Rewrite_Function_Call_For_C (N : Node_Id);
-- When generating C code, replace a call to a function that returns an
-- array into the generated procedure with an additional out parameter.
procedure Set_Enclosing_Sec_Stack_Return (N : Node_Id);
-- N is a return statement for a function that returns its result on the
-- secondary stack. This sets the Sec_Stack_Needed_For_Return flag on the
-- function and all blocks and loops that the return statement is jumping
-- out of. This ensures that the secondary stack is not released; otherwise
-- the function result would be reclaimed before returning to the caller.
procedure Warn_BIP (Func_Call : Node_Id);
-- Give a warning on a build-in-place function call if the -gnatd_B switch
-- was given.
----------------------------------------------
-- Add_Access_Actual_To_Build_In_Place_Call --
----------------------------------------------
procedure Add_Access_Actual_To_Build_In_Place_Call
(Function_Call : Node_Id;
Function_Id : Entity_Id;
Return_Object : Node_Id;
Is_Access : Boolean := False)
is
Loc : constant Source_Ptr := Sloc (Function_Call);
Obj_Address : Node_Id;
Obj_Acc_Formal : Entity_Id;
begin
-- Locate the implicit access parameter in the called function
Obj_Acc_Formal := Build_In_Place_Formal (Function_Id, BIP_Object_Access);
-- If no return object is provided, then pass null
if not Present (Return_Object) then
Obj_Address := Make_Null (Loc);
Set_Parent (Obj_Address, Function_Call);
-- If Return_Object is already an expression of an access type, then use
-- it directly, since it must be an access value denoting the return
-- object, and couldn't possibly be the return object itself.
elsif Is_Access then
Obj_Address := Return_Object;
Set_Parent (Obj_Address, Function_Call);
-- Apply Unrestricted_Access to caller's return object
else
Obj_Address :=
Make_Attribute_Reference (Loc,
Prefix => Return_Object,
Attribute_Name => Name_Unrestricted_Access);
Set_Parent (Return_Object, Obj_Address);
Set_Parent (Obj_Address, Function_Call);
end if;
Analyze_And_Resolve (Obj_Address, Etype (Obj_Acc_Formal));
-- Build the parameter association for the new actual and add it to the
-- end of the function's actuals.
Add_Extra_Actual_To_Call (Function_Call, Obj_Acc_Formal, Obj_Address);
end Add_Access_Actual_To_Build_In_Place_Call;
------------------------------------------------------
-- Add_Unconstrained_Actuals_To_Build_In_Place_Call --
------------------------------------------------------
procedure Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Function_Call : Node_Id;
Function_Id : Entity_Id;
Alloc_Form : BIP_Allocation_Form := Unspecified;
Alloc_Form_Exp : Node_Id := Empty;
Pool_Actual : Node_Id := Make_Null (No_Location))
is
Loc : constant Source_Ptr := Sloc (Function_Call);
Alloc_Form_Actual : Node_Id;
Alloc_Form_Formal : Node_Id;
Pool_Formal : Node_Id;
begin
-- Nothing to do when the size of the object is known, and the caller is
-- in charge of allocating it, and the callee doesn't unconditionally
-- require an allocation form (such as due to having a tagged result).
if not Needs_BIP_Alloc_Form (Function_Id) then
return;
end if;
-- Locate the implicit allocation form parameter in the called function.
-- Maybe it would be better for each implicit formal of a build-in-place
-- function to have a flag or a Uint attribute to identify it. ???
Alloc_Form_Formal := Build_In_Place_Formal (Function_Id, BIP_Alloc_Form);
if Present (Alloc_Form_Exp) then
pragma Assert (Alloc_Form = Unspecified);
Alloc_Form_Actual := Alloc_Form_Exp;
else
pragma Assert (Alloc_Form /= Unspecified);
Alloc_Form_Actual :=
Make_Integer_Literal (Loc,
Intval => UI_From_Int (BIP_Allocation_Form'Pos (Alloc_Form)));
end if;
Analyze_And_Resolve (Alloc_Form_Actual, Etype (Alloc_Form_Formal));
-- Build the parameter association for the new actual and add it to the
-- end of the function's actuals.
Add_Extra_Actual_To_Call
(Function_Call, Alloc_Form_Formal, Alloc_Form_Actual);
-- Pass the Storage_Pool parameter. This parameter is omitted on ZFP as
-- those targets do not support pools.
if RTE_Available (RE_Root_Storage_Pool_Ptr) then
Pool_Formal := Build_In_Place_Formal (Function_Id, BIP_Storage_Pool);
Analyze_And_Resolve (Pool_Actual, Etype (Pool_Formal));
Add_Extra_Actual_To_Call
(Function_Call, Pool_Formal, Pool_Actual);
end if;
end Add_Unconstrained_Actuals_To_Build_In_Place_Call;
-----------------------------------------------------------
-- Add_Finalization_Master_Actual_To_Build_In_Place_Call --
-----------------------------------------------------------
procedure Add_Finalization_Master_Actual_To_Build_In_Place_Call
(Func_Call : Node_Id;
Func_Id : Entity_Id;
Ptr_Typ : Entity_Id := Empty;
Master_Exp : Node_Id := Empty)
is
begin
if not Needs_BIP_Finalization_Master (Func_Id) then
return;
end if;
declare
Formal : constant Entity_Id :=
Build_In_Place_Formal (Func_Id, BIP_Finalization_Master);
Loc : constant Source_Ptr := Sloc (Func_Call);
Actual : Node_Id;
Desig_Typ : Entity_Id;
begin
-- If there is a finalization master actual, such as the implicit
-- finalization master of an enclosing build-in-place function,
-- then this must be added as an extra actual of the call.
if Present (Master_Exp) then
Actual := Master_Exp;
-- Case where the context does not require an actual master
elsif No (Ptr_Typ) then
Actual := Make_Null (Loc);
else
Desig_Typ := Directly_Designated_Type (Ptr_Typ);
-- Check for a library-level access type whose designated type has
-- suppressed finalization or the access type is subject to pragma
-- No_Heap_Finalization. Such an access type lacks a master. Pass
-- a null actual to callee in order to signal a missing master.
if Is_Library_Level_Entity (Ptr_Typ)
and then (Finalize_Storage_Only (Desig_Typ)
or else No_Heap_Finalization (Ptr_Typ))
then
Actual := Make_Null (Loc);
-- Types in need of finalization actions
elsif Needs_Finalization (Desig_Typ) then
-- The general mechanism of creating finalization masters for
-- anonymous access types is disabled by default, otherwise
-- finalization masters will pop all over the place. Such types
-- use context-specific masters.
if Ekind (Ptr_Typ) = E_Anonymous_Access_Type
and then No (Finalization_Master (Ptr_Typ))
then
Build_Anonymous_Master (Ptr_Typ);
end if;
-- Access-to-controlled types should always have a master
pragma Assert (Present (Finalization_Master (Ptr_Typ)));
Actual :=
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Finalization_Master (Ptr_Typ), Loc),
Attribute_Name => Name_Unrestricted_Access);
-- Tagged types
else
Actual := Make_Null (Loc);
end if;
end if;
Analyze_And_Resolve (Actual, Etype (Formal));
-- Build the parameter association for the new actual and add it to
-- the end of the function's actuals.
Add_Extra_Actual_To_Call (Func_Call, Formal, Actual);
end;
end Add_Finalization_Master_Actual_To_Build_In_Place_Call;
------------------------------
-- Add_Extra_Actual_To_Call --
------------------------------
procedure Add_Extra_Actual_To_Call
(Subprogram_Call : Node_Id;
Extra_Formal : Entity_Id;
Extra_Actual : Node_Id)
is
Loc : constant Source_Ptr := Sloc (Subprogram_Call);
Param_Assoc : Node_Id;
begin
Param_Assoc :=
Make_Parameter_Association (Loc,
Selector_Name => New_Occurrence_Of (Extra_Formal, Loc),
Explicit_Actual_Parameter => Extra_Actual);
Set_Parent (Param_Assoc, Subprogram_Call);
Set_Parent (Extra_Actual, Param_Assoc);
if Present (Parameter_Associations (Subprogram_Call)) then
if Nkind (Last (Parameter_Associations (Subprogram_Call))) =
N_Parameter_Association
then
-- Find last named actual, and append
declare
L : Node_Id;
begin
L := First_Actual (Subprogram_Call);
while Present (L) loop
if No (Next_Actual (L)) then
Set_Next_Named_Actual (Parent (L), Extra_Actual);
exit;
end if;
Next_Actual (L);
end loop;
end;
else
Set_First_Named_Actual (Subprogram_Call, Extra_Actual);
end if;
Append (Param_Assoc, To => Parameter_Associations (Subprogram_Call));
else
Set_Parameter_Associations (Subprogram_Call, New_List (Param_Assoc));
Set_First_Named_Actual (Subprogram_Call, Extra_Actual);
end if;
end Add_Extra_Actual_To_Call;
---------------------------------------------
-- Add_Task_Actuals_To_Build_In_Place_Call --
---------------------------------------------
procedure Add_Task_Actuals_To_Build_In_Place_Call
(Function_Call : Node_Id;
Function_Id : Entity_Id;
Master_Actual : Node_Id;
Chain : Node_Id := Empty)
is
Loc : constant Source_Ptr := Sloc (Function_Call);
Actual : Node_Id;
Chain_Actual : Node_Id;
Chain_Formal : Node_Id;
Master_Formal : Node_Id;
begin
-- No such extra parameters are needed if there are no tasks
if not Needs_BIP_Task_Actuals (Function_Id) then
return;
end if;
Actual := Master_Actual;
-- Use a dummy _master actual in case of No_Task_Hierarchy
if Restriction_Active (No_Task_Hierarchy) then
Actual := New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc);
-- In the case where we use the master associated with an access type,
-- the actual is an entity and requires an explicit reference.
elsif Nkind (Actual) = N_Defining_Identifier then
Actual := New_Occurrence_Of (Actual, Loc);
end if;
-- Locate the implicit master parameter in the called function
Master_Formal := Build_In_Place_Formal (Function_Id, BIP_Task_Master);
Analyze_And_Resolve (Actual, Etype (Master_Formal));
-- Build the parameter association for the new actual and add it to the
-- end of the function's actuals.
Add_Extra_Actual_To_Call (Function_Call, Master_Formal, Actual);
-- Locate the implicit activation chain parameter in the called function
Chain_Formal :=
Build_In_Place_Formal (Function_Id, BIP_Activation_Chain);
-- Create the actual which is a pointer to the current activation chain
if No (Chain) then
Chain_Actual :=
Make_Attribute_Reference (Loc,
Prefix => Make_Identifier (Loc, Name_uChain),
Attribute_Name => Name_Unrestricted_Access);
-- Allocator case; make a reference to the Chain passed in by the caller
else
Chain_Actual :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Chain, Loc),
Attribute_Name => Name_Unrestricted_Access);
end if;
Analyze_And_Resolve (Chain_Actual, Etype (Chain_Formal));
-- Build the parameter association for the new actual and add it to the
-- end of the function's actuals.
Add_Extra_Actual_To_Call (Function_Call, Chain_Formal, Chain_Actual);
end Add_Task_Actuals_To_Build_In_Place_Call;
----------------------------------
-- Apply_CW_Accessibility_Check --
----------------------------------
procedure Apply_CW_Accessibility_Check (Exp : Node_Id; Func : Entity_Id) is
Loc : constant Source_Ptr := Sloc (Exp);
begin
if Ada_Version >= Ada_2005
and then Tagged_Type_Expansion
and then not Scope_Suppress.Suppress (Accessibility_Check)
and then
(Is_Class_Wide_Type (Etype (Exp))
or else Nkind (Exp) in
N_Type_Conversion | N_Unchecked_Type_Conversion
or else (Is_Entity_Name (Exp)
and then Is_Formal (Entity (Exp)))
or else Scope_Depth (Enclosing_Dynamic_Scope (Etype (Exp))) >
Scope_Depth (Enclosing_Dynamic_Scope (Func)))
then
declare
Tag_Node : Node_Id;
begin
-- Ada 2005 (AI-251): In class-wide interface objects we displace
-- "this" to reference the base of the object. This is required to
-- get access to the TSD of the object.
if Is_Class_Wide_Type (Etype (Exp))
and then Is_Interface (Etype (Exp))
then
-- If the expression is an explicit dereference then we can
-- directly displace the pointer to reference the base of
-- the object.
if Nkind (Exp) = N_Explicit_Dereference then
Tag_Node :=
Make_Explicit_Dereference (Loc,
Prefix =>
Unchecked_Convert_To (RTE (RE_Tag_Ptr),
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Base_Address), Loc),
Parameter_Associations => New_List (
Unchecked_Convert_To (RTE (RE_Address),
Duplicate_Subexpr (Prefix (Exp)))))));
-- Similar case to the previous one but the expression is a
-- renaming of an explicit dereference.
elsif Nkind (Exp) = N_Identifier
and then Present (Renamed_Object (Entity (Exp)))
and then Nkind (Renamed_Object (Entity (Exp)))
= N_Explicit_Dereference
then
Tag_Node :=
Make_Explicit_Dereference (Loc,
Prefix =>
Unchecked_Convert_To (RTE (RE_Tag_Ptr),
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Base_Address), Loc),
Parameter_Associations => New_List (
Unchecked_Convert_To (RTE (RE_Address),
Duplicate_Subexpr
(Prefix
(Renamed_Object (Entity (Exp)))))))));
-- Common case: obtain the address of the actual object and
-- displace the pointer to reference the base of the object.
else
Tag_Node :=
Make_Explicit_Dereference (Loc,
Prefix =>
Unchecked_Convert_To (RTE (RE_Tag_Ptr),
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Base_Address), Loc),
Parameter_Associations => New_List (
Make_Attribute_Reference (Loc,
Prefix => Duplicate_Subexpr (Exp),
Attribute_Name => Name_Address)))));
end if;
else
Tag_Node :=
Make_Attribute_Reference (Loc,
Prefix => Duplicate_Subexpr (Exp),
Attribute_Name => Name_Tag);
end if;
-- CodePeer does not do anything useful with
-- Ada.Tags.Type_Specific_Data components.
if not CodePeer_Mode then
Insert_Action (Exp,
Make_Raise_Program_Error (Loc,
Condition =>
Make_Op_Gt (Loc,
Left_Opnd => Build_Get_Access_Level (Loc, Tag_Node),
Right_Opnd =>
Make_Integer_Literal (Loc,
Scope_Depth (Enclosing_Dynamic_Scope (Func)))),
Reason => PE_Accessibility_Check_Failed));
end if;
end;
end if;
end Apply_CW_Accessibility_Check;
-----------------------
-- BIP_Formal_Suffix --
-----------------------
function BIP_Formal_Suffix (Kind : BIP_Formal_Kind) return String is
begin
case Kind is
when BIP_Alloc_Form =>
return BIP_Alloc_Suffix;
when BIP_Storage_Pool =>
return BIP_Storage_Pool_Suffix;
when BIP_Finalization_Master =>
return BIP_Finalization_Master_Suffix;
when BIP_Task_Master =>
return BIP_Task_Master_Suffix;
when BIP_Activation_Chain =>
return BIP_Activation_Chain_Suffix;
when BIP_Object_Access =>
return BIP_Object_Access_Suffix;
end case;
end BIP_Formal_Suffix;
---------------------
-- BIP_Suffix_Kind --
---------------------
function BIP_Suffix_Kind (E : Entity_Id) return BIP_Formal_Kind is
Nam : constant String := Get_Name_String (Chars (E));
function Has_Suffix (Suffix : String) return Boolean;
-- Return True if Nam has suffix Suffix
function Has_Suffix (Suffix : String) return Boolean is
Len : constant Natural := Suffix'Length;
begin
return Nam'Length > Len
and then Nam (Nam'Last - Len + 1 .. Nam'Last) = Suffix;
end Has_Suffix;
-- Start of processing for BIP_Suffix_Kind
begin
if Has_Suffix (BIP_Alloc_Suffix) then
return BIP_Alloc_Form;
elsif Has_Suffix (BIP_Storage_Pool_Suffix) then
return BIP_Storage_Pool;
elsif Has_Suffix (BIP_Finalization_Master_Suffix) then
return BIP_Finalization_Master;
elsif Has_Suffix (BIP_Task_Master_Suffix) then
return BIP_Task_Master;
elsif Has_Suffix (BIP_Activation_Chain_Suffix) then
return BIP_Activation_Chain;
elsif Has_Suffix (BIP_Object_Access_Suffix) then
return BIP_Object_Access;
else
raise Program_Error;
end if;
end BIP_Suffix_Kind;
---------------------------
-- Build_In_Place_Formal --
---------------------------
function Build_In_Place_Formal
(Func : Entity_Id;
Kind : BIP_Formal_Kind) return Entity_Id
is
Extra_Formal : Entity_Id := Extra_Formals (Func);
Formal_Suffix : constant String := BIP_Formal_Suffix (Kind);
begin
-- Maybe it would be better for each implicit formal of a build-in-place
-- function to have a flag or a Uint attribute to identify it. ???
-- The return type in the function declaration may have been a limited
-- view, and the extra formals for the function were not generated at
-- that point. At the point of call the full view must be available and
-- the extra formals can be created.
if No (Extra_Formal) then
Create_Extra_Formals (Func);
Extra_Formal := Extra_Formals (Func);
end if;
-- We search for a formal with a matching suffix. We can't search
-- for the full name, because of the code at the end of Sem_Ch6.-
-- Create_Extra_Formals, which copies the Extra_Formals over to
-- the Alias of an instance, which will cause the formals to have
-- "incorrect" names.
loop
pragma Assert (Present (Extra_Formal));
declare
Name : constant String := Get_Name_String (Chars (Extra_Formal));
begin
exit when Name'Length >= Formal_Suffix'Length
and then Formal_Suffix =
Name (Name'Last - Formal_Suffix'Length + 1 .. Name'Last);
end;
Next_Formal_With_Extras (Extra_Formal);
end loop;
return Extra_Formal;
end Build_In_Place_Formal;
-------------------------------
-- Build_Procedure_Body_Form --
-------------------------------
function Build_Procedure_Body_Form
(Func_Id : Entity_Id;
Func_Body : Node_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Func_Body);
Proc_Decl : constant Node_Id :=
Next (Unit_Declaration_Node (Func_Id));
-- It is assumed that the next node following the declaration of the
-- corresponding subprogram spec is the declaration of the procedure
-- form.
Proc_Id : constant Entity_Id := Defining_Entity (Proc_Decl);
procedure Replace_Returns (Param_Id : Entity_Id; Stmts : List_Id);
-- Replace each return statement found in the list Stmts with an
-- assignment of the return expression to parameter Param_Id.
---------------------
-- Replace_Returns --
---------------------
procedure Replace_Returns (Param_Id : Entity_Id; Stmts : List_Id) is
Stmt : Node_Id;
begin
Stmt := First (Stmts);
while Present (Stmt) loop
if Nkind (Stmt) = N_Block_Statement then
Replace_Returns (Param_Id,
Statements (Handled_Statement_Sequence (Stmt)));
elsif Nkind (Stmt) = N_Case_Statement then
declare
Alt : Node_Id;
begin
Alt := First (Alternatives (Stmt));
while Present (Alt) loop
Replace_Returns (Param_Id, Statements (Alt));
Next (Alt);
end loop;
end;
elsif Nkind (Stmt) = N_Extended_Return_Statement then
declare
Ret_Obj : constant Entity_Id :=
Defining_Entity
(First (Return_Object_Declarations (Stmt)));
Assign : constant Node_Id :=
Make_Assignment_Statement (Sloc (Stmt),
Name =>
New_Occurrence_Of (Param_Id, Loc),
Expression =>
New_Occurrence_Of (Ret_Obj, Sloc (Stmt)));
Stmts : List_Id;
begin
-- The extended return may just contain the declaration
if Present (Handled_Statement_Sequence (Stmt)) then
Stmts := Statements (Handled_Statement_Sequence (Stmt));
else
Stmts := New_List;
end if;
Set_Assignment_OK (Name (Assign));
Rewrite (Stmt,
Make_Block_Statement (Sloc (Stmt),
Declarations =>
Return_Object_Declarations (Stmt),
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => Stmts)));
Replace_Returns (Param_Id, Stmts);
Append_To (Stmts, Assign);
Append_To (Stmts, Make_Simple_Return_Statement (Loc));
end;
elsif Nkind (Stmt) = N_If_Statement then
Replace_Returns (Param_Id, Then_Statements (Stmt));
Replace_Returns (Param_Id, Else_Statements (Stmt));
declare
Part : Node_Id;
begin
Part := First (Elsif_Parts (Stmt));
while Present (Part) loop
Replace_Returns (Param_Id, Then_Statements (Part));
Next (Part);
end loop;
end;
elsif Nkind (Stmt) = N_Loop_Statement then
Replace_Returns (Param_Id, Statements (Stmt));
elsif Nkind (Stmt) = N_Simple_Return_Statement then
-- Generate:
-- Param := Expr;
-- return;
Rewrite (Stmt,
Make_Assignment_Statement (Sloc (Stmt),
Name => New_Occurrence_Of (Param_Id, Loc),
Expression => Relocate_Node (Expression (Stmt))));
Insert_After (Stmt, Make_Simple_Return_Statement (Loc));
-- Skip the added return
Next (Stmt);
end if;
Next (Stmt);
end loop;
end Replace_Returns;
-- Local variables
Stmts : List_Id;
New_Body : Node_Id;
-- Start of processing for Build_Procedure_Body_Form
begin
-- This routine replaces the original function body:
-- function F (...) return Array_Typ is
-- begin
-- ...
-- return Something;
-- end F;
-- with the following:
-- procedure P (..., Result : out Array_Typ) is
-- begin
-- ...
-- Result := Something;
-- end P;
Stmts :=
Statements (Handled_Statement_Sequence (Func_Body));
Replace_Returns (Last_Entity (Proc_Id), Stmts);
New_Body :=
Make_Subprogram_Body (Loc,
Specification =>
Copy_Subprogram_Spec (Specification (Proc_Decl)),
Declarations => Declarations (Func_Body),
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => Stmts));
-- If the function is a generic instance, so is the new procedure.
-- Set flag accordingly so that the proper renaming declarations are
-- generated.
Set_Is_Generic_Instance (Proc_Id, Is_Generic_Instance (Func_Id));
return New_Body;
end Build_Procedure_Body_Form;
-----------------------
-- Caller_Known_Size --
-----------------------
function Caller_Known_Size
(Func_Call : Node_Id;
Result_Subt : Entity_Id) return Boolean
is
begin
return
(Is_Definite_Subtype (Underlying_Type (Result_Subt))
and then No (Controlling_Argument (Func_Call)))
or else not Requires_Transient_Scope (Underlying_Type (Result_Subt));
end Caller_Known_Size;
-----------------------
-- Check_BIP_Actuals --
-----------------------
function Check_BIP_Actuals
(Subp_Call : Node_Id;
Subp_Id : Entity_Id) return Boolean
is
Formal : Entity_Id;
Actual : Node_Id;
begin
pragma Assert (Nkind (Subp_Call) in N_Entry_Call_Statement
| N_Function_Call
| N_Procedure_Call_Statement);
Formal := First_Formal_With_Extras (Subp_Id);
Actual := First_Actual (Subp_Call);
while Present (Formal) and then Present (Actual) loop
if Is_Build_In_Place_Entity (Formal)
and then Nkind (Actual) = N_Identifier
and then Is_Build_In_Place_Entity (Entity (Actual))
and then BIP_Suffix_Kind (Formal)
/= BIP_Suffix_Kind (Entity (Actual))
then
return False;
end if;
Next_Formal_With_Extras (Formal);
Next_Actual (Actual);
end loop;
return No (Formal) and then No (Actual);
end Check_BIP_Actuals;
-----------------------------
-- Check_Number_Of_Actuals --
-----------------------------
function Check_Number_Of_Actuals
(Subp_Call : Node_Id;
Subp_Id : Entity_Id) return Boolean
is
Formal : Entity_Id;
Actual : Node_Id;
begin
pragma Assert (Nkind (Subp_Call) in N_Entry_Call_Statement
| N_Function_Call
| N_Procedure_Call_Statement);
Formal := First_Formal_With_Extras (Subp_Id);
Actual := First_Actual (Subp_Call);
while Present (Formal) and then Present (Actual) loop
Next_Formal_With_Extras (Formal);
Next_Actual (Actual);
end loop;
return No (Formal) and then No (Actual);
end Check_Number_Of_Actuals;
--------------------------------
-- Check_Overriding_Operation --
--------------------------------
procedure Check_Overriding_Operation (Subp : Entity_Id) is
Typ : constant Entity_Id := Find_Dispatching_Type (Subp);
Op_List : constant Elist_Id := Primitive_Operations (Typ);
Op_Elmt : Elmt_Id;
Prim_Op : Entity_Id;
Par_Op : Entity_Id;
begin
if Is_Derived_Type (Typ)
and then not Is_Private_Type (Typ)
and then In_Open_Scopes (Scope (Etype (Typ)))
and then Is_Base_Type (Typ)
then
-- Subp overrides an inherited private operation if there is an
-- inherited operation with a different name than Subp (see
-- Derive_Subprogram) whose Alias is a hidden subprogram with the
-- same name as Subp.
Op_Elmt := First_Elmt (Op_List);
while Present (Op_Elmt) loop
Prim_Op := Node (Op_Elmt);
Par_Op := Alias (Prim_Op);
if Present (Par_Op)
and then not Comes_From_Source (Prim_Op)
and then Chars (Prim_Op) /= Chars (Par_Op)
and then Chars (Par_Op) = Chars (Subp)
and then Is_Hidden (Par_Op)
and then Type_Conformant (Prim_Op, Subp)
then
Set_DT_Position_Value (Subp, DT_Position (Prim_Op));
end if;
Next_Elmt (Op_Elmt);
end loop;
end if;
end Check_Overriding_Operation;
-------------------------------
-- Detect_Infinite_Recursion --
-------------------------------
procedure Detect_Infinite_Recursion (N : Node_Id; Spec : Entity_Id) is
Loc : constant Source_Ptr := Sloc (N);
Var_List : constant Elist_Id := New_Elmt_List;
-- List of globals referenced by body of procedure
Call_List : constant Elist_Id := New_Elmt_List;
-- List of recursive calls in body of procedure
Shad_List : constant Elist_Id := New_Elmt_List;
-- List of entity id's for entities created to capture the value of
-- referenced globals on entry to the procedure.
Scop : constant Uint := Scope_Depth (Spec);
-- This is used to record the scope depth of the current procedure, so
-- that we can identify global references.
Max_Vars : constant := 4;
-- Do not test more than four global variables
Count_Vars : Natural := 0;
-- Count variables found so far
Var : Entity_Id;
Elm : Elmt_Id;
Ent : Entity_Id;
Call : Elmt_Id;
Decl : Node_Id;
Test : Node_Id;
Elm1 : Elmt_Id;
Elm2 : Elmt_Id;
Last : Node_Id;
function Process (Nod : Node_Id) return Traverse_Result;
-- Function to traverse the subprogram body (using Traverse_Func)
-------------
-- Process --
-------------
function Process (Nod : Node_Id) return Traverse_Result is
begin
-- Procedure call
if Nkind (Nod) = N_Procedure_Call_Statement then
-- Case of one of the detected recursive calls
if Is_Entity_Name (Name (Nod))
and then Has_Recursive_Call (Entity (Name (Nod)))
and then Entity (Name (Nod)) = Spec
then
Append_Elmt (Nod, Call_List);
return Skip;
-- Any other procedure call may have side effects
else
return Abandon;
end if;
-- A call to a pure function can always be ignored
elsif Nkind (Nod) = N_Function_Call
and then Is_Entity_Name (Name (Nod))
and then Is_Pure (Entity (Name (Nod)))
then
return Skip;
-- Case of an identifier reference
elsif Nkind (Nod) = N_Identifier then
Ent := Entity (Nod);
-- If no entity, then ignore the reference
-- Not clear why this can happen. To investigate, remove this
-- test and look at the crash that occurs here in 3401-004 ???
if No (Ent) then
return Skip;
-- Ignore entities with no Scope, again not clear how this
-- can happen, to investigate, look at 4108-008 ???
elsif No (Scope (Ent)) then
return Skip;
-- Ignore the reference if not to a more global object
elsif Scope_Depth (Scope (Ent)) >= Scop then
return Skip;
-- References to types, exceptions and constants are always OK
elsif Is_Type (Ent)
or else Ekind (Ent) = E_Exception
or else Ekind (Ent) = E_Constant
then
return Skip;
-- If other than a non-volatile scalar variable, we have some
-- kind of global reference (e.g. to a function) that we cannot
-- deal with so we forget the attempt.
elsif Ekind (Ent) /= E_Variable
or else not Is_Scalar_Type (Etype (Ent))
or else Treat_As_Volatile (Ent)
then
return Abandon;
-- Otherwise we have a reference to a global scalar
else
-- Loop through global entities already detected
Elm := First_Elmt (Var_List);
loop
-- If not detected before, record this new global reference
if No (Elm) then
Count_Vars := Count_Vars + 1;
if Count_Vars <= Max_Vars then
Append_Elmt (Entity (Nod), Var_List);
else
return Abandon;
end if;
exit;
-- If recorded before, ignore
elsif Node (Elm) = Entity (Nod) then
return Skip;
-- Otherwise keep looking
else
Next_Elmt (Elm);
end if;
end loop;
return Skip;
end if;
-- For all other node kinds, recursively visit syntactic children
else
return OK;
end if;
end Process;
function Traverse_Body is new Traverse_Func (Process);
-- Start of processing for Detect_Infinite_Recursion
begin
-- Do not attempt detection in No_Implicit_Conditional mode, since we
-- won't be able to generate the code to handle the recursion in any
-- case.
if Restriction_Active (No_Implicit_Conditionals) then
return;
end if;
-- Otherwise do traversal and quit if we get abandon signal
if Traverse_Body (N) = Abandon then
return;
-- We must have a call, since Has_Recursive_Call was set. If not just
-- ignore (this is only an error check, so if we have a funny situation,
-- due to bugs or errors, we do not want to bomb).
elsif Is_Empty_Elmt_List (Call_List) then
return;
end if;
-- Here is the case where we detect recursion at compile time
-- Push our current scope for analyzing the declarations and code that
-- we will insert for the checking.
Push_Scope (Spec);
-- This loop builds temporary variables for each of the referenced
-- globals, so that at the end of the loop the list Shad_List contains
-- these temporaries in one-to-one correspondence with the elements in
-- Var_List.
Last := Empty;
Elm := First_Elmt (Var_List);
while Present (Elm) loop
Var := Node (Elm);
Ent := Make_Temporary (Loc, 'S');
Append_Elmt (Ent, Shad_List);
-- Insert a declaration for this temporary at the start of the
-- declarations for the procedure. The temporaries are declared as
-- constant objects initialized to the current values of the
-- corresponding temporaries.
Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Ent,
Object_Definition => New_Occurrence_Of (Etype (Var), Loc),
Constant_Present => True,
Expression => New_Occurrence_Of (Var, Loc));
if No (Last) then
Prepend (Decl, Declarations (N));
else
Insert_After (Last, Decl);
end if;
Last := Decl;
Analyze (Decl);
Next_Elmt (Elm);
end loop;
-- Loop through calls
Call := First_Elmt (Call_List);
while Present (Call) loop
-- Build a predicate expression of the form
-- True
-- and then global1 = temp1
-- and then global2 = temp2
-- ...
-- This predicate determines if any of the global values
-- referenced by the procedure have changed since the
-- current call, if not an infinite recursion is assured.
Test := New_Occurrence_Of (Standard_True, Loc);
Elm1 := First_Elmt (Var_List);
Elm2 := First_Elmt (Shad_List);
while Present (Elm1) loop
Test :=
Make_And_Then (Loc,
Left_Opnd => Test,
Right_Opnd =>
Make_Op_Eq (Loc,
Left_Opnd => New_Occurrence_Of (Node (Elm1), Loc),
Right_Opnd => New_Occurrence_Of (Node (Elm2), Loc)));
Next_Elmt (Elm1);
Next_Elmt (Elm2);
end loop;
-- Now we replace the call with the sequence
-- if no-changes (see above) then
-- raise Storage_Error;
-- else
-- original-call
-- end if;
Rewrite (Node (Call),
Make_If_Statement (Loc,
Condition => Test,
Then_Statements => New_List (
Make_Raise_Storage_Error (Loc,
Reason => SE_Infinite_Recursion)),
Else_Statements => New_List (
Relocate_Node (Node (Call)))));
Analyze (Node (Call));
Next_Elmt (Call);
end loop;
-- Remove temporary scope stack entry used for analysis
Pop_Scope;
end Detect_Infinite_Recursion;
--------------------
-- Expand_Actuals --
--------------------
procedure Expand_Actuals
(N : Node_Id;
Subp : Entity_Id;
Post_Call : out List_Id)
is
Loc : constant Source_Ptr := Sloc (N);
Actual : Node_Id;
Formal : Entity_Id;
N_Node : Node_Id;
E_Actual : Entity_Id;
E_Formal : Entity_Id;
procedure Add_Call_By_Copy_Code;
-- For cases where the parameter must be passed by copy, this routine
-- generates a temporary variable into which the actual is copied and
-- then passes this as the parameter. For an OUT or IN OUT parameter,
-- an assignment is also generated to copy the result back. The call
-- also takes care of any constraint checks required for the type
-- conversion case (on both the way in and the way out).
procedure Add_Simple_Call_By_Copy_Code (Force : Boolean);
-- This is similar to the above, but is used in cases where we know
-- that all that is needed is to simply create a temporary and copy
-- the value in and out of the temporary. If Force is True, then the
-- procedure may disregard legality considerations.
-- ??? We need to do the copy for a bit-packed array because this is
-- where the rewriting into a mask-and-shift sequence is done. But of
-- course this may break the program if it expects bits to be really
-- passed by reference. That's what we have done historically though.
procedure Add_Validation_Call_By_Copy_Code (Act : Node_Id);
-- Perform copy-back for actual parameter Act which denotes a validation
-- variable.
procedure Check_Fortran_Logical;
-- A value of type Logical that is passed through a formal parameter
-- must be normalized because .TRUE. usually does not have the same
-- representation as True. We assume that .FALSE. = False = 0.
-- What about functions that return a logical type ???
function Is_Legal_Copy return Boolean;
-- Check that an actual can be copied before generating the temporary
-- to be used in the call. If the formal is of a by_reference type or
-- is aliased, then the program is illegal (this can only happen in
-- the presence of representation clauses that force a misalignment)
-- If the formal is a by_reference parameter imposed by a DEC pragma,
-- emit a warning that this might lead to unaligned arguments.
function Make_Var (Actual : Node_Id) return Entity_Id;
-- Returns an entity that refers to the given actual parameter, Actual
-- (not including any type conversion). If Actual is an entity name,
-- then this entity is returned unchanged, otherwise a renaming is
-- created to provide an entity for the actual.
procedure Reset_Packed_Prefix;
-- The expansion of a packed array component reference is delayed in
-- the context of a call. Now we need to complete the expansion, so we
-- unmark the analyzed bits in all prefixes.
function Requires_Atomic_Or_Volatile_Copy return Boolean;
-- Returns whether a copy is required as per RM C.6(19) and gives a
-- warning in this case.
---------------------------
-- Add_Call_By_Copy_Code --
---------------------------
procedure Add_Call_By_Copy_Code is
Crep : Boolean;
Expr : Node_Id;
F_Typ : Entity_Id := Etype (Formal);
Indic : Node_Id;
Init : Node_Id;
Temp : Entity_Id;
V_Typ : Entity_Id;
Var : Entity_Id;
begin
if not Is_Legal_Copy then
return;
end if;
Temp := Make_Temporary (Loc, 'T', Actual);
-- Handle formals whose type comes from the limited view
if From_Limited_With (F_Typ)
and then Has_Non_Limited_View (F_Typ)
then
F_Typ := Non_Limited_View (F_Typ);
end if;
-- Use formal type for temp, unless formal type is an unconstrained
-- array, in which case we don't have to worry about bounds checks,
-- and we use the actual type, since that has appropriate bounds.
if Is_Array_Type (F_Typ) and then not Is_Constrained (F_Typ) then
Indic := New_Occurrence_Of (Etype (Actual), Loc);
else
Indic := New_Occurrence_Of (F_Typ, Loc);
end if;
-- The new code will be properly analyzed below and the setting of
-- the Do_Range_Check flag recomputed so remove the obsolete one.
Set_Do_Range_Check (Actual, False);
if Nkind (Actual) = N_Type_Conversion then
Set_Do_Range_Check (Expression (Actual), False);
V_Typ := Etype (Expression (Actual));
-- If the formal is an (in-)out parameter, capture the name
-- of the variable in order to build the post-call assignment.
Var := Make_Var (Expression (Actual));
Crep := not Has_Compatible_Representation
(Target_Type => F_Typ,
Operand_Type => Etype (Expression (Actual)));
else
V_Typ := Etype (Actual);
Var := Make_Var (Actual);
Crep := False;
end if;
-- Setup initialization for case of in out parameter, or an out
-- parameter where the formal is an unconstrained array (in the
-- latter case, we have to pass in an object with bounds).
-- If this is an out parameter, the initial copy is wasteful, so as
-- an optimization for the one-dimensional case we extract the
-- bounds of the actual and build an uninitialized temporary of the
-- right size.
-- If the formal is an out parameter with discriminants, the
-- discriminants must be captured even if the rest of the object
-- is in principle uninitialized, because the discriminants may
-- be read by the called subprogram.
if Ekind (Formal) = E_In_Out_Parameter
or else (Is_Array_Type (F_Typ) and then not Is_Constrained (F_Typ))
or else Has_Discriminants (F_Typ)
then
if Nkind (Actual) = N_Type_Conversion then
if Conversion_OK (Actual) then
Init := OK_Convert_To (F_Typ, New_Occurrence_Of (Var, Loc));
else
Init := Convert_To (F_Typ, New_Occurrence_Of (Var, Loc));
end if;
elsif Ekind (Formal) = E_Out_Parameter
and then Is_Array_Type (F_Typ)
and then Number_Dimensions (F_Typ) = 1
and then not Has_Non_Null_Base_Init_Proc (F_Typ)
then
-- Actual is a one-dimensional array or slice, and the type
-- requires no initialization. Create a temporary of the
-- right size, but do not copy actual into it (optimization).
Init := Empty;
Indic :=
Make_Subtype_Indication (Loc,
Subtype_Mark => New_Occurrence_Of (F_Typ, Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => New_List (
Make_Range (Loc,
Low_Bound =>
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Var, Loc),
Attribute_Name => Name_First),
High_Bound =>
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Var, Loc),
Attribute_Name => Name_Last)))));
else
Init := New_Occurrence_Of (Var, Loc);
end if;
-- An initialization is created for packed conversions as
-- actuals for out parameters to enable Make_Object_Declaration
-- to determine the proper subtype for N_Node. Note that this
-- is wasteful because the extra copying on the call side is
-- not required for such out parameters. ???
elsif Ekind (Formal) = E_Out_Parameter
and then Nkind (Actual) = N_Type_Conversion
and then (Is_Bit_Packed_Array (F_Typ)
or else
Is_Bit_Packed_Array (Etype (Expression (Actual))))
then
if Conversion_OK (Actual) then
Init := OK_Convert_To (F_Typ, New_Occurrence_Of (Var, Loc));
else
Init := Convert_To (F_Typ, New_Occurrence_Of (Var, Loc));
end if;
elsif Ekind (Formal) = E_In_Parameter then
-- Handle the case in which the actual is a type conversion
if Nkind (Actual) = N_Type_Conversion then
if Conversion_OK (Actual) then
Init := OK_Convert_To (F_Typ, New_Occurrence_Of (Var, Loc));
else
Init := Convert_To (F_Typ, New_Occurrence_Of (Var, Loc));
end if;
else
Init := New_Occurrence_Of (Var, Loc);
end if;
-- Access types are passed in without checks, but if a copy-back is
-- required for a null-excluding check on an in-out or out parameter,
-- then the initial value is that of the actual.
elsif Is_Access_Type (E_Formal)
and then Can_Never_Be_Null (Etype (Actual))
and then not Can_Never_Be_Null (E_Formal)
then
Init := New_Occurrence_Of (Var, Loc);
-- View conversions when the formal type has the Default_Value aspect
-- require passing in the value of the conversion's operand. The type
-- of that operand also has Default_Value, as required by AI12-0074
-- (RM 6.4.1(5.3/4)). The subtype denoted by the subtype_indication
-- is changed to the base type of the formal subtype, to ensure that
-- the actual's value can be assigned without a constraint check
-- (note that no check is done on passing to an out parameter). Also
-- note that the two types necessarily share the same ancestor type,
-- as required by 6.4.1(5.2/4), so underlying base types will match.
elsif Ekind (Formal) = E_Out_Parameter
and then Is_Scalar_Type (Etype (F_Typ))
and then Nkind (Actual) = N_Type_Conversion
and then Present (Default_Aspect_Value (Etype (F_Typ)))
then
Indic := New_Occurrence_Of (Base_Type (F_Typ), Loc);
Init := Convert_To
(Base_Type (F_Typ), New_Occurrence_Of (Var, Loc));
else
Init := Empty;
end if;
N_Node :=
Make_Object_Declaration (Loc,
Defining_Identifier => Temp,
Object_Definition => Indic,
Expression => Init);
Set_Assignment_OK (N_Node);
Insert_Action (N, N_Node);
-- Now, normally the deal here is that we use the defining
-- identifier created by that object declaration. There is
-- one exception to this. In the change of representation case
-- the above declaration will end up looking like:
-- temp : type := identifier;
-- And in this case we might as well use the identifier directly
-- and eliminate the temporary. Note that the analysis of the
-- declaration was not a waste of time in that case, since it is
-- what generated the necessary change of representation code. If
-- the change of representation introduced additional code, as in
-- a fixed-integer conversion, the expression is not an identifier
-- and must be kept.
if Crep
and then Present (Expression (N_Node))
and then Is_Entity_Name (Expression (N_Node))
then
Temp := Entity (Expression (N_Node));
Rewrite (N_Node, Make_Null_Statement (Loc));
end if;
-- For IN parameter, all we do is to replace the actual
if Ekind (Formal) = E_In_Parameter then
Rewrite (Actual, New_Occurrence_Of (Temp, Loc));
Analyze (Actual);
-- Processing for OUT or IN OUT parameter
else
-- Kill current value indications for the temporary variable we
-- created, since we just passed it as an OUT parameter.
Kill_Current_Values (Temp);
Set_Is_Known_Valid (Temp, False);
Set_Is_True_Constant (Temp, False);
-- If type conversion, use reverse conversion on exit
if Nkind (Actual) = N_Type_Conversion then
if Conversion_OK (Actual) then
Expr := OK_Convert_To (V_Typ, New_Occurrence_Of (Temp, Loc));
else
Expr := Convert_To (V_Typ, New_Occurrence_Of (Temp, Loc));
end if;
else
Expr := New_Occurrence_Of (Temp, Loc);
end if;
Rewrite (Actual, New_Occurrence_Of (Temp, Loc));
Analyze (Actual);
-- If the actual is a conversion of a packed reference, it may
-- already have been expanded by Remove_Side_Effects, and the
-- resulting variable is a temporary which does not designate
-- the proper out-parameter, which may not be addressable. In
-- that case, generate an assignment to the original expression
-- (before expansion of the packed reference) so that the proper
-- expansion of assignment to a packed component can take place.
declare
Obj : Node_Id;
Lhs : Node_Id;
begin
if Is_Renaming_Of_Object (Var)
and then Nkind (Renamed_Object (Var)) = N_Selected_Component
and then Nkind (Original_Node (Prefix (Renamed_Object (Var))))
= N_Indexed_Component
and then
Has_Non_Standard_Rep (Etype (Prefix (Renamed_Object (Var))))
then
Obj := Renamed_Object (Var);
Lhs :=
Make_Selected_Component (Loc,
Prefix =>
New_Copy_Tree (Original_Node (Prefix (Obj))),
Selector_Name => New_Copy (Selector_Name (Obj)));
Reset_Analyzed_Flags (Lhs);
else
Lhs := New_Occurrence_Of (Var, Loc);
end if;
Set_Assignment_OK (Lhs);
if Is_Access_Type (E_Formal)
and then Is_Entity_Name (Lhs)
and then
Present (Effective_Extra_Accessibility (Entity (Lhs)))
then
-- Copyback target is an Ada 2012 stand-alone object of an
-- anonymous access type.
pragma Assert (Ada_Version >= Ada_2012);
if Type_Access_Level (E_Formal) >
Object_Access_Level (Lhs)
then
Append_To (Post_Call,
Make_Raise_Program_Error (Loc,
Reason => PE_Accessibility_Check_Failed));
end if;
Append_To (Post_Call,
Make_Assignment_Statement (Loc,
Name => Lhs,
Expression => Expr));
-- We would like to somehow suppress generation of the
-- extra_accessibility assignment generated by the expansion
-- of the above assignment statement. It's not a correctness
-- issue because the following assignment renders it dead,
-- but generating back-to-back assignments to the same
-- target is undesirable. ???
Append_To (Post_Call,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (
Effective_Extra_Accessibility (Entity (Lhs)), Loc),
Expression => Make_Integer_Literal (Loc,
Type_Access_Level (E_Formal))));
else
if Is_Access_Type (E_Formal)
and then Can_Never_Be_Null (Etype (Actual))
and then not Can_Never_Be_Null (E_Formal)
then
Append_To (Post_Call,
Make_Raise_Constraint_Error (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd => New_Occurrence_Of (Temp, Loc),
Right_Opnd => Make_Null (Loc)),
Reason => CE_Access_Check_Failed));
end if;
Append_To (Post_Call,
Make_Assignment_Statement (Loc,
Name => Lhs,
Expression => Expr));
end if;
end;
end if;
end Add_Call_By_Copy_Code;
----------------------------------
-- Add_Simple_Call_By_Copy_Code --
----------------------------------
procedure Add_Simple_Call_By_Copy_Code (Force : Boolean) is
Decl : Node_Id;
F_Typ : Entity_Id := Etype (Formal);
Incod : Node_Id;
Indic : Node_Id;
Lhs : Node_Id;
Outcod : Node_Id;
Rhs : Node_Id;
Temp : Entity_Id;
begin
-- Unless forced not to, check the legality of the copy operation
if not Force and then not Is_Legal_Copy then
return;
end if;
-- Handle formals whose type comes from the limited view
if From_Limited_With (F_Typ)
and then Has_Non_Limited_View (F_Typ)
then
F_Typ := Non_Limited_View (F_Typ);
end if;
-- Use formal type for temp, unless formal type is an unconstrained
-- array, in which case we don't have to worry about bounds checks,
-- and we use the actual type, since that has appropriate bounds.
if Is_Array_Type (F_Typ) and then not Is_Constrained (F_Typ) then
Indic := New_Occurrence_Of (Etype (Actual), Loc);
else
Indic := New_Occurrence_Of (F_Typ, Loc);
end if;
-- Prepare to generate code
Reset_Packed_Prefix;
Temp := Make_Temporary (Loc, 'T', Actual);
Incod := Relocate_Node (Actual);
Outcod := New_Copy_Tree (Incod);
-- Generate declaration of temporary variable, initializing it
-- with the input parameter unless we have an OUT formal or
-- this is an initialization call.
-- If the formal is an out parameter with discriminants, the
-- discriminants must be captured even if the rest of the object
-- is in principle uninitialized, because the discriminants may
-- be read by the called subprogram.
if Ekind (Formal) = E_Out_Parameter then
Incod := Empty;
if Has_Discriminants (F_Typ) then
Indic := New_Occurrence_Of (Etype (Actual), Loc);
end if;
elsif Inside_Init_Proc then
-- Could use a comment here to match comment below ???
if Nkind (Actual) /= N_Selected_Component
or else
not Has_Discriminant_Dependent_Constraint
(Entity (Selector_Name (Actual)))
then
Incod := Empty;
-- Otherwise, keep the component in order to generate the proper
-- actual subtype, that depends on enclosing discriminants.
else
null;
end if;
end if;
Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Temp,
Object_Definition => Indic,
Expression => Incod);
if Inside_Init_Proc
and then No (Incod)
then
-- If the call is to initialize a component of a composite type,
-- and the component does not depend on discriminants, use the
-- actual type of the component. This is required in case the
-- component is constrained, because in general the formal of the
-- initialization procedure will be unconstrained. Note that if
-- the component being initialized is constrained by an enclosing
-- discriminant, the presence of the initialization in the
-- declaration will generate an expression for the actual subtype.
Set_No_Initialization (Decl);
Set_Object_Definition (Decl,
New_Occurrence_Of (Etype (Actual), Loc));
end if;
Insert_Action (N, Decl);
-- The actual is simply a reference to the temporary
Rewrite (Actual, New_Occurrence_Of (Temp, Loc));
-- Generate copy out if OUT or IN OUT parameter
if Ekind (Formal) /= E_In_Parameter then
Lhs := Outcod;
Rhs := New_Occurrence_Of (Temp, Loc);
Set_Is_True_Constant (Temp, False);
-- Deal with conversion
if Nkind (Lhs) = N_Type_Conversion then
Lhs := Expression (Lhs);
Rhs := Convert_To (Etype (Actual), Rhs);
end if;
Append_To (Post_Call,
Make_Assignment_Statement (Loc,
Name => Lhs,
Expression => Rhs));
Set_Assignment_OK (Name (Last (Post_Call)));
end if;
end Add_Simple_Call_By_Copy_Code;
--------------------------------------
-- Add_Validation_Call_By_Copy_Code --
--------------------------------------
procedure Add_Validation_Call_By_Copy_Code (Act : Node_Id) is
Expr : Node_Id;
Obj : Node_Id;
Obj_Typ : Entity_Id;
Var : constant Node_Id := Unqual_Conv (Act);
Var_Id : Entity_Id;
begin
-- Generate range check if required
if Do_Range_Check (Actual) then
Generate_Range_Check (Actual, E_Formal, CE_Range_Check_Failed);
end if;
-- If there is a type conversion in the actual, it will be reinstated
-- below, the new instance will be properly analyzed and the setting
-- of the Do_Range_Check flag recomputed so remove the obsolete one.
if Nkind (Actual) = N_Type_Conversion then
Set_Do_Range_Check (Expression (Actual), False);
end if;
-- Copy the value of the validation variable back into the object
-- being validated.
if Is_Entity_Name (Var) then
Var_Id := Entity (Var);
Obj := Validated_Object (Var_Id);
Obj_Typ := Etype (Obj);
Expr := New_Occurrence_Of (Var_Id, Loc);
-- A type conversion is needed when the validation variable and
-- the validated object carry different types. This case occurs
-- when the actual is qualified in some fashion.
-- Common:
-- subtype Int is Integer range ...;
-- procedure Call (Val : in out Integer);
-- Original:
-- Object : Int;
-- Call (Integer (Object));
-- Expanded:
-- Object : Int;
-- Var : Integer := Object; -- conversion to base type
-- if not Var'Valid then -- validity check
-- Call (Var); -- modify Var
-- Object := Int (Var); -- conversion to subtype
if Etype (Var_Id) /= Obj_Typ then
Expr :=
Make_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (Obj_Typ, Loc),
Expression => Expr);
end if;
-- Generate:
-- Object := Var;
-- <or>
-- Object := Object_Type (Var);
Append_To (Post_Call,
Make_Assignment_Statement (Loc,
Name => Obj,
Expression => Expr));
-- If the flow reaches this point, then this routine was invoked with
-- an actual which does not denote a validation variable.
else
pragma Assert (False);
null;
end if;
end Add_Validation_Call_By_Copy_Code;
---------------------------
-- Check_Fortran_Logical --
---------------------------
procedure Check_Fortran_Logical is
Logical : constant Entity_Id := Etype (Formal);
Var : Entity_Id;
-- Note: this is very incomplete, e.g. it does not handle arrays
-- of logical values. This is really not the right approach at all???)
begin
if Convention (Subp) = Convention_Fortran
and then Root_Type (Etype (Formal)) = Standard_Boolean
and then Ekind (Formal) /= E_In_Parameter
then
Var := Make_Var (Actual);
Append_To (Post_Call,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Var, Loc),
Expression =>
Unchecked_Convert_To (
Logical,
Make_Op_Ne (Loc,
Left_Opnd => New_Occurrence_Of (Var, Loc),
Right_Opnd =>
Unchecked_Convert_To (
Logical,
New_Occurrence_Of (Standard_False, Loc))))));
end if;
end Check_Fortran_Logical;
-------------------
-- Is_Legal_Copy --
-------------------
function Is_Legal_Copy return Boolean is
begin
-- An attempt to copy a value of such a type can only occur if
-- representation clauses give the actual a misaligned address.
if Is_By_Reference_Type (Etype (Formal))
or else Is_Aliased (Formal)
or else (Mechanism (Formal) = By_Reference
and then not Has_Foreign_Convention (Subp))
then
-- The actual may in fact be properly aligned but there is not
-- enough front-end information to determine this. In that case
-- gigi will emit an error or a warning if a copy is not legal,
-- or generate the proper code.
return False;
-- For users of Starlet, we assume that the specification of by-
-- reference mechanism is mandatory. This may lead to unaligned
-- objects but at least for DEC legacy code it is known to work.
-- The warning will alert users of this code that a problem may
-- be lurking.
elsif Mechanism (Formal) = By_Reference
and then Ekind (Scope (Formal)) = E_Procedure
and then Is_Valued_Procedure (Scope (Formal))
then
Error_Msg_N
("by_reference actual may be misaligned??", Actual);
return False;
else
return True;
end if;
end Is_Legal_Copy;
--------------
-- Make_Var --
--------------
function Make_Var (Actual : Node_Id) return Entity_Id is
Var : Entity_Id;
begin
if Is_Entity_Name (Actual) then
return Entity (Actual);
else
Var := Make_Temporary (Loc, 'T', Actual);
N_Node :=
Make_Object_Renaming_Declaration (Loc,
Defining_Identifier => Var,
Subtype_Mark =>
New_Occurrence_Of (Etype (Actual), Loc),
Name => Relocate_Node (Actual));
Insert_Action (N, N_Node);
return Var;
end if;
end Make_Var;
-------------------------
-- Reset_Packed_Prefix --
-------------------------
procedure Reset_Packed_Prefix is
Pfx : Node_Id := Actual;
begin
loop
Set_Analyzed (Pfx, False);
exit when
Nkind (Pfx) not in N_Selected_Component | N_Indexed_Component;
Pfx := Prefix (Pfx);
end loop;
end Reset_Packed_Prefix;
----------------------------------------
-- Requires_Atomic_Or_Volatile_Copy --
----------------------------------------
function Requires_Atomic_Or_Volatile_Copy return Boolean is
begin
-- If the formal is already passed by copy, no need to do anything
if Is_By_Copy_Type (E_Formal) then
return False;
end if;
-- There is no requirement inside initialization procedures and this
-- would generate copies for atomic or volatile composite components.
if Inside_Init_Proc then
return False;
end if;
-- Check for atomicity mismatch
if Is_Atomic_Object (Actual) and then not Is_Atomic (E_Formal)
then
if Comes_From_Source (N) then
Error_Msg_N
("??atomic actual passed by copy (RM C.6(19))", Actual);
end if;
return True;
end if;
-- Check for volatility mismatch
if Is_Volatile_Object (Actual) and then not Is_Volatile (E_Formal)
then
if Comes_From_Source (N) then
Error_Msg_N
("??volatile actual passed by copy (RM C.6(19))", Actual);
end if;
return True;
end if;
return False;
end Requires_Atomic_Or_Volatile_Copy;
-- Start of processing for Expand_Actuals
begin
Post_Call := New_List;
Formal := First_Formal (Subp);
Actual := First_Actual (N);
while Present (Formal) loop
E_Formal := Etype (Formal);
E_Actual := Etype (Actual);
-- Handle formals whose type comes from the limited view
if From_Limited_With (E_Formal)
and then Has_Non_Limited_View (E_Formal)
then
E_Formal := Non_Limited_View (E_Formal);
end if;
if Is_Scalar_Type (E_Formal)
or else Nkind (Actual) = N_Slice
then
Check_Fortran_Logical;
-- RM 6.4.1 (11)
elsif Ekind (Formal) /= E_Out_Parameter then
-- The unusual case of the current instance of a protected type
-- requires special handling. This can only occur in the context
-- of a call within the body of a protected operation.
if Is_Entity_Name (Actual)
and then Ekind (Entity (Actual)) = E_Protected_Type
and then In_Open_Scopes (Entity (Actual))
then
if Scope (Subp) /= Entity (Actual) then
Error_Msg_N
("operation outside protected type may not "
& "call back its protected operations??", Actual);
end if;
Rewrite (Actual,
Expand_Protected_Object_Reference (N, Entity (Actual)));
end if;
-- Ada 2005 (AI-318-02): If the actual parameter is a call to a
-- build-in-place function, then a temporary return object needs
-- to be created and access to it must be passed to the function
-- (and ensure that we have an activation chain defined for tasks
-- and a Master variable).
-- Currently we limit such functions to those with inherently
-- limited result subtypes, but eventually we plan to expand the
-- functions that are treated as build-in-place to include other
-- composite result types.
-- But do not do it here for intrinsic subprograms since this will
-- be done properly after the subprogram is expanded.
if Is_Intrinsic_Subprogram (Subp) then
null;
elsif Is_Build_In_Place_Function_Call (Actual) then
Build_Activation_Chain_Entity (N);
Build_Master_Entity (Etype (Actual));
Make_Build_In_Place_Call_In_Anonymous_Context (Actual);
-- Ada 2005 (AI-318-02): Specialization of the previous case for
-- actuals containing build-in-place function calls whose returned
-- object covers interface types.
elsif Present (Unqual_BIP_Iface_Function_Call (Actual)) then
Build_Activation_Chain_Entity (N);
Build_Master_Entity (Etype (Actual));
Make_Build_In_Place_Iface_Call_In_Anonymous_Context (Actual);
end if;
Apply_Constraint_Check (Actual, E_Formal);
-- Out parameter case. No constraint checks on access type
-- RM 6.4.1 (13), but on return a null-excluding check may be
-- required (see below).
elsif Is_Access_Type (E_Formal) then
null;
-- RM 6.4.1 (14)
elsif Has_Discriminants (Base_Type (E_Formal))
or else Has_Non_Null_Base_Init_Proc (E_Formal)
then
Apply_Constraint_Check (Actual, E_Formal);
-- RM 6.4.1 (15)
else
Apply_Constraint_Check (Actual, Base_Type (E_Formal));
end if;
-- Processing for IN-OUT and OUT parameters
if Ekind (Formal) /= E_In_Parameter then
-- For type conversions of arrays, apply length/range checks
if Is_Array_Type (E_Formal)
and then Nkind (Actual) = N_Type_Conversion
then
if Is_Constrained (E_Formal) then
Apply_Length_Check (Expression (Actual), E_Formal);
else
Apply_Range_Check (Expression (Actual), E_Formal);
end if;
end if;
-- The actual denotes a variable which captures the value of an
-- object for validation purposes. Add a copy-back to reflect any
-- potential changes in value back into the original object.
-- Var : ... := Object;
-- if not Var'Valid then -- validity check
-- Call (Var); -- modify var
-- Object := Var; -- update Object
-- This case is given higher priority because the subsequent check
-- for type conversion may add an extra copy of the variable and
-- prevent proper value propagation back in the original object.
if Is_Validation_Variable_Reference (Actual) then
Add_Validation_Call_By_Copy_Code (Actual);
-- If argument is a type conversion for a type that is passed by
-- copy, then we must pass the parameter by copy.
elsif Nkind (Actual) = N_Type_Conversion
and then
(Is_Elementary_Type (E_Formal)
or else Is_Bit_Packed_Array (Etype (Formal))
or else Is_Bit_Packed_Array (Etype (Expression (Actual)))
-- Also pass by copy if change of representation
or else not Has_Compatible_Representation
(Target_Type => Etype (Formal),
Operand_Type => Etype (Expression (Actual))))
then
Add_Call_By_Copy_Code;
-- References to components of bit-packed arrays are expanded
-- at this point, rather than at the point of analysis of the
-- actuals, to handle the expansion of the assignment to
-- [in] out parameters.
elsif Is_Ref_To_Bit_Packed_Array (Actual) then
Add_Simple_Call_By_Copy_Code (Force => True);
-- If a nonscalar actual is possibly bit-aligned, we need a copy
-- because the back-end cannot cope with such objects. In other
-- cases where alignment forces a copy, the back-end generates
-- it properly. It should not be generated unconditionally in the
-- front-end because it does not know precisely the alignment
-- requirements of the target, and makes too conservative an
-- estimate, leading to superfluous copies or spurious errors
-- on by-reference parameters.
elsif Nkind (Actual) = N_Selected_Component
and then
Component_May_Be_Bit_Aligned (Entity (Selector_Name (Actual)))
and then not Represented_As_Scalar (Etype (Formal))
then
Add_Simple_Call_By_Copy_Code (Force => False);
-- References to slices of bit-packed arrays are expanded
elsif Is_Ref_To_Bit_Packed_Slice (Actual) then
Add_Call_By_Copy_Code;
-- References to possibly unaligned slices of arrays are expanded
elsif Is_Possibly_Unaligned_Slice (Actual) then
Add_Call_By_Copy_Code;
-- Deal with access types where the actual subtype and the
-- formal subtype are not the same, requiring a check.
-- It is necessary to exclude tagged types because of "downward
-- conversion" errors, but null-excluding checks on return may be
-- required.
elsif Is_Access_Type (E_Formal)
and then not Is_Tagged_Type (Designated_Type (E_Formal))
and then (not Same_Type (E_Formal, E_Actual)
or else (Can_Never_Be_Null (E_Actual)
and then not Can_Never_Be_Null (E_Formal)))
then
Add_Call_By_Copy_Code;
-- We may need to force a copy because of atomicity or volatility
-- considerations.
elsif Requires_Atomic_Or_Volatile_Copy then
Add_Call_By_Copy_Code;
-- Add call-by-copy code for the case of scalar out parameters
-- when it is not known at compile time that the subtype of the
-- formal is a subrange of the subtype of the actual (or vice
-- versa for in out parameters), in order to get range checks
-- on such actuals. (Maybe this case should be handled earlier
-- in the if statement???)
elsif Is_Scalar_Type (E_Formal)
and then
(not In_Subrange_Of (E_Formal, E_Actual)
or else
(Ekind (Formal) = E_In_Out_Parameter
and then not In_Subrange_Of (E_Actual, E_Formal)))
then
Add_Call_By_Copy_Code;
end if;
-- RM 3.2.4 (23/3): A predicate is checked on in-out and out
-- by-reference parameters on exit from the call. If the actual
-- is a derived type and the operation is inherited, the body
-- of the operation will not contain a call to the predicate
-- function, so it must be done explicitly after the call. Ditto
-- if the actual is an entity of a predicated subtype.
-- The rule refers to by-reference types, but a check is needed
-- for by-copy types as well. That check is subsumed by the rule
-- for subtype conversion on assignment, but we can generate the
-- required check now.
-- Note also that Subp may be either a subprogram entity for
-- direct calls, or a type entity for indirect calls, which must
-- be handled separately because the name does not denote an
-- overloadable entity.
By_Ref_Predicate_Check : declare
Aund : constant Entity_Id := Underlying_Type (E_Actual);
Atyp : Entity_Id;
begin
if No (Aund) then
Atyp := E_Actual;
else
Atyp := Aund;
end if;
if Predicate_Enabled (Atyp)
-- Skip predicate checks for special cases
and then Predicate_Tests_On_Arguments (Subp)
then
Append_To (Post_Call,
Make_Predicate_Check (Atyp, Actual));
end if;
end By_Ref_Predicate_Check;
-- Processing for IN parameters
else
-- Generate range check if required
if Do_Range_Check (Actual) then
Generate_Range_Check (Actual, E_Formal, CE_Range_Check_Failed);
end if;
-- For IN parameters in the bit-packed array case, we expand an
-- indexed component (the circuit in Exp_Ch4 deliberately left
-- indexed components appearing as actuals untouched, so that
-- the special processing above for the OUT and IN OUT cases
-- could be performed. We could make the test in Exp_Ch4 more
-- complex and have it detect the parameter mode, but it is
-- easier simply to handle all cases here.)
if Nkind (Actual) = N_Indexed_Component
and then Is_Bit_Packed_Array (Etype (Prefix (Actual)))
then
Reset_Packed_Prefix;
Expand_Packed_Element_Reference (Actual);
-- If we have a reference to a bit-packed array, we copy it, since
-- the actual must be byte aligned.
-- Is this really necessary in all cases???
elsif Is_Ref_To_Bit_Packed_Array (Actual) then
Add_Simple_Call_By_Copy_Code (Force => True);
-- If we have a C++ constructor call, we need to create the object
elsif Is_CPP_Constructor_Call (Actual) then
Add_Simple_Call_By_Copy_Code (Force => True);
-- If a nonscalar actual is possibly unaligned, we need a copy
elsif Is_Possibly_Unaligned_Object (Actual)
and then not Represented_As_Scalar (Etype (Formal))
then
Add_Simple_Call_By_Copy_Code (Force => False);
-- Similarly, we have to expand slices of packed arrays here
-- because the result must be byte aligned.
elsif Is_Ref_To_Bit_Packed_Slice (Actual) then
Add_Call_By_Copy_Code;
-- Only processing remaining is to pass by copy if this is a
-- reference to a possibly unaligned slice, since the caller
-- expects an appropriately aligned argument.
elsif Is_Possibly_Unaligned_Slice (Actual) then
Add_Call_By_Copy_Code;
-- We may need to force a copy because of atomicity or volatility
-- considerations.
elsif Requires_Atomic_Or_Volatile_Copy then
Add_Call_By_Copy_Code;
-- An unusual case: a current instance of an enclosing task can be
-- an actual, and must be replaced by a reference to self.
elsif Is_Entity_Name (Actual)
and then Is_Task_Type (Entity (Actual))
then
if In_Open_Scopes (Entity (Actual)) then
Rewrite (Actual,
(Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (RE_Self), Loc))));
Analyze (Actual);
-- A task type cannot otherwise appear as an actual
else
raise Program_Error;
end if;
end if;
end if;
-- Type-invariant checks for in-out and out parameters, as well as
-- for in parameters of procedures (AI05-0289 and AI12-0044).
if Ekind (Formal) /= E_In_Parameter
or else Ekind (Subp) = E_Procedure
then
Caller_Side_Invariant_Checks : declare
function Is_Public_Subp return Boolean;
-- Check whether the subprogram being called is a visible
-- operation of the type of the actual. Used to determine
-- whether an invariant check must be generated on the
-- caller side.
---------------------
-- Is_Public_Subp --
---------------------
function Is_Public_Subp return Boolean is
Pack : constant Entity_Id := Scope (Subp);
Subp_Decl : Node_Id;
begin
if not Is_Subprogram (Subp) then
return False;
-- The operation may be inherited, or a primitive of the
-- root type.
elsif
Nkind (Parent (Subp)) in N_Private_Extension_Declaration
| N_Full_Type_Declaration
then
Subp_Decl := Parent (Subp);
else
Subp_Decl := Unit_Declaration_Node (Subp);
end if;
return Ekind (Pack) = E_Package
and then
List_Containing (Subp_Decl) =
Visible_Declarations
(Specification (Unit_Declaration_Node (Pack)));
end Is_Public_Subp;
-- Start of processing for Caller_Side_Invariant_Checks
begin
-- We generate caller-side invariant checks in two cases:
-- a) when calling an inherited operation, where there is an
-- implicit view conversion of the actual to the parent type.
-- b) When the conversion is explicit
-- We treat these cases separately because the required
-- conversion for a) is added later when expanding the call.
if Has_Invariants (Etype (Actual))
and then
Nkind (Parent (Etype (Actual)))
= N_Private_Extension_Declaration
then
if Comes_From_Source (N) and then Is_Public_Subp then
Append_To (Post_Call, Make_Invariant_Call (Actual));
end if;
elsif Nkind (Actual) = N_Type_Conversion
and then Has_Invariants (Etype (Expression (Actual)))
then
if Comes_From_Source (N) and then Is_Public_Subp then
Append_To
(Post_Call, Make_Invariant_Call (Expression (Actual)));
end if;
end if;
end Caller_Side_Invariant_Checks;
end if;
Next_Formal (Formal);
Next_Actual (Actual);
end loop;
end Expand_Actuals;
-----------------
-- Expand_Call --
-----------------
procedure Expand_Call (N : Node_Id) is
Post_Call : List_Id;
-- If this is an indirect call through an Access_To_Subprogram
-- with contract specifications, it is rewritten as a call to
-- the corresponding Access_Subprogram_Wrapper with the same
-- actuals, whose body contains a naked indirect call (which
-- itself must not be rewritten, to prevent infinite recursion).
Must_Rewrite_Indirect_Call : constant Boolean :=
Ada_Version >= Ada_2020
and then Nkind (Name (N)) = N_Explicit_Dereference
and then Ekind (Etype (Name (N))) = E_Subprogram_Type
and then Present
(Access_Subprogram_Wrapper (Etype (Name (N))));
begin
pragma Assert (Nkind (N) in N_Entry_Call_Statement
| N_Function_Call
| N_Procedure_Call_Statement);
-- Check that this is not the call in the body of the wrapper
if Must_Rewrite_Indirect_Call
and then (not Is_Overloadable (Current_Scope)
or else not Is_Access_Subprogram_Wrapper (Current_Scope))
then
declare
Loc : constant Source_Ptr := Sloc (N);
Wrapper : constant Entity_Id :=
Access_Subprogram_Wrapper (Etype (Name (N)));
Ptr : constant Node_Id := Prefix (Name (N));
Ptr_Type : constant Entity_Id := Etype (Ptr);
Typ : constant Entity_Id := Etype (N);
New_N : Node_Id;
Parms : List_Id := Parameter_Associations (N);
Ptr_Act : Node_Id;
begin
-- The last actual in the call is the pointer itself.
-- If the aspect is inherited, convert the pointer to the
-- parent type that specifies the contract.
-- If the original access_to_subprogram has defaults for
-- in_parameters, the call may include named associations, so
-- we create one for the pointer as well.
if Is_Derived_Type (Ptr_Type)
and then Ptr_Type /= Etype (Last_Formal (Wrapper))
then
Ptr_Act :=
Make_Type_Conversion (Loc,
New_Occurrence_Of
(Etype (Last_Formal (Wrapper)), Loc), Ptr);
else
Ptr_Act := Ptr;
end if;
-- Handle parameterless subprogram.
if No (Parms) then
Parms := New_List;
end if;
Append
(Make_Parameter_Association (Loc,
Selector_Name => Make_Identifier (Loc,
Chars (Last_Formal (Wrapper))),
Explicit_Actual_Parameter => Ptr_Act),
Parms);
if Nkind (N) = N_Procedure_Call_Statement then
New_N := Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Wrapper, Loc),
Parameter_Associations => Parms);
else
New_N := Make_Function_Call (Loc,
Name => New_Occurrence_Of (Wrapper, Loc),
Parameter_Associations => Parms);
end if;
Rewrite (N, New_N);
Analyze_And_Resolve (N, Typ);
end;
else
Expand_Call_Helper (N, Post_Call);
Insert_Post_Call_Actions (N, Post_Call);
end if;
end Expand_Call;
------------------------
-- Expand_Call_Helper --
------------------------
-- This procedure handles expansion of function calls and procedure call
-- statements (i.e. it serves as the body for Expand_N_Function_Call and
-- Expand_N_Procedure_Call_Statement). Processing for calls includes:
-- Replace call to Raise_Exception by Raise_Exception_Always if possible
-- Provide values of actuals for all formals in Extra_Formals list
-- Replace "call" to enumeration literal function by literal itself
-- Rewrite call to predefined operator as operator
-- Replace actuals to in-out parameters that are numeric conversions,
-- with explicit assignment to temporaries before and after the call.
-- Note that the list of actuals has been filled with default expressions
-- during semantic analysis of the call. Only the extra actuals required
-- for the 'Constrained attribute and for accessibility checks are added
-- at this point.
procedure Expand_Call_Helper (N : Node_Id; Post_Call : out List_Id) is
Loc : constant Source_Ptr := Sloc (N);
Call_Node : Node_Id := N;
Extra_Actuals : List_Id := No_List;
Prev : Node_Id := Empty;
procedure Add_Actual_Parameter (Insert_Param : Node_Id);
-- Adds one entry to the end of the actual parameter list. Used for
-- default parameters and for extra actuals (for Extra_Formals). The
-- argument is an N_Parameter_Association node.
procedure Add_Extra_Actual (Expr : Node_Id; EF : Entity_Id);
-- Adds an extra actual to the list of extra actuals. Expr is the
-- expression for the value of the actual, EF is the entity for the
-- extra formal.
procedure Add_View_Conversion_Invariants
(Formal : Entity_Id;
Actual : Node_Id);
-- Adds invariant checks for every intermediate type between the range
-- of a view converted argument to its ancestor (from parent to child).
function Can_Fold_Predicate_Call (P : Entity_Id) return Boolean;
-- Try to constant-fold a predicate check, which often enough is a
-- simple arithmetic expression that can be computed statically if
-- its argument is static. This cleans up the output of CCG, even
-- though useless predicate checks will be generally removed by
-- back-end optimizations.
procedure Check_Subprogram_Variant;
-- Emit a call to the internally generated procedure with checks for
-- aspect Subprogrgram_Variant, if present and enabled.
function Inherited_From_Formal (S : Entity_Id) return Entity_Id;
-- Within an instance, a type derived from an untagged formal derived
-- type inherits from the original parent, not from the actual. The
-- current derivation mechanism has the derived type inherit from the
-- actual, which is only correct outside of the instance. If the
-- subprogram is inherited, we test for this particular case through a
-- convoluted tree traversal before setting the proper subprogram to be
-- called.
function In_Unfrozen_Instance (E : Entity_Id) return Boolean;
-- Return true if E comes from an instance that is not yet frozen
function Is_Class_Wide_Interface_Type (E : Entity_Id) return Boolean;
-- Return True when E is a class-wide interface type or an access to
-- a class-wide interface type.
function Is_Direct_Deep_Call (Subp : Entity_Id) return Boolean;
-- Determine if Subp denotes a non-dispatching call to a Deep routine
function New_Value (From : Node_Id) return Node_Id;
-- From is the original Expression. New_Value is equivalent to a call
-- to Duplicate_Subexpr with an explicit dereference when From is an
-- access parameter.
--------------------------
-- Add_Actual_Parameter --
--------------------------
procedure Add_Actual_Parameter (Insert_Param : Node_Id) is
Actual_Expr : constant Node_Id :=
Explicit_Actual_Parameter (Insert_Param);
begin
-- Case of insertion is first named actual
if No (Prev) or else
Nkind (Parent (Prev)) /= N_Parameter_Association
then
Set_Next_Named_Actual
(Insert_Param, First_Named_Actual (Call_Node));
Set_First_Named_Actual (Call_Node, Actual_Expr);
if No (Prev) then
if No (Parameter_Associations (Call_Node)) then
Set_Parameter_Associations (Call_Node, New_List);
end if;
Append (Insert_Param, Parameter_Associations (Call_Node));
else
Insert_After (Prev, Insert_Param);
end if;
-- Case of insertion is not first named actual
else
Set_Next_Named_Actual
(Insert_Param, Next_Named_Actual (Parent (Prev)));
Set_Next_Named_Actual (Parent (Prev), Actual_Expr);
Append (Insert_Param, Parameter_Associations (Call_Node));
end if;
Prev := Actual_Expr;
end Add_Actual_Parameter;
----------------------
-- Add_Extra_Actual --
----------------------
procedure Add_Extra_Actual (Expr : Node_Id; EF : Entity_Id) is
Loc : constant Source_Ptr := Sloc (Expr);
begin
if Extra_Actuals = No_List then
Extra_Actuals := New_List;
Set_Parent (Extra_Actuals, Call_Node);
end if;
Append_To (Extra_Actuals,
Make_Parameter_Association (Loc,
Selector_Name => New_Occurrence_Of (EF, Loc),
Explicit_Actual_Parameter => Expr));
Analyze_And_Resolve (Expr, Etype (EF));
if Nkind (Call_Node) = N_Function_Call then
Set_Is_Accessibility_Actual (Parent (Expr));
end if;
end Add_Extra_Actual;
------------------------------------
-- Add_View_Conversion_Invariants --
------------------------------------
procedure Add_View_Conversion_Invariants
(Formal : Entity_Id;
Actual : Node_Id)
is
Arg : Entity_Id;
Curr_Typ : Entity_Id;
Inv_Checks : List_Id;
Par_Typ : Entity_Id;
begin
Inv_Checks := No_List;
-- Extract the argument from a potentially nested set of view
-- conversions.
Arg := Actual;
while Nkind (Arg) = N_Type_Conversion loop
Arg := Expression (Arg);
end loop;
-- Move up the derivation chain starting with the type of the formal
-- parameter down to the type of the actual object.
Curr_Typ := Empty;
Par_Typ := Etype (Arg);
while Par_Typ /= Etype (Formal) and Par_Typ /= Curr_Typ loop
Curr_Typ := Par_Typ;
if Has_Invariants (Curr_Typ)
and then Present (Invariant_Procedure (Curr_Typ))
then
-- Verify the invariant of the current type. Generate:
-- <Curr_Typ>Invariant (Curr_Typ (Arg));
Prepend_New_To (Inv_Checks,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of
(Invariant_Procedure (Curr_Typ), Loc),
Parameter_Associations => New_List (
Make_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (Curr_Typ, Loc),
Expression => New_Copy_Tree (Arg)))));
end if;
Par_Typ := Base_Type (Etype (Curr_Typ));
end loop;
-- If the node is a function call the generated tests have been
-- already handled in Insert_Post_Call_Actions.
if not Is_Empty_List (Inv_Checks)
and then Nkind (Call_Node) = N_Procedure_Call_Statement
then
Insert_Actions_After (Call_Node, Inv_Checks);
end if;
end Add_View_Conversion_Invariants;
-----------------------------
-- Can_Fold_Predicate_Call --
-----------------------------
function Can_Fold_Predicate_Call (P : Entity_Id) return Boolean is
Actual : Node_Id;
function May_Fold (N : Node_Id) return Traverse_Result;
-- The predicate expression is foldable if it only contains operators
-- and literals. During this check, we also replace occurrences of
-- the formal of the constructed predicate function with the static
-- value of the actual. This is done on a copy of the analyzed
-- expression for the predicate.
--------------
-- May_Fold --
--------------
function May_Fold (N : Node_Id) return Traverse_Result is
begin
case Nkind (N) is
when N_Op =>
return OK;
when N_Expanded_Name
| N_Identifier
=>
if Ekind (Entity (N)) = E_In_Parameter
and then Entity (N) = First_Entity (P)
then
Rewrite (N, New_Copy (Actual));
Set_Is_Static_Expression (N);
return OK;
elsif Ekind (Entity (N)) = E_Enumeration_Literal then
return OK;
else
return Abandon;
end if;
when N_Case_Expression
| N_If_Expression
=>
return OK;
when N_Integer_Literal =>
return OK;
when others =>
return Abandon;
end case;
end May_Fold;
function Try_Fold is new Traverse_Func (May_Fold);
-- Other lLocal variables
Subt : constant Entity_Id := Etype (First_Entity (P));
Aspect : Node_Id;
Pred : Node_Id;
-- Start of processing for Can_Fold_Predicate_Call
begin
-- Folding is only interesting if the actual is static and its type
-- has a Dynamic_Predicate aspect. For CodePeer we preserve the
-- function call.
Actual := First (Parameter_Associations (Call_Node));
Aspect := Find_Aspect (Subt, Aspect_Dynamic_Predicate);
-- If actual is a declared constant, retrieve its value
if Is_Entity_Name (Actual)
and then Ekind (Entity (Actual)) = E_Constant
then
Actual := Constant_Value (Entity (Actual));
end if;
if No (Actual)
or else Nkind (Actual) /= N_Integer_Literal
or else not Has_Dynamic_Predicate_Aspect (Subt)
or else No (Aspect)
or else CodePeer_Mode
then
return False;
end if;
-- Retrieve the analyzed expression for the predicate
Pred := New_Copy_Tree (Expression (Aspect));
if Try_Fold (Pred) = OK then
Rewrite (Call_Node, Pred);
Analyze_And_Resolve (Call_Node, Standard_Boolean);
return True;
-- Otherwise continue the expansion of the function call
else
return False;
end if;
end Can_Fold_Predicate_Call;
------------------------------
-- Check_Subprogram_Variant --
------------------------------
procedure Check_Subprogram_Variant is
Variant_Prag : constant Node_Id :=
Get_Pragma (Current_Scope, Pragma_Subprogram_Variant);
Variant_Proc : Entity_Id;
begin
if Present (Variant_Prag) and then Is_Checked (Variant_Prag) then
-- Analysis of the pragma rewrites its argument with a reference
-- to the internally generated procedure.
Variant_Proc :=
Entity
(Expression
(First
(Pragma_Argument_Associations (Variant_Prag))));
Insert_Action (Call_Node,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (Variant_Proc, Loc),
Parameter_Associations =>
New_Copy_List (Parameter_Associations (Call_Node))));
end if;
end Check_Subprogram_Variant;
---------------------------
-- Inherited_From_Formal --
---------------------------
function Inherited_From_Formal (S : Entity_Id) return Entity_Id is
Par : Entity_Id;
Gen_Par : Entity_Id;
Gen_Prim : Elist_Id;
Elmt : Elmt_Id;
Indic : Node_Id;
begin
-- If the operation is inherited, it is attached to the corresponding
-- type derivation. If the parent in the derivation is a generic
-- actual, it is a subtype of the actual, and we have to recover the
-- original derived type declaration to find the proper parent.
if Nkind (Parent (S)) /= N_Full_Type_Declaration
or else not Is_Derived_Type (Defining_Identifier (Parent (S)))
or else Nkind (Type_Definition (Original_Node (Parent (S)))) /=
N_Derived_Type_Definition
or else not In_Instance
then
return Empty;
else
Indic :=
Subtype_Indication
(Type_Definition (Original_Node (Parent (S))));
if Nkind (Indic) = N_Subtype_Indication then
Par := Entity (Subtype_Mark (Indic));
else
Par := Entity (Indic);
end if;
end if;
if not Is_Generic_Actual_Type (Par)
or else Is_Tagged_Type (Par)
or else Nkind (Parent (Par)) /= N_Subtype_Declaration
or else not In_Open_Scopes (Scope (Par))
then
return Empty;
else
Gen_Par := Generic_Parent_Type (Parent (Par));
end if;
-- If the actual has no generic parent type, the formal is not
-- a formal derived type, so nothing to inherit.
if No (Gen_Par) then
return Empty;
end if;
-- If the generic parent type is still the generic type, this is a
-- private formal, not a derived formal, and there are no operations
-- inherited from the formal.
if Nkind (Parent (Gen_Par)) = N_Formal_Type_Declaration then
return Empty;
end if;
Gen_Prim := Collect_Primitive_Operations (Gen_Par);
Elmt := First_Elmt (Gen_Prim);
while Present (Elmt) loop
if Chars (Node (Elmt)) = Chars (S) then
declare
F1 : Entity_Id;
F2 : Entity_Id;
begin
F1 := First_Formal (S);
F2 := First_Formal (Node (Elmt));
while Present (F1)
and then Present (F2)
loop
if Etype (F1) = Etype (F2)
or else Etype (F2) = Gen_Par
then
Next_Formal (F1);
Next_Formal (F2);
else
Next_Elmt (Elmt);
exit; -- not the right subprogram
end if;
return Node (Elmt);
end loop;
end;
else
Next_Elmt (Elmt);
end if;
end loop;
raise Program_Error;
end Inherited_From_Formal;
--------------------------
-- In_Unfrozen_Instance --
--------------------------
function In_Unfrozen_Instance (E : Entity_Id) return Boolean is
S : Entity_Id;
begin
S := E;
while Present (S) and then S /= Standard_Standard loop
if Is_Generic_Instance (S)
and then Present (Freeze_Node (S))
and then not Analyzed (Freeze_Node (S))
then
return True;
end if;
S := Scope (S);
end loop;
return False;
end In_Unfrozen_Instance;
----------------------------------
-- Is_Class_Wide_Interface_Type --
----------------------------------
function Is_Class_Wide_Interface_Type (E : Entity_Id) return Boolean is
DDT : Entity_Id;
Typ : Entity_Id := E;
begin
if Has_Non_Limited_View (Typ) then
Typ := Non_Limited_View (Typ);
end if;
if Ekind (Typ) = E_Anonymous_Access_Type then
DDT := Directly_Designated_Type (Typ);
if Has_Non_Limited_View (DDT) then
DDT := Non_Limited_View (DDT);
end if;
return Is_Class_Wide_Type (DDT) and then Is_Interface (DDT);
else
return Is_Class_Wide_Type (Typ) and then Is_Interface (Typ);
end if;
end Is_Class_Wide_Interface_Type;
-------------------------
-- Is_Direct_Deep_Call --
-------------------------
function Is_Direct_Deep_Call (Subp : Entity_Id) return Boolean is
begin
if Is_TSS (Subp, TSS_Deep_Adjust)
or else Is_TSS (Subp, TSS_Deep_Finalize)
or else Is_TSS (Subp, TSS_Deep_Initialize)
then
declare
Actual : Node_Id;
Formal : Entity_Id;
begin
Actual := First (Parameter_Associations (Call_Node));
Formal := First_Formal (Subp);
while Present (Actual)
and then Present (Formal)
loop
if Nkind (Actual) = N_Identifier
and then Is_Controlling_Actual (Actual)
and then Etype (Actual) = Etype (Formal)
then
return True;
end if;
Next (Actual);
Next_Formal (Formal);
end loop;
end;
end if;
return False;
end Is_Direct_Deep_Call;
---------------
-- New_Value --
---------------
function New_Value (From : Node_Id) return Node_Id is
Res : constant Node_Id := Duplicate_Subexpr (From);
begin
if Is_Access_Type (Etype (From)) then
return Make_Explicit_Dereference (Sloc (From), Prefix => Res);
else
return Res;
end if;
end New_Value;
-- Local variables
Remote : constant Boolean := Is_Remote_Call (Call_Node);
Actual : Node_Id;
Formal : Entity_Id;
Orig_Subp : Entity_Id := Empty;
Param_Count : Positive;
Parent_Formal : Entity_Id;
Parent_Subp : Entity_Id;
Prev_Ult : Node_Id;
Scop : Entity_Id;
Subp : Entity_Id;
Prev_Orig : Node_Id;
-- Original node for an actual, which may have been rewritten. If the
-- actual is a function call that has been transformed from a selected
-- component, the original node is unanalyzed. Otherwise, it carries
-- semantic information used to generate additional actuals.
CW_Interface_Formals_Present : Boolean := False;
-- Start of processing for Expand_Call_Helper
begin
Post_Call := New_List;
-- Expand the function or procedure call if the first actual has a
-- declared dimension aspect, and the subprogram is declared in one
-- of the dimension I/O packages.
if Ada_Version >= Ada_2012
and then
Nkind (Call_Node) in N_Procedure_Call_Statement | N_Function_Call
and then Present (Parameter_Associations (Call_Node))
then
Expand_Put_Call_With_Symbol (Call_Node);
end if;
-- Ignore if previous error
if Nkind (Call_Node) in N_Has_Etype
and then Etype (Call_Node) = Any_Type
then
return;
end if;
-- Call using access to subprogram with explicit dereference
if Nkind (Name (Call_Node)) = N_Explicit_Dereference then
Subp := Etype (Name (Call_Node));
Parent_Subp := Empty;
-- Case of call to simple entry, where the Name is a selected component
-- whose prefix is the task, and whose selector name is the entry name
elsif Nkind (Name (Call_Node)) = N_Selected_Component then
Subp := Entity (Selector_Name (Name (Call_Node)));
Parent_Subp := Empty;
-- Case of call to member of entry family, where Name is an indexed
-- component, with the prefix being a selected component giving the
-- task and entry family name, and the index being the entry index.
elsif Nkind (Name (Call_Node)) = N_Indexed_Component then
Subp := Entity (Selector_Name (Prefix (Name (Call_Node))));
Parent_Subp := Empty;
-- Normal case
else
Subp := Entity (Name (Call_Node));
Parent_Subp := Alias (Subp);
-- Replace call to Raise_Exception by call to Raise_Exception_Always
-- if we can tell that the first parameter cannot possibly be null.
-- This improves efficiency by avoiding a run-time test.
-- We do not do this if Raise_Exception_Always does not exist, which
-- can happen in configurable run time profiles which provide only a
-- Raise_Exception.
if Is_RTE (Subp, RE_Raise_Exception)
and then RTE_Available (RE_Raise_Exception_Always)
then
declare
FA : constant Node_Id :=
Original_Node (First_Actual (Call_Node));
begin
-- The case we catch is where the first argument is obtained
-- using the Identity attribute (which must always be
-- non-null).
if Nkind (FA) = N_Attribute_Reference
and then Attribute_Name (FA) = Name_Identity
then
Subp := RTE (RE_Raise_Exception_Always);
Set_Name (Call_Node, New_Occurrence_Of (Subp, Loc));
end if;
end;
end if;
if Ekind (Subp) = E_Entry then
Parent_Subp := Empty;
end if;
end if;
-- Ada 2005 (AI-345): We have a procedure call as a triggering
-- alternative in an asynchronous select or as an entry call in
-- a conditional or timed select. Check whether the procedure call
-- is a renaming of an entry and rewrite it as an entry call.
if Ada_Version >= Ada_2005
and then Nkind (Call_Node) = N_Procedure_Call_Statement
and then
((Nkind (Parent (Call_Node)) = N_Triggering_Alternative
and then Triggering_Statement (Parent (Call_Node)) = Call_Node)
or else
(Nkind (Parent (Call_Node)) = N_Entry_Call_Alternative
and then Entry_Call_Statement (Parent (Call_Node)) = Call_Node))
then
declare
Ren_Decl : Node_Id;
Ren_Root : Entity_Id := Subp;
begin
-- This may be a chain of renamings, find the root
if Present (Alias (Ren_Root)) then
Ren_Root := Alias (Ren_Root);
end if;
if Present (Original_Node (Parent (Parent (Ren_Root)))) then
Ren_Decl := Original_Node (Parent (Parent (Ren_Root)));
if Nkind (Ren_Decl) = N_Subprogram_Renaming_Declaration then
Rewrite (Call_Node,
Make_Entry_Call_Statement (Loc,
Name =>
New_Copy_Tree (Name (Ren_Decl)),
Parameter_Associations =>
New_Copy_List_Tree
(Parameter_Associations (Call_Node))));
return;
end if;
end if;
end;
end if;
-- If this is a call to a predicate function, try to constant fold it
if Nkind (Call_Node) = N_Function_Call
and then Is_Entity_Name (Name (Call_Node))
and then Is_Predicate_Function (Subp)
and then Can_Fold_Predicate_Call (Subp)
then
return;
end if;
if Modify_Tree_For_C
and then Nkind (Call_Node) = N_Function_Call
and then Is_Entity_Name (Name (Call_Node))
then
declare
Func_Id : constant Entity_Id :=
Ultimate_Alias (Entity (Name (Call_Node)));
begin
-- When generating C code, transform a function call that returns
-- a constrained array type into procedure form.
if Rewritten_For_C (Func_Id) then
-- For internally generated calls ensure that they reference
-- the entity of the spec of the called function (needed since
-- the expander may generate calls using the entity of their
-- body). See for example Expand_Boolean_Operator().
if not (Comes_From_Source (Call_Node))
and then Nkind (Unit_Declaration_Node (Func_Id)) =
N_Subprogram_Body
then
Set_Entity (Name (Call_Node),
Corresponding_Function
(Corresponding_Procedure (Func_Id)));
end if;
Rewrite_Function_Call_For_C (Call_Node);
return;
-- Also introduce a temporary for functions that return a record
-- called within another procedure or function call, since records
-- are passed by pointer in the generated C code, and we cannot
-- take a pointer from a subprogram call.
elsif Nkind (Parent (Call_Node)) in N_Subprogram_Call
and then Is_Record_Type (Etype (Func_Id))
then
declare
Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'T');
Decl : Node_Id;
begin
-- Generate:
-- Temp : ... := Func_Call (...);
Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Temp_Id,
Object_Definition =>
New_Occurrence_Of (Etype (Func_Id), Loc),
Expression =>
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (Func_Id, Loc),
Parameter_Associations =>
Parameter_Associations (Call_Node)));
Insert_Action (Parent (Call_Node), Decl);
Rewrite (Call_Node, New_Occurrence_Of (Temp_Id, Loc));
return;
end;
end if;
end;
end if;
-- First step, compute extra actuals, corresponding to any Extra_Formals
-- present. Note that we do not access Extra_Formals directly, instead
-- we simply note the presence of the extra formals as we process the
-- regular formals collecting corresponding actuals in Extra_Actuals.
-- We also generate any required range checks for actuals for in formals
-- as we go through the loop, since this is a convenient place to do it.
-- (Though it seems that this would be better done in Expand_Actuals???)
-- Special case: Thunks must not compute the extra actuals; they must
-- just propagate to the target primitive their extra actuals.
if Is_Thunk (Current_Scope)
and then Thunk_Entity (Current_Scope) = Subp
and then Present (Extra_Formals (Subp))
then
pragma Assert (Present (Extra_Formals (Current_Scope)));
declare
Target_Formal : Entity_Id;
Thunk_Formal : Entity_Id;
begin
Target_Formal := Extra_Formals (Subp);
Thunk_Formal := Extra_Formals (Current_Scope);
while Present (Target_Formal) loop
Add_Extra_Actual
(Expr => New_Occurrence_Of (Thunk_Formal, Loc),
EF => Thunk_Formal);
Target_Formal := Extra_Formal (Target_Formal);
Thunk_Formal := Extra_Formal (Thunk_Formal);
end loop;
while Is_Non_Empty_List (Extra_Actuals) loop
Add_Actual_Parameter (Remove_Head (Extra_Actuals));
end loop;
Expand_Actuals (Call_Node, Subp, Post_Call);
pragma Assert (Is_Empty_List (Post_Call));
pragma Assert (Check_Number_Of_Actuals (Call_Node, Subp));
pragma Assert (Check_BIP_Actuals (Call_Node, Subp));
return;
end;
end if;
Formal := First_Formal (Subp);
Actual := First_Actual (Call_Node);
Param_Count := 1;
while Present (Formal) loop
-- Prepare to examine current entry
Prev := Actual;
Prev_Orig := Original_Node (Prev);
-- Ada 2005 (AI-251): Check if any formal is a class-wide interface
-- to expand it in a further round.
CW_Interface_Formals_Present :=
CW_Interface_Formals_Present
or else Is_Class_Wide_Interface_Type (Etype (Formal));
-- Create possible extra actual for constrained case. Usually, the
-- extra actual is of the form actual'constrained, but since this
-- attribute is only available for unconstrained records, TRUE is
-- expanded if the type of the formal happens to be constrained (for
-- instance when this procedure is inherited from an unconstrained
-- record to a constrained one) or if the actual has no discriminant
-- (its type is constrained). An exception to this is the case of a
-- private type without discriminants. In this case we pass FALSE
-- because the object has underlying discriminants with defaults.
if Present (Extra_Constrained (Formal)) then
if Ekind (Etype (Prev)) in Private_Kind
and then not Has_Discriminants (Base_Type (Etype (Prev)))
then
Add_Extra_Actual
(Expr => New_Occurrence_Of (Standard_False, Loc),
EF => Extra_Constrained (Formal));
elsif Is_Constrained (Etype (Formal))
or else not Has_Discriminants (Etype (Prev))
then
Add_Extra_Actual
(Expr => New_Occurrence_Of (Standard_True, Loc),
EF => Extra_Constrained (Formal));
-- Do not produce extra actuals for Unchecked_Union parameters.
-- Jump directly to the end of the loop.
elsif Is_Unchecked_Union (Base_Type (Etype (Actual))) then
goto Skip_Extra_Actual_Generation;
else
-- If the actual is a type conversion, then the constrained
-- test applies to the actual, not the target type.
declare
Act_Prev : Node_Id;
begin
-- Test for unchecked conversions as well, which can occur
-- as out parameter actuals on calls to stream procedures.
Act_Prev := Prev;
while Nkind (Act_Prev) in N_Type_Conversion
| N_Unchecked_Type_Conversion
loop
Act_Prev := Expression (Act_Prev);
end loop;
-- If the expression is a conversion of a dereference, this
-- is internally generated code that manipulates addresses,
-- e.g. when building interface tables. No check should
-- occur in this case, and the discriminated object is not
-- directly a hand.
if not Comes_From_Source (Actual)
and then Nkind (Actual) = N_Unchecked_Type_Conversion
and then Nkind (Act_Prev) = N_Explicit_Dereference
then
Add_Extra_Actual
(Expr => New_Occurrence_Of (Standard_False, Loc),
EF => Extra_Constrained (Formal));
else
Add_Extra_Actual
(Expr =>
Make_Attribute_Reference (Sloc (Prev),
Prefix =>
Duplicate_Subexpr_No_Checks
(Act_Prev, Name_Req => True),
Attribute_Name => Name_Constrained),
EF => Extra_Constrained (Formal));
end if;
end;
end if;
end if;
-- Create possible extra actual for accessibility level
if Present (Get_Accessibility (Formal)) then
-- Ada 2005 (AI-252): If the actual was rewritten as an Access
-- attribute, then the original actual may be an aliased object
-- occurring as the prefix in a call using "Object.Operation"
-- notation. In that case we must pass the level of the object,
-- so Prev_Orig is reset to Prev and the attribute will be
-- processed by the code for Access attributes further below.
if Prev_Orig /= Prev
and then Nkind (Prev) = N_Attribute_Reference
and then Get_Attribute_Id (Attribute_Name (Prev)) =
Attribute_Access
and then Is_Aliased_View (Prev_Orig)
then
Prev_Orig := Prev;
-- A class-wide precondition generates a test in which formals of
-- the subprogram are replaced by actuals that came from source.
-- In that case as well, the accessiblity comes from the actual.
-- This is the one case in which there are references to formals
-- outside of their subprogram.
elsif Prev_Orig /= Prev
and then Is_Entity_Name (Prev_Orig)
and then Present (Entity (Prev_Orig))
and then Is_Formal (Entity (Prev_Orig))
and then not In_Open_Scopes (Scope (Entity (Prev_Orig)))
then
Prev_Orig := Prev;
-- If the actual is a formal of an enclosing subprogram it is
-- the right entity, even if it is a rewriting. This happens
-- when the call is within an inherited condition or predicate.
elsif Is_Entity_Name (Actual)
and then Is_Formal (Entity (Actual))
and then In_Open_Scopes (Scope (Entity (Actual)))
then
Prev_Orig := Prev;
-- If the actual is an attribute reference that was expanded
-- into a reference to an entity, then get accessibility level
-- from that entity. AARM 6.1.1(27.d) says "... the implicit
-- constant declaration defines the accessibility level of X'Old".
elsif Nkind (Prev_Orig) = N_Attribute_Reference
and then Attribute_Name (Prev_Orig) in Name_Old | Name_Loop_Entry
and then Is_Entity_Name (Prev)
and then Present (Entity (Prev))
and then Is_Object (Entity (Prev))
then
Prev_Orig := Prev;
elsif Nkind (Prev_Orig) = N_Type_Conversion then
Prev_Orig := Expression (Prev_Orig);
end if;
-- Ada 2005 (AI-251): Thunks must propagate the extra actuals of
-- accessibility levels.
if Is_Thunk (Current_Scope) then
declare
Parm_Ent : Entity_Id;
begin
if Is_Controlling_Actual (Actual) then
-- Find the corresponding actual of the thunk
Parm_Ent := First_Entity (Current_Scope);
for J in 2 .. Param_Count loop
Next_Entity (Parm_Ent);
end loop;
-- Handle unchecked conversion of access types generated
-- in thunks (cf. Expand_Interface_Thunk).
elsif Is_Access_Type (Etype (Actual))
and then Nkind (Actual) = N_Unchecked_Type_Conversion
then
Parm_Ent := Entity (Expression (Actual));
else pragma Assert (Is_Entity_Name (Actual));
Parm_Ent := Entity (Actual);
end if;
Add_Extra_Actual
(Expr =>
New_Occurrence_Of (Get_Accessibility (Parm_Ent), Loc),
EF => Get_Accessibility (Formal));
end;
elsif Is_Entity_Name (Prev_Orig) then
-- When passing an access parameter, or a renaming of an access
-- parameter, as the actual to another access parameter we need
-- to pass along the actual's own access level parameter. This
-- is done if we are within the scope of the formal access
-- parameter (if this is an inlined body the extra formal is
-- irrelevant).
if (Is_Formal (Entity (Prev_Orig))
or else
(Present (Renamed_Object (Entity (Prev_Orig)))
and then
Is_Entity_Name (Renamed_Object (Entity (Prev_Orig)))
and then
Is_Formal
(Entity (Renamed_Object (Entity (Prev_Orig))))))
and then Ekind (Etype (Prev_Orig)) = E_Anonymous_Access_Type
and then In_Open_Scopes (Scope (Entity (Prev_Orig)))
then
declare
Parm_Ent : constant Entity_Id := Param_Entity (Prev_Orig);
begin
pragma Assert (Present (Parm_Ent));
if Present (Get_Accessibility (Parm_Ent)) then
Add_Extra_Actual
(Expr =>
New_Occurrence_Of
(Get_Accessibility (Parm_Ent), Loc),
EF => Get_Accessibility (Formal));
-- If the actual access parameter does not have an
-- associated extra formal providing its scope level,
-- then treat the actual as having library-level
-- accessibility.
else
Add_Extra_Actual
(Expr =>
Make_Integer_Literal (Loc,
Intval => Scope_Depth (Standard_Standard)),
EF => Get_Accessibility (Formal));
end if;
end;
-- The actual is a normal access value, so just pass the level
-- of the actual's access type.
else
Add_Extra_Actual
(Expr => Dynamic_Accessibility_Level (Prev_Orig),
EF => Get_Accessibility (Formal));
end if;
-- If the actual is an access discriminant, then pass the level
-- of the enclosing object (RM05-3.10.2(12.4/2)).
elsif Nkind (Prev_Orig) = N_Selected_Component
and then Ekind (Entity (Selector_Name (Prev_Orig))) =
E_Discriminant
and then Ekind (Etype (Entity (Selector_Name (Prev_Orig)))) =
E_Anonymous_Access_Type
then
Add_Extra_Actual
(Expr =>
Make_Integer_Literal (Loc,
Intval => Object_Access_Level (Prefix (Prev_Orig))),
EF => Get_Accessibility (Formal));
-- All other cases
else
case Nkind (Prev_Orig) is
when N_Attribute_Reference =>
case Get_Attribute_Id (Attribute_Name (Prev_Orig)) is
-- Ignore 'Result, 'Loop_Entry, and 'Old as they can
-- be used to identify access objects and do not have
-- an effect on accessibility level.
when Attribute_Loop_Entry
| Attribute_Old
| Attribute_Result
=>
null;
-- For X'Access, pass on the level of the prefix X
when Attribute_Access =>
-- Accessibility level of S'Access is that of A
Prev_Orig := Prefix (Prev_Orig);
-- If the expression is a view conversion, the
-- accessibility level is that of the expression.
if Nkind (Original_Node (Prev_Orig)) =
N_Type_Conversion
and then
Nkind (Expression (Original_Node (Prev_Orig))) =
N_Explicit_Dereference
then
Prev_Orig :=
Expression (Original_Node (Prev_Orig));
end if;
-- Obtain the ultimate prefix so we can check for
-- the case where we are taking 'Access of a
-- component of an anonymous access formal - which
-- would mean we need to pass said formal's
-- corresponding extra accessibility formal.
Prev_Ult := Ultimate_Prefix (Prev_Orig);
if Is_Entity_Name (Prev_Ult)
and then not Is_Type (Entity (Prev_Ult))
and then Present
(Get_Accessibility
(Entity (Prev_Ult)))
then
Add_Extra_Actual
(Expr =>
New_Occurrence_Of
(Get_Accessibility
(Entity (Prev_Ult)), Loc),
EF => Get_Accessibility (Formal));
-- Normal case, call Object_Access_Level. Note:
-- should be Dynamic_Accessibility_Level ???
else
Add_Extra_Actual
(Expr =>
Make_Integer_Literal (Loc,
Intval =>
Object_Access_Level (Prev_Orig)),
EF => Get_Accessibility (Formal));
end if;
-- Treat the unchecked attributes as library-level
when Attribute_Unchecked_Access
| Attribute_Unrestricted_Access
=>
Add_Extra_Actual
(Expr =>
Make_Integer_Literal (Loc,
Intval => Scope_Depth (Standard_Standard)),
EF => Get_Accessibility (Formal));
-- No other cases of attributes returning access
-- values that can be passed to access parameters.
when others =>
raise Program_Error;
end case;
-- For allocators we pass the level of the execution of the
-- called subprogram, which is one greater than the current
-- scope level. However, according to RM 3.10.2(14/3) this
-- is wrong since for an anonymous allocator defining the
-- value of an access parameter, the accessibility level is
-- that of the innermost master of the call???
when N_Allocator =>
Add_Extra_Actual
(Expr =>
Make_Integer_Literal (Loc,
Intval => Scope_Depth (Current_Scope) + 1),
EF => Get_Accessibility (Formal));
-- For most other cases we simply pass the level of the
-- actual's access type. The type is retrieved from
-- Prev rather than Prev_Orig, because in some cases
-- Prev_Orig denotes an original expression that has
-- not been analyzed.
-- However, when the actual is wrapped in a conditional
-- expression we must add a local temporary to store the
-- level at each branch, and, possibly, expand the call
-- into an expression with actions.
when others =>
if Nkind (Prev) = N_Expression_With_Actions
and then Nkind (Original_Node (Prev)) in
N_If_Expression | N_Case_Expression
then
declare
Decl : Node_Id;
pragma Warnings (Off, Decl);
-- Suppress warning for the final removal loop
Lvl : Entity_Id;
Res : Entity_Id;
Temp : Node_Id;
Typ : Node_Id;
procedure Insert_Level_Assign (Branch : Node_Id);
-- Recursivly add assignment of the level temporary
-- on each branch while moving through nested
-- conditional expressions.
-------------------------
-- Insert_Level_Assign --
-------------------------
procedure Insert_Level_Assign (Branch : Node_Id) is
procedure Expand_Branch (Res_Assn : Node_Id);
-- Perform expansion or iterate further within
-- nested conditionals given the object
-- declaration or assignment to result object
-- created during expansion which represents
-- a branch of the conditional expression.
-------------------
-- Expand_Branch --
-------------------
procedure Expand_Branch (Res_Assn : Node_Id) is
begin
pragma Assert (Nkind (Res_Assn) in
N_Assignment_Statement |
N_Object_Declaration);
-- There are more nested conditional
-- expressions so we must go deeper.
if Nkind (Expression (Res_Assn)) =
N_Expression_With_Actions
and then
Nkind
(Original_Node (Expression (Res_Assn)))
in N_Case_Expression | N_If_Expression
then
Insert_Level_Assign
(Expression (Res_Assn));
-- Add the level assignment
else
Insert_Before_And_Analyze (Res_Assn,
Make_Assignment_Statement (Loc,
Name =>
New_Occurrence_Of
(Lvl, Loc),
Expression =>
Dynamic_Accessibility_Level
(Expression (Res_Assn))));
end if;
end Expand_Branch;
Cond : Node_Id;
Alt : Node_Id;
-- Start of processing for Insert_Level_Assign
begin
-- Examine further nested condtionals
pragma Assert (Nkind (Branch) =
N_Expression_With_Actions);
-- Find the relevant statement in the actions
Cond := First (Actions (Branch));
while Present (Cond) loop
exit when Nkind (Cond) in
N_Case_Statement | N_If_Statement;
Next (Cond);
end loop;
-- The conditional expression may have been
-- optimized away, so examine the actions in
-- the branch.
if No (Cond) then
Expand_Branch (Last (Actions (Branch)));
-- Iterate through if expression branches
elsif Nkind (Cond) = N_If_Statement then
Expand_Branch (Last (Then_Statements (Cond)));
Expand_Branch (Last (Else_Statements (Cond)));
-- Iterate through case alternatives
elsif Nkind (Cond) = N_Case_Statement then
Alt := First (Alternatives (Cond));
while Present (Alt) loop
Expand_Branch (Last (Statements (Alt)));
Next (Alt);
end loop;
end if;
end Insert_Level_Assign;
-- Start of processing for cond expression case
begin
-- Create declaration of a temporary to store the
-- accessibility level of each branch of the
-- conditional expression.
Lvl := Make_Temporary (Loc, 'L');
Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Lvl,
Object_Definition =>
New_Occurrence_Of (Standard_Natural, Loc));
-- Install the declaration and perform necessary
-- expansion if we are dealing with a function
-- call.
if Nkind (Call_Node) = N_Procedure_Call_Statement
then
-- Generate:
-- Lvl : Natural;
-- Call (
-- {do
-- If_Exp_Res : Typ;
-- if Cond then
-- Lvl := 0; -- Access level
-- If_Exp_Res := Exp;
-- ...
-- in If_Exp_Res end;},
-- Lvl,
-- ...
-- )
Insert_Before_And_Analyze (Call_Node, Decl);
-- A function call must be transformed into an
-- expression with actions.
else
-- Generate:
-- do
-- Lvl : Natural;
-- in Call (do{
-- If_Exp_Res : Typ
-- if Cond then
-- Lvl := 0; -- Access level
-- If_Exp_Res := Exp;
-- in If_Exp_Res end;},
-- Lvl,
-- ...
-- )
-- end;
Res := Make_Temporary (Loc, 'R');
Typ := Etype (Call_Node);
Temp := Relocate_Node (Call_Node);
-- Perform the rewrite with the dummy
Rewrite (Call_Node,
Make_Expression_With_Actions (Loc,
Expression => New_Occurrence_Of (Res, Loc),
Actions => New_List (
Decl,
Make_Object_Declaration (Loc,
Defining_Identifier => Res,
Object_Definition =>
New_Occurrence_Of (Typ, Loc)))));
-- Analyze the expression with the dummy
Analyze_And_Resolve (Call_Node, Typ);
-- Properly set the expression and move our view
-- of the call node
Set_Expression (Call_Node, Relocate_Node (Temp));
Call_Node := Expression (Call_Node);
-- Remove the declaration of the dummy and the
-- subsequent actions its analysis has created.
while Present (Remove_Next (Decl)) loop
null;
end loop;
end if;
-- Decorate the conditional expression with
-- assignments to our level temporary.
Insert_Level_Assign (Prev);
-- Make our level temporary the passed actual
Add_Extra_Actual
(Expr => New_Occurrence_Of (Lvl, Loc),
EF => Get_Accessibility (Formal));
end;
-- General case uncomplicated by conditional expressions
else
Add_Extra_Actual
(Expr => Dynamic_Accessibility_Level (Prev),
EF => Get_Accessibility (Formal));
end if;
end case;
end if;
end if;
-- Perform the check of 4.6(49) that prevents a null value from being
-- passed as an actual to an access parameter. Note that the check
-- is elided in the common cases of passing an access attribute or
-- access parameter as an actual. Also, we currently don't enforce
-- this check for expander-generated actuals and when -gnatdj is set.
if Ada_Version >= Ada_2005 then
-- Ada 2005 (AI-231): Check null-excluding access types. Note that
-- the intent of 6.4.1(13) is that null-exclusion checks should
-- not be done for 'out' parameters, even though it refers only
-- to constraint checks, and a null_exclusion is not a constraint.
-- Note that AI05-0196-1 corrects this mistake in the RM.
if Is_Access_Type (Etype (Formal))
and then Can_Never_Be_Null (Etype (Formal))
and then Ekind (Formal) /= E_Out_Parameter
and then Nkind (Prev) /= N_Raise_Constraint_Error
and then (Known_Null (Prev)
or else not Can_Never_Be_Null (Etype (Prev)))
then
Install_Null_Excluding_Check (Prev);
end if;
-- Ada_Version < Ada_2005
else
if Ekind (Etype (Formal)) /= E_Anonymous_Access_Type
or else Access_Checks_Suppressed (Subp)
then
null;
elsif Debug_Flag_J then
null;
elsif not Comes_From_Source (Prev) then
null;
elsif Is_Entity_Name (Prev)
and then Ekind (Etype (Prev)) = E_Anonymous_Access_Type
then
null;
elsif Nkind (Prev) in N_Allocator | N_Attribute_Reference then
null;
else
Install_Null_Excluding_Check (Prev);
end if;
end if;
-- Perform appropriate validity checks on parameters that
-- are entities.
if Validity_Checks_On then
if (Ekind (Formal) = E_In_Parameter
and then Validity_Check_In_Params)
or else
(Ekind (Formal) = E_In_Out_Parameter
and then Validity_Check_In_Out_Params)
then
-- If the actual is an indexed component of a packed type (or
-- is an indexed or selected component whose prefix recursively
-- meets this condition), it has not been expanded yet. It will
-- be copied in the validity code that follows, and has to be
-- expanded appropriately, so reanalyze it.
-- What we do is just to unset analyzed bits on prefixes till
-- we reach something that does not have a prefix.
declare
Nod : Node_Id;
begin
Nod := Actual;
while Nkind (Nod) in
N_Indexed_Component | N_Selected_Component
loop
Set_Analyzed (Nod, False);
Nod := Prefix (Nod);
end loop;
end;
Ensure_Valid (Actual);
end if;
end if;
-- For IN OUT and OUT parameters, ensure that subscripts are valid
-- since this is a left side reference. We only do this for calls
-- from the source program since we assume that compiler generated
-- calls explicitly generate any required checks. We also need it
-- only if we are doing standard validity checks, since clearly it is
-- not needed if validity checks are off, and in subscript validity
-- checking mode, all indexed components are checked with a call
-- directly from Expand_N_Indexed_Component.
if Comes_From_Source (Call_Node)
and then Ekind (Formal) /= E_In_Parameter
and then Validity_Checks_On
and then Validity_Check_Default
and then not Validity_Check_Subscripts
then
Check_Valid_Lvalue_Subscripts (Actual);
end if;
-- Mark any scalar OUT parameter that is a simple variable as no
-- longer known to be valid (unless the type is always valid). This
-- reflects the fact that if an OUT parameter is never set in a
-- procedure, then it can become invalid on the procedure return.
if Ekind (Formal) = E_Out_Parameter
and then Is_Entity_Name (Actual)
and then Ekind (Entity (Actual)) = E_Variable
and then not Is_Known_Valid (Etype (Actual))
then
Set_Is_Known_Valid (Entity (Actual), False);
end if;
-- For an OUT or IN OUT parameter, if the actual is an entity, then
-- clear current values, since they can be clobbered. We are probably
-- doing this in more places than we need to, but better safe than
-- sorry when it comes to retaining bad current values.
if Ekind (Formal) /= E_In_Parameter
and then Is_Entity_Name (Actual)
and then Present (Entity (Actual))
then
declare
Ent : constant Entity_Id := Entity (Actual);
Sav : Node_Id;
begin
-- For an OUT or IN OUT parameter that is an assignable entity,
-- we do not want to clobber the Last_Assignment field, since
-- if it is set, it was precisely because it is indeed an OUT
-- or IN OUT parameter. We do reset the Is_Known_Valid flag
-- since the subprogram could have returned in invalid value.
if Is_Assignable (Ent) then
Sav := Last_Assignment (Ent);
Kill_Current_Values (Ent);
Set_Last_Assignment (Ent, Sav);
Set_Is_Known_Valid (Ent, False);
Set_Is_True_Constant (Ent, False);
-- For all other cases, just kill the current values
else
Kill_Current_Values (Ent);
end if;
end;
end if;
-- If the formal is class wide and the actual is an aggregate, force
-- evaluation so that the back end who does not know about class-wide
-- type, does not generate a temporary of the wrong size.
if not Is_Class_Wide_Type (Etype (Formal)) then
null;
elsif Nkind (Actual) = N_Aggregate
or else (Nkind (Actual) = N_Qualified_Expression
and then Nkind (Expression (Actual)) = N_Aggregate)
then
Force_Evaluation (Actual);
end if;
-- In a remote call, if the formal is of a class-wide type, check
-- that the actual meets the requirements described in E.4(18).
if Remote and then Is_Class_Wide_Type (Etype (Formal)) then
Insert_Action (Actual,
Make_Transportable_Check (Loc,
Duplicate_Subexpr_Move_Checks (Actual)));
end if;
-- Perform invariant checks for all intermediate types in a view
-- conversion after successful return from a call that passes the
-- view conversion as an IN OUT or OUT parameter (RM 7.3.2 (12/3,
-- 13/3, 14/3)). Consider only source conversion in order to avoid
-- generating spurious checks on complex expansion such as object
-- initialization through an extension aggregate.
if Comes_From_Source (Call_Node)
and then Ekind (Formal) /= E_In_Parameter
and then Nkind (Actual) = N_Type_Conversion
then
Add_View_Conversion_Invariants (Formal, Actual);
end if;
-- Generating C the initialization of an allocator is performed by
-- means of individual statements, and hence it must be done before
-- the call.
if Modify_Tree_For_C
and then Nkind (Actual) = N_Allocator
and then Nkind (Expression (Actual)) = N_Qualified_Expression
then
Remove_Side_Effects (Actual);
end if;
-- This label is required when skipping extra actual generation for
-- Unchecked_Union parameters.
<<Skip_Extra_Actual_Generation>>
Param_Count := Param_Count + 1;
Next_Actual (Actual);
Next_Formal (Formal);
end loop;
-- If we are calling an Ada 2012 function which needs to have the
-- "accessibility level determined by the point of call" (AI05-0234)
-- passed in to it, then pass it in.
if Ekind (Subp) in E_Function | E_Operator | E_Subprogram_Type
and then
Present (Extra_Accessibility_Of_Result (Ultimate_Alias (Subp)))
then
declare
Ancestor : Node_Id := Parent (Call_Node);
Level : Node_Id := Empty;
Defer : Boolean := False;
begin
-- Unimplemented: if Subp returns an anonymous access type, then
-- a) if the call is the operand of an explict conversion, then
-- the target type of the conversion (a named access type)
-- determines the accessibility level pass in;
-- b) if the call defines an access discriminant of an object
-- (e.g., the discriminant of an object being created by an
-- allocator, or the discriminant of a function result),
-- then the accessibility level to pass in is that of the
-- discriminated object being initialized).
-- ???
while Nkind (Ancestor) = N_Qualified_Expression
loop
Ancestor := Parent (Ancestor);
end loop;
case Nkind (Ancestor) is
when N_Allocator =>
-- At this point, we'd like to assign
-- Level := Dynamic_Accessibility_Level (Ancestor);
-- but Etype of Ancestor may not have been set yet,
-- so that doesn't work.
-- Handle this later in Expand_Allocator_Expression.
Defer := True;
when N_Object_Declaration
| N_Object_Renaming_Declaration
=>
declare
Def_Id : constant Entity_Id :=
Defining_Identifier (Ancestor);
begin
if Is_Return_Object (Def_Id) then
if Present (Extra_Accessibility_Of_Result
(Return_Applies_To (Scope (Def_Id))))
then
-- Pass along value that was passed in if the
-- routine we are returning from also has an
-- Accessibility_Of_Result formal.
Level :=
New_Occurrence_Of
(Extra_Accessibility_Of_Result
(Return_Applies_To (Scope (Def_Id))), Loc);
end if;
else
Level :=
Make_Integer_Literal (Loc,
Intval => Object_Access_Level (Def_Id));
end if;
end;
when N_Simple_Return_Statement =>
if Present (Extra_Accessibility_Of_Result
(Return_Applies_To
(Return_Statement_Entity (Ancestor))))
then
-- Pass along value that was passed in if the returned
-- routine also has an Accessibility_Of_Result formal.
Level :=
New_Occurrence_Of
(Extra_Accessibility_Of_Result
(Return_Applies_To
(Return_Statement_Entity (Ancestor))), Loc);
end if;
when others =>
null;
end case;
if not Defer then
if not Present (Level) then
-- The "innermost master that evaluates the function call".
-- ??? - Should we use Integer'Last here instead in order
-- to deal with (some of) the problems associated with
-- calls to subps whose enclosing scope is unknown (e.g.,
-- Anon_Access_To_Subp_Param.all)?
Level :=
Make_Integer_Literal (Loc,
Intval => Scope_Depth (Current_Scope) + 1);
end if;
Add_Extra_Actual
(Expr => Level,
EF =>
Extra_Accessibility_Of_Result (Ultimate_Alias (Subp)));
end if;
end;
end if;
-- If we are expanding the RHS of an assignment we need to check if tag
-- propagation is needed. You might expect this processing to be in
-- Analyze_Assignment but has to be done earlier (bottom-up) because the
-- assignment might be transformed to a declaration for an unconstrained
-- value if the expression is classwide.
if Nkind (Call_Node) = N_Function_Call
and then Is_Tag_Indeterminate (Call_Node)
and then Is_Entity_Name (Name (Call_Node))
then
declare
Ass : Node_Id := Empty;
begin
if Nkind (Parent (Call_Node)) = N_Assignment_Statement then
Ass := Parent (Call_Node);
elsif Nkind (Parent (Call_Node)) = N_Qualified_Expression
and then Nkind (Parent (Parent (Call_Node))) =
N_Assignment_Statement
then
Ass := Parent (Parent (Call_Node));
elsif Nkind (Parent (Call_Node)) = N_Explicit_Dereference
and then Nkind (Parent (Parent (Call_Node))) =
N_Assignment_Statement
then
Ass := Parent (Parent (Call_Node));
end if;
if Present (Ass)
and then Is_Class_Wide_Type (Etype (Name (Ass)))
then
-- Move the error messages below to sem???
if Is_Access_Type (Etype (Call_Node)) then
if Designated_Type (Etype (Call_Node)) /=
Root_Type (Etype (Name (Ass)))
then
Error_Msg_NE
("tag-indeterminate expression must have designated "
& "type& (RM 5.2 (6))",
Call_Node, Root_Type (Etype (Name (Ass))));
else
Propagate_Tag (Name (Ass), Call_Node);
end if;
elsif Etype (Call_Node) /= Root_Type (Etype (Name (Ass))) then
Error_Msg_NE
("tag-indeterminate expression must have type & "
& "(RM 5.2 (6))",
Call_Node, Root_Type (Etype (Name (Ass))));
else
Propagate_Tag (Name (Ass), Call_Node);
end if;
-- The call will be rewritten as a dispatching call, and
-- expanded as such.
return;
end if;
end;
end if;
-- Ada 2005 (AI-251): If some formal is a class-wide interface, expand
-- it to point to the correct secondary virtual table.
if Nkind (Call_Node) in N_Subprogram_Call
and then CW_Interface_Formals_Present
then
Expand_Interface_Actuals (Call_Node);
end if;
-- Deals with Dispatch_Call if we still have a call, before expanding
-- extra actuals since this will be done on the re-analysis of the
-- dispatching call. Note that we do not try to shorten the actual list
-- for a dispatching call, it would not make sense to do so. Expansion
-- of dispatching calls is suppressed for VM targets, because the VM
-- back-ends directly handle the generation of dispatching calls and
-- would have to undo any expansion to an indirect call.
if Nkind (Call_Node) in N_Subprogram_Call
and then Present (Controlling_Argument (Call_Node))
then
declare
Call_Typ : constant Entity_Id := Etype (Call_Node);
Typ : constant Entity_Id := Find_Dispatching_Type (Subp);
Eq_Prim_Op : Entity_Id := Empty;
New_Call : Node_Id;
Param : Node_Id;
Prev_Call : Node_Id;
begin
if not Is_Limited_Type (Typ) then
Eq_Prim_Op := Find_Prim_Op (Typ, Name_Op_Eq);
end if;
if Tagged_Type_Expansion then
Expand_Dispatching_Call (Call_Node);
-- The following return is worrisome. Is it really OK to skip
-- all remaining processing in this procedure ???
return;
-- VM targets
else
Apply_Tag_Checks (Call_Node);
-- If this is a dispatching "=", we must first compare the
-- tags so we generate: x.tag = y.tag and then x = y
if Subp = Eq_Prim_Op then
-- Mark the node as analyzed to avoid reanalyzing this
-- dispatching call (which would cause a never-ending loop)
Prev_Call := Relocate_Node (Call_Node);
Set_Analyzed (Prev_Call);
Param := First_Actual (Call_Node);
New_Call :=
Make_And_Then (Loc,
Left_Opnd =>
Make_Op_Eq (Loc,
Left_Opnd =>
Make_Selected_Component (Loc,
Prefix => New_Value (Param),
Selector_Name =>
New_Occurrence_Of
(First_Tag_Component (Typ), Loc)),
Right_Opnd =>
Make_Selected_Component (Loc,
Prefix =>
Unchecked_Convert_To (Typ,
New_Value (Next_Actual (Param))),
Selector_Name =>
New_Occurrence_Of
(First_Tag_Component (Typ), Loc))),
Right_Opnd => Prev_Call);
Rewrite (Call_Node, New_Call);
Analyze_And_Resolve
(Call_Node, Call_Typ, Suppress => All_Checks);
end if;
-- Expansion of a dispatching call results in an indirect call,
-- which in turn causes current values to be killed (see
-- Resolve_Call), so on VM targets we do the call here to
-- ensure consistent warnings between VM and non-VM targets.
Kill_Current_Values;
end if;
-- If this is a dispatching "=" then we must update the reference
-- to the call node because we generated:
-- x.tag = y.tag and then x = y
if Subp = Eq_Prim_Op then
Call_Node := Right_Opnd (Call_Node);
end if;
end;
end if;
-- Similarly, expand calls to RCI subprograms on which pragma
-- All_Calls_Remote applies. The rewriting will be reanalyzed
-- later. Do this only when the call comes from source since we
-- do not want such a rewriting to occur in expanded code.
if Is_All_Remote_Call (Call_Node) then
Expand_All_Calls_Remote_Subprogram_Call (Call_Node);
-- Similarly, do not add extra actuals for an entry call whose entity
-- is a protected procedure, or for an internal protected subprogram
-- call, because it will be rewritten as a protected subprogram call
-- and reanalyzed (see Expand_Protected_Subprogram_Call).
elsif Is_Protected_Type (Scope (Subp))
and then Ekind (Subp) in E_Procedure | E_Function
then
null;
-- During that loop we gathered the extra actuals (the ones that
-- correspond to Extra_Formals), so now they can be appended.
else
while Is_Non_Empty_List (Extra_Actuals) loop
Add_Actual_Parameter (Remove_Head (Extra_Actuals));
end loop;
end if;
-- At this point we have all the actuals, so this is the point at which
-- the various expansion activities for actuals is carried out.
Expand_Actuals (Call_Node, Subp, Post_Call);
-- If it is a recursive call then call the internal procedure that
-- verifies Subprogram_Variant contract (if present and enabled).
-- Detecting calls to subprogram aliases is necessary for recursive
-- calls in instances of generic subprograms, where the renaming of
-- the current subprogram is called.
if Is_Subprogram (Subp)
and then Same_Or_Aliased_Subprograms (Subp, Current_Scope)
then
Check_Subprogram_Variant;
end if;
-- Verify that the actuals do not share storage. This check must be done
-- on the caller side rather that inside the subprogram to avoid issues
-- of parameter passing.
if Check_Aliasing_Of_Parameters then
Apply_Parameter_Aliasing_Checks (Call_Node, Subp);
end if;
-- If the subprogram is a renaming, or if it is inherited, replace it in
-- the call with the name of the actual subprogram being called. If this
-- is a dispatching call, the run-time decides what to call. The Alias
-- attribute does not apply to entries.
if Nkind (Call_Node) /= N_Entry_Call_Statement
and then No (Controlling_Argument (Call_Node))
and then Present (Parent_Subp)
and then not Is_Direct_Deep_Call (Subp)
then
if Present (Inherited_From_Formal (Subp)) then
Parent_Subp := Inherited_From_Formal (Subp);
else
Parent_Subp := Ultimate_Alias (Parent_Subp);
end if;
-- The below setting of Entity is suspect, see F109-018 discussion???
Set_Entity (Name (Call_Node), Parent_Subp);
-- Move this check to sem???
if Is_Abstract_Subprogram (Parent_Subp)
and then not In_Instance
then
Error_Msg_NE
("cannot call abstract subprogram &!",
Name (Call_Node), Parent_Subp);
end if;
-- Inspect all formals of derived subprogram Subp. Compare parameter
-- types with the parent subprogram and check whether an actual may
-- need a type conversion to the corresponding formal of the parent
-- subprogram.
-- Not clear whether intrinsic subprograms need such conversions. ???
if not Is_Intrinsic_Subprogram (Parent_Subp)
or else Is_Generic_Instance (Parent_Subp)
then
declare
procedure Convert (Act : Node_Id; Typ : Entity_Id);
-- Rewrite node Act as a type conversion of Act to Typ. Analyze
-- and resolve the newly generated construct.
-------------
-- Convert --
-------------
procedure Convert (Act : Node_Id; Typ : Entity_Id) is
begin
Rewrite (Act, OK_Convert_To (Typ, Act));
Analyze_And_Resolve (Act, Typ);
end Convert;
-- Local variables
Actual_Typ : Entity_Id;
Formal_Typ : Entity_Id;
Parent_Typ : Entity_Id;
begin
Actual := First_Actual (Call_Node);
Formal := First_Formal (Subp);
Parent_Formal := First_Formal (Parent_Subp);
while Present (Formal) loop
Actual_Typ := Etype (Actual);
Formal_Typ := Etype (Formal);
Parent_Typ := Etype (Parent_Formal);
-- For an IN parameter of a scalar type, the derived formal
-- type and parent formal type differ, and the parent formal
-- type and actual type do not match statically.
if Is_Scalar_Type (Formal_Typ)
and then Ekind (Formal) = E_In_Parameter
and then Formal_Typ /= Parent_Typ
and then
not Subtypes_Statically_Match (Parent_Typ, Actual_Typ)
and then not Raises_Constraint_Error (Actual)
then
Convert (Actual, Parent_Typ);
-- For access types, the parent formal type and actual type
-- differ.
elsif Is_Access_Type (Formal_Typ)
and then Base_Type (Parent_Typ) /= Base_Type (Actual_Typ)
then
if Ekind (Formal) /= E_In_Parameter then
Convert (Actual, Parent_Typ);
elsif Ekind (Parent_Typ) = E_Anonymous_Access_Type
and then Designated_Type (Parent_Typ) /=
Designated_Type (Actual_Typ)
and then not Is_Controlling_Formal (Formal)
then
-- This unchecked conversion is not necessary unless
-- inlining is enabled, because in that case the type
-- mismatch may become visible in the body about to be
-- inlined.
Rewrite (Actual,
Unchecked_Convert_To (Parent_Typ, Actual));
Analyze_And_Resolve (Actual, Parent_Typ);
end if;
-- If there is a change of representation, then generate a
-- warning, and do the change of representation.
elsif not Has_Compatible_Representation
(Target_Type => Formal_Typ,
Operand_Type => Parent_Typ)
then
Error_Msg_N
("??change of representation required", Actual);
Convert (Actual, Parent_Typ);
-- For array and record types, the parent formal type and
-- derived formal type have different sizes or pragma Pack
-- status.
elsif ((Is_Array_Type (Formal_Typ)
and then Is_Array_Type (Parent_Typ))
or else
(Is_Record_Type (Formal_Typ)
and then Is_Record_Type (Parent_Typ)))
and then
(Esize (Formal_Typ) /= Esize (Parent_Typ)
or else Has_Pragma_Pack (Formal_Typ) /=
Has_Pragma_Pack (Parent_Typ))
then
Convert (Actual, Parent_Typ);
end if;
Next_Actual (Actual);
Next_Formal (Formal);
Next_Formal (Parent_Formal);
end loop;
end;
end if;
Orig_Subp := Subp;
Subp := Parent_Subp;
end if;
-- Deal with case where call is an explicit dereference
if Nkind (Name (Call_Node)) = N_Explicit_Dereference then
-- Handle case of access to protected subprogram type
if Is_Access_Protected_Subprogram_Type
(Base_Type (Etype (Prefix (Name (Call_Node)))))
then
-- If this is a call through an access to protected operation, the
-- prefix has the form (object'address, operation'access). Rewrite
-- as a for other protected calls: the object is the 1st parameter
-- of the list of actuals.
declare
Call : Node_Id;
Parm : List_Id;
Nam : Node_Id;
Obj : Node_Id;
Ptr : constant Node_Id := Prefix (Name (Call_Node));
T : constant Entity_Id :=
Equivalent_Type (Base_Type (Etype (Ptr)));
D_T : constant Entity_Id :=
Designated_Type (Base_Type (Etype (Ptr)));
begin
Obj :=
Make_Selected_Component (Loc,
Prefix => Unchecked_Convert_To (T, Ptr),
Selector_Name =>
New_Occurrence_Of (First_Entity (T), Loc));
Nam :=
Make_Selected_Component (Loc,
Prefix => Unchecked_Convert_To (T, Ptr),
Selector_Name =>
New_Occurrence_Of (Next_Entity (First_Entity (T)), Loc));
Nam :=
Make_Explicit_Dereference (Loc,
Prefix => Nam);
if Present (Parameter_Associations (Call_Node)) then
Parm := Parameter_Associations (Call_Node);
else
Parm := New_List;
end if;
Prepend (Obj, Parm);
if Etype (D_T) = Standard_Void_Type then
Call :=
Make_Procedure_Call_Statement (Loc,
Name => Nam,
Parameter_Associations => Parm);
else
Call :=
Make_Function_Call (Loc,
Name => Nam,
Parameter_Associations => Parm);
end if;
Set_First_Named_Actual (Call, First_Named_Actual (Call_Node));
Set_Etype (Call, Etype (D_T));
-- We do not re-analyze the call to avoid infinite recursion.
-- We analyze separately the prefix and the object, and set
-- the checks on the prefix that would otherwise be emitted
-- when resolving a call.
Rewrite (Call_Node, Call);
Analyze (Nam);
Apply_Access_Check (Nam);
Analyze (Obj);
return;
end;
end if;
end if;
-- If this is a call to an intrinsic subprogram, then perform the
-- appropriate expansion to the corresponding tree node and we
-- are all done (since after that the call is gone).
-- In the case where the intrinsic is to be processed by the back end,
-- the call to Expand_Intrinsic_Call will do nothing, which is fine,
-- since the idea in this case is to pass the call unchanged. If the
-- intrinsic is an inherited unchecked conversion, and the derived type
-- is the target type of the conversion, we must retain it as the return
-- type of the expression. Otherwise the expansion below, which uses the
-- parent operation, will yield the wrong type.
if Is_Intrinsic_Subprogram (Subp) then
Expand_Intrinsic_Call (Call_Node, Subp);
if Nkind (Call_Node) = N_Unchecked_Type_Conversion
and then Parent_Subp /= Orig_Subp
and then Etype (Parent_Subp) /= Etype (Orig_Subp)
then
Set_Etype (Call_Node, Etype (Orig_Subp));
end if;
return;
end if;
if Ekind (Subp) in E_Function | E_Procedure then
-- We perform a simple optimization on calls for To_Address by
-- replacing them with an unchecked conversion. Not only is this
-- efficient, but it also avoids order of elaboration problems when
-- address clauses are inlined (address expression elaborated at the
-- wrong point).
-- We perform this optimization regardless of whether we are in the
-- main unit or in a unit in the context of the main unit, to ensure
-- that the generated tree is the same in both cases, for CodePeer
-- use.
if Is_RTE (Subp, RE_To_Address) then
Rewrite (Call_Node,
Unchecked_Convert_To
(RTE (RE_Address), Relocate_Node (First_Actual (Call_Node))));
return;
-- A call to a null procedure is replaced by a null statement, but we
-- are not allowed to ignore possible side effects of the call, so we
-- make sure that actuals are evaluated.
-- We also suppress this optimization for GNATcoverage.
elsif Is_Null_Procedure (Subp)
and then not Opt.Suppress_Control_Flow_Optimizations
then
Actual := First_Actual (Call_Node);
while Present (Actual) loop
Remove_Side_Effects (Actual);
Next_Actual (Actual);
end loop;
Rewrite (Call_Node, Make_Null_Statement (Loc));
return;
end if;
-- Handle inlining. No action needed if the subprogram is not inlined
if not Is_Inlined (Subp) then
null;
-- Front-end inlining of expression functions (performed also when
-- back-end inlining is enabled).
elsif Is_Inlinable_Expression_Function (Subp) then
Rewrite
(Call_Node, New_Copy (Expression_Of_Expression_Function (Subp)));
Analyze (Call_Node);
return;
-- Handle front-end inlining
elsif not Back_End_Inlining then
Inlined_Subprogram : declare
Bod : Node_Id;
Must_Inline : Boolean := False;
Spec : constant Node_Id := Unit_Declaration_Node (Subp);
begin
-- Verify that the body to inline has already been seen, and
-- that if the body is in the current unit the inlining does
-- not occur earlier. This avoids order-of-elaboration problems
-- in the back end.
-- This should be documented in sinfo/einfo ???
if No (Spec)
or else Nkind (Spec) /= N_Subprogram_Declaration
or else No (Body_To_Inline (Spec))
then
Must_Inline := False;
-- If this an inherited function that returns a private type,
-- do not inline if the full view is an unconstrained array,
-- because such calls cannot be inlined.
elsif Present (Orig_Subp)
and then Is_Array_Type (Etype (Orig_Subp))
and then not Is_Constrained (Etype (Orig_Subp))
then
Must_Inline := False;
elsif In_Unfrozen_Instance (Scope (Subp)) then
Must_Inline := False;
else
Bod := Body_To_Inline (Spec);
if (In_Extended_Main_Code_Unit (Call_Node)
or else In_Extended_Main_Code_Unit (Parent (Call_Node))
or else Has_Pragma_Inline_Always (Subp))
and then (not In_Same_Extended_Unit (Sloc (Bod), Loc)
or else
Earlier_In_Extended_Unit (Sloc (Bod), Loc))
then
Must_Inline := True;
-- If we are compiling a package body that is not the main
-- unit, it must be for inlining/instantiation purposes,
-- in which case we inline the call to insure that the same
-- temporaries are generated when compiling the body by
-- itself. Otherwise link errors can occur.
-- If the function being called is itself in the main unit,
-- we cannot inline, because there is a risk of double
-- elaboration and/or circularity: the inlining can make
-- visible a private entity in the body of the main unit,
-- that gigi will see before its sees its proper definition.
elsif not In_Extended_Main_Code_Unit (Call_Node)
and then In_Package_Body
then
Must_Inline := not In_Extended_Main_Source_Unit (Subp);
-- Inline calls to _postconditions when generating C code
elsif Modify_Tree_For_C
and then In_Same_Extended_Unit (Sloc (Bod), Loc)
and then Chars (Name (Call_Node)) = Name_uPostconditions
then
Must_Inline := True;
end if;
end if;
if Must_Inline then
Expand_Inlined_Call (Call_Node, Subp, Orig_Subp);
else
-- Let the back end handle it
Add_Inlined_Body (Subp, Call_Node);
if Front_End_Inlining
and then Nkind (Spec) = N_Subprogram_Declaration
and then In_Extended_Main_Code_Unit (Call_Node)
and then No (Body_To_Inline (Spec))
and then not Has_Completion (Subp)
and then In_Same_Extended_Unit (Sloc (Spec), Loc)
then
Cannot_Inline
("cannot inline& (body not seen yet)?",
Call_Node, Subp);
end if;
end if;
end Inlined_Subprogram;
-- Front-end expansion of simple functions returning unconstrained
-- types (see Check_And_Split_Unconstrained_Function). Note that the
-- case of a simple renaming (Body_To_Inline in N_Entity below, see
-- also Build_Renamed_Body) cannot be expanded here because this may
-- give rise to order-of-elaboration issues for the types of the
-- parameters of the subprogram, if any.
elsif Present (Unit_Declaration_Node (Subp))
and then Nkind (Unit_Declaration_Node (Subp)) =
N_Subprogram_Declaration
and then Present (Body_To_Inline (Unit_Declaration_Node (Subp)))
and then
Nkind (Body_To_Inline (Unit_Declaration_Node (Subp))) not in
N_Entity
then
Expand_Inlined_Call (Call_Node, Subp, Orig_Subp);
-- Back-end inlining either if optimization is enabled or the call is
-- required to be inlined.
elsif Optimization_Level > 0
or else Has_Pragma_Inline_Always (Subp)
then
Add_Inlined_Body (Subp, Call_Node);
end if;
end if;
-- Check for protected subprogram. This is either an intra-object call,
-- or a protected function call. Protected procedure calls are rewritten
-- as entry calls and handled accordingly.
-- In Ada 2005, this may be an indirect call to an access parameter that
-- is an access_to_subprogram. In that case the anonymous type has a
-- scope that is a protected operation, but the call is a regular one.
-- In either case do not expand call if subprogram is eliminated.
Scop := Scope (Subp);
if Nkind (Call_Node) /= N_Entry_Call_Statement
and then Is_Protected_Type (Scop)
and then Ekind (Subp) /= E_Subprogram_Type
and then not Is_Eliminated (Subp)
then
-- If the call is an internal one, it is rewritten as a call to the
-- corresponding unprotected subprogram.
Expand_Protected_Subprogram_Call (Call_Node, Subp, Scop);
end if;
-- Functions returning controlled objects need special attention. If
-- the return type is limited, then the context is initialization and
-- different processing applies. If the call is to a protected function,
-- the expansion above will call Expand_Call recursively. Otherwise the
-- function call is transformed into a temporary which obtains the
-- result from the secondary stack.
if Needs_Finalization (Etype (Subp)) then
if not Is_Build_In_Place_Function_Call (Call_Node)
and then
(No (First_Formal (Subp))
or else
not Is_Concurrent_Record_Type (Etype (First_Formal (Subp))))
then
Expand_Ctrl_Function_Call (Call_Node);
-- Build-in-place function calls which appear in anonymous contexts
-- need a transient scope to ensure the proper finalization of the
-- intermediate result after its use.
elsif Is_Build_In_Place_Function_Call (Call_Node)
and then Nkind (Parent (Unqual_Conv (Call_Node))) in
N_Attribute_Reference
| N_Function_Call
| N_Indexed_Component
| N_Object_Renaming_Declaration
| N_Procedure_Call_Statement
| N_Selected_Component
| N_Slice
and then
(Ekind (Current_Scope) /= E_Loop
or else Nkind (Parent (Call_Node)) /= N_Function_Call
or else not Is_Build_In_Place_Function_Call
(Parent (Call_Node)))
then
Establish_Transient_Scope (Call_Node, Manage_Sec_Stack => True);
end if;
end if;
end Expand_Call_Helper;
-------------------------------
-- Expand_Ctrl_Function_Call --
-------------------------------
procedure Expand_Ctrl_Function_Call (N : Node_Id) is
function Is_Element_Reference (N : Node_Id) return Boolean;
-- Determine whether node N denotes a reference to an Ada 2012 container
-- element.
--------------------------
-- Is_Element_Reference --
--------------------------
function Is_Element_Reference (N : Node_Id) return Boolean is
Ref : constant Node_Id := Original_Node (N);
begin
-- Analysis marks an element reference by setting the generalized
-- indexing attribute of an indexed component before the component
-- is rewritten into a function call.
return
Nkind (Ref) = N_Indexed_Component
and then Present (Generalized_Indexing (Ref));
end Is_Element_Reference;
-- Start of processing for Expand_Ctrl_Function_Call
begin
-- Optimization, if the returned value (which is on the sec-stack) is
-- returned again, no need to copy/readjust/finalize, we can just pass
-- the value thru (see Expand_N_Simple_Return_Statement), and thus no
-- attachment is needed
if Nkind (Parent (N)) = N_Simple_Return_Statement then
return;
end if;
-- Resolution is now finished, make sure we don't start analysis again
-- because of the duplication.
Set_Analyzed (N);
-- A function which returns a controlled object uses the secondary
-- stack. Rewrite the call into a temporary which obtains the result of
-- the function using 'reference.
Remove_Side_Effects (N);
-- The side effect removal of the function call produced a temporary.
-- When the context is a case expression, if expression, or expression
-- with actions, the lifetime of the temporary must be extended to match
-- that of the context. Otherwise the function result will be finalized
-- too early and affect the result of the expression. To prevent this
-- unwanted effect, the temporary should not be considered for clean up
-- actions by the general finalization machinery.
-- Exception to this rule are references to Ada 2012 container elements.
-- Such references must be finalized at the end of each iteration of the
-- related quantified expression, otherwise the container will remain
-- busy.
if Nkind (N) = N_Explicit_Dereference
and then Within_Case_Or_If_Expression (N)
and then not Is_Element_Reference (N)
then
Set_Is_Ignored_Transient (Entity (Prefix (N)));
end if;
end Expand_Ctrl_Function_Call;
----------------------------------------
-- Expand_N_Extended_Return_Statement --
----------------------------------------
-- If there is a Handled_Statement_Sequence, we rewrite this:
-- return Result : T := <expression> do
-- <handled_seq_of_stms>
-- end return;
-- to be:
-- declare
-- Result : T := <expression>;
-- begin
-- <handled_seq_of_stms>
-- return Result;
-- end;
-- Otherwise (no Handled_Statement_Sequence), we rewrite this:
-- return Result : T := <expression>;
-- to be:
-- return <expression>;
-- unless it's build-in-place or there's no <expression>, in which case
-- we generate:
-- declare
-- Result : T := <expression>;
-- begin
-- return Result;
-- end;
-- Note that this case could have been written by the user as an extended
-- return statement, or could have been transformed to this from a simple
-- return statement.
-- That is, we need to have a reified return object if there are statements
-- (which might refer to it) or if we're doing build-in-place (so we can
-- set its address to the final resting place or if there is no expression
-- (in which case default initial values might need to be set)).
procedure Expand_N_Extended_Return_Statement (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
function Build_Heap_Or_Pool_Allocator
(Temp_Id : Entity_Id;
Temp_Typ : Entity_Id;
Func_Id : Entity_Id;
Ret_Typ : Entity_Id;
Alloc_Expr : Node_Id) return Node_Id;
-- Create the statements necessary to allocate a return object on the
-- heap or user-defined storage pool. The object may need finalization
-- actions depending on the return type.
--
-- * Controlled case
--
-- if BIPfinalizationmaster = null then
-- Temp_Id := <Alloc_Expr>;
-- else
-- declare
-- type Ptr_Typ is access Ret_Typ;
-- for Ptr_Typ'Storage_Pool use
-- Base_Pool (BIPfinalizationmaster.all).all;
-- Local : Ptr_Typ;
--
-- begin
-- procedure Allocate (...) is
-- begin
-- System.Storage_Pools.Subpools.Allocate_Any (...);
-- end Allocate;
--
-- Local := <Alloc_Expr>;
-- Temp_Id := Temp_Typ (Local);
-- end;
-- end if;
--
-- * Non-controlled case
--
-- Temp_Id := <Alloc_Expr>;
--
-- Temp_Id is the temporary which is used to reference the internally
-- created object in all allocation forms. Temp_Typ is the type of the
-- temporary. Func_Id is the enclosing function. Ret_Typ is the return
-- type of Func_Id. Alloc_Expr is the actual allocator.
function Move_Activation_Chain (Func_Id : Entity_Id) return Node_Id;
-- Construct a call to System.Tasking.Stages.Move_Activation_Chain
-- with parameters:
-- From current activation chain
-- To activation chain passed in by the caller
-- New_Master master passed in by the caller
--
-- Func_Id is the entity of the function where the extended return
-- statement appears.
----------------------------------
-- Build_Heap_Or_Pool_Allocator --
----------------------------------
function Build_Heap_Or_Pool_Allocator
(Temp_Id : Entity_Id;
Temp_Typ : Entity_Id;
Func_Id : Entity_Id;
Ret_Typ : Entity_Id;
Alloc_Expr : Node_Id) return Node_Id
is
begin
pragma Assert (Is_Build_In_Place_Function (Func_Id));
-- Processing for objects that require finalization actions
if Needs_Finalization (Ret_Typ) then
declare
Decls : constant List_Id := New_List;
Fin_Mas_Id : constant Entity_Id :=
Build_In_Place_Formal
(Func_Id, BIP_Finalization_Master);
Orig_Expr : constant Node_Id :=
New_Copy_Tree
(Source => Alloc_Expr,
Scopes_In_EWA_OK => True);
Stmts : constant List_Id := New_List;
Desig_Typ : Entity_Id;
Local_Id : Entity_Id;
Pool_Id : Entity_Id;
Ptr_Typ : Entity_Id;
begin
-- Generate:
-- Pool_Id renames Base_Pool (BIPfinalizationmaster.all).all;
Pool_Id := Make_Temporary (Loc, 'P');
Append_To (Decls,
Make_Object_Renaming_Declaration (Loc,
Defining_Identifier => Pool_Id,
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Root_Storage_Pool), Loc),
Name =>
Make_Explicit_Dereference (Loc,
Prefix =>
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Base_Pool), Loc),
Parameter_Associations => New_List (
Make_Explicit_Dereference (Loc,
Prefix =>
New_Occurrence_Of (Fin_Mas_Id, Loc)))))));
-- Create an access type which uses the storage pool of the
-- caller's master. This additional type is necessary because
-- the finalization master cannot be associated with the type
-- of the temporary. Otherwise the secondary stack allocation
-- will fail.
Desig_Typ := Ret_Typ;
-- Ensure that the build-in-place machinery uses a fat pointer
-- when allocating an unconstrained array on the heap. In this
-- case the result object type is a constrained array type even
-- though the function type is unconstrained.
if Ekind (Desig_Typ) = E_Array_Subtype then
Desig_Typ := Base_Type (Desig_Typ);
end if;
-- Generate:
-- type Ptr_Typ is access Desig_Typ;
Ptr_Typ := Make_Temporary (Loc, 'P');
Append_To (Decls,
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Ptr_Typ,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
Subtype_Indication =>
New_Occurrence_Of (Desig_Typ, Loc))));
-- Perform minor decoration in order to set the master and the
-- storage pool attributes.
Set_Ekind (Ptr_Typ, E_Access_Type);
Set_Finalization_Master (Ptr_Typ, Fin_Mas_Id);
Set_Associated_Storage_Pool (Ptr_Typ, Pool_Id);
-- Create the temporary, generate:
-- Local_Id : Ptr_Typ;
Local_Id := Make_Temporary (Loc, 'T');
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier => Local_Id,
Object_Definition =>
New_Occurrence_Of (Ptr_Typ, Loc)));
-- Allocate the object, generate:
-- Local_Id := <Alloc_Expr>;
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Local_Id, Loc),
Expression => Alloc_Expr));
-- Generate:
-- Temp_Id := Temp_Typ (Local_Id);
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Temp_Id, Loc),
Expression =>
Unchecked_Convert_To (Temp_Typ,
New_Occurrence_Of (Local_Id, Loc))));
-- Wrap the allocation in a block. This is further conditioned
-- by checking the caller finalization master at runtime. A
-- null value indicates a non-existent master, most likely due
-- to a Finalize_Storage_Only allocation.
-- Generate:
-- if BIPfinalizationmaster = null then
-- Temp_Id := <Orig_Expr>;
-- else
-- declare
-- <Decls>
-- begin
-- <Stmts>
-- end;
-- end if;
return
Make_If_Statement (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd => New_Occurrence_Of (Fin_Mas_Id, Loc),
Right_Opnd => Make_Null (Loc)),
Then_Statements => New_List (
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Temp_Id, Loc),
Expression => Orig_Expr)),
Else_Statements => New_List (
Make_Block_Statement (Loc,
Declarations => Decls,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => Stmts))));
end;
-- For all other cases, generate:
-- Temp_Id := <Alloc_Expr>;
else
return
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Temp_Id, Loc),
Expression => Alloc_Expr);
end if;
end Build_Heap_Or_Pool_Allocator;
---------------------------
-- Move_Activation_Chain --
---------------------------
function Move_Activation_Chain (Func_Id : Entity_Id) return Node_Id is
begin
return
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Move_Activation_Chain), Loc),
Parameter_Associations => New_List (
-- Source chain
Make_Attribute_Reference (Loc,
Prefix => Make_Identifier (Loc, Name_uChain),
Attribute_Name => Name_Unrestricted_Access),
-- Destination chain
New_Occurrence_Of
(Build_In_Place_Formal (Func_Id, BIP_Activation_Chain), Loc),
-- New master
New_Occurrence_Of
(Build_In_Place_Formal (Func_Id, BIP_Task_Master), Loc)));
end Move_Activation_Chain;
-- Local variables
Func_Id : constant Entity_Id :=
Return_Applies_To (Return_Statement_Entity (N));
Is_BIP_Func : constant Boolean :=
Is_Build_In_Place_Function (Func_Id);
Ret_Obj_Id : constant Entity_Id :=
First_Entity (Return_Statement_Entity (N));
Ret_Obj_Decl : constant Node_Id := Parent (Ret_Obj_Id);
Ret_Typ : constant Entity_Id := Etype (Func_Id);
Exp : Node_Id;
HSS : Node_Id;
Result : Node_Id;
Stmts : List_Id;
Return_Stmt : Node_Id := Empty;
-- Force initialization to facilitate static analysis
-- Start of processing for Expand_N_Extended_Return_Statement
begin
-- Given that functionality of interface thunks is simple (just displace
-- the pointer to the object) they are always handled by means of
-- simple return statements.
pragma Assert (not Is_Thunk (Current_Subprogram));
if Nkind (Ret_Obj_Decl) = N_Object_Declaration then
Exp := Expression (Ret_Obj_Decl);
-- Assert that if F says "return R : T := G(...) do..."
-- then F and G are both b-i-p, or neither b-i-p.
if Nkind (Exp) = N_Function_Call then
pragma Assert (Ekind (Current_Subprogram) = E_Function);
pragma Assert
(Is_Build_In_Place_Function (Current_Subprogram) =
Is_Build_In_Place_Function_Call (Exp));
null;
end if;
-- Ada 2005 (AI95-344): If the result type is class-wide, then insert
-- a check that the level of the return expression's underlying type
-- is not deeper than the level of the master enclosing the function.
-- AI12-043: The check is made immediately after the return object
-- is created.
if Present (Exp) and then Is_Class_Wide_Type (Ret_Typ) then
Apply_CW_Accessibility_Check (Exp, Func_Id);
end if;
else
Exp := Empty;
end if;
HSS := Handled_Statement_Sequence (N);
-- If the returned object needs finalization actions, the function must
-- perform the appropriate cleanup should it fail to return. The state
-- of the function itself is tracked through a flag which is coupled
-- with the scope finalizer. There is one flag per each return object
-- in case of multiple returns.
if Is_BIP_Func and then Needs_Finalization (Etype (Ret_Obj_Id)) then
declare
Flag_Decl : Node_Id;
Flag_Id : Entity_Id;
Func_Bod : Node_Id;
begin
-- Recover the function body
Func_Bod := Unit_Declaration_Node (Func_Id);
if Nkind (Func_Bod) = N_Subprogram_Declaration then
Func_Bod := Parent (Parent (Corresponding_Body (Func_Bod)));
end if;
if Nkind (Func_Bod) = N_Function_Specification then
Func_Bod := Parent (Func_Bod); -- one more level for child units
end if;
pragma Assert (Nkind (Func_Bod) = N_Subprogram_Body);
-- Create a flag to track the function state
Flag_Id := Make_Temporary (Loc, 'F');
Set_Status_Flag_Or_Transient_Decl (Ret_Obj_Id, Flag_Id);
-- Insert the flag at the beginning of the function declarations,
-- generate:
-- Fnn : Boolean := False;
Flag_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Flag_Id,
Object_Definition =>
New_Occurrence_Of (Standard_Boolean, Loc),
Expression =>
New_Occurrence_Of (Standard_False, Loc));
Prepend_To (Declarations (Func_Bod), Flag_Decl);
Analyze (Flag_Decl);
end;
end if;
-- Build a simple_return_statement that returns the return object when
-- there is a statement sequence, or no expression, or the result will
-- be built in place. Note however that we currently do this for all
-- composite cases, even though not all are built in place.
if Present (HSS)
or else Is_Composite_Type (Ret_Typ)
or else No (Exp)
then
if No (HSS) then
Stmts := New_List;
-- If the extended return has a handled statement sequence, then wrap
-- it in a block and use the block as the first statement.
else
Stmts := New_List (
Make_Block_Statement (Loc,
Declarations => New_List,
Handled_Statement_Sequence => HSS));
end if;
-- If the result type contains tasks, we call Move_Activation_Chain.
-- Later, the cleanup code will call Complete_Master, which will
-- terminate any unactivated tasks belonging to the return statement
-- master. But Move_Activation_Chain updates their master to be that
-- of the caller, so they will not be terminated unless the return
-- statement completes unsuccessfully due to exception, abort, goto,
-- or exit. As a formality, we test whether the function requires the
-- result to be built in place, though that's necessarily true for
-- the case of result types with task parts.
if Is_BIP_Func and then Has_Task (Ret_Typ) then
-- The return expression is an aggregate for a complex type which
-- contains tasks. This particular case is left unexpanded since
-- the regular expansion would insert all temporaries and
-- initialization code in the wrong block.
if Nkind (Exp) = N_Aggregate then
Expand_N_Aggregate (Exp);
end if;
-- Do not move the activation chain if the return object does not
-- contain tasks.
if Has_Task (Etype (Ret_Obj_Id)) then
Append_To (Stmts, Move_Activation_Chain (Func_Id));
end if;
end if;
-- Update the state of the function right before the object is
-- returned.
if Is_BIP_Func and then Needs_Finalization (Etype (Ret_Obj_Id)) then
declare
Flag_Id : constant Entity_Id :=
Status_Flag_Or_Transient_Decl (Ret_Obj_Id);
begin
-- Generate:
-- Fnn := True;
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Flag_Id, Loc),
Expression => New_Occurrence_Of (Standard_True, Loc)));
end;
end if;
-- Build a simple_return_statement that returns the return object
Return_Stmt :=
Make_Simple_Return_Statement (Loc,
Expression => New_Occurrence_Of (Ret_Obj_Id, Loc));
Append_To (Stmts, Return_Stmt);
HSS := Make_Handled_Sequence_Of_Statements (Loc, Stmts);
end if;
-- Case where we build a return statement block
if Present (HSS) then
Result :=
Make_Block_Statement (Loc,
Declarations => Return_Object_Declarations (N),
Handled_Statement_Sequence => HSS);
-- We set the entity of the new block statement to be that of the
-- return statement. This is necessary so that various fields, such
-- as Finalization_Chain_Entity carry over from the return statement
-- to the block. Note that this block is unusual, in that its entity
-- is an E_Return_Statement rather than an E_Block.
Set_Identifier
(Result, New_Occurrence_Of (Return_Statement_Entity (N), Loc));
-- If the object decl was already rewritten as a renaming, then we
-- don't want to do the object allocation and transformation of
-- the return object declaration to a renaming. This case occurs
-- when the return object is initialized by a call to another
-- build-in-place function, and that function is responsible for
-- the allocation of the return object.
if Is_BIP_Func
and then Nkind (Ret_Obj_Decl) = N_Object_Renaming_Declaration
then
pragma Assert
(Nkind (Original_Node (Ret_Obj_Decl)) = N_Object_Declaration
and then
-- It is a regular BIP object declaration
(Is_Build_In_Place_Function_Call
(Expression (Original_Node (Ret_Obj_Decl)))
-- It is a BIP object declaration that displaces the pointer
-- to the object to reference a convered interface type.
or else
Present (Unqual_BIP_Iface_Function_Call
(Expression (Original_Node (Ret_Obj_Decl))))));
-- Return the build-in-place result by reference
Set_By_Ref (Return_Stmt);
elsif Is_BIP_Func then
-- Locate the implicit access parameter associated with the
-- caller-supplied return object and convert the return
-- statement's return object declaration to a renaming of a
-- dereference of the access parameter. If the return object's
-- declaration includes an expression that has not already been
-- expanded as separate assignments, then add an assignment
-- statement to ensure the return object gets initialized.
-- declare
-- Result : T [:= <expression>];
-- begin
-- ...
-- is converted to
-- declare
-- Result : T renames FuncRA.all;
-- [Result := <expression;]
-- begin
-- ...
declare
Ret_Obj_Expr : constant Node_Id := Expression (Ret_Obj_Decl);
Ret_Obj_Typ : constant Entity_Id := Etype (Ret_Obj_Id);
Init_Assignment : Node_Id := Empty;
Obj_Acc_Formal : Entity_Id;
Obj_Acc_Deref : Node_Id;
Obj_Alloc_Formal : Entity_Id;
begin
-- Build-in-place results must be returned by reference
Set_By_Ref (Return_Stmt);
-- Retrieve the implicit access parameter passed by the caller
Obj_Acc_Formal :=
Build_In_Place_Formal (Func_Id, BIP_Object_Access);
-- If the return object's declaration includes an expression
-- and the declaration isn't marked as No_Initialization, then
-- we need to generate an assignment to the object and insert
-- it after the declaration before rewriting it as a renaming
-- (otherwise we'll lose the initialization). The case where
-- the result type is an interface (or class-wide interface)
-- is also excluded because the context of the function call
-- must be unconstrained, so the initialization will always
-- be done as part of an allocator evaluation (storage pool
-- or secondary stack), never to a constrained target object
-- passed in by the caller. Besides the assignment being
-- unneeded in this case, it avoids problems with trying to
-- generate a dispatching assignment when the return expression
-- is a nonlimited descendant of a limited interface (the
-- interface has no assignment operation).
if Present (Ret_Obj_Expr)
and then not No_Initialization (Ret_Obj_Decl)
and then not Is_Interface (Ret_Obj_Typ)
then
Init_Assignment :=
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Ret_Obj_Id, Loc),
Expression =>
New_Copy_Tree
(Source => Ret_Obj_Expr,
Scopes_In_EWA_OK => True));
Set_Etype (Name (Init_Assignment), Etype (Ret_Obj_Id));
Set_Assignment_OK (Name (Init_Assignment));
Set_No_Ctrl_Actions (Init_Assignment);
Set_Parent (Name (Init_Assignment), Init_Assignment);
Set_Parent (Expression (Init_Assignment), Init_Assignment);
Set_Expression (Ret_Obj_Decl, Empty);
if Is_Class_Wide_Type (Etype (Ret_Obj_Id))
and then not Is_Class_Wide_Type
(Etype (Expression (Init_Assignment)))
then
Rewrite (Expression (Init_Assignment),
Make_Type_Conversion (Loc,
Subtype_Mark =>
New_Occurrence_Of (Etype (Ret_Obj_Id), Loc),
Expression =>
Relocate_Node (Expression (Init_Assignment))));
end if;
-- In the case of functions where the calling context can
-- determine the form of allocation needed, initialization
-- is done with each part of the if statement that handles
-- the different forms of allocation (this is true for
-- unconstrained, tagged, and controlled result subtypes).
if not Needs_BIP_Alloc_Form (Func_Id) then
Insert_After (Ret_Obj_Decl, Init_Assignment);
end if;
end if;
-- When the function's subtype is unconstrained, a run-time
-- test may be needed to decide the form of allocation to use
-- for the return object. The function has an implicit formal
-- parameter indicating this. If the BIP_Alloc_Form formal has
-- the value one, then the caller has passed access to an
-- existing object for use as the return object. If the value
-- is two, then the return object must be allocated on the
-- secondary stack. Otherwise, the object must be allocated in
-- a storage pool. We generate an if statement to test the
-- implicit allocation formal and initialize a local access
-- value appropriately, creating allocators in the secondary
-- stack and global heap cases. The special formal also exists
-- and must be tested when the function has a tagged result,
-- even when the result subtype is constrained, because in
-- general such functions can be called in dispatching contexts
-- and must be handled similarly to functions with a class-wide
-- result.
if Needs_BIP_Alloc_Form (Func_Id) then
Obj_Alloc_Formal :=
Build_In_Place_Formal (Func_Id, BIP_Alloc_Form);
declare
Pool_Id : constant Entity_Id :=
Make_Temporary (Loc, 'P');
Alloc_Obj_Id : Entity_Id;
Alloc_Obj_Decl : Node_Id;
Alloc_If_Stmt : Node_Id;
Guard_Except : Node_Id;
Heap_Allocator : Node_Id;
Pool_Decl : Node_Id;
Pool_Allocator : Node_Id;
Ptr_Type_Decl : Node_Id;
Ref_Type : Entity_Id;
SS_Allocator : Node_Id;
begin
-- Create an access type designating the function's
-- result subtype.
Ref_Type := Make_Temporary (Loc, 'A');
Ptr_Type_Decl :=
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Ref_Type,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
All_Present => True,
Subtype_Indication =>
New_Occurrence_Of (Ret_Obj_Typ, Loc)));
Insert_Before (Ret_Obj_Decl, Ptr_Type_Decl);
-- Create an access object that will be initialized to an
-- access value denoting the return object, either coming
-- from an implicit access value passed in by the caller
-- or from the result of an allocator.
Alloc_Obj_Id := Make_Temporary (Loc, 'R');
Set_Etype (Alloc_Obj_Id, Ref_Type);
Alloc_Obj_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Alloc_Obj_Id,
Object_Definition =>
New_Occurrence_Of (Ref_Type, Loc));
Insert_Before (Ret_Obj_Decl, Alloc_Obj_Decl);
-- Create allocators for both the secondary stack and
-- global heap. If there's an initialization expression,
-- then create these as initialized allocators.
if Present (Ret_Obj_Expr)
and then not No_Initialization (Ret_Obj_Decl)
then
-- Always use the type of the expression for the
-- qualified expression, rather than the result type.
-- In general we cannot always use the result type
-- for the allocator, because the expression might be
-- of a specific type, such as in the case of an
-- aggregate or even a nonlimited object when the
-- result type is a limited class-wide interface type.
Heap_Allocator :=
Make_Allocator (Loc,
Expression =>
Make_Qualified_Expression (Loc,
Subtype_Mark =>
New_Occurrence_Of
(Etype (Ret_Obj_Expr), Loc),
Expression =>
New_Copy_Tree
(Source => Ret_Obj_Expr,
Scopes_In_EWA_OK => True)));
else
-- If the function returns a class-wide type we cannot
-- use the return type for the allocator. Instead we
-- use the type of the expression, which must be an
-- aggregate of a definite type.
if Is_Class_Wide_Type (Ret_Obj_Typ) then
Heap_Allocator :=
Make_Allocator (Loc,
Expression =>
New_Occurrence_Of
(Etype (Ret_Obj_Expr), Loc));
else
Heap_Allocator :=
Make_Allocator (Loc,
Expression =>
New_Occurrence_Of (Ret_Obj_Typ, Loc));
end if;
-- If the object requires default initialization then
-- that will happen later following the elaboration of
-- the object renaming. If we don't turn it off here
-- then the object will be default initialized twice.
Set_No_Initialization (Heap_Allocator);
end if;
-- Set the flag indicating that the allocator came from
-- a build-in-place return statement, so we can avoid
-- adjusting the allocated object. Note that this flag
-- will be inherited by the copies made below.
Set_Alloc_For_BIP_Return (Heap_Allocator);
-- The Pool_Allocator is just like the Heap_Allocator,
-- except we set Storage_Pool and Procedure_To_Call so
-- it will use the user-defined storage pool.
Pool_Allocator :=
New_Copy_Tree
(Source => Heap_Allocator,
Scopes_In_EWA_OK => True);
pragma Assert (Alloc_For_BIP_Return (Pool_Allocator));
-- Do not generate the renaming of the build-in-place
-- pool parameter on ZFP because the parameter is not
-- created in the first place.
if RTE_Available (RE_Root_Storage_Pool_Ptr) then
Pool_Decl :=
Make_Object_Renaming_Declaration (Loc,
Defining_Identifier => Pool_Id,
Subtype_Mark =>
New_Occurrence_Of
(RTE (RE_Root_Storage_Pool), Loc),
Name =>
Make_Explicit_Dereference (Loc,
New_Occurrence_Of
(Build_In_Place_Formal
(Func_Id, BIP_Storage_Pool), Loc)));
Set_Storage_Pool (Pool_Allocator, Pool_Id);
Set_Procedure_To_Call
(Pool_Allocator, RTE (RE_Allocate_Any));
else
Pool_Decl := Make_Null_Statement (Loc);
end if;
-- If the No_Allocators restriction is active, then only
-- an allocator for secondary stack allocation is needed.
-- It's OK for such allocators to have Comes_From_Source
-- set to False, because gigi knows not to flag them as
-- being a violation of No_Implicit_Heap_Allocations.
if Restriction_Active (No_Allocators) then
SS_Allocator := Heap_Allocator;
Heap_Allocator := Make_Null (Loc);
Pool_Allocator := Make_Null (Loc);
-- Otherwise the heap and pool allocators may be needed,
-- so we make another allocator for secondary stack
-- allocation.
else
SS_Allocator :=
New_Copy_Tree
(Source => Heap_Allocator,
Scopes_In_EWA_OK => True);
pragma Assert (Alloc_For_BIP_Return (SS_Allocator));
-- The heap and pool allocators are marked as
-- Comes_From_Source since they correspond to an
-- explicit user-written allocator (that is, it will
-- only be executed on behalf of callers that call the
-- function as initialization for such an allocator).
-- Prevents errors when No_Implicit_Heap_Allocations
-- is in force.
Set_Comes_From_Source (Heap_Allocator, True);
Set_Comes_From_Source (Pool_Allocator, True);
end if;
-- The allocator is returned on the secondary stack
Check_Restriction (No_Secondary_Stack, N);
Set_Storage_Pool (SS_Allocator, RTE (RE_SS_Pool));
Set_Procedure_To_Call
(SS_Allocator, RTE (RE_SS_Allocate));
-- The allocator is returned on the secondary stack,
-- so indicate that the function return, as well as
-- all blocks that encloses the allocator, must not
-- release it. The flags must be set now because
-- the decision to use the secondary stack is done
-- very late in the course of expanding the return
-- statement, past the point where these flags are
-- normally set.
Set_Uses_Sec_Stack (Func_Id);
Set_Uses_Sec_Stack (Return_Statement_Entity (N));
Set_Sec_Stack_Needed_For_Return
(Return_Statement_Entity (N));
Set_Enclosing_Sec_Stack_Return (N);
-- Guard against poor expansion on the caller side by
-- using a raise statement to catch out-of-range values
-- of formal parameter BIP_Alloc_Form.
if Exceptions_OK then
Guard_Except :=
Make_Raise_Program_Error (Loc,
Reason => PE_Build_In_Place_Mismatch);
else
Guard_Except := Make_Null_Statement (Loc);
end if;
-- Create an if statement to test the BIP_Alloc_Form
-- formal and initialize the access object to either the
-- BIP_Object_Access formal (BIP_Alloc_Form =
-- Caller_Allocation), the result of allocating the
-- object in the secondary stack (BIP_Alloc_Form =
-- Secondary_Stack), or else an allocator to create the
-- return object in the heap or user-defined pool
-- (BIP_Alloc_Form = Global_Heap or User_Storage_Pool).
-- ??? An unchecked type conversion must be made in the
-- case of assigning the access object formal to the
-- local access object, because a normal conversion would
-- be illegal in some cases (such as converting access-
-- to-unconstrained to access-to-constrained), but the
-- the unchecked conversion will presumably fail to work
-- right in just such cases. It's not clear at all how to
-- handle this. ???
Alloc_If_Stmt :=
Make_If_Statement (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd =>
New_Occurrence_Of (Obj_Alloc_Formal, Loc),
Right_Opnd =>
Make_Integer_Literal (Loc,
UI_From_Int (BIP_Allocation_Form'Pos
(Caller_Allocation)))),
Then_Statements => New_List (
Make_Assignment_Statement (Loc,
Name =>
New_Occurrence_Of (Alloc_Obj_Id, Loc),
Expression =>
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark =>
New_Occurrence_Of (Ref_Type, Loc),
Expression =>
New_Occurrence_Of (Obj_Acc_Formal, Loc)))),
Elsif_Parts => New_List (
Make_Elsif_Part (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd =>
New_Occurrence_Of (Obj_Alloc_Formal, Loc),
Right_Opnd =>
Make_Integer_Literal (Loc,
UI_From_Int (BIP_Allocation_Form'Pos
(Secondary_Stack)))),
Then_Statements => New_List (
Make_Assignment_Statement (Loc,
Name =>
New_Occurrence_Of (Alloc_Obj_Id, Loc),
Expression => SS_Allocator))),
Make_Elsif_Part (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd =>
New_Occurrence_Of (Obj_Alloc_Formal, Loc),
Right_Opnd =>
Make_Integer_Literal (Loc,
UI_From_Int (BIP_Allocation_Form'Pos
(Global_Heap)))),
Then_Statements => New_List (
Build_Heap_Or_Pool_Allocator
(Temp_Id => Alloc_Obj_Id,
Temp_Typ => Ref_Type,
Func_Id => Func_Id,
Ret_Typ => Ret_Obj_Typ,
Alloc_Expr => Heap_Allocator))),
-- ???If all is well, we can put the following
-- 'elsif' in the 'else', but this is a useful
-- self-check in case caller and callee don't agree
-- on whether BIPAlloc and so on should be passed.
Make_Elsif_Part (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd =>
New_Occurrence_Of (Obj_Alloc_Formal, Loc),
Right_Opnd =>
Make_Integer_Literal (Loc,
UI_From_Int (BIP_Allocation_Form'Pos
(User_Storage_Pool)))),
Then_Statements => New_List (
Pool_Decl,
Build_Heap_Or_Pool_Allocator
(Temp_Id => Alloc_Obj_Id,
Temp_Typ => Ref_Type,
Func_Id => Func_Id,
Ret_Typ => Ret_Obj_Typ,
Alloc_Expr => Pool_Allocator)))),
-- Raise Program_Error if it's none of the above;
-- this is a compiler bug.
Else_Statements => New_List (Guard_Except));
-- If a separate initialization assignment was created
-- earlier, append that following the assignment of the
-- implicit access formal to the access object, to ensure
-- that the return object is initialized in that case. In
-- this situation, the target of the assignment must be
-- rewritten to denote a dereference of the access to the
-- return object passed in by the caller.
if Present (Init_Assignment) then
Rewrite (Name (Init_Assignment),
Make_Explicit_Dereference (Loc,
Prefix => New_Occurrence_Of (Alloc_Obj_Id, Loc)));
pragma Assert
(Assignment_OK
(Original_Node (Name (Init_Assignment))));
Set_Assignment_OK (Name (Init_Assignment));
Set_Etype (Name (Init_Assignment), Etype (Ret_Obj_Id));
Append_To
(Then_Statements (Alloc_If_Stmt), Init_Assignment);
end if;
Insert_Before (Ret_Obj_Decl, Alloc_If_Stmt);
-- Remember the local access object for use in the
-- dereference of the renaming created below.
Obj_Acc_Formal := Alloc_Obj_Id;
end;
-- When the function's subtype is unconstrained and a run-time
-- test is not needed, we nevertheless need to build the return
-- using the function's result subtype.
elsif not Is_Constrained (Underlying_Type (Etype (Func_Id)))
then
declare
Alloc_Obj_Id : Entity_Id;
Alloc_Obj_Decl : Node_Id;
Ptr_Type_Decl : Node_Id;
Ref_Type : Entity_Id;
begin
-- Create an access type designating the function's
-- result subtype.
Ref_Type := Make_Temporary (Loc, 'A');
Ptr_Type_Decl :=
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Ref_Type,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
All_Present => True,
Subtype_Indication =>
New_Occurrence_Of (Ret_Obj_Typ, Loc)));
Insert_Before (Ret_Obj_Decl, Ptr_Type_Decl);
-- Create an access object initialized to the conversion
-- of the implicit access value passed in by the caller.
Alloc_Obj_Id := Make_Temporary (Loc, 'R');
Set_Etype (Alloc_Obj_Id, Ref_Type);
-- See the ??? comment a few lines above about the use of
-- an unchecked conversion here.
Alloc_Obj_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Alloc_Obj_Id,
Object_Definition =>
New_Occurrence_Of (Ref_Type, Loc),
Expression =>
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark =>
New_Occurrence_Of (Ref_Type, Loc),
Expression =>
New_Occurrence_Of (Obj_Acc_Formal, Loc)));
Insert_Before (Ret_Obj_Decl, Alloc_Obj_Decl);
-- Remember the local access object for use in the
-- dereference of the renaming created below.
Obj_Acc_Formal := Alloc_Obj_Id;
end;
end if;
-- Replace the return object declaration with a renaming of a
-- dereference of the access value designating the return
-- object.
Obj_Acc_Deref :=
Make_Explicit_Dereference (Loc,
Prefix => New_Occurrence_Of (Obj_Acc_Formal, Loc));
Rewrite (Ret_Obj_Decl,
Make_Object_Renaming_Declaration (Loc,
Defining_Identifier => Ret_Obj_Id,
Access_Definition => Empty,
Subtype_Mark => New_Occurrence_Of (Ret_Obj_Typ, Loc),
Name => Obj_Acc_Deref));
Set_Renamed_Object (Ret_Obj_Id, Obj_Acc_Deref);
end;
end if;
-- Case where we do not build a block
else
-- We're about to drop Return_Object_Declarations on the floor, so
-- we need to insert it, in case it got expanded into useful code.
-- Remove side effects from expression, which may be duplicated in
-- subsequent checks (see Expand_Simple_Function_Return).
Insert_List_Before (N, Return_Object_Declarations (N));
Remove_Side_Effects (Exp);
-- Build simple_return_statement that returns the expression directly
Return_Stmt := Make_Simple_Return_Statement (Loc, Expression => Exp);
Result := Return_Stmt;
end if;
-- Set the flag to prevent infinite recursion
Set_Comes_From_Extended_Return_Statement (Return_Stmt);
Rewrite (N, Result);
-- AI12-043: The checks of 6.5(8.1/3) and 6.5(21/3) are made immediately
-- before an object is returned. A predicate that applies to the return
-- subtype is checked immediately before an object is returned.
-- Suppress access checks to avoid generating extra checks for b-i-p.
Analyze (N, Suppress => Access_Check);
end Expand_N_Extended_Return_Statement;
----------------------------
-- Expand_N_Function_Call --
----------------------------
procedure Expand_N_Function_Call (N : Node_Id) is
begin
Expand_Call (N);
end Expand_N_Function_Call;
---------------------------------------
-- Expand_N_Procedure_Call_Statement --
---------------------------------------
procedure Expand_N_Procedure_Call_Statement (N : Node_Id) is
begin
Expand_Call (N);
end Expand_N_Procedure_Call_Statement;
--------------------------------------
-- Expand_N_Simple_Return_Statement --
--------------------------------------
procedure Expand_N_Simple_Return_Statement (N : Node_Id) is
begin
-- Defend against previous errors (i.e. the return statement calls a
-- function that is not available in configurable runtime).
if Present (Expression (N))
and then Nkind (Expression (N)) = N_Empty
then
Check_Error_Detected;
return;
end if;
-- Distinguish the function and non-function cases:
case Ekind (Return_Applies_To (Return_Statement_Entity (N))) is
when E_Function
| E_Generic_Function
=>
Expand_Simple_Function_Return (N);
when E_Entry
| E_Entry_Family
| E_Generic_Procedure
| E_Procedure
| E_Return_Statement
=>
Expand_Non_Function_Return (N);
when others =>
raise Program_Error;
end case;
exception
when RE_Not_Available =>
return;
end Expand_N_Simple_Return_Statement;
------------------------------
-- Expand_N_Subprogram_Body --
------------------------------
-- Add dummy push/pop label nodes at start and end to clear any local
-- exception indications if local-exception-to-goto optimization is active.
-- Add return statement if last statement in body is not a return statement
-- (this makes things easier on Gigi which does not want to have to handle
-- a missing return).
-- Add call to Activate_Tasks if body is a task activator
-- Deal with possible detection of infinite recursion
-- Eliminate body completely if convention stubbed
-- Encode entity names within body, since we will not need to reference
-- these entities any longer in the front end.
-- Initialize scalar out parameters if Initialize/Normalize_Scalars
-- Reset Pure indication if any parameter has root type System.Address
-- or has any parameters of limited types, where limited means that the
-- run-time view is limited (i.e. the full type is limited).
-- Wrap thread body
procedure Expand_N_Subprogram_Body (N : Node_Id) is
Body_Id : constant Entity_Id := Defining_Entity (N);
HSS : constant Node_Id := Handled_Statement_Sequence (N);
Loc : constant Source_Ptr := Sloc (N);
procedure Add_Return (Spec_Id : Entity_Id; Stmts : List_Id);
-- Append a return statement to the statement sequence Stmts if the last
-- statement is not already a return or a goto statement. Note that the
-- latter test is not critical, it does not matter if we add a few extra
-- returns, since they get eliminated anyway later on. Spec_Id denotes
-- the corresponding spec of the subprogram body.
----------------
-- Add_Return --
----------------
procedure Add_Return (Spec_Id : Entity_Id; Stmts : List_Id) is
Last_Stmt : Node_Id;
Loc : Source_Ptr;
Stmt : Node_Id;
begin
-- Get last statement, ignoring any Pop_xxx_Label nodes, which are
-- not relevant in this context since they are not executable.
Last_Stmt := Last (Stmts);
while Nkind (Last_Stmt) in N_Pop_xxx_Label loop
Prev (Last_Stmt);
end loop;
-- Now insert return unless last statement is a transfer
if not Is_Transfer (Last_Stmt) then
-- The source location for the return is the end label of the
-- procedure if present. Otherwise use the sloc of the last
-- statement in the list. If the list comes from a generated
-- exception handler and we are not debugging generated code,
-- all the statements within the handler are made invisible
-- to the debugger.
if Nkind (Parent (Stmts)) = N_Exception_Handler
and then not Comes_From_Source (Parent (Stmts))
then
Loc := Sloc (Last_Stmt);
elsif Present (End_Label (HSS)) then
Loc := Sloc (End_Label (HSS));
else
Loc := Sloc (Last_Stmt);
end if;
-- Append return statement, and set analyzed manually. We can't
-- call Analyze on this return since the scope is wrong.
-- Note: it almost works to push the scope and then do the Analyze
-- call, but something goes wrong in some weird cases and it is
-- not worth worrying about ???
Stmt := Make_Simple_Return_Statement (Loc);
-- The return statement is handled properly, and the call to the
-- postcondition, inserted below, does not require information
-- from the body either. However, that call is analyzed in the
-- enclosing scope, and an elaboration check might improperly be
-- added to it. A guard in Sem_Elab is needed to prevent that
-- spurious check, see Check_Elab_Call.
Append_To (Stmts, Stmt);
Set_Analyzed (Stmt);
-- Call the _Postconditions procedure if the related subprogram
-- has contract assertions that need to be verified on exit.
if Ekind (Spec_Id) = E_Procedure
and then Present (Postconditions_Proc (Spec_Id))
then
Insert_Action (Stmt,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (Postconditions_Proc (Spec_Id), Loc)));
end if;
-- Ada 2020 (AI12-0279): append the call to 'Yield unless this is
-- a generic subprogram (since in such case it will be added to
-- the instantiations).
if Has_Yield_Aspect (Spec_Id)
and then Ekind (Spec_Id) /= E_Generic_Procedure
and then RTE_Available (RE_Yield)
then
Insert_Action (Stmt,
Make_Procedure_Call_Statement (Loc,
New_Occurrence_Of (RTE (RE_Yield), Loc)));
end if;
end if;
end Add_Return;
-- Local variables
Except_H : Node_Id;
L : List_Id;
Spec_Id : Entity_Id;
-- Start of processing for Expand_N_Subprogram_Body
begin
if Present (Corresponding_Spec (N)) then
Spec_Id := Corresponding_Spec (N);
else
Spec_Id := Body_Id;
end if;
-- If this is a Pure function which has any parameters whose root type
-- is System.Address, reset the Pure indication.
-- This check is also performed when the subprogram is frozen, but we
-- repeat it on the body so that the indication is consistent, and so
-- it applies as well to bodies without separate specifications.
if Is_Pure (Spec_Id)
and then Is_Subprogram (Spec_Id)
and then not Has_Pragma_Pure_Function (Spec_Id)
then
Check_Function_With_Address_Parameter (Spec_Id);
if Spec_Id /= Body_Id then
Set_Is_Pure (Body_Id, Is_Pure (Spec_Id));
end if;
end if;
-- Set L to either the list of declarations if present, or to the list
-- of statements if no declarations are present. This is used to insert
-- new stuff at the start.
if Is_Non_Empty_List (Declarations (N)) then
L := Declarations (N);
else
L := Statements (HSS);
end if;
-- If local-exception-to-goto optimization active, insert dummy push
-- statements at start, and dummy pop statements at end, but inhibit
-- this if we have No_Exception_Handlers, since they are useless and
-- interfere with analysis, e.g. by CodePeer. We also don't need these
-- if we're unnesting subprograms because the only purpose of these
-- nodes is to ensure we don't set a label in one subprogram and branch
-- to it in another.
if (Debug_Flag_Dot_G
or else Restriction_Active (No_Exception_Propagation))
and then not Restriction_Active (No_Exception_Handlers)
and then not CodePeer_Mode
and then not Unnest_Subprogram_Mode
and then Is_Non_Empty_List (L)
then
declare
FS : constant Node_Id := First (L);
FL : constant Source_Ptr := Sloc (FS);
LS : Node_Id;
LL : Source_Ptr;
begin
-- LS points to either last statement, if statements are present
-- or to the last declaration if there are no statements present.
-- It is the node after which the pop's are generated.
if Is_Non_Empty_List (Statements (HSS)) then
LS := Last (Statements (HSS));
else
LS := Last (L);
end if;
LL := Sloc (LS);
Insert_List_Before_And_Analyze (FS, New_List (
Make_Push_Constraint_Error_Label (FL),
Make_Push_Program_Error_Label (FL),
Make_Push_Storage_Error_Label (FL)));
Insert_List_After_And_Analyze (LS, New_List (
Make_Pop_Constraint_Error_Label (LL),
Make_Pop_Program_Error_Label (LL),
Make_Pop_Storage_Error_Label (LL)));
end;
end if;
-- Initialize any scalar OUT args if Initialize/Normalize_Scalars
if Init_Or_Norm_Scalars and then Is_Subprogram (Spec_Id) then
declare
F : Entity_Id;
A : Node_Id;
begin
-- Loop through formals
F := First_Formal (Spec_Id);
while Present (F) loop
if Is_Scalar_Type (Etype (F))
and then Ekind (F) = E_Out_Parameter
then
Check_Restriction (No_Default_Initialization, F);
-- Insert the initialization. We turn off validity checks
-- for this assignment, since we do not want any check on
-- the initial value itself (which may well be invalid).
-- Predicate checks are disabled as well (RM 6.4.1 (13/3))
A :=
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (F, Loc),
Expression => Get_Simple_Init_Val (Etype (F), N));
Set_Suppress_Assignment_Checks (A);
Insert_Before_And_Analyze (First (L),
A, Suppress => Validity_Check);
end if;
Next_Formal (F);
end loop;
end;
end if;
-- Clear out statement list for stubbed procedure
if Present (Corresponding_Spec (N)) then
Set_Elaboration_Flag (N, Spec_Id);
if Convention (Spec_Id) = Convention_Stubbed
or else Is_Eliminated (Spec_Id)
then
Set_Declarations (N, Empty_List);
Set_Handled_Statement_Sequence (N,
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (Make_Null_Statement (Loc))));
return;
end if;
end if;
-- Create a set of discriminals for the next protected subprogram body
if Is_List_Member (N)
and then Present (Parent (List_Containing (N)))
and then Nkind (Parent (List_Containing (N))) = N_Protected_Body
and then Present (Next_Protected_Operation (N))
then
Set_Discriminals (Parent (Base_Type (Scope (Spec_Id))));
end if;
-- Returns_By_Ref flag is normally set when the subprogram is frozen but
-- subprograms with no specs are not frozen.
declare
Typ : constant Entity_Id := Etype (Spec_Id);
Utyp : constant Entity_Id := Underlying_Type (Typ);
begin
if Is_Limited_View (Typ) then
Set_Returns_By_Ref (Spec_Id);
elsif Present (Utyp) and then CW_Or_Has_Controlled_Part (Utyp) then
Set_Returns_By_Ref (Spec_Id);
end if;
end;
-- For a procedure, we add a return for all possible syntactic ends of
-- the subprogram.
if Ekind (Spec_Id) in E_Procedure | E_Generic_Procedure then
Add_Return (Spec_Id, Statements (HSS));
if Present (Exception_Handlers (HSS)) then
Except_H := First_Non_Pragma (Exception_Handlers (HSS));
while Present (Except_H) loop
Add_Return (Spec_Id, Statements (Except_H));
Next_Non_Pragma (Except_H);
end loop;
end if;
-- For a function, we must deal with the case where there is at least
-- one missing return. What we do is to wrap the entire body of the
-- function in a block:
-- begin
-- ...
-- end;
-- becomes
-- begin
-- begin
-- ...
-- end;
-- raise Program_Error;
-- end;
-- This approach is necessary because the raise must be signalled to the
-- caller, not handled by any local handler (RM 6.4(11)).
-- Note: we do not need to analyze the constructed sequence here, since
-- it has no handler, and an attempt to analyze the handled statement
-- sequence twice is risky in various ways (e.g. the issue of expanding
-- cleanup actions twice).
elsif Has_Missing_Return (Spec_Id) then
declare
Hloc : constant Source_Ptr := Sloc (HSS);
Blok : constant Node_Id :=
Make_Block_Statement (Hloc,
Handled_Statement_Sequence => HSS);
Rais : constant Node_Id :=
Make_Raise_Program_Error (Hloc,
Reason => PE_Missing_Return);
begin
Set_Handled_Statement_Sequence (N,
Make_Handled_Sequence_Of_Statements (Hloc,
Statements => New_List (Blok, Rais)));
Push_Scope (Spec_Id);
Analyze (Blok);
Analyze (Rais);
Pop_Scope;
end;
end if;
-- If subprogram contains a parameterless recursive call, then we may
-- have an infinite recursion, so see if we can generate code to check
-- for this possibility if storage checks are not suppressed.
if Ekind (Spec_Id) = E_Procedure
and then Has_Recursive_Call (Spec_Id)
and then not Storage_Checks_Suppressed (Spec_Id)
then
Detect_Infinite_Recursion (N, Spec_Id);
end if;
-- Set to encode entity names in package body before gigi is called
Qualify_Entity_Names (N);
-- If the body belongs to a nonabstract library-level source primitive
-- of a tagged type, install an elaboration check which ensures that a
-- dispatching call targeting the primitive will not execute the body
-- without it being previously elaborated.
Install_Primitive_Elaboration_Check (N);
end Expand_N_Subprogram_Body;
-----------------------------------
-- Expand_N_Subprogram_Body_Stub --
-----------------------------------
procedure Expand_N_Subprogram_Body_Stub (N : Node_Id) is
Bod : Node_Id;
begin
if Present (Corresponding_Body (N)) then
Bod := Unit_Declaration_Node (Corresponding_Body (N));
-- The body may have been expanded already when it is analyzed
-- through the subunit node. Do no expand again: it interferes
-- with the construction of unnesting tables when generating C.
if not Analyzed (Bod) then
Expand_N_Subprogram_Body (Bod);
end if;
-- Add full qualification to entities that may be created late
-- during unnesting.
Qualify_Entity_Names (N);
end if;
end Expand_N_Subprogram_Body_Stub;
-------------------------------------
-- Expand_N_Subprogram_Declaration --
-------------------------------------
-- If the declaration appears within a protected body, it is a private
-- operation of the protected type. We must create the corresponding
-- protected subprogram an associated formals. For a normal protected
-- operation, this is done when expanding the protected type declaration.
-- If the declaration is for a null procedure, emit null body
procedure Expand_N_Subprogram_Declaration (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Subp : constant Entity_Id := Defining_Entity (N);
-- Local variables
Scop : constant Entity_Id := Scope (Subp);
Prot_Bod : Node_Id;
Prot_Decl : Node_Id;
Prot_Id : Entity_Id;
begin
-- Deal with case of protected subprogram. Do not generate protected
-- operation if operation is flagged as eliminated.
if Is_List_Member (N)
and then Present (Parent (List_Containing (N)))
and then Nkind (Parent (List_Containing (N))) = N_Protected_Body
and then Is_Protected_Type (Scop)
then
if No (Protected_Body_Subprogram (Subp))
and then not Is_Eliminated (Subp)
then
Prot_Decl :=
Make_Subprogram_Declaration (Loc,
Specification =>
Build_Protected_Sub_Specification
(N, Scop, Unprotected_Mode));
-- The protected subprogram is declared outside of the protected
-- body. Given that the body has frozen all entities so far, we
-- analyze the subprogram and perform freezing actions explicitly.
-- including the generation of an explicit freeze node, to ensure
-- that gigi has the proper order of elaboration.
-- If the body is a subunit, the insertion point is before the
-- stub in the parent.
Prot_Bod := Parent (List_Containing (N));
if Nkind (Parent (Prot_Bod)) = N_Subunit then
Prot_Bod := Corresponding_Stub (Parent (Prot_Bod));
end if;
Insert_Before (Prot_Bod, Prot_Decl);
Prot_Id := Defining_Unit_Name (Specification (Prot_Decl));
Set_Has_Delayed_Freeze (Prot_Id);
Push_Scope (Scope (Scop));
Analyze (Prot_Decl);
Freeze_Before (N, Prot_Id);
Set_Protected_Body_Subprogram (Subp, Prot_Id);
Pop_Scope;
end if;
-- Ada 2005 (AI-348): Generate body for a null procedure. In most
-- cases this is superfluous because calls to it will be automatically
-- inlined, but we definitely need the body if preconditions for the
-- procedure are present, or if performing coverage analysis.
elsif Nkind (Specification (N)) = N_Procedure_Specification
and then Null_Present (Specification (N))
then
declare
Bod : constant Node_Id := Body_To_Inline (N);
begin
Set_Has_Completion (Subp, False);
Append_Freeze_Action (Subp, Bod);
-- The body now contains raise statements, so calls to it will
-- not be inlined.
Set_Is_Inlined (Subp, False);
end;
end if;
-- When generating C code, transform a function that returns a
-- constrained array type into a procedure with an out parameter
-- that carries the return value.
-- We skip this transformation for unchecked conversions, since they
-- are not needed by the C generator (and this also produces cleaner
-- output).
if Modify_Tree_For_C
and then Nkind (Specification (N)) = N_Function_Specification
and then Is_Array_Type (Etype (Subp))
and then Is_Constrained (Etype (Subp))
and then not Is_Unchecked_Conversion_Instance (Subp)
then
Build_Procedure_Form (N);
end if;
end Expand_N_Subprogram_Declaration;
--------------------------------
-- Expand_Non_Function_Return --
--------------------------------
procedure Expand_Non_Function_Return (N : Node_Id) is
pragma Assert (No (Expression (N)));
Loc : constant Source_Ptr := Sloc (N);
Scope_Id : Entity_Id := Return_Applies_To (Return_Statement_Entity (N));
Kind : constant Entity_Kind := Ekind (Scope_Id);
Call : Node_Id;
Acc_Stat : Node_Id;
Goto_Stat : Node_Id;
Lab_Node : Node_Id;
begin
-- Call the _Postconditions procedure if the related subprogram has
-- contract assertions that need to be verified on exit.
if Ekind (Scope_Id) in E_Entry | E_Entry_Family | E_Procedure
and then Present (Postconditions_Proc (Scope_Id))
then
Insert_Action (N,
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Postconditions_Proc (Scope_Id), Loc)));
end if;
-- Ada 2020 (AI12-0279)
if Has_Yield_Aspect (Scope_Id)
and then RTE_Available (RE_Yield)
then
Insert_Action (N,
Make_Procedure_Call_Statement (Loc,
New_Occurrence_Of (RTE (RE_Yield), Loc)));
end if;
-- If it is a return from a procedure do no extra steps
if Kind = E_Procedure or else Kind = E_Generic_Procedure then
return;
-- If it is a nested return within an extended one, replace it with a
-- return of the previously declared return object.
elsif Kind = E_Return_Statement then
Rewrite (N,
Make_Simple_Return_Statement (Loc,
Expression =>
New_Occurrence_Of (First_Entity (Scope_Id), Loc)));
Set_Comes_From_Extended_Return_Statement (N);
Set_Return_Statement_Entity (N, Scope_Id);
Expand_Simple_Function_Return (N);
return;
end if;
pragma Assert (Is_Entry (Scope_Id));
-- Look at the enclosing block to see whether the return is from an
-- accept statement or an entry body.
for J in reverse 0 .. Scope_Stack.Last loop
Scope_Id := Scope_Stack.Table (J).Entity;
exit when Is_Concurrent_Type (Scope_Id);
end loop;
-- If it is a return from accept statement it is expanded as call to
-- RTS Complete_Rendezvous and a goto to the end of the accept body.
-- (cf : Expand_N_Accept_Statement, Expand_N_Selective_Accept,
-- Expand_N_Accept_Alternative in exp_ch9.adb)
if Is_Task_Type (Scope_Id) then
Call :=
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (RTE (RE_Complete_Rendezvous), Loc));
Insert_Before (N, Call);
-- why not insert actions here???
Analyze (Call);
Acc_Stat := Parent (N);
while Nkind (Acc_Stat) /= N_Accept_Statement loop
Acc_Stat := Parent (Acc_Stat);
end loop;
Lab_Node := Last (Statements
(Handled_Statement_Sequence (Acc_Stat)));
Goto_Stat := Make_Goto_Statement (Loc,
Name => New_Occurrence_Of
(Entity (Identifier (Lab_Node)), Loc));
Set_Analyzed (Goto_Stat);
Rewrite (N, Goto_Stat);
Analyze (N);
-- If it is a return from an entry body, put a Complete_Entry_Body call
-- in front of the return.
elsif Is_Protected_Type (Scope_Id) then
Call :=
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Complete_Entry_Body), Loc),
Parameter_Associations => New_List (
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of
(Find_Protection_Object (Current_Scope), Loc),
Attribute_Name => Name_Unchecked_Access)));
Insert_Before (N, Call);
Analyze (Call);
end if;
end Expand_Non_Function_Return;
---------------------------------------
-- Expand_Protected_Object_Reference --
---------------------------------------
function Expand_Protected_Object_Reference
(N : Node_Id;
Scop : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (N);
Corr : Entity_Id;
Rec : Node_Id;
Param : Entity_Id;
Proc : Entity_Id;
begin
Rec := Make_Identifier (Loc, Name_uObject);
Set_Etype (Rec, Corresponding_Record_Type (Scop));
-- Find enclosing protected operation, and retrieve its first parameter,
-- which denotes the enclosing protected object. If the enclosing
-- operation is an entry, we are immediately within the protected body,
-- and we can retrieve the object from the service entries procedure. A
-- barrier function has the same signature as an entry. A barrier
-- function is compiled within the protected object, but unlike
-- protected operations its never needs locks, so that its protected
-- body subprogram points to itself.
Proc := Current_Scope;
while Present (Proc)
and then Scope (Proc) /= Scop
loop
Proc := Scope (Proc);
end loop;
Corr := Protected_Body_Subprogram (Proc);
if No (Corr) then
-- Previous error left expansion incomplete.
-- Nothing to do on this call.
return Empty;
end if;
Param :=
Defining_Identifier
(First (Parameter_Specifications (Parent (Corr))));
if Is_Subprogram (Proc) and then Proc /= Corr then
-- Protected function or procedure
Set_Entity (Rec, Param);
-- Rec is a reference to an entity which will not be in scope when
-- the call is reanalyzed, and needs no further analysis.
Set_Analyzed (Rec);
else
-- Entry or barrier function for entry body. The first parameter of
-- the entry body procedure is pointer to the object. We create a
-- local variable of the proper type, duplicating what is done to
-- define _object later on.
declare
Decls : List_Id;
Obj_Ptr : constant Entity_Id := Make_Temporary (Loc, 'T');
begin
Decls := New_List (
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Obj_Ptr,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
Subtype_Indication =>
New_Occurrence_Of
(Corresponding_Record_Type (Scop), Loc))));
Insert_Actions (N, Decls);
Freeze_Before (N, Obj_Ptr);
Rec :=
Make_Explicit_Dereference (Loc,
Prefix =>
Unchecked_Convert_To (Obj_Ptr,
New_Occurrence_Of (Param, Loc)));
-- Analyze new actual. Other actuals in calls are already analyzed
-- and the list of actuals is not reanalyzed after rewriting.
Set_Parent (Rec, N);
Analyze (Rec);
end;
end if;
return Rec;
end Expand_Protected_Object_Reference;
--------------------------------------
-- Expand_Protected_Subprogram_Call --
--------------------------------------
procedure Expand_Protected_Subprogram_Call
(N : Node_Id;
Subp : Entity_Id;
Scop : Entity_Id)
is
Rec : Node_Id;
procedure Expand_Internal_Init_Call;
-- A call to an operation of the type may occur in the initialization
-- of a private component. In that case the prefix of the call is an
-- entity name and the call is treated as internal even though it
-- appears in code outside of the protected type.
procedure Freeze_Called_Function;
-- If it is a function call it can appear in elaboration code and
-- the called entity must be frozen before the call. This must be
-- done before the call is expanded, as the expansion may rewrite it
-- to something other than a call (e.g. a temporary initialized in a
-- transient block).
-------------------------------
-- Expand_Internal_Init_Call --
-------------------------------
procedure Expand_Internal_Init_Call is
begin
-- If the context is a protected object (rather than a protected
-- type) the call itself is bound to raise program_error because
-- the protected body will not have been elaborated yet. This is
-- diagnosed subsequently in Sem_Elab.
Freeze_Called_Function;
-- The target of the internal call is the first formal of the
-- enclosing initialization procedure.
Rec := New_Occurrence_Of (First_Formal (Current_Scope), Sloc (N));
Build_Protected_Subprogram_Call (N,
Name => Name (N),
Rec => Rec,
External => False);
Analyze (N);
Resolve (N, Etype (Subp));
end Expand_Internal_Init_Call;
----------------------------
-- Freeze_Called_Function --
----------------------------
procedure Freeze_Called_Function is
begin
if Ekind (Subp) = E_Function then
Freeze_Expression (Name (N));
end if;
end Freeze_Called_Function;
-- Start of processing for Expand_Protected_Subprogram_Call
begin
-- If the protected object is not an enclosing scope, this is an inter-
-- object function call. Inter-object procedure calls are expanded by
-- Exp_Ch9.Build_Simple_Entry_Call. The call is intra-object only if the
-- subprogram being called is in the protected body being compiled, and
-- if the protected object in the call is statically the enclosing type.
-- The object may be a component of some other data structure, in which
-- case this must be handled as an inter-object call.
if not In_Open_Scopes (Scop)
or else Is_Entry_Wrapper (Current_Scope)
or else not Is_Entity_Name (Name (N))
then
if Nkind (Name (N)) = N_Selected_Component then
Rec := Prefix (Name (N));
elsif Nkind (Name (N)) = N_Indexed_Component then
Rec := Prefix (Prefix (Name (N)));
-- If this is a call within an entry wrapper, it appears within a
-- precondition that calls another primitive of the synchronized
-- type. The target object of the call is the first actual on the
-- wrapper. Note that this is an external call, because the wrapper
-- is called outside of the synchronized object. This means that
-- an entry call to an entry with preconditions involves two
-- synchronized operations.
elsif Ekind (Current_Scope) = E_Procedure
and then Is_Entry_Wrapper (Current_Scope)
then
Rec := New_Occurrence_Of (First_Entity (Current_Scope), Sloc (N));
-- A default parameter of a protected operation may be a call to
-- a protected function of the type. This appears as an internal
-- call in the profile of the operation, but if the context is an
-- external call we must convert the call into an external one,
-- using the protected object that is the target, so that:
-- Prot.P (F)
-- is transformed into
-- Prot.P (Prot.F)
elsif Nkind (Parent (N)) = N_Procedure_Call_Statement
and then Nkind (Name (Parent (N))) = N_Selected_Component
and then Is_Protected_Type (Etype (Prefix (Name (Parent (N)))))
and then Is_Entity_Name (Name (N))
and then Scope (Entity (Name (N))) =
Etype (Prefix (Name (Parent (N))))
then
Rewrite (Name (N),
Make_Selected_Component (Sloc (N),
Prefix => New_Copy_Tree (Prefix (Name (Parent (N)))),
Selector_Name => Relocate_Node (Name (N))));
Analyze_And_Resolve (N);
return;
else
-- If the context is the initialization procedure for a protected
-- type, the call is legal because the called entity must be a
-- function of that enclosing type, and this is treated as an
-- internal call.
pragma Assert
(Is_Entity_Name (Name (N)) and then Inside_Init_Proc);
Expand_Internal_Init_Call;
return;
end if;
Freeze_Called_Function;
Build_Protected_Subprogram_Call (N,
Name => New_Occurrence_Of (Subp, Sloc (N)),
Rec => Convert_Concurrent (Rec, Etype (Rec)),
External => True);
else
Rec := Expand_Protected_Object_Reference (N, Scop);
if No (Rec) then
return;
end if;
Freeze_Called_Function;
Build_Protected_Subprogram_Call (N,
Name => Name (N),
Rec => Rec,
External => False);
end if;
-- Analyze and resolve the new call. The actuals have already been
-- resolved, but expansion of a function call will add extra actuals
-- if needed. Analysis of a procedure call already includes resolution.
Analyze (N);
if Ekind (Subp) = E_Function then
Resolve (N, Etype (Subp));
end if;
end Expand_Protected_Subprogram_Call;
-----------------------------------
-- Expand_Simple_Function_Return --
-----------------------------------
-- The "simple" comes from the syntax rule simple_return_statement. The
-- semantics are not at all simple.
procedure Expand_Simple_Function_Return (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Scope_Id : constant Entity_Id :=
Return_Applies_To (Return_Statement_Entity (N));
-- The function we are returning from
R_Type : constant Entity_Id := Etype (Scope_Id);
-- The result type of the function
Utyp : constant Entity_Id := Underlying_Type (R_Type);
Exp : Node_Id := Expression (N);
pragma Assert (Present (Exp));
Exp_Is_Function_Call : constant Boolean :=
Nkind (Exp) = N_Function_Call
or else (Nkind (Exp) = N_Explicit_Dereference
and then Is_Entity_Name (Prefix (Exp))
and then Ekind (Entity (Prefix (Exp))) = E_Constant
and then Is_Related_To_Func_Return (Entity (Prefix (Exp))));
Exp_Typ : constant Entity_Id := Etype (Exp);
-- The type of the expression (not necessarily the same as R_Type)
Subtype_Ind : Node_Id;
-- If the result type of the function is class-wide and the expression
-- has a specific type, then we use the expression's type as the type of
-- the return object. In cases where the expression is an aggregate that
-- is built in place, this avoids the need for an expensive conversion
-- of the return object to the specific type on assignments to the
-- individual components.
procedure Check_Against_Result_Level (Level : Node_Id);
-- Check the given accessibility level against the level
-- determined by the point of call. (AI05-0234).
--------------------------------
-- Check_Against_Result_Level --
--------------------------------
procedure Check_Against_Result_Level (Level : Node_Id) is
begin
Insert_Action (N,
Make_Raise_Program_Error (Loc,
Condition =>
Make_Op_Gt (Loc,
Left_Opnd => Level,
Right_Opnd =>
New_Occurrence_Of
(Extra_Accessibility_Of_Result (Scope_Id), Loc)),
Reason => PE_Accessibility_Check_Failed));
end Check_Against_Result_Level;
-- Start of processing for Expand_Simple_Function_Return
begin
if Is_Class_Wide_Type (R_Type)
and then not Is_Class_Wide_Type (Exp_Typ)
and then Nkind (Exp) /= N_Type_Conversion
then
Subtype_Ind := New_Occurrence_Of (Exp_Typ, Loc);
else
Subtype_Ind := New_Occurrence_Of (R_Type, Loc);
-- If the result type is class-wide and the expression is a view
-- conversion, the conversion plays no role in the expansion because
-- it does not modify the tag of the object. Remove the conversion
-- altogether to prevent tag overwriting.
if Is_Class_Wide_Type (R_Type)
and then not Is_Class_Wide_Type (Exp_Typ)
and then Nkind (Exp) = N_Type_Conversion
then
Exp := Expression (Exp);
end if;
end if;
-- Assert that if F says "return G(...);"
-- then F and G are both b-i-p, or neither b-i-p.
if Nkind (Exp) = N_Function_Call then
pragma Assert (Ekind (Scope_Id) = E_Function);
pragma Assert
(Is_Build_In_Place_Function (Scope_Id) =
Is_Build_In_Place_Function_Call (Exp));
null;
end if;
-- For the case of a simple return that does not come from an
-- extended return, in the case of build-in-place, we rewrite
-- "return <expression>;" to be:
-- return _anon_ : <return_subtype> := <expression>
-- The expansion produced by Expand_N_Extended_Return_Statement will
-- contain simple return statements (for example, a block containing
-- simple return of the return object), which brings us back here with
-- Comes_From_Extended_Return_Statement set. The reason for the barrier
-- checking for a simple return that does not come from an extended
-- return is to avoid this infinite recursion.
-- The reason for this design is that for Ada 2005 limited returns, we
-- need to reify the return object, so we can build it "in place", and
-- we need a block statement to hang finalization and tasking stuff.
-- ??? In order to avoid disruption, we avoid translating to extended
-- return except in the cases where we really need to (Ada 2005 for
-- inherently limited). We might prefer to do this translation in all
-- cases (except perhaps for the case of Ada 95 inherently limited),
-- in order to fully exercise the Expand_N_Extended_Return_Statement
-- code. This would also allow us to do the build-in-place optimization
-- for efficiency even in cases where it is semantically not required.
-- As before, we check the type of the return expression rather than the
-- return type of the function, because the latter may be a limited
-- class-wide interface type, which is not a limited type, even though
-- the type of the expression may be.
pragma Assert
(Comes_From_Extended_Return_Statement (N)
or else not Is_Build_In_Place_Function_Call (Exp)
or else Is_Build_In_Place_Function (Scope_Id));
if not Comes_From_Extended_Return_Statement (N)
and then Is_Build_In_Place_Function (Scope_Id)
and then not Debug_Flag_Dot_L
-- The functionality of interface thunks is simple and it is always
-- handled by means of simple return statements. This leaves their
-- expansion simple and clean.
and then not Is_Thunk (Scope_Id)
then
declare
Return_Object_Entity : constant Entity_Id :=
Make_Temporary (Loc, 'R', Exp);
Obj_Decl : constant Node_Id :=
Make_Object_Declaration (Loc,
Defining_Identifier => Return_Object_Entity,
Object_Definition => Subtype_Ind,
Expression => Exp);
Ext : constant Node_Id :=
Make_Extended_Return_Statement (Loc,
Return_Object_Declarations => New_List (Obj_Decl));
-- Do not perform this high-level optimization if the result type
-- is an interface because the "this" pointer must be displaced.
begin
Rewrite (N, Ext);
Analyze (N);
return;
end;
end if;
-- Here we have a simple return statement that is part of the expansion
-- of an extended return statement (either written by the user, or
-- generated by the above code).
-- Always normalize C/Fortran boolean result. This is not always needed,
-- but it seems a good idea to minimize the passing around of non-
-- normalized values, and in any case this handles the processing of
-- barrier functions for protected types, which turn the condition into
-- a return statement.
if Is_Boolean_Type (Exp_Typ) and then Nonzero_Is_True (Exp_Typ) then
Adjust_Condition (Exp);
Adjust_Result_Type (Exp, Exp_Typ);
end if;
-- Do validity check if enabled for returns
if Validity_Checks_On and then Validity_Check_Returns then
Ensure_Valid (Exp);
end if;
-- Check the result expression of a scalar function against the subtype
-- of the function by inserting a conversion. This conversion must
-- eventually be performed for other classes of types, but for now it's
-- only done for scalars ???
if Is_Scalar_Type (Exp_Typ) and then Exp_Typ /= R_Type then
Rewrite (Exp, Convert_To (R_Type, Exp));
-- The expression is resolved to ensure that the conversion gets
-- expanded to generate a possible constraint check.
Analyze_And_Resolve (Exp, R_Type);
end if;
-- Deal with returning variable length objects and controlled types
-- Nothing to do if we are returning by reference, or this is not a
-- type that requires special processing (indicated by the fact that
-- it requires a cleanup scope for the secondary stack case).
if Is_Build_In_Place_Function (Scope_Id)
or else Is_Limited_Interface (Exp_Typ)
then
null;
-- No copy needed for thunks returning interface type objects since
-- the object is returned by reference and the maximum functionality
-- required is just to displace the pointer.
elsif Is_Thunk (Scope_Id) and then Is_Interface (Exp_Typ) then
null;
-- If the call is within a thunk and the type is a limited view, the
-- backend will eventually see the non-limited view of the type.
elsif Is_Thunk (Scope_Id) and then Is_Incomplete_Type (Exp_Typ) then
return;
-- A return statement from an ignored Ghost function does not use the
-- secondary stack (or any other one).
elsif not Requires_Transient_Scope (R_Type)
or else Is_Ignored_Ghost_Entity (Scope_Id)
then
-- Mutable records with variable-length components are not returned
-- on the sec-stack, so we need to make sure that the back end will
-- only copy back the size of the actual value, and not the maximum
-- size. We create an actual subtype for this purpose. However we
-- need not do it if the expression is a function call since this
-- will be done in the called function and doing it here too would
-- cause a temporary with maximum size to be created.
declare
Ubt : constant Entity_Id := Underlying_Type (Base_Type (Exp_Typ));
Decl : Node_Id;
Ent : Entity_Id;
begin
if not Exp_Is_Function_Call
and then Has_Discriminants (Ubt)
and then not Is_Constrained (Ubt)
and then not Has_Unchecked_Union (Ubt)
then
Decl := Build_Actual_Subtype (Ubt, Exp);
Ent := Defining_Identifier (Decl);
Insert_Action (Exp, Decl);
Rewrite (Exp, Unchecked_Convert_To (Ent, Exp));
Analyze_And_Resolve (Exp);
end if;
end;
-- Here if secondary stack is used
else
-- Prevent the reclamation of the secondary stack by all enclosing
-- blocks and loops as well as the related function; otherwise the
-- result would be reclaimed too early.
Set_Enclosing_Sec_Stack_Return (N);
-- Optimize the case where the result is a function call. In this
-- case the result is already on the secondary stack and no further
-- processing is required except to set the By_Ref flag to ensure
-- that gigi does not attempt an extra unnecessary copy. (Actually
-- not just unnecessary but wrong in the case of a controlled type,
-- where gigi does not know how to do a copy.)
if Requires_Transient_Scope (Exp_Typ)
and then Exp_Is_Function_Call
then
Set_By_Ref (N);
-- Remove side effects from the expression now so that other parts
-- of the expander do not have to reanalyze this node without this
-- optimization
Rewrite (Exp, Duplicate_Subexpr_No_Checks (Exp));
-- Ada 2005 (AI-251): If the type of the returned object is
-- an interface then add an implicit type conversion to force
-- displacement of the "this" pointer.
if Is_Interface (R_Type) then
Rewrite (Exp, Convert_To (R_Type, Relocate_Node (Exp)));
end if;
Analyze_And_Resolve (Exp, R_Type);
-- For controlled types, do the allocation on the secondary stack
-- manually in order to call adjust at the right time:
-- type Anon1 is access R_Type;
-- for Anon1'Storage_pool use ss_pool;
-- Anon2 : anon1 := new R_Type'(expr);
-- return Anon2.all;
-- We do the same for classwide types that are not potentially
-- controlled (by the virtue of restriction No_Finalization) because
-- gigi is not able to properly allocate class-wide types.
elsif CW_Or_Has_Controlled_Part (Utyp) then
declare
Loc : constant Source_Ptr := Sloc (N);
Acc_Typ : constant Entity_Id := Make_Temporary (Loc, 'A');
Alloc_Node : Node_Id;
Temp : Entity_Id;
begin
Set_Ekind (Acc_Typ, E_Access_Type);
Set_Associated_Storage_Pool (Acc_Typ, RTE (RE_SS_Pool));
-- This is an allocator for the secondary stack, and it's fine
-- to have Comes_From_Source set False on it, as gigi knows not
-- to flag it as a violation of No_Implicit_Heap_Allocations.
Alloc_Node :=
Make_Allocator (Loc,
Expression =>
Make_Qualified_Expression (Loc,
Subtype_Mark => New_Occurrence_Of (Etype (Exp), Loc),
Expression => Relocate_Node (Exp)));
-- We do not want discriminant checks on the declaration,
-- given that it gets its value from the allocator.
Set_No_Initialization (Alloc_Node);
Temp := Make_Temporary (Loc, 'R', Alloc_Node);
Insert_List_Before_And_Analyze (N, New_List (
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Acc_Typ,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
Subtype_Indication => Subtype_Ind)),
Make_Object_Declaration (Loc,
Defining_Identifier => Temp,
Object_Definition => New_Occurrence_Of (Acc_Typ, Loc),
Expression => Alloc_Node)));
Rewrite (Exp,
Make_Explicit_Dereference (Loc,
Prefix => New_Occurrence_Of (Temp, Loc)));
-- Ada 2005 (AI-251): If the type of the returned object is
-- an interface then add an implicit type conversion to force
-- displacement of the "this" pointer.
if Is_Interface (R_Type) then
Rewrite (Exp, Convert_To (R_Type, Relocate_Node (Exp)));
end if;
Analyze_And_Resolve (Exp, R_Type);
end;
-- Otherwise use the gigi mechanism to allocate result on the
-- secondary stack.
else
Check_Restriction (No_Secondary_Stack, N);
Set_Storage_Pool (N, RTE (RE_SS_Pool));
Set_Procedure_To_Call (N, RTE (RE_SS_Allocate));
end if;
end if;
-- Implement the rules of 6.5(8-10), which require a tag check in
-- the case of a limited tagged return type, and tag reassignment for
-- nonlimited tagged results. These actions are needed when the return
-- type is a specific tagged type and the result expression is a
-- conversion or a formal parameter, because in that case the tag of
-- the expression might differ from the tag of the specific result type.
-- We must also verify an underlying type exists for the return type in
-- case it is incomplete - in which case is not necessary to generate a
-- check anyway since an incomplete limited tagged return type would
-- qualify as a premature usage.
if Present (Utyp)
and then Is_Tagged_Type (Utyp)
and then not Is_Class_Wide_Type (Utyp)
and then (Nkind (Exp) in
N_Type_Conversion | N_Unchecked_Type_Conversion
or else (Is_Entity_Name (Exp)
and then Is_Formal (Entity (Exp))))
then
-- When the return type is limited, perform a check that the tag of
-- the result is the same as the tag of the return type.
if Is_Limited_Type (R_Type) then
Insert_Action (Exp,
Make_Raise_Constraint_Error (Loc,
Condition =>
Make_Op_Ne (Loc,
Left_Opnd =>
Make_Selected_Component (Loc,
Prefix => Duplicate_Subexpr (Exp),
Selector_Name => Make_Identifier (Loc, Name_uTag)),
Right_Opnd =>
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Base_Type (Utyp), Loc),
Attribute_Name => Name_Tag)),
Reason => CE_Tag_Check_Failed));
-- If the result type is a specific nonlimited tagged type, then we
-- have to ensure that the tag of the result is that of the result
-- type. This is handled by making a copy of the expression in
-- the case where it might have a different tag, namely when the
-- expression is a conversion or a formal parameter. We create a new
-- object of the result type and initialize it from the expression,
-- which will implicitly force the tag to be set appropriately.
else
declare
ExpR : constant Node_Id := Relocate_Node (Exp);
Result_Id : constant Entity_Id :=
Make_Temporary (Loc, 'R', ExpR);
Result_Exp : constant Node_Id :=
New_Occurrence_Of (Result_Id, Loc);
Result_Obj : constant Node_Id :=
Make_Object_Declaration (Loc,
Defining_Identifier => Result_Id,
Object_Definition =>
New_Occurrence_Of (R_Type, Loc),
Constant_Present => True,
Expression => ExpR);
begin
Set_Assignment_OK (Result_Obj);
Insert_Action (Exp, Result_Obj);
Rewrite (Exp, Result_Exp);
Analyze_And_Resolve (Exp, R_Type);
end;
end if;
-- Ada 2005 (AI95-344): If the result type is class-wide, then insert
-- a check that the level of the return expression's underlying type
-- is not deeper than the level of the master enclosing the function.
-- AI12-043: The check is made immediately after the return object is
-- created. This means that we do not apply it to the simple return
-- generated by the expansion of an extended return statement.
-- No runtime check needed in interface thunks since it is performed
-- by the target primitive associated with the thunk.
elsif Is_Class_Wide_Type (R_Type)
and then not Comes_From_Extended_Return_Statement (N)
and then not Is_Thunk (Scope_Id)
then
Apply_CW_Accessibility_Check (Exp, Scope_Id);
-- Ada 2012 (AI05-0073): If the result subtype of the function is
-- defined by an access_definition designating a specific tagged
-- type T, a check is made that the result value is null or the tag
-- of the object designated by the result value identifies T.
-- The return expression is referenced twice in the code below, so it
-- must be made free of side effects. Given that different compilers
-- may evaluate these parameters in different order, both occurrences
-- perform a copy.
elsif Ekind (R_Type) = E_Anonymous_Access_Type
and then Is_Tagged_Type (Designated_Type (R_Type))
and then not Is_Class_Wide_Type (Designated_Type (R_Type))
and then Nkind (Original_Node (Exp)) /= N_Null
and then not Tag_Checks_Suppressed (Designated_Type (R_Type))
then
-- Generate:
-- [Constraint_Error
-- when Exp /= null
-- and then Exp.all not in Designated_Type]
Insert_Action (N,
Make_Raise_Constraint_Error (Loc,
Condition =>
Make_And_Then (Loc,
Left_Opnd =>
Make_Op_Ne (Loc,
Left_Opnd => Duplicate_Subexpr (Exp),
Right_Opnd => Make_Null (Loc)),
Right_Opnd =>
Make_Not_In (Loc,
Left_Opnd =>
Make_Explicit_Dereference (Loc,
Prefix => Duplicate_Subexpr (Exp)),
Right_Opnd =>
New_Occurrence_Of (Designated_Type (R_Type), Loc))),
Reason => CE_Tag_Check_Failed),
Suppress => All_Checks);
end if;
-- Determine if the special rules within RM 3.10.2 for explicitly
-- aliased formals apply to Exp - in which case we require a dynamic
-- check to be generated.
if Is_Special_Aliased_Formal_Access (Exp, Scope_Id) then
Check_Against_Result_Level
(Make_Integer_Literal (Loc,
Object_Access_Level (Entity (Ultimate_Prefix (Prefix (Exp))))));
end if;
-- AI05-0234: Check unconstrained access discriminants to ensure
-- that the result does not outlive an object designated by one
-- of its discriminants (RM 6.5(21/3)).
if Present (Extra_Accessibility_Of_Result (Scope_Id))
and then Has_Unconstrained_Access_Discriminants (R_Type)
then
declare
Discrim_Source : Node_Id;
begin
Discrim_Source := Exp;
while Nkind (Discrim_Source) = N_Qualified_Expression loop
Discrim_Source := Expression (Discrim_Source);
end loop;
if Nkind (Discrim_Source) = N_Identifier
and then Is_Return_Object (Entity (Discrim_Source))
then
Discrim_Source := Entity (Discrim_Source);
if Is_Constrained (Etype (Discrim_Source)) then
Discrim_Source := Etype (Discrim_Source);
else
Discrim_Source := Expression (Parent (Discrim_Source));
end if;
elsif Nkind (Discrim_Source) = N_Identifier
and then Nkind (Original_Node (Discrim_Source)) in
N_Aggregate | N_Extension_Aggregate
then
Discrim_Source := Original_Node (Discrim_Source);
elsif Nkind (Discrim_Source) = N_Explicit_Dereference and then
Nkind (Original_Node (Discrim_Source)) = N_Function_Call
then
Discrim_Source := Original_Node (Discrim_Source);
end if;
Discrim_Source := Unqual_Conv (Discrim_Source);
case Nkind (Discrim_Source) is
when N_Defining_Identifier =>
pragma Assert (Is_Composite_Type (Discrim_Source)
and then Has_Discriminants (Discrim_Source)
and then Is_Constrained (Discrim_Source));
declare
Discrim : Entity_Id :=
First_Discriminant (Base_Type (R_Type));
Disc_Elmt : Elmt_Id :=
First_Elmt (Discriminant_Constraint
(Discrim_Source));
begin
loop
if Ekind (Etype (Discrim)) =
E_Anonymous_Access_Type
then
Check_Against_Result_Level
(Dynamic_Accessibility_Level (Node (Disc_Elmt)));
end if;
Next_Elmt (Disc_Elmt);
Next_Discriminant (Discrim);
exit when not Present (Discrim);
end loop;
end;
when N_Aggregate
| N_Extension_Aggregate
=>
-- Unimplemented: extension aggregate case where discrims
-- come from ancestor part, not extension part.
declare
Discrim : Entity_Id :=
First_Discriminant (Base_Type (R_Type));
Disc_Exp : Node_Id := Empty;
Positionals_Exhausted
: Boolean := not Present (Expressions
(Discrim_Source));
function Associated_Expr
(Comp_Id : Entity_Id;
Associations : List_Id) return Node_Id;
-- Given a component and a component associations list,
-- locate the expression for that component; returns
-- Empty if no such expression is found.
---------------------
-- Associated_Expr --
---------------------
function Associated_Expr
(Comp_Id : Entity_Id;
Associations : List_Id) return Node_Id
is
Assoc : Node_Id;
Choice : Node_Id;
begin
-- Simple linear search seems ok here
Assoc := First (Associations);
while Present (Assoc) loop
Choice := First (Choices (Assoc));
while Present (Choice) loop
if (Nkind (Choice) = N_Identifier
and then Chars (Choice) = Chars (Comp_Id))
or else (Nkind (Choice) = N_Others_Choice)
then
return Expression (Assoc);
end if;
Next (Choice);
end loop;
Next (Assoc);
end loop;
return Empty;
end Associated_Expr;
begin
if not Positionals_Exhausted then
Disc_Exp := First (Expressions (Discrim_Source));
end if;
loop
if Positionals_Exhausted then
Disc_Exp :=
Associated_Expr
(Discrim,
Component_Associations (Discrim_Source));
end if;
if Ekind (Etype (Discrim)) =
E_Anonymous_Access_Type
then
Check_Against_Result_Level
(Dynamic_Accessibility_Level (Disc_Exp));
end if;
Next_Discriminant (Discrim);
exit when not Present (Discrim);
if not Positionals_Exhausted then
Next (Disc_Exp);
Positionals_Exhausted := not Present (Disc_Exp);
end if;
end loop;
end;
when N_Function_Call =>
-- No check needed (check performed by callee)
null;
when others =>
declare
Level : constant Node_Id :=
Make_Integer_Literal (Loc,
Object_Access_Level (Discrim_Source));
begin
-- Unimplemented: check for name prefix that includes
-- a dereference of an access value with a dynamic
-- accessibility level (e.g., an access param or a
-- saooaaat) and use dynamic level in that case. For
-- example:
-- return Access_Param.all(Some_Index).Some_Component;
-- ???
Set_Etype (Level, Standard_Natural);
Check_Against_Result_Level (Level);
end;
end case;
end;
end if;
-- If we are returning a nonscalar object that is possibly unaligned,
-- then copy the value into a temporary first. This copy may need to
-- expand to a loop of component operations.
if Is_Possibly_Unaligned_Slice (Exp)
or else (Is_Possibly_Unaligned_Object (Exp)
and then not Represented_As_Scalar (Etype (Exp)))
then
declare
ExpR : constant Node_Id := Relocate_Node (Exp);
Tnn : constant Entity_Id := Make_Temporary (Loc, 'T', ExpR);
begin
Insert_Action (Exp,
Make_Object_Declaration (Loc,
Defining_Identifier => Tnn,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (R_Type, Loc),
Expression => ExpR),
Suppress => All_Checks);
Rewrite (Exp, New_Occurrence_Of (Tnn, Loc));
end;
end if;
-- Call the _Postconditions procedure if the related function has
-- contract assertions that need to be verified on exit.
if Ekind (Scope_Id) = E_Function
and then Present (Postconditions_Proc (Scope_Id))
then
-- In the case of discriminated objects, we have created a
-- constrained subtype above, and used the underlying type. This
-- transformation is post-analysis and harmless, except that now the
-- call to the post-condition will be analyzed and the type kinds
-- have to match.
if Nkind (Exp) = N_Unchecked_Type_Conversion
and then Is_Private_Type (R_Type) /= Is_Private_Type (Etype (Exp))
then
Rewrite (Exp, Expression (Relocate_Node (Exp)));
end if;
-- We are going to reference the returned value twice in this case,
-- once in the call to _Postconditions, and once in the actual return
-- statement, but we can't have side effects happening twice.
Force_Evaluation (Exp, Mode => Strict);
-- Generate call to _Postconditions
Insert_Action (Exp,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (Postconditions_Proc (Scope_Id), Loc),
Parameter_Associations => New_List (New_Copy_Tree (Exp))));
end if;
-- Ada 2005 (AI-251): If this return statement corresponds with an
-- simple return statement associated with an extended return statement
-- and the type of the returned object is an interface then generate an
-- implicit conversion to force displacement of the "this" pointer.
if Ada_Version >= Ada_2005
and then Comes_From_Extended_Return_Statement (N)
and then Nkind (Expression (N)) = N_Identifier
and then Is_Interface (Utyp)
and then Utyp /= Underlying_Type (Exp_Typ)
then
Rewrite (Exp, Convert_To (Utyp, Relocate_Node (Exp)));
Analyze_And_Resolve (Exp);
end if;
-- Ada 2020 (AI12-0279)
if Has_Yield_Aspect (Scope_Id)
and then RTE_Available (RE_Yield)
then
Insert_Action (N,
Make_Procedure_Call_Statement (Loc,
New_Occurrence_Of (RTE (RE_Yield), Loc)));
end if;
end Expand_Simple_Function_Return;
-----------------------
-- Freeze_Subprogram --
-----------------------
procedure Freeze_Subprogram (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
procedure Register_Predefined_DT_Entry (Prim : Entity_Id);
-- (Ada 2005): Register a predefined primitive in all the secondary
-- dispatch tables of its primitive type.
----------------------------------
-- Register_Predefined_DT_Entry --
----------------------------------
procedure Register_Predefined_DT_Entry (Prim : Entity_Id) is
Iface_DT_Ptr : Elmt_Id;
Tagged_Typ : Entity_Id;
Thunk_Id : Entity_Id;
Thunk_Code : Node_Id;
begin
Tagged_Typ := Find_Dispatching_Type (Prim);
if No (Access_Disp_Table (Tagged_Typ))
or else not Has_Interfaces (Tagged_Typ)
or else not RTE_Available (RE_Interface_Tag)
or else Restriction_Active (No_Dispatching_Calls)
then
return;
end if;
-- Skip the first two access-to-dispatch-table pointers since they
-- leads to the primary dispatch table (predefined DT and user
-- defined DT). We are only concerned with the secondary dispatch
-- table pointers. Note that the access-to- dispatch-table pointer
-- corresponds to the first implemented interface retrieved below.
Iface_DT_Ptr :=
Next_Elmt (Next_Elmt (First_Elmt (Access_Disp_Table (Tagged_Typ))));
while Present (Iface_DT_Ptr)
and then Ekind (Node (Iface_DT_Ptr)) = E_Constant
loop
pragma Assert (Has_Thunks (Node (Iface_DT_Ptr)));
Expand_Interface_Thunk (Prim, Thunk_Id, Thunk_Code,
Iface => Related_Type (Node (Iface_DT_Ptr)));
if Present (Thunk_Code) then
Insert_Actions_After (N, New_List (
Thunk_Code,
Build_Set_Predefined_Prim_Op_Address (Loc,
Tag_Node =>
New_Occurrence_Of (Node (Next_Elmt (Iface_DT_Ptr)), Loc),
Position => DT_Position (Prim),
Address_Node =>
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Thunk_Id, Loc),
Attribute_Name => Name_Unrestricted_Access))),
Build_Set_Predefined_Prim_Op_Address (Loc,
Tag_Node =>
New_Occurrence_Of
(Node (Next_Elmt (Next_Elmt (Next_Elmt (Iface_DT_Ptr)))),
Loc),
Position => DT_Position (Prim),
Address_Node =>
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Prim, Loc),
Attribute_Name => Name_Unrestricted_Access)))));
end if;
-- Skip the tag of the predefined primitives dispatch table
Next_Elmt (Iface_DT_Ptr);
pragma Assert (Has_Thunks (Node (Iface_DT_Ptr)));
-- Skip tag of the no-thunks dispatch table
Next_Elmt (Iface_DT_Ptr);
pragma Assert (not Has_Thunks (Node (Iface_DT_Ptr)));
-- Skip tag of predefined primitives no-thunks dispatch table
Next_Elmt (Iface_DT_Ptr);
pragma Assert (not Has_Thunks (Node (Iface_DT_Ptr)));
Next_Elmt (Iface_DT_Ptr);
end loop;
end Register_Predefined_DT_Entry;
-- Local variables
Subp : constant Entity_Id := Entity (N);
-- Start of processing for Freeze_Subprogram
begin
-- We suppress the initialization of the dispatch table entry when
-- not Tagged_Type_Expansion because the dispatching mechanism is
-- handled internally by the target.
if Is_Dispatching_Operation (Subp)
and then not Is_Abstract_Subprogram (Subp)
and then Present (DTC_Entity (Subp))
and then Present (Scope (DTC_Entity (Subp)))
and then Tagged_Type_Expansion
and then not Restriction_Active (No_Dispatching_Calls)
and then RTE_Available (RE_Tag)
then
declare
Typ : constant Entity_Id := Scope (DTC_Entity (Subp));
begin
-- Handle private overridden primitives
if not Is_CPP_Class (Typ) then
Check_Overriding_Operation (Subp);
end if;
-- We assume that imported CPP primitives correspond with objects
-- whose constructor is in the CPP side; therefore we don't need
-- to generate code to register them in the dispatch table.
if Is_CPP_Class (Typ) then
null;
-- Handle CPP primitives found in derivations of CPP_Class types.
-- These primitives must have been inherited from some parent, and
-- there is no need to register them in the dispatch table because
-- Build_Inherit_Prims takes care of initializing these slots.
elsif Is_Imported (Subp)
and then Convention (Subp) in Convention_C_Family
then
null;
-- Generate code to register the primitive in non statically
-- allocated dispatch tables
elsif not Building_Static_DT (Scope (DTC_Entity (Subp))) then
-- When a primitive is frozen, enter its name in its dispatch
-- table slot.
if not Is_Interface (Typ)
or else Present (Interface_Alias (Subp))
then
if Is_Predefined_Dispatching_Operation (Subp) then
Register_Predefined_DT_Entry (Subp);
end if;
Insert_Actions_After (N,
Register_Primitive (Loc, Prim => Subp));
end if;
end if;
end;
end if;
-- Mark functions that return by reference. Note that it cannot be part
-- of the normal semantic analysis of the spec since the underlying
-- returned type may not be known yet (for private types).
declare
Typ : constant Entity_Id := Etype (Subp);
Utyp : constant Entity_Id := Underlying_Type (Typ);
begin
if Is_Limited_View (Typ) then
Set_Returns_By_Ref (Subp);
elsif Present (Utyp) and then CW_Or_Has_Controlled_Part (Utyp) then
Set_Returns_By_Ref (Subp);
end if;
end;
-- Wnen freezing a null procedure, analyze its delayed aspects now
-- because we may not have reached the end of the declarative list when
-- delayed aspects are normally analyzed. This ensures that dispatching
-- calls are properly rewritten when the generated _Postcondition
-- procedure is analyzed in the null procedure body.
if Nkind (Parent (Subp)) = N_Procedure_Specification
and then Null_Present (Parent (Subp))
then
Analyze_Entry_Or_Subprogram_Contract (Subp);
end if;
end Freeze_Subprogram;
--------------------------
-- Has_BIP_Extra_Formal --
--------------------------
function Has_BIP_Extra_Formal
(E : Entity_Id;
Kind : BIP_Formal_Kind) return Boolean
is
Extra_Formal : Entity_Id := Extra_Formals (E);
begin
-- We can only rely on the availability of the extra formals in frozen
-- entities or in subprogram types of dispatching calls (since their
-- extra formals are added when the target subprogram is frozen; see
-- Expand_Dispatching_Call).
pragma Assert (Is_Frozen (E)
or else (Ekind (E) = E_Subprogram_Type
and then Is_Dispatch_Table_Entity (E))
or else (Is_Dispatching_Operation (E)
and then Is_Frozen (Find_Dispatching_Type (E))));
while Present (Extra_Formal) loop
if Is_Build_In_Place_Entity (Extra_Formal)
and then BIP_Suffix_Kind (Extra_Formal) = Kind
then
return True;
end if;
Next_Formal_With_Extras (Extra_Formal);
end loop;
return False;
end Has_BIP_Extra_Formal;
------------------------------
-- Insert_Post_Call_Actions --
------------------------------
procedure Insert_Post_Call_Actions (N : Node_Id; Post_Call : List_Id) is
Context : constant Node_Id := Parent (N);
begin
if Is_Empty_List (Post_Call) then
return;
end if;
-- Cases where the call is not a member of a statement list. This also
-- includes the cases where the call is an actual in another function
-- call, or is an index, or is an operand of an if-expression, i.e. is
-- in an expression context.
if not Is_List_Member (N)
or else Nkind (Context) in N_Function_Call
| N_If_Expression
| N_Indexed_Component
then
-- In Ada 2012 the call may be a function call in an expression
-- (since OUT and IN OUT parameters are now allowed for such calls).
-- The write-back of (in)-out parameters is handled by the back-end,
-- but the constraint checks generated when subtypes of formal and
-- actual don't match must be inserted in the form of assignments.
if Nkind (N) = N_Function_Call
or else Nkind (Original_Node (N)) = N_Function_Call
then
pragma Assert (Ada_Version >= Ada_2012);
-- Functions with '[in] out' parameters are only allowed in Ada
-- 2012.
-- We used to handle this by climbing up parents to a
-- non-statement/declaration and then simply making a call to
-- Insert_Actions_After (P, Post_Call), but that doesn't work
-- for Ada 2012. If we are in the middle of an expression, e.g.
-- the condition of an IF, this call would insert after the IF
-- statement, which is much too late to be doing the write back.
-- For example:
-- if Clobber (X) then
-- Put_Line (X'Img);
-- else
-- goto Junk
-- end if;
-- Now assume Clobber changes X, if we put the write back after
-- the IF, the Put_Line gets the wrong value and the goto causes
-- the write back to be skipped completely.
-- To deal with this, we replace the call by
-- do
-- Tnnn : constant function-result-type := function-call;
-- Post_Call actions
-- in
-- Tnnn;
-- end;
declare
Loc : constant Source_Ptr := Sloc (N);
Tnnn : constant Entity_Id := Make_Temporary (Loc, 'T');
FRTyp : constant Entity_Id := Etype (N);
Name : constant Node_Id := Relocate_Node (N);
begin
Prepend_To (Post_Call,
Make_Object_Declaration (Loc,
Defining_Identifier => Tnnn,
Object_Definition => New_Occurrence_Of (FRTyp, Loc),
Constant_Present => True,
Expression => Name));
Rewrite (N,
Make_Expression_With_Actions (Loc,
Actions => Post_Call,
Expression => New_Occurrence_Of (Tnnn, Loc)));
-- We don't want to just blindly call Analyze_And_Resolve
-- because that would cause unwanted recursion on the call.
-- So for a moment set the call as analyzed to prevent that
-- recursion, and get the rest analyzed properly, then reset
-- the analyzed flag, so our caller can continue.
Set_Analyzed (Name, True);
Analyze_And_Resolve (N, FRTyp);
Set_Analyzed (Name, False);
end;
-- If not the special Ada 2012 case of a function call, then we must
-- have the triggering statement of a triggering alternative or an
-- entry call alternative, and we can add the post call stuff to the
-- corresponding statement list.
else
pragma Assert (Nkind (Context) in N_Entry_Call_Alternative
| N_Triggering_Alternative);
if Is_Non_Empty_List (Statements (Context)) then
Insert_List_Before_And_Analyze
(First (Statements (Context)), Post_Call);
else
Set_Statements (Context, Post_Call);
end if;
end if;
-- A procedure call is always part of a declarative or statement list,
-- however a function call may appear nested within a construct. Most
-- cases of function call nesting are handled in the special case above.
-- The only exception is when the function call acts as an actual in a
-- procedure call. In this case the function call is in a list, but the
-- post-call actions must be inserted after the procedure call.
-- What if the function call is an aggregate component ???
elsif Nkind (Context) = N_Procedure_Call_Statement then
Insert_Actions_After (Context, Post_Call);
-- Otherwise, normal case where N is in a statement sequence, just put
-- the post-call stuff after the call statement.
else
Insert_Actions_After (N, Post_Call);
end if;
end Insert_Post_Call_Actions;
-----------------------------------
-- Is_Build_In_Place_Result_Type --
-----------------------------------
function Is_Build_In_Place_Result_Type (Typ : Entity_Id) return Boolean is
begin
if not Expander_Active then
return False;
end if;
-- In Ada 2005 all functions with an inherently limited return type
-- must be handled using a build-in-place profile, including the case
-- of a function with a limited interface result, where the function
-- may return objects of nonlimited descendants.
if Is_Limited_View (Typ) then
return Ada_Version >= Ada_2005 and then not Debug_Flag_Dot_L;
else
if Debug_Flag_Dot_9 then
return False;
end if;
if Has_Interfaces (Typ) then
return False;
end if;
declare
T : Entity_Id := Typ;
begin
-- For T'Class, return True if it's True for T. This is necessary
-- because a class-wide function might say "return F (...)", where
-- F returns the corresponding specific type. We need a loop in
-- case T is a subtype of a class-wide type.
while Is_Class_Wide_Type (T) loop
T := Etype (T);
end loop;
-- If this is a generic formal type in an instance, return True if
-- it's True for the generic actual type.
if Nkind (Parent (T)) = N_Subtype_Declaration
and then Present (Generic_Parent_Type (Parent (T)))
then
T := Entity (Subtype_Indication (Parent (T)));
if Present (Full_View (T)) then
T := Full_View (T);
end if;
end if;
if Present (Underlying_Type (T)) then
T := Underlying_Type (T);
end if;
declare
Result : Boolean;
-- So we can stop here in the debugger
begin
-- ???For now, enable build-in-place for a very narrow set of
-- controlled types. Change "if True" to "if False" to
-- experiment with more controlled types. Eventually, we might
-- like to enable build-in-place for all tagged types, all
-- types that need finalization, and all caller-unknown-size
-- types.
if True then
Result := Is_Controlled (T)
and then Present (Enclosing_Subprogram (T))
and then not Is_Compilation_Unit (Enclosing_Subprogram (T))
and then Ekind (Enclosing_Subprogram (T)) = E_Procedure;
else
Result := Is_Controlled (T);
end if;
return Result;
end;
end;
end if;
end Is_Build_In_Place_Result_Type;
------------------------------
-- Is_Build_In_Place_Entity --
------------------------------
function Is_Build_In_Place_Entity (E : Entity_Id) return Boolean is
Nam : constant String := Get_Name_String (Chars (E));
function Has_Suffix (Suffix : String) return Boolean;
-- Return True if Nam has suffix Suffix
function Has_Suffix (Suffix : String) return Boolean is
Len : constant Natural := Suffix'Length;
begin
return Nam'Length > Len
and then Nam (Nam'Last - Len + 1 .. Nam'Last) = Suffix;
end Has_Suffix;
-- Start of processing for Is_Build_In_Place_Entity
begin
return Has_Suffix (BIP_Alloc_Suffix)
or else Has_Suffix (BIP_Storage_Pool_Suffix)
or else Has_Suffix (BIP_Finalization_Master_Suffix)
or else Has_Suffix (BIP_Task_Master_Suffix)
or else Has_Suffix (BIP_Activation_Chain_Suffix)
or else Has_Suffix (BIP_Object_Access_Suffix);
end Is_Build_In_Place_Entity;
--------------------------------
-- Is_Build_In_Place_Function --
--------------------------------
function Is_Build_In_Place_Function (E : Entity_Id) return Boolean is
begin
-- This function is called from Expand_Subtype_From_Expr during
-- semantic analysis, even when expansion is off. In those cases
-- the build_in_place expansion will not take place.
if not Expander_Active then
return False;
end if;
-- For now we test whether E denotes a function or access-to-function
-- type whose result subtype is inherently limited. Later this test
-- may be revised to allow composite nonlimited types.
if Ekind (E) in E_Function | E_Generic_Function
or else (Ekind (E) = E_Subprogram_Type
and then Etype (E) /= Standard_Void_Type)
then
-- If the function is imported from a foreign language, we don't do
-- build-in-place. Note that Import (Ada) functions can do
-- build-in-place. Note that it is OK for a build-in-place function
-- to return a type with a foreign convention; the build-in-place
-- machinery will ensure there is no copying.
return Is_Build_In_Place_Result_Type (Etype (E))
and then not (Has_Foreign_Convention (E) and then Is_Imported (E))
and then not Debug_Flag_Dot_L;
else
return False;
end if;
end Is_Build_In_Place_Function;
-------------------------------------
-- Is_Build_In_Place_Function_Call --
-------------------------------------
function Is_Build_In_Place_Function_Call (N : Node_Id) return Boolean is
Exp_Node : constant Node_Id := Unqual_Conv (N);
Function_Id : Entity_Id;
begin
-- Return False if the expander is currently inactive, since awareness
-- of build-in-place treatment is only relevant during expansion. Note
-- that Is_Build_In_Place_Function, which is called as part of this
-- function, is also conditioned this way, but we need to check here as
-- well to avoid blowing up on processing protected calls when expansion
-- is disabled (such as with -gnatc) since those would trip over the
-- raise of Program_Error below.
-- In SPARK mode, build-in-place calls are not expanded, so that we
-- may end up with a call that is neither resolved to an entity, nor
-- an indirect call.
if not Expander_Active or else Nkind (Exp_Node) /= N_Function_Call then
return False;
end if;
if Is_Entity_Name (Name (Exp_Node)) then
Function_Id := Entity (Name (Exp_Node));
-- In the case of an explicitly dereferenced call, use the subprogram
-- type generated for the dereference.
elsif Nkind (Name (Exp_Node)) = N_Explicit_Dereference then
Function_Id := Etype (Name (Exp_Node));
-- This may be a call to a protected function.
elsif Nkind (Name (Exp_Node)) = N_Selected_Component then
Function_Id := Etype (Entity (Selector_Name (Name (Exp_Node))));
else
raise Program_Error;
end if;
declare
Result : constant Boolean := Is_Build_In_Place_Function (Function_Id);
-- So we can stop here in the debugger
begin
return Result;
end;
end Is_Build_In_Place_Function_Call;
-----------------------
-- Is_Null_Procedure --
-----------------------
function Is_Null_Procedure (Subp : Entity_Id) return Boolean is
Decl : constant Node_Id := Unit_Declaration_Node (Subp);
begin
if Ekind (Subp) /= E_Procedure then
return False;
-- Check if this is a declared null procedure
elsif Nkind (Decl) = N_Subprogram_Declaration then
if not Null_Present (Specification (Decl)) then
return False;
elsif No (Body_To_Inline (Decl)) then
return False;
-- Check if the body contains only a null statement, followed by
-- the return statement added during expansion.
else
declare
Orig_Bod : constant Node_Id := Body_To_Inline (Decl);
Stat : Node_Id;
Stat2 : Node_Id;
begin
if Nkind (Orig_Bod) /= N_Subprogram_Body then
return False;
else
-- We must skip SCIL nodes because they are currently
-- implemented as special N_Null_Statement nodes.
Stat :=
First_Non_SCIL_Node
(Statements (Handled_Statement_Sequence (Orig_Bod)));
Stat2 := Next_Non_SCIL_Node (Stat);
return
Is_Empty_List (Declarations (Orig_Bod))
and then Nkind (Stat) = N_Null_Statement
and then
(No (Stat2)
or else
(Nkind (Stat2) = N_Simple_Return_Statement
and then No (Next (Stat2))));
end if;
end;
end if;
else
return False;
end if;
end Is_Null_Procedure;
-------------------------------------------
-- Make_Build_In_Place_Call_In_Allocator --
-------------------------------------------
procedure Make_Build_In_Place_Call_In_Allocator
(Allocator : Node_Id;
Function_Call : Node_Id)
is
Acc_Type : constant Entity_Id := Etype (Allocator);
Loc : constant Source_Ptr := Sloc (Function_Call);
Func_Call : Node_Id := Function_Call;
Ref_Func_Call : Node_Id;
Function_Id : Entity_Id;
Result_Subt : Entity_Id;
New_Allocator : Node_Id;
Return_Obj_Access : Entity_Id; -- temp for function result
Temp_Init : Node_Id; -- initial value of Return_Obj_Access
Alloc_Form : BIP_Allocation_Form;
Pool : Node_Id; -- nonnull if Alloc_Form = User_Storage_Pool
Return_Obj_Actual : Node_Id; -- the temp.all, in caller-allocates case
Chain : Entity_Id; -- activation chain, in case of tasks
begin
-- Step past qualification or unchecked conversion (the latter can occur
-- in cases of calls to 'Input).
if Nkind (Func_Call) in N_Qualified_Expression
| N_Type_Conversion
| N_Unchecked_Type_Conversion
then
Func_Call := Expression (Func_Call);
end if;
-- Mark the call as processed as a build-in-place call
pragma Assert (not Is_Expanded_Build_In_Place_Call (Func_Call));
Set_Is_Expanded_Build_In_Place_Call (Func_Call);
if Is_Entity_Name (Name (Func_Call)) then
Function_Id := Entity (Name (Func_Call));
elsif Nkind (Name (Func_Call)) = N_Explicit_Dereference then
Function_Id := Etype (Name (Func_Call));
else
raise Program_Error;
end if;
Warn_BIP (Func_Call);
Result_Subt := Available_View (Etype (Function_Id));
-- Create a temp for the function result. In the caller-allocates case,
-- this will be initialized to the result of a new uninitialized
-- allocator. Note: we do not use Allocator as the Related_Node of
-- Return_Obj_Access in call to Make_Temporary below as this would
-- create a sort of infinite "recursion".
Return_Obj_Access := Make_Temporary (Loc, 'R');
Set_Etype (Return_Obj_Access, Acc_Type);
Set_Can_Never_Be_Null (Acc_Type, False);
-- It gets initialized to null, so we can't have that
-- When the result subtype is constrained, the return object is created
-- on the caller side, and access to it is passed to the function. This
-- optimization is disabled when the result subtype needs finalization
-- actions because the caller side allocation may result in undesirable
-- finalization. Consider the following example:
--
-- function Make_Lim_Ctrl return Lim_Ctrl is
-- begin
-- return Result : Lim_Ctrl := raise Program_Error do
-- null;
-- end return;
-- end Make_Lim_Ctrl;
--
-- Obj : Lim_Ctrl_Ptr := new Lim_Ctrl'(Make_Lim_Ctrl);
--
-- Even though the size of limited controlled type Lim_Ctrl is known,
-- allocating Obj at the caller side will chain Obj on Lim_Ctrl_Ptr's
-- finalization master. The subsequent call to Make_Lim_Ctrl will fail
-- during the initialization actions for Result, which implies that
-- Result (and Obj by extension) should not be finalized. However Obj
-- will be finalized when access type Lim_Ctrl_Ptr goes out of scope
-- since it is already attached on the related finalization master.
-- Here and in related routines, we must examine the full view of the
-- type, because the view at the point of call may differ from the
-- one in the function body, and the expansion mechanism depends on
-- the characteristics of the full view.
if Needs_BIP_Alloc_Form (Function_Id) then
Temp_Init := Empty;
-- Case of a user-defined storage pool. Pass an allocation parameter
-- indicating that the function should allocate its result in the
-- pool, and pass the pool. Use 'Unrestricted_Access because the
-- pool may not be aliased.
if Present (Associated_Storage_Pool (Acc_Type)) then
Alloc_Form := User_Storage_Pool;
Pool :=
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of
(Associated_Storage_Pool (Acc_Type), Loc),
Attribute_Name => Name_Unrestricted_Access);
-- No user-defined pool; pass an allocation parameter indicating that
-- the function should allocate its result on the heap.
else
Alloc_Form := Global_Heap;
Pool := Make_Null (No_Location);
end if;
-- The caller does not provide the return object in this case, so we
-- have to pass null for the object access actual.
Return_Obj_Actual := Empty;
else
-- Replace the initialized allocator of form "new T'(Func (...))"
-- with an uninitialized allocator of form "new T", where T is the
-- result subtype of the called function. The call to the function
-- is handled separately further below.
New_Allocator :=
Make_Allocator (Loc,
Expression => New_Occurrence_Of (Result_Subt, Loc));
Set_No_Initialization (New_Allocator);
-- Copy attributes to new allocator. Note that the new allocator
-- logically comes from source if the original one did, so copy the
-- relevant flag. This ensures proper treatment of the restriction
-- No_Implicit_Heap_Allocations in this case.
Set_Storage_Pool (New_Allocator, Storage_Pool (Allocator));
Set_Procedure_To_Call (New_Allocator, Procedure_To_Call (Allocator));
Set_Comes_From_Source (New_Allocator, Comes_From_Source (Allocator));
Rewrite (Allocator, New_Allocator);
-- Initial value of the temp is the result of the uninitialized
-- allocator. Unchecked_Convert is needed for T'Input where T is
-- derived from a controlled type.
Temp_Init := Relocate_Node (Allocator);
if Nkind (Function_Call) in
N_Type_Conversion | N_Unchecked_Type_Conversion
then
Temp_Init := Unchecked_Convert_To (Acc_Type, Temp_Init);
end if;
-- Indicate that caller allocates, and pass in the return object
Alloc_Form := Caller_Allocation;
Pool := Make_Null (No_Location);
Return_Obj_Actual :=
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (Result_Subt, Loc),
Expression =>
Make_Explicit_Dereference (Loc,
Prefix => New_Occurrence_Of (Return_Obj_Access, Loc)));
-- When the result subtype is unconstrained, the function itself must
-- perform the allocation of the return object, so we pass parameters
-- indicating that.
end if;
-- Declare the temp object
Insert_Action (Allocator,
Make_Object_Declaration (Loc,
Defining_Identifier => Return_Obj_Access,
Object_Definition => New_Occurrence_Of (Acc_Type, Loc),
Expression => Temp_Init));
Ref_Func_Call := Make_Reference (Loc, Func_Call);
-- Ada 2005 (AI-251): If the type of the allocator is an interface
-- then generate an implicit conversion to force displacement of the
-- "this" pointer.
if Is_Interface (Designated_Type (Acc_Type)) then
Rewrite
(Ref_Func_Call,
OK_Convert_To (Acc_Type, Ref_Func_Call));
-- If the types are incompatible, we need an unchecked conversion. Note
-- that the full types will be compatible, but the types not visibly
-- compatible.
elsif Nkind (Function_Call)
in N_Type_Conversion | N_Unchecked_Type_Conversion
then
Ref_Func_Call := Unchecked_Convert_To (Acc_Type, Ref_Func_Call);
end if;
declare
Assign : constant Node_Id :=
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Return_Obj_Access, Loc),
Expression => Ref_Func_Call);
-- Assign the result of the function call into the temp. In the
-- caller-allocates case, this is overwriting the temp with its
-- initial value, which has no effect. In the callee-allocates case,
-- this is setting the temp to point to the object allocated by the
-- callee. Unchecked_Convert is needed for T'Input where T is derived
-- from a controlled type.
Actions : List_Id;
-- Actions to be inserted. If there are no tasks, this is just the
-- assignment statement. If the allocated object has tasks, we need
-- to wrap the assignment in a block that activates them. The
-- activation chain of that block must be passed to the function,
-- rather than some outer chain.
begin
if Might_Have_Tasks (Result_Subt) then
Actions := New_List;
Build_Task_Allocate_Block_With_Init_Stmts
(Actions, Allocator, Init_Stmts => New_List (Assign));
Chain := Activation_Chain_Entity (Last (Actions));
else
Actions := New_List (Assign);
Chain := Empty;
end if;
Insert_Actions (Allocator, Actions);
end;
-- When the function has a controlling result, an allocation-form
-- parameter must be passed indicating that the caller is allocating
-- the result object. This is needed because such a function can be
-- called as a dispatching operation and must be treated similarly
-- to functions with unconstrained result subtypes.
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Alloc_Form, Pool_Actual => Pool);
Add_Finalization_Master_Actual_To_Build_In_Place_Call
(Func_Call, Function_Id, Acc_Type);
Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Master_Actual => Master_Id (Acc_Type),
Chain => Chain);
-- Add an implicit actual to the function call that provides access
-- to the allocated object. An unchecked conversion to the (specific)
-- result subtype of the function is inserted to handle cases where
-- the access type of the allocator has a class-wide designated type.
Add_Access_Actual_To_Build_In_Place_Call
(Func_Call, Function_Id, Return_Obj_Actual);
-- Finally, replace the allocator node with a reference to the temp
Rewrite (Allocator, New_Occurrence_Of (Return_Obj_Access, Loc));
Analyze_And_Resolve (Allocator, Acc_Type);
pragma Assert (Check_Number_Of_Actuals (Func_Call, Function_Id));
pragma Assert (Check_BIP_Actuals (Func_Call, Function_Id));
end Make_Build_In_Place_Call_In_Allocator;
---------------------------------------------------
-- Make_Build_In_Place_Call_In_Anonymous_Context --
---------------------------------------------------
procedure Make_Build_In_Place_Call_In_Anonymous_Context
(Function_Call : Node_Id)
is
Loc : constant Source_Ptr := Sloc (Function_Call);
Func_Call : constant Node_Id := Unqual_Conv (Function_Call);
Function_Id : Entity_Id;
Result_Subt : Entity_Id;
Return_Obj_Id : Entity_Id;
Return_Obj_Decl : Entity_Id;
begin
-- If the call has already been processed to add build-in-place actuals
-- then return. One place this can occur is for calls to build-in-place
-- functions that occur within a call to a protected operation, where
-- due to rewriting and expansion of the protected call there can be
-- more than one call to Expand_Actuals for the same set of actuals.
if Is_Expanded_Build_In_Place_Call (Func_Call) then
return;
end if;
-- Mark the call as processed as a build-in-place call
Set_Is_Expanded_Build_In_Place_Call (Func_Call);
if Is_Entity_Name (Name (Func_Call)) then
Function_Id := Entity (Name (Func_Call));
elsif Nkind (Name (Func_Call)) = N_Explicit_Dereference then
Function_Id := Etype (Name (Func_Call));
else
raise Program_Error;
end if;
Warn_BIP (Func_Call);
Result_Subt := Etype (Function_Id);
-- If the build-in-place function returns a controlled object, then the
-- object needs to be finalized immediately after the context. Since
-- this case produces a transient scope, the servicing finalizer needs
-- to name the returned object. Create a temporary which is initialized
-- with the function call:
--
-- Temp_Id : Func_Type := BIP_Func_Call;
--
-- The initialization expression of the temporary will be rewritten by
-- the expander using the appropriate mechanism in Make_Build_In_Place_
-- Call_In_Object_Declaration.
if Needs_Finalization (Result_Subt) then
declare
Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'R');
Temp_Decl : Node_Id;
begin
-- Reset the guard on the function call since the following does
-- not perform actual call expansion.
Set_Is_Expanded_Build_In_Place_Call (Func_Call, False);
Temp_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Temp_Id,
Object_Definition =>
New_Occurrence_Of (Result_Subt, Loc),
Expression =>
New_Copy_Tree (Function_Call));
Insert_Action (Function_Call, Temp_Decl);
Rewrite (Function_Call, New_Occurrence_Of (Temp_Id, Loc));
Analyze (Function_Call);
end;
-- When the result subtype is definite, an object of the subtype is
-- declared and an access value designating it is passed as an actual.
elsif Caller_Known_Size (Func_Call, Result_Subt) then
-- Create a temporary object to hold the function result
Return_Obj_Id := Make_Temporary (Loc, 'R');
Set_Etype (Return_Obj_Id, Result_Subt);
Return_Obj_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Return_Obj_Id,
Aliased_Present => True,
Object_Definition => New_Occurrence_Of (Result_Subt, Loc));
Set_No_Initialization (Return_Obj_Decl);
Insert_Action (Func_Call, Return_Obj_Decl);
-- When the function has a controlling result, an allocation-form
-- parameter must be passed indicating that the caller is allocating
-- the result object. This is needed because such a function can be
-- called as a dispatching operation and must be treated similarly
-- to functions with unconstrained result subtypes.
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Alloc_Form => Caller_Allocation);
Add_Finalization_Master_Actual_To_Build_In_Place_Call
(Func_Call, Function_Id);
Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Make_Identifier (Loc, Name_uMaster));
-- Add an implicit actual to the function call that provides access
-- to the caller's return object.
Add_Access_Actual_To_Build_In_Place_Call
(Func_Call, Function_Id, New_Occurrence_Of (Return_Obj_Id, Loc));
pragma Assert (Check_Number_Of_Actuals (Func_Call, Function_Id));
pragma Assert (Check_BIP_Actuals (Func_Call, Function_Id));
-- When the result subtype is unconstrained, the function must allocate
-- the return object in the secondary stack, so appropriate implicit
-- parameters are added to the call to indicate that. A transient
-- scope is established to ensure eventual cleanup of the result.
else
-- Pass an allocation parameter indicating that the function should
-- allocate its result on the secondary stack.
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Alloc_Form => Secondary_Stack);
Add_Finalization_Master_Actual_To_Build_In_Place_Call
(Func_Call, Function_Id);
Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Make_Identifier (Loc, Name_uMaster));
-- Pass a null value to the function since no return object is
-- available on the caller side.
Add_Access_Actual_To_Build_In_Place_Call
(Func_Call, Function_Id, Empty);
pragma Assert (Check_Number_Of_Actuals (Func_Call, Function_Id));
pragma Assert (Check_BIP_Actuals (Func_Call, Function_Id));
end if;
end Make_Build_In_Place_Call_In_Anonymous_Context;
--------------------------------------------
-- Make_Build_In_Place_Call_In_Assignment --
--------------------------------------------
procedure Make_Build_In_Place_Call_In_Assignment
(Assign : Node_Id;
Function_Call : Node_Id)
is
Func_Call : constant Node_Id := Unqual_Conv (Function_Call);
Lhs : constant Node_Id := Name (Assign);
Loc : constant Source_Ptr := Sloc (Function_Call);
Func_Id : Entity_Id;
Obj_Decl : Node_Id;
Obj_Id : Entity_Id;
Ptr_Typ : Entity_Id;
Ptr_Typ_Decl : Node_Id;
New_Expr : Node_Id;
Result_Subt : Entity_Id;
begin
-- Mark the call as processed as a build-in-place call
pragma Assert (not Is_Expanded_Build_In_Place_Call (Func_Call));
Set_Is_Expanded_Build_In_Place_Call (Func_Call);
if Is_Entity_Name (Name (Func_Call)) then
Func_Id := Entity (Name (Func_Call));
elsif Nkind (Name (Func_Call)) = N_Explicit_Dereference then
Func_Id := Etype (Name (Func_Call));
else
raise Program_Error;
end if;
Warn_BIP (Func_Call);
Result_Subt := Etype (Func_Id);
-- When the result subtype is unconstrained, an additional actual must
-- be passed to indicate that the caller is providing the return object.
-- This parameter must also be passed when the called function has a
-- controlling result, because dispatching calls to the function needs
-- to be treated effectively the same as calls to class-wide functions.
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Func_Call, Func_Id, Alloc_Form => Caller_Allocation);
Add_Finalization_Master_Actual_To_Build_In_Place_Call
(Func_Call, Func_Id);
Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Func_Id, Make_Identifier (Loc, Name_uMaster));
-- Add an implicit actual to the function call that provides access to
-- the caller's return object.
Add_Access_Actual_To_Build_In_Place_Call
(Func_Call,
Func_Id,
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (Result_Subt, Loc),
Expression => Relocate_Node (Lhs)));
-- Create an access type designating the function's result subtype
Ptr_Typ := Make_Temporary (Loc, 'A');
Ptr_Typ_Decl :=
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Ptr_Typ,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
All_Present => True,
Subtype_Indication =>
New_Occurrence_Of (Result_Subt, Loc)));
Insert_After_And_Analyze (Assign, Ptr_Typ_Decl);
-- Finally, create an access object initialized to a reference to the
-- function call. We know this access value is non-null, so mark the
-- entity accordingly to suppress junk access checks.
New_Expr := Make_Reference (Loc, Relocate_Node (Func_Call));
-- Add a conversion if it's the wrong type
if Etype (New_Expr) /= Ptr_Typ then
New_Expr :=
Make_Unchecked_Type_Conversion (Loc,
New_Occurrence_Of (Ptr_Typ, Loc), New_Expr);
end if;
Obj_Id := Make_Temporary (Loc, 'R', New_Expr);
Set_Etype (Obj_Id, Ptr_Typ);
Set_Is_Known_Non_Null (Obj_Id);
Obj_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Obj_Id,
Object_Definition => New_Occurrence_Of (Ptr_Typ, Loc),
Expression => New_Expr);
Insert_After_And_Analyze (Ptr_Typ_Decl, Obj_Decl);
Rewrite (Assign, Make_Null_Statement (Loc));
pragma Assert (Check_Number_Of_Actuals (Func_Call, Func_Id));
pragma Assert (Check_BIP_Actuals (Func_Call, Func_Id));
end Make_Build_In_Place_Call_In_Assignment;
----------------------------------------------------
-- Make_Build_In_Place_Call_In_Object_Declaration --
----------------------------------------------------
procedure Make_Build_In_Place_Call_In_Object_Declaration
(Obj_Decl : Node_Id;
Function_Call : Node_Id)
is
function Get_Function_Id (Func_Call : Node_Id) return Entity_Id;
-- Get the value of Function_Id, below
---------------------
-- Get_Function_Id --
---------------------
function Get_Function_Id (Func_Call : Node_Id) return Entity_Id is
begin
if Is_Entity_Name (Name (Func_Call)) then
return Entity (Name (Func_Call));
elsif Nkind (Name (Func_Call)) = N_Explicit_Dereference then
return Etype (Name (Func_Call));
else
raise Program_Error;
end if;
end Get_Function_Id;
-- Local variables
Func_Call : constant Node_Id := Unqual_Conv (Function_Call);
Function_Id : constant Entity_Id := Get_Function_Id (Func_Call);
Loc : constant Source_Ptr := Sloc (Function_Call);
Obj_Loc : constant Source_Ptr := Sloc (Obj_Decl);
Obj_Def_Id : constant Entity_Id := Defining_Identifier (Obj_Decl);
Obj_Typ : constant Entity_Id := Etype (Obj_Def_Id);
Encl_Func : constant Entity_Id := Enclosing_Subprogram (Obj_Def_Id);
Result_Subt : constant Entity_Id := Etype (Function_Id);
Call_Deref : Node_Id;
Caller_Object : Node_Id;
Def_Id : Entity_Id;
Designated_Type : Entity_Id;
Fmaster_Actual : Node_Id := Empty;
Pool_Actual : Node_Id;
Ptr_Typ : Entity_Id;
Ptr_Typ_Decl : Node_Id;
Pass_Caller_Acc : Boolean := False;
Res_Decl : Node_Id;
Definite : constant Boolean :=
Caller_Known_Size (Func_Call, Result_Subt)
and then not Is_Class_Wide_Type (Obj_Typ);
-- In the case of "X : T'Class := F(...);", where F returns a
-- Caller_Known_Size (specific) tagged type, we treat it as
-- indefinite, because the code for the Definite case below sets the
-- initialization expression of the object to Empty, which would be
-- illegal Ada, and would cause gigi to misallocate X.
-- Start of processing for Make_Build_In_Place_Call_In_Object_Declaration
begin
-- If the call has already been processed to add build-in-place actuals
-- then return.
if Is_Expanded_Build_In_Place_Call (Func_Call) then
return;
end if;
-- Mark the call as processed as a build-in-place call
Set_Is_Expanded_Build_In_Place_Call (Func_Call);
Warn_BIP (Func_Call);
-- Create an access type designating the function's result subtype.
-- We use the type of the original call because it may be a call to an
-- inherited operation, which the expansion has replaced with the parent
-- operation that yields the parent type. Note that this access type
-- must be declared before we establish a transient scope, so that it
-- receives the proper accessibility level.
if Is_Class_Wide_Type (Obj_Typ)
and then not Is_Interface (Obj_Typ)
and then not Is_Class_Wide_Type (Etype (Function_Call))
then
Designated_Type := Obj_Typ;
else
Designated_Type := Etype (Function_Call);
end if;
Ptr_Typ := Make_Temporary (Loc, 'A');
Ptr_Typ_Decl :=
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Ptr_Typ,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
All_Present => True,
Subtype_Indication =>
New_Occurrence_Of (Designated_Type, Loc)));
-- The access type and its accompanying object must be inserted after
-- the object declaration in the constrained case, so that the function
-- call can be passed access to the object. In the indefinite case, or
-- if the object declaration is for a return object, the access type and
-- object must be inserted before the object, since the object
-- declaration is rewritten to be a renaming of a dereference of the
-- access object. Note: we need to freeze Ptr_Typ explicitly, because
-- the result object is in a different (transient) scope, so won't cause
-- freezing.
if Definite and then not Is_Return_Object (Obj_Def_Id) then
-- The presence of an address clause complicates the build-in-place
-- expansion because the indicated address must be processed before
-- the indirect call is generated (including the definition of a
-- local pointer to the object). The address clause may come from
-- an aspect specification or from an explicit attribute
-- specification appearing after the object declaration. These two
-- cases require different processing.
if Has_Aspect (Obj_Def_Id, Aspect_Address) then
-- Skip non-delayed pragmas that correspond to other aspects, if
-- any, to find proper insertion point for freeze node of object.
declare
D : Node_Id := Obj_Decl;
N : Node_Id := Next (D);
begin
while Present (N)
and then Nkind (N) in N_Attribute_Reference | N_Pragma
loop
Analyze (N);
D := N;
Next (N);
end loop;
Insert_After (D, Ptr_Typ_Decl);
-- Freeze object before pointer declaration, to ensure that
-- generated attribute for address is inserted at the proper
-- place.
Freeze_Before (Ptr_Typ_Decl, Obj_Def_Id);
end;
Analyze (Ptr_Typ_Decl);
elsif Present (Following_Address_Clause (Obj_Decl)) then
-- Locate explicit address clause, which may also follow pragmas
-- generated by other aspect specifications.
declare
Addr : constant Node_Id := Following_Address_Clause (Obj_Decl);
D : Node_Id := Next (Obj_Decl);
begin
while Present (D) loop
Analyze (D);
exit when D = Addr;
Next (D);
end loop;
Insert_After_And_Analyze (Addr, Ptr_Typ_Decl);
end;
else
Insert_After_And_Analyze (Obj_Decl, Ptr_Typ_Decl);
end if;
else
Insert_Action (Obj_Decl, Ptr_Typ_Decl);
end if;
-- Force immediate freezing of Ptr_Typ because Res_Decl will be
-- elaborated in an inner (transient) scope and thus won't cause
-- freezing by itself. It's not an itype, but it needs to be frozen
-- inside the current subprogram (see Freeze_Outside in freeze.adb).
Freeze_Itype (Ptr_Typ, Ptr_Typ_Decl);
-- If the object is a return object of an enclosing build-in-place
-- function, then the implicit build-in-place parameters of the
-- enclosing function are simply passed along to the called function.
-- (Unfortunately, this won't cover the case of extension aggregates
-- where the ancestor part is a build-in-place indefinite function
-- call that should be passed along the caller's parameters.
-- Currently those get mishandled by reassigning the result of the
-- call to the aggregate return object, when the call result should
-- really be directly built in place in the aggregate and not in a
-- temporary. ???)
if Is_Return_Object (Obj_Def_Id) then
Pass_Caller_Acc := True;
-- When the enclosing function has a BIP_Alloc_Form formal then we
-- pass it along to the callee (such as when the enclosing function
-- has an unconstrained or tagged result type).
if Needs_BIP_Alloc_Form (Encl_Func) then
if RTE_Available (RE_Root_Storage_Pool_Ptr) then
Pool_Actual :=
New_Occurrence_Of
(Build_In_Place_Formal
(Encl_Func, BIP_Storage_Pool), Loc);
-- The build-in-place pool formal is not built on e.g. ZFP
else
Pool_Actual := Empty;
end if;
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Function_Call => Func_Call,
Function_Id => Function_Id,
Alloc_Form_Exp =>
New_Occurrence_Of
(Build_In_Place_Formal (Encl_Func, BIP_Alloc_Form), Loc),
Pool_Actual => Pool_Actual);
-- Otherwise, if enclosing function has a definite result subtype,
-- then caller allocation will be used.
else
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Alloc_Form => Caller_Allocation);
end if;
if Needs_BIP_Finalization_Master (Encl_Func) then
Fmaster_Actual :=
New_Occurrence_Of
(Build_In_Place_Formal
(Encl_Func, BIP_Finalization_Master), Loc);
end if;
-- Retrieve the BIPacc formal from the enclosing function and convert
-- it to the access type of the callee's BIP_Object_Access formal.
Caller_Object :=
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark =>
New_Occurrence_Of
(Etype (Build_In_Place_Formal
(Function_Id, BIP_Object_Access)),
Loc),
Expression =>
New_Occurrence_Of
(Build_In_Place_Formal (Encl_Func, BIP_Object_Access),
Loc));
-- In the definite case, add an implicit actual to the function call
-- that provides access to the declared object. An unchecked conversion
-- to the (specific) result type of the function is inserted to handle
-- the case where the object is declared with a class-wide type.
elsif Definite then
Caller_Object :=
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (Result_Subt, Loc),
Expression => New_Occurrence_Of (Obj_Def_Id, Loc));
-- When the function has a controlling result, an allocation-form
-- parameter must be passed indicating that the caller is allocating
-- the result object. This is needed because such a function can be
-- called as a dispatching operation and must be treated similarly to
-- functions with indefinite result subtypes.
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Alloc_Form => Caller_Allocation);
-- The allocation for indefinite library-level objects occurs on the
-- heap as opposed to the secondary stack. This accommodates DLLs where
-- the secondary stack is destroyed after each library unload. This is a
-- hybrid mechanism where a stack-allocated object lives on the heap.
elsif Is_Library_Level_Entity (Obj_Def_Id)
and then not Restriction_Active (No_Implicit_Heap_Allocations)
then
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Alloc_Form => Global_Heap);
Caller_Object := Empty;
-- Create a finalization master for the access result type to ensure
-- that the heap allocation can properly chain the object and later
-- finalize it when the library unit goes out of scope.
if Needs_Finalization (Etype (Func_Call)) then
Build_Finalization_Master
(Typ => Ptr_Typ,
For_Lib_Level => True,
Insertion_Node => Ptr_Typ_Decl);
Fmaster_Actual :=
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Finalization_Master (Ptr_Typ), Loc),
Attribute_Name => Name_Unrestricted_Access);
end if;
-- In other indefinite cases, pass an indication to do the allocation
-- on the secondary stack and set Caller_Object to Empty so that a null
-- value will be passed for the caller's object address. A transient
-- scope is established to ensure eventual cleanup of the result.
else
Add_Unconstrained_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Alloc_Form => Secondary_Stack);
Caller_Object := Empty;
Establish_Transient_Scope (Obj_Decl, Manage_Sec_Stack => True);
end if;
-- Pass along any finalization master actual, which is needed in the
-- case where the called function initializes a return object of an
-- enclosing build-in-place function.
Add_Finalization_Master_Actual_To_Build_In_Place_Call
(Func_Call => Func_Call,
Func_Id => Function_Id,
Master_Exp => Fmaster_Actual);
if Nkind (Parent (Obj_Decl)) = N_Extended_Return_Statement
and then Needs_BIP_Task_Actuals (Function_Id)
then
-- Here we're passing along the master that was passed in to this
-- function.
Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id,
Master_Actual =>
New_Occurrence_Of
(Build_In_Place_Formal (Encl_Func, BIP_Task_Master), Loc));
else
Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Make_Identifier (Loc, Name_uMaster));
end if;
Add_Access_Actual_To_Build_In_Place_Call
(Func_Call,
Function_Id,
Caller_Object,
Is_Access => Pass_Caller_Acc);
-- Finally, create an access object initialized to a reference to the
-- function call. We know this access value cannot be null, so mark the
-- entity accordingly to suppress the access check. We need to suppress
-- warnings, because this can be part of the expansion of "for ... of"
-- and similar constructs that generate finalization actions. Such
-- finalization actions are safe, because they check a count that
-- indicates which objects should be finalized, but the back end
-- nonetheless warns about uninitialized objects.
Def_Id := Make_Temporary (Loc, 'R', Func_Call);
Set_Warnings_Off (Def_Id);
Set_Etype (Def_Id, Ptr_Typ);
Set_Is_Known_Non_Null (Def_Id);
if Nkind (Function_Call) in N_Type_Conversion
| N_Unchecked_Type_Conversion
then
Res_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Def_Id,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (Ptr_Typ, Loc),
Expression =>
Make_Unchecked_Type_Conversion (Loc,
New_Occurrence_Of (Ptr_Typ, Loc),
Make_Reference (Loc, Relocate_Node (Func_Call))));
else
Res_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Def_Id,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (Ptr_Typ, Loc),
Expression =>
Make_Reference (Loc, Relocate_Node (Func_Call)));
end if;
Insert_After_And_Analyze (Ptr_Typ_Decl, Res_Decl);
-- If the result subtype of the called function is definite and is not
-- itself the return expression of an enclosing BIP function, then mark
-- the object as having no initialization.
if Definite and then not Is_Return_Object (Obj_Def_Id) then
-- The related object declaration is encased in a transient block
-- because the build-in-place function call contains at least one
-- nested function call that produces a controlled transient
-- temporary:
-- Obj : ... := BIP_Func_Call (Ctrl_Func_Call);
-- Since the build-in-place expansion decouples the call from the
-- object declaration, the finalization machinery lacks the context
-- which prompted the generation of the transient block. To resolve
-- this scenario, store the build-in-place call.
if Scope_Is_Transient then
Set_BIP_Initialization_Call (Obj_Def_Id, Res_Decl);
end if;
Set_Expression (Obj_Decl, Empty);
Set_No_Initialization (Obj_Decl);
-- In case of an indefinite result subtype, or if the call is the
-- return expression of an enclosing BIP function, rewrite the object
-- declaration as an object renaming where the renamed object is a
-- dereference of <function_Call>'reference:
--
-- Obj : Subt renames <function_call>'Ref.all;
else
Call_Deref :=
Make_Explicit_Dereference (Obj_Loc,
Prefix => New_Occurrence_Of (Def_Id, Obj_Loc));
Rewrite (Obj_Decl,
Make_Object_Renaming_Declaration (Obj_Loc,
Defining_Identifier => Make_Temporary (Obj_Loc, 'D'),
Subtype_Mark =>
New_Occurrence_Of (Designated_Type, Obj_Loc),
Name => Call_Deref));
-- At this point, Defining_Identifier (Obj_Decl) is no longer equal
-- to Obj_Def_Id.
Set_Renamed_Object (Defining_Identifier (Obj_Decl), Call_Deref);
-- If the original entity comes from source, then mark the new
-- entity as needing debug information, even though it's defined
-- by a generated renaming that does not come from source, so that
-- the Materialize_Entity flag will be set on the entity when
-- Debug_Renaming_Declaration is called during analysis.
if Comes_From_Source (Obj_Def_Id) then
Set_Debug_Info_Needed (Defining_Identifier (Obj_Decl));
end if;
Analyze (Obj_Decl);
Replace_Renaming_Declaration_Id
(Obj_Decl, Original_Node (Obj_Decl));
end if;
pragma Assert (Check_Number_Of_Actuals (Func_Call, Function_Id));
pragma Assert (Check_BIP_Actuals (Func_Call, Function_Id));
end Make_Build_In_Place_Call_In_Object_Declaration;
-------------------------------------------------
-- Make_Build_In_Place_Iface_Call_In_Allocator --
-------------------------------------------------
procedure Make_Build_In_Place_Iface_Call_In_Allocator
(Allocator : Node_Id;
Function_Call : Node_Id)
is
BIP_Func_Call : constant Node_Id :=
Unqual_BIP_Iface_Function_Call (Function_Call);
Loc : constant Source_Ptr := Sloc (Function_Call);
Anon_Type : Entity_Id;
Tmp_Decl : Node_Id;
Tmp_Id : Entity_Id;
begin
-- No action of the call has already been processed
if Is_Expanded_Build_In_Place_Call (BIP_Func_Call) then
return;
end if;
Tmp_Id := Make_Temporary (Loc, 'D');
-- Insert a temporary before N initialized with the BIP function call
-- without its enclosing type conversions and analyze it without its
-- expansion. This temporary facilitates us reusing the BIP machinery,
-- which takes care of adding the extra build-in-place actuals and
-- transforms this object declaration into an object renaming
-- declaration.
Anon_Type := Create_Itype (E_Anonymous_Access_Type, Function_Call);
Set_Directly_Designated_Type (Anon_Type, Etype (BIP_Func_Call));
Set_Etype (Anon_Type, Anon_Type);
Build_Class_Wide_Master (Anon_Type);
Tmp_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Tmp_Id,
Object_Definition => New_Occurrence_Of (Anon_Type, Loc),
Expression =>
Make_Allocator (Loc,
Expression =>
Make_Qualified_Expression (Loc,
Subtype_Mark =>
New_Occurrence_Of (Etype (BIP_Func_Call), Loc),
Expression => New_Copy_Tree (BIP_Func_Call))));
-- Manually set the associated node for the anonymous access type to
-- be its local declaration, to avoid confusing and complicating
-- the accessibility machinery.
Set_Associated_Node_For_Itype (Anon_Type, Tmp_Decl);
Expander_Mode_Save_And_Set (False);
Insert_Action (Allocator, Tmp_Decl);
Expander_Mode_Restore;
Make_Build_In_Place_Call_In_Allocator
(Allocator => Expression (Tmp_Decl),
Function_Call => Expression (Expression (Tmp_Decl)));
-- Add a conversion to displace the pointer to the allocated object
-- to reference the corresponding dispatch table.
Rewrite (Allocator,
Convert_To (Etype (Allocator),
New_Occurrence_Of (Tmp_Id, Loc)));
end Make_Build_In_Place_Iface_Call_In_Allocator;
---------------------------------------------------------
-- Make_Build_In_Place_Iface_Call_In_Anonymous_Context --
---------------------------------------------------------
procedure Make_Build_In_Place_Iface_Call_In_Anonymous_Context
(Function_Call : Node_Id)
is
BIP_Func_Call : constant Node_Id :=
Unqual_BIP_Iface_Function_Call (Function_Call);
Loc : constant Source_Ptr := Sloc (Function_Call);
Tmp_Decl : Node_Id;
Tmp_Id : Entity_Id;
begin
-- No action of the call has already been processed
if Is_Expanded_Build_In_Place_Call (BIP_Func_Call) then
return;
end if;
pragma Assert (Needs_Finalization (Etype (BIP_Func_Call)));
-- Insert a temporary before the call initialized with function call to
-- reuse the BIP machinery which takes care of adding the extra build-in
-- place actuals and transforms this object declaration into an object
-- renaming declaration.
Tmp_Id := Make_Temporary (Loc, 'D');
Tmp_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Tmp_Id,
Object_Definition =>
New_Occurrence_Of (Etype (Function_Call), Loc),
Expression => Relocate_Node (Function_Call));
Expander_Mode_Save_And_Set (False);
Insert_Action (Function_Call, Tmp_Decl);
Expander_Mode_Restore;
Make_Build_In_Place_Iface_Call_In_Object_Declaration
(Obj_Decl => Tmp_Decl,
Function_Call => Expression (Tmp_Decl));
end Make_Build_In_Place_Iface_Call_In_Anonymous_Context;
----------------------------------------------------------
-- Make_Build_In_Place_Iface_Call_In_Object_Declaration --
----------------------------------------------------------
procedure Make_Build_In_Place_Iface_Call_In_Object_Declaration
(Obj_Decl : Node_Id;
Function_Call : Node_Id)
is
BIP_Func_Call : constant Node_Id :=
Unqual_BIP_Iface_Function_Call (Function_Call);
Loc : constant Source_Ptr := Sloc (Function_Call);
Obj_Id : constant Entity_Id := Defining_Entity (Obj_Decl);
Tmp_Decl : Node_Id;
Tmp_Id : Entity_Id;
begin
-- No action of the call has already been processed
if Is_Expanded_Build_In_Place_Call (BIP_Func_Call) then
return;
end if;
Tmp_Id := Make_Temporary (Loc, 'D');
-- Insert a temporary before N initialized with the BIP function call
-- without its enclosing type conversions and analyze it without its
-- expansion. This temporary facilitates us reusing the BIP machinery,
-- which takes care of adding the extra build-in-place actuals and
-- transforms this object declaration into an object renaming
-- declaration.
Tmp_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Tmp_Id,
Object_Definition =>
New_Occurrence_Of (Etype (BIP_Func_Call), Loc),
Expression => New_Copy_Tree (BIP_Func_Call));
Expander_Mode_Save_And_Set (False);
Insert_Action (Obj_Decl, Tmp_Decl);
Expander_Mode_Restore;
Make_Build_In_Place_Call_In_Object_Declaration
(Obj_Decl => Tmp_Decl,
Function_Call => Expression (Tmp_Decl));
pragma Assert (Nkind (Tmp_Decl) = N_Object_Renaming_Declaration);
-- Replace the original build-in-place function call by a reference to
-- the resulting temporary object renaming declaration. In this way,
-- all the interface conversions performed in the original Function_Call
-- on the build-in-place object are preserved.
Rewrite (BIP_Func_Call, New_Occurrence_Of (Tmp_Id, Loc));
-- Replace the original object declaration by an internal object
-- renaming declaration. This leaves the generated code more clean (the
-- build-in-place function call in an object renaming declaration and
-- displacements of the pointer to the build-in-place object in another
-- renaming declaration) and allows us to invoke the routine that takes
-- care of replacing the identifier of the renaming declaration (routine
-- originally developed for the regular build-in-place management).
Rewrite (Obj_Decl,
Make_Object_Renaming_Declaration (Loc,
Defining_Identifier => Make_Temporary (Loc, 'D'),
Subtype_Mark => New_Occurrence_Of (Etype (Obj_Id), Loc),
Name => Function_Call));
Analyze (Obj_Decl);
Replace_Renaming_Declaration_Id (Obj_Decl, Original_Node (Obj_Decl));
end Make_Build_In_Place_Iface_Call_In_Object_Declaration;
--------------------------------------------
-- Make_CPP_Constructor_Call_In_Allocator --
--------------------------------------------
procedure Make_CPP_Constructor_Call_In_Allocator
(Allocator : Node_Id;
Function_Call : Node_Id)
is
Loc : constant Source_Ptr := Sloc (Function_Call);
Acc_Type : constant Entity_Id := Etype (Allocator);
Function_Id : constant Entity_Id := Entity (Name (Function_Call));
Result_Subt : constant Entity_Id := Available_View (Etype (Function_Id));
New_Allocator : Node_Id;
Return_Obj_Access : Entity_Id;
Tmp_Obj : Node_Id;
begin
pragma Assert (Nkind (Allocator) = N_Allocator
and then Nkind (Function_Call) = N_Function_Call);
pragma Assert (Convention (Function_Id) = Convention_CPP
and then Is_Constructor (Function_Id));
pragma Assert (Is_Constrained (Underlying_Type (Result_Subt)));
-- Replace the initialized allocator of form "new T'(Func (...))" with
-- an uninitialized allocator of form "new T", where T is the result
-- subtype of the called function. The call to the function is handled
-- separately further below.
New_Allocator :=
Make_Allocator (Loc,
Expression => New_Occurrence_Of (Result_Subt, Loc));
Set_No_Initialization (New_Allocator);
-- Copy attributes to new allocator. Note that the new allocator
-- logically comes from source if the original one did, so copy the
-- relevant flag. This ensures proper treatment of the restriction
-- No_Implicit_Heap_Allocations in this case.
Set_Storage_Pool (New_Allocator, Storage_Pool (Allocator));
Set_Procedure_To_Call (New_Allocator, Procedure_To_Call (Allocator));
Set_Comes_From_Source (New_Allocator, Comes_From_Source (Allocator));
Rewrite (Allocator, New_Allocator);
-- Create a new access object and initialize it to the result of the
-- new uninitialized allocator. Note: we do not use Allocator as the
-- Related_Node of Return_Obj_Access in call to Make_Temporary below
-- as this would create a sort of infinite "recursion".
Return_Obj_Access := Make_Temporary (Loc, 'R');
Set_Etype (Return_Obj_Access, Acc_Type);
-- Generate:
-- Rnnn : constant ptr_T := new (T);
-- Init (Rnn.all,...);
Tmp_Obj :=
Make_Object_Declaration (Loc,
Defining_Identifier => Return_Obj_Access,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (Acc_Type, Loc),
Expression => Relocate_Node (Allocator));
Insert_Action (Allocator, Tmp_Obj);
Insert_List_After_And_Analyze (Tmp_Obj,
Build_Initialization_Call (Loc,
Id_Ref =>
Make_Explicit_Dereference (Loc,
Prefix => New_Occurrence_Of (Return_Obj_Access, Loc)),
Typ => Etype (Function_Id),
Constructor_Ref => Function_Call));
-- Finally, replace the allocator node with a reference to the result of
-- the function call itself (which will effectively be an access to the
-- object created by the allocator).
Rewrite (Allocator, New_Occurrence_Of (Return_Obj_Access, Loc));
-- Ada 2005 (AI-251): If the type of the allocator is an interface then
-- generate an implicit conversion to force displacement of the "this"
-- pointer.
if Is_Interface (Designated_Type (Acc_Type)) then
Rewrite (Allocator, Convert_To (Acc_Type, Relocate_Node (Allocator)));
end if;
Analyze_And_Resolve (Allocator, Acc_Type);
end Make_CPP_Constructor_Call_In_Allocator;
----------------------
-- Might_Have_Tasks --
----------------------
function Might_Have_Tasks (Typ : Entity_Id) return Boolean is
begin
return not Global_No_Tasking
and then not No_Run_Time_Mode
and then (Has_Task (Typ)
or else (Is_Class_Wide_Type (Typ)
and then Is_Limited_Record (Typ)));
end Might_Have_Tasks;
----------------------------
-- Needs_BIP_Task_Actuals --
----------------------------
function Needs_BIP_Task_Actuals (Func_Id : Entity_Id) return Boolean is
pragma Assert (Is_Build_In_Place_Function (Func_Id));
Subp_Id : Entity_Id;
Func_Typ : Entity_Id;
begin
if Global_No_Tasking or else No_Run_Time_Mode then
return False;
end if;
-- For thunks we must rely on their target entity; otherwise, given that
-- the profile of thunks for functions returning a limited interface
-- type returns a class-wide type, we would erroneously add these extra
-- formals.
if Is_Thunk (Func_Id) then
Subp_Id := Thunk_Entity (Func_Id);
-- Common case
else
Subp_Id := Func_Id;
end if;
Func_Typ := Underlying_Type (Etype (Subp_Id));
-- At first sight, for all the following cases, we could add assertions
-- to ensure that if Func_Id is frozen then the computed result matches
-- with the availability of the task master extra formal; unfortunately
-- this is not feasible because we may be precisely freezing this entity
-- (that is, Is_Frozen has been set by Freeze_Entity but it has not
-- completed its work).
if Has_Task (Func_Typ) then
return True;
elsif Ekind (Func_Id) = E_Function then
return Might_Have_Tasks (Func_Typ);
-- Handle subprogram type internally generated for dispatching call. We
-- cannot rely on the return type of the subprogram type of dispatching
-- calls since it is always a class-wide type (cf. Expand_Dispatching_
-- Call).
elsif Ekind (Func_Id) = E_Subprogram_Type then
if Is_Dispatch_Table_Entity (Func_Id) then
return Has_BIP_Extra_Formal (Func_Id, BIP_Task_Master);
else
return Might_Have_Tasks (Func_Typ);
end if;
else
raise Program_Error;
end if;
end Needs_BIP_Task_Actuals;
-----------------------------------
-- Needs_BIP_Finalization_Master --
-----------------------------------
function Needs_BIP_Finalization_Master
(Func_Id : Entity_Id) return Boolean
is
pragma Assert (Is_Build_In_Place_Function (Func_Id));
Func_Typ : constant Entity_Id := Underlying_Type (Etype (Func_Id));
begin
-- A formal giving the finalization master is needed for build-in-place
-- functions whose result type needs finalization or is a tagged type.
-- Tagged primitive build-in-place functions need such a formal because
-- they can be called by a dispatching call, and extensions may require
-- finalization even if the root type doesn't. This means they're also
-- needed for tagged nonprimitive build-in-place functions with tagged
-- results, since such functions can be called via access-to-function
-- types, and those can be used to call primitives, so masters have to
-- be passed to all such build-in-place functions, primitive or not.
return
not Restriction_Active (No_Finalization)
and then (Needs_Finalization (Func_Typ)
or else Is_Tagged_Type (Func_Typ));
end Needs_BIP_Finalization_Master;
--------------------------
-- Needs_BIP_Alloc_Form --
--------------------------
function Needs_BIP_Alloc_Form (Func_Id : Entity_Id) return Boolean is
pragma Assert (Is_Build_In_Place_Function (Func_Id));
Func_Typ : constant Entity_Id := Underlying_Type (Etype (Func_Id));
begin
return Requires_Transient_Scope (Func_Typ);
end Needs_BIP_Alloc_Form;
-------------------------------------
-- Replace_Renaming_Declaration_Id --
-------------------------------------
procedure Replace_Renaming_Declaration_Id
(New_Decl : Node_Id;
Orig_Decl : Node_Id)
is
New_Id : constant Entity_Id := Defining_Entity (New_Decl);
Orig_Id : constant Entity_Id := Defining_Entity (Orig_Decl);
begin
Set_Chars (New_Id, Chars (Orig_Id));
-- Swap next entity links in preparation for exchanging entities
declare
Next_Id : constant Entity_Id := Next_Entity (New_Id);
begin
Link_Entities (New_Id, Next_Entity (Orig_Id));
Link_Entities (Orig_Id, Next_Id);
end;
Set_Homonym (New_Id, Homonym (Orig_Id));
Exchange_Entities (New_Id, Orig_Id);
-- Preserve source indication of original declaration, so that xref
-- information is properly generated for the right entity.
Preserve_Comes_From_Source (New_Decl, Orig_Decl);
Preserve_Comes_From_Source (Orig_Id, Orig_Decl);
Set_Comes_From_Source (New_Id, False);
end Replace_Renaming_Declaration_Id;
---------------------------------
-- Rewrite_Function_Call_For_C --
---------------------------------
procedure Rewrite_Function_Call_For_C (N : Node_Id) is
Orig_Func : constant Entity_Id := Entity (Name (N));
Func_Id : constant Entity_Id := Ultimate_Alias (Orig_Func);
Par : constant Node_Id := Parent (N);
Proc_Id : constant Entity_Id := Corresponding_Procedure (Func_Id);
Loc : constant Source_Ptr := Sloc (Par);
Actuals : List_Id;
Last_Actual : Node_Id;
Last_Formal : Entity_Id;
-- Start of processing for Rewrite_Function_Call_For_C
begin
-- The actuals may be given by named associations, so the added actual
-- that is the target of the return value of the call must be a named
-- association as well, so we retrieve the name of the generated
-- out_formal.
Last_Formal := First_Formal (Proc_Id);
while Present (Next_Formal (Last_Formal)) loop
Next_Formal (Last_Formal);
end loop;
Actuals := Parameter_Associations (N);
-- The original function may lack parameters
if No (Actuals) then
Actuals := New_List;
end if;
-- If the function call is the expression of an assignment statement,
-- transform the assignment into a procedure call. Generate:
-- LHS := Func_Call (...);
-- Proc_Call (..., LHS);
-- If function is inherited, a conversion may be necessary.
if Nkind (Par) = N_Assignment_Statement then
Last_Actual := Name (Par);
if not Comes_From_Source (Orig_Func)
and then Etype (Orig_Func) /= Etype (Func_Id)
then
Last_Actual :=
Make_Type_Conversion (Loc,
New_Occurrence_Of (Etype (Func_Id), Loc),
Last_Actual);
end if;
Append_To (Actuals,
Make_Parameter_Association (Loc,
Selector_Name =>
Make_Identifier (Loc, Chars (Last_Formal)),
Explicit_Actual_Parameter => Last_Actual));
Rewrite (Par,
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Proc_Id, Loc),
Parameter_Associations => Actuals));
Analyze (Par);
-- Otherwise the context is an expression. Generate a temporary and a
-- procedure call to obtain the function result. Generate:
-- ... Func_Call (...) ...
-- Temp : ...;
-- Proc_Call (..., Temp);
-- ... Temp ...
else
declare
Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'T');
Call : Node_Id;
Decl : Node_Id;
begin
-- Generate:
-- Temp : ...;
Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Temp_Id,
Object_Definition =>
New_Occurrence_Of (Etype (Func_Id), Loc));
-- Generate:
-- Proc_Call (..., Temp);
Append_To (Actuals,
Make_Parameter_Association (Loc,
Selector_Name =>
Make_Identifier (Loc, Chars (Last_Formal)),
Explicit_Actual_Parameter =>
New_Occurrence_Of (Temp_Id, Loc)));
Call :=
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Proc_Id, Loc),
Parameter_Associations => Actuals);
Insert_Actions (Par, New_List (Decl, Call));
Rewrite (N, New_Occurrence_Of (Temp_Id, Loc));
end;
end if;
end Rewrite_Function_Call_For_C;
------------------------------------
-- Set_Enclosing_Sec_Stack_Return --
------------------------------------
procedure Set_Enclosing_Sec_Stack_Return (N : Node_Id) is
P : Node_Id := N;
begin
-- Due to a possible mix of internally generated blocks, source blocks
-- and loops, the scope stack may not be contiguous as all labels are
-- inserted at the top level within the related function. Instead,
-- perform a parent-based traversal and mark all appropriate constructs.
while Present (P) loop
-- Mark the label of a source or internally generated block or
-- loop.
if Nkind (P) in N_Block_Statement | N_Loop_Statement then
Set_Sec_Stack_Needed_For_Return (Entity (Identifier (P)));
-- Mark the enclosing function
elsif Nkind (P) = N_Subprogram_Body then
if Present (Corresponding_Spec (P)) then
Set_Sec_Stack_Needed_For_Return (Corresponding_Spec (P));
else
Set_Sec_Stack_Needed_For_Return (Defining_Entity (P));
end if;
-- Do not go beyond the enclosing function
exit;
end if;
P := Parent (P);
end loop;
end Set_Enclosing_Sec_Stack_Return;
------------------------------------
-- Unqual_BIP_Iface_Function_Call --
------------------------------------
function Unqual_BIP_Iface_Function_Call (Expr : Node_Id) return Node_Id is
Has_Pointer_Displacement : Boolean := False;
On_Object_Declaration : Boolean := False;
-- Remember if processing the renaming expressions on recursion we have
-- traversed an object declaration, since we can traverse many object
-- declaration renamings but just one regular object declaration.
function Unqual_BIP_Function_Call (Expr : Node_Id) return Node_Id;
-- Search for a build-in-place function call skipping any qualification
-- including qualified expressions, type conversions, references, calls
-- to displace the pointer to the object, and renamings. Return Empty if
-- no build-in-place function call is found.
------------------------------
-- Unqual_BIP_Function_Call --
------------------------------
function Unqual_BIP_Function_Call (Expr : Node_Id) return Node_Id is
begin
-- Recurse to handle case of multiple levels of qualification and/or
-- conversion.
if Nkind (Expr) in N_Qualified_Expression
| N_Type_Conversion
| N_Unchecked_Type_Conversion
then
return Unqual_BIP_Function_Call (Expression (Expr));
-- Recurse to handle case of multiple levels of references and
-- explicit dereferences.
elsif Nkind (Expr) in N_Attribute_Reference
| N_Explicit_Dereference
| N_Reference
then
return Unqual_BIP_Function_Call (Prefix (Expr));
-- Recurse on object renamings
elsif Nkind (Expr) = N_Identifier
and then Present (Entity (Expr))
and then Ekind (Entity (Expr)) in E_Constant | E_Variable
and then Nkind (Parent (Entity (Expr))) =
N_Object_Renaming_Declaration
and then Present (Renamed_Object (Entity (Expr)))
then
return Unqual_BIP_Function_Call (Renamed_Object (Entity (Expr)));
-- Recurse on the initializing expression of the first reference of
-- an object declaration.
elsif not On_Object_Declaration
and then Nkind (Expr) = N_Identifier
and then Present (Entity (Expr))
and then Ekind (Entity (Expr)) in E_Constant | E_Variable
and then Nkind (Parent (Entity (Expr))) = N_Object_Declaration
and then Present (Expression (Parent (Entity (Expr))))
then
On_Object_Declaration := True;
return
Unqual_BIP_Function_Call (Expression (Parent (Entity (Expr))));
-- Recurse to handle calls to displace the pointer to the object to
-- reference a secondary dispatch table.
elsif Nkind (Expr) = N_Function_Call
and then Nkind (Name (Expr)) in N_Has_Entity
and then Present (Entity (Name (Expr)))
and then RTU_Loaded (Ada_Tags)
and then RTE_Available (RE_Displace)
and then Is_RTE (Entity (Name (Expr)), RE_Displace)
then
Has_Pointer_Displacement := True;
return
Unqual_BIP_Function_Call (First (Parameter_Associations (Expr)));
-- Normal case: check if the inner expression is a BIP function call
-- and the pointer to the object is displaced.
elsif Has_Pointer_Displacement
and then Is_Build_In_Place_Function_Call (Expr)
then
return Expr;
else
return Empty;
end if;
end Unqual_BIP_Function_Call;
-- Start of processing for Unqual_BIP_Iface_Function_Call
begin
if Nkind (Expr) = N_Identifier and then No (Entity (Expr)) then
-- Can happen for X'Elab_Spec in the binder-generated file
return Empty;
end if;
return Unqual_BIP_Function_Call (Expr);
end Unqual_BIP_Iface_Function_Call;
--------------
-- Warn_BIP --
--------------
procedure Warn_BIP (Func_Call : Node_Id) is
begin
if Debug_Flag_Underscore_BB then
Error_Msg_N ("build-in-place function call?", Func_Call);
end if;
end Warn_BIP;
end Exp_Ch6;
|
libsrc/_DEVELOPMENT/math/float/math48/lm/z80/asm_double64u.asm | jpoikela/z88dk | 640 | 97616 | <filename>libsrc/_DEVELOPMENT/math/float/math48/lm/z80/asm_double64u.asm
SECTION code_clib
SECTION code_fp_math48
PUBLIC asm_double64u
EXTERN am48_double64u
defc asm_double64u = am48_double64u
|
lib/nucleus.asm | neilsf/TinyBasic64 | 4 | 90792 | <filename>lib/nucleus.asm
reserved0 EQU $fb
reserved1 EQU $fc
reserved2 EQU $fd
reserved3 EQU $fe
reserved4 EQU $02
reserved5 EQU $03
reserved6 EQU $04
reserved7 EQU $05
reserved8 EQU $06
reserved9 EQU $07
stack EQU $0100
PROCESSOR 6502
; Push a zero on the stack
; EXAMINE REFS BEFORE CHANGING!
MAC pzero
lda #$00
pha
ENDM
; Push a one on the stack
; EXAMINE REFS BEFORE CHANGING!
MAC pone
lda #$01
pha
ENDM
; Push one byte on the stack
MAC pbyte
lda {1}
pha
ENDM
; Push byte war on the stack
MAC pbvar
pbyte {1}
ENDM
; Push one byte as a word on the stack
MAC pbyteasw
lda {1}
pha
lda #$00
pha
ENDM
; Push one word on the stack
MAC pword
lda #<{1}
pha
lda #>{1}
pha
ENDM
; Push one word variable on the stack
MAC pwvar
lda.w {1}
pha
lda.w {1}+1
pha
ENDM
MAC psvar
pwvar {1}
ENDM
; Push address on stack
MAC paddr
pword {1}
ENDM
; Pull byte to variable
MAC plb2var
pla
sta {1}
ENDM
; Pull word to variable
MAC plw2var
pla
sta {1}+1
pla
sta {1}
ENDM
; Compare two bytes on stack for less than
MAC cmpblt
pla
sta reserved1
pla
cmp reserved1
bcs .phf
pone
jmp *+6
.phf: pzero
ENDM
; Compare two bytes on stack for less than or equal
MAC cmpblte
pla
sta reserved1
pla
cmp reserved1
bcc .pht
beq .pht
pzero
jmp *+6
.pht: pone
ENDM
; Compare two bytes on stack for greater than or equal
MAC cmpbgte
pla
sta reserved1
pla
cmp reserved1
bcs .pht
pzero
jmp *+6
.pht: pone
ENDM
; Compare two bytes on stack for equality
MAC cmpbeq
pla
sta reserved1
pla
cmp reserved1
beq .pht
pzero
jmp *+6
.pht: pone
ENDM
; Compare two bytes on stack for inequality
MAC cmpbneq
pla
sta reserved1
pla
cmp reserved1
bne .pht
pzero
jmp *+6
.pht: pone
ENDM
; Compare two bytes on stack for greater than
MAC cmpbgt
pla
sta reserved1
pla
cmp reserved1
bcc .phf
beq .phf
pone
jmp *+6
.phf: pzero
ENDM
; Compare two words on stack for equality
MAC cmpweq
pla
sta reserved1
pla
sta reserved2
pla
cmp reserved1
bne .phf
pla
cmp reserved2
bne .phf+1
pone
jmp *+7
.phf: pla
pzero
ENDM
; Compare two words on stack for inequality
MAC cmpwneq
pla
sta reserved1
pla
sta reserved2
pla
cmp reserved1
bne .pht
pla
cmp reserved2
bne .pht+1
pzero
jmp *+7
.pht: pla
pone
ENDM
; Compare two words on stack for less than (Higher on stack < Lower on stack)
; unsigned version
MAC cmpuwlt
tsx
lda.wx stack+4
cmp.wx stack+2
lda.wx stack+3
sbc.wx stack+1
bcs .phf
inx
inx
inx
inx
txs
pone
jmp *+11
.phf: inx
inx
inx
inx
txs
pzero
ENDM
; Compare two words on stack for less than (Higher on stack < Lower on stack)
; signed version
MAC cmpwlt
tsx
lda.wx stack+4
cmp.wx stack+2
lda.wx stack+3
sbc.wx stack+1
bpl .phf
inx
inx
inx
inx
txs
pone
jmp *+11
.phf: inx
inx
inx
inx
txs
pzero
ENDM
; Compare two words on stack for greater than or equal (H >= L)
; Unsigned version
MAC cmpuwgte
tsx
lda.wx stack+4
cmp.wx stack+2
lda.wx stack+3
sbc.wx stack+1
bcs .pht
inx
inx
inx
inx
txs
pzero
jmp *+11
.pht: inx
inx
inx
inx
txs
pone
ENDM
; Compare two words on stack for greater than or equal (H >= L)
; Signed version
MAC cmpwgte
tsx
lda.wx stack+4
cmp.wx stack+2
lda.wx stack+3
sbc.wx stack+1
bpl .pht
inx
inx
inx
inx
txs
pzero
jmp *+11
.pht: inx
inx
inx
inx
txs
pone
ENDM
; Compare two words on stack for greater than (H > L)
; unsigned version
MAC cmpuwgt
tsx
lda.wx stack+2
cmp.wx stack+4
lda.wx stack+1
sbc.wx stack+3
bcc .pht
inx
inx
inx
inx
txs
pzero
jmp *+11
.pht: inx
inx
inx
inx
txs
pone
ENDM
; Compare two words on stack for greater than (H > L)
; signed version
MAC cmpwgt
tsx
lda.wx stack+2
cmp.wx stack+4
lda.wx stack+1
sbc.wx stack+3
bmi .pht
inx
inx
inx
inx
txs
pzero
jmp *+11
.pht: inx
inx
inx
inx
txs
pone
ENDM
; Compare two words on stack for less than or equals (H <= L)
; signed version
MAC cmpwlte
tsx
lda.wx stack+2
cmp.wx stack+4
lda.wx stack+1
sbc.wx stack+3
bmi .phf
inx
inx
inx
inx
txs
pone
jmp *+11
.phf: inx
inx
inx
inx
txs
pzero
ENDM
; Add bytes on stack
MAC addb
pla
tsx
clc
adc.wx stack+1
sta.wx stack+1
ENDM
; Add words on stack
MAC addw
tsx
lda.wx stack+2
clc
adc.wx stack+4
sta.wx stack+4
pla
adc.wx stack+3
sta.wx stack+3
pla
ENDM
; Substract bytes on stack
MAC subb
tsx
lda.wx stack+2
sec
sbc.wx stack+1
sta.wx stack+2
pla
ENDM
; Substract words on stack
MAC subw
tsx
lda.wx stack+4
sec
sbc.wx stack+2
sta.wx stack+4
lda.wx stack+3
sbc.wx stack+1
sta.wx stack+3
inx
inx
txs
ENDM
; Multiply bytes on stack
; by <NAME> 20030207
MAC mulb
pla
sta reserved1
pla
sta reserved2
lda #$00
beq .enterLoop
.doAdd:
clc
adc reserved1
.loop:
asl reserved1
.enterLoop:
lsr reserved2
bcs .doAdd
bne .loop
.end:
pha
ENDM
MAC twoscomplement
lda {1}+1
eor #$ff
sta {1}+1
lda {1}
eor #$ff
clc
adc #$01
sta {1}
ENDM
; Signed 16-bit multiplication
NUCL_SMUL16
ldy #$00 ; .y will hold the sign of product
lda reserved1
bpl .skip ; if factor1 is negative
twoscomplement reserved0 ; then factor1 := -factor1
iny ; and switch sign
.skip
lda reserved3
bpl .skip2 ; if factor2 is negative
twoscomplement reserved2 ; then factor2 := -factor2
iny ; and switch sign
.skip2
jsr NUCL_MUL16 ; do unsigned multiplication
tya
and #$01 ; if .x is odd
beq .q
twoscomplement reserved0 ; then product := -product
.q rts
;Multiply words at reserved0 and reserved2, with 16-bit result at reserved0
;and 16-bit overflow at reserved5
NUCL_MUL16 SUBROUTINE
ldx #$11
lda #$00
sta reserved5
clc
.1: ror
ror reserved5
ror reserved1
ror reserved0
dex
beq .q
bcc .1
sta reserved6
lda reserved5
clc
adc reserved2
sta reserved5
lda reserved6
adc reserved3
jmp .1
.q: sta reserved6
rts
; Multiply words on stack
MAC mulw
pla
sta reserved1
pla
sta reserved0
pla
sta reserved3
pla
sta reserved2
jsr NUCL_SMUL16
lda reserved0
pha
lda reserved1
pha
ENDM
; 8 bit division routine
; submitted by Graham at CSDb forum
NUCL_DIV8 SUBROUTINE
asl reserved0
lda #$00
rol
ldx #$08
.loop1
cmp reserved1
bcc *+4
sbc reserved1
rol reserved0
rol
dex
bne .loop1
ldx #$08
.loop2
cmp reserved1
bcc *+4
sbc reserved1
rol reserved2
asl
dex
bne .loop2
rts
; Divide two bytes on stack
MAC divb
pla
sta reserved1
pla
sta reserved0
jsr NUCL_DIV8
lda reserved0
pha
ENDM
; Invert true/false value on top byte of stack
MAC notbool
pla
beq .skip
pzero
jmp *+6
.skip:
pone
ENDM
; Negate byte on stack (return twos complement)
MAC negbyte
pla
eor #$FF
clc
adc #$01
pha
ENDM
; Negate word on stack (return twos complement)
MAC negw
tsx
lda.wx stack+1
eor #$ff
sta.wx stack+1
lda.wx stack+2
eor #$ff
clc
adc #$01
sta.wx stack+2
bcc *+5
inc.wx stack+1
ENDM
; TODO
; Negate int on stack
MAC negint
tsx
lda.wx stack+1
eor #$ff
sta.wx stack+1
lda.wx stack+2
eor #$ff
clc
adc #$01
sta.wx stack+2
bcc *+5
inc.wx stack+1
ENDM
; Divide integers on stack
MAC divw
lda reserved0
bne .ok
lda reserved1
bne .ok
lda #<err_divzero
pha
lda #>err_divzero
pha
jmp RUNTIME_ERROR
.ok
plw2var reserved0
plw2var reserved2
jsr NUCL_DIV16
pwvar reserved2
ENDM
NUCL_DIV16 SUBROUTINE
ldx #$00
lda reserved2+1
bpl .skip
twoscomplement reserved2
inx
.skip
lda reserved0+1
bpl .skip2
twoscomplement reserved0
inx
.skip2
txa
pha
jsr NUCL_DIVU16
pla
and #$01
beq .q
twoscomplement reserved2
.q rts
; 16 bit division routine
; Author: unknown
NUCL_DIVU16 SUBROUTINE
.divisor EQU reserved0
.dividend EQU reserved2
.remainder EQU reserved4
.result EQU .dividend ; save memory by reusing divident to store the result
lda #0 ;preset remainder to 0
sta .remainder
sta .remainder+1
ldx #16 ;repeat for each bit: ...
.divloop:
asl .dividend ;dividend lb & hb*2, msb -> Carry
rol .dividend+1
rol .remainder ;remainder lb & hb * 2 + msb from carry
rol .remainder+1
lda .remainder
sec
sbc .divisor ;substract divisor to see if it fits in
tay ;lb result -> Y, for we may need it later
lda .remainder+1
sbc .divisor+1
bcc .skip ;if carry=0 then divisor didn't fit in yet
sta .remainder+1 ;else save substraction result as new remainder,
sty .remainder
inc .result ;and INCrement result cause divisor fit in 1 times
.skip:
dex
bne .divloop
rts
; poke routine
; requires that arguments are pushed backwards (value first)
MAC poke
pla
sta reserved1
pla
sta reserved0
ldy #$00
pla ;discard high byte
pla
sta (reserved0),y
ENDM
MAC peek
pla
sta reserved1
pla
sta reserved0
ldy #$00
lda (reserved0),y
pha
pzero
ENDM
; init program: save stack pointer
MAC init_program
tsx
stx RESERVED_STACK_POINTER
ENDM
; end program: restorre stack pointer and exit
MAC halt
ldx RESERVED_STACK_POINTER
txs
rts
ENDM
err_divzero HEX 44 49 56 49 53 49 4F 4E 20 42 59 20 5A 45 52 4F 00
RUNTIME_ERROR SUBROUTINE
pla
tay
pla
jsr STDLIB_PRINT
halt
|
data/jpred4/jp_batch_1613899824__V8Rd0eV/jp_batch_1613899824__V8Rd0eV.als | jonriege/predict-protein-structure | 0 | 2993 | <filename>data/jpred4/jp_batch_1613899824__V8Rd0eV/jp_batch_1613899824__V8Rd0eV.als
SILENT_MODE
BLOCK_FILE jp_batch_1613899824__V8Rd0eV.concise.blc
MAX_NSEQ 836
MAX_INPUT_LEN 838
OUTPUT_FILE jp_batch_1613899824__V8Rd0eV.concise.ps
PORTRAIT
POINTSIZE 8
IDENT_WIDTH 12
X_OFFSET 2
Y_OFFSET 2
DEFINE_FONT 0 Helvetica DEFAULT
DEFINE_FONT 1 Helvetica REL 0.75
DEFINE_FONT 7 Helvetica REL 0.6
DEFINE_FONT 3 Helvetica-Bold DEFAULT
DEFINE_FONT 4 Times-Bold DEFAULT
DEFINE_FONT 5 Helvetica-BoldOblique DEFAULT
#
DEFINE_COLOUR 3 1 0.62 0.67 # Turquiose
DEFINE_COLOUR 4 1 1 0 # Yellow
DEFINE_COLOUR 5 1 0 0 # Red
DEFINE_COLOUR 7 1 0 1 # Purple
DEFINE_COLOUR 8 0 0 1 # Blue
DEFINE_COLOUR 9 0 1 0 # Green
DEFINE_COLOUR 10 0.41 0.64 1.00 # Pale blue
DEFINE_COLOUR 11 0.41 0.82 0.67 # Pale green
DEFINE_COLOUR 50 0.69 0.18 0.37 # Pink (helix)
DEFINE_COLOUR 51 1.00 0.89 0.00 # Gold (strand)
NUMBER_INT 10
SETUP
#
# Highlight specific residues.
# Avoid highlighting Lupas 'C' predictions by
# limiting the highlighting to the alignments
Scol_CHARS C 1 1 85 825 4
Ccol_CHARS H ALL 5
Ccol_CHARS P ALL 8
SURROUND_CHARS LIV ALL
#
# Replace known structure types with whitespace
SUB_CHARS 1 826 85 835 H SPACE
SUB_CHARS 1 826 85 835 E SPACE
SUB_CHARS 1 826 85 835 - SPACE
STRAND 19 829 24
COLOUR_TEXT_REGION 19 829 24 829 51
STRAND 27 829 28
COLOUR_TEXT_REGION 27 829 28 829 51
STRAND 75 829 77
COLOUR_TEXT_REGION 75 829 77 829 51
HELIX 6 829 13
COLOUR_TEXT_REGION 6 829 13 829 50
HELIX 31 829 34
COLOUR_TEXT_REGION 31 829 34 829 50
HELIX 41 829 47
COLOUR_TEXT_REGION 41 829 47 829 50
HELIX 52 829 58
COLOUR_TEXT_REGION 52 829 58 829 50
HELIX 63 829 70
COLOUR_TEXT_REGION 63 829 70 829 50
STRAND 5 834 5
COLOUR_TEXT_REGION 5 834 5 834 51
STRAND 19 834 23
COLOUR_TEXT_REGION 19 834 23 834 51
STRAND 27 834 28
COLOUR_TEXT_REGION 27 834 28 834 51
STRAND 74 834 77
COLOUR_TEXT_REGION 74 834 77 834 51
HELIX 6 834 13
COLOUR_TEXT_REGION 6 834 13 834 50
HELIX 41 834 47
COLOUR_TEXT_REGION 41 834 47 834 50
HELIX 52 834 58
COLOUR_TEXT_REGION 52 834 58 834 50
HELIX 63 834 69
COLOUR_TEXT_REGION 63 834 69 834 50
STRAND 20 835 24
COLOUR_TEXT_REGION 20 835 24 835 51
STRAND 27 835 27
COLOUR_TEXT_REGION 27 835 27 835 51
STRAND 75 835 77
COLOUR_TEXT_REGION 75 835 77 835 51
HELIX 7 835 13
COLOUR_TEXT_REGION 7 835 13 835 50
HELIX 31 835 34
COLOUR_TEXT_REGION 31 835 34 835 50
HELIX 52 835 57
COLOUR_TEXT_REGION 52 835 57 835 50
HELIX 63 835 71
COLOUR_TEXT_REGION 63 835 71 835 50
|
tests/syntax/bad/testfile-params-4.adb | xuedong/mini-ada | 0 | 1793 | <reponame>xuedong/mini-ada<filename>tests/syntax/bad/testfile-params-4.adb
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
procedure P(:integer) is begin x := 0; end;
begin P(0); end;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/lto1_pkg.adb | best08618/asylo | 7 | 9776 | package body Lto1_Pkg is
procedure Initialize (Radar : in Radar_T) is
Antenna1 : Antenna_Type_T;
Antenna2 : Antenna_Type_T;
begin
case Radar.Sensor_Type is
when radpr | radssr =>
Antenna1 := Radar.Sensor_Type;
Antenna2 := Radar.Sensor_Type;
when radcmb =>
Antenna1 := radpr;
Antenna2 := radssr;
when others =>
Antenna1 := radpr;
Antenna2 := radssr;
end case;
if Antenna1 /= radpr or Antenna2 /= radssr then
raise Program_Error;
end if;
end Initialize;
end Lto1_Pkg;
|
examples/shared/common/gui/bitmapped_drawing.adb | WickedShell/Ada_Drivers_Library | 6 | 7215 | <gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Bitmap_Color_Conversion; use Bitmap_Color_Conversion;
package body Bitmapped_Drawing is
---------------
-- Draw_Char --
---------------
procedure Draw_Char
(Buffer : in out Bitmap_Buffer'Class;
Start : Point;
Char : Character;
Font : BMP_Font;
Foreground : UInt32;
Background : UInt32)
is
begin
for H in 0 .. Char_Height (Font) - 1 loop
for W in 0 .. Char_Width (Font) - 1 loop
if (Data (Font, Char, H) and Mask (Font, W)) /= 0 then
Buffer.Set_Source (Word_To_Bitmap_Color (Buffer.Color_Mode, Foreground));
Buffer.Set_Pixel ((Start.X + W, Start.Y + H));
else
Buffer.Set_Source (Word_To_Bitmap_Color (Buffer.Color_Mode, Background));
Buffer.Set_Pixel ((Start.X + W, Start.Y + H));
end if;
end loop;
end loop;
end Draw_Char;
-----------------
-- Draw_String --
-----------------
procedure Draw_String
(Buffer : in out Bitmap_Buffer'Class;
Start : Point;
Msg : String;
Font : BMP_Font;
Foreground : Bitmap_Color;
Background : Bitmap_Color)
is
Count : Natural := 0;
FG : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Foreground);
BG : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Background);
begin
for C of Msg loop
exit when Start.X + Count * Char_Width (Font) > Buffer.Width;
Draw_Char
(Buffer,
(Start.X + Count * Char_Width (Font), Start.Y),
C,
Font,
FG,
BG);
Count := Count + 1;
end loop;
end Draw_String;
-----------------
-- Draw_String --
-----------------
procedure Draw_String
(Buffer : in out Bitmap_Buffer'Class;
Start : Point;
Msg : String;
Font : Hershey_Font;
Height : Natural;
Bold : Boolean;
Foreground : Bitmap_Color;
Fast : Boolean := True)
is
procedure Internal_Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive);
procedure Internal_Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive)
is
begin
Draw_Line (Buffer,
(X0, Y0),
(X1, Y1),
Width,
Fast => Fast);
end Internal_Draw_Line;
procedure Draw_Glyph is new Hershey_Fonts.Draw_Glyph
(Internal_Draw_Line);
Current : Point := Start;
begin
Buffer.Set_Source (Foreground);
for C of Msg loop
exit when Current.X > Buffer.Width;
Draw_Glyph
(Fnt => Font,
C => C,
X => Current.X,
Y => Current.Y,
Height => Height,
Bold => Bold);
end loop;
end Draw_String;
-----------------
-- Draw_String --
-----------------
procedure Draw_String
(Buffer : in out Bitmap_Buffer'Class;
Area : Rect;
Msg : String;
Font : Hershey_Font;
Bold : Boolean;
Outline : Boolean;
Foreground : Bitmap_Color;
Fast : Boolean := True)
is
Length : constant Natural :=
Hershey_Fonts.Strlen (Msg, Font, Area.Height);
Ratio : Float;
Current : Point := (0, 0);
Prev : UInt32;
FG : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Foreground);
Blk : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Black);
procedure Internal_Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive);
procedure Internal_Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive)
is
begin
Draw_Line (Buffer,
(Area.Position.X + Natural (Float (X0) * Ratio),
Area.Position.Y + Y0),
(Area.Position.X + Natural (Float (X1) * Ratio),
Area.Position.Y + Y1),
Width,
Fast);
end Internal_Draw_Line;
procedure Draw_Glyph is new Hershey_Fonts.Draw_Glyph
(Internal_Draw_Line);
begin
if Length > Area.Width then
Ratio := Float (Area.Width) / Float (Length);
else
Ratio := 1.0;
Current.X := (Area.Width - Length) / 2;
end if;
Buffer.Set_Source (Foreground);
for C of Msg loop
Draw_Glyph
(Fnt => Font,
C => C,
X => Current.X,
Y => Current.Y,
Height => Area.Height,
Bold => Bold);
end loop;
if Outline and then Area.Height > 40 then
for Y in Area.Position.Y + 1 .. Area.Position.Y + Area.Height loop
Prev := Buffer.Pixel ((Area.Position.X, Y));
if Prev = FG then
Buffer.Set_Pixel ((Area.Position.X, Y), Black);
end if;
for X in Area.Position.X + 1 .. Area.Position.X + Area.Width loop
declare
Col : constant UInt32 := Buffer.Pixel ((X, Y));
Top : constant UInt32 := Buffer.Pixel ((X, Y - 1));
begin
if Prev /= FG
and then Col = FG
then
Buffer.Set_Pixel ((X, Y), Blk);
elsif Prev = FG
and then Col /= FG
then
Buffer.Set_Pixel ((X - 1, Y), Blk);
elsif Top /= FG
and then Top /= Blk
and then Col = FG
then
Buffer.Set_Pixel ((X, Y), Blk);
elsif Top = FG
and then Col /= FG
then
Buffer.Set_Pixel ((X, Y - 1), Blk);
end if;
Prev := Col;
end;
end loop;
end loop;
end if;
end Draw_String;
end Bitmapped_Drawing;
|
collision.asm | laerreal/flyshooter | 0 | 246587 | ; push 1 - адрес
; push 2 - адрес
collision:
push bp
mov bp,sp
push bx
mov bx,[bp+4]
mov ax,[bx+12]
mov bx,[bp+6]
cmp ax,[bx+12]
pushf
xor ax,ax
popf
je collision_end
mov ax,[bx]
mov [_xp],ax
mov [_xm],ax
mov ax,[bx+2]
mov [_yp],ax
mov [_ym],ax
mov bx,[bx+10]
mov ax,[bx]
shl ax,2
add ax,[bx]
shl ax,1
add ax,2
add bx,ax
mov ax,[bx]
add [_xp],ax
sub [_xm],ax
mov ax,[bx+2]
add [_yp],ax
sub [_ym],ax
mov bx,[bp+4]
mov bx,[bx+10]
mov ax,[bx]
shl ax,2
add ax,[bx]
shl ax,1
add ax,2
add bx,ax
mov ax,[bx]
add [_xp],ax
sub [_xm],ax
mov ax,[bx+2]
add [_yp],ax
sub [_ym],ax
xor ax,ax
mov bx,[bp+4]
mov cx,[bx]
cmp cx,[_xm]
jl collision_end
cmp cx,[_xp]
jg collision_end
mov cx,[bx+2]
cmp cx,[_ym]
jl collision_end
cmp cx,[_yp]
jg collision_end
inc ax
collision_end:
pop bx
mov sp,bp
pop bp
retn 4
_xp dw 12
_xm dw 14
_yp dw 3
_ym dw 8
|
oeis/089/A089033.asm | neoneye/loda-programs | 11 | 6128 | <gh_stars>10-100
; A089033: Numbers n such that 7*n+3 is prime.
; Submitted by <NAME>(s4)
; 0,2,4,8,10,14,22,28,32,34,38,40,44,50,52,58,68,74,80,82,88,92,94,110,112,118,122,134,140,142,148,158,160,164,170,178,182,184,188,194,208,212,220,224,230,232,238,242,250,260,268,272,278,298,304,320,334,340,344,352,364,368,370,374,380,382,388,398,400,412,422,424,428,434,440,452,454,458,464,472,484,490,494,502,508,520,524,532,538,542,550,554,560,572,574,578,584,590,602,604
mov $1,2
mov $2,$0
pow $2,2
lpb $2
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,14
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,1
lpe
mov $0,$1
div $0,7
|
Transynther/x86/_processed/NONE/_st_/i7-7700_9_0xca_notsx.log_84_1734.asm | ljhsiun2/medusa | 9 | 20747 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1828d, %rsi
lea addresses_normal_ht+0x743f, %rdi
clflush (%rdi)
nop
nop
and $46273, %r10
mov $32, %rcx
rep movsw
xor $55155, %rbp
lea addresses_D_ht+0x1cae9, %rcx
nop
nop
nop
nop
nop
sub $7912, %r14
mov (%rcx), %r10d
nop
nop
xor $29590, %rdi
lea addresses_normal_ht+0x13371, %r14
add $45928, %r11
mov $0x6162636465666768, %r10
movq %r10, (%r14)
nop
nop
nop
inc %r14
lea addresses_WT_ht+0x4189, %r11
nop
nop
add $49898, %rcx
and $0xffffffffffffffc0, %r11
movaps (%r11), %xmm3
vpextrq $1, %xmm3, %rbp
xor %rcx, %rcx
lea addresses_normal_ht+0x17a89, %rcx
clflush (%rcx)
cmp $31214, %rbp
movb (%rcx), %r14b
nop
nop
dec %rcx
lea addresses_normal_ht+0x673b, %r11
nop
nop
nop
nop
nop
inc %r14
movw $0x6162, (%r11)
nop
nop
nop
and %rdi, %rdi
lea addresses_normal_ht+0x3089, %rbp
nop
nop
nop
nop
xor %rdi, %rdi
vmovups (%rbp), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %rcx
nop
nop
nop
nop
inc %rbp
lea addresses_WT_ht+0x789, %rcx
nop
nop
nop
add %rbp, %rbp
mov (%rcx), %r10d
nop
nop
nop
nop
and $917, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_UC+0x1af62, %r13
nop
nop
cmp $39854, %rdx
movb $0x51, (%r13)
nop
and $41301, %r13
// Store
lea addresses_normal+0xf721, %rax
nop
lfence
mov $0x5152535455565758, %r15
movq %r15, (%rax)
nop
nop
nop
nop
nop
cmp $42681, %rbx
// REPMOV
lea addresses_D+0x2c09, %rsi
lea addresses_PSE+0x1bc09, %rdi
cmp %r13, %r13
mov $3, %rcx
rep movsb
nop
nop
cmp %r8, %r8
// Store
lea addresses_normal+0x5121, %rdx
nop
nop
nop
xor $18778, %rbx
mov $0x5152535455565758, %rdi
movq %rdi, %xmm2
movups %xmm2, (%rdx)
nop
nop
dec %r15
// Store
lea addresses_PSE+0xeb09, %r8
clflush (%r8)
nop
nop
nop
sub $34413, %r15
mov $0x5152535455565758, %rsi
movq %rsi, (%r8)
nop
sub %rsi, %rsi
// Load
mov $0x194abd00000004c9, %r15
nop
nop
nop
dec %rcx
mov (%r15), %edx
xor %rbx, %rbx
// Load
lea addresses_D+0x3e9, %rdi
clflush (%rdi)
nop
nop
nop
cmp $48921, %r13
mov (%rdi), %r15
nop
nop
nop
nop
and %r8, %r8
// Store
lea addresses_WT+0x19e3f, %r8
clflush (%r8)
nop
nop
add $3823, %rdi
mov $0x5152535455565758, %r15
movq %r15, (%r8)
nop
xor %r8, %r8
// Faulty Load
lea addresses_PSE+0x1bc09, %rcx
nop
nop
cmp %r8, %r8
mov (%rcx), %r15w
lea oracles, %rbx
and $0xff, %r15
shlq $12, %r15
mov (%rbx,%r15,1), %r15
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 2, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_D'}, 'dst': {'congruent': 0, 'same': True, 'type': 'addresses_PSE'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 3, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'}
{'src': {'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 4, 'same': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1, 'same': False, 'type': 'addresses_WT'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 0, 'same': True, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7, 'same': True, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'36': 84}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
Ada/src/fakelib/utilities.ads | fintatarta/fakedsp | 0 | 8759 | --
-- Many consider a "Utilities" package bad style and maybe it is true.
-- However, often you need some "odds and ends" stuff that is not
-- strictly related to the main code.
--
package Utilities is
-- Root package
end Utilities;
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_18.asm | ljhsiun2/medusa | 9 | 172623 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x11dd0, %rsi
lea addresses_UC_ht+0x1345e, %rdi
nop
sub $39620, %rdx
mov $15, %rcx
rep movsl
nop
nop
nop
xor $22459, %r11
lea addresses_WT_ht+0x1c9e0, %rsi
lea addresses_D_ht+0x3bdc, %rdi
clflush (%rdi)
nop
and %r12, %r12
mov $12, %rcx
rep movsl
nop
cmp $9374, %r12
lea addresses_WT_ht+0xf904, %rdx
nop
nop
and %r9, %r9
mov $0x6162636465666768, %r12
movq %r12, %xmm6
vmovups %ymm6, (%rdx)
nop
nop
nop
nop
nop
xor $61371, %rsi
lea addresses_UC_ht+0x15b17, %rcx
nop
nop
nop
nop
sub $22306, %r9
mov (%rcx), %di
nop
nop
nop
nop
nop
add %r9, %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r15
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_UC+0xb750, %r9
clflush (%r9)
nop
nop
nop
nop
inc %rbx
mov $0x5152535455565758, %r14
movq %r14, (%r9)
nop
nop
nop
nop
nop
lfence
// REPMOV
lea addresses_D+0x6746, %rsi
lea addresses_UC+0x1fb50, %rdi
nop
nop
nop
nop
add %rbx, %rbx
mov $38, %rcx
rep movsq
// Exception!!!
nop
nop
nop
nop
nop
mov (0), %rsi
nop
nop
nop
nop
xor $26366, %rcx
// Faulty Load
lea addresses_PSE+0x8f50, %r14
nop
nop
cmp $14892, %r13
vmovups (%r14), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $1, %xmm2, %rcx
lea oracles, %r14
and $0xff, %rcx
shlq $12, %rcx
mov (%r14,%rcx,1), %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r15
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 8, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_UC'}, 'OP': 'REPM'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
BitTune Lang/BitTuneGrammar.g4 | BenMiller3/BitTune | 0 | 833 | grammar BitTuneGrammar ;
program: statement+ ;
statement : noteSequence | multiNoteSequence | shapeSequence | commentSequence ;
noteSequence : note ;
multiNoteSequence : number note ;
shapeSequence : shapeName (noteSequence | multiNoteSequence)+ endShape ;
number : INT ;
note : NOTE ;
shapeName : RECT | OVAL | LINE | DOTS ;
endShape : CLOSE_BRACKET ;
commentSequence : COMMENT ;
NOTE : [a-gA-GrR][a-gA-GrR]?[a-gA-GrR]?[a-gA-GrR]? ; // Note can be up to 4 instances of a-g or r for rest
RECT : 'rect(' ;
OVAL : 'oval(' ;
LINE : 'line(' ;
DOTS : 'dots(' ;
CLOSE_BRACKET : ')' ;
COMMENT : '//' ~[\r\n]* '\r'? '\n' -> skip ;
INT : [0-9]+ ;
WS : [ \t\r\n]+ -> skip ; // skip tabs, spaces, and new lines |
tests/natools-chunked_strings-tests-cxa4030.adb | faelys/natools | 0 | 24639 | ------------------------------------------------------------------------------
-- Copyright (c) 2011, <NAME> --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Characters.Handling;
with Ada.Characters.Latin_1;
with Ada.Exceptions;
with Ada.Strings; use Ada.Strings;
procedure Natools.Chunked_Strings.Tests.CXA4030
(Report : in out Natools.Tests.Reporter'Class)
is
package NT renames Natools.Tests;
begin
NT.Section (Report, "Port of ACATS CXA4030");
declare
package L1 renames Ada.Characters.Latin_1;
New_Character_String : Chunked_String
:= To_Chunked_String (L1.LC_A_Grave & L1.LC_A_Ring
& L1.LC_AE_Diphthong & L1.LC_C_Cedilla
& L1.LC_E_Acute & L1.LC_I_Circumflex
& L1.LC_Icelandic_Eth & L1.LC_N_Tilde
& L1.LC_O_Oblique_Stroke & L1.LC_Icelandic_Thorn);
TC_New_Character_String : constant Chunked_String
:= To_Chunked_String (L1.UC_A_Grave & L1.UC_A_Ring
& L1.UC_AE_Diphthong & L1.UC_C_Cedilla
& L1.UC_E_Acute & L1.UC_I_Circumflex
& L1.UC_Icelandic_Eth & L1.UC_N_Tilde
& L1.UC_O_Oblique_Stroke & L1.UC_Icelandic_Thorn);
Map_To_Lower_Case_Ptr : constant Maps.Character_Mapping_Function
:= Ada.Characters.Handling.To_Lower'Access;
Map_To_Upper_Case_Ptr : constant Maps.Character_Mapping_Function
:= Ada.Characters.Handling.To_Upper'Access;
begin
NT.Section (Report, "Function Index, Forward direction");
declare
Name : constant String := "Mixed case mapped to lower";
begin
Test (Report, Name,
Index (Source => To_Chunked_String
("The library package Strings.Unbounded"),
Pattern => "unb",
Going => Ada.Strings.Forward,
Mapping => Map_To_Lower_Case_Ptr),
29);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to lower";
begin
Test (Report, Name,
Index (To_Chunked_String
("THE RAIN IN SPAIN FALLS MAINLY ON THE PLAIN"),
"ain",
Mapping => Map_To_Lower_Case_Ptr),
6);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Lower case mapped to lower";
begin
Test (Report, Name,
Index (To_Chunked_String ("maximum number"),
"um",
Ada.Strings.Forward,
Ada.Characters.Handling.To_Lower'Access),
6);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Mixed case mapped to upper";
begin
Test (Report, Name,
Index (To_Chunked_String ("CoMpLeTeLy MiXeD CaSe StRiNg"),
"MIXED CASE STRING",
Ada.Strings.Forward,
Map_To_Upper_Case_Ptr),
12);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to lower (no match)";
begin
Test (Report, Name,
Index (To_Chunked_String
("STRING WITH NO MATCHING PATTERNS"),
"WITH",
Mapping => Map_To_Lower_Case_Ptr),
0);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to upper";
begin
Test (Report, Name,
Index (To_Chunked_String ("THIS STRING IS IN UPPER CASE"),
"IS",
Ada.Strings.Forward,
Ada.Characters.Handling.To_Upper'Access),
3);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Null string";
begin
Test (Report, Name,
Index (Null_Chunked_String,
"is",
Mapping => Map_To_Lower_Case_Ptr),
0);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to lower";
begin
Test (Report, Name,
Index (To_Chunked_String ("AAABBBaaabbb"),
"aabb",
Mapping => Ada.Characters.Handling.To_Lower'Access),
2);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
NT.End_Section (Report);
NT.Section (Report, "Function Index, Backward direction");
declare
Name : constant String := "Mixed case mapped to lower";
begin
Test (Report, Name,
Index (To_Chunked_String ("Case of a Mixed Case String"),
"case",
Ada.Strings.Backward,
Map_To_Lower_Case_Ptr),
17);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Mixed case mapped to upper";
begin
Test (Report, Name,
Index (To_Chunked_String ("Case of a Mixed Case String"),
"CASE",
Ada.Strings.Backward,
Mapping => Map_To_Upper_Case_Ptr),
17);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to lower";
begin
Test (Report, Name,
Index (To_Chunked_String ("rain, Rain, and more RAIN"),
"rain",
Ada.Strings.Backward,
Ada.Characters.Handling.To_Lower'Access),
22);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Lower case mapped to upper";
begin
Test (Report, Name,
Index (To_Chunked_String ("RIGHT place, right time"),
"RIGHT",
Going => Ada.Strings.Backward,
Mapping => Ada.Characters.Handling.To_Upper'Access),
14);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to lower (no match)";
begin
Test (Report, Name,
Index (To_Chunked_String ("WOULD MATCH BUT FOR THE CASE"),
"WOULD MATCH BUT FOR THE CASE",
Going => Ada.Strings.Backward,
Mapping => Map_To_Lower_Case_Ptr),
0);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
NT.End_Section (Report);
declare
Null_String : constant String := "";
TC_Natural : Natural := 1000;
begin
TC_Natural
:= Index (To_Chunked_String ("A Valid Chunked String"),
Null_String,
Going => Ada.Strings.Forward,
Mapping => Ada.Characters.Handling.To_Lower'Access);
NT.Item (Report, "Pattern_Error raised in Index", NT.Fail);
NT.Info (Report, "No exception has been raised.");
NT.Info (Report, "Return value: " & Natural'Image (TC_Natural));
exception
when Pattern_Error =>
NT.Item (Report, "Pattern_Error raised in Index", NT.Success);
when Error : others =>
NT.Item (Report, "Pattern_Error raised in Index", NT.Fail);
NT.Info (Report, "Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
NT.Section (Report, "Function Count with mapping function");
declare
Name : constant String := "Upper case mapped to lower";
begin
Test (Report, Name,
Count (Source => To_Chunked_String ("ABABABA"),
Pattern => "aba",
Mapping => Map_To_Lower_Case_Ptr),
2);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to lower (no match)";
begin
Test (Report, Name,
Count (To_Chunked_String ("ABABABA"),
"ABA",
Mapping => Map_To_Lower_Case_Ptr),
0);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Mixed case mapped to lower";
begin
Test (Report, Name,
Count (To_Chunked_String ("This IS a MISmatched issue"),
"is",
Ada.Characters.Handling.To_Lower'Access),
4);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to upper";
begin
Test (Report, Name,
Count (To_Chunked_String ("ABABABA"),
"ABA",
Map_To_Upper_Case_Ptr),
2);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to upper (no match)";
begin
Test (Report, Name,
Count (To_Chunked_String ("This IS a MISmatched issue"),
"is",
Mapping => Map_To_Upper_Case_Ptr),
0);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Mixed case mapped to lower";
begin
Test (Report, Name,
Count (To_Chunked_String
("She sells sea shells by the sea shore"),
"s",
Ada.Characters.Handling.To_Lower'Access),
8);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Empty string";
begin
Test (Report, Name,
Count (Null_Chunked_String,
"match",
Map_To_Upper_Case_Ptr),
0);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
NT.End_Section (Report);
declare
Null_Pattern_String : constant String := "";
TC_Natural : Natural := 1000;
begin
TC_Natural := Count (To_Chunked_String ("A Valid String"),
Null_Pattern_String,
Map_To_Lower_Case_Ptr);
NT.Item (Report, "Pattern_Error raised in Count", NT.Fail);
NT.Info (Report, "No exception has been raised.");
NT.Info (Report, "Return value: " & Natural'Image (TC_Natural));
exception
when Pattern_Error =>
NT.Item (Report, "Pattern_Error raised in Count", NT.Success);
when Error : others =>
NT.Item (Report, "Pattern_Error raised in Count", NT.Fail);
NT.Info (Report, "Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
NT.Section (Report, "Function Translate");
declare
Name : constant String := "Mixed case mapped to lower";
begin
Test (Report, Name,
Translate (Source => To_Chunked_String
("A Sample Mixed Case String"),
Mapping => Map_To_Lower_Case_Ptr),
"a sample mixed case string");
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to lower";
begin
Test (Report, Name,
Translate (To_Chunked_String ("ALL LOWER CASE"),
Ada.Characters.Handling.To_Lower'Access),
"all lower case");
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Lower case mapped to lower";
begin
Test (Report, Name,
Translate (To_Chunked_String ("end with lower case"),
Map_To_Lower_Case_Ptr),
"end with lower case");
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Empty string";
begin
Test (Report, Name,
Translate (Null_Chunked_String,
Ada.Characters.Handling.To_Lower'Access),
Null_Chunked_String);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Lower case mapped to upper";
begin
Test (Report, Name,
Translate (To_Chunked_String ("start with lower case"),
Map_To_Upper_Case_Ptr),
"START WITH LOWER CASE");
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Upper case mapped to upper";
begin
Test (Report, Name,
Translate (To_Chunked_String ("ALL UPPER CASE STRING"),
Ada.Characters.Handling.To_Upper'Access),
"ALL UPPER CASE STRING");
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Mixed case mapped to upper";
begin
Test (Report, Name,
Translate (To_Chunked_String
("LoTs Of MiXeD CaSe ChArAcTeRs"),
Map_To_Upper_Case_Ptr),
"LOTS OF MIXED CASE CHARACTERS");
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Diacritics";
begin
Test (Report, Name,
Translate (New_Character_String,
Ada.Characters.Handling.To_Upper'Access),
TC_New_Character_String);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
NT.End_Section (Report);
NT.Section (Report, "Procedure Translate");
declare
use Ada.Characters.Handling;
Str_1 : Chunked_String
:= To_Chunked_String ("AN ALL UPPER CASE STRING");
Str_2 : Chunked_String
:= To_Chunked_String ("A Mixed Case String");
Str_3 : Chunked_String
:= To_Chunked_String ("a string with lower case letters");
TC_Str_1 : constant Chunked_String := Str_1;
TC_Str_3 : constant Chunked_String := Str_3;
begin
declare
Name : constant String := "Upper case mapped to lower";
begin
Translate (Source => Str_1, Mapping => Map_To_Lower_Case_Ptr);
Test (Report, Name, Str_1,
To_Chunked_String ("an all upper case string"));
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Lower case mapped back to upper";
begin
Translate (Source => Str_1, Mapping => Map_To_Upper_Case_Ptr);
Test (Report, Name, Str_1, TC_Str_1);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Mixed case mapped to lower";
begin
Translate (Str_2, Mapping => Map_To_Lower_Case_Ptr);
Test (Report, Name, Str_2,
To_Chunked_String ("a mixed case string"));
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Lower case mapped to upper";
begin
Translate (Str_2, Mapping => To_Upper'Access);
Test (Report, Name, Str_2,
To_Chunked_String ("A MIXED CASE STRING"));
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Lower case mapped to lower";
begin
Translate (Str_3, To_Lower'Access);
Test (Report, Name, Str_3, TC_Str_3);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Lower case mapped to upper";
begin
Translate (Str_3, To_Upper'Access);
Test (Report, Name, Str_3,
To_Chunked_String ("A STRING WITH LOWER CASE LETTERS"));
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Diacritics";
begin
Translate (New_Character_String, Map_To_Upper_Case_Ptr);
Test (Report, Name, New_Character_String, TC_New_Character_String);
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
end;
NT.End_Section (Report);
exception
when Error : others =>
NT.Item (Report, "Preparation", NT.Error);
NT.Info (Report, "Exception: "
& Ada.Exceptions.Exception_Name (Error));
NT.Info (Report, Ada.Exceptions.Exception_Message (Error));
end;
NT.End_Section (Report);
end Natools.Chunked_Strings.Tests.CXA4030;
|
lpair.asm | Fizzmy/assembly | 0 | 170669 | <filename>lpair.asm<gh_stars>0
.model small
.stack
.data
maxlen db 11h
actlen db ?
nmbuf db 11h dup(0)
numa dd 0
numb dd 0
ans dd 0
crlf db 0dh,0ah,'$'
.code
start: mov ax,@data;设置数据段地址
mov ds,ax
call read;读入n,存入numa
lea si,numa
mov [si],ax
mov [si+2],dx
call read;读入m
lea si,numa
;比较dx_ax和numa的大小,也就是m和n的大小
cmp dx,[si+2];比较高位
ja bbig;高位大于,说明后读入的大
jb abig;高位小于,说明先读入的大
cmp ax,[si];高位等于,比较低位
ja bbig;低位大于,说明后读入的大
jmp abig;否则认为先读入的大
abig: xchg [si],ax;先读入的大,交换dx_ax和numa
xchg [si+2],dx
bbig: lea si,numb;dx_ax放入numb
mov [si],ax
mov [si+2],dx
call solve;调用循环模块运行算法
mov ax,4c00h;结束程序
int 21h
solve proc near;算法主体部分,求[numa,numb]之间的亲密数对
lea si,numa;dx_ax存储numa
mov ax,[si]
mov dx,[si+2]
lp2:
call getd;求当前dx_ax的因数和
lea si,ans;读入因数和存储到cx_bx中
mov bx,[si]
mov cx,[si+2]
;判断cx_bx是否大于dx_ax
cmp cx,dx;判断高位
jb no;高位小于,准备开始下一次循环
ja nxt;高位大于,继续算法
cmp bx,ax;高位等于,判断低位
jbe no;低位小于等于,准备开始下一次循环
;低位大于,继续算法
nxt: ;判断cx_bx是否小于等于numb
lea si,numb
cmp cx,[si+2];判断高位
ja no;高位大于,准备开始下一次循环
jb work;高位小于,继续算法
cmp bx,[si];高位等于,判断低位
ja no;低位大于,准备开始下一次循环
;低位小于等于,继续算法
work:
push ax;保存dx_ax的值,也就是当前枚举到的数字
push dx
mov ax,bx;cx_bx是dx_ax的因数和,cx_bx赋值到dx_ax
mov dx,cx
push bx;保存寄存器信息
push cx
call getd;求当前dx_ax的因数和
pop cx;恢复寄存器信息
pop bx
;判断ans是否和dx_ax相等
lea si,ans
pop dx;恢复寄存器信息
pop ax
cmp dx,[si+2];判断高位
jnz no;不等,准备开始下一次循环
cmp ax,[si];判断低位
jnz no;不等,准备开始下一次循环
;相等,输出答案
push ax;保存寄存器信息
push dx
call pr;调用输出子程序输出dx_ax
mov dl,',';输出逗号分隔符
mov ax,0200h
int 21h
mov ax,bx;cx_dx赋值到dx_ax
mov dx,cx
call pr;调用输出子程序输出当前的dx_ax
lea dx,crlf;输出回车
mov ax,0900h
int 21h
pop dx;恢复寄存器信息
pop ax
no:
lea si,numb;判断dx_ax是否等于numb
cmp dx,[si+2];比较高位
jnz addi;不等,开始下一次循环
cmp ax,[si];高位相等比较低位
jnz addi;不等,开始下一次循环
ret;相等则子程序返回
addi: add ax,1;dx_ax+1
adc dx,0
jmp lp2;开始下一次循环
pr proc near
push cx;保存寄存器信息
push bx
mov bx,000ah;除数设为10
call print
pop bx;恢复寄存器信息
pop cx
ret
getd proc near;求dx_ax的因数和(除去本身)
lea si,ans;用ans来存储答案
mov word ptr [si],0001h;初值设为1
mov word ptr [si+2],0000h
mov bx,1;循环初值为2
lp: inc bx
push ax;保存寄存器信息
push dx
mov ax,bx;求解bx*bx
mul bx
mov cx,dx;判断bx*bx是否已经大于dx_ax
pop dx
cmp cx,dx
ja ed1;高位大于,跳转到结束操作
jb bg1;高位小于,开始循环
;高位等于,开始比较低位
mov cx,ax
pop ax
cmp cx,ax
ja ed;低位大于,跳转到结束操作
jb bg;低位小于,开始循环
add [si],bx;低位等于,说明bx*bx==dx_ax,dx_ax是完全平方数,只统计一次bx,子程序返回
adc word ptr [si+2],0;处理进位
ret
bg1: pop ax;一定注意要恢复寄存器信息
bg: push dx;保存寄存器的信息
push ax
push ax;求出dx_ax除以bx的商和余数,使用和print子程序相同的方法
mov ax,dx
xor dx,dx
div bx
mov cx,ax
pop ax
div bx;最终cx_ax为商,dx为余数
cmp dx,0;判断余数是否为0
jnz rt;不为零则开始下一个循环
add [si],bx;为0则答案加入bx
adc word ptr [si+2],0
mov dx,cx;加入商cx_ax
add [si],ax
adc [si+2],dx
rt: pop ax;恢复寄存器信息
pop dx
jmp lp
ed1: pop ax;恢复寄存器信息
ed: ret
read proc near ;读入一个数字,存放在dx_ax中
push bx;保护寄存器内容
lea dx,maxlen;读入字符串
mov ax,0a00h
int 21h
lea dx,crlf;输出回车
mov ax,0900h
int 21h
mov cl,actlen;读入的字符串长度为循环次数
lea si,nmbuf;指针指向字符串头
mov bx,000ah;bx赋值10
xor ax,ax;清空要用到的寄存器
xor dx,dx
nextc: mov ch,[si];取出字符,然后-'0'
sub ch,'0'
;计算dx_ax*10,需要先计算dx*10,再计算ax*10
push ax; 计算dx*10
mov ax,dx
mul bx
mov dx,ax
pop ax
push cx;计算ax*10
mov cx,dx
mul bx
add dx,cx;加上dx*10
pop cx
add al,ch;加上之前取出的字符代表的数字
adc ah,0;处理进位
adc dx,0
inc si;指针后移
dec cl;循环次数-1
jnz nextc;不为零继续循环
cmp ax,0;特判数字为0的情况
jnz nz
cmp dx,0
jnz nz
inc ax;数字为0则加一
nz:
pop bx;恢复寄存器内容
ret
print proc near ;将 dx_ax中的整数输出
cmp ax,0; 判断是不是0,是0直接返回
jnz down
cmp dx,0
jnz down
ret
down:;dx_ax除以10,求余数和商,类似于乘法,拆解成dx除以10,dx除以10的余数作为高16位,+ax再除以10
push ax
mov ax,dx ;求dx除以10
xor dx,dx
div bx
mov cx,ax; cx存储高16位的商,余数在dx,同时dx也是下一次除法操作的高16位,因此dx不变
pop ax;求dx_ax除以10
div bx
push dx;栈存储余数
mov dx,cx;恢复dx,dx_ax变成商
call print;递归调用
pop dx;恢复余数
add dl,'0';输出余数
mov ax,0200h
int 21h
ret
end start |
programs/oeis/154/A154600.asm | karttu/loda | 1 | 94762 | ; A154600: a(n) = 2*n^2 + 22*n + 9.
; 33,61,93,129,169,213,261,313,369,429,493,561,633,709,789,873,961,1053,1149,1249,1353,1461,1573,1689,1809,1933,2061,2193,2329,2469,2613,2761,2913,3069,3229,3393,3561,3733,3909,4089,4273,4461,4653,4849,5049,5253,5461,5673,5889,6109,6333,6561,6793,7029,7269,7513,7761,8013,8269,8529,8793,9061,9333,9609,9889,10173,10461,10753,11049,11349,11653,11961,12273,12589,12909,13233,13561,13893,14229,14569,14913,15261,15613,15969,16329,16693,17061,17433,17809,18189,18573,18961,19353,19749,20149,20553,20961,21373,21789,22209,22633,23061,23493,23929,24369,24813,25261,25713,26169,26629,27093,27561,28033,28509,28989,29473,29961,30453,30949,31449,31953,32461,32973,33489,34009,34533,35061,35593,36129,36669,37213,37761,38313,38869,39429,39993,40561,41133,41709,42289,42873,43461,44053,44649,45249,45853,46461,47073,47689,48309,48933,49561,50193,50829,51469,52113,52761,53413,54069,54729,55393,56061,56733,57409,58089,58773,59461,60153,60849,61549,62253,62961,63673,64389,65109,65833,66561,67293,68029,68769,69513,70261,71013,71769,72529,73293,74061,74833,75609,76389,77173,77961,78753,79549,80349,81153,81961,82773,83589,84409,85233,86061,86893,87729,88569,89413,90261,91113,91969,92829,93693,94561,95433,96309,97189,98073,98961,99853,100749,101649,102553,103461,104373,105289,106209,107133,108061,108993,109929,110869,111813,112761,113713,114669,115629,116593,117561,118533,119509,120489,121473,122461,123453,124449,125449,126453,127461,128473,129489,130509
mov $1,$0
add $0,13
mul $1,2
mul $1,$0
add $1,33
|
models/tests/test06.als | transclosure/Amalgam | 4 | 756 | <reponame>transclosure/Amalgam
module tests/test // Bugpost by <NAME> <<EMAIL>>
abstract sig Component {}
abstract sig Step extends Component {}
sig Pipeline extends Component {}
sig Identity extends Step {}
sig XSLT extends Step {}
sig XInclude extends Step {}
run {some Pipeline} for 3 expect 1
run {some Pipeline} for 3 but 1 Pipeline expect 1
|
test/Compiler/simple/Literals.agda | cruhland/agda | 1,989 | 16743 | {-# OPTIONS --universe-polymorphism #-}
module Literals where
open import Common.Nat
open import Common.Float
open import Common.Char
open import Common.String
open import Common.Unit
open import Common.IO
afloat : Float
afloat = 1.23
astring : String
astring = "abc"
achar : Char
achar = 'd'
anat : Nat
anat = 123
main : IO Unit
main =
printFloat afloat ,,
putStr astring ,,
printChar achar ,,
printNat anat ,,
putStrLn ""
|
LibraBFT/Lemmas.agda | lisandrasilva/bft-consensus-agda-1 | 0 | 17227 | <gh_stars>0
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import Level using (0ℓ)
-- This module incldes various Agda lemmas that are independent of the project's domain
module LibraBFT.Lemmas where
cong₃ : ∀{a b c d}{A : Set a}{B : Set b}{C : Set c}{D : Set d}
→ (f : A → B → C → D) → ∀{x y u v m n} → x ≡ y → u ≡ v → m ≡ n
→ f x u m ≡ f y v n
cong₃ f refl refl refl = refl
≡-pi : ∀{a}{A : Set a}{x y : A}(p q : x ≡ y) → p ≡ q
≡-pi refl refl = refl
Unit-pi : {u1 u2 : Unit}
→ u1 ≡ u2
Unit-pi {unit} {unit} = refl
++-inj : ∀{a}{A : Set a}{m n o p : List A}
→ length m ≡ length n → m ++ o ≡ n ++ p
→ m ≡ n × o ≡ p
++-inj {m = []} {x ∷ n} () hip
++-inj {m = x ∷ m} {[]} () hip
++-inj {m = []} {[]} lhip hip
= refl , hip
++-inj {m = m ∷ ms} {n ∷ ns} lhip hip
with ++-inj {m = ms} {ns} (suc-injective lhip) (proj₂ (∷-injective hip))
...| (mn , op) rewrite proj₁ (∷-injective hip)
= cong (n ∷_) mn , op
++-abs : ∀{a}{A : Set a}{n : List A}(m : List A)
→ 1 ≤ length m → [] ≡ m ++ n → ⊥
++-abs [] ()
++-abs (x ∷ m) imp ()
data All-vec {ℓ} {A : Set ℓ} (P : A → Set ℓ) : ∀ {n} → Vec {ℓ} A n → Set (Level.suc ℓ) where
[] : All-vec P []
_∷_ : ∀ {x n} {xs : Vec A n} (px : P x) (pxs : All-vec P xs) → All-vec P (x ∷ xs)
≤-unstep : ∀{m n} → suc m ≤ n → m ≤ n
≤-unstep (s≤s ss) = ≤-step ss
≡⇒≤ : ∀{m n} → m ≡ n → m ≤ n
≡⇒≤ refl = ≤-refl
∈-cong : ∀{a b}{A : Set a}{B : Set b}{x : A}{l : List A}
→ (f : A → B) → x ∈ l → f x ∈ List-map f l
∈-cong f (here px) = here (cong f px)
∈-cong f (there hyp) = there (∈-cong f hyp)
All-self : ∀{a}{A : Set a}{xs : List A} → All (_∈ xs) xs
All-self = All-tabulate (λ x → x)
All-reduce⁺
: ∀{a b}{A : Set a}{B : Set b}{Q : A → Set}{P : B → Set}
→ { xs : List A }
→ (f : ∀{x} → Q x → B)
→ (∀{x} → (prf : Q x) → P (f prf))
→ (all : All Q xs)
→ All P (All-reduce f all)
All-reduce⁺ f hyp [] = []
All-reduce⁺ f hyp (ax ∷ axs) = (hyp ax) ∷ All-reduce⁺ f hyp axs
All-reduce⁻
: ∀{a b}{A : Set a}{B : Set b}
{Q : A → Set}
→ { xs : List A }
→ ∀ {vdq}
→ (f : ∀{x} → Q x → B)
→ (all : All Q xs)
→ vdq ∈ All-reduce f all
→ ∃[ v ] ∃[ v∈xs ] (vdq ≡ f {v} v∈xs)
All-reduce⁻ {Q = Q} {(h ∷ _)} {vdq} f (px ∷ pxs) (here refl) = h , px , refl
All-reduce⁻ {Q = Q} {(_ ∷ t)} {vdq} f (px ∷ pxs) (there vdq∈) = All-reduce⁻ {xs = t} f pxs vdq∈
List-index : ∀ {A : Set} → (_≟A_ : (a₁ a₂ : A) → Dec (a₁ ≡ a₂)) → A → (l : List A) → Maybe (Fin (length l))
List-index _≟A_ x l with break (_≟A x) l
...| not≡ , _ with length not≡ <? length l
...| no _ = nothing
...| yes found = just ( fromℕ< {length not≡} {length l} found)
nats : ℕ → List ℕ
nats 0 = []
nats (suc n) = (nats n) ++ (n ∷ [])
_ : nats 4 ≡ 0 ∷ 1 ∷ 2 ∷ 3 ∷ []
_ = refl
_ : Maybe-map toℕ (List-index _≟_ 2 (nats 4)) ≡ just 2
_ = refl
_ : Maybe-map toℕ (List-index _≟_ 4 (nats 4)) ≡ nothing
_ = refl
allDistinct : ∀ {A : Set} → List A → Set
allDistinct l = ∀ (i j : Σ ℕ (_< length l)) →
proj₁ i ≡ proj₁ j
⊎ List-lookup l (fromℕ< (proj₂ i)) ≢ List-lookup l (fromℕ< (proj₂ j))
postulate -- TODO-1: currently unused; prove it, if needed
allDistinct? : ∀ {A : Set} → {≟A : (a₁ a₂ : A) → Dec (a₁ ≡ a₂)} → (l : List A) → Dec (allDistinct l)
-- Extends an arbitrary relation to work on the head of
-- the supplied list, if any.
data OnHead {A : Set}(P : A → A → Set) (x : A) : List A → Set where
[] : OnHead P x []
on-∷ : ∀{y ys} → P x y → OnHead P x (y ∷ ys)
-- Establishes that a list is sorted according to the supplied
-- relation.
data IsSorted {A : Set}(_<_ : A → A → Set) : List A → Set where
[] : IsSorted _<_ []
_∷_ : ∀{x xs} → OnHead _<_ x xs → IsSorted _<_ xs → IsSorted _<_ (x ∷ xs)
OnHead-prop : ∀{A}(P : A → A → Set)(x : A)(l : List A)
→ Irrelevant P
→ isPropositional (OnHead P x l)
OnHead-prop P x [] hyp [] [] = refl
OnHead-prop P x (x₁ ∷ l) hyp (on-∷ x₂) (on-∷ x₃) = cong on-∷ (hyp x₂ x₃)
IsSorted-prop : ∀{A}(_<_ : A → A → Set)(l : List A)
→ Irrelevant _<_
→ isPropositional (IsSorted _<_ l)
IsSorted-prop _<_ [] hyp [] [] = refl
IsSorted-prop _<_ (x ∷ l) hyp (x₁ ∷ a) (x₂ ∷ b)
= cong₂ _∷_ (OnHead-prop _<_ x l hyp x₁ x₂)
(IsSorted-prop _<_ l hyp a b)
IsSorted-map⁻ : {A : Set}{_≤_ : A → A → Set}
→ {B : Set}(f : B → A)(l : List B)
→ IsSorted (λ x y → f x ≤ f y) l
→ IsSorted _≤_ (List-map f l)
IsSorted-map⁻ f .[] [] = []
IsSorted-map⁻ f .(_ ∷ []) (x ∷ []) = [] ∷ []
IsSorted-map⁻ f .(_ ∷ _ ∷ _) (on-∷ x ∷ (x₁ ∷ is)) = (on-∷ x) ∷ IsSorted-map⁻ f _ (x₁ ∷ is)
-- TODO-1 : Better name and/or replace with library property
Any-sym : ∀ {a b}{A : Set a}{B : Set b}{tgt : B}{l : List A}{f : A → B}
→ Any (λ x → tgt ≡ f x) l
→ Any (λ x → f x ≡ tgt) l
Any-sym (here x) = here (sym x)
Any-sym (there x) = there (Any-sym x)
Any-lookup-correct : ∀ {a b}{A : Set a}{B : Set b}{tgt : B}{l : List A}{f : A → B}
→ (p : Any (λ x → f x ≡ tgt) l)
→ Any-lookup p ∈ l
Any-lookup-correct (here px) = here refl
Any-lookup-correct (there p) = there (Any-lookup-correct p)
Any-lookup-correctP : ∀ {a}{A : Set a}{l : List A}{P : A → Set}
→ (p : Any P l)
→ Any-lookup p ∈ l
Any-lookup-correctP (here px) = here refl
Any-lookup-correctP (there p) = there (Any-lookup-correctP p)
Any-witness : ∀ {a b} {A : Set a} {l : List A} {P : A → Set b}
→ (p : Any P l) → P (Any-lookup p)
Any-witness (here px) = px
Any-witness (there x) = Any-witness x
-- TODO-1: there is probably a library property for this.
∈⇒Any : ∀ {A : Set}{x : A}
→ {xs : List A}
→ x ∈ xs
→ Any (_≡ x) xs
∈⇒Any {x = x} (here refl) = here refl
∈⇒Any {x = x} {h ∷ t} (there xxxx) = there (∈⇒Any {xs = t} xxxx)
false≢true : false ≢ true
false≢true ()
witness : {A : Set}{P : A → Set}{x : A}{xs : List A}
→ x ∈ xs → All P xs → P x
witness x y = All-lookup y x
maybe-⊥ : ∀{a}{A : Set a}{x : A}{y : Maybe A}
→ y ≡ just x
→ y ≡ nothing
→ ⊥
maybe-⊥ () refl
Maybe-map-cool : ∀ {S S₁ : Set} {f : S → S₁} {x : Maybe S} {z}
→ Maybe-map f x ≡ just z
→ x ≢ nothing
Maybe-map-cool {x = nothing} ()
Maybe-map-cool {x = just y} prf = λ x → ⊥-elim (maybe-⊥ (sym x) refl)
Maybe-map-cool-1 : ∀ {S S₁ : Set} {f : S → S₁} {x : Maybe S} {z}
→ Maybe-map f x ≡ just z
→ Σ S (λ x' → f x' ≡ z)
Maybe-map-cool-1 {x = nothing} ()
Maybe-map-cool-1 {x = just y} {z = z} refl = y , refl
Maybe-map-cool-2 : ∀ {S S₁ : Set} {f : S → S₁} {x : S} {z}
→ f x ≡ z
→ Maybe-map f (just x) ≡ just z
Maybe-map-cool-2 {S}{S₁}{f}{x}{z} prf rewrite prf = refl
T⇒true : ∀ {a : Bool} → T a → a ≡ true
T⇒true {true} _ = refl
isJust : ∀ {A : Set}{aMB : Maybe A}{a : A}
→ aMB ≡ just a
→ Is-just aMB
isJust refl = just tt
to-witness-isJust-≡ : ∀ {A : Set}{aMB : Maybe A}{a prf}
→ to-witness (isJust {aMB = aMB} {a} prf) ≡ a
to-witness-isJust-≡ {aMB = just a'} {a} {prf}
with to-witness-lemma (isJust {aMB = just a'} {a} prf) refl
...| xxx = just-injective (trans (sym xxx) prf)
|
oeis/052/A052714.asm | neoneye/loda-programs | 11 | 103714 | <gh_stars>10-100
; A052714: a(n) = 2^(n-1) * n! * Catalan(n-1) for n > 0 with a(0) = 0.
; 0,1,4,48,960,26880,967680,42577920,2214051840,132843110400,9033331507200,686533194547200,57668788341964800,5305528527460761600,530552852746076160000,57299708096576225280000,6646766139202842132480000,824199001261152424427520000,108794268166472120024432640000,15231197543306096803420569600000,2254217236409302326906244300800000,351657888879851162997374110924800000,57671893776295590731569354191667200000,9919565729522841605829928920966758400000,1785521831314111489049387205774016512000000
lpb $0
trn $0,1
seq $0,144828 ; Partial products of successive terms of A017113; a(0)=1.
mov $2,$0
mov $0,$1
lpe
mov $0,$2
|
utility/IO.asm | puzzud/puzl6502 | 0 | 103071 | <reponame>puzzud/puzl6502<gh_stars>0
;------------------------------------------------------------------
!zone MemoryCopy
MemoryCopy
ldx PARAM2
ldy #0
.MemoryCopyLoop
; Decrement 16-bit size/counter.
txa
bne .decrementSizeLo
lda PARAM3
beq .MemoryCopyEnd
.decrementSizeHi
dec PARAM3
.decrementSizeLo
dex
.CopyByte
; Copy one byte.
lda (ZEROPAGE_POINTER_1),y
sta (ZEROPAGE_POINTER_2),y
; Increment Y index.
iny
bne .MemoryCopyLoop
; if Y index wraps around.
; Increment hi-byte of source/destination addresses
inc ZEROPAGE_POINTER_1+1
inc ZEROPAGE_POINTER_2+1
jmp .MemoryCopyLoop
.MemoryCopyEnd
rts
;------------------------------------------------------------------
; !zone MemoryCopyToRegister
; MemoryCopyToRegister
; ldy #0
; .MemoryCopyLoop
;
; ; Decrement 16-bit size/counter.
; lda PARAM1
; bne .decrementSizeLo
; lda PARAM2
; beq .MemoryCopyEnd
; .decrementSizeHi
; dec PARAM2
; .decrementSizeLo
; dec PARAM1
;
; .CopyByte
; ; Copy one byte.
; tya
; tax
; lda (ZEROPAGE_POINTER_1),y
; ldy #0
; sta (ZEROPAGE_POINTER_2),y
; ;sta VRAM_ADDRESS_REG
; txa
; tay
;
; ; Increment Y index.
; iny
; bne .MemoryCopyLoop
;
; ; if Y index wraps around.
; ; Increment hi-byte of source address
; inc ZEROPAGE_POINTER_1+1
;
; jmp .MemoryCopyLoop
;
; .MemoryCopyEnd
; rts
;------------------------------------------------------------------
!zone MemoryFill
MemoryFill
ldx PARAM2
ldy #0
.MemoryFillLoop
; Decrement 16-bit size/counter.
txa
bne .decrementSizeLo
lda PARAM3
beq .MemoryFillEnd
.decrementSizeHi
dec PARAM3
.decrementSizeLo
dex
.SetByte
; Copy one byte.
lda PARAM1
sta (ZEROPAGE_POINTER_2),y
; Increment Y index.
iny
bne .MemoryFillLoop
; if Y index wraps around.
; Increment hi-byte of destination address
inc ZEROPAGE_POINTER_2+1
jmp .MemoryFillLoop
.MemoryFillEnd
rts
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/array5.adb | best08618/asylo | 7 | 17026 | <reponame>best08618/asylo<gh_stars>1-10
-- { dg-do run }
-- { dg-options "-O" }
procedure Array5 is
type myint is range 0 .. 100_000;
Bla : constant myint := 359;
type my_array is array (1 .. 2) of myint;
type item is record
Length : Integer;
Content : my_array;
end record;
procedure create_item (M : out item) is
begin
M.Length := 1;
M.Content := (others => Bla);
end;
Var : item;
begin
create_item (Var);
if Var.Length = 1
and then Var.Content (1) = Bla
then
null;
else
raise Program_Error;
end if;
end;
|
oeis/224/A224500.asm | neoneye/loda-programs | 11 | 10290 | ; A224500: Number of ordered full binary trees with labels from a set of at most n labels.
; Submitted by <NAME>(s2)
; 1,4,21,184,2425,42396,916909,23569456,701312049,23697421300,896146948741,37491632258664,1719091662617641,85724109916049164,4618556912276116125,267351411229327901536,16547551265061986364769,1090506038795558789135076,76234505063400211010327029,5634709420806553357800261400,439043283838645698385394488281,35967276967259842483932520569724,3090517287173805474644214574597261,277928083651828392684101734395936144,26106478287355011979423820168452596625,2556748542082963346694548023237213451476
mul $0,2
mov $1,1
lpb $0
sub $0,2
sub $2,$1
mul $2,2
sub $1,$2
add $1,1
mul $2,$0
lpe
mov $0,$1
|
programs/oeis/017/A017344.asm | karttu/loda | 1 | 101595 | ; A017344: a(n) = (10*n + 6)^4.
; 1296,65536,456976,1679616,4477456,9834496,18974736,33362176,54700816,84934656,126247696,181063936,252047376,342102016,454371856,592240896,759333136,959512576,1196883216,1475789056,1800814096,2176782336,2608757776,3102044416,3662186256,4294967296,5006411536,5802782976,6690585616,7676563456,8767700496,9971220736,11294588176,12745506816,14331920656,16062013696,17944209936,19987173376,22199808016,24591257856,27170906896,29948379136,32933538576,36136489216,39567575056,43237380096,47156728336,51336683776,55788550416,60523872256,65554433296,70892257536,76549608976,82538991616,88873149456,95565066496,102627966736,110075314176,117920812816,126178406656,134862279696,143986855936,153566799376,163617014016,174152643856,185189072896,196741925136,208827064576,221460595216,234658861056,248438446096,262816174336,277809109776,293434556416,309710058256,326653399296,344282603536,362615934976,381671897616,401469235456,422026932496,443364212736,465500540176,488455618816,512249392656,536902045696,562434001936,588865925376,616218720016,644513529856,673771738896,704014971136,735265090576,767544201216,800874647056,835279012096,870780120336,907401035776,945165062416,984095744256,1024216865296,1065552449536,1108126760976,1151964303616,1197089821456,1243528298496,1291304958736,1340445266176,1390974924816,1442919878656,1496306311696,1551160647936,1607509551376,1665379926016,1724798915856,1785793904896,1848392517136,1912622616576,1978512307216,2046089933056,2115384078096,2186423566336,2259237461776,2333855068416,2410305930256,2488619831296,2568826795536,2650957086976,2735041209616,2821109907456,2909194164496,2999325204736,3091534492176,3185853730816,3282314864656,3380950077696,3481791793936,3584872677376,3690225632016,3797883801856,3907880570896,4020249563136,4135024642576,4252239913216,4371929719056,4494128644096,4618871512336,4746193387776,4876129574416,5008715616256,5143987297296,5281980641536,5422731912976,5566277615616,5712654493456,5861899530496,6014049950736,6169143218176,6327217036816,6488309350656,6652458343696,6819702439936,6990080303376,7163630838016,7340393187856,7520406736896,7703711109136,7890346168576,8080352019216,8273769005056,8470637710096,8670998958336,8874893813776,9082363580416,9293449802256,9508194263296,9726638987536,9948826238976,10174798521616,10404598579456,10638269396496,10875854196736,11117396444176,11362939842816,11612528336656,11866206109696,12124017585936,12386007429376,12652220544016,12922702073856,13197497402896,13476652155136,13760212194576,14048223625216,14340732791056,14637786276096,14939430904336,15245713739776,15556682086416,15872383488256,16192865729296,16518176833536,16848365064976,17183478927616,17523567165456,17868678762496,18218862942736,18574169170176,18934647148816,19300346822656,19671318375696,20047612231936,20429279055376,20816369750016,21208935459856,21607027568896,22010697701136,22419997720576,22834979731216,23255696077056,23682199342096,24114542350336,24552778165776,24996960092416,25447141674256,25903376695296,26365719179536,26834223390976,27308943833616,27789935251456,28277252628496,28770951188736,29271086396176,29777713954816,30290889808656,30810670141696,31337111377936,31870270181376,32410203456016,32956968345856,33510622234896,34071222747136,34638827746576,35213495337216,35795283863056,36384251908096,36980458296336,37583962091776,38194822598416,38813099360256
mul $0,10
add $0,6
pow $0,4
mov $1,$0
|
alloy4fun_models/trashltl/models/9/J7Gy7vQfRkk5Drim3.als | Kaixi26/org.alloytools.alloy | 0 | 2868 | open main
pred idJ7Gy7vQfRkk5Drim3_prop10 {
always all f:Protected | always f in Protected
}
pred __repair { idJ7Gy7vQfRkk5Drim3_prop10 }
check __repair { idJ7Gy7vQfRkk5Drim3_prop10 <=> prop10o } |
src/xen/amd64/hypercall_thunk.asm | omeg/winpv-xenbus | 5 | 92789 | <filename>src/xen/amd64/hypercall_thunk.asm
page ,132
title Hypercall Thunks
.code
extrn Hypercall:qword
; uintptr_t __stdcall hypercall2(uint32_t ord, uintptr_t arg1, uintptr_t arg2);
public hypercall2
hypercall2 proc
push rdi
push rsi
mov rdi, rdx ; arg1
mov rax, qword ptr [Hypercall]
shl rcx, 5 ; ord
add rax, rcx
mov rsi, r8 ; arg2
call rax
pop rsi
pop rdi
ret
hypercall2 endp
; uintptr_t __stdcall hypercall3(uint32_t ord, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3);
public hypercall3
hypercall3 proc
push rdi
push rsi
mov rdi, rdx ; arg1
mov rax, qword ptr [Hypercall]
shl rcx, 5 ; ord
add rax, rcx
mov rsi, r8 ; arg2
mov rdx, r9 ; arg3
call rax
pop rsi
pop rdi
ret
hypercall3 endp
end
|
src/ffi-c/src/mandelpng.adb | shintakezou/adaplayground | 0 | 24412 | --
-- for the Mandelbrot part, see
-- https://github.com/shintakezou/adaplayground/blob/master/src/mandel_utf.adb
--
-- Usage example:
-- ./mandelpng -2 -2 2 2
--
-- To build, gprbuild. It works on my machine! You need libpng lib and
-- headers.
--
-- Messy withs and uses; no idea if there's a better more idiomatic
-- way.
--
with
Ada.Numerics.Elementary_Functions,
Ada.Numerics.Generic_Complex_Types,
Ada.Unchecked_Deallocation;
use
Ada.Numerics.Elementary_Functions;
with
Interfaces.C,
Interfaces.C.Strings,
Interfaces.C.Pointers;
with PNGFunc_C;
with stdint_h; use stdint_h;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
procedure MandelPNG is
package C renames Interfaces.C;
package Complex_Types is new Ada.Numerics.Generic_Complex_Types (Float);
use Complex_Types;
-- Configuration constants.
Width : constant := 800;
Height : constant := 600;
Max_Iterations : constant := 32;
-- Returns the intensity of a single point in the Mandelbrot set.
function Render_Pixel (C : Complex) return Float is
Z : Complex := Complex'(0.0, 0.0);
begin
for N in Integer range 0 .. Max_Iterations loop
Z := Z*Z + C;
if (abs Z > 2.0) then
return Float (N) / Float (Max_Iterations);
end if;
end loop;
return 0.0;
end;
type Bitmap is array(Integer range <>, Integer range <>) of Float;
type Bitmap_Ref is access Bitmap;
procedure Free_Bitmap is new Ada.Unchecked_Deallocation
(Object => Bitmap, Name => Bitmap_Ref);
procedure Mandelbrot
(Data : Bitmap_Ref;
R1, I1, R2, I2 : Float)
is
Width : Integer := Data'Length (1);
Height : Integer := Data'Length (2);
Xdelta : Float := (R2-R1) / Float (Width);
Ydelta : Float := (I2-I1) / Float (Height);
I : Float;
C : Complex;
begin
Put_Line ("Width: " & Integer'Image (Width));
Put_Line ("Height: " & Integer'Image (Height));
Put_Line ("Xdelta: " & Float'Image (Xdelta));
Put_Line ("Ydelta: " & Float'Image (Ydelta));
for Y in Data'Range (2) loop
I := I1 + Float (Y) * Ydelta;
for X in Data'Range (1) loop
C := Complex'(R1 + Float (X) * Xdelta, I);
Data (X, Y) := Render_Pixel (C);
end loop;
end loop;
end;
procedure Dump_Bitmap(Data : Bitmap_Ref) is
subtype Buffer_Index is Integer range 0 .. 3 * Width * Height - 1;
type Buffer is array (Buffer_Index range <>) of aliased uint8_t
with
Component_Size => 8,
Convention => C;
type Buffer_Access is access all Buffer;
type RGB is record
Red, Green, Blue : uint8_t;
end record;
procedure To_RGB (V : in Float; D : out RGB) is
RR, GG, BB : Float;
begin
RR := 255.0 * V; GG := 255.0 * V; BB := 255.0 * V;
D.Red := uint8_t (RR);
D.Green := uint8_t (GG);
D.Blue := uint8_t (BB);
end To_RGB;
package Im is new C.Pointers (Index => Buffer_Index,
Element => uint8_t,
Element_Array => Buffer,
Default_Terminator => uint8_t'First);
R : C.int;
Image : aliased Buffer (Buffer_Index'Range);
The_Image : Im.Pointer := Image (0)'Access;
Vals : RGB;
begin
for Y in Data'Range (2) loop
for X in Data'Range (1) loop
To_RGB (Data (X, Y), Vals);
Image (3 * (Y * Width + X) + 0) := Vals.Red;
Image (3 * (Y * Width + X) + 1) := Vals.Green;
Image (3 * (Y * Width + X) + 2) := Vals.Blue;
end loop;
end loop;
R := PNGFunc_C.create_image (C.Strings.New_String ("out.png"),
Width,
Height,
The_Image);
if Integer (R) < 0 then
Put_Line (Standard_Error, "error writing image to file");
else
Put_Line ("file written");
end if;
end;
Image : Bitmap_Ref;
use Ada.Command_Line;
begin
if Argument_Count < 4 then
Put_Line (Standard_Error, "Usage: " &
Command_Name & " R1 I1 R2 I2");
else
declare
R1 : Float := Float'Value (Argument (1));
R2 : Float := Float'Value (Argument (3));
I1 : Float := Float'Value (Argument (2));
I2 : Float := Float'Value (Argument (4));
begin
Image := new Bitmap (0 .. Width - 1, 0 .. Height - 1);
Mandelbrot (Image, R1, I1, R2, I2);
Dump_Bitmap (Image);
Free_Bitmap (Image);
end;
end if;
end;
|
Tests/yasm-regression/loopadsz.asm | 13xforever/x86-assembly-textmate-bundle | 69 | 160362 | [bits 16]
foo: a32 loop foo ; out: 67 e2 fd
bar: loop bar, ecx ; out: 67 e2 fd
[bits 32]
baz: a16 loop baz ; out: 67 e2 fd
qux: loop qux, cx ; out: 67 e2 fd
|
oeis/001/A001786.asm | neoneye/loda-programs | 11 | 242998 | ; A001786: Expansion of 1/((1+x)(1-x)^11).
; Submitted by <NAME>
; 1,10,56,230,771,2232,5776,13672,30086,62292,122464,230252,416394,727672,1233584,2035176,3276559,5159726,7963384,12066626,17978389,26373776,38138464,54422576,76705564,106873832,147313024,201017112,271716644,364028752,483631776,637467632,833975341,1083359442,1397897336,1792289950,2284060471,2894006280,3646709616,4571112920,5701165250,7076546620,8743477600,10755622020,13175091150,16073558280,19533493200,23649526680,28529955675,34298400630,41095626936,49081543290,58437390441,69368134560,82105080256
mov $2,$0
add $2,1
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
add $0,10
bin $0,10
mul $4,-1
add $4,$0
lpe
mov $0,$4
|
Installer-main.scpt | chris1111/Show-Drive | 1 | 3827 | <reponame>chris1111/Show-Drive<filename>Installer-main.scpt<gh_stars>1-10
# Show Drive
# Copyright (c) 2021 chris1111
set theAction to button returned of (display dialog "
You have two choices, Install Show Drive or Uninstall it.
The Icon Status Bar will be on the bar each time you log in.
Click Install to install Show Drive in your Applications
============================
" with icon note cancel button "Quit" buttons {"Install", "Uninstall", "Quit"} default button {"Install"})
{"Install", "Uninstall"}
set source to path to me as string
set source to POSIX path of source & "Contents/Resources/PackageRoot/Show Drive.app"
set source to quoted form of source
--display dialog source
if theAction = "Install" then do shell script "cp -R " & source & " /Applications/'Show Drive.app'"
delay 2
if theAction = "Install" then tell application "System Events"
get full name of current user
make new login item at end of login items with properties ¬
{path:"/Applications/Show Drive.app"}
end tell
delay 1
if theAction = "Install" then do shell script "open -a /Applications/'Show Drive.app'"
if theAction = "Install" then
display dialog "Installation Show Drive done!" with icon note buttons "Done" default button "Done" giving up after 3
end if
if theAction = "Uninstall" then do shell script "killall -c 'Show Drive'"
if theAction = "Uninstall" then do shell script "rm -rf " & " /Applications/'Show Drive.app'"
if theAction = "Uninstall" then tell application "System Events" to delete login item "Show Drive"
if theAction = "Uninstall" then display dialog "Uninstall Show Drive done!" with icon note buttons "Done" default button "Done" giving up after 3
|
src/my_package.ads | thierr26/gnatdoc_test | 0 | 3190 | <gh_stars>0
package My_Package is
-- @summary
-- Test package.
--
subtype Count is Long_Long_Integer range 0 .. Long_Long_Integer'Last;
type Arr is array (Positive range <>) of Natural;
type Enum is (One, Two, Three);
----------------------------------------------------------------------------
function My_Function (A : Arr) return Boolean
with Post =>
My_Function'Result = (for all Z in A'Range => A(Z) = A(A'First));
-- @param A An array.
-- @return True if all array elements are equal, False otherwise.
----------------------------------------------------------------------------
type My_Interface is interface;
not overriding
function My_Primitive (Obj : in out My_Interface) return Count is abstract;
-- @param Obj My_Interface object.
-- @return Next term of the Fibonacci Sequence.
----------------------------------------------------------------------------
type My_Implementation is new My_Interface with private;
not overriding function Create return My_Implementation;
-- @return My_Implementation object.
overriding
function My_Primitive (Obj : in out My_Implementation) return Count;
-- @param Obj My_Implementation object.
-- @return Next term of the Fibonacci Sequence.
----------------------------------------------------------------------------
private
My_Package_Range_Error : exception;
type My_Implementation is new My_Interface with
record
K : Count := 0;
Prev_Prev_Term, Prev_Term : Count := 1;
end record;
end My_Package;
|
Library/Chart/CObject/cobjectBuild.asm | steakknife/pcgeos | 504 | 28017 | <reponame>steakknife/pcgeos
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: cobjectBuild.asm
AUTHOR: <NAME>
METHODS:
Name Description
---- -----------
FUNCTIONS:
Scope Name Description
----- ---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/24/92 Initial version.
DESCRIPTION:
$Id: cobjectBuild.asm,v 1.1 97/04/04 17:46:27 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ChartObjectBuild
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: If this object is newly built, then send a RECALC-SIZE
to the ChartGroup.
PASS: *ds:si = ChartObjectClass object
ds:di = ChartObjectClass instance data
es = Segment of ChartObjectClass.
RETURN: nothing
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/24/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ChartObjectBuild method dynamic ChartObjectClass,
MSG_CHART_OBJECT_BUILD
uses ax,cx
.enter
test ds:[di].COI_state, mask COS_BUILT
jnz done
; Built for the first time
ornf ds:[di].COI_state, mask COS_BUILT
mov cl, mask COS_IMAGE_INVALID or mask COS_GEOMETRY_INVALID
mov ax, MSG_CHART_OBJECT_MARK_INVALID
call ObjCallInstanceNoLock
done:
.leave
ret
ChartObjectBuild endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ChartObjectRelocate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Clear out the selection count on a read, because GrObj
documents are always unselected when first read, and
we're careful to keep chart objects from being
discarded when they're selected
PASS: *ds:si - ChartObjectClass object
ds:di - ChartObjectClass instance data
es - segment of ChartObjectClass
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 2/23/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ChartObjectRelocate method dynamic ChartObjectClass,
reloc
cmp dx, VMRT_RELOCATE_AFTER_READ
jne done
clr ds:[di].COI_selection
done:
mov di, offset ChartObjectClass
call ObjRelocOrUnRelocSuper
ret
ChartObjectRelocate endm
|
src/account.ads | xiashuangxi/coconut | 0 | 11437 | package Account is
end Account;
|
src/task/context_swap.asm | RandyLambert/LUTF | 5 | 23353 | <filename>src/task/context_swap.asm<gh_stars>1-10
[bits 64]
section .text
global context_swap
context_swap:
;交换任务上下文 context_swap(c_context, n_context); 保存当前上下文,切换next上下文
;rdi中存储的是c_context,rsi中存储的是n_context
;保存当前上下文
mov [rdi], r8
mov [rdi + 8*1], r9
mov [rdi + 8*2], r10
mov [rdi + 8*3], r11
mov [rdi + 8*4], r12
mov [rdi + 8*5], r13
mov [rdi + 8*6], r14
mov [rdi + 8*7], r15
mov [rdi + 8*8], rdi
mov [rdi + 8*9], rsi
mov [rdi + 8*10], rbp
mov [rdi + 8*11], rbx
mov [rdi + 8*12], rdx
mov [rdi + 8*13], rax
mov [rdi + 8*14], rcx
; mov [rdi + 8*15], rsp
mov rcx, [rsp]; [rsp] == rip
mov [rdi + 8*16], rcx ;[rdi + 8*16]存储rip的值,返回地址为下一次切换到该任务时的运行指令的地址
lea rcx, [rsp + 8];???
mov [rdi + 8*15], rcx ;下次切换到该任务时,栈的栈顶
;切换到next的上下文
;Load the next stack pointer and the preserved registers.
; mov rdi, rsi
mov r8, [rsi]
mov r9, [rsi + 8*1]
mov r10, [rsi + 8*2]
mov r11, [rsi + 8*3]
mov r12, [rsi + 8*4]
mov r13, [rsi + 8*5]
mov r14, [rsi + 8*6]
mov r15, [rsi + 8*7]
mov rdi, [rsi + 8*8]
;mov rsi, [rsi + 8*9]
mov rbp, [rsi + 8*10]
mov rbx, [rsi + 8*11]
mov rdx, [rsi + 8*12]
mov rax, [rsi + 8*13]
mov rsp, [rsi + 8*15] ;切换栈
mov rcx, [rsi + 8*16] ;rip的内容
push rcx
mov rcx, [rsi + 8*14]
mov rsi, [rsi + 8*9]
ret
; struct sigcontext
; {
; __uint64_t r8;
; __uint64_t r9;
; __uint64_t r10;
; __uint64_t r11;
; __uint64_t r12;
; __uint64_t r13;
; __uint64_t r14;
; __uint64_t r15;
; __uint64_t rdi;
; __uint64_t rsi;
; __uint64_t rbp;
; __uint64_t rbx;
; __uint64_t rdx;
; __uint64_t rax;
; __uint64_t rcx;
; __uint64_t rsp;
; __uint64_t rip;
; __uint64_t eflags;
; unsigned short cs;
; unsigned short gs;
; unsigned short fs;
; unsigned short __pad0;
; __uint64_t err;
; __uint64_t trapno;
; __uint64_t oldmask;
; __uint64_t cr2;
; __extension__ union
; {
; struct _fpstate * fpstate;
; __uint64_t __fpstate_word;
; };
; __uint64_t __reserved1 [8];
; };
|
nes-test-roms/mmc3_irq_tests/source/runtime_swapcart.asm | joebentley/ones | 1,461 | 5424 | <gh_stars>1000+
.include "delays.a"
.include "serial.a"
.include "debug.a"
.include "ppu_util.a"
debug_newline:
lda #13
debug_char:
debug_char_no_wait:
jmp serial_write
.code
init_runtime:
rts
.code
forever:
jmp $0700
.code
.default main = reset
.org $fffa
.dw nmi
.dw main
.dw irq
|
test/fail/ATPBadType1.agda | asr/eagda | 1 | 1699 | -- An ATP type must be used with data-types or postulates.
-- This error is detected by Syntax.Translation.ConcreteToAbstract.
module ATPBadType1 where
data Bool : Set where
false true : Bool
{-# ATP type false #-}
|
oeis/329/A329178.asm | neoneye/loda-programs | 11 | 242227 | <gh_stars>10-100
; A329178: Sum of the products of pairs of Padovan numbers which are two apart, starting from A000931(5).
; Submitted by <NAME>
; 1,3,5,11,19,34,62,107,191,335,587,1035,1812,3184,5589,9803,17213,30199,52999,93014,163214,286439,502655,882095,1547991,2716503,4767160,8365776,14680889,25763219,45211237,79340227,139232411,244335770,428779502,752455475
mov $3,2
mov $4,$0
lpb $3
mov $0,$4
add $1,1
sub $3,1
add $0,$3
add $0,2
seq $0,134816 ; Padovan's spiral numbers.
sub $0,1
add $2,1
mul $2,$0
add $1,$2
lpe
mov $0,$1
sub $0,2
|
src/crafts.adb | thindil/steamsky | 80 | 10902 | <reponame>thindil/steamsky
-- Copyright 2016-2021 <NAME>
--
-- This file is part of Steam Sky.
--
-- Steam Sky is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- Steam Sky 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 General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Steam Sky. If not, see <http://www.gnu.org/licenses/>.
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with DOM.Core; use DOM.Core;
with DOM.Core.Documents;
with DOM.Core.Nodes; use DOM.Core.Nodes;
with DOM.Core.Elements; use DOM.Core.Elements;
with Messages; use Messages;
with Ships.Cargo; use Ships.Cargo;
with Ships.Crew; use Ships.Crew;
with Crew; use Crew;
with Crew.Inventory; use Crew.Inventory;
with Items; use Items;
with Statistics; use Statistics;
with Log; use Log;
with Goals; use Goals;
with Trades; use Trades;
package body Crafts is
procedure LoadRecipes(Reader: Tree_Reader) is
TempRecord: Craft_Data;
TempMaterials: UnboundedString_Container.Vector;
TempAmount: Positive_Container.Vector;
RecipesData: Document;
NodesList, ChildNodes: Node_List;
Amount, DeleteIndex: Natural;
RecipeIndex, ItemIndex, Value: Unbounded_String;
RecipeNode, ChildNode: Node;
MaterialAdded: Boolean;
Action: Data_Action;
SkillIndex: Skills_Container.Extended_Index;
begin
RecipesData := Get_Tree(Reader);
NodesList :=
DOM.Core.Documents.Get_Elements_By_Tag_Name(RecipesData, "recipe");
Load_Recipes_Loop :
for I in 0 .. Length(NodesList) - 1 loop
TempRecord :=
(MaterialTypes => TempMaterials, MaterialAmounts => TempAmount,
ResultIndex => Null_Unbounded_String, ResultAmount => 10_000,
Workplace => ALCHEMY_LAB, Skill => 1, Time => 15, Difficulty => 1,
Tool => To_Unbounded_String("None"), Reputation => -100,
ToolQuality => 100);
RecipeNode := Item(NodesList, I);
RecipeIndex :=
To_Unbounded_String(Get_Attribute(RecipeNode, "index"));
Action :=
(if Get_Attribute(RecipeNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(RecipeNode, "action"))
else ADD);
if Action in UPDATE | REMOVE then
if not Recipes_Container.Contains(Recipes_List, RecipeIndex) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" recipe '" & To_String(RecipeIndex) &
"', there is no recipe with that index.";
end if;
elsif Recipes_Container.Contains(Recipes_List, RecipeIndex) then
raise Data_Loading_Error
with "Can't add recipe '" & To_String(RecipeIndex) &
"', there is already a recipe with that index.";
end if;
if Action /= REMOVE then
if Action = UPDATE then
TempRecord := Recipes_List(RecipeIndex);
end if;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name
(RecipeNode, "material");
Read_Materials_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
Amount := Natural'Value(Get_Attribute(ChildNode, "amount"));
Value := To_Unbounded_String(Get_Attribute(ChildNode, "type"));
if Amount > 0 then
MaterialAdded := False;
Check_Added_Materials_Loop :
for K in
TempRecord.MaterialTypes.First_Index ..
TempRecord.MaterialTypes.Last_Index loop
if TempRecord.MaterialTypes(K) = Value then
TempRecord.MaterialAmounts(K) := Amount;
MaterialAdded := True;
exit Check_Added_Materials_Loop;
end if;
end loop Check_Added_Materials_Loop;
if not MaterialAdded then
TempRecord.MaterialTypes.Append(New_Item => Value);
TempRecord.MaterialAmounts.Append(New_Item => Amount);
end if;
else
DeleteIndex := TempRecord.MaterialTypes.First_Index;
Delete_Materials_Loop :
while DeleteIndex <= TempRecord.MaterialTypes.Last_Index loop
if TempRecord.MaterialTypes(DeleteIndex) = Value then
TempRecord.MaterialTypes.Delete(Index => DeleteIndex);
exit Delete_Materials_Loop;
end if;
DeleteIndex := DeleteIndex + 1;
end loop Delete_Materials_Loop;
end if;
end loop Read_Materials_Loop;
Value := To_Unbounded_String(Get_Attribute(RecipeNode, "result"));
if Value /= Null_Unbounded_String then
ItemIndex := Value;
if ItemIndex = Null_Unbounded_String then
raise Data_Loading_Error
with "Can't add recipe '" & To_String(RecipeIndex) &
"', result item index '" & To_String(Value) &
"' does't exist.";
end if;
TempRecord.ResultIndex := ItemIndex;
end if;
Value := To_Unbounded_String(Get_Attribute(RecipeNode, "crafted"));
if Value /= Null_Unbounded_String then
TempRecord.ResultAmount := Positive'Value(To_String(Value));
end if;
Value :=
To_Unbounded_String(Get_Attribute(RecipeNode, "workplace"));
if Value /= Null_Unbounded_String then
TempRecord.Workplace := ModuleType'Value(To_String(Value));
end if;
Value := To_Unbounded_String(Get_Attribute(RecipeNode, "skill"));
if Value /= Null_Unbounded_String then
SkillIndex := Find_Skill_Index(To_String(Value));
if SkillIndex = 0 then
raise Data_Loading_Error
with "Can't add recipe '" & To_String(RecipeIndex) &
"', no skill named '" & To_String(Value) & "'";
end if;
TempRecord.Skill := SkillIndex;
end if;
if Get_Attribute(RecipeNode, "time") /= "" then
TempRecord.Time :=
Positive'Value(Get_Attribute(RecipeNode, "time"));
end if;
if Get_Attribute(RecipeNode, "difficulty") /= "" then
TempRecord.Difficulty :=
Positive'Value(Get_Attribute(RecipeNode, "difficulty"));
end if;
if Get_Attribute(RecipeNode, "tool") /= "" then
TempRecord.Tool :=
To_Unbounded_String(Get_Attribute(RecipeNode, "tool"));
end if;
Value :=
To_Unbounded_String(Get_Attribute(RecipeNode, "reputation"));
if Value /= Null_Unbounded_String then
TempRecord.Reputation := Integer'Value(To_String(Value));
end if;
Value :=
To_Unbounded_String(Get_Attribute(RecipeNode, "toolquality"));
if Value /= Null_Unbounded_String then
TempRecord.ToolQuality := Positive'Value(To_String(Value));
end if;
if Action /= UPDATE then
Recipes_Container.Include
(Recipes_List, RecipeIndex, TempRecord);
Log_Message
("Recipe added: " &
To_String(Items_List(TempRecord.ResultIndex).Name),
EVERYTHING);
else
Recipes_List(RecipeIndex) := TempRecord;
Log_Message
("Recipe updated: " &
To_String(Items_List(TempRecord.ResultIndex).Name),
EVERYTHING);
end if;
else
Recipes_Container.Exclude(Recipes_List, RecipeIndex);
Log_Message
("Recipe removed: " & To_String(RecipeIndex), EVERYTHING);
end if;
end loop Load_Recipes_Loop;
end LoadRecipes;
function SetRecipeData(RecipeIndex: Unbounded_String) return Craft_Data is
Recipe: Craft_Data;
ItemIndex: Unbounded_String;
begin
if Length(RecipeIndex) > 6
and then Slice(RecipeIndex, 1, 5) = "Study" then
ItemIndex := Unbounded_Slice(RecipeIndex, 7, Length(RecipeIndex));
Recipe.MaterialTypes.Append(New_Item => Items_List(ItemIndex).IType);
Recipe.MaterialAmounts.Append(New_Item => 1);
Recipe.ResultIndex := ItemIndex;
Recipe.ResultAmount := 0;
Recipe.Workplace := ALCHEMY_LAB;
Set_Recipe_Skill_Loop :
for ProtoRecipe of Recipes_List loop
if ProtoRecipe.ResultIndex = Recipe.ResultIndex then
Recipe.Skill := ProtoRecipe.Skill;
Recipe.Time := ProtoRecipe.Difficulty * 15;
exit Set_Recipe_Skill_Loop;
end if;
end loop Set_Recipe_Skill_Loop;
Recipe.Difficulty := 1;
Recipe.Tool := Alchemy_Tools;
Recipe.ToolQuality := 100;
return Recipe;
elsif Length(RecipeIndex) > 12
and then Slice(RecipeIndex, 1, 11) = "Deconstruct" then
ItemIndex := Unbounded_Slice(RecipeIndex, 13, Length(RecipeIndex));
Recipe.MaterialTypes.Append(New_Item => Items_List(ItemIndex).IType);
Recipe.MaterialAmounts.Append(New_Item => 1);
Recipe.Workplace := ALCHEMY_LAB;
Set_Recipe_Data_Loop :
for ProtoRecipe of Recipes_List loop
if ProtoRecipe.ResultIndex = ItemIndex then
Recipe.Skill := ProtoRecipe.Skill;
Recipe.Time := ProtoRecipe.Difficulty * 15;
Recipe.Difficulty := ProtoRecipe.Difficulty;
Recipe.ResultIndex :=
FindProtoItem(ProtoRecipe.MaterialTypes(1));
Recipe.ResultAmount :=
Positive
(Float'Ceiling
(Float(ProtoRecipe.MaterialAmounts.Element(1)) * 0.8));
if Recipe.ResultAmount = ProtoRecipe.MaterialAmounts(1) then
Recipe.ResultAmount := Recipe.ResultAmount - 1;
end if;
exit Set_Recipe_Data_Loop;
end if;
end loop Set_Recipe_Data_Loop;
Recipe.Tool := Alchemy_Tools;
Recipe.ToolQuality := 100;
return Recipe;
end if;
return Recipes_List(RecipeIndex);
end SetRecipeData;
function CheckRecipe(RecipeIndex: Unbounded_String) return Positive is
Recipe: Craft_Data;
MaterialIndexes: Positive_Container.Vector;
RecipeName: Unbounded_String;
MaxAmount: Positive := Positive'Last;
MType: ModuleType;
begin
Recipe := SetRecipeData(RecipeIndex);
if Length(RecipeIndex) > 6
and then Slice(RecipeIndex, 1, 5) = "Study" then
RecipeName :=
To_Unbounded_String("studying ") &
Items_List(Unbounded_Slice(RecipeIndex, 7, Length(RecipeIndex)))
.Name;
MType := ALCHEMY_LAB;
elsif Length(RecipeIndex) > 12
and then Slice(RecipeIndex, 1, 11) = "Deconstruct" then
RecipeName :=
To_Unbounded_String("deconstructing ") &
Items_List(Unbounded_Slice(RecipeIndex, 13, Length(RecipeIndex)))
.Name;
MType := ALCHEMY_LAB;
else
RecipeName :=
To_Unbounded_String("manufacturing ") &
Items_List(Recipe.ResultIndex).Name;
MType := Recipes_List(RecipeIndex).Workplace;
end if;
-- Check for workshop
declare
HaveWorkshop: Boolean := False;
begin
Check_For_Workshop_Loop :
for Module of Player_Ship.Modules loop
if Modules_List(Module.Proto_Index).MType = MType and
Module.Durability > 0 then
HaveWorkshop := True;
exit Check_For_Workshop_Loop;
end if;
end loop Check_For_Workshop_Loop;
if not HaveWorkshop then
raise Crafting_No_Workshop with To_String(RecipeName);
end if;
end;
-- Check for materials
if Length(RecipeIndex) > 6
and then Slice(RecipeIndex, 1, 5) = "Study" then
Study_Materials_Loop :
for I in Player_Ship.Cargo.Iterate loop
if Items_List(Player_Ship.Cargo(I).ProtoIndex).Name =
Items_List(Recipe.ResultIndex).Name then
MaterialIndexes.Append
(New_Item => Inventory_Container.To_Index(I));
exit Study_Materials_Loop;
end if;
end loop Study_Materials_Loop;
MaxAmount := 1;
elsif Length(RecipeIndex) > 12
and then Slice(RecipeIndex, 1, 11) = "Deconstruct" then
Deconstruct_Materials_Loop :
for I in Player_Ship.Cargo.Iterate loop
if Player_Ship.Cargo(I).ProtoIndex =
Unbounded_Slice(RecipeIndex, 13, Length(RecipeIndex)) then
MaterialIndexes.Append
(New_Item => Inventory_Container.To_Index(I));
MaxAmount := Player_Ship.Cargo(I).Amount;
exit Deconstruct_Materials_Loop;
end if;
end loop Deconstruct_Materials_Loop;
else
Find_Materials_Loop :
for J in Recipe.MaterialTypes.Iterate loop
Check_Player_Cargo_Loop :
for I in Player_Ship.Cargo.Iterate loop
if Items_List(Player_Ship.Cargo(I).ProtoIndex).IType =
Recipe.MaterialTypes(J) and
Player_Ship.Cargo(I).Amount >=
Recipe.MaterialAmounts
(UnboundedString_Container.To_Index(J)) then
MaterialIndexes.Append
(New_Item => Inventory_Container.To_Index(I));
if MaxAmount >
Player_Ship.Cargo(I).Amount /
Recipe.MaterialAmounts
(UnboundedString_Container.To_Index(J)) then
MaxAmount :=
Player_Ship.Cargo(I).Amount /
Recipe.MaterialAmounts
(UnboundedString_Container.To_Index(J));
end if;
exit Check_Player_Cargo_Loop;
end if;
end loop Check_Player_Cargo_Loop;
end loop Find_Materials_Loop;
end if;
if MaterialIndexes.Length < Recipe.MaterialTypes.Length then
raise Crafting_No_Materials with To_String(RecipeName);
end if;
-- Check for tool
declare
HaveTool: Boolean := False;
begin
if Recipe.Tool /= To_Unbounded_String("None")
and then
FindItem
(Inventory => Player_Ship.Cargo, ItemType => Recipe.Tool,
Quality => Recipe.ToolQuality) >
0 then
HaveTool := True;
elsif Recipe.Tool = To_Unbounded_String("None") then
HaveTool := True;
end if;
if not HaveTool then
raise Crafting_No_Tools with To_String(RecipeName);
end if;
end;
-- Check for free space
declare
SpaceNeeded: Integer := 0;
begin
Count_Needed_Space_Loop :
for I in MaterialIndexes.Iterate loop
SpaceNeeded :=
SpaceNeeded +
Items_List(Player_Ship.Cargo(MaterialIndexes(I)).ProtoIndex)
.Weight *
Recipe.MaterialAmounts(Positive_Container.To_Index(I));
end loop Count_Needed_Space_Loop;
if FreeCargo
(SpaceNeeded -
(Items_List(Recipe.ResultIndex).Weight * Recipe.ResultAmount)) <
0 then
raise Trade_No_Free_Cargo;
end if;
end;
return MaxAmount;
end CheckRecipe;
procedure Manufacturing(Minutes: Positive) is
ResultAmount, CraftedAmount, GainedExp: Natural := 0;
Amount, NewAmount: Integer := 0;
Recipe: Craft_Data;
MaterialIndexes: UnboundedString_Container.Vector;
WorkTime, CurrentMinutes, RecipeTime: Integer;
Damage: Damage_Factor := 0.0;
RecipeName: Unbounded_String;
HaveMaterial: Boolean;
CraftingMaterial: Natural;
CrafterIndex: Crew_Container.Extended_Index;
CargoIndex, ToolIndex: Inventory_Container.Extended_Index;
procedure ResetOrder(Module: in out Module_Data; ModuleOwner: Natural) is
HaveWorker: Boolean := False;
begin
if ToolIndex in
Player_Ship.Crew(CrafterIndex).Inventory.First_Index ..
Player_Ship.Crew(CrafterIndex).Inventory.Last_Index then
UpdateCargo
(Player_Ship,
Player_Ship.Crew(CrafterIndex).Inventory(ToolIndex).ProtoIndex,
1,
Player_Ship.Crew(CrafterIndex).Inventory(ToolIndex).Durability);
UpdateInventory
(MemberIndex => CrafterIndex, Amount => -1,
InventoryIndex => ToolIndex);
end if;
Check_Owner_Loop :
for Owner of Module.Owner loop
if Owner = ModuleOwner or ModuleOwner = 0 then
if Owner in
Player_Ship.Crew.First_Index ..
Player_Ship.Crew.Last_Index then
GiveOrders(Player_Ship, Owner, Rest);
end if;
Owner := 0;
end if;
if Owner > 0 then
HaveWorker := True;
end if;
end loop Check_Owner_Loop;
if not HaveWorker then
Module.Crafting_Index := Null_Unbounded_String;
Module.Crafting_Time := 0;
Module.Crafting_Amount := 0;
end if;
end ResetOrder;
begin
Modules_Loop :
for Module of Player_Ship.Modules loop
if Module.M_Type /= WORKSHOP then
goto End_Of_Loop;
end if;
if Module.Crafting_Index = Null_Unbounded_String then
goto End_Of_Loop;
end if;
Owners_Loop :
for Owner of Module.Owner loop
if Owner = 0 then
goto End_Of_Owners_Loop;
end if;
CrafterIndex := Owner;
if Player_Ship.Crew(CrafterIndex).Order = Craft then
CurrentMinutes := Minutes;
RecipeTime := Module.Crafting_Time;
Recipe := SetRecipeData(Module.Crafting_Index);
if Length(Module.Crafting_Index) > 6
and then Slice(Module.Crafting_Index, 1, 5) = "Study" then
RecipeName :=
To_Unbounded_String("studying ") &
Items_List(Recipe.ResultIndex).Name;
elsif Length(Module.Crafting_Index) > 12
and then Slice(Module.Crafting_Index, 1, 11) =
"Deconstruct" then
RecipeName :=
To_Unbounded_String("deconstructing ") &
Items_List
(Unbounded_Slice
(Module.Crafting_Index, 13,
Length(Module.Crafting_Index)))
.Name;
else
RecipeName :=
To_Unbounded_String("manufacturing ") &
Items_List(Recipe.ResultIndex).Name;
end if;
if Module.Durability = 0 then
AddMessage
(To_String(Module.Name) & " is destroyed, so " &
To_String(Player_Ship.Crew(CrafterIndex).Name) &
" can't work on " & To_String(RecipeName) & ".",
CraftMessage, RED);
ResetOrder(Module, Owner);
CurrentMinutes := 0;
end if;
WorkTime := Player_Ship.Crew(CrafterIndex).OrderTime;
CraftedAmount := 0;
Craft_Loop :
while CurrentMinutes > 0 loop
if CurrentMinutes < RecipeTime then
RecipeTime := RecipeTime - CurrentMinutes;
WorkTime := WorkTime - CurrentMinutes;
CurrentMinutes := 0;
goto End_Of_Craft_Loop;
end if;
RecipeTime := RecipeTime - CurrentMinutes;
WorkTime := WorkTime - CurrentMinutes;
CurrentMinutes := 0;
CurrentMinutes := CurrentMinutes - RecipeTime;
WorkTime := WorkTime - RecipeTime;
RecipeTime := Recipe.Time;
MaterialIndexes.Clear;
if Length(Module.Crafting_Index) > 6
and then Slice(Module.Crafting_Index, 1, 5) = "Study" then
Study_Materials_Loop :
for J in Items_List.Iterate loop
if Items_List(J).Name =
Items_List(Recipe.ResultIndex).Name then
MaterialIndexes.Append
(New_Item => Objects_Container.Key(J));
exit Study_Materials_Loop;
end if;
end loop Study_Materials_Loop;
elsif Length(Module.Crafting_Index) > 12
and then Slice(Module.Crafting_Index, 1, 11) =
"Deconstruct" then
MaterialIndexes.Append
(New_Item =>
Unbounded_Slice
(Module.Crafting_Index, 13,
Length(Module.Crafting_Index)));
else
Recipe_Loop :
for K in Recipe.MaterialTypes.Iterate loop
Materials_Loop :
for J in Items_List.Iterate loop
if Items_List(J).IType =
Recipe.MaterialTypes
(UnboundedString_Container.To_Index(K)) then
MaterialIndexes.Append
(New_Item => Objects_Container.Key(J));
exit Materials_Loop;
end if;
end loop Materials_Loop;
end loop Recipe_Loop;
end if;
CraftingMaterial := 0;
Check_Materials_Loop :
for MaterialIndex of MaterialIndexes loop
CraftingMaterial :=
FindItem
(Player_Ship.Cargo,
ItemType => Items_List(MaterialIndex).IType);
if CraftingMaterial = 0 then
AddMessage
("You don't have the crafting materials for " &
To_String(RecipeName) & ".",
CraftMessage, RED);
ResetOrder(Module, Owner);
exit Craft_Loop;
elsif Player_Ship.Cargo(CraftingMaterial).ProtoIndex /=
MaterialIndex then
MaterialIndex :=
Player_Ship.Cargo(CraftingMaterial).ProtoIndex;
end if;
end loop Check_Materials_Loop;
if Recipe.Tool /= To_Unbounded_String("None") then
ToolIndex :=
FindTools
(CrafterIndex, Recipe.Tool, Craft,
Recipe.ToolQuality);
if ToolIndex = 0 then
AddMessage
("You don't have the tool for " &
To_String(RecipeName) & ".",
CraftMessage, RED);
ResetOrder(Module, Owner);
exit Craft_Loop;
end if;
else
ToolIndex := 0;
end if;
Amount := 0;
Count_Amount_Loop :
for J in MaterialIndexes.Iterate loop
Amount :=
Amount +
Items_List(MaterialIndexes(J)).Weight *
Recipe.MaterialAmounts
(UnboundedString_Container.To_Index(J));
end loop Count_Amount_Loop;
ResultAmount :=
Recipe.ResultAmount +
Integer
(Float'Floor
(Float(Recipe.ResultAmount) *
(Float
(GetSkillLevel
(Player_Ship.Crew(CrafterIndex),
Recipe.Skill)) /
100.0)));
Damage :=
1.0 -
Damage_Factor
(Float(Module.Durability) /
Float(Module.Max_Durability));
ResultAmount :=
ResultAmount -
Natural(Float(ResultAmount) * Float(Damage));
if ResultAmount = 0 then
ResultAmount := 1;
end if;
Check_Enough_Materials_Loop :
for J in MaterialIndexes.Iterate loop
HaveMaterial := False;
Check_Cargo_Materials_Loop :
for Item of Player_Ship.Cargo loop
if Items_List(Item.ProtoIndex).IType =
Items_List(MaterialIndexes(J)).IType and
Item.Amount >=
Recipe.MaterialAmounts
(UnboundedString_Container.To_Index(J)) then
HaveMaterial := True;
exit Check_Cargo_Materials_Loop;
end if;
end loop Check_Cargo_Materials_Loop;
exit Check_Enough_Materials_Loop when not HaveMaterial;
end loop Check_Enough_Materials_Loop;
if not HaveMaterial then
AddMessage
("You don't have enough crafting materials for " &
To_String(RecipeName) & ".",
CraftMessage, RED);
ResetOrder(Module, Owner);
exit Craft_Loop;
end if;
CraftedAmount := CraftedAmount + ResultAmount;
Module.Crafting_Amount := Module.Crafting_Amount - 1;
Remove_Materials_Loop :
for J in MaterialIndexes.Iterate loop
CargoIndex := 1;
Remove_Materials_From_Cargo_Loop :
while CargoIndex <= Player_Ship.Cargo.Last_Index loop
if Items_List(Player_Ship.Cargo(CargoIndex).ProtoIndex)
.IType =
Items_List(MaterialIndexes(J)).IType then
if Player_Ship.Cargo(CargoIndex).Amount >
Recipe.MaterialAmounts
(UnboundedString_Container.To_Index(J)) then
NewAmount :=
Player_Ship.Cargo(CargoIndex).Amount -
Recipe.MaterialAmounts
(UnboundedString_Container.To_Index(J));
Player_Ship.Cargo(CargoIndex).Amount :=
NewAmount;
exit Remove_Materials_From_Cargo_Loop;
elsif Player_Ship.Cargo(CargoIndex).Amount =
Recipe.MaterialAmounts
(UnboundedString_Container.To_Index(J)) then
Player_Ship.Cargo.Delete
(Index => CargoIndex, Count => 1);
if ToolIndex > CargoIndex then
ToolIndex := ToolIndex - 1;
end if;
exit Remove_Materials_From_Cargo_Loop;
end if;
end if;
CargoIndex := CargoIndex + 1;
end loop Remove_Materials_From_Cargo_Loop;
end loop Remove_Materials_Loop;
if ToolIndex > 0 then
DamageItem
(Player_Ship.Crew(CrafterIndex).Inventory, ToolIndex,
GetSkillLevel
(Player_Ship.Crew(CrafterIndex), Recipe.Skill),
CrafterIndex);
end if;
if Length(Module.Crafting_Index) < 6
or else
(Length(Module.Crafting_Index) > 6
and then Slice(Module.Crafting_Index, 1, 5) /=
"Study") then
Amount :=
Amount -
(Items_List(Recipe.ResultIndex).Weight * ResultAmount);
if FreeCargo(Amount) < 0 then
AddMessage
("You don't have the free cargo space for " &
To_String(RecipeName) & ".",
CraftMessage, RED);
ResetOrder(Module, Owner);
exit Craft_Loop;
end if;
if Length(Module.Crafting_Index) > 11
and then Slice(Module.Crafting_Index, 1, 11) =
"Deconstruct" then
UpdateCargo
(Player_Ship, Recipe.ResultIndex, ResultAmount);
else
UpdateCargo
(Player_Ship,
Recipes_List(Module.Crafting_Index).ResultIndex,
ResultAmount);
end if;
Update_Crafting_Orders_Loop :
for I in Recipes_List.Iterate loop
if Recipes_List(I).ResultIndex =
Recipe.ResultIndex then
UpdateCraftingOrders(Recipes_Container.Key(I));
exit Update_Crafting_Orders_Loop;
end if;
end loop Update_Crafting_Orders_Loop;
else
Learn_Recipe_Loop :
for I in Recipes_List.Iterate loop
if Recipes_List(I).ResultIndex =
Recipe.ResultIndex then
Known_Recipes.Append
(New_Item => Recipes_Container.Key(I));
exit Learn_Recipe_Loop;
end if;
end loop Learn_Recipe_Loop;
exit Craft_Loop;
end if;
exit Craft_Loop when Module.Crafting_Amount = 0;
<<End_Of_Craft_Loop>>
end loop Craft_Loop;
Module.Crafting_Time := RecipeTime;
if CraftedAmount > 0 then
if Recipe.ResultAmount > 0 then
if Length(Module.Crafting_Index) > 12
and then Slice(Module.Crafting_Index, 1, 11) =
"Deconstruct" then
AddMessage
(To_String(Player_Ship.Crew(CrafterIndex).Name) &
" has recovered" & Integer'Image(CraftedAmount) &
" " &
To_String(Items_List(Recipe.ResultIndex).Name) &
".",
CraftMessage, GREEN);
else
AddMessage
(To_String(Player_Ship.Crew(CrafterIndex).Name) &
" has manufactured" & Integer'Image(CraftedAmount) &
" " &
To_String(Items_List(Recipe.ResultIndex).Name) &
".",
CraftMessage, GREEN);
end if;
Update_Goal_Loop :
for I in Recipes_List.Iterate loop
if Recipes_List(I).ResultIndex =
Recipe.ResultIndex then
UpdateGoal
(CRAFT, Recipes_Container.Key(I), CraftedAmount);
exit Update_Goal_Loop;
end if;
end loop Update_Goal_Loop;
if CurrentGoal.TargetIndex /= Null_Unbounded_String then
UpdateGoal
(CRAFT, Items_List(Recipe.ResultIndex).IType,
CraftedAmount);
if Items_List(Recipe.ResultIndex).ShowType /=
Null_Unbounded_String then
UpdateGoal
(CRAFT, Items_List(Recipe.ResultIndex).ShowType,
CraftedAmount);
end if;
end if;
else
AddMessage
(To_String(Player_Ship.Crew(CrafterIndex).Name) &
" has discovered recipe for " &
To_String(Items_List(Recipe.ResultIndex).Name) & ".",
CraftMessage, GREEN);
UpdateGoal(CRAFT, Null_Unbounded_String);
end if;
end if;
if Player_Ship.Crew(CrafterIndex).Order = Craft then
Update_Work_Time_Loop :
while WorkTime <= 0 loop
GainedExp := GainedExp + 1;
WorkTime := WorkTime + 15;
end loop Update_Work_Time_Loop;
if GainedExp > 0 then
GainExp(GainedExp, Recipe.Skill, CrafterIndex);
end if;
Player_Ship.Crew(CrafterIndex).OrderTime := WorkTime;
if Module.Crafting_Amount = 0 then
ResetOrder(Module, Owner);
end if;
end if;
end if;
<<End_Of_Owners_Loop>>
end loop Owners_Loop;
<<End_Of_Loop>>
end loop Modules_Loop;
exception
when An_Exception : Crew_No_Space_Error =>
AddMessage(Exception_Message(An_Exception), OrderMessage, RED);
GiveOrders(Player_Ship, CrafterIndex, Rest);
end Manufacturing;
procedure SetRecipe
(Workshop, Amount: Positive; RecipeIndex: Unbounded_String) is
RecipeName, ItemIndex: Unbounded_String;
begin
Player_Ship.Modules(Workshop).Crafting_Amount := Amount;
if Length(RecipeIndex) > 6
and then Slice(RecipeIndex, 1, 5) = "Study" then
ItemIndex := Unbounded_Slice(RecipeIndex, 7, Length(RecipeIndex));
Set_Study_Difficulty_Loop :
for ProtoRecipe of Recipes_List loop
if ProtoRecipe.ResultIndex = ItemIndex then
Player_Ship.Modules(Workshop).Crafting_Time :=
ProtoRecipe.Difficulty * 15;
exit Set_Study_Difficulty_Loop;
end if;
end loop Set_Study_Difficulty_Loop;
RecipeName :=
To_Unbounded_String("Studying ") & Items_List(ItemIndex).Name;
Player_Ship.Modules(Workshop).Crafting_Index := RecipeIndex;
elsif Length(RecipeIndex) > 12
and then Slice(RecipeIndex, 1, 11) = "Deconstruct" then
ItemIndex := Unbounded_Slice(RecipeIndex, 13, Length(RecipeIndex));
Set_Deconstruct_Difficulty_Loop :
for ProtoRecipe of Recipes_List loop
if ProtoRecipe.ResultIndex = ItemIndex then
Player_Ship.Modules(Workshop).Crafting_Time :=
ProtoRecipe.Difficulty * 15;
exit Set_Deconstruct_Difficulty_Loop;
end if;
end loop Set_Deconstruct_Difficulty_Loop;
RecipeName :=
To_Unbounded_String("Deconstructing ") & Items_List(ItemIndex).Name;
Player_Ship.Modules(Workshop).Crafting_Index := RecipeIndex;
else
Player_Ship.Modules(Workshop).Crafting_Index := RecipeIndex;
Player_Ship.Modules(Workshop).Crafting_Time :=
Recipes_List(RecipeIndex).Time;
RecipeName := Items_List(Recipes_List(RecipeIndex).ResultIndex).Name;
end if;
AddMessage
(To_String(RecipeName) & " was set as manufacturing order in " &
To_String(Player_Ship.Modules(Workshop).Name) & ".",
CraftMessage);
UpdateOrders(Player_Ship);
end SetRecipe;
end Crafts;
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/ce/ce3410c.ada | best08618/asylo | 7 | 24386 | -- CE3410C.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT SET_LINE SETS THE CURRENT LINE NUMBER TO THE VALUE
-- SPECIFIED BY TO FOR FILES OF MODES IN_FILE AND OUT_FILE.
-- CHECK THAT IT HAS NO EFFECT IF THE VALUE SPECIFIED BY TO IS
-- EQUAL TO THE CURRENT LINE NUMBER FOR BOTH IN_FILE AND OUT_FILE.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH SUPPORT
-- TEXT FILES.
-- HISTORY:
-- ABW 08/26/82
-- SPS 09/20/82
-- JBG 01/27/83
-- EG 05/22/85
-- TBN 11/10/86 REVISED TEST TO OUTPUT A NOT_APPLICABLE
-- RESULT WHEN FILES ARE NOT SUPPORTED.
-- JLH 09/01/87 REMOVED DEPENDENCE ON RESET, ADDED MORE TEST
-- CASES, AND CHECKED FOR USE_ERROR ON DELETE.
-- JRL 02/29/96 Added File parameter to call to Set_Page_Length.
WITH REPORT; USE REPORT;
WITH TEXT_IO; USE TEXT_IO;
WITH CHECK_FILE;
PROCEDURE CE3410C IS
INCOMPLETE : EXCEPTION;
BEGIN
TEST ("CE3410C", "CHECK THAT SET_LINE SETS LINE " &
"NUMBER CORRECTLY");
DECLARE
FILE : FILE_TYPE;
CHAR : CHARACTER := ('C');
ITEM_CHAR : CHARACTER;
ONE : POSITIVE_COUNT := POSITIVE_COUNT (IDENT_INT(1));
TWO : POSITIVE_COUNT := POSITIVE_COUNT (IDENT_INT(2));
THREE : POSITIVE_COUNT := POSITIVE_COUNT (IDENT_INT(3));
FOUR : POSITIVE_COUNT := POSITIVE_COUNT (IDENT_INT(4));
BEGIN
BEGIN
CREATE (FILE, OUT_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED ON TEXT CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED ON TEXT " &
"CREATE WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED ON TEXT " &
"CREATE");
RAISE INCOMPLETE;
END;
SET_LINE (FILE, FOUR);
IF LINE (FILE) /= FOUR THEN
FAILED ("FOR OUT_FILE LINE NOT FOUR");
ELSE
PUT (FILE, 'C');
NEW_LINE (FILE);
SET_LINE (FILE, 5);
IF LINE (FILE) /= FOUR+1 THEN
FAILED ("FOR OUT_FILE LINE UNNECESSARILY " &
"CHANGED FROM FOUR");
ELSE
SET_LINE (FILE, 8);
PUT (FILE, "DE");
SET_LINE (FILE, TWO+1);
IF LINE (FILE) /= TWO+ONE THEN
FAILED ("FOR OUT_FILE LINE NOT THREE");
END IF;
SET_LINE (FILE, TWO);
IF PAGE (FILE) /= ONE+TWO THEN
FAILED ("PAGE TERMINATOR NOT OUTPUT - 2");
END IF;
IF LINE (FILE) /= TWO THEN
FAILED ("LINE NOT TWO; IS" &
COUNT'IMAGE(LINE(FILE)));
END IF;
SET_PAGE_LENGTH (FILE, TWO);
PUT (FILE, 'X');
SET_LINE (FILE, TWO);
PUT (FILE, 'Y');
IF LINE (FILE) /= TWO THEN
FAILED ("LINE NOT TWO; IS " &
COUNT'IMAGE(LINE(FILE)));
END IF;
IF PAGE (FILE) /= THREE THEN
FAILED ("PAGE NOT THREE; IS " &
COUNT'IMAGE(PAGE(FILE)));
END IF;
END IF;
END IF;
CHECK_FILE (FILE, "###C####DE#@##@#XY#@%");
CLOSE (FILE);
BEGIN
OPEN (FILE, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED FOR TEXT OPEN " &
"WITH IN_FILE MODE");
RAISE INCOMPLETE;
END;
SET_LINE (FILE, FOUR);
IF LINE (FILE) /= FOUR THEN
FAILED ("FOR IN_FILE LINE NOT FOUR");
ELSE
GET (FILE, ITEM_CHAR);
IF ITEM_CHAR /= 'C' THEN
FAILED ("SET_LINE FOR READ; ACTUALLY READ '" &
ITEM_CHAR & "'");
END IF;
SKIP_LINE (FILE);
SET_LINE (FILE, 5);
IF LINE (FILE) /= FOUR+1 OR PAGE (FILE) /= ONE THEN
FAILED ("INCORRECT LINE OR PAGE");
ELSE
SET_LINE (FILE, 8);
GET (FILE, ITEM_CHAR);
IF ITEM_CHAR /= 'D' THEN
FAILED ("SET_LINE FOR READ 2; ACTUALLY READ '"&
ITEM_CHAR & "'");
END IF;
SET_LINE (FILE, TWO);
IF PAGE (FILE) /= TWO THEN
FAILED ("FOR IN_FILE PAGE NOT TWO");
END IF;
SET_LINE (FILE, TWO);
IF PAGE (FILE) /= TWO OR LINE (FILE) /= TWO THEN
FAILED ("FOR IN_FILE PAGE NOT 2");
END IF;
SKIP_LINE (FILE);
SET_LINE (FILE, TWO);
GET (FILE, ITEM_CHAR);
IF ITEM_CHAR /= 'X' THEN
FAILED ("SET_LINE FOR READ 3; ACTUALLY READ '"&
ITEM_CHAR & "'");
END IF;
END IF;
END IF;
BEGIN
DELETE (FILE);
EXCEPTION
WHEN USE_ERROR =>
NULL;
END;
EXCEPTION
WHEN INCOMPLETE =>
NULL;
END;
RESULT;
END CE3410C;
|
ffight/lcs/1p/3F.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 29405 | <filename>ffight/lcs/1p/3F.asm
copyright zengfr site:http://github.com/zengfr/romhack
00759C move.b ($b,A2), ($3f,A3) [1p+16]
0075A2 bmi $76c2 [1p+3F]
00A308 clr.b ($3f,A4)
00A30C clr.b ($40,A4)
copyright zengfr site:http://github.com/zengfr/romhack
|
src/test/resources/data/potests/test53.asm | cpcitor/mdlz80optimizer | 36 | 174537 | ; Test to prevent a corner case reported by jltursan
org #4000
di
ld sp,hl ; 7
pop de ; 11 fetch sine
pop bc ; 11 fetch cosine
ld sp,ix
pop hl
pop hl
add hl,de
push hl ; mdl:no-opt
pop hl
pop hl
add hl,bc
push hl
ei
loop:
jr loop |
oeis/062/A062000.asm | neoneye/loda-programs | 11 | 23282 | ; A062000: a(n) = a(n-1)^2-a(n-2)^2.
; Submitted by <NAME>
; 0,2,4,12,128,16240,263721216,69548879504781056,4837046640370554355727482727956480,23397020201120067002755280700388456275000098577861376610994277515264,547420554291620500578892066497978916610063688703501975716854449748089639227562822264574470862277363333845184511690827125552196978999296
mov $3,2
lpb $0
sub $0,1
pow $2,2
add $2,$3
sub $3,$2
lpe
mov $0,$2
|
generated/natools-static_maps-web-comments-list_elements.ads | faelys/natools-web | 1 | 21442 | package Natools.Static_Maps.Web.Comments.List_Elements is
pragma Pure;
function Hash (S : String) return Natural;
end Natools.Static_Maps.Web.Comments.List_Elements;
|
src/test/resources/data/generationtests/glass-labels-expected.asm | cpcitor/mdlz80optimizer | 36 | 246085 | ; Test to check labels are parsed like in Glass (reported by Torihino)
DI: ds 1, 0 ; this should parse "DI" as a label |
programs/oeis/227/A227241.asm | neoneye/loda | 22 | 16700 | <reponame>neoneye/loda
; A227241: a(n) = sigma(n)*( 2*sigma(n)+1 ).
; 3,21,36,105,78,300,136,465,351,666,300,1596,406,1176,1176,1953,666,3081,820,3570,2080,2628,1176,7260,1953,3570,3240,6328,1830,10440,2080,8001,4656,5886,4656,16653,2926,7260,6328,16290,3570,18528,3916,14196,12246,10440,4656,30876,6555,17391,10440,19306,5886,28920,10440,28920,12880,16290,7260,56616,7750,18528,21736,32385,14196,41616,9316,31878,18528,41616,10440,76245,11026,26106,30876,39340,18528,56616,12880,69378,29403,31878,14196,100576,23436,34980,28920,64980,16290,109746,25200,56616,32896,41616,28920,127260,19306,58653,48828,94395
seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n).
add $1,$0
add $1,$0
mul $1,$0
add $1,$0
mov $0,$1
|
examples/vga_text/program.asm | dargueta/unicorn-lua | 14 | 176816 | <reponame>dargueta/unicorn-lua
bits 32
cpu 386
org 0x7c000
entry_point:
mov edi, 0xb8000
mov esi, message
mov ecx, [n_chars]
cld
; AH is the text attribute. Start with red on a black background and increment
; it on every iteration to change the text color.
mov ah, 0x01
.print_loop:
lodsb
stosw
inc ah
loop .print_loop
.done:
cli
hlt
message: db "Hello, World!"
n_chars: dd ($ - message)
; Pad to the end of the sector and then add the boot signature.
times 510-($-$$) db 0
db 0x55, 0xaa
|
Kernel/asm/RTC.asm | rlajous/Simple-SO | 0 | 176024 | <filename>Kernel/asm/RTC.asm<gh_stars>0
GLOBAL getSeconds
GLOBAL getMinutes
GLOBAL getHours
GLOBAL setFormat
section .text
setFormat:
push rbp
mov rbp,rsp
mov al,0Bh
out 70h,al
in al,71h
or al,00000100b
out 71h,al
mov rsp,rbp
pop rbp
ret
getSeconds:
push rbp
mov rbp,rsp
mov al,0
out 70h,al
in al,71h
movzx rax,ax
mov rsp,rbp
pop rbp
ret
getMinutes:
push rbp
mov rbp,rsp
mov al,2
out 70h,al
in al,71h
movzx rax,al
mov rsp,rbp
pop rbp
ret
getHours:
push rbp
mov rbp,rsp
mov al,4
out 70h,al
in al,71h
movzx rax,al
mov rsp,rbp
pop rbp
ret
getMonth:
push rbp
mov rbp,rsp
mov al,8
out 70h,al
in al,71h
movzx rax,al
mov rsp,rbp
pop rbp
ret
getYear:
push rbp
mov rbp,rsp
mov al,9
out 70h,al
in al,71h
movzx rax,al
mov rsp,rbp
pop rbp
ret
section .data
section .bss
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/specs/root-level_1-level_2.ads | best08618/asylo | 7 | 9777 | package Root.Level_1.Level_2 is
type Level_2_Type (First : Natural;
Second : Natural) is new
Level_1.Level_1_Type (First => First, Second => Second) with null record;
end Root.Level_1.Level_2;
|
test/Succeed/FlatUnderscore.agda | cruhland/agda | 1,989 | 6830 | module FlatUnderscore where
postulate
A : Set
f : (@♭ X : A → Set) → ∀ a → X a
@♭ B : A → Set
-- The undescore should be solved to B.
g : ∀ a → B a
g = f _
|
chrome-keystroke-clipboard.applescript | mkrogh/9to5 | 1 | 2065 | <reponame>mkrogh/9to5
tell application "Google Chrome"
activate
end tell
tell application "System Events"
set cmd to (the clipboard as text)
repeat with i from 1 to count characters of cmd
keystroke (character i of cmd)
delay (0.03)
end repeat
display notification "" with title "TypePaster" subtitle "Done typing." sound name "Funk"
end tell
|
examples/shared/serial_ports/src/serial_io-nonblocking.ads | morbos/Ada_Drivers_Library | 2 | 11327 | <filename>examples/shared/serial_ports/src/serial_io-nonblocking.ads
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package defines an abstract data type for a "serial port" providing
-- non-blocking input (Get) and output (Put) procedures. The procedures are
-- considered non-blocking because they return to the caller (potentially)
-- before the entire message is received or sent.
--
-- The serial port abstraction is a wrapper around a USART peripheral,
-- described by a value of type Peripheral_Descriptor.
--
-- Interrupts are used to send and receive characters.
--
-- NB: clients must not send or receive messages until any prior sending or
-- receiving is completed. See the two functions Sending and Receiving and
-- the preconditions on Put and Get.
with Message_Buffers; use Message_Buffers;
with Ada.Interrupts; use Ada.Interrupts;
package Serial_IO.Nonblocking is
pragma Elaborate_Body;
type Serial_Port
(IRQ : Interrupt_ID;
Device : not null access Peripheral_Descriptor)
is tagged limited private;
procedure Initialize (This : in out Serial_Port) with
Post => Initialized (This);
function Initialized (This : Serial_Port) return Boolean with Inline;
Serial_Port_Uninitialized : exception;
procedure Configure
(This : in out Serial_Port;
Baud_Rate : Baud_Rates;
Parity : Parities := No_Parity;
Data_Bits : Word_Lengths := Word_Length_8;
End_Bits : Stop_Bits := Stopbits_1;
Control : Flow_Control := No_Flow_Control)
with
Pre => (Initialized (This) or else raise Serial_Port_Uninitialized);
procedure Put (This : in out Serial_Port; Msg : not null access Message) with
Pre => (Initialized (This) or else raise Serial_Port_Uninitialized)
and then
not Sending (This),
Inline;
procedure Get (This : in out Serial_Port; Msg : not null access Message) with
Pre => (Initialized (This) or else raise Serial_Port_Uninitialized)
and then
not Receiving (This),
Inline;
function Sending (This : in out Serial_Port) return Boolean;
-- Returns whether This is currently sending a message.
function Receiving (This : in out Serial_Port) return Boolean;
-- Returns whether This is currently receiving a message.
private
-- The protected type defining the interrupt handling for sending and
-- receiving characters via the USART attached to the serial port. Each
-- serial port type a component of this protected type.
protected type Controller (IRQ : Interrupt_ID; Port : access Serial_Port) is
pragma Interrupt_Priority;
procedure Start_Sending (Msg : not null access Message) with
Pre => not Sending;
procedure Start_Receiving (Msg : not null access Message) with
Pre => not Receiving;
function Sending return Boolean;
function Receiving return Boolean;
private
Next_Out : Positive;
Awaiting_Transfer : Natural;
Outgoing_Msg : access Message;
Incoming_Msg : access Message;
procedure Handle_Transmission with Inline;
procedure Handle_Reception with Inline;
procedure Detect_Errors (Is_Xmit_IRQ : Boolean) with Inline;
procedure IRQ_Handler with Attach_Handler => IRQ;
end Controller;
type Serial_Port
(IRQ : Interrupt_ID;
Device : not null access Peripheral_Descriptor)
is tagged limited record
Initialized : Boolean := False;
Control : Controller (IRQ, Serial_Port'Access);
end record;
end Serial_IO.Nonblocking;
|
data/mapHeaders/safarizoneresthouse2.asm | adhi-thirumala/EvoYellow | 16 | 245384 | SafariZoneRestHouse2_h:
db GATE ; tileset
db SAFARI_ZONE_REST_HOUSE_2_HEIGHT, SAFARI_ZONE_REST_HOUSE_2_WIDTH ; dimensions (y, x)
dw SafariZoneRestHouse2Blocks, SafariZoneRestHouse2TextPointers, SafariZoneRestHouse2Script ; blocks, texts, scripts
db $00 ; connections
dw SafariZoneRestHouse2Object ; objects
|
oeis/019/A019040.asm | neoneye/loda-programs | 11 | 166298 | ; A019040: Expansion of 1/((1-4x)(1-5x)(1-11x)).
; Submitted by <NAME>
; 1,20,281,3460,40161,453300,5048041,55853540,616079921,6785596180,74686191801,821775473220,9040683799681,99453356876660,1094016369479561,12034328357198500,132378357688767441,1456165680554230740,16017841284704959321,176196348399674565380,1938160304835531911201,21319765719784455994420,234517434768189226839081,2579691841773251293909860,28376610556403088203118961,312142717606046489991703700,3433569901099077588323086841,37769268949270698862135167940,415461958627953972030430838721
mov $1,1
mov $3,2
lpb $0
sub $0,1
mul $1,5
sub $2,1
mul $2,2
div $3,2
mul $3,11
add $3,2
sub $3,$2
add $1,$3
mul $2,2
sub $2,2
mul $3,2
lpe
mov $0,$1
|
programs/oeis/100/A100071.asm | neoneye/loda | 22 | 4962 | ; A100071: a(n) = n * binomial(n-1, floor((n-1)/2)) = n * max_{i=0..n} binomial(n-1, i).
; 0,1,2,6,12,30,60,140,280,630,1260,2772,5544,12012,24024,51480,102960,218790,437580,923780,1847560,3879876,7759752,16224936,32449872,67603900,135207800,280816200,561632400,1163381400,2326762800,4808643120,9617286240,19835652870,39671305740,81676217700,163352435400,335780006100,671560012200,1378465288200,2756930576400,5651707681620,11303415363240,23145088600920,46290177201840,94684453367400,189368906734800,386971244197200,773942488394400,1580132580471900,3160265160943800,6446940928325352,12893881856650704,26283682246249512,52567364492499024,107081668410646160,214163336821292320,435975364243345080,871950728486690160,1773968723472921360,3547937446945842720,7214139475456546864,14428278950913093728,29321986255081448544,58643972510162897088,119120569161268384710,238241138322536769420,483701705079089804580,967403410158179609160,1963259861791599795060,3926519723583199590120,7965225724983062025672,15930451449966124051344,32303415440209084881892,64606830880418169763784,130959792325171965737400,261919584650343931474800,530731789949381124304200,1061463579898762248608400,2150144174666723529232400,4300288349333447058464800,8708083907400230293391220,17416167814800460586782440,35257120210449712895193720,70514240420899425790387440,142707391328010742671022200,285414782656021485342044400,577467118397066726157159600,1154934236794133452314319200,2336116978969951755817600200,4672233957939903511635200400,9448295337167360434640071920,18896590674334720869280143840,38203976798111500887892464720,76407953596223001775784929440,154441608332791173802118474400,308883216665582347604236948800,624201500345030994116895500700,1248403000690061988233791001400,2522283613639104833370312431400
mov $2,2
add $2,$0
div $2,2
mov $1,$2
mov $3,$0
bin $3,$2
mul $3,2
mul $1,$3
div $1,2
mov $0,$1
|
scripts/route7.asm | longlostsoul/EvoYellow | 16 | 160763 | <gh_stars>10-100
Route7Script:
call EnableAutoTextBoxDrawing
ret
Route7TextPointers:
dw Route7Text1
dw Route7Tree1
Route7Text1:
TX_FAR _Route7Text1
db "@"
Route7Tree1:
db $08 ; asm
ld a, 14
ld [wWhichTrade], a
callba BerryTreeScript
jp TextScriptEnd |
oeis/028/A028919.asm | neoneye/loda-programs | 11 | 27339 | <reponame>neoneye/loda-programs
; A028919: Congruent to 0, 6, 10, 12 (mod 14).
; Submitted by <NAME>(s3)
; 0,6,10,12,14,20,24,26,28,34,38,40,42,48,52,54,56,62,66,68,70,76,80,82,84,90,94,96,98,104,108,110,112,118,122,124,126,132,136,138,140,146,150,152,154,160,164,166,168,174,178,180,182,188,192,194,196,202,206,208,210,216,220,222,224,230,234,236
mul $0,7
mov $1,$0
add $0,1
div $1,2
sub $0,$1
div $0,2
mod $1,2
add $1,$0
mul $1,2
mov $0,$1
|
programs/oeis/291/A291268.asm | jmorken/loda | 1 | 179057 | <reponame>jmorken/loda
; A291268: The arithmetic function v_3(n,2).
; 1,0,2,2,3,3,4,3,5,5,6,6,7,6,8,8,9,9,10,9,11,11,12,12,13,12,14,14,15,15,16,15,17,17,18,18,19,18,20,20,21,21,22,21,23,23,24,24,25,24,26,26,27,27,28,27,29,29,30,30,31,30,32,32,33,33,34,33,35
mov $1,$0
sub $0,13
mod $0,6
div $1,2
lpb $0
add $1,1
trn $0,$1
lpe
|
Ada95/samples/ncurses2-getch_test.adb | Distrotech/ncurses | 1 | 23220 | <reponame>Distrotech/ncurses
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000-2008,2009 Free Software Foundation, Inc. --
-- --
-- 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, distribute with modifications, 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 ABOVE 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. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: <NAME> <<EMAIL>> 2000
-- Version Control
-- $Revision: 1.8 $
-- $Date: 2009/12/26 17:38:58 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- Character input test
-- test the keypad feature
with ncurses2.util; use ncurses2.util;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Mouse; use Terminal_Interface.Curses.Mouse;
with Ada.Characters.Handling;
with Ada.Strings.Bounded;
with ncurses2.genericPuts;
procedure ncurses2.getch_test is
use Int_IO;
function mouse_decode (ep : Mouse_Event) return String;
function mouse_decode (ep : Mouse_Event) return String is
Y : Line_Position;
X : Column_Position;
Button : Mouse_Button;
State : Button_State;
package BS is new Ada.Strings.Bounded.Generic_Bounded_Length (200);
use BS;
buf : Bounded_String := To_Bounded_String ("");
begin
-- Note that these bindings do not allow
-- two button states,
-- The C version can print {click-1, click-3} for example.
-- They also don't have the 'id' or z coordinate.
Get_Event (ep, Y, X, Button, State);
-- TODO Append (buf, "id "); from C version
Append (buf, "at (");
Append (buf, Column_Position'Image (X));
Append (buf, ", ");
Append (buf, Line_Position'Image (Y));
Append (buf, ") state");
Append (buf, Mouse_Button'Image (Button));
Append (buf, " = ");
Append (buf, Button_State'Image (State));
return To_String (buf);
end mouse_decode;
buf : String (1 .. 1024); -- TODO was BUFSIZE
n : Integer;
c : Key_Code;
blockflag : Timeout_Mode := Blocking;
firsttime : Boolean := True;
tmp2 : Event_Mask;
tmp6 : String (1 .. 6);
tmp20 : String (1 .. 20);
x : Column_Position;
y : Line_Position;
tmpx : Integer;
incount : Integer := 0;
begin
Refresh;
tmp2 := Start_Mouse (All_Events);
Add (Str => "Delay in 10ths of a second (<CR> for blocking input)? ");
Set_Echo_Mode (SwitchOn => True);
Get (Str => buf);
Set_Echo_Mode (SwitchOn => False);
Set_NL_Mode (SwitchOn => False);
if Ada.Characters.Handling.Is_Digit (buf (1)) then
Get (Item => n, From => buf, Last => tmpx);
Set_Timeout_Mode (Mode => Delayed, Amount => n * 100);
blockflag := Delayed;
end if;
c := Character'Pos ('?');
Set_Raw_Mode (SwitchOn => True);
loop
if not firsttime then
Add (Str => "Key pressed: ");
Put (tmp6, Integer (c), 8);
Add (Str => tmp6);
Add (Ch => ' ');
if c = Key_Mouse then
declare
event : Mouse_Event;
begin
event := Get_Mouse;
Add (Str => "KEY_MOUSE, ");
Add (Str => mouse_decode (event));
Add (Ch => newl);
end;
elsif c >= Key_Min then
Key_Name (c, tmp20);
Add (Str => tmp20);
-- I used tmp and got bitten by the length problem:->
Add (Ch => newl);
elsif c > 16#80# then -- TODO fix, use constant if possible
declare
c2 : constant Character := Character'Val (c mod 16#80#);
begin
if Ada.Characters.Handling.Is_Graphic (c2) then
Add (Str => "M-");
Add (Ch => c2);
else
Add (Str => "M-");
Add (Str => Un_Control ((Ch => c2,
Color => Color_Pair'First,
Attr => Normal_Video)));
end if;
Add (Str => " (high-half character)");
Add (Ch => newl);
end;
else
declare
c2 : constant Character := Character'Val (c mod 16#80#);
begin
if Ada.Characters.Handling.Is_Graphic (c2) then
Add (Ch => c2);
Add (Str => " (ASCII printable character)");
Add (Ch => newl);
else
Add (Str => Un_Control ((Ch => c2,
Color => Color_Pair'First,
Attr => Normal_Video)));
Add (Str => " (ASCII control character)");
Add (Ch => newl);
end if;
end;
end if;
-- TODO I am not sure why this was in the C version
-- the delay statement scroll anyway.
Get_Cursor_Position (Line => y, Column => x);
if y >= Lines - 1 then
Move_Cursor (Line => 0, Column => 0);
end if;
Clear_To_End_Of_Line;
end if;
firsttime := False;
if c = Character'Pos ('g') then
declare
package p is new ncurses2.genericPuts (1024);
use p;
use p.BS;
timedout : Boolean := False;
boundedbuf : Bounded_String;
begin
Add (Str => "getstr test: ");
Set_Echo_Mode (SwitchOn => True);
-- Note that if delay mode is set
-- Get can raise an exception.
-- The C version would print the string it had so far
-- also TODO get longer length string, like the C version
declare begin
myGet (Str => boundedbuf);
exception when Curses_Exception =>
Add (Str => "Timed out.");
Add (Ch => newl);
timedout := True;
end;
-- note that the Ada Get will stop reading at 1024.
if not timedout then
Set_Echo_Mode (SwitchOn => False);
Add (Str => " I saw '");
myAdd (Str => boundedbuf);
Add (Str => "'.");
Add (Ch => newl);
end if;
end;
elsif c = Character'Pos ('s') then
ShellOut (True);
elsif c = Character'Pos ('x') or c = Character'Pos ('q') or
(c = Key_None and blockflag = Blocking) then
exit;
elsif c = Character'Pos ('?') then
Add (Str => "Type any key to see its keypad value. Also:");
Add (Ch => newl);
Add (Str => "g -- triggers a getstr test");
Add (Ch => newl);
Add (Str => "s -- shell out");
Add (Ch => newl);
Add (Str => "q -- quit");
Add (Ch => newl);
Add (Str => "? -- repeats this help message");
Add (Ch => newl);
end if;
loop
c := Getchar;
exit when c /= Key_None;
if blockflag /= Blocking then
Put (tmp6, incount); -- argh string length!
Add (Str => tmp6);
Add (Str => ": input timed out");
Add (Ch => newl);
else
Put (tmp6, incount);
Add (Str => tmp6);
Add (Str => ": input error");
Add (Ch => newl);
exit;
end if;
incount := incount + 1;
end loop;
end loop;
End_Mouse (tmp2);
Set_Timeout_Mode (Mode => Blocking, Amount => 0); -- amount is ignored
Set_Raw_Mode (SwitchOn => False);
Set_NL_Mode (SwitchOn => True);
Erase;
End_Windows;
end ncurses2.getch_test;
|
Ada/src/Problem_70.adb | Tim-Tom/project-euler | 0 | 12200 | with Ada.Text_IO;
with PrimeUtilities;
package body Problem_70 is
package IO renames Ada.Text_IO;
subtype Ten_Million is Integer range 1 .. 9_999_999;
package Ten_Million_Primes is new PrimeUtilities(Ten_Million);
type Digit_Count is Array(Character range '0' .. '9') of Natural;
procedure Solve is
sieve : constant Ten_Million_Primes.Sieve := Ten_Million_Primes.Generate_Sieve(Ten_Million'Last / 2);
best : Ten_Million := 1;
best_ratio : Long_Float := 0.0;
function Convert(num : Ten_Million) return Digit_Count is
str : constant String := Ten_Million'Image(num);
counts : Digit_Count := (others => 0);
begin
for i in 2 .. str'Last loop
counts(str(i)) := counts(str(i)) + 1;
end loop;
return counts;
end Convert;
procedure Check(num, euler : Ten_Million; ratio : Long_Float) is
num_c : constant Digit_Count := Convert(num);
euler_c : constant Digit_Count := Convert(euler);
begin
for c in num_c'Range loop
if num_c(c) /= euler_c(c) then
return;
end if;
end loop;
best := num;
best_ratio := ratio;
end Check;
procedure Solve_Recursive(min_index : Positive; start_ratio : Long_Float; start_euler, so_far : Ten_Million) is
prime : Ten_Million;
total : Ten_Million;
euler : Ten_Million;
ratio : Long_Float;
begin
for prime_index in min_index .. sieve'Last loop
prime := sieve(prime_index);
exit when Ten_Million'Last / prime < so_far;
total := so_far * prime;
euler := start_euler * (prime - 1);
ratio := start_ratio * (1.0 - 1.0 / Long_Float(prime));
exit when ratio < 0.1;
loop
if ratio > best_ratio then
Check(total, euler, ratio);
end if;
Solve_Recursive(prime_index + 1, ratio, euler, total);
exit when Ten_Million'Last / prime < total;
total := total * prime;
euler := euler * prime;
end loop;
end loop;
end Solve_Recursive;
begin
Solve_Recursive(sieve'First, 1.0, 1, 1);
IO.Put_Line(Integer'Image(best));
end Solve;
end Problem_70;
|
Project/Parser/grammar/Demo.g4 | Jim-Dev/Pseudo_ES | 0 | 3815 | grammar Demo;
addition: left=addition SIGN_ADD right=NUMBER #Plus
| number=NUMBER #Number
;
NUMBER: [0-9]+;
SIGN_ADD: '+'; |
tools/css-commands.ads | stcarrez/ada-css | 3 | 21541 | -----------------------------------------------------------------------
-- css-commands -- Commands for CSS tools
-- Copyright (C) 2018, 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Commands.Drivers;
with Util.Commands.Parsers;
with Util.Commands.Consoles;
with Util.Commands.Consoles.Text;
with CSS.Printer.Text_IO;
with CSS.Core.Sets;
with CSS.Core.Sheets;
with CSS.Tools.Messages;
with CSS.Analysis.Classes;
package CSS.Commands is
-- The type of notice that are reported.
type Notice_Type is (N_HELP, N_USAGE, N_INFO);
-- The possible fields.
type Field_Type is (F_CLASS_NAME, F_COLOR,
F_VALUE_1, F_VALUE_2, F_VALUE_3, F_VALUE_4, F_VALUE_LAST);
-- Make the generic abstract console interface.
package Consoles is
new Util.Commands.Consoles (Field_Type => Field_Type,
Notice_Type => Notice_Type);
subtype Console_Access is Consoles.Console_Access;
-- And the text console to write on stdout (a Gtk console could be done someday).
package Text_Consoles is
new Consoles.Text;
type Context_Type is limited record
Doc : aliased CSS.Core.Sheets.CSSStylesheet;
Err_Handler : aliased CSS.Tools.Messages.Message_List;
Output : CSS.Printer.Text_IO.File_Type;
Report : CSS.Printer.Text_IO.File_Type;
Dup_Rules : CSS.Core.Sets.Set;
Class_Map : CSS.Analysis.Classes.Class_Maps.Map;
Console : Console_Access;
end record;
package Drivers is
new Util.Commands.Drivers (Context_Type => Context_Type,
Driver_Name => "gen-commands",
Config_Parser => Util.Commands.Parsers.No_Parser);
subtype Command is Drivers.Command_Type;
subtype Command_Access is Drivers.Command_Access;
subtype Argument_List is Util.Commands.Argument_List;
Driver : Drivers.Driver_Type;
-- Load the CSS files.
procedure Load (Args : in Argument_List'Class;
Context : in out Context_Type);
-- Initialize the context.
procedure Initialize (Context : in out Context_Type);
-- Print csstools short usage.
procedure Short_Help_Usage;
end CSS.Commands;
|
test/Succeed/Issue3364.agda | hborum/agda | 2 | 10602 | <reponame>hborum/agda<filename>test/Succeed/Issue3364.agda
-- Andreas, 2018-11-03, issue #3364
-- Andreas, 2019-02-23, issue #3457
--
-- Better error when trying to import with new qualified module name.
open import Agda.Builtin.Nat as Builtin.Nat
-- WAS: Error:
-- Not in scope:
-- as at ...
-- when scope checking as
-- NOW: Warning
-- `as' must be followed by an identifier; a qualified name is not allowed here
-- when scope checking the declaration
-- open import Agda.Builtin.Nat as Builtin.Nat
import Agda.Builtin.Sigma as .as
-- `as' must be followed by an identifier
-- when scope checking the declaration
-- import Agda.Builtin.Sigma as .as
import Agda.Builtin.String as _
-- `as' must be followed by an identifier; an underscore is not allowed here
-- when scope checking the declaration
-- import Agda.Builtin.String as _
|
src/fltk-images-rgb-bmp.ads | micahwelf/FLTK-Ada | 1 | 4545 | <reponame>micahwelf/FLTK-Ada<gh_stars>1-10
package FLTK.Images.RGB.BMP is
type BMP_Image is new RGB_Image with private;
type BMP_Image_Reference (Data : not null access BMP_Image'Class) is limited null record
with Implicit_Dereference => Data;
package Forge is
function Create
(Filename : in String)
return BMP_Image;
end Forge;
private
type BMP_Image is new RGB_Image with null record;
overriding procedure Finalize
(This : in out BMP_Image);
end FLTK.Images.RGB.BMP;
|
gtkada_backend/src/screen_interface-gtkada.adb | Fabien-Chouteau/Giza | 7 | 20459 | <gh_stars>1-10
with Gtk.Window; use Gtk.Window;
with Gtk.Box; use Gtk.Box;
with Gtk.Drawing_Area; use Gtk.Drawing_Area;
with Glib; use Glib;
with Cairo; use Cairo;
with Glib.Main; use Glib.Main;
with Gdk.Window; use Gdk.Window;
with Gtk.Handlers; use Gtk.Handlers;
with Ada.Text_IO; use Ada.Text_IO;
use Gdk;
with Gtk.Widget; use Gtk.Widget;
with Cairo.Image_Surface; use Cairo.Image_Surface;
with Cairo.Surface;
with Gdk.Event; use Gdk.Event;
package body Screen_Interface is
Width_Size : constant := Width'Last - Width'First + 1;
Height_Size : constant := Height'Last - Height'First + 1;
TS : Touch_State := (False, 0, 0);
package Event_Cb is new Gtk.Handlers.Return_Callback
(Gtk_Drawing_Area_Record, Boolean);
Darea : Gtk_Drawing_Area;
subtype Frame_Buffer_Array is
ARGB32_Array (1 .. Natural (Width_Size * Height_Size));
-- We use a protected objet to synchonize access from GTK loop and the
-- outside world.
protected Frame_Buffer is
procedure Set_Pixel (P : Point; Col : Color);
procedure Fill_Screen (Col : Color);
procedure Draw (Cr : Cairo_Context);
procedure Initialize;
private
Buffer : aliased ARGB32_Array (0 .. (Width_Size * Height_Size) -1);
Surface : Cairo_Surface;
end Frame_Buffer;
protected body Frame_Buffer is
procedure Set_Pixel (P : Point; Col : Color) is
begin
Buffer (P.X + P.Y * Width_Size) := Col;
end Set_Pixel;
procedure Fill_Screen (Col : Color) is
begin
Buffer := (others => Col);
end Fill_Screen;
procedure Draw (Cr : Cairo_Context) is
W : Gint := Darea.Get_Allocated_Width;
H : Gint := Darea.Get_Allocated_Height;
W_Ratio : Gdouble := Gdouble (W) / Gdouble (Width_Size);
H_Ratio : Gdouble := Gdouble (H) / Gdouble (Height_Size);
begin
Cairo.Save (Cr);
Cairo.Scale (Cr, W_Ratio, H_Ratio);
Set_Source_Surface (Cr, Surface, 0.0, 0.0);
Cairo.Paint (Cr);
Cairo.Restore (Cr);
end Draw;
procedure Initialize is
Stride : constant Gint := Cairo_Format_Stride_For_Width
(Format => Cairo_Format_ARGB32,
Width => Width_Size);
begin
Surface := Create_For_Data_Generic
(Buffer (Buffer'First)'Address,
Cairo_Format_ARGB32,
Width_Size,
Height_Size,
Stride);
end Initialize;
end Frame_Buffer;
-----------------
-- Window_Idle --
-----------------
function Window_Idle return Boolean
is
W, H : Gint;
begin
if Darea = null or else Get_Window (Darea) = null then
return True;
end if;
W := Darea.Get_Allocated_Width;
H := Darea.Get_Allocated_Height;
Invalidate_Rect (Get_Window (Darea),
(0, 0, W, H), Invalidate_Children => True);
return True;
end Window_Idle;
function Redraw (Area : access Gtk_Drawing_Area_Record'Class;
Cr : Cairo_Context) return Boolean is
pragma Unreferenced (Area);
begin
if Darea = null or else Get_Window (Darea) = null then
return True;
end if;
Frame_Buffer.Draw (Cr);
return False;
end Redraw;
function On_Button
(Self : access Gtk_Widget_Record'Class;
Event : Gdk.Event.Gdk_Event_Button) return Boolean;
function On_Button
(Self : access Gtk_Widget_Record'Class;
Event : Gdk.Event.Gdk_Event_Button) return Boolean is
W : Gdouble := Gdouble (Darea.Get_Allocated_Width);
H : Gdouble := Gdouble (Darea.Get_Allocated_Height);
begin
if Event.The_Type = Button_Press and then Event.Button = 1 then
TS.X := Width ((Event.X / W) * Gdouble (Width_Size));
TS.Y := Height ((Event.Y / H) * Gdouble (Height_Size));
TS.Touch_Detected := True;
elsif Event.The_Type = Button_Release and then Event.Button = 1 then
TS := (False, 0, 0);
end if;
return False;
exception
when others =>
Put_Line ("On_Button exception");
TS.X := 0;
TS.Y := 0;
return False;
end On_Button;
function On_Motion
(Self : access Gtk_Widget_Record'Class;
Event : Gdk.Event.Gdk_Event_Motion) return Boolean is
W : Gdouble := Gdouble (Darea.Get_Allocated_Width);
H : Gdouble := Gdouble (Darea.Get_Allocated_Height);
begin
if TS.Touch_Detected then
TS.X := Width ((Event.X / W) * Gdouble (Width_Size));
TS.Y := Height ((Event.Y / H) * Gdouble (Height_Size));
end if;
return False;
exception
when others =>
Put_Line ("On Motion exception");
TS.X := 0;
TS.Y := 0;
return False;
end On_Motion;
procedure Initialize is
Win : Gtk_Window;
Box : Gtk_Vbox;
Src_Id : G_Source_Id;
pragma Unreferenced (Src_Id);
begin
Frame_Buffer.Initialize;
Gtk_New (Win);
Win.Set_Default_Size (Gint (Width'Last - Width'First + 1),
Gint (Height'Last - Height'First + 1));
Win.Add_Events(Button_Release_Mask);
Win.Add_Events(Button_Press_Mask);
Win.Add_Events(Pointer_Motion_Mask);
Win.Add_Events(Pointer_Motion_Hint_Mask);
Win.On_Button_Press_Event (On_Button'Access, True);
Win.On_Button_Release_Event (On_Button'Access, True);
Win.On_Motion_Notify_Event (On_Motion'Access);
Gtk_New_Vbox (Box);
Gtk_New (Darea);
Win.Add (Darea);
Event_Cb.Connect (Darea, Signal_Draw,
Event_Cb.To_Marshaller (Redraw'Unrestricted_Access));
-- Show the window
Win.Show_All;
Src_Id := Timeout_Add (100, Window_Idle'Access);
end;
function Get_Touch_State return Touch_State is
begin
delay 0.1;
return TS;
end;
procedure Set_Pixel (P : Point; Col : Color) is
begin
Frame_Buffer.Set_Pixel (P, Col);
end;
procedure Fill_Screen (Col : Color) is
begin
Frame_Buffer.Fill_Screen (Col);
end Fill_Screen;
function RGB_To_Color (R, G, B : RGB_Value) return Color is
Result : Color;
begin
Result.Red := Byte (R);
Result.Green := Byte (G);
Result.Blue := Byte (B);
Result.Alpha := 255;
return Result;
end RGB_To_Color;
end Screen_Interface;
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c94007a.ada | best08618/asylo | 7 | 10061 | <reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c94007a.ada<gh_stars>1-10
-- C94007A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT A TASK THAT IS DECLARED IN A NON-LIBRARY PACKAGE
-- (SPECIFICATION OR BODY) DOES NOT "DEPEND" ON THE PACKAGE,
-- BUT ON THE INNERMOST ENCLOSING BLOCK, SUBPROGRAM BODY,
-- OR TASK BODY.
-- SUBTESTS ARE:
-- (A) A SIMPLE TASK OBJECT, IN A VISIBLE PART, IN A BLOCK.
-- (B) AN ARRAY OF TASK OBJECT, IN A PRIVATE PART, IN A FUNCTION.
-- (C) AN ARRAY OF RECORD OF TASK OBJECT, IN A PACKAGE BODY,
-- IN A TASK BODY.
-- HISTORY:
-- JRK 10/13/81
-- SPS 11/21/82
-- DHH 09/07/88 REVISED HEADER, ADDED EXCEPTION HANDLERS ON OUTER
-- BLOCKS, AND ADDED CASE TO INSURE THAT LEAVING A
-- PACKAGE VIA AN EXCEPTION WOULD NOT ABORT TASKS.
-- PWN 01/31/95 REMOVED PRAGMA PRIORITY FOR ADA 9X.
with Impdef;
WITH REPORT; USE REPORT;
WITH SYSTEM; USE SYSTEM;
PROCEDURE C94007A IS
TASK TYPE SYNC IS
ENTRY ID (C : CHARACTER);
ENTRY INNER;
ENTRY OUTER;
END SYNC;
TASK BODY SYNC IS
ID_C : CHARACTER;
BEGIN
ACCEPT ID (C : CHARACTER) DO
ID_C := C;
END ID;
DELAY 1.0 * Impdef.One_Second;
SELECT
ACCEPT OUTER;
OR
DELAY 120.0 * Impdef.One_Second;
FAILED ("PROBABLY BLOCKED - (" & ID_C & ')');
END SELECT;
ACCEPT INNER;
END SYNC;
BEGIN
TEST ("C94007A", "CHECK THAT A TASK THAT IS DECLARED IN A " &
"NON-LIBRARY PACKAGE (SPECIFICATION OR BODY) " &
"DOES NOT ""DEPEND"" ON THE PACKAGE, BUT ON " &
"THE INNERMOST ENCLOSING BLOCK, SUBPROGRAM " &
"BODY, OR TASK BODY");
--------------------------------------------------
DECLARE -- (A)
S : SYNC;
BEGIN -- (A)
S.ID ('A');
DECLARE
PACKAGE PKG IS
TASK T IS
ENTRY E;
END T;
END PKG;
PACKAGE BODY PKG IS
TASK BODY T IS
BEGIN
S.INNER; -- PROBABLE INNER BLOCK POINT.
END T;
END PKG; -- PROBABLE OUTER BLOCK POINT.
BEGIN
S.OUTER;
EXCEPTION
WHEN TASKING_ERROR => NULL;
END;
EXCEPTION
WHEN OTHERS =>
FAILED("UNEXPECTED EXCEPTION RAISED - A");
END; -- (A)
--------------------------------------------------
DECLARE -- (B)
S : SYNC;
I : INTEGER;
FUNCTION F RETURN INTEGER IS
PACKAGE PKG IS
PRIVATE
TASK TYPE TT IS
ENTRY E;
END TT;
A : ARRAY (1..1) OF TT;
END PKG;
PACKAGE BODY PKG IS
TASK BODY TT IS
BEGIN
S.INNER; -- PROBABLE INNER BLOCK POINT.
END TT;
END PKG; -- PROBABLE OUTER BLOCK POINT.
BEGIN -- F
S.OUTER;
RETURN 0;
EXCEPTION
WHEN TASKING_ERROR => RETURN 0;
END F;
BEGIN -- (B)
S.ID ('B');
I := F;
EXCEPTION
WHEN OTHERS =>
FAILED("UNEXPECTED EXCEPTION RAISED - B");
END; -- (B)
--------------------------------------------------
DECLARE -- (C)
S : SYNC;
BEGIN -- (C)
S.ID ('C');
DECLARE
TASK TSK IS
END TSK;
TASK BODY TSK IS
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
TASK TYPE TT IS
ENTRY E;
END TT;
TYPE RT IS
RECORD
T : TT;
END RECORD;
AR : ARRAY (1..1) OF RT;
TASK BODY TT IS
BEGIN
S.INNER; -- PROBABLE INNER BLOCK POINT.
END TT;
END PKG; -- PROBABLE OUTER BLOCK POINT.
BEGIN -- TSK
S.OUTER;
EXCEPTION
WHEN TASKING_ERROR => NULL;
END TSK;
BEGIN
NULL;
END;
EXCEPTION
WHEN OTHERS =>
FAILED("UNEXPECTED EXCEPTION RAISED - C");
END; -- (C)
--------------------------------------------------
DECLARE -- (D)
GLOBAL : INTEGER := IDENT_INT(5);
BEGIN -- (D)
DECLARE
PACKAGE PKG IS
TASK T IS
ENTRY E;
END T;
TASK T1 IS
END T1;
END PKG;
PACKAGE BODY PKG IS
TASK BODY T IS
BEGIN
ACCEPT E DO
RAISE CONSTRAINT_ERROR;
END E;
END T;
TASK BODY T1 IS
BEGIN
DELAY 120.0 * Impdef.One_Second;
GLOBAL := IDENT_INT(1);
END T1;
BEGIN
T.E;
END PKG;
USE PKG;
BEGIN
NULL;
END;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF GLOBAL /= IDENT_INT(1) THEN
FAILED("TASK NOT COMPLETED");
END IF;
WHEN OTHERS =>
FAILED("UNEXPECTED EXCEPTION RAISED - D");
END; -- (D)
RESULT;
END C94007A;
|
src/dds-request_reply-typed_requester_generic.adb | alexcamposruiz/dds-requestreply | 0 | 11185 | <filename>src/dds-request_reply-typed_requester_generic.adb<gh_stars>0
pragma Ada_2012;
package body DDS.Request_Reply.Typed_Requester_Generic is
-----------------------------
-- Get_Request_Data_Writer --
-----------------------------
function Get_Request_Data_Writer
(Self : not null access Ref) return DDS.DataWriter.Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True,
"Get_Request_Data_Writer unimplemented");
return raise Program_Error
with "Unimplemented function Get_Request_Data_Writer";
end Get_Request_Data_Writer;
---------------------------
-- Get_Reply_Data_Reader --
---------------------------
function Get_Reply_Data_Reader
(Self : not null access Ref) return DDS.DataReader.Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True,
"Get_Reply_Data_Reader unimplemented");
return raise Program_Error
with "Unimplemented function Get_Reply_Data_Reader";
end Get_Reply_Data_Reader;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String; Qos_Library_Name : DDS.String;
Qos_Profile_Name : DDS.String;
Publisher : DDS.Publisher.Ref_Access := null;
Subscriber : DDS.Subscriber.Ref_Access := null;
A_Listner : Request_Listeners.Ref_Access := null;
Mask : DDS.StatusMask := DDS.STATUS_MASK_NONE) return Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
return raise Program_Error with "Unimplemented function Create";
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Request_Topic_Name : DDS.String; Reply_Topic_Name : DDS.String;
Qos_Library_Name : DDS.String; Qos_Profile_Name : DDS.String;
Publisher : DDS.Publisher.Ref_Access := null;
Subscriber : DDS.Subscriber.Ref_Access := null;
A_Listner : Request_Listeners.Ref_Access := null;
Mask : DDS.StatusMask := DDS.STATUS_MASK_NONE) return Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
return raise Program_Error with "Unimplemented function Create";
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String; Datawriter_Qos : DDS.DataWriterQos;
Datareader_Qos : DDS.DataReaderQos;
Publisher : DDS.Publisher.Ref_Access := null;
Subscriber : DDS.Subscriber.Ref_Access := null;
A_Listner : Request_Listeners.Ref_Access := null;
Mask : DDS.StatusMask := DDS.STATUS_MASK_NONE) return Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
return raise Program_Error with "Unimplemented function Create";
end Create;
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Request_Topic_Name : DDS.String; Reply_Topic_Name : DDS.String;
Datawriter_Qos : DDS.DataWriterQos; Datareader_Qos : DDS.DataReaderQos;
Publisher : DDS.Publisher.Ref_Access := null;
Subscriber : DDS.Subscriber.Ref_Access := null;
A_Listner : Request_Listeners.Ref_Access := null;
Mask : DDS.StatusMask := DDS.STATUS_MASK_NONE) return Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True, "Create unimplemented");
return raise Program_Error with "Unimplemented function Create";
end Create;
------------
-- Delete --
------------
procedure Delete (Self : in out Ref_Access) is
begin
pragma Compile_Time_Warning (Standard.True, "Delete unimplemented");
raise Program_Error with "Unimplemented procedure Delete";
end Delete;
------------------
-- Send_Request --
------------------
function Send_Request
(Self : not null access Ref; Data : Request_DataWriters.Treats.Data_Type)
return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Send_Request unimplemented");
return raise Program_Error with "Unimplemented function Send_Request";
end Send_Request;
------------------
-- Send_Request --
------------------
procedure Send_Request
(Self : not null access Ref; Data : Request_DataWriters.Treats.Data_Type)
is
begin
pragma Compile_Time_Warning (Standard.True,
"Send_Request unimplemented");
raise Program_Error with "Unimplemented procedure Send_Request";
end Send_Request;
------------------
-- Send_Request --
------------------
function Send_Request
(Self : not null access Ref; Data : Request_DataWriters.Treats.Data_Type)
return Reply_DataReaders.Treats.Data_Type
is
begin
pragma Compile_Time_Warning (Standard.True,
"Send_Request unimplemented");
return raise Program_Error with "Unimplemented function Send_Request";
end Send_Request;
------------------
-- Send_Request --
------------------
procedure Send_Request
(Self : not null access Ref;
Request : access Request_DataWriters.Treats.Data_Type)
is
begin
pragma Compile_Time_Warning (Standard.True,
"Send_Request unimplemented");
raise Program_Error with "Unimplemented procedure Send_Request";
end Send_Request;
------------------
-- Send_Request --
------------------
function Send_Request
(Self : not null access Ref;
Request : access Request_DataWriters.Treats.Data_Type)
return Reply_DataReaders.Container
is
begin
pragma Compile_Time_Warning (Standard.True,
"Send_Request unimplemented");
return raise Program_Error with "Unimplemented function Send_Request";
end Send_Request;
------------------
-- Send_Request --
------------------
function Send_Request
(Self : not null access Ref;
Request : Request_DataWriters.Treats.Data_Type) return Reply_DataReaders
.Container
is
begin
pragma Compile_Time_Warning (Standard.True,
"Send_Request unimplemented");
return raise Program_Error with "Unimplemented function Send_Request";
end Send_Request;
------------------
-- Send_Request --
------------------
function Send_Request
(Self : not null access Ref;
Request : access Request_DataWriters.Treats.Data_Type;
Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long;
Timeout : DDS.Duration_T := DURATION_INFINITE) return Reply_DataReaders
.Container
is
begin
pragma Compile_Time_Warning (Standard.True,
"Send_Request unimplemented");
return raise Program_Error with "Unimplemented function Send_Request";
end Send_Request;
------------------
-- Send_Request --
------------------
procedure Send_Request
(Self : not null access Ref;
Request : access Request_DataWriters.Treats.Data_Type;
Request_Info : DDS.WriteParams_T)
is
begin
pragma Compile_Time_Warning (Standard.True,
"Send_Request unimplemented");
raise Program_Error with "Unimplemented procedure Send_Request";
end Send_Request;
-------------------
-- Receive_Reply --
-------------------
function Receive_Reply
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Info_Seq : not null access DDS.SampleInfo_Seq.Sequence;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Reply unimplemented");
return raise Program_Error with "Unimplemented function Receive_Reply";
end Receive_Reply;
-------------------
-- Receive_Reply --
-------------------
function Receive_Reply
(Self : not null access Ref; Timeout : DDS.Duration_T)
return Reply_DataReaders.Container
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Reply unimplemented");
return raise Program_Error with "Unimplemented function Receive_Reply";
end Receive_Reply;
---------------------
-- Receive_Replies --
---------------------
function Receive_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences
.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Replies unimplemented");
return raise Program_Error with "Unimplemented function Receive_Replies";
end Receive_Replies;
---------------------
-- Receive_Replies --
---------------------
procedure Receive_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences
.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long;
Timeout : DDS.Duration_T)
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Replies unimplemented");
raise Program_Error with "Unimplemented procedure Receive_Replies";
end Receive_Replies;
---------------------
-- Receive_Replies --
---------------------
function Receive_Replies
(Self : not null access Ref; Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T)
return Reply_DataReaders.Container
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Replies unimplemented");
return raise Program_Error with "Unimplemented function Receive_Replies";
end Receive_Replies;
---------------------
-- Receive_Replies --
---------------------
function Receive_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences
.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long;
Timeout : Duration) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Replies unimplemented");
return raise Program_Error with "Unimplemented function Receive_Replies";
end Receive_Replies;
---------------------
-- Receive_Replies --
---------------------
function Receive_Replies
(Self : not null access Ref; Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.long; Timeout : Duration) return Reply_DataReaders
.Container
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Replies unimplemented");
return raise Program_Error with "Unimplemented function Receive_Replies";
end Receive_Replies;
----------------
-- Take_Reply --
----------------
function Take_Reply
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True, "Take_Reply unimplemented");
return raise Program_Error with "Unimplemented function Take_Reply";
end Take_Reply;
------------------
-- Take_Replies --
------------------
function Take_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences
.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Take_Replies unimplemented");
return raise Program_Error with "Unimplemented function Take_Replies";
end Take_Replies;
------------------
-- Take_Replies --
------------------
function Take_Replies
(Self : not null access Ref; Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T)
return Reply_DataReaders.Container
is
begin
pragma Compile_Time_Warning (Standard.True,
"Take_Replies unimplemented");
return raise Program_Error with "Unimplemented function Take_Replies";
end Take_Replies;
------------------------------------
-- Take_Reply_For_Related_Request --
------------------------------------
function Take_Reply_For_Related_Request
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Related_Request_Info : not null access DDS.SampleIdentity_T) return DDS
.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Take_Reply_For_Related_Request unimplemented");
return raise Program_Error
with "Unimplemented function Take_Reply_For_Related_Request";
end Take_Reply_For_Related_Request;
--------------------------------------
-- Take_Replies_For_Related_Request --
--------------------------------------
function Take_Replies_For_Related_Request
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences
.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Related_Request_Info : not null access DDS.SampleIdentity_T) return DDS
.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Take_Replies_For_Related_Request unimplemented");
return raise Program_Error
with "Unimplemented function Take_Replies_For_Related_Request";
end Take_Replies_For_Related_Request;
--------------------------------------
-- Take_Replies_For_Related_Request --
--------------------------------------
function Take_Replies_For_Related_Request
(Self : not null access Ref;
Related_Request_Info : not null access DDS.SampleIdentity_T)
return Reply_DataReaders.Container
is
begin
pragma Compile_Time_Warning (Standard.True,
"Take_Replies_For_Related_Request unimplemented");
return raise Program_Error
with "Unimplemented function Take_Replies_For_Related_Request";
end Take_Replies_For_Related_Request;
----------------
-- Read_Reply --
----------------
function Read_Reply
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True, "Read_Reply unimplemented");
return raise Program_Error with "Unimplemented function Read_Reply";
end Read_Reply;
------------------
-- Read_Replies --
------------------
function Read_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences
.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Read_Replies unimplemented");
return raise Program_Error with "Unimplemented function Read_Replies";
end Read_Replies;
------------------
-- Read_Replies --
------------------
function Read_Replies
(Self : not null access Ref; Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T)
return Reply_DataReaders.Container'Class
is
begin
pragma Compile_Time_Warning (Standard.True,
"Read_Replies unimplemented");
return raise Program_Error with "Unimplemented function Read_Replies";
end Read_Replies;
------------------------------------
-- Read_Reply_For_Related_Request --
------------------------------------
function Read_Reply_For_Related_Request
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Related_Request_Info : DDS.SampleIdentity_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Read_Reply_For_Related_Request unimplemented");
return raise Program_Error
with "Unimplemented function Read_Reply_For_Related_Request";
end Read_Reply_For_Related_Request;
--------------------------------------
-- Read_Replies_For_Related_Request --
--------------------------------------
function Read_Replies_For_Related_Request
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences
.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Related_Request_Info : DDS.SampleIdentity_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Read_Replies_For_Related_Request unimplemented");
return raise Program_Error
with "Unimplemented function Read_Replies_For_Related_Request";
end Read_Replies_For_Related_Request;
--------------------------------------
-- Read_Replies_For_Related_Request --
--------------------------------------
function Read_Replies_For_Related_Request
(Self : not null access Ref; Related_Request_Info : DDS.SampleIdentity_T)
return Reply_DataReaders.Container'Class
is
begin
pragma Compile_Time_Warning (Standard.True,
"Read_Replies_For_Related_Request unimplemented");
return raise Program_Error
with "Unimplemented function Read_Replies_For_Related_Request";
end Read_Replies_For_Related_Request;
-----------------
-- Return_Loan --
-----------------
procedure Return_Loan
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences
.Sequence_Access;
Sample_Info : DDS.SampleInfo_Seq.Sequence_Access)
is
begin
pragma Compile_Time_Warning (Standard.True, "Return_Loan unimplemented");
raise Program_Error with "Unimplemented procedure Return_Loan";
end Return_Loan;
-----------------
-- Return_Loan --
-----------------
procedure Return_Loan
(Self : not null access Ref;
Replies : Reply_DataReaders.Treats.Data_Sequences.Sequence;
Sample_Info : DDS.SampleInfo_Seq.Sequence)
is
begin
pragma Compile_Time_Warning (Standard.True, "Return_Loan unimplemented");
raise Program_Error with "Unimplemented procedure Return_Loan";
end Return_Loan;
------------
-- Delete --
------------
procedure Delete (This : in out Ref) is
begin
pragma Compile_Time_Warning (Standard.True, "Delete unimplemented");
raise Program_Error with "Unimplemented procedure Delete";
end Delete;
----------------------
-- Wait_For_Replies --
----------------------
procedure Wait_For_Replies
(This : in out Ref; Min_Count : Dds.long; Max_Wait : DDS.Duration_T)
is
begin
pragma Compile_Time_Warning (Standard.True,
"Wait_For_Replies unimplemented");
raise Program_Error with "Unimplemented procedure Wait_For_Replies";
end Wait_For_Replies;
-----------------------------------------
-- Wait_For_Replies_For_Related_Reques --
-----------------------------------------
procedure Wait_For_Replies_For_Related_Reques
(This : in out Ref; Min_Count : Dds.long; Max_Wait : DDS.Duration_T;
Related_Request_Id : DDS.SampleIdentity_T)
is
begin
pragma Compile_Time_Warning (Standard.True,
"Wait_For_Replies_For_Related_Reques unimplemented");
raise Program_Error
with "Unimplemented procedure Wait_For_Replies_For_Related_Reques";
end Wait_For_Replies_For_Related_Reques;
----------------------------
-- Get_Request_DataWriter --
----------------------------
function Get_Request_DataWriter
(Self : not null access Ref) return Request_DataWriters.Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True,
"Get_Request_DataWriter unimplemented");
return raise Program_Error
with "Unimplemented function Get_Request_DataWriter";
end Get_Request_DataWriter;
--------------------------
-- Get_Reply_DataReader --
--------------------------
function Get_Reply_DataReader
(Self : not null access Ref) return Reply_DataReaders.Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True,
"Get_Reply_DataReader unimplemented");
return raise Program_Error
with "Unimplemented function Get_Reply_DataReader";
end Get_Reply_DataReader;
--------------------------------
-- On_Offered_Deadline_Missed --
--------------------------------
procedure On_Offered_Deadline_Missed
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Status : in DDS.OfferedDeadlineMissedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Offered_Deadline_Missed unimplemented");
raise Program_Error
with "Unimplemented procedure On_Offered_Deadline_Missed";
end On_Offered_Deadline_Missed;
-----------------------
-- On_Data_Available --
-----------------------
procedure On_Data_Available
(Self : not null access DataReader_Listner;
The_Reader : in DDS.DataReaderListener.DataReader_Access)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Data_Available unimplemented");
raise Program_Error with "Unimplemented procedure On_Data_Available";
end On_Data_Available;
---------------------------------
-- On_Offered_Incompatible_Qos --
---------------------------------
procedure On_Offered_Incompatible_Qos
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Status : in DDS.OfferedIncompatibleQosStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Offered_Incompatible_Qos unimplemented");
raise Program_Error
with "Unimplemented procedure On_Offered_Incompatible_Qos";
end On_Offered_Incompatible_Qos;
------------------------
-- On_Liveliness_Lost --
------------------------
procedure On_Liveliness_Lost
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Status : in DDS.LivelinessLostStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Liveliness_Lost unimplemented");
raise Program_Error with "Unimplemented procedure On_Liveliness_Lost";
end On_Liveliness_Lost;
----------------------------
-- On_Publication_Matched --
----------------------------
procedure On_Publication_Matched
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Status : in DDS.PublicationMatchedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Publication_Matched unimplemented");
raise Program_Error
with "Unimplemented procedure On_Publication_Matched";
end On_Publication_Matched;
--------------------------------------
-- On_Reliable_Writer_Cache_Changed --
--------------------------------------
procedure On_Reliable_Writer_Cache_Changed
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Status : in DDS.ReliableWriterCacheChangedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Reliable_Writer_Cache_Changed unimplemented");
raise Program_Error
with "Unimplemented procedure On_Reliable_Writer_Cache_Changed";
end On_Reliable_Writer_Cache_Changed;
-----------------------------------------
-- On_Reliable_Reader_Activity_Changed --
-----------------------------------------
procedure On_Reliable_Reader_Activity_Changed
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Status : in DDS.ReliableReaderActivityChangedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Reliable_Reader_Activity_Changed unimplemented");
raise Program_Error
with "Unimplemented procedure On_Reliable_Reader_Activity_Changed";
end On_Reliable_Reader_Activity_Changed;
--------------------------------
-- On_Destination_Unreachable --
--------------------------------
procedure On_Destination_Unreachable
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Instance : in DDS.InstanceHandle_T; Locator : in DDS.Locator_T)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Destination_Unreachable unimplemented");
raise Program_Error
with "Unimplemented procedure On_Destination_Unreachable";
end On_Destination_Unreachable;
---------------------
-- On_Data_Request --
---------------------
procedure On_Data_Request
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class; Cookie : in DDS.Cookie_T;
Request : in out System.Address)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Data_Request unimplemented");
raise Program_Error with "Unimplemented procedure On_Data_Request";
end On_Data_Request;
--------------------
-- On_Data_Return --
--------------------
procedure On_Data_Return
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class; Arg : System.Address;
Cookie : in DDS.Cookie_T)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Data_Return unimplemented");
raise Program_Error with "Unimplemented procedure On_Data_Return";
end On_Data_Return;
-----------------------
-- On_Sample_Removed --
-----------------------
procedure On_Sample_Removed
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class; Cookie : in DDS.Cookie_T)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Sample_Removed unimplemented");
raise Program_Error with "Unimplemented procedure On_Sample_Removed";
end On_Sample_Removed;
--------------------------
-- On_Instance_Replaced --
--------------------------
procedure On_Instance_Replaced
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Instance : in DDS.InstanceHandle_T)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Instance_Replaced unimplemented");
raise Program_Error with "Unimplemented procedure On_Instance_Replaced";
end On_Instance_Replaced;
-----------------------------------
-- On_Application_Acknowledgment --
-----------------------------------
procedure On_Application_Acknowledgment
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Info : in DDS.AcknowledgmentInfo)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Application_Acknowledgment unimplemented");
raise Program_Error
with "Unimplemented procedure On_Application_Acknowledgment";
end On_Application_Acknowledgment;
---------------------------------
-- On_Service_Request_Accepted --
---------------------------------
procedure On_Service_Request_Accepted
(Self : not null access DataReader_Listner;
Writer : access DDS.DataWriter.Ref'Class;
Info : in DDS.ServiceRequestAcceptedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Service_Request_Accepted unimplemented");
raise Program_Error
with "Unimplemented procedure On_Service_Request_Accepted";
end On_Service_Request_Accepted;
----------------------------------
-- On_Requested_Deadline_Missed --
----------------------------------
procedure On_Requested_Deadline_Missed
(Self : not null access DataWriter_Listner;
The_Reader : in DDS.DataReaderListener.DataReader_Access;
Status : in DDS.RequestedDeadlineMissedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Requested_Deadline_Missed unimplemented");
raise Program_Error
with "Unimplemented procedure On_Requested_Deadline_Missed";
end On_Requested_Deadline_Missed;
-----------------------------------
-- On_Requested_Incompatible_Qos --
-----------------------------------
procedure On_Requested_Incompatible_Qos
(Self : not null access DataWriter_Listner;
The_Reader : in DDS.DataReaderListener.DataReader_Access;
Status : in DDS.RequestedIncompatibleQosStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Requested_Incompatible_Qos unimplemented");
raise Program_Error
with "Unimplemented procedure On_Requested_Incompatible_Qos";
end On_Requested_Incompatible_Qos;
------------------------
-- On_Sample_Rejected --
------------------------
procedure On_Sample_Rejected
(Self : not null access DataWriter_Listner;
The_Reader : in DDS.DataReaderListener.DataReader_Access;
Status : in DDS.SampleRejectedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Sample_Rejected unimplemented");
raise Program_Error with "Unimplemented procedure On_Sample_Rejected";
end On_Sample_Rejected;
---------------------------
-- On_Liveliness_Changed --
---------------------------
procedure On_Liveliness_Changed
(Self : not null access DataWriter_Listner;
The_Reader : in DDS.DataReaderListener.DataReader_Access;
Status : in DDS.LivelinessChangedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Liveliness_Changed unimplemented");
raise Program_Error with "Unimplemented procedure On_Liveliness_Changed";
end On_Liveliness_Changed;
-----------------------
-- On_Data_Available --
-----------------------
procedure On_Data_Available
(Self : not null access DataWriter_Listner;
The_Reader : in DDS.DataReaderListener.DataReader_Access)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Data_Available unimplemented");
raise Program_Error with "Unimplemented procedure On_Data_Available";
end On_Data_Available;
-----------------------------
-- On_Subscription_Matched --
-----------------------------
procedure On_Subscription_Matched
(Self : not null access DataWriter_Listner;
The_Reader : in DDS.DataReaderListener.DataReader_Access;
Status : in DDS.SubscriptionMatchedStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Subscription_Matched unimplemented");
raise Program_Error
with "Unimplemented procedure On_Subscription_Matched";
end On_Subscription_Matched;
--------------------
-- On_Sample_Lost --
--------------------
procedure On_Sample_Lost
(Self : not null access DataWriter_Listner;
The_Reader : in DDS.DataReaderListener.DataReader_Access;
Status : in DDS.SampleLostStatus)
is
begin
pragma Compile_Time_Warning (Standard.True,
"On_Sample_Lost unimplemented");
raise Program_Error with "Unimplemented procedure On_Sample_Lost";
end On_Sample_Lost;
end DDS.Request_Reply.Typed_Requester_Generic;
|
src/Utilities/OLD/tokenize.ads | fintatarta/eugen | 0 | 11117 | -- -*- Mode: Ada -*-
-- Filename : tokenize.ads
-- Description : Ruby-like split
-- Author : <NAME>
-- Created On : Tue Sep 11 22:05:53 2007
-- Last Modified By: <NAME>
-- Last Modified On: November 14, 2007
-- Update Count : 1
-- Status : <TESTED>
--
-- This package provides a function Split which divides its input
-- string in smaller strings, separated by a "separator" (much as the
-- split function in Perl, Ruby, and so on...). Function Split returns
-- a Token_List (defined by this package) whose elements can be accessed
-- by the function Element.
--
-- Function Split can accept a third Boolean value Collate_Separator.
-- If Collate_Separator is true, consecutive istances of the separator are
-- considered as a single one. If Collate_Separator is False, for every
-- pair of consecutive separator characters an empty string will be returned.
-- Moreover, if Collate_Separator is True, any separator at the beginning of
-- the string is ignored. Separators at the end are always ignored.
--
-- The default value of Collate_Separator is true if the separator
-- is the space, false otherwise.
--
-- Examples:
--
-- Split("Hello there") returns "Hello" and "there"
-- Split("Hello there", ' ', False) returns "Hello", "" and "there"
-- Split("Hello::there", ':') returns "Hello", "" and "there"
-- Split("Hello::there", ':', True) returns "Hello" and "there"
--
with Ada.Containers.Indefinite_Vectors;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
package Tokenize is
package String_Vectors is
new Ada.Containers.Indefinite_Vectors(Index_Type => Positive,
Element_Type => String);
subtype Token_List is String_Vectors.Vector;
type Token_Array is array (Positive range <>) of Unbounded_String;
--
-- Split string To_Be_Splitted in substring separated by
-- Separator. If Collate_Separator is true consider consecutive
-- istances of Separator as a single one
--
function Split(To_Be_Splitted : String;
Separator : Character;
Collate_Separator : Boolean) return Token_List;
function Split (To_Be_Splitted : String;
Separators : String;
Collate_Separator : Boolean) return Token_List;
--
-- Similar to the three-parameter version, but the Separator
-- char defaults to the space and Collate_Separator is True
-- if Separator is the space, false otherwise
--
function Split(To_Be_Splitted : String;
Separator : Character := ' ') return Token_List;
function Split (To_Be_Splitted : String;
Separator : Character := ' ') return Token_Array;
--
-- Return the Index-th token
--
function Element (Container : Token_List;
Index : Positive) return String
renames String_Vectors.Element;
--
-- Return the number of tokens
--
function Length(Container : Token_List) return Natural;
function To_Array (List : Token_List) return Token_Array;
end Tokenize;
|
Appl/Games/GWPoker/gwpoker.asm | steakknife/pcgeos | 504 | 2094 | <reponame>steakknife/pcgeos
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: GeoWorks Poker
FILE: gwpoker.asm
REVISION HISTORY:
Name Date Description
---- ---- -----------
Jon 12/90 Initial Version
bchow 2 /93 2.0 update
DESCRIPTION:
RCS STAMP:
$Id: gwpoker.asm,v 1.1 97/04/04 15:19:57 newdeal Exp $
------------------------------------------------------------------------------@
;------------------------------------------------------------------------------
; Common GEODE stuff
;------------------------------------------------------------------------------
_Application = 1
;Standard include files
include geos.def
include geode.def
include ec.def
include myMacros.def
include library.def
include resource.def
include object.def
include graphics.def
include gstring.def
include Objects/winC.def
include heap.def
include lmem.def
include timer.def
include timedate.def
include system.def
include file.def
include fileEnum.def
include vm.def
include hugearr.def
include Objects/inputC.def
include initfile.def
include dbase.def
;------------------------------------------------------------------------------
; Libraries used
;------------------------------------------------------------------------------
UseLib ui.def
UseLib sound.def
UseLib game.def
UseLib cards.def
UseLib dbase.def
UseLib wav.def
; Don't enable both of these at once
WAV_SOUND equ 0
STANDARD_SOUND equ 1
; This enables/disables code to allow setting of card fading. The ui
; must be uncommented/commented in bjack.ui also.
FADING = 0
include pokerGame.asm
include payoffDisplay.asm
include pokerSound.asm
;------------------------------------------------------------------------------
; Macros
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Constants
;------------------------------------------------------------------------------
SCORE_DISPLAY_BUFFER_SIZE equ 12 ;11 chars for score +
; null terminator
if STANDARD_SOUND
; Notes
; WHOLE equ 48
; HALF equ WHOLE/2
HALF_D equ HALF * 3/2
; QUARTER equ WHOLE/4
QUARTER_D equ QUARTER * 3/2
; EIGHTH equ QUARTER/2
endif
;------------------------------------------------------------------------------
; Definitions
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Object Class include files
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Class & Method Definitions
;------------------------------------------------------------------------------
;This is the class for this application's process.
PokerProcessClass class GenProcessClass
MSG_ADD message
MSG_POKER_SAVE_OPTIONS message
PokerProcessClass endc ;end of class definition
;------------------------------------------------------------------------------
; Resources
;------------------------------------------------------------------------------
include sizes.def
include gwpoker.rdef
;------------------------------------------------------------------------------
; Initialized variables and class structures
;------------------------------------------------------------------------------
idata segment
;Class definition is stored in the application's idata resource here.
PokerProcessClass mask CLASSF_NEVER_SAVED
idata ends
;------------------------------------------------------------------------------
; Uninitialized variables
;------------------------------------------------------------------------------
udata segment
udata ends
;------------------------------------------------------------------------------
; Code for PokerProcessClass
;------------------------------------------------------------------------------
CommonCode segment resource ;start of code resource
PokerStartUp method PokerProcessClass, MSG_GEN_PROCESS_OPEN_APPLICATION
call PokerSetViewBackgroundColor
; If the game is already open then we started to exit
; but were started backup. All the ui objects should still
; be in place. So just call the super class. Note -
; the AAF_RESTORING_FROM_STATE bit will be set in this
; case even though we aren't coming back from state, so
; checking for being open must come before checking the
; bit.
;
call PokerCheckIfGameIsOpen
jc callSuper
test cx, mask AAF_RESTORING_FROM_STATE
jz startingUp
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
mov ax, MSG_GAME_RESTORE_BITMAPS
mov di, mask MF_FIXUP_DS
call ObjMessage
callSuper:
mov di, offset PokerProcessClass
mov ax, MSG_GEN_PROCESS_OPEN_APPLICATION
call ObjCallSuperNoLock
setupSounds:
if STANDARD_SOUND
; Under any circumstances that we receive
; MSG_GEN_PROCESS_OPEN_APPLICATION the sound buffers will
; need to be created.
;
CallMod SoundSetupSounds
endif
; Mark the game as open so that we can detect the lazarus
; situation.
;
call PokerMarkGameOpen
ret
startingUp:
call PokerMakeSureTokenIsInstalled
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
mov ax, MSG_GAME_SETUP_STUFF
mov di, mask MF_FIXUP_DS
call ObjMessage
mov di, offset PokerProcessClass
mov ax, MSG_GEN_PROCESS_OPEN_APPLICATION
call ObjCallSuperNoLock
;
; We're not restoring from state, so we need to create a full
; deck and start a new game here
;
; Instantiate a full deck of cards,including 2 jokers
;
CallObject MyHand, MSG_HAND_MAKE_FULL_HAND, MF_FIXUP_DS
CallObject MyPlayingTable, MSG_ADD_JOKER, MF_FIXUP_DS
CallObject MyPlayingTable, MSG_ADD_JOKER, MF_FIXUP_DS
;
; Get which card back we're using
;
mov cx, cs
mov ds, cx ;DS:SI <- ptr to category string
mov si, offset pokerCategoryString
mov dx, offset pokerWhichBackString
call InitFileReadInteger
jc wild
mov_trash cx, ax ;cx <- which back
mov ax, MSG_GAME_SET_WHICH_BACK
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
clr di
call ObjMessage
wild:
;
; Get the wild choice
;
mov cx, cs
mov ds, cx
mov si, offset pokerCategoryString
mov dx, offset pokerWildString
call InitFileReadInteger
jc getPlayTune
mov_trash cx, ax ;cx <- wild
clr dx ;indeterminate ones
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
mov bx, handle WildList
mov si, offset WildList
clr di
call ObjMessage
getPlayTune:
;
; Set sound setting
;
mov cx, cs
mov ds, cx
mov si, offset pokerCategoryString ;category
mov dx, offset pokerPlayTuneString ;key
call InitFileReadInteger ;look into the .ini file
jc getFading
mov_trash cx, ax ;cx <- which back
mov dx, 0 ;not indeterminate
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
mov bx, handle SoundList
mov si, offset SoundList
clr di
call ObjMessage
getFading:
if FADING
;
; Set fading mode.
;
mov cx, cs
mov ds, cx
mov si, offset pokerCategoryString ;category
mov dx, offset pokerFadingString ;key
call InitFileReadBoolean ;look into the .ini file
jc initScore
mov_trash cx, ax ;dx = boolean Fade
clr dx ;indeterminate ones
mov bx, handle FadeList
mov si, offset FadeList
mov ax, MSG_GEN_BOOLEAN_GROUP_SET_GROUP_STATE
clr di
call ObjMessage
initScore:
endif
;
; Initialize the score and wager fields if not restoring from
; state.
;
mov cx, INITIAL_CASH
CallObject MyPlayingTable, MSG_GAME_UPDATE_SCORE, MF_FORCE_QUEUE
mov cx, INITIAL_WAGER
clr dx
CallObject MyPlayingTable, MSG_ADJUST_WAGER_AND_CASH, MF_FORCE_QUEUE
clr cx
clr dx
CallObject MyPlayingTable, MSG_SHOW_WINNINGS, MF_FORCE_QUEUE
;
; Read the UI to see whether or not we want wild cards to
; show up while playing
;
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
clr di
mov ax, MSG_SET_WILD
call ObjMessage
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
clr di
mov ax, MSG_SOLITAIRE_SET_FADE_STATUS
call ObjMessage
jmp setupSounds
PokerStartUp endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PokerCheckIfGameIsOpen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Will check if the varData ATTR_SOLITAIRE_GAME_OPEN
exists for MyPlayingTable
CALLED BY: SolitiareOpenApplication
PASS: nothing
RETURN: carry set if vardata found
carry clear if not found
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
PW 7/ 7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PokerCheckIfGameIsOpen proc near
uses ax,bx,cx,dx,si,di,bp
.enter
sub sp, size GetVarDataParams
mov bp, sp
mov ss:[bp].GVDP_dataType, \
ATTR_POKER_GAME_OPEN
mov {word} ss:[bp].GVDP_bufferSize, 0
; clrdw ss:[bp].GVDP_buffer
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
mov ax, MSG_META_GET_VAR_DATA
mov dx, size GetVarDataParams
mov di, mask MF_CALL or mask MF_STACK
call ObjMessage
add sp, size GetVarDataParams
cmp ax, -1 ; check if not found
stc
jne varDataFound
;varDataNotFound:
clc
varDataFound:
.leave
ret
PokerCheckIfGameIsOpen endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PokerMarkGameOpen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Will add the varData ATTR_SOLITAIRE_GAME_OPEN to
MyPlayingTable
CALLED BY: PokerOpenApplication
PASS: nothing
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
PW 7/ 7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PokerMarkGameOpen proc near
uses ax,bx,cx,dx,si,di,bp
.enter
sub sp, size AddVarDataParams
mov bp, sp
mov ss:[bp].AVDP_dataType, \
ATTR_POKER_GAME_OPEN
mov {word} ss:[bp].AVDP_dataSize, size byte
clrdw ss:[bp].AVDP_data
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
mov ax, MSG_META_ADD_VAR_DATA
mov dx, size AddVarDataParams
mov di, mask MF_CALL or mask MF_STACK
call ObjMessage
add sp, size AddVarDataParams
.leave
ret
PokerMarkGameOpen endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PokerMakeSureTokenIsInstalled
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: The zoomer doesn't force applications to install their tokens.
So we must do it ourselves
CALLED BY: INTERNAL
GWPokerStartUp
PASS: *ds:si - GWPokerProcessClass
RETURN:
nothing
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 8/20/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PokerMakeSureTokenIsInstalled proc near
uses ax,bx,cx,dx,bp,si,di
.enter
mov bx,handle PokerApp
mov si,offset PokerApp
mov di,mask MF_FIXUP_DS
mov ax,MSG_GEN_APPLICATION_INSTALL_TOKEN
call ObjMessage
.leave
ret
PokerMakeSureTokenIsInstalled endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PokerSetViewBackgroundColor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the background color of the view to green if on
a color display and white if on a black and white
display
CALLED BY: PokerOpenApplication
PASS:
RETURN:
nothing
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 6/ 7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PokerSetViewBackgroundColor proc near
uses ax,bx,cx,dx,di,si,bp
.enter
; Use VUP_QUERY to field to avoid building GenApp object.
;
mov bx, segment GenFieldClass
mov si, offset GenFieldClass
mov ax, MSG_VIS_VUP_QUERY
mov cx, VUQ_DISPLAY_SCHEME ; get display scheme
mov di, mask MF_RECORD
call ObjMessage ; di = event handle
mov cx, di ; cx = event handle
mov bx, handle PokerApp
mov si, offset PokerApp
mov ax, MSG_GEN_CALL_PARENT
mov di,mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage ; ah = display type, bp = ptsize
mov cl, C_GREEN ;assume color display
and ah, mask DT_DISP_CLASS
cmp ah, DC_GRAY_1 shl offset DT_DISP_CLASS
jne setColor
mov cl,C_WHITE
setColor:
mov ch, CF_INDEX or (CMT_DITHER shl offset CMM_MAP_TYPE)
mov bx,handle PokerView
mov si,offset PokerView
mov di,mask MF_FIXUP_DS
mov ax,MSG_GEN_VIEW_SET_COLOR
call ObjMessage
mov ch, CF_INDEX
mov di,mask MF_FIXUP_DS
mov bx,handle InstructionDisplay
mov si,offset InstructionDisplay
mov ax,MSG_VIS_TEXT_SET_WASH_COLOR
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle Instruction2Display
mov si,offset Instruction2Display
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle FiveOfAKindDisplay
mov si,offset FiveOfAKindDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle StraightFlushDisplay
mov si,offset StraightFlushDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle FourOfAKindDisplay
mov si,offset FourOfAKindDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle FullHouseDisplay
mov si,offset FullHouseDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle FlushDisplay
mov si,offset FlushDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle StraightDisplay
mov si,offset StraightDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle ThreeOfAKindDisplay
mov si,offset ThreeOfAKindDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle TwoPairDisplay
mov si,offset TwoPairDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle PairDisplay
mov si,offset PairDisplay
call ObjMessage
mov di,mask MF_FIXUP_DS
mov bx,handle LostDisplay
mov si,offset LostDisplay
call ObjMessage
.leave
ret
PokerSetViewBackgroundColor endp
;
; These strings are in the .ini file so do not have to be localizable
;
pokerCategoryString char "poker",0
pokerWhichBackString char "whichBack",0
pokerPlayTuneString char "playTunes",0
pokerWildString char "wild",0
if FADING
pokerFadingString char "fadeCards",0
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KlondikeSaveOptions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: This routine saves the current settings of the options menu
to the .ini file.
CALLED BY: GLOBAL
PASS: es - idata
RETURN: nada
DESTROYED: various important but undocumented things
PSEUDO CODE/STRATEGY:
This page intentionally left blank
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 1/ 3/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PokerSaveOptions method PokerProcessClass, MSG_POKER_SAVE_OPTIONS
;
; Save which back
;
mov ax, MSG_GAME_GET_WHICH_BACK
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
mov di, mask MF_CALL
call ObjMessage ;CX <- starting level
mov bp, cx ;BP <- value
mov cx, cs
mov ds, cx
mov si, offset pokerCategoryString
mov dx, offset pokerWhichBackString
call InitFileWriteInteger
;
; Save wild mode
;
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
mov bx, handle WildList
mov si, offset WildList
mov di, mask MF_CALL
call ObjMessage ;AX <- wild boolean
EC < ERROR_C -1 >
mov bp, ax ;BP <- value
mov cx, ds
mov si, offset pokerCategoryString
mov dx, offset pokerWildString
call InitFileWriteInteger
if FADING
;
; Save fade mode
;
mov ax, MSG_GEN_BOOLEAN_GROUP_GET_SELECTED_BOOLEANS
mov bx, handle FadeList
mov si, offset FadeList
mov di, mask MF_CALL
call ObjMessage
call ObjMessage ;LES_ACTUAL_EXCL set if on...
and ax, 1 ;filter through fade bit
mov cx, ds
mov si, offset pokerCategoryString
mov dx, offset pokerFadingString
call InitFileWriteBoolean
endif
;
; Save sound setting
;
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
mov bx, handle SoundList
mov si, offset SoundList
mov di, mask MF_CALL
call ObjMessage
EC < ERROR_C -1 >
mov bp, ax
mov cx, ds
mov si, offset pokerCategoryString
mov dx, offset pokerPlayTuneString
call InitFileWriteInteger
call InitFileCommit
ret
PokerSaveOptions endm
PokerShutDown method PokerProcessClass,
MSG_GEN_PROCESS_CLOSE_APPLICATION
.enter
if 0
mov ax, MSG_GAME_SAVE_STATE
mov bx, handle MyPlayingTable
mov si, offset MyPlayingTable
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
push cx ;save block
endif
CallObject MyPlayingTable, MSG_GAME_SHUTDOWN, MF_FIXUP_DS
mov di, segment PokerProcessClass
mov es, di
mov di, offset PokerProcessClass
mov ax, MSG_GEN_PROCESS_CLOSE_APPLICATION
call ObjCallSuperNoLock
if 0
pop cx
endif
.leave
ret
PokerShutDown endm
CommonCode ends ;end of CommonCode resource
|
nand2tetris/04/Screen Trial.asm | SleimiKhalil/HtDP | 1 | 166598 | <reponame>SleimiKhalil/HtDP
@SCREEN
M=-1
|
sound/musicasm/HCZ2.asm | NatsumiFox/Sonic-3-93-Nov-03 | 7 | 164002 | <filename>sound/musicasm/HCZ2.asm
HCZ2_Header:
sHeaderInit ; Z80 offset is $D492
sHeaderPatch HCZ2_Patches
sHeaderCh $06, $03
sHeaderTempo $01, $25
sHeaderDAC HCZ2_DAC
sHeaderFM HCZ2_FM1, $0C, $12
sHeaderFM HCZ2_FM2, $0C, $12
sHeaderFM HCZ2_FM3, $18, $18
sHeaderFM HCZ2_FM4, $18, $0D
sHeaderFM HCZ2_FM5, $18, $18
sHeaderPSG HCZ2_PSG1, $F4, $05, $00, v0C
sHeaderPSG HCZ2_PSG2, $F4, $05, $00, v0C
sHeaderPSG HCZ2_PSG3, $00, $03, $00, v0C
dc.b $F2, $F2 ; Unused
HCZ2_DAC:
dc.b dKick, $06
sPan spLeft
dc.b dHighTom, $02, dHighTom, $04, dHighTom, $06, dHighTom, dHighTom
dc.b dHighTom
sPan spCenter
dc.b dMidTom, dMidTom, dMidTom, dMidTom, dMidTom, dLowTom
sPan spRight
dc.b dLowTom, $02, dLowTom, $04, dLowTom, $06, dFloorTom, dFloorTom
sPan spCenter
dc.b dKick, $0C, dSnare, $1E, dKick, $0C, dKick, $12
dc.b dKick, $0C, dSnare, dKick, $06
sPan spLeft
dc.b dHighTom, $02, dHighTom, $04, dHighTom, $06, dHighTom, dHighTom
dc.b dHighTom
sPan spCenter
dc.b dMidTom, dMidTom, dMidTom, dMidTom, dMidTom, dLowTom
sPan spRight
dc.b dLowTom, $02, dLowTom, $04, dLowTom, $06, dFloorTom, dFloorTom
sPan spCenter
dc.b dKick, $0C, dSnare, $1E, dKick, $0C, dKick, $12
dc.b dKick, $0C, dSnare, dKick, $18, dSnare, $06, dKick
dc.b $0C, dKick, dKick, $12, dSnare, $0C, dKick, dKick
dc.b $18, dSnare, $06, dKick, $0C, dKick, dKick, $12
dc.b dSnare, $0C, dKick, dKick, $18, dSnare, $06, dKick
dc.b $0C, dKick, dKick, $12, dSnare, $0C, dKick, dKick
dc.b $24, dSnare, $06, dKick, $0C, dKick, $12, dKick
dc.b $0C, dSnare, dKick, $18, dSnare, $06, dKick, $0C
dc.b dKick, dKick, $12, dSnare, $0C, dKick, dKick, $18
dc.b dSnare, $06, dKick, $0C, dKick, dKick, $12, dSnare
dc.b $0C, dKick, dKick, $18, dSnare, $06, dKick, $0C
dc.b dKick, dKick, $12, dSnare, $0C, dKick, $06, dSnare
dc.b $0C, dKick, dKick, $06, dHighTom, dMidTom, dLowTom, dSnare
dc.b $18, dSnare, $0C, dSnare, $02, dSnare, $04, dSnare
dc.b $06, dSnare, dKick, $18, dSnare, $06, dKick, $0C
dc.b dKick, $1E, dSnare, $0C, dKick, dKick, $18, dSnare
dc.b $06, dKick, $0C, dKick, $1E, dSnare, $0C, dKick
dc.b dKick, $18, dSnare, $06, dKick, $0C, dKick, $1E
dc.b dSnare, $0C, dKick, $12, dSnare, dSnare, $0C, dSnare
dc.b $06, dSnare, $0C, dSnare, $12, dSnare, $06, dSnare
dc.b dSnare, dSnare, dKick, $18, dSnare, $06, dKick, $0C
dc.b dKick, $1E, dSnare, $0C, dKick, dKick, $18, dSnare
dc.b $06, dKick, $0C, dKick, $1E, dSnare, $0C, dKick
dc.b dKick, $18, dSnare, $06, dKick, $0C, dKick, $1E
dc.b dSnare, $0C, dKick, $06, dKick, $0C, dKick, dKick
dc.b $06, dSnare, dKick, dKick, dSnare, dKick, dKick, $0C
dc.b dSnare, dSnare, $06, dSnare, dSnare, dKick, $12, dKick
dc.b $06, dSnare, $1E, dKick, $06, dKick, $0C, dSnare
dc.b $18, dKick, $12, dKick, $06, dSnare, $1E, dKick
dc.b $06, dKick, $0C, dSnare, $18, dKick, $12, dKick
dc.b $06, dSnare, $1E, dKick, $06, dKick, $0C, dSnare
dc.b $18, dKick, $0C, dSnare, dKick, $06, dSnare, $0C
dc.b dSnare, $06, dKick, dSnare, $12, dSnare, $04, dSnare
dc.b dSnare, dSnare, $06, dSnare, dKick, $12, dKick, $06
dc.b dSnare, $1E, dKick, $06, dKick, $0C, dSnare, $18
dc.b dKick, $12, dKick, $06, dSnare, $1E, dKick, $06
dc.b dKick, $0C, dSnare, $18, dKick, $12, dKick, $06
dc.b dSnare, $1E, dKick, $06, dKick, $0C, dSnare, $1E
dc.b dSnare, $0C, dSnare, dSnare, $06, dSnare, $0C, dSnare
dc.b $18, dSnare, $02, dSnare, dSnare, dSnare, $06, dSnare
dc.b dSnare
sJump HCZ2_DAC
dc.b $F2 ; Unused
HCZ2_FM1:
sPatFM $06
ssDetune $01
ssModZ80 $0A, $01, $03, $06
dc.b nF3, $04, nRst, $08, nF3, $04, nRst, $0E
dc.b nF3, $04, nRst, $02, nF3, nRst, $04, nF3
dc.b $0A, nRst, $02, nF3, $0A, nRst, $02, nBb2
dc.b $04, nRst, $02, nF3, $04, nRst, $08, nF3
dc.b $04, nRst, $08, nEb3, $04, nRst, $08, nEb3
dc.b $04, nRst, $0E, nEb3, $04, nRst, $02, nEb3
dc.b nRst, $04, nE3, nRst, $08, nE3, $10, nRst
dc.b $02, nE3, $04, nRst, $08, nE3, $04, nRst
dc.b $08, nF3, $04, nRst, $08, nF3, $04, nRst
dc.b $0E, nF3, $04, nRst, $02, nF3, nRst, $04
dc.b nF3, $0A, nRst, $02, nF3, $0A, nRst, $02
dc.b nBb2, $04, nRst, $02, nF3, $04, nRst, $08
dc.b nF3, $04, nRst, $08, nEb3, $04, nRst, $08
dc.b nEb3, $04, nRst, $0E, nEb3, $04, nRst, $02
dc.b nEb3, nRst, $04, nE3, nRst, $08, nE3, $10
dc.b nRst, $02, nE3, $04, nRst, $08, nE3, $04
dc.b nRst, $08, nF3, $04, nRst, $08, nF3, $04
dc.b nRst, $0E, nF3, $04, nRst, $02, nF3, nRst
dc.b $04, nF3, $0A, nRst, $02, nF3, $0A, nRst
dc.b $02, nBb2, $04, nRst, $02, nF3, $04, nRst
dc.b $08, nF3, $04, nRst, $08, nEb3, $04, nRst
dc.b $08, nEb3, $04, nRst, $0E, nEb3, $04, nRst
dc.b $02, nEb3, nRst, $04, nE3, nRst, $08, nE3
dc.b $10, nRst, $02, nE3, $04, nRst, $08, nE3
dc.b $04, nRst, $08, nF3, $04, nRst, $08, nF3
dc.b $04, nRst, $0E, nF3, $04, nRst, $02, nF3
dc.b nRst, $04, nF3, $0A, nRst, $02, nF3, $0A
dc.b nRst, $02, nBb2, $04, nRst, $02, nF3, $04
dc.b nRst, $08, nF3, $04, nRst, $08, nEb3, $04
dc.b nRst, $08, nEb3, $04, nRst, $0E, nEb3, $04
dc.b nRst, $02, nEb3, nRst, $04, nE3, nRst, $08
dc.b nE3, $10, nRst, $02, nE3, $04, nRst, $08
dc.b nE3, $04, nRst, $08, nF3, $04, nRst, $08
dc.b nF3, $04, nRst, $0E, nF3, $04, nRst, $02
dc.b nF3, nRst, $04, nF3, $0A, nRst, $02, nF3
dc.b $0A, nRst, $02, nBb2, $04, nRst, $02, nF3
dc.b $04, nRst, $08, nF3, $04, nRst, $08, nEb3
dc.b $04, nRst, $08, nEb3, $04, nRst, $0E, nEb3
dc.b $04, nRst, $02, nEb3, nRst, $04, nE3, nRst
dc.b $08, nE3, $10, nRst, $02, nE3, $04, nRst
dc.b $08, nE3, $04, nRst, $08, nF3, $04, nRst
dc.b $08, nF3, $04, nRst, $0E, nF3, $04, nRst
dc.b $02, nF3, nRst, $04, nF3, $0A, nRst, $02
dc.b nF3, $0A, nRst, $02, nBb2, $04, nRst, $02
dc.b nF3, $04, nRst, $08, nF3, $04, nRst, $02
dc.b nEb3, $04, nRst, $08, nC4, $06, nBb3, nG3
dc.b nF3, $04, nFs3, nF3, nEb3, $06, nC3, nRst
dc.b $12, nF3, $1E, nEb3, $0A, nRst, $02, nD3
dc.b $04, nRst, $02, nEb3, $0A, nRst, $02, nD3
dc.b $0A, nRst, $02, nEb3, $04, nRst, $0E, nC4
dc.b $04, nRst, $02, nC4, $04, nRst, $08, nD4
dc.b $02, nRst, $04, nEb4, $0A, nRst, $02, nD3
dc.b $0A, nRst, $02, nF3, $04, nRst, $02, nD3
dc.b $0A, nRst, $02, nF3, $0A, nRst, $02, nD3
dc.b $04, nRst, $0E, nBb3, $04, nRst, $02, nBb3
dc.b $04, nRst, $08, nC4, $02, nRst, $04, nD4
dc.b $0A, nRst, $02, nD3, $0A, nRst, $02, nC3
dc.b $04, nRst, $02, nD3, $0A, nRst, $02, nC3
dc.b $0A, nRst, $02, nD3, $04, nRst, $0E, nD4
dc.b $04, nRst, $02, nD4, $04, nRst, $08, nEb4
dc.b $02, nRst, $04, nF4, $0A, nRst, $08, nBb3
dc.b $04, nRst, $0E, nBb3, $0A, nRst, $02, nBb3
dc.b $04, nRst, $02, nBb3, $04, nRst, $08, nBb3
dc.b $10, nRst, $02, nEb3, $0A, nRst, $02, nF3
dc.b $0A, nRst, $02, nEb3, $0A, nRst, $02, nD3
dc.b $04, nRst, $02, nEb3, $0A, nRst, $02, nD3
dc.b $0A, nRst, $02, nEb3, $04, nRst, $0E, nC4
dc.b $04, nRst, $02, nC4, $04, nRst, $08, nD4
dc.b $02, nRst, $04, nEb4, $0A, nRst, $02, nD3
dc.b $0A, nRst, $02, nF3, $04, nRst, $02, nD3
dc.b $0A, nRst, $02, nF3, $0A, nRst, $02, nBb2
dc.b $04, nRst, $0E, nBb3, $04, nRst, $02, nBb3
dc.b $04, nRst, $08, nEb4, $02, nRst, $04, nG4
dc.b $0A, nRst, $02, nEb3, $0A, nRst, $02, nBb2
dc.b $04, nRst, $02, nEb3, $0A, nRst, $02, nBb2
dc.b $0A, nRst, $02, nC3, $04, nRst, $0E, nA3
dc.b $04, nRst, $02, nA3, $04, nRst, $08, nC4
dc.b $02, nRst, $04, nEb4, $0A, nRst, $08, nEb4
dc.b $04, nRst, $08, nEb4, $04, nRst, $08, nEb4
dc.b $04, nRst, $02, nEb4, $0A, nRst, $02, nB3
dc.b $04, nRst, $02, nB3, $04, nRst, $08, nB3
dc.b $04, nRst, $0E, nEb3, $04, nRst, $02, nF3
dc.b $04, nRst, $08, nG3, $04, nRst, $02, nF3
dc.b $04, nRst, $02, nEb3, $04, nRst, $08, nD3
dc.b $04, nRst, $02, nEb3, $04, nRst, $02, nC3
dc.b $04, nRst, $08, nBb3, $10, nRst, $02, nG3
dc.b $04, nRst, $08, nF3, $04, nRst, $0E, nD4
dc.b $04, nRst, $02, nBb3, $04, nRst, $02, nG3
dc.b $04, nRst, $02, nEb3, $10, nRst, $02, nD3
dc.b $34, nRst, $08, nG3, $04, nRst, $02, nF3
dc.b $04, nRst, $02, nEb3, $04, nRst, $08, nD3
dc.b $04, nRst, $02, nEb3, $04, nRst, $02, nC3
dc.b $04, nRst, $08, nB3, $10, nRst, $02, nG3
dc.b $04, nRst, $08, nF3, $04, nRst, $08, nG3
dc.b $16, nRst, $02, nBb3, $10, nRst, $02, nBb3
dc.b $04, nRst, $08, nAb3, $10, nRst, $02, nG3
dc.b $16, nRst, $08, nG3, $04, nRst, $02, nF3
dc.b $04, nRst, $02, nEb3, $04, nRst, $08, nD3
dc.b $04, nRst, $02, nEb3, $04, nRst, $02, nC3
dc.b $04, nRst, $08, nBb3, $10, nRst, $02, nG3
dc.b $04, nRst, $08, nF3, $04, nRst, $0E, nD4
dc.b $04, nRst, $02, nBb3, $04, nRst, $02, nG3
dc.b $04, nRst, $02, nEb3, $10, nRst, $02, nD3
dc.b $34, nRst, $08, nG3, $04, nRst, $02, nF3
dc.b $04, nRst, $02, nEb3, $04, nRst, $08, nD3
dc.b $04, nRst, $02, nEb3, $04, nRst, $02, nC3
dc.b $04, nRst, $08, nEb2, $04, nRst, $02, nAb2
dc.b $04, nRst, $02, nEb2, $04, nRst, $02, nEb3
dc.b $0A, nRst, $02, nAb3, $0A, nRst, $08, nG3
dc.b $04, nRst, $08, nG3, $04, nRst, $08, nG3
dc.b $04, nRst, $02, nG3, $0A, nRst, $02, nG3
dc.b $04, nRst, $2C
sJump HCZ2_FM1
dc.b $F2 ; Unused
HCZ2_FM2:
sPatFM $06
ssDetune $FF
ssModZ80 $0A, $01, $03, $06
dc.b nBb2, $04, nRst, $08, nBb2, $04, nRst, $0E
dc.b nBb2, $04, nRst, $02, nBb2, nRst, $04, nBb2
dc.b $0A, nRst, $02, nBb2, $0A, nRst, $08, nBb2
dc.b $04, nRst, $08, nBb2, $04, nRst, $08, nA2
dc.b $04, nRst, $08, nA2, $04, nRst, $0E, nA2
dc.b $04, nRst, $02, nA2, nRst, $04, nBb2, nRst
dc.b $08, nBb2, $10, nRst, $02, nBb2, $04, nRst
dc.b $08, nBb2, $04, nRst, $08, nBb2, $04, nRst
dc.b $08, nBb2, $04, nRst, $0E, nBb2, $04, nRst
dc.b $02, nBb2, nRst, $04, nBb2, $0A, nRst, $02
dc.b nBb2, $0A, nRst, $08, nBb2, $04, nRst, $08
dc.b nBb2, $04, nRst, $08, nA2, $04, nRst, $08
dc.b nA2, $04, nRst, $0E, nA2, $04, nRst, $02
dc.b nA2, nRst, $04, nBb2, nRst, $08, nBb2, $10
dc.b nRst, $02, nBb2, $04, nRst, $08, nBb2, $04
dc.b nRst, $08, nBb2, $04, nRst, $08, nBb2, $04
dc.b nRst, $0E, nBb2, $04, nRst, $02, nBb2, nRst
dc.b $04, nBb2, $0A, nRst, $02, nBb2, $0A, nRst
dc.b $08, nBb2, $04, nRst, $08, nBb2, $04, nRst
dc.b $08, nA2, $04, nRst, $08, nA2, $04, nRst
dc.b $0E, nA2, $04, nRst, $02, nA2, nRst, $04
dc.b nBb2, nRst, $08, nBb2, $10, nRst, $02, nBb2
dc.b $04, nRst, $08, nBb2, $04, nRst, $08, nBb2
dc.b $04, nRst, $08, nBb2, $04, nRst, $0E, nBb2
dc.b $04, nRst, $02, nBb2, nRst, $04, nBb2, $0A
dc.b nRst, $02, nBb2, $0A, nRst, $08, nBb2, $04
dc.b nRst, $08, nBb2, $04, nRst, $08, nA2, $04
dc.b nRst, $08, nA2, $04, nRst, $0E, nA2, $04
dc.b nRst, $02, nA2, nRst, $04, nBb2, nRst, $08
dc.b nBb2, $10, nRst, $02, nBb2, $04, nRst, $08
dc.b nBb2, $04, nRst, $08, nBb2, $04, nRst, $08
dc.b nBb2, $04, nRst, $0E, nBb2, $04, nRst, $02
dc.b nBb2, nRst, $04, nBb2, $0A, nRst, $02, nBb2
dc.b $0A, nRst, $08, nBb2, $04, nRst, $08, nBb2
dc.b $04, nRst, $08, nA2, $04, nRst, $08, nA2
dc.b $04, nRst, $0E, nA2, $04, nRst, $02, nA2
dc.b nRst, $04, nBb2, nRst, $08, nBb2, $10, nRst
dc.b $02, nBb2, $04, nRst, $08, nBb2, $04, nRst
dc.b $08, nBb2, $04, nRst, $08, nBb2, $04, nRst
dc.b $0E, nBb2, $04, nRst, $02, nBb2, nRst, $04
dc.b nBb2, $0A, nRst, $02, nBb2, $0A, nRst, $08
dc.b nBb2, $04, nRst, $08, nBb2, $04, nRst, $02
dc.b nBb2, $04, nRst, $44, nB2, $1E, nC3, $0A
dc.b nRst, $02, nBb2, $04, nRst, $02, nC3, $0A
dc.b nRst, $02, nBb2, $0A, nRst, $02, nC3, $04
dc.b nRst, $0E, nAb3, $04, nRst, $02, nAb3, $04
dc.b nRst, $08, nBb3, $02, nRst, $04, nC4, $0A
dc.b nRst, $02, nBb2, $0A, nRst, $02, nD3, $04
dc.b nRst, $02, nBb2, $0A, nRst, $02, nD3, $0A
dc.b nRst, $02, nBb2, $04, nRst, $0E, nG3, $04
dc.b nRst, $02, nG3, $04, nRst, $08, nAb3, $02
dc.b nRst, $04, nBb3, $0A, nRst, $02, nBb2, $0A
dc.b nRst, $02, nAb2, $04, nRst, $02, nBb2, $0A
dc.b nRst, $02, nAb2, $0A, nRst, $02, nBb2, $04
dc.b nRst, $0E, nBb3, $04, nRst, $02, nBb3, $04
dc.b nRst, $08, nC4, $02, nRst, $04, nD4, $0A
dc.b nRst, $08, nG3, $04, nRst, $0E, nF3, $0A
dc.b nRst, $02, nF3, $04, nRst, $02, nG3, $04
dc.b nRst, $08, nD3, $10, nRst, $02, nC3, $0A
dc.b nRst, $02, nD3, $0A, nRst, $02, nC3, $0A
dc.b nRst, $02, nBb2, $04, nRst, $02, nC3, $0A
dc.b nRst, $02, nBb2, $0A, nRst, $02, nC3, $04
dc.b nRst, $0E, nAb3, $04, nRst, $02, nAb3, $04
dc.b nRst, $08, nBb3, $02, nRst, $04, nC4, $0A
dc.b nRst, $02, nBb2, $0A, nRst, $02, nD3, $04
dc.b nRst, $02, nBb2, $0A, nRst, $02, nD3, $0A
dc.b nRst, $02, nG2, $04, nRst, $0E, nG3, $04
dc.b nRst, $02, nG3, $04, nRst, $08, nBb3, $02
dc.b nRst, $04, nEb4, $0A, nRst, $02, nBb2, $0A
dc.b nRst, $02, nG2, $04, nRst, $02, nBb2, $0A
dc.b nRst, $02, nG2, $0A, nRst, $02, nA2, $04
dc.b nRst, $0E, nF3, $04, nRst, $02, nF3, $04
dc.b nRst, $08, nA3, $02, nRst, $04, nC4, $0A
dc.b nRst, $08, nG3, $04, nRst, $08, nG3, $04
dc.b nRst, $08, nG3, $04, nRst, $02, nG3, $0A
dc.b nRst, $02, nF3, $04, nRst, $02, nF3, $04
dc.b nRst, $08, nF3, $04, nRst, $0E, nC3, $04
dc.b nRst, $02, nD3, $04, nRst, $08, nEb3, $04
dc.b nRst, $02, nD3, $04, nRst, $02, nC3, $04
dc.b nRst, $08, nBb2, $04, nRst, $02, nC3, $04
dc.b nRst, $02, nAb2, $04, nRst, $08, nF3, $10
dc.b nRst, $02, nEb3, $04, nRst, $08, nD3, $04
dc.b nRst, $0E, nBb3, $04, nRst, $02, nG3, $04
dc.b nRst, $02, nEb3, $04, nRst, $02, nC3, $10
dc.b nRst, $02, nF2, $34, nRst, $08, nEb3, $04
dc.b nRst, $02, nD3, $04, nRst, $02, nC3, $04
dc.b nRst, $08, nBb2, $04, nRst, $02, nC3, $04
dc.b nRst, $02, nAb2, $04, nRst, $08, nF3, $10
dc.b nRst, $02, nEb3, $04, nRst, $08, nD3, $04
dc.b nRst, $08, nEb3, $16, nRst, $02, nF3, $10
dc.b nRst, $02, nF3, $04, nRst, $08, nEb3, $10
dc.b nRst, $02, nD3, $16, nRst, $08, nEb3, $04
dc.b nRst, $02, nD3, $04, nRst, $02, nC3, $04
dc.b nRst, $08, nBb2, $04, nRst, $02, nC3, $04
dc.b nRst, $02, nAb2, $04, nRst, $08, nF3, $10
dc.b nRst, $02, nEb3, $04, nRst, $08, nD3, $04
dc.b nRst, $0E, nBb3, $04, nRst, $02, nG3, $04
dc.b nRst, $02, nEb3, $04, nRst, $02, nC3, $10
dc.b nRst, $02, nF2, $34, nRst, $08, nEb3, $04
dc.b nRst, $02, nD3, $04, nRst, $02, nC3, $04
dc.b nRst, $08, nBb2, $04, nRst, $02, nC3, $04
dc.b nRst, $02, nAb2, $04, nRst, $1A, nC3, $0A
dc.b nRst, $02, nEb3, $0A, nRst, $08, nD3, $04
dc.b nRst, $08, nD3, $04, nRst, $08, nD3, $04
dc.b nRst, $02, nD3, $0A, nRst, $02, nD3, $04
dc.b nRst, $2C
sJump HCZ2_FM2
dc.b $F2 ; Unused
HCZ2_FM3:
sPan spLeft
sPatFM $03
ssDetune $FE
ssModZ80 $0F, $01, $06, $06
dc.b nRst, $7F, nRst, nRst, $76, nG4, $06, nBb4
dc.b nC5, nG4, nF4, $02, nEb4, nD4, nC4, nBb3
dc.b nA3, nG3, nRst, $04, nBb3, $06, nC4, nG3
dc.b nF3, $02, nFs3, $04, nF3, $06, nEb3, nC3
dc.b nG3, $02, nA3, nBb3, $08, nBb3, $02, nBb3
dc.b $04, nA3, $12, nG3, $02, nFs3, nF3, nEb3
dc.b nD3, nC3, nBb2, nA2, nG2, nRst, $36, nBb3
dc.b $06, nB3, nC4, nFs3, $02, nG3, $04, nF3
dc.b $02, nEb3, nC3, nBb2, nA2, nG2, nF2, nEb2
dc.b $04, nF3, $02, nFs3, $04, nF3, $06, nEb3
dc.b nF3, nEb3, nC3, nBb2, nG3, $0C, nG3, $06
dc.b nC4, $12, nA3, $02, nG3, nF3, nEb3, nD3
dc.b nC3, nRst, $3C, nG4, $06, nBb4, nC5, nG4
dc.b nF4, $02, nEb4, nD4, nC4, nBb3, nA3, nG3
dc.b nRst, $04, nBb3, $06, nC4, nG3, nF3, $02
dc.b nFs3, $04, nF3, $06, nEb3, nC3, nG3, $02
dc.b nA3, nBb3, $08, nBb3, $02, nBb3, $04, nA3
dc.b $12, nG3, $02, nF3, nEb3, nD3, nC3, nBb2
dc.b nA2, nG2, nF2, nRst, $36, nBb3, $06, nB3
dc.b nC4, nFs3, $02, nG3, $04, nF3, $02, nEb3
dc.b nC3, nBb2, nA2, nG2, nF2, nEb2, $04, nF3
dc.b $02, nFs3, $04, nF3, $06, nEb3, nF3, nEb3
dc.b nC3, nBb2, nG3, $0C, nG3, $06, nEb3, $12
dc.b nD3, $02, nC3, nBb2, nA2, nG2, nF2, nRst
dc.b $1E
sPatFM $0E
ssDetune $01
ssModZ80 $0F, $01, $06, $06
saTranspose $F4
dc.b nF3, $06, nFs3, $02, nG3, $04, nBb3, $06
dc.b nEb4, nF4, nG4, nBb4, nD5, $02, nEb5, $08
dc.b nRst, $02, nF5, $04, nRst, $02, nFs5, nG5
dc.b $08, nRst, $02, nC5, $0A, nRst, $02, nFs5
dc.b nG5, $26, nRst, $02, nF5, $04, nRst, $02
dc.b nEb5, $04, nRst, $02, nCs5, nD5, $26, nRst
dc.b $02, nBb4, $34, nRst, $02, nCs5, nD5, $08
dc.b nRst, $02, nEb5, $04, nRst, $02, nE5, nF5
dc.b $08, nRst, $02, nBb4, $0A, nRst, $02, nF5
dc.b nF5, $26, nRst, $02, nEb5, $04, nRst, $02
dc.b nD5, $04, nRst, $02, nC5, $2E, nRst, $08
dc.b nD5, $10, nRst, $02, nEb5, $0A, nRst, $02
dc.b nF5, $0A, nRst, $02, nD5, nEb5, $08, nRst
dc.b $02, nF5, $04, nRst, $02, nFs5, nG5, $08
dc.b nRst, $02, nC5, $0A, nRst, $02, nG5, $28
dc.b nRst, $02, nF5, $04, nRst, $02, nEb5, $04
dc.b nRst, $02, nCs5, nD5, $26, nRst, $02, nEb5
dc.b $1C, nRst, $0E, nEb5, $04, nRst, $02, nF5
dc.b $04, nRst, $02, nFs5, nG5, $08, nRst, $02
dc.b nEb5, $04, nRst, $02, nG5, $0A, nRst, $02
dc.b nBb4, $0A, nRst, $02, nC5, $28, nRst, $02
dc.b nEb5, $04, nRst, $02, nF5, $04, nRst, $02
dc.b nG5, $2E, nRst, $02, nF5, $12, nEb5, $02
dc.b nD5, nC5, nBb4, nAb4, nG4, nF4, nEb4, nD4
sPatFM $03
ssDetune $FE
ssModZ80 $0F, $01, $06, $06
saTranspose $0C
dc.b nC4, $04, nRst, $02, nD4, $04, nRst, $02
dc.b nEb4, $0C, nD4, $02, nC4, nBb3, nAb3, nG3
dc.b nF3, nC4, $0A, nRst, $02, nEb4, $04, nRst
dc.b $02, nE4, nF4, nRst, $08, nD4, $10, nRst
dc.b $02, nC4, $04, nRst, $08, nBb3, $04, nRst
dc.b $08, nFs3, $02, nG3, $14, nRst, $02, nFs3
dc.b nG3, $08, nRst, $02, nF3, $04, nRst, $02
dc.b nFs3, nG3, $28, nC4, $04, nRst, $02, nD4
dc.b $04, nRst, $02, nEb4, $0C, nD4, $02, nC4
dc.b nBb3, nAb3, nG3, nF3, nC4, $0A, nRst, $02
dc.b nEb4, $04, nRst, $02, nE4, nF4, nRst, $08
dc.b nD4, $10, nRst, $02, nC4, $04, nRst, $08
dc.b nB3, $04, nRst, $08, nC4, $10, nRst, $02
dc.b nC4, $04, nRst, $02, nD4, $0A, nRst, $02
dc.b nC4, $04, nRst, $02, nD4, $04, nRst, $08
dc.b nEb4, $10, nRst, $02, nF4, $0A, nRst, $02
dc.b nC4, $04, nRst, $02, nD4, $04, nRst, $02
dc.b nEb4, $0C, nD4, $02, nC4, nBb3, nAb3, nG3
dc.b nF3, nC4, $0A, nRst, $02, nEb4, $04, nRst
dc.b $02, nE4, nF4, nRst, $08, nD4, $10, nRst
dc.b $02, nC4, $04, nRst, $08, nBb3, $04, nRst
dc.b $08, nFs3, $02, nG3, $14, nRst, $02, nFs3
dc.b nG3, $08, nRst, $02, nF3, $04, nRst, $02
dc.b nFs3, nG3, $28, nC4, $04, nRst, $02, nD4
dc.b $04, nRst, $02, nEb4, $10, nRst, $02, nEb4
dc.b $04, nRst, $08, nD4, $04, nRst, $02, nEb4
dc.b $10, nRst, $02, nEb4, $04, nRst, $02, nF4
dc.b $0A, nRst, $02, nEb4, $04, nRst, $08, nAb4
dc.b $04, nRst, $0E, nC5, $04, nRst, $08, nC5
dc.b $04, nRst, $08, nC5, $04, nRst, $02, nC5
dc.b $0A, nRst, $02, nB4, $04, nRst, $2C
sJump HCZ2_FM3
dc.b $F2 ; Unused
HCZ2_FM4:
sPatFM $15
ssDetune $00
ssModZ80 $0F, $01, $06, $06
dc.b nC1, $0A, nRst, $02, nEb1, nRst, $04, nC1
dc.b $10, nRst, $02, nEb1, nRst, $04, nF1, nRst
dc.b $08, nEb1, $10, nRst, $02, nF1, $16, nRst
dc.b $02, nC1, $0A, nRst, $02, nA0, nRst, $04
dc.b nC1, $12, nA0, $04, nRst, $02, nBb0, $04
dc.b nRst, $08, nG0, $10, nRst, $02, nBb0, $16
dc.b nRst, $02, nC1, $0A, nRst, $02, nEb1, nRst
dc.b $04, nC1, $10, nRst, $02, nEb1, nRst, $04
dc.b nF1, nRst, $08, nEb1, $10, nRst, $02, nF1
dc.b $16, nRst, $02, nC1, $0A, nRst, $02, nA0
dc.b nRst, $04, nC1, $12, nA0, $04, nRst, $02
dc.b nBb0, $04, nRst, $08, nG0, $10, nRst, $02
dc.b nBb0, $16, nRst, $02, nC1, $0A, nRst, $02
dc.b nEb1, nRst, $04, nC1, $10, nRst, $02, nEb1
dc.b nRst, $04, nF1, nRst, $08, nEb1, $10, nRst
dc.b $02, nF1, $16, nRst, $02, nC1, $0A, nRst
dc.b $02, nA0, nRst, $04, nC1, $12, nA0, $04
dc.b nRst, $02, nBb0, $04, nRst, $08, nG0, $10
dc.b nRst, $02, nBb0, $16, nRst, $02, nC1, $0A
dc.b nRst, $02, nEb1, nRst, $04, nC1, $10, nRst
dc.b $02, nEb1, nRst, $04, nF1, nRst, $08, nEb1
dc.b $10, nRst, $02, nF1, $16, nRst, $02, nC1
dc.b $0A, nRst, $02, nA0, nRst, $04, nC1, $12
dc.b nA0, $04, nRst, $02, nBb0, $04, nRst, $08
dc.b nG0, $10, nRst, $02, nBb0, $16, nRst, $02
dc.b nC1, $0A, nRst, $02, nEb1, nRst, $04, nC1
dc.b $10, nRst, $02, nEb1, $04, nRst, $02, nF1
dc.b $04, nRst, $08, nEb1, $10, nRst, $02, nF1
dc.b $16, nRst, $02, nC1, $0A, nRst, $02, nA0
dc.b nRst, $04, nC1, $12, nA0, $04, nRst, $02
dc.b nBb0, $04, nRst, $08, nG0, $10, nRst, $02
dc.b nBb0, $16, nRst, $02, nC1, $0A, nRst, $02
dc.b nEb1, nRst, $04, nC1, $10, nRst, $02, nEb1
dc.b $04, nRst, $02, nF1, $04, nRst, $08, nEb1
dc.b $10, nRst, $02, nF1, $10, nRst, $02, nEb1
dc.b $04, nRst, $08, nC2, $04, nRst, $02, nBb1
dc.b $04, nRst, $02, nG1, $04, nRst, $02, nF1
dc.b $04, nFs1, nF1, nEb1, $06, nC1, $04, nRst
dc.b $14, nG0, $1C, nRst, $02, nAb0, $0A, nRst
dc.b $02, nAb0, nRst, $04, nAb1, nRst, $08, nAb0
dc.b $04, nRst, $08, nAb0, $04, nRst, $08, nAb1
dc.b $04, nRst, $02, nAb0, $16, nRst, $02, nAb0
dc.b $04, nRst, $08, nG0, $0A, nRst, $02, nG0
dc.b nRst, $04, nG1, nRst, $08, nG0, $04, nRst
dc.b $08, nG0, $04, nRst, $08, nG1, $04, nRst
dc.b $02, nG0, $16, nRst, $02, nG0, $04, nRst
dc.b $08, nBb0, $0A, nRst, $02, nBb0, nRst, $04
dc.b nBb1, nRst, $08, nBb0, $04, nRst, $08, nBb0
dc.b $04, nRst, $08, nBb1, $04, nRst, $02, nBb0
dc.b $10, nRst, $02, nBb0, nRst, $04, nBb0, nRst
dc.b $0E, nC1, $04, nRst, $0E, nC1, $04, nRst
dc.b $08, nC2, $04, nRst, $02, nC1, $04, nRst
dc.b $08, nC2, $10, nRst, $02, nC1, $0A, nRst
dc.b $02, nC2, $0A, nRst, $02, nAb0, $0A, nRst
dc.b $02, nAb0, nRst, $04, nAb1, nRst, $08, nAb0
dc.b $04, nRst, $08, nAb0, $04, nRst, $08, nAb1
dc.b $04, nRst, $02, nAb0, $16, nRst, $02, nAb0
dc.b $04, nRst, $08, nG0, $0A, nRst, $02, nG0
dc.b nRst, $04, nG1, nRst, $08, nG0, $04, nRst
dc.b $08, nG0, $04, nRst, $08, nG1, $04, nRst
dc.b $02, nG0, $16, nRst, $02, nG0, $04, nRst
dc.b $08, nF0, $0A, nRst, $02, nF0, nRst, $04
dc.b nF1, nRst, $08, nF0, $04, nRst, $08, nF0
dc.b $04, nRst, $08, nF1, $04, nRst, $02, nF0
dc.b $16, nRst, $02, nF0, nRst, $04, nAb0, nRst
dc.b $08, nAb0, $04, nRst, $08, nAb0, $04, nRst
dc.b $08, nAb0, $04, nRst, $02, nAb0, $0A, nRst
dc.b $02, nG0, $04, nRst, $02, nG0, $04, nRst
dc.b $08, nG0, $04, nRst, $08, nG1, $04, nRst
dc.b $02, nG0, $04, nRst, $02, nG0, $04, nRst
dc.b $02, nF0, $10, nRst, $02, nF0, nRst, $22
dc.b nG0, $02, nRst, $04, nG1, $0A, nRst, $02
dc.b nG0, $16, nRst, $02, nAb0, $10, nRst, $02
dc.b nAb0, nRst, $22, nBb0, $02, nRst, $04, nBb1
dc.b $0A, nRst, $02, nBb0, $0A, nRst, $02, nBb1
dc.b $0A, nRst, $02, nF0, $10, nRst, $02, nF0
dc.b nRst, $22, nG0, $02, nRst, $04, nG1, $0A
dc.b nRst, $02, nG0, $16, nRst, $02, nC1, $10
dc.b nRst, $02, nC2, nRst, $04, nBb0, $10, nRst
dc.b $02, nBb1, nRst, $0A, nAb0, $02, nRst, $04
dc.b nAb1, $0A, nRst, $02, nG0, $0A, nRst, $02
dc.b nG1, $0A, nRst, $02, nF0, $10, nRst, $02
dc.b nF0, nRst, $22, nG0, $02, nRst, $04, nG1
dc.b $0A, nRst, $02, nG0, $16, nRst, $02, nAb0
dc.b $10, nRst, $02, nAb0, nRst, $22, nBb0, $02
dc.b nRst, $04, nBb1, $0A, nRst, $02, nBb0, $0A
dc.b nRst, $02, nBb1, $0A, nRst, $02, nAb0, $10
dc.b nRst, $02, nAb0, nRst, $22, nF0, $02, nRst
dc.b $04, nF0, $0A, nRst, $02, nEb0, $0A, nRst
dc.b $02, nF0, $0A, nRst, $08, nG0, $04, nRst
dc.b $08, nG0, $04, nRst, $08, nG0, $04, nRst
dc.b $02, nG0, $0A, nRst, $02, nG0, $04, nRst
dc.b $14, nF0, $04, nRst, $02, nFs0, $04, nRst
dc.b $02, nG0, $04, nRst, $02, nBb0, $04, nRst
dc.b $02
sJump HCZ2_FM4
dc.b $F2 ; Unused
HCZ2_FM5:
dc.b nRst, $01
sPan spRight
HCZ2_Jump1:
sPatFM $03
ssDetune $02
ssModZ80 $0F, $01, $06, $06
dc.b nRst, $7F, nRst, nRst, $76, nG4, $06, nBb4
dc.b nC5, nG4, nF4, $02, nEb4, nD4, nC4, nBb3
dc.b nA3, nG3, nRst, $04, nBb3, $06, nC4, nG3
dc.b nF3, $02, nFs3, $04, nF3, $06, nEb3, nC3
dc.b nG3, $02, nA3, nBb3, $08, nBb3, $02, nBb3
dc.b $04, nA3, $12, nG3, $02, nFs3, nF3, nEb3
dc.b nD3, nC3, nBb2, nA2, nG2, nRst, $36, nBb3
dc.b $06, nB3, nC4, nFs3, $02, nG3, $04, nF3
dc.b $02, nEb3, nC3, nBb2, nA2, nG2, nF2, nEb2
dc.b $04, nF3, $02, nFs3, $04, nF3, $06, nEb3
dc.b nF3, nEb3, nC3, nBb2, nG3, $0C, nG3, $06
dc.b nC4, $12, nA3, $02, nG3, nF3, nEb3, nD3
dc.b nC3, nRst, $3C, nG4, $06, nBb4, nC5, nG4
dc.b nF4, $02, nEb4, nD4, nC4, nBb3, nA3, nG3
dc.b nRst, $04, nBb3, $06, nC4, nG3, nF3, $02
dc.b nFs3, $04, nF3, $06, nEb3, nC3, nG3, $02
dc.b nA3, nBb3, $08, nBb3, $02, nBb3, $04, nA3
dc.b $12, nG3, $02, nF3, nEb3, nD3, nC3, nBb2
dc.b nA2, nG2, nF2, nRst, $36, nBb3, $06, nB3
dc.b nC4, nFs3, $02, nG3, $04, nF3, $02, nEb3
dc.b nC3, nBb2, nA2, nG2, nF2, nEb2, $04, nF3
dc.b $02, nFs3, $04, nF3, $06, nEb3, nF3, nEb3
dc.b nC3, nBb2, nG3, $0C, nG3, $06, nEb3, $12
dc.b nD3, $02, nC3, nBb2, nA2, nG2, nF2, nRst
dc.b $1E
sPatFM $0E
ssDetune $FF
ssModZ80 $0F, $01, $06, $06
saTranspose $F4
dc.b nF3, $06, nFs3, $02, nG3, $04, nBb3, $06
dc.b nEb4, nF4, nG4, nBb4, nD5, $02, nEb5, $08
dc.b nRst, $02, nF5, $04, nRst, $02, nFs5, nG5
dc.b $08, nRst, $02, nC5, $0A, nRst, $02, nFs5
dc.b nG5, $26, nRst, $02, nF5, $04, nRst, $02
dc.b nEb5, $04, nRst, $02, nCs5, nD5, $26, nRst
dc.b $02, nBb4, $34, nRst, $02, nCs5, nD5, $08
dc.b nRst, $02, nEb5, $04, nRst, $02, nE5, nF5
dc.b $08, nRst, $02, nBb4, $0A, nRst, $02, nF5
dc.b nF5, $26, nRst, $02, nEb5, $04, nRst, $02
dc.b nD5, $04, nRst, $02, nC5, $2E, nRst, $08
dc.b nD5, $10, nRst, $02, nEb5, $0A, nRst, $02
dc.b nF5, $0A, nRst, $02, nD5, nEb5, $08, nRst
dc.b $02, nF5, $04, nRst, $02, nFs5, nG5, $08
dc.b nRst, $02, nC5, $0A, nRst, $02, nG5, $28
dc.b nRst, $02, nF5, $04, nRst, $02, nEb5, $04
dc.b nRst, $02, nCs5, nD5, $26, nRst, $02, nEb5
dc.b $1C, nRst, $0E, nEb5, $04, nRst, $02, nF5
dc.b $04, nRst, $02, nFs5, nG5, $08, nRst, $02
dc.b nEb5, $04, nRst, $02, nG5, $0A, nRst, $02
dc.b nBb4, $0A, nRst, $02, nC5, $28, nRst, $02
dc.b nEb5, $04, nRst, $02, nF5, $04, nRst, $02
dc.b nG5, $2E, nRst, $02, nF5, $12, nEb5, $02
dc.b nD5, nC5, nBb4, nAb4, nG4, nF4, nEb4, nD4
sPatFM $03
ssDetune $02
ssModZ80 $0F, $01, $06, $06
saTranspose $0C
dc.b nC4, $04, nRst, $02, nD4, $04, nRst, $02
dc.b nEb4, $0C, nD4, $02, nC4, nBb3, nAb3, nG3
dc.b nF3, nC4, $0A, nRst, $02, nEb4, $04, nRst
dc.b $02, nE4, nF4, nRst, $08, nD4, $10, nRst
dc.b $02, nC4, $04, nRst, $08, nBb3, $04, nRst
dc.b $08, nFs3, $02, nG3, $14, nRst, $02, nFs3
dc.b nG3, $08, nRst, $02, nF3, $04, nRst, $02
dc.b nFs3, nG3, $28, nC4, $04, nRst, $02, nD4
dc.b $04, nRst, $02, nEb4, $0C, nD4, $02, nC4
dc.b nBb3, nAb3, nG3, nF3, nC4, $0A, nRst, $02
dc.b nEb4, $04, nRst, $02, nE4, nF4, nRst, $08
dc.b nD4, $10, nRst, $02, nC4, $04, nRst, $08
dc.b nB3, $04, nRst, $08, nC4, $10, nRst, $02
dc.b nC4, $04, nRst, $02, nD4, $0A, nRst, $02
dc.b nC4, $04, nRst, $02, nD4, $04, nRst, $08
dc.b nEb4, $10, nRst, $02, nF4, $0A, nRst, $02
dc.b nC4, $04, nRst, $02, nD4, $04, nRst, $02
dc.b nEb4, $0C, nD4, $02, nC4, nBb3, nAb3, nG3
dc.b nF3, nC4, $0A, nRst, $02, nEb4, $04, nRst
dc.b $02, nE4, nF4, nRst, $08, nD4, $10, nRst
dc.b $02, nC4, $04, nRst, $08, nBb3, $04, nRst
dc.b $08, nFs3, $02, nG3, $14, nRst, $02, nFs3
dc.b nG3, $08, nRst, $02, nF3, $04, nRst, $02
dc.b nFs3, nG3, $28, nC4, $04, nRst, $02, nD4
dc.b $04, nRst, $02, nEb4, $10, nRst, $02, nEb4
dc.b $04, nRst, $08, nD4, $04, nRst, $02, nEb4
dc.b $10, nRst, $02, nEb4, $04, nRst, $02, nF4
dc.b $0A, nRst, $02, nEb4, $04, nRst, $08, nAb4
dc.b $04, nRst, $0E, nC5, $04, nRst, $08, nC5
dc.b $04, nRst, $08, nC5, $04, nRst, $02, nC5
dc.b $0A, nRst, $02, nB4, $04, nRst, $2C
sJump HCZ2_Jump1
dc.b $F2 ; Unused
HCZ2_PSG1:
sVolEnvPSG v0A
HCZ2_Jump2:
dc.b nC4, $04, nRst, $02, nG3, $04, nRst, $02
dc.b nBb3, $04, nRst, $02, nG3, $04, nRst, $08
dc.b nG3, $04, nRst, $02, nBb3, $04, nRst, $02
dc.b nG3, $04, nRst, $02, nC4, $04, nRst, $02
dc.b nG3, $04, nRst, $02, nBb3, $04, nRst, $02
dc.b nG3, $04, nRst, $60, nRst, $1A, nC4, $04
dc.b nRst, $02, nG3, $04, nRst, $02, nBb3, $04
dc.b nRst, $02, nG3, $04, nRst, $08, nG3, $04
dc.b nRst, $02, nBb3, $04, nRst, $02, nG3, $04
dc.b nRst, $02, nC4, $04, nRst, $02, nG3, $04
dc.b nRst, $02, nBb3, $04, nRst, $02, nG3, $04
dc.b nRst, $60, nRst, nRst, $38, nF4, $06, nFs4
dc.b nG4, nBb5, nRst, nC5, nFs5, $02, nG5, $12
dc.b nRst, $70, nC4, $04, nRst, $02, nA4, $04
dc.b nRst, $02, nG4, $04, nRst, $08, nF4, $04
dc.b nRst, $02, nFs4, nG4, $04, nE4, nRst, $7F
dc.b nRst, $31, nF4, $06, nFs4, nG4, nBb5, nRst
dc.b nC5, nFs5, $02, nG5, $12, nRst, $70, nC5
dc.b $06, nBb4, nG4, nF4, $04, nFs4, nF4, nEb4
dc.b $06, nC4, nRst, $12, nBb3, $1E, nRst, $3C
dc.b nC4, $04, nRst, $02, nC4, $04, nRst, $08
dc.b nD4, $02, nRst, $04, nEb4, $0A, nRst, $3E
dc.b nBb3, $04, nRst, $02, nBb3, $04, nRst, $08
dc.b nC4, $02, nRst, $04, nD4, $0A, nRst, $3E
dc.b nD4, $04, nRst, $02, nD4, $04, nRst, $08
dc.b nEb4, $02, nRst, $04, nF4, $0A, nRst, $08
dc.b nEb5, $04, nRst, $0E, nD5, $0A, nRst, $02
dc.b nD5, $04, nRst, $02, nEb5, $04, nRst, $08
dc.b nD5, $10, nRst, $02, nEb5, $0A, nRst, $02
dc.b nF5, $0A, nRst, $3E, nC4, $04, nRst, $02
dc.b nC4, $04, nRst, $08, nD4, $02, nRst, $04
dc.b nEb4, $0A, nRst, $3E, nBb3, $04, nRst, $02
dc.b nBb3, $04, nRst, $08, nEb4, $02, nRst, $04
dc.b nG4, $0A, nRst, $3E, nA3, $04, nRst, $02
dc.b nA3, $04, nRst, $08, nC4, $02, nRst, $04
dc.b nEb4, $0A, nRst, $08, nEb4, $04, nRst, $02
dc.b nEb3, $04, nRst, $02, nEb4, $04, nRst, $02
dc.b nEb3, $04, nRst, $02, nEb4, $04, nRst, $02
dc.b nEb4, $04, nRst, $02, nEb3, $04, nRst, $02
dc.b nD4, $04, nRst, $02, nD4, $04, nRst, $08
dc.b nD4, $04, nRst, $50, nBb3, $04, nRst, $02
dc.b nG3, $04, nRst, $02, nBb3, $04, nRst, $02
dc.b nBb3, $04, nRst, $02, nBb3, $04, nRst, $02
dc.b nG3, $04, nRst, $02, nBb3, $04, nRst, $38
dc.b nD4, $04, nRst, $02, nBb3, $04, nRst, $02
dc.b nD4, $04, nRst, $02, nF4, $04, nRst, $02
dc.b nD4, $04, nRst, $02, nBb3, $04, nRst, $02
dc.b nG3, $04, nRst, $38, nB3, $04, nRst, $02
dc.b nG3, $04, nRst, $02, nB3, $04, nRst, $02
dc.b nF3, $04, nRst, $02, nG3, $04, nRst, $02
dc.b nB3, $04, nRst, $02, nD4, $04, nRst, $02
dc.b nC3, $04, nRst, $02, nEb3, $04, nRst, $02
dc.b nG3, $04, nRst, $02, nEb3, $04, nRst, $02
dc.b nD3, $04, nRst, $02, nF3, $04, nRst, $02
dc.b nBb3, $04, nRst, $02, nD3, $04, nRst, $02
dc.b nEb3, $04, nRst, $02, nAb3, $04, nRst, $02
dc.b nC4, $04, nRst, $02, nEb3, $04, nRst, $02
dc.b nF3, $04, nRst, $02, nG3, $04, nRst, $02
dc.b nD4, $04, nRst, $02, nG3, $04, nRst, $38
dc.b nBb3, $04, nRst, $02, nG3, $04, nRst, $02
dc.b nBb3, $04, nRst, $02, nBb3, $04, nRst, $02
dc.b nBb3, $04, nRst, $02, nG3, $04, nRst, $02
dc.b nBb3, $04, nRst, $38, nD4, $04, nRst, $02
dc.b nBb3, $04, nRst, $02, nD4, $04, nRst, $02
dc.b nF4, $04, nRst, $02, nD4, $04, nRst, $02
dc.b nBb3, $04, nRst, $02, nG3, $04, nRst, $38
dc.b nEb3, $04, nRst, $02, nAb3, $04, nRst, $02
dc.b nEb3, $04, nRst, $02, nEb3, $04, nRst, $02
dc.b nC4, $04, nRst, $02, nAb3, $04, nRst, $02
dc.b nEb4, $04, nRst, $08, nEb5, $04, nRst, $08
dc.b nEb5, $04, nRst, $08, nEb5, $04, nRst, $02
dc.b nEb5, $0A, nRst, $02, nD5, $04, nRst, $2C
sJump HCZ2_Jump2
dc.b $F2 ; Unused
HCZ2_PSG2:
sVolEnvPSG v08
dc.b nRst, $01
ssDetune $01
sJump HCZ2_Jump2
dc.b $F6, $BB, $E7, $F2 ; Unused
HCZ2_PSG3:
sVolEnvPSG v02
sNoisePSG $E7
HCZ2_Jump3:
dc.b nRst, $18, nRst, $18, nRst, $18, nRst, $18
dc.b nRst, $18
sVolEnvPSG v01
dc.b nBb6, $04
sVolEnvPSG v01
dc.b nBb6, $04
sVolEnvPSG v01
dc.b nBb6, $04
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06, sHold, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $0C, sHold, $18, sHold, $18, sHold, $18
dc.b sHold, $18, sHold, $18, sHold, $18
sVolEnvPSG v01
dc.b nBb6, $04
sVolEnvPSG v01
dc.b nBb6, $04
sVolEnvPSG v01
dc.b nBb6, $04
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06, sHold, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $0C, sHold, $18
HCZ2_Loop1:
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sLoop $01, $03, HCZ2_Loop1
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06, sHold, $18, sHold, $18, sHold, $18
dc.b sHold, $18
HCZ2_Loop2:
sVolEnvPSG v01
dc.b nBb6, $0C
sVolEnvPSG v08
dc.b nBb6, $0C
sVolEnvPSG v01
dc.b nBb6, $0C
sVolEnvPSG v08
dc.b nBb6, $0C
sVolEnvPSG v01
dc.b nBb6, $0C
sVolEnvPSG v08
dc.b nBb6, $0C
sVolEnvPSG v01
dc.b nBb6, $0C
sVolEnvPSG v08
dc.b nBb6, $0C
sLoop $01, $03, HCZ2_Loop2
dc.b sHold, $18, sHold, $18, sHold, $18, sHold, $18
HCZ2_Loop3:
sVolEnvPSG v01
dc.b nBb6, $0C
sVolEnvPSG v08
dc.b nBb6, $0C
sVolEnvPSG v01
dc.b nBb6, $0C
sVolEnvPSG v08
dc.b nBb6, $0C
sVolEnvPSG v01
dc.b nBb6, $0C
sVolEnvPSG v08
dc.b nBb6, $0C
sVolEnvPSG v01
dc.b nBb6, $0C
sVolEnvPSG v08
dc.b nBb6, $0C
sLoop $01, $03, HCZ2_Loop3
dc.b sHold, $18, sHold, $18, sHold, $18, sHold, $18
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06, sHold, $18
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06
sVolEnvPSG v08
dc.b nBb6, $06
sVolEnvPSG v01
dc.b nBb6, $06, sHold, $18, sHold, $18, sHold, $18
dc.b sHold, $18
sJump HCZ2_Jump3
dc.b $F2 ; Unused
HCZ2_Patches:
; Patch $00
; $3C
; $01, $00, $00, $00, $1F, $1F, $15, $1F
; $11, $0D, $12, $05, $07, $04, $09, $02
; $55, $3A, $25, $1A, $1A, $80, $07, $80
spAlgorithm $04
spFeedback $07
spDetune $00, $00, $00, $00
spMultiple $01, $00, $00, $00
spRateScale $00, $00, $00, $00
spAttackRt $1F, $15, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $11, $12, $0D, $05
spSustainLv $05, $02, $03, $01
spDecayRt $07, $09, $04, $02
spReleaseRt $05, $05, $0A, $0A
spTotalLv $1A, $07, $00, $00
; Patch $01
; $3D
; $01, $01, $01, $01, $94, $19, $19, $19
; $0F, $0D, $0D, $0D, $07, $04, $04, $04
; $25, $1A, $1A, $1A, $15, $80, $80, $80
spAlgorithm $05
spFeedback $07
spDetune $00, $00, $00, $00
spMultiple $01, $01, $01, $01
spRateScale $02, $00, $00, $00
spAttackRt $14, $19, $19, $19
spAmpMod $00, $00, $00, $00
spSustainRt $0F, $0D, $0D, $0D
spSustainLv $02, $01, $01, $01
spDecayRt $07, $04, $04, $04
spReleaseRt $05, $0A, $0A, $0A
spTotalLv $15, $00, $00, $00
; Patch $02
; $03
; $00, $D7, $33, $02, $5F, $9F, $5F, $1F
; $13, $0F, $0A, $0A, $10, $0F, $02, $09
; $35, $15, $25, $1A, $13, $16, $15, $80
spAlgorithm $03
spFeedback $00
spDetune $00, $03, $0D, $00
spMultiple $00, $03, $07, $02
spRateScale $01, $01, $02, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $13, $0A, $0F, $0A
spSustainLv $03, $02, $01, $01
spDecayRt $10, $02, $0F, $09
spReleaseRt $05, $05, $05, $0A
spTotalLv $13, $15, $16, $00
; Patch $03
; $34
; $70, $72, $31, $31, $1F, $1F, $1F, $1F
; $10, $06, $06, $06, $01, $06, $06, $06
; $35, $1A, $15, $1A, $10, $80, $18, $80
spAlgorithm $04
spFeedback $06
spDetune $07, $03, $07, $03
spMultiple $00, $01, $02, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $10, $06, $06, $06
spSustainLv $03, $01, $01, $01
spDecayRt $01, $06, $06, $06
spReleaseRt $05, $05, $0A, $0A
spTotalLv $10, $18, $00, $00
; Patch $04
; $3E
; $77, $71, $32, $31, $1F, $1F, $1F, $1F
; $0D, $06, $00, $00, $08, $06, $00, $00
; $15, $0A, $0A, $0A, $1B, $80, $80, $80
spAlgorithm $06
spFeedback $07
spDetune $07, $03, $07, $03
spMultiple $07, $02, $01, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $0D, $00, $06, $00
spSustainLv $01, $00, $00, $00
spDecayRt $08, $00, $06, $00
spReleaseRt $05, $0A, $0A, $0A
spTotalLv $1B, $00, $00, $00
; Patch $05
; $34
; $33, $41, $7E, $74, $5B, $9F, $5F, $1F
; $04, $07, $07, $08, $00, $00, $00, $00
; $FF, $FF, $EF, $FF, $23, $80, $29, $87
spAlgorithm $04
spFeedback $06
spDetune $03, $07, $04, $07
spMultiple $03, $0E, $01, $04
spRateScale $01, $01, $02, $00
spAttackRt $1B, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $04, $07, $07, $08
spSustainLv $0F, $0E, $0F, $0F
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $23, $29, $00, $07
; Patch $06
; $3A
; $01, $07, $01, $01, $8E, $8E, $8D, $53
; $0E, $0E, $0E, $03, $00, $00, $00, $07
; $1F, $FF, $1F, $0F, $18, $28, $27, $80
spAlgorithm $02
spFeedback $07
spDetune $00, $00, $00, $00
spMultiple $01, $01, $07, $01
spRateScale $02, $02, $02, $01
spAttackRt $0E, $0D, $0E, $13
spAmpMod $00, $00, $00, $00
spSustainRt $0E, $0E, $0E, $03
spSustainLv $01, $01, $0F, $00
spDecayRt $00, $00, $00, $07
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $18, $27, $28, $00
; Patch $07
; $3C
; $32, $32, $71, $42, $1F, $18, $1F, $1E
; $07, $1F, $07, $1F, $00, $00, $00, $00
; $1F, $0F, $1F, $0F, $1E, $80, $0C, $80
spAlgorithm $04
spFeedback $07
spDetune $03, $07, $03, $04
spMultiple $02, $01, $02, $02
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $18, $1E
spAmpMod $00, $00, $00, $00
spSustainRt $07, $07, $1F, $1F
spSustainLv $01, $01, $00, $00
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1E, $0C, $00, $00
; Patch $08
; $3C
; $71, $72, $3F, $34, $8D, $52, $9F, $1F
; $09, $00, $00, $0D, $00, $00, $00, $00
; $23, $08, $02, $F7, $15, $80, $1D, $87
spAlgorithm $04
spFeedback $07
spDetune $07, $03, $07, $03
spMultiple $01, $0F, $02, $04
spRateScale $02, $02, $01, $00
spAttackRt $0D, $1F, $12, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $09, $00, $00, $0D
spSustainLv $02, $00, $00, $0F
spDecayRt $00, $00, $00, $00
spReleaseRt $03, $02, $08, $07
spTotalLv $15, $1D, $00, $07
; Patch $09
; $3D
; $01, $01, $00, $00, $8E, $52, $14, $4C
; $08, $08, $0E, $03, $00, $00, $00, $00
; $1F, $1F, $1F, $1F, $1B, $80, $80, $9B
spAlgorithm $05
spFeedback $07
spDetune $00, $00, $00, $00
spMultiple $01, $00, $01, $00
spRateScale $02, $00, $01, $01
spAttackRt $0E, $14, $12, $0C
spAmpMod $00, $00, $00, $00
spSustainRt $08, $0E, $08, $03
spSustainLv $01, $01, $01, $01
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1B, $00, $00, $1B
; Patch $0A
; $3A
; $31, $53, $31, $41, $8D, $4F, $15, $52
; $06, $08, $07, $04, $02, $00, $00, $00
; $1F, $1F, $2F, $2F, $19, $20, $2A, $80
spAlgorithm $02
spFeedback $07
spDetune $03, $03, $05, $04
spMultiple $01, $01, $03, $01
spRateScale $02, $00, $01, $01
spAttackRt $0D, $15, $0F, $12
spAmpMod $00, $00, $00, $00
spSustainRt $06, $07, $08, $04
spSustainLv $01, $02, $01, $02
spDecayRt $02, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $19, $2A, $20, $00
; Patch $0B
; $3C
; $36, $31, $76, $71, $94, $9F, $96, $9F
; $12, $00, $14, $0F, $04, $0A, $04, $0D
; $2F, $0F, $4F, $2F, $33, $80, $1A, $80
spAlgorithm $04
spFeedback $07
spDetune $03, $07, $03, $07
spMultiple $06, $06, $01, $01
spRateScale $02, $02, $02, $02
spAttackRt $14, $16, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $12, $14, $00, $0F
spSustainLv $02, $04, $00, $02
spDecayRt $04, $04, $0A, $0D
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $33, $1A, $00, $00
; Patch $0C
; $34
; $33, $41, $7E, $74, $5B, $9F, $5F, $1F
; $04, $07, $07, $08, $00, $00, $00, $00
; $FF, $FF, $EF, $FF, $23, $90, $29, $97
spAlgorithm $04
spFeedback $06
spDetune $03, $07, $04, $07
spMultiple $03, $0E, $01, $04
spRateScale $01, $01, $02, $00
spAttackRt $1B, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $04, $07, $07, $08
spSustainLv $0F, $0E, $0F, $0F
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $23, $29, $10, $17
; Patch $0D
; $38
; $63, $31, $31, $31, $10, $13, $1A, $1B
; $0E, $00, $00, $00, $00, $00, $00, $00
; $3F, $0F, $0F, $0F, $1A, $19, $1A, $80
spAlgorithm $00
spFeedback $07
spDetune $06, $03, $03, $03
spMultiple $03, $01, $01, $01
spRateScale $00, $00, $00, $00
spAttackRt $10, $1A, $13, $1B
spAmpMod $00, $00, $00, $00
spSustainRt $0E, $00, $00, $00
spSustainLv $03, $00, $00, $00
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1A, $1A, $19, $00
; Patch $0E
; $3A
; $31, $25, $73, $41, $5F, $1F, $1F, $9C
; $08, $05, $04, $1E, $03, $04, $02, $06
; $2F, $2F, $1F, $0F, $29, $27, $1F, $80
spAlgorithm $02
spFeedback $07
spDetune $03, $07, $02, $04
spMultiple $01, $03, $05, $01
spRateScale $01, $00, $00, $02
spAttackRt $1F, $1F, $1F, $1C
spAmpMod $00, $00, $00, $00
spSustainRt $08, $04, $05, $1E
spSustainLv $02, $01, $02, $00
spDecayRt $03, $02, $04, $06
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $29, $1F, $27, $00
; Patch $0F
; $04
; $71, $41, $31, $31, $12, $12, $12, $12
; $00, $00, $00, $00, $00, $00, $00, $00
; $0F, $0F, $0F, $0F, $23, $80, $23, $80
spAlgorithm $04
spFeedback $00
spDetune $07, $03, $04, $03
spMultiple $01, $01, $01, $01
spRateScale $00, $00, $00, $00
spAttackRt $12, $12, $12, $12
spAmpMod $00, $00, $00, $00
spSustainRt $00, $00, $00, $00
spSustainLv $00, $00, $00, $00
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $23, $23, $00, $00
; Patch $10
; $14
; $75, $72, $35, $32, $9F, $9F, $9F, $9F
; $05, $05, $00, $0A, $05, $05, $07, $05
; $2F, $FF, $0F, $2F, $1E, $80, $14, $80
spAlgorithm $04
spFeedback $02
spDetune $07, $03, $07, $03
spMultiple $05, $05, $02, $02
spRateScale $02, $02, $02, $02
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $05, $00, $05, $0A
spSustainLv $02, $00, $0F, $02
spDecayRt $05, $07, $05, $05
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1E, $14, $00, $00
; Patch $11
; $3D
; $01, $00, $01, $02, $12, $1F, $1F, $14
; $07, $02, $02, $0A, $05, $05, $05, $05
; $2F, $2F, $2F, $AF, $1C, $80, $82, $80
spAlgorithm $05
spFeedback $07
spDetune $00, $00, $00, $00
spMultiple $01, $01, $00, $02
spRateScale $00, $00, $00, $00
spAttackRt $12, $1F, $1F, $14
spAmpMod $00, $00, $00, $00
spSustainRt $07, $02, $02, $0A
spSustainLv $02, $02, $02, $0A
spDecayRt $05, $05, $05, $05
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1C, $02, $00, $00
; Patch $12
; $1C
; $73, $72, $33, $32, $94, $99, $94, $99
; $08, $0A, $08, $0A, $00, $05, $00, $05
; $3F, $4F, $3F, $4F, $1E, $80, $19, $80
spAlgorithm $04
spFeedback $03
spDetune $07, $03, $07, $03
spMultiple $03, $03, $02, $02
spRateScale $02, $02, $02, $02
spAttackRt $14, $14, $19, $19
spAmpMod $00, $00, $00, $00
spSustainRt $08, $08, $0A, $0A
spSustainLv $03, $03, $04, $04
spDecayRt $00, $00, $05, $05
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1E, $19, $00, $00
; Patch $13
; $31
; $33, $01, $00, $00, $9F, $1F, $1F, $1F
; $0D, $0A, $0A, $0A, $0A, $07, $07, $07
; $FF, $AF, $AF, $AF, $1E, $1E, $1E, $80
spAlgorithm $01
spFeedback $06
spDetune $03, $00, $00, $00
spMultiple $03, $00, $01, $00
spRateScale $02, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $0D, $0A, $0A, $0A
spSustainLv $0F, $0A, $0A, $0A
spDecayRt $0A, $07, $07, $07
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1E, $1E, $1E, $00
; Patch $14
; $3A
; $70, $76, $30, $71, $1F, $95, $1F, $1F
; $0E, $0F, $05, $0C, $07, $06, $06, $07
; $2F, $4F, $1F, $5F, $21, $12, $28, $80
spAlgorithm $02
spFeedback $07
spDetune $07, $03, $07, $07
spMultiple $00, $00, $06, $01
spRateScale $00, $00, $02, $00
spAttackRt $1F, $1F, $15, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $0E, $05, $0F, $0C
spSustainLv $02, $01, $04, $05
spDecayRt $07, $06, $06, $07
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $21, $28, $12, $00
; Patch $15
; $28
; $71, $00, $30, $01, $1F, $1F, $1D, $1F
; $13, $13, $06, $05, $03, $03, $02, $05
; $4F, $4F, $2F, $3F, $0E, $14, $1E, $80
spAlgorithm $00
spFeedback $05
spDetune $07, $03, $00, $00
spMultiple $01, $00, $00, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1D, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $13, $06, $13, $05
spSustainLv $04, $02, $04, $03
spDecayRt $03, $02, $03, $05
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $0E, $1E, $14, $00
; Patch $16
; $3E
; $38, $01, $7A, $34, $59, $D9, $5F, $9C
; $0F, $04, $0F, $0A, $02, $02, $05, $05
; $AF, $AF, $66, $66, $28, $80, $A3, $80
spAlgorithm $06
spFeedback $07
spDetune $03, $07, $00, $03
spMultiple $08, $0A, $01, $04
spRateScale $01, $01, $03, $02
spAttackRt $19, $1F, $19, $1C
spAmpMod $00, $00, $00, $00
spSustainRt $0F, $0F, $04, $0A
spSustainLv $0A, $06, $0A, $06
spDecayRt $02, $05, $02, $05
spReleaseRt $0F, $06, $0F, $06
spTotalLv $28, $23, $00, $00
; Patch $17
; $39
; $32, $31, $72, $71, $1F, $1F, $1F, $1F
; $00, $00, $00, $00, $00, $00, $00, $00
; $0F, $0F, $0F, $0F, $1B, $32, $28, $80
spAlgorithm $01
spFeedback $07
spDetune $03, $07, $03, $07
spMultiple $02, $02, $01, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $00, $00, $00, $00
spSustainLv $00, $00, $00, $00
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1B, $28, $32, $00
; Patch $18
; $07
; $34, $74, $32, $71, $1F, $1F, $1F, $1F
; $0A, $0A, $05, $03, $00, $00, $00, $00
; $3F, $3F, $2F, $2F, $8A, $8A, $80, $80
spAlgorithm $07
spFeedback $00
spDetune $03, $03, $07, $07
spMultiple $04, $02, $04, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $0A, $05, $0A, $03
spSustainLv $03, $02, $03, $02
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $0A, $00, $0A, $00
; Patch $19
; $3A
; $31, $37, $31, $31, $8D, $8D, $8E, $53
; $0E, $0E, $0E, $03, $00, $00, $00, $00
; $1F, $FF, $1F, $0F, $17, $28, $26, $80
spAlgorithm $02
spFeedback $07
spDetune $03, $03, $03, $03
spMultiple $01, $01, $07, $01
spRateScale $02, $02, $02, $01
spAttackRt $0D, $0E, $0D, $13
spAmpMod $00, $00, $00, $00
spSustainRt $0E, $0E, $0E, $03
spSustainLv $01, $01, $0F, $00
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $17, $26, $28, $00
; Patch $1A
; $3B
; $3A, $31, $71, $74, $DF, $1F, $1F, $DF
; $00, $0A, $0A, $05, $00, $05, $05, $03
; $0F, $5F, $1F, $5F, $32, $1E, $0F, $80
spAlgorithm $03
spFeedback $07
spDetune $03, $07, $03, $07
spMultiple $0A, $01, $01, $04
spRateScale $03, $00, $00, $03
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $00, $0A, $0A, $05
spSustainLv $00, $01, $05, $05
spDecayRt $00, $05, $05, $03
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $32, $0F, $1E, $00
; Patch $1B
; $3A
; $32, $56, $32, $42, $8D, $4F, $15, $52
; $06, $08, $07, $04, $02, $00, $00, $00
; $1F, $1F, $2F, $2F, $19, $20, $2A, $80
spAlgorithm $02
spFeedback $07
spDetune $03, $03, $05, $04
spMultiple $02, $02, $06, $02
spRateScale $02, $00, $01, $01
spAttackRt $0D, $15, $0F, $12
spAmpMod $00, $00, $00, $00
spSustainRt $06, $07, $08, $04
spSustainLv $01, $02, $01, $02
spDecayRt $02, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $19, $2A, $20, $00
; Patch $1C
; $2C
; $71, $74, $32, $32, $1F, $12, $1F, $12
; $00, $0A, $00, $0A, $00, $00, $00, $00
; $0F, $1F, $0F, $1F, $16, $80, $17, $80
spAlgorithm $04
spFeedback $05
spDetune $07, $03, $07, $03
spMultiple $01, $02, $04, $02
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $12, $12
spAmpMod $00, $00, $00, $00
spSustainRt $00, $00, $0A, $0A
spSustainLv $00, $00, $01, $01
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $16, $17, $00, $00
; Patch $1D
; $3A
; $01, $07, $01, $01, $8E, $8E, $8D, $53
; $0E, $0E, $0E, $03, $00, $00, $00, $07
; $1F, $FF, $1F, $0F, $18, $28, $27, $8F
spAlgorithm $02
spFeedback $07
spDetune $00, $00, $00, $00
spMultiple $01, $01, $07, $01
spRateScale $02, $02, $02, $01
spAttackRt $0E, $0D, $0E, $13
spAmpMod $00, $00, $00, $00
spSustainRt $0E, $0E, $0E, $03
spSustainLv $01, $01, $0F, $00
spDecayRt $00, $00, $00, $07
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $18, $27, $28, $0F
; Patch $1E
; $36
; $7A, $32, $51, $11, $1F, $1F, $59, $1C
; $0A, $0D, $06, $0A, $07, $00, $02, $02
; $AF, $5F, $5F, $5F, $1E, $8B, $81, $80
spAlgorithm $06
spFeedback $06
spDetune $07, $05, $03, $01
spMultiple $0A, $01, $02, $01
spRateScale $00, $01, $00, $00
spAttackRt $1F, $19, $1F, $1C
spAmpMod $00, $00, $00, $00
spSustainRt $0A, $06, $0D, $0A
spSustainLv $0A, $05, $05, $05
spDecayRt $07, $02, $00, $02
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1E, $01, $0B, $00
; Patch $1F
; $3C
; $71, $72, $3F, $34, $8D, $52, $9F, $1F
; $09, $00, $00, $0D, $00, $00, $00, $00
; $23, $08, $02, $F7, $15, $85, $1D, $8A
spAlgorithm $04
spFeedback $07
spDetune $07, $03, $07, $03
spMultiple $01, $0F, $02, $04
spRateScale $02, $02, $01, $00
spAttackRt $0D, $1F, $12, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $09, $00, $00, $0D
spSustainLv $02, $00, $00, $0F
spDecayRt $00, $00, $00, $00
spReleaseRt $03, $02, $08, $07
spTotalLv $15, $1D, $05, $0A
; Patch $20
; $3E
; $77, $71, $32, $31, $1F, $1F, $1F, $1F
; $0D, $06, $00, $00, $08, $06, $00, $00
; $15, $0A, $0A, $0A, $1B, $8F, $8F, $8F
spAlgorithm $06
spFeedback $07
spDetune $07, $03, $07, $03
spMultiple $07, $02, $01, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $0D, $00, $06, $00
spSustainLv $01, $00, $00, $00
spDecayRt $08, $00, $06, $00
spReleaseRt $05, $0A, $0A, $0A
spTotalLv $1B, $0F, $0F, $0F
; Patch $21
; $07
; $34, $74, $32, $71, $1F, $1F, $1F, $1F
; $0A, $0A, $05, $03, $00, $00, $00, $00
; $3F, $3F, $2F, $2F, $8A, $8A, $8A, $8A
spAlgorithm $07
spFeedback $00
spDetune $03, $03, $07, $07
spMultiple $04, $02, $04, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $0A, $05, $0A, $03
spSustainLv $03, $02, $03, $02
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $0A, $0A, $0A, $0A
|
HoareCompleteness.agda | iwilare/imp-semantics | 6 | 10014 | open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym)
open import Function.Equivalence using (_⇔_; equivalence; Equivalence)
open import Data.Bool using (Bool; true; false; if_then_else_)
open import Data.Product using (_×_; _,_; proj₁; proj₂)
open import Data.Sum using (_⊎_)
open import IMP
open import OperationalSemantics
open import Hoare
wp : ∀{l} → com → assn {l} → assn {l}
wp c Q s = ∀ t → ⦅ c , s ⦆⇒ t → Q t
fatto : ∀{P Q : assn} {c}
→ ⊨[ P ] c [ Q ]
→ (∀ s → P s → wp c Q s)
fatto = λ z s z₁ t → z z₁
fatto-converse : ∀{P Q : assn} {c}
→ (∀ s → P s → wp c Q s)
→ ⊨[ P ] c [ Q ]
fatto-converse = (λ z {s} {t} z₁ → z s z₁ t)
wp-hoare : ∀ c {l} {Q : assn {l}}
→ ⊢[ wp c Q ] c [ Q ]
wp-hoare SKIP = Conseq (λ s z → z s Skip) Skip (λ s z → z)
wp-hoare (x ::= a) = Conseq (λ s wpe → wpe (s [ x ::= aval a s ]) Loc) Loc (λ s r → r)
wp-hoare (c :: c₁) = Comp (Conseq (λ s z x x₁ x₂ x₃ → z x₂ (Comp x₁ x₃)) (wp-hoare c) (λ s z → z)) (wp-hoare c₁)
wp-hoare (IF x THEN c ELSE c₁) = If (Conseq (λ s z x x₁ → proj₁ z x (IfTrue (proj₂ z) x₁)) (wp-hoare c) (λ s z → z))
(Conseq (λ s z x x₁ → proj₁ z x (IfFalse (proj₂ z) x₁)) (wp-hoare c₁) (λ s z → z))
wp-hoare (WHILE b DO c) =
Conseq (λ s x → x)
(While (Conseq (λ s z x x₁ x₂ x₃ → proj₁ z x₂ (WhileTrue (proj₂ z) x₁ x₃))
(wp-hoare c)
(λ s z → z)))
(λ s z → proj₁ z s (WhileFalse (proj₂ z)))
completeness : ∀ c {P Q : assn}
→ ⊨[ P ] c [ Q ]
→ ⊢[ P ] c [ Q ]
completeness c cc = Conseq (fatto cc) (wp-hoare c) (λ r x → x)
|
test/z80/test_rot.asm | gb-archive/asmotor | 0 | 105237 | <filename>test/z80/test_rot.asm
SECTION "Test",CODE[0]
rl (hl)
rl (ix+1)
rl (iy+2)
rl l
rla
rlc (hl)
rlc (ix+1)
rlc (iy+2)
rlc l
rlca
rld
rr (hl)
rr (ix+1)
rr (iy+2)
rr l
rra
rrc (hl)
rrc (ix+1)
rrc (iy+2)
rrc l
rrca
rrd
|
programs/oeis/052/A052780.asm | neoneye/loda | 22 | 102338 | ; A052780: Expansion of e.g.f. x^2*exp(4*x).
; 0,0,2,24,192,1280,7680,43008,229376,1179648,5898240,28835840,138412032,654311424,3053453312,14092861440,64424509440,292057776128,1314259992576,5875515260928,26113401159680,115448720916480,507974372032512,2225411534618624,9710886696517632,42221246506598400,182958734861926400,790381734603522048,3404721318292094976,14627691589699371008,62690106812997304320,268054249821091921920,1143698132569992200192,4869940435459321626624,20697246850702116913152,87806501790857465692160,371886360525984560578560,1572548038795591856160768,6639647274914721170456576,27994188510451256826789888,117870267412426344533852160,495659586041997961629532160,2081770261376391438844035072,8733280120896081158077415424,36596602411374054376705359872,153195079861565809018766622720,640633970330184292260296785920,2676426364934992154331906572288,11171170914511271600689696997376,46586159558387430505003842797568,194108998159947627104182678323200,808127257645496243454148293427200,3361809391805264372769256900657152,13974580216916000922099656136065024,58048256285651080753337033180577792,240955026091381844636493345277870080,999517145267954318492120543374868480
mov $1,4
pow $1,$0
bin $0,2
mul $1,$0
div $1,16
mul $1,2
mov $0,$1
|
other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/risc.lzh/risc/mak/kart-pers.asm | prismotizm/gigaleak | 0 | 174563 | Name: kart-pers.asm
Type: file
Size: 14825
Last-Modified: '1992-08-31T05:36:10Z'
SHA-1: E023811EBE5F9029C9E35ADCA6A4099334DBCA27
Description: null
|
programs/oeis/024/A024117.asm | neoneye/loda | 22 | 25247 | ; A024117: a(n) = 10^n - n^3.
; 1,9,92,973,9936,99875,999784,9999657,99999488,999999271,9999999000,99999998669,999999998272,9999999997803,99999999997256,999999999996625,9999999999995904,99999999999995087,999999999999994168,9999999999999993141,99999999999999992000,999999999999999990739,9999999999999999989352,99999999999999999987833,999999999999999999986176,9999999999999999999984375,99999999999999999999982424,999999999999999999999980317,9999999999999999999999978048,99999999999999999999999975611,999999999999999999999999973000,9999999999999999999999999970209,99999999999999999999999999967232,999999999999999999999999999964063,9999999999999999999999999999960696,99999999999999999999999999999957125,999999999999999999999999999999953344
mov $1,10
pow $1,$0
mov $2,$0
pow $0,2
mul $0,$2
sub $1,$0
mov $0,$1
|
matrixTransformG5_SIMD.asm | k-allard/assembly_SIMD_training | 0 | 88833 | .text
.intel_syntax noprefix
.literal16
.p2align 4
MASK1:
.long 0
.long 0xffffffff
.long 0
.long 0
MASK2:
.long 0
.long 0
.long 0xffffffff
.long 0
MASK3:
.long 0
.long 0
.long 0
.long 0xffffffff
.text
.globl __Z22matrixTransformG5_SIMDPiS_ii
.p2align 4, 0x90
__Z22matrixTransformG5_SIMDPiS_ii:
push rbp
mov rbp, rsp
push r15
push r14
push rbx
# деление L / 5
movsxd r9, edx # L - кол-во рядов
imul rax, r9, 0x66666667
mov rdx, rax
shr rdx, 63
sar rax, 33
add eax, edx # eax = blockLength = L / 5
lea rdx, [rax + rax] # rdx = blockLength * 2
mov r10, rax # r10 = blockLength
shl rax, 2 # rax = blockLength * 4
lea rbx, [r10 + 2*r10] # rbx = blockLength * 3
mov r8d, ecx # r8d = Q
add rsi, 64 # rsi - newMatrix
shl r9, 2 # r9 = L * 4
lea rcx, [rdi + 4*r10] # matrix[blockLength * 1] или matrix+4*blockLength
lea rdx, [rdi + 4*rdx] # matrix[blockLength * 2] или matrix+4*blockLength*2
lea r15, [rdi + 4*rbx] # matrix[blockLength * 3] или matrix+4*blockLength*3
lea r11, [rdi + 4*rax] # matrix[blockLength * 4] или matrix+4*blockLength*4
xor r14d, r14d
pxor xmm8, xmm8
movdqa xmm9, xmmword ptr [rip + MASK1] # xmm9 = [0,0xffffffff,0,0]
movdqa xmm10, xmmword ptr [rip + MASK2] # xmm10 = [0,0,0xffffffff,0]
movdqa xmm11, xmmword ptr [rip + MASK3] # xmm11 = [0,0,0,0xffffffff]
.p2align 4, 0x90
# начало цикла for (int q = 0; q < Q; q++)
LOOP_ROWS:
mov rbx, rsi
xor eax, eax # i = 0
.p2align 4, 0x90
# начало цикла for(int i = 0; i < blockLength; i += 4)
LOOP_BLOCKS:
movdqa xmm0, xmmword ptr [rdi + 4*rax] # matrix[i] или matrix+4*i
movdqa xmm1, xmmword ptr [rcx + 4*rax] # matrix[i+blockLength] или matrix+4*i+4*blockLength
movdqa xmm2, xmmword ptr [rdx + 4*rax] # matrix[i+blockLength*2] или matrix+4*i+4*blockLength*2
movdqa xmm3, xmmword ptr [r15 + 4*rax] # matrix[i+blockLength*3] или matrix+4*i+4*blockLength*3
movdqa xmm4, xmmword ptr [r11 + 4*rax] # matrix[i+blockLength*4] или matrix+4*i+4*blockLength*4
movdqa xmm5, xmm3
pslldq xmm5, 12 # xmm5 = 0000000,0000000,0000000,xmm3[0]
movdqa xmm6, xmm2
punpckldq xmm6, xmm8 # xmm6 = xmm2[0],0000000,xmm2[1],0000000
pslldq xmm6, 8 # xmm6 = 0000000,0000000,xmm2[0],0000000
xorps xmm7, xmm7 # xmm7 = 0000000,0000000,0000000,0000000
movss xmm7, xmm1 # xmm7 = xmm1[0],0000000,0000000,0000000
pslldq xmm7, 4 # xmm7 = 0000000,xmm1[0],0000000,0000000
por xmm7, xmm5 # xmm7 = 0000000,xmm1[0],0000000,xmm3[0]
pxor xmm5, xmm5 # xmm5 = 0000000,0000000,0000000,0000000
movss xmm5, xmm0 # xmm5 = xmm0[0],0000000,0000000,0000000
orps xmm5, xmm6 # xmm5 = xmm0[0],0000000,xmm2[0],0000000
orps xmm5, xmm7 # xmm5 = xmm0[0],xmm1[0],xmm2[0],xmm3[0]
movdqa xmmword ptr [rbx - 64], xmm5
movdqa xmm7, xmm2
pand xmm7, xmm9
pslldq xmm7, 8
movdqa xmm5, xmm1
andps xmm5, xmm9
pslldq xmm5, 4
por xmm5, xmm7
movdqa xmm7, xmm0
andps xmm7, xmm9
xorps xmm6, xmm6
movss xmm6, xmm4
orps xmm6, xmm7
orps xmm6, xmm5
movdqa xmmword ptr [rbx - 48], xmm6
movdqa xmm7, xmm1
movsd xmm7, xmm8
pslldq xmm7, 4
movdqa xmm5, xmm0
andps xmm5, xmm10
movdqa xmm6, xmm4
andps xmm6, xmm9
orps xmm6, xmm5
orps xmm6, xmm7
movq xmm7, xmm3
psrldq xmm7, 4
por xmm7, xmm6
movdqa xmmword ptr [rbx - 32], xmm7
andps xmm0, xmm11
movdqa xmm7, xmm4
andps xmm7, xmm10
orps xmm7, xmm0
movdqa xmm0, xmm3
pand xmm0, xmm10
psrldq xmm0, 4
movdqa xmm5, xmm2
pand xmm5, xmm10
psrldq xmm5, 8
por xmm5, xmm7
por xmm5, xmm0
movdqa xmmword ptr [rbx - 16], xmm5
andps xmm4, xmm11
pand xmm3, xmm11
psrldq xmm3, 4
pand xmm2, xmm11
psrldq xmm2, 8
psrldq xmm1, 12
por xmm1, xmm4
por xmm1, xmm2
por xmm1, xmm3
movdqa xmmword ptr [rbx], xmm1
add rax, 4 # i += 4
add rbx, 80 # newMatrix += G*i или newMatrix += 5*4*sizeof(int)
cmp rax, r10
jl LOOP_BLOCKS
# конец цикла for(int i = 0; i < blockLength; i += 4)
inc r14
add rsi, r9
add r11, r9
add r15, r9
add rdx, r9
add rcx, r9
add rdi, r9
cmp r14, r8
jne LOOP_ROWS
# конец цикла for (int q = 0; q < Q; q++)
pop rbx
pop r14
pop r15
pop rbp
ret
|
programs/oeis/116/A116774.asm | jmorken/loda | 1 | 27860 | <gh_stars>1-10
; A116774: Number of permutations of length n which avoid the patterns 2143, 2341, 4312; or avoid the patterns 1234, 1432, 3412.
; 1,2,6,21,69,198,498,1121,2305,4402,7910,13509,22101,34854,53250,79137,114785,162946,226918,310613,418629,556326,729906,946497,1214241,1542386,1941382,2422981,3000341,3688134
mov $12,$0
mov $14,$0
add $14,1
lpb $14
clr $0,12
mov $0,$12
sub $14,1
sub $0,$14
mov $9,$0
mov $11,$0
add $11,1
lpb $11
mov $0,$9
sub $11,1
sub $0,$11
mov $7,$0
bin $7,2
mov $0,$7
add $0,1
pow $0,2
mov $3,1
add $3,$0
add $3,2
mov $7,$8
mov $8,1
lpb $0
mov $0,$7
mov $5,40
lpe
mul $3,26
add $3,$5
mov $1,$3
sub $1,105
div $1,39
mov $5,$2
add $10,$1
lpe
add $13,$10
lpe
mov $1,$13
|
test/Succeed/Issue826.agda | shlevy/agda | 3 | 3354 | -- Andreas, 2013-03-20 Problem was that CompiledClause.Match.unfoldCoinduction
-- did not instantiate metas
-- {-# OPTIONS -v tc.meta.assign:10 -v tc.reduce:100 -v tc.with.abstract:50 #-}
{-# OPTIONS --allow-unsolved-metas #-}
module Issue826 where
open import Common.Coinduction
postulate
A : Set
x : A
P : A → Set
p : P x
data Q : ∞ A → Set where
♯x = ♯ x
Foo : Q ♯x
Foo = goal
where
x′ : _
x′ = _ -- problem went away if we wrote ♯x here
goal : Q x′ -- ensures that x′ = ♯ x (instantiates meta)
goal = {!♭ x′!} -- normalization of this expression should be x, but was not
-- Note that ♭ x′ is definitionally equal to x:
ok : P (♭ x′)
ok = p
good : P x
good with (♭ x′) | p
good | y | p′ = p′
{- This still does not work because the underscore is solved too late,
only after with-abstraction is taking place.
bad : P (♭ x′)
bad with x | p
bad | y | p′ = p′
-}
|
Driver/IFS/DOS/MS7/Common/dos7FileChange.asm | steakknife/pcgeos | 504 | 81264 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT:
MODULE:
FILE: dosFileChange.asm
AUTHOR: <NAME>, Nov 10, 1992
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Adam 11/10/92 Initial revision
DESCRIPTION:
Support functions for generating file-change notification.
$Id: dos7FileChange.asm,v 1.1 97/04/10 11:55:30 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Resident segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DOSFileChangeCalculateID
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Calculate the 32-bit ID for a path.
CALLED BY: (EXTERNAL)
PASS: ds:si = path whose ID wants calculating
RETURN: cxdx = 32-bit ID
DESTROYED: si
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DOSFileChangeCalculateID proc far
uses ax
.enter
clr cx
mov dx, 0x31fe ; magic number
call DOSFileChangeCalculateIDLow
.leave
ret
DOSFileChangeCalculateID endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DOSFileChangeCalculateIDLow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Calculate the 32-bit ID for a path, augmenting an ID
calculated for the leading components.
CALLED BY: (EXTERNAL)
PASS: ds:si = path whose ID wants calculating
RETURN: cxdx = 32-bit ID
DESTROYED: ax, si
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DOSFileChangeCalculateIDLow proc far
uses bx, di, bp
.enter
mov bx, cx
mov cl, 5
clr ah
charLoop:
lodsb
cmp al, '\\' ; don't count backslashes, so we avoid
je charLoop ; ickiness augmenting the current dir's
; ID during a FileEnum.
tst al ; end of string?
jz done ; yes
if _MS7
;
; Since dos7 maintains the case when the current dir is set, and
; different parts of the system use all upper of mixed case, we
; must convert to upper here so we can depend on the results.
;
cmp al, 'a'
jb onWithIt
cmp al, 'z'
ja onWithIt
sub al, 'a' - 'A'
onWithIt:
endif
;
; Multiply existing value by 33
;
movdw dibp, bxdx ; save current value for add
rol dx, cl ; *32, saving high 5 bits in low ones
shl bx, cl ; *32, making room for high 5 bits of
; dx
mov ch, dl
andnf ch, 0x1f ; ch <- high 5 bits of dx
andnf dl, not 0x1f ; nuke saved high 5 bits
or bl, ch ; shift high 5 bits into bx
adddw bxdx, dibp ; *32+1 = *33
;
; Add current character into the value.
;
add dx, ax
adc bx, 0
jmp charLoop
done:
;
; Return ID in cxdx
;
mov cx, bx
.leave
ret
DOSFileChangeCalculateIDLow endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DOSFileChangeGetCurPathID
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Fetch the ID of the current directory on DOS's default drive.
This is different from DOSPathGetCurPathID, which returns
the ID for the thread's current directory, as this can
be called after mapping a path with leading components
and obtain the proper result, while the other can't.
CALLED BY: (EXTERNAL)
PASS: nothing
RETURN: cxdx = FileID for DOS's current dir.
DESTROYED: ax, dosPathBuffer
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DOSFileChangeGetCurPathID proc far
uses ds, si
.enter
;
; Fetch the DOS dir for the default drive into dosPathBuffer. Don't
; have to worry that we don't get a leading backslash, as backslashes
; don't count in the calculation anyway.
;
segmov ds, dgroup, si
mov si, offset dosPathBuffer
clr dx ; default drive
if _MS7
mov ax, MSDOS7F_GET_CURRENT_DIR
else
mov ah, MSDOS_GET_CURRENT_DIR
endif
call FileInt21
;
; Figure the ID for the thing starting from scratch.
;
call DOSFileChangeCalculateID
.leave
ret
DOSFileChangeGetCurPathID endp
Resident ends
PathOps segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DOSFileChangeGenerateNotifyWithName
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Generate notification for something that requires a path
name in the data block
CALLED BY: (EXTERNAL) DOSAllocOpOpen, DOSAllocOpCreate, DOSPathOpRename,
DOSPathOpMove
PASS: ax = FileChangeNotificationType
[dosPathBuffer] = current directory (DOS)
[dosFinalComponent] = pointer to file name to include in the
notification
RETURN: carry clear
DESTROYED: ax, bx
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DOSFileChangeGenerateNotifyWithName proc far
uses cx, dx, ds
.enter
call PathOps_LoadVarSegDS
;
; Compute the ID for the containing directory, which is already loaded
; into dosPathBuffer.
;
push si
mov si, offset dosPathBuffer
call DOSFileChangeCalculateID ; cxdx <- dirID
pop si
;
; Point to the final component on which things operated and generate
; the notification.
;
lds bx, ds:[dosFinalComponent]
call FSDGenerateNotify
clc
.leave
ret
DOSFileChangeGenerateNotifyWithName endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DOSFileChangeGenerateNotifyForNativeFFD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Generate a file-change notification for whatever's in
dosNativeFFD
CALLED BY: (EXTERNAL) DOSPathOpDeleteDir
PASS: ax = FileChangeNotificationType
ds = dgroup
si = disk handle
RETURN: carry clear
DESTROYED: ax, dosPathBuffer
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DOSFileChangeGenerateNotifyForNativeFFD proc far
uses cx, dx
.enter
if _MS7
push si
mov si, offset dos7FindData
clr cx, dx
call DOS7GetIDFromFD
pop si
else:
GetIDFromDTA ds:[dosNativeFFD], cx, dx
endif
call FSDGenerateNotify
clc
.leave
ret
DOSFileChangeGenerateNotifyForNativeFFD endp
PathOps ends
|
hacks/images/m6502/zookeeper.asm | MBrassey/xscreensaver_BlueMatrix | 2 | 99656 | <filename>hacks/images/m6502/zookeeper.asm
; We all love zookeeper !!!!
; muhmi Nov 13, 2007 9:45 am
ldx #0
lda #0
hupsu:
sta $200,x
sta $300,x
sta $400,x
sta $500,x
bne hupsu
lda #1
ldx #0
fill:
txa
tay
lda seko,x
tax
lda kuva,x
sta $200,x
lda kuva_0,x
sta $300,x
lda kuva_1,x
sta $400,x
lda kuva_2,x
sta $500,x
tya
tax
inx
bne fill
rts
seko:
dcb 46,93,219,97,168,170,196,63,204,201,206
dcb 56,238,25,2,186,209,191,138,226,80,128
dcb 58,171,81,115,42,44,102,193,69,231,107
dcb 78,5,218,103,11,13,221,130,149,16,227
dcb 105,213,232,182,17,255,27,190,205,137,192
dcb 222,233,94,52,229,96,18,220,202,122,166
dcb 43,153,131,246,177,4,70,22,7,86,173
dcb 141,151,164,32,143,40,156,185,121,132,165
dcb 62,249,252,139,154,251,85,236,12,134,245
dcb 184,39,195,119,242,244,162,74,1,77,51
dcb 33,75,35,76,34,10,89,47,189,237,71
dcb 159,9,38,101,180,116,147,140,183,157,123
dcb 14,19,126,199,100,45,241,28,125,210,155
dcb 41,254,31,144,55,247,111,95,57,53,223
dcb 152,108,203,36,214,37,113,200,66,67,197
dcb 29,250,20,212,68,87,207,163,145,211,48
dcb 136,24,98,215,169,83,124,224,181,187,142
dcb 84,240,54,110,234,59,243,79,50,30,114
dcb 6,178,0,172,148,146,179,120,60,225,65
dcb 230,208,15,72,117,248,198,106,129,92,127
dcb 175,160,49,216,176,133,64,109,112,82,90
dcb 235,104,158,194,8,161,167,88,91,174,23
dcb 73,118,150,3,99,61,217,26,239,21,253
dcb 135,188,228
kuva:
dcb 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
dcb 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
dcb 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0
dcb 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1
dcb 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0
dcb 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1
dcb 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,11,11
dcb 11,0,0,0,0,0,0,1,0,0,0,11,11,11,0,0,0,0,0,1,1,1,1,1
dcb 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dcb 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
dcb 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1
kuva_0:
dcb 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dcb 0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1
dcb 1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1
dcb 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1
dcb 1,0,0,0,1,1,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0
dcb 0,1,15,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1
dcb 0,0,0,0,0,0,0,0,0,0,15,0,0,0,1,1,1,0,0,0,1,0,0,0
dcb 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,15,0,0,0,1,1
dcb 1,0,0,0,1,0,0,0,0,1,1,1,0,0,0,1,0,0,0,1,1,1,0,0
dcb 0,0,15,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,1,0,0,0,1
dcb 0,0,0,1,1,1,0,0,0,0,1,0,0,0,1,1
kuva_1:
dcb 1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0
dcb 0,0,15,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1
dcb 0,0,0,0,0,0,0,0,0,0,15,0,0,0,1,1,1,0,0,0,1,1,0,0
dcb 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,1
dcb 1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1
dcb 1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0
dcb 1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1
dcb 1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1
dcb 1,0,0,0,1,1,1,1,1,1,1,1,1,15,15,15,1,1,1,1,1,1,1,1
dcb 1,1,15,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,15,15,15
dcb 1,1,1,1,1,1,1,1,1,1,15,0,0,0,1,1
kuva_2:
dcb 1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
dcb 1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,15,15,0
dcb 15,15,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1
dcb 1,1,1,1,1,15,15,0,15,15,1,1,1,1,1,1,1,1,1,0,0,0,1,1
dcb 1,0,0,0,15,1,1,1,1,1,1,1,1,15,15,0,1,1,1,1,1,1,1,1
dcb 1,1,1,0,0,0,1,1,1,0,0,0,0,15,15,15,15,15,15,1,15,1,1,1
dcb 1,1,15,1,15,15,15,1,1,15,0,0,0,0,1,1,1,0,0,0,0,15,15,15
dcb 15,15,15,1,15,1,1,1,1,1,15,1,15,15,15,1,1,15,0,0,0,0,1,1
dcb 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dcb 0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
dcb 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1
|
x86/Gen_Legal.asm | lantonov/asm | 150 | 11716 | ; Generate all legal moves.
calign 16
Gen_Legal:
; in: rbp address of position
; rbx address of state
; io: rdi address to write moves
push rsi r12 r13 r14 r15
; generate moves
mov rax, qword[rbx+State.checkersBB]
mov rsi, rdi
mov r15, qword[rbx+State.pinned]
mov r13d, dword[rbp+Pos.sideToMove]
mov r12, qword[rbp+Pos.typeBB+8*King]
and r12, qword[rbp+Pos.typeBB+8*r13]
_tzcnt r14, r12
; r15 = pinned pieces
; r14d = our king square
; r13d = side
; r12 = our king bitboard
test rax, rax
jnz .InCheck
.NotInCheck: call Gen_NonEvasions
jmp .GenDone
.InCheck: call Gen_Evasions
.GenDone:
shl r14d, 6
mov edx, dword[rsi]
mov ecx, edx
mov eax, edx
cmp rsi, rdi
je .FilterDone
test r15, r15
jne .FilterYesPinned
.FilterNoPinned:
and ecx, 0x0FC0 ; ecx shr 6 = source square
add rsi, sizeof.ExtMove
cmp ecx, r14d
je .KingMove
cmp edx, MOVE_TYPE_EPCAP shl 12
jae .EpCapture
mov edx, dword[rsi]
mov ecx, edx ; move is legal at this point
mov eax, edx
cmp rsi, rdi
jne .FilterNoPinned
.FilterDone:
pop r15 r14 r13 r12 rsi
ret
calign 8
.KingMove:
; if they have an attacker to king's destination square, then move is illegal
and eax, 63 ; eax = destination square
mov ecx, r13d
shl ecx, 6+3
mov rcx, qword[PawnAttacks+rcx+8*rax]
; pseudo legal castling moves are always legal ep captures have already been caught
cmp edx, MOVE_TYPE_CASTLE shl 12
jae .FilterLegalChoose
mov r9, qword[rbp+Pos.typeBB+8*r13]
xor r13d, 1
mov r10, qword[rbp+Pos.typeBB+8*r13]
or r9, r10
xor r13d, 1
; pawn
and rcx, qword[rbp+Pos.typeBB+8*Pawn]
test rcx, r10
jnz .FilterIllegalChoose
; king
mov rdx, qword[KingAttacks+8*rax]
and rdx, qword[rbp+Pos.typeBB+8*King]
test rdx, r10
jnz .FilterIllegalChoose
; knight
mov rdx, qword[KnightAttacks+8*rax]
and rdx, qword[rbp+Pos.typeBB+8*Knight]
test rdx, r10
jnz .FilterIllegalChoose
; bishop + queen
BishopAttacks rdx, rax, r9, r8
mov r8, qword[rbp+Pos.typeBB+8*Bishop]
or r8, qword[rbp+Pos.typeBB+8*Queen]
and r8, r10
test rdx, r8
jnz .FilterIllegalChoose
; rook + queen
RookAttacks rdx, rax, r9, r8
mov r8, qword[rbp+Pos.typeBB+8*Rook]
or r8, qword[rbp+Pos.typeBB+8*Queen]
and r8, r10
test rdx, r8
jnz .FilterIllegalChoose
.FilterLegalChoose:
mov edx, dword[rsi]
mov ecx, edx ; move is legal at this point
mov eax, edx
cmp rsi, rdi
je .FilterDone
test r15, r15
jz .FilterNoPinned
jmp .FilterYesPinned
.FilterIllegalChoose:
sub rdi, sizeof.ExtMove
sub rsi, sizeof.ExtMove
mov edx, dword [rdi]
mov dword [rsi], edx
mov ecx, edx ; move is legal at this point
mov eax, edx
cmp rsi, rdi
je .FilterDone
test r15, r15
jz .FilterNoPinned
calign 8
.FilterYesPinned:
and ecx, 0x0FC0 ; ecx shr 6 = source square
add rsi, sizeof.ExtMove
cmp ecx, r14d
je .KingMove
cmp edx, MOVE_TYPE_EPCAP shl 12
jae .EpCapture
shr ecx, 6
and eax, 0x0FFF
bt r15, rcx
jc .FilterYesPinnedWeArePinned
.FilterYesPinnedLegal:
mov edx, dword[rsi]
mov ecx, edx ; move is legal at this point
mov eax, edx
cmp rsi, rdi
jne .FilterYesPinned
jmp .FilterDone
.FilterYesPinnedWeArePinned:
test r12, qword[LineBB+8*rax]
jnz .FilterYesPinnedLegal
.FilterYesPinnedIllegal:
sub rdi, sizeof.ExtMove
sub rsi, sizeof.ExtMove
mov edx, dword[rdi]
mov dword[rsi], edx
mov ecx, edx ; move is legal at this point
mov eax, edx
cmp rsi, rdi
jne .FilterYesPinned
jmp .FilterDone
calign 8
.EpCapture:
; for ep captures, just make the move and test if our king is attacked
xor r13d, 1
mov r10, qword[rbp+Pos.typeBB+8*r13]
xor r13d, 1
mov r9d, r14d
shr r9d, 6
; all pieces
mov rdx, qword[rbp+Pos.typeBB+8*White]
or rdx, qword[rbp+Pos.typeBB+8*Black]
; remove source square
shr ecx, 6
btr rdx, rcx
; add destination square (ep square)
and eax, 63
bts rdx, rax
; remove captured pawn
lea ecx, [2*r13-1]
lea ecx, [rax+8*rcx]
btr rdx, rcx
; check for rook attacks
RookAttacks rax, r9, rdx, r8
mov rcx, qword[rbp+Pos.typeBB+8*Rook]
or rcx, qword[rbp+Pos.typeBB+8*Queen]
and rcx, r10
test rax, rcx
jnz .FilterIllegalChoose
; check for bishop attacks
BishopAttacks rax, r9, rdx, r8
mov rcx, qword [rbp+Pos.typeBB+8*Bishop]
or rcx, qword[rbp+Pos.typeBB+8*Queen]
and rcx, r10
test rax, rcx
jnz .FilterIllegalChoose
jmp .FilterLegalChoose
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/loop_optimization23.adb | best08618/asylo | 7 | 25745 | <reponame>best08618/asylo
-- { dg-do run }
-- { dg-options "-O3" }
-- PR tree-optimization/71083
with Loop_Optimization23_Pkg;
use Loop_Optimization23_Pkg;
procedure Loop_Optimization23 is
Test : ArrayOfStructB;
begin
Test (0).b.b := 9999;
Foo (Test);
if Test (100).b.b /= 9999 then
raise Program_Error;
end if;
end;
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2062.asm | ljhsiun2/medusa | 9 | 177822 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r15
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0xb375, %r12
nop
nop
cmp $40246, %rdi
mov (%r12), %rbx
nop
nop
nop
nop
nop
and %r12, %r12
lea addresses_WC_ht+0x1dc79, %rax
nop
nop
nop
add $56232, %rdx
movups (%rax), %xmm3
vpextrq $1, %xmm3, %r11
nop
nop
nop
xor %rax, %rax
lea addresses_UC_ht+0x6f75, %r11
nop
nop
cmp %r15, %r15
mov (%r11), %rdx
nop
nop
nop
nop
and $9948, %rax
lea addresses_WT_ht+0x99e5, %rdi
nop
nop
dec %rdx
vmovups (%rdi), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %r11
sub %rdi, %rdi
lea addresses_A_ht+0x16f75, %rdi
nop
inc %rax
movb $0x61, (%rdi)
mfence
lea addresses_D_ht+0x1375, %rax
nop
nop
nop
sub $6756, %r15
movb (%rax), %r12b
nop
cmp %r15, %r15
lea addresses_WC_ht+0x2676, %r12
nop
nop
sub $569, %rdx
movl $0x61626364, (%r12)
nop
sub %r12, %r12
lea addresses_D_ht+0xfb95, %r15
dec %rdx
movups (%r15), %xmm3
vpextrq $1, %xmm3, %rdi
nop
nop
nop
add %rdi, %rdi
lea addresses_WC_ht+0x5475, %r15
nop
nop
nop
add $45788, %rdi
mov (%r15), %r11d
nop
nop
nop
nop
nop
sub $58752, %r15
lea addresses_WT_ht+0x9475, %r11
and $1516, %rdx
mov (%r11), %rax
nop
inc %rbx
lea addresses_D_ht+0x356b, %r11
nop
nop
nop
dec %r15
movl $0x61626364, (%r11)
nop
nop
nop
mfence
lea addresses_WT_ht+0x1775, %rax
nop
nop
nop
and $20495, %rdi
mov (%rax), %ebx
nop
nop
sub $1530, %rdx
lea addresses_WC_ht+0xaef1, %rsi
lea addresses_A_ht+0x12d05, %rdi
nop
nop
nop
sub %rdx, %rdx
mov $73, %rcx
rep movsw
nop
nop
and %r12, %r12
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r15
push %r9
push %rbx
push %rcx
push %rdi
// Store
lea addresses_RW+0x15ab5, %rdi
nop
nop
nop
nop
nop
and $6382, %rbx
movl $0x51525354, (%rdi)
nop
nop
nop
nop
nop
cmp $53481, %r13
// Store
mov $0xc7b, %r12
nop
nop
nop
nop
add $35597, %r9
movb $0x51, (%r12)
nop
nop
nop
xor $4192, %r15
// Store
mov $0x935, %r9
nop
nop
nop
nop
nop
add $33214, %r15
movb $0x51, (%r9)
nop
nop
nop
nop
nop
cmp $468, %rbx
// Store
lea addresses_UC+0x19175, %r13
nop
nop
cmp $46639, %rdi
movb $0x51, (%r13)
nop
nop
nop
nop
nop
add $15045, %rdi
// Faulty Load
lea addresses_normal+0x11775, %rbx
add %r13, %r13
mov (%rbx), %rcx
lea oracles, %r15
and $0xff, %rcx
shlq $12, %rcx
mov (%r15,%rcx,1), %rcx
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r15
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': True, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 10, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 11, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 11, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 2, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 4, 'same': False, 'NT': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 1, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 11, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
alloy4fun_models/trashltl/models/9/nkjhA6HR9GgKFqLfc.als | Kaixi26/org.alloytools.alloy | 0 | 4435 | <reponame>Kaixi26/org.alloytools.alloy
open main
pred idnkjhA6HR9GgKFqLfc_prop10 {
always all p : Protected | p in Protected => always p in Protected
}
pred __repair { idnkjhA6HR9GgKFqLfc_prop10 }
check __repair { idnkjhA6HR9GgKFqLfc_prop10 <=> prop10o } |
Gsanity.asm | Ghazal-S/Project2 | 0 | 19185 |
_Gsanity: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
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: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
Gsanity();
11: e8 4a 00 00 00 call 60 <Gsanity>
16: 66 90 xchg %ax,%ax
18: 66 90 xchg %ax,%ax
1a: 66 90 xchg %ax,%ax
1c: 66 90 xchg %ax,%ax
1e: 66 90 xchg %ax,%ax
00000020 <foo>:
{
20: 55 push %ebp
21: 89 e5 mov %esp,%ebp
23: 53 push %ebx
for (i=0;i<50;i++){
24: 31 db xor %ebx,%ebx
{
26: 83 ec 04 sub $0x4,%esp
29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printf(2, "process %d is printing for the %d time \n",getpid(),i);
30: e8 7d 03 00 00 call 3b2 <getpid>
35: 53 push %ebx
36: 50 push %eax
for (i=0;i<50;i++){
37: 83 c3 01 add $0x1,%ebx
printf(2, "process %d is printing for the %d time \n",getpid(),i);
3a: 68 d8 07 00 00 push $0x7d8
3f: 6a 02 push $0x2
41: e8 3a 04 00 00 call 480 <printf>
for (i=0;i<50;i++){
46: 83 c4 10 add $0x10,%esp
49: 83 fb 32 cmp $0x32,%ebx
4c: 75 e2 jne 30 <foo+0x10>
}
4e: 8b 5d fc mov -0x4(%ebp),%ebx
51: c9 leave
52: c3 ret
53: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000060 <Gsanity>:
{
60: 55 push %ebp
61: 89 e5 mov %esp,%ebp
63: 83 ec 10 sub $0x10,%esp
printf(1, "Gsanity\n");
66: 68 04 08 00 00 push $0x804
6b: 6a 01 push $0x1
6d: e8 0e 04 00 00 call 480 <printf>
printf(1, "Father pid is %d \n",getpid());
72: e8 3b 03 00 00 call 3b2 <getpid>
77: 83 c4 0c add $0xc,%esp
7a: 50 push %eax
7b: 68 0d 08 00 00 push $0x80d
80: 6a 01 push $0x1
82: e8 f9 03 00 00 call 480 <printf>
sleep(10);
87: c7 04 24 0a 00 00 00 movl $0xa,(%esp)
8e: e8 37 03 00 00 call 3ca <sleep>
pid = fork ();
93: e8 82 02 00 00 call 31a <fork>
if ( pid < 0 ) {
98: 83 c4 10 add $0x10,%esp
9b: 85 c0 test %eax,%eax
9d: 78 0a js a9 <Gsanity+0x49>
foo();
9f: e8 7c ff ff ff call 20 <foo>
exit();
a4: e8 79 02 00 00 call 322 <exit>
printf(1, "%d failed in fork!\n", getpid());
a9: e8 04 03 00 00 call 3b2 <getpid>
ae: 52 push %edx
af: 50 push %eax
b0: 68 21 08 00 00 push $0x821
b5: 6a 01 push $0x1
b7: e8 c4 03 00 00 call 480 <printf>
exit();
bc: e8 61 02 00 00 call 322 <exit>
c1: 66 90 xchg %ax,%ax
c3: 66 90 xchg %ax,%ax
c5: 66 90 xchg %ax,%ax
c7: 66 90 xchg %ax,%ax
c9: 66 90 xchg %ax,%ax
cb: 66 90 xchg %ax,%ax
cd: 66 90 xchg %ax,%ax
cf: 90 nop
000000d0 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
d0: 55 push %ebp
d1: 89 e5 mov %esp,%ebp
d3: 53 push %ebx
d4: 8b 45 08 mov 0x8(%ebp),%eax
d7: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
da: 89 c2 mov %eax,%edx
dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
e0: 83 c1 01 add $0x1,%ecx
e3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
e7: 83 c2 01 add $0x1,%edx
ea: 84 db test %bl,%bl
ec: 88 5a ff mov %bl,-0x1(%edx)
ef: 75 ef jne e0 <strcpy+0x10>
;
return os;
}
f1: 5b pop %ebx
f2: 5d pop %ebp
f3: c3 ret
f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000100 <strcmp>:
int
strcmp(const char *p, const char *q)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 53 push %ebx
104: 8b 55 08 mov 0x8(%ebp),%edx
107: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
10a: 0f b6 02 movzbl (%edx),%eax
10d: 0f b6 19 movzbl (%ecx),%ebx
110: 84 c0 test %al,%al
112: 75 1c jne 130 <strcmp+0x30>
114: eb 2a jmp 140 <strcmp+0x40>
116: 8d 76 00 lea 0x0(%esi),%esi
119: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
120: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
123: 0f b6 02 movzbl (%edx),%eax
p++, q++;
126: 83 c1 01 add $0x1,%ecx
129: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
12c: 84 c0 test %al,%al
12e: 74 10 je 140 <strcmp+0x40>
130: 38 d8 cmp %bl,%al
132: 74 ec je 120 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
134: 29 d8 sub %ebx,%eax
}
136: 5b pop %ebx
137: 5d pop %ebp
138: c3 ret
139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
140: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
142: 29 d8 sub %ebx,%eax
}
144: 5b pop %ebx
145: 5d pop %ebp
146: c3 ret
147: 89 f6 mov %esi,%esi
149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000150 <strlen>:
uint
strlen(const char *s)
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
156: 80 39 00 cmpb $0x0,(%ecx)
159: 74 15 je 170 <strlen+0x20>
15b: 31 d2 xor %edx,%edx
15d: 8d 76 00 lea 0x0(%esi),%esi
160: 83 c2 01 add $0x1,%edx
163: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
167: 89 d0 mov %edx,%eax
169: 75 f5 jne 160 <strlen+0x10>
;
return n;
}
16b: 5d pop %ebp
16c: c3 ret
16d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
170: 31 c0 xor %eax,%eax
}
172: 5d pop %ebp
173: c3 ret
174: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
17a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000180 <memset>:
void*
memset(void *dst, int c, uint n)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 57 push %edi
184: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
187: 8b 4d 10 mov 0x10(%ebp),%ecx
18a: 8b 45 0c mov 0xc(%ebp),%eax
18d: 89 d7 mov %edx,%edi
18f: fc cld
190: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
192: 89 d0 mov %edx,%eax
194: 5f pop %edi
195: 5d pop %ebp
196: c3 ret
197: 89 f6 mov %esi,%esi
199: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001a0 <strchr>:
char*
strchr(const char *s, char c)
{
1a0: 55 push %ebp
1a1: 89 e5 mov %esp,%ebp
1a3: 53 push %ebx
1a4: 8b 45 08 mov 0x8(%ebp),%eax
1a7: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
1aa: 0f b6 10 movzbl (%eax),%edx
1ad: 84 d2 test %dl,%dl
1af: 74 1d je 1ce <strchr+0x2e>
if(*s == c)
1b1: 38 d3 cmp %dl,%bl
1b3: 89 d9 mov %ebx,%ecx
1b5: 75 0d jne 1c4 <strchr+0x24>
1b7: eb 17 jmp 1d0 <strchr+0x30>
1b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1c0: 38 ca cmp %cl,%dl
1c2: 74 0c je 1d0 <strchr+0x30>
for(; *s; s++)
1c4: 83 c0 01 add $0x1,%eax
1c7: 0f b6 10 movzbl (%eax),%edx
1ca: 84 d2 test %dl,%dl
1cc: 75 f2 jne 1c0 <strchr+0x20>
return (char*)s;
return 0;
1ce: 31 c0 xor %eax,%eax
}
1d0: 5b pop %ebx
1d1: 5d pop %ebp
1d2: c3 ret
1d3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001e0 <gets>:
char*
gets(char *buf, int max)
{
1e0: 55 push %ebp
1e1: 89 e5 mov %esp,%ebp
1e3: 57 push %edi
1e4: 56 push %esi
1e5: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
1e6: 31 f6 xor %esi,%esi
1e8: 89 f3 mov %esi,%ebx
{
1ea: 83 ec 1c sub $0x1c,%esp
1ed: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
1f0: eb 2f jmp 221 <gets+0x41>
1f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
1f8: 8d 45 e7 lea -0x19(%ebp),%eax
1fb: 83 ec 04 sub $0x4,%esp
1fe: 6a 01 push $0x1
200: 50 push %eax
201: 6a 00 push $0x0
203: e8 42 01 00 00 call 34a <read>
if(cc < 1)
208: 83 c4 10 add $0x10,%esp
20b: 85 c0 test %eax,%eax
20d: 7e 1c jle 22b <gets+0x4b>
break;
buf[i++] = c;
20f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
213: 83 c7 01 add $0x1,%edi
216: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
219: 3c 0a cmp $0xa,%al
21b: 74 23 je 240 <gets+0x60>
21d: 3c 0d cmp $0xd,%al
21f: 74 1f je 240 <gets+0x60>
for(i=0; i+1 < max; ){
221: 83 c3 01 add $0x1,%ebx
224: 3b 5d 0c cmp 0xc(%ebp),%ebx
227: 89 fe mov %edi,%esi
229: 7c cd jl 1f8 <gets+0x18>
22b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
22d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
230: c6 03 00 movb $0x0,(%ebx)
}
233: 8d 65 f4 lea -0xc(%ebp),%esp
236: 5b pop %ebx
237: 5e pop %esi
238: 5f pop %edi
239: 5d pop %ebp
23a: c3 ret
23b: 90 nop
23c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
240: 8b 75 08 mov 0x8(%ebp),%esi
243: 8b 45 08 mov 0x8(%ebp),%eax
246: 01 de add %ebx,%esi
248: 89 f3 mov %esi,%ebx
buf[i] = '\0';
24a: c6 03 00 movb $0x0,(%ebx)
}
24d: 8d 65 f4 lea -0xc(%ebp),%esp
250: 5b pop %ebx
251: 5e pop %esi
252: 5f pop %edi
253: 5d pop %ebp
254: c3 ret
255: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000260 <stat>:
int
stat(const char *n, struct stat *st)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 56 push %esi
264: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
265: 83 ec 08 sub $0x8,%esp
268: 6a 00 push $0x0
26a: ff 75 08 pushl 0x8(%ebp)
26d: e8 00 01 00 00 call 372 <open>
if(fd < 0)
272: 83 c4 10 add $0x10,%esp
275: 85 c0 test %eax,%eax
277: 78 27 js 2a0 <stat+0x40>
return -1;
r = fstat(fd, st);
279: 83 ec 08 sub $0x8,%esp
27c: ff 75 0c pushl 0xc(%ebp)
27f: 89 c3 mov %eax,%ebx
281: 50 push %eax
282: e8 03 01 00 00 call 38a <fstat>
close(fd);
287: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
28a: 89 c6 mov %eax,%esi
close(fd);
28c: e8 c9 00 00 00 call 35a <close>
return r;
291: 83 c4 10 add $0x10,%esp
}
294: 8d 65 f8 lea -0x8(%ebp),%esp
297: 89 f0 mov %esi,%eax
299: 5b pop %ebx
29a: 5e pop %esi
29b: 5d pop %ebp
29c: c3 ret
29d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
2a0: be ff ff ff ff mov $0xffffffff,%esi
2a5: eb ed jmp 294 <stat+0x34>
2a7: 89 f6 mov %esi,%esi
2a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000002b0 <atoi>:
int
atoi(const char *s)
{
2b0: 55 push %ebp
2b1: 89 e5 mov %esp,%ebp
2b3: 53 push %ebx
2b4: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
2b7: 0f be 11 movsbl (%ecx),%edx
2ba: 8d 42 d0 lea -0x30(%edx),%eax
2bd: 3c 09 cmp $0x9,%al
n = 0;
2bf: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
2c4: 77 1f ja 2e5 <atoi+0x35>
2c6: 8d 76 00 lea 0x0(%esi),%esi
2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
2d0: 8d 04 80 lea (%eax,%eax,4),%eax
2d3: 83 c1 01 add $0x1,%ecx
2d6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
2da: 0f be 11 movsbl (%ecx),%edx
2dd: 8d 5a d0 lea -0x30(%edx),%ebx
2e0: 80 fb 09 cmp $0x9,%bl
2e3: 76 eb jbe 2d0 <atoi+0x20>
return n;
}
2e5: 5b pop %ebx
2e6: 5d pop %ebp
2e7: c3 ret
2e8: 90 nop
2e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000002f0 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
2f0: 55 push %ebp
2f1: 89 e5 mov %esp,%ebp
2f3: 56 push %esi
2f4: 53 push %ebx
2f5: 8b 5d 10 mov 0x10(%ebp),%ebx
2f8: 8b 45 08 mov 0x8(%ebp),%eax
2fb: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2fe: 85 db test %ebx,%ebx
300: 7e 14 jle 316 <memmove+0x26>
302: 31 d2 xor %edx,%edx
304: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
308: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
30c: 88 0c 10 mov %cl,(%eax,%edx,1)
30f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
312: 39 d3 cmp %edx,%ebx
314: 75 f2 jne 308 <memmove+0x18>
return vdst;
}
316: 5b pop %ebx
317: 5e pop %esi
318: 5d pop %ebp
319: c3 ret
0000031a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
31a: b8 01 00 00 00 mov $0x1,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <exit>:
SYSCALL(exit)
322: b8 02 00 00 00 mov $0x2,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <wait>:
SYSCALL(wait)
32a: b8 03 00 00 00 mov $0x3,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <getPerformanceData>:
SYSCALL(getPerformanceData) // calculates process run time and wait time
332: b8 16 00 00 00 mov $0x16,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <nice>:
SYSCALL(nice)
33a: b8 17 00 00 00 mov $0x17,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <pipe>:
SYSCALL(pipe)
342: b8 04 00 00 00 mov $0x4,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <read>:
SYSCALL(read)
34a: b8 05 00 00 00 mov $0x5,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <write>:
SYSCALL(write)
352: b8 10 00 00 00 mov $0x10,%eax
357: cd 40 int $0x40
359: c3 ret
0000035a <close>:
SYSCALL(close)
35a: b8 15 00 00 00 mov $0x15,%eax
35f: cd 40 int $0x40
361: c3 ret
00000362 <kill>:
SYSCALL(kill)
362: b8 06 00 00 00 mov $0x6,%eax
367: cd 40 int $0x40
369: c3 ret
0000036a <exec>:
SYSCALL(exec)
36a: b8 07 00 00 00 mov $0x7,%eax
36f: cd 40 int $0x40
371: c3 ret
00000372 <open>:
SYSCALL(open)
372: b8 0f 00 00 00 mov $0xf,%eax
377: cd 40 int $0x40
379: c3 ret
0000037a <mknod>:
SYSCALL(mknod)
37a: b8 11 00 00 00 mov $0x11,%eax
37f: cd 40 int $0x40
381: c3 ret
00000382 <unlink>:
SYSCALL(unlink)
382: b8 12 00 00 00 mov $0x12,%eax
387: cd 40 int $0x40
389: c3 ret
0000038a <fstat>:
SYSCALL(fstat)
38a: b8 08 00 00 00 mov $0x8,%eax
38f: cd 40 int $0x40
391: c3 ret
00000392 <link>:
SYSCALL(link)
392: b8 13 00 00 00 mov $0x13,%eax
397: cd 40 int $0x40
399: c3 ret
0000039a <mkdir>:
SYSCALL(mkdir)
39a: b8 14 00 00 00 mov $0x14,%eax
39f: cd 40 int $0x40
3a1: c3 ret
000003a2 <chdir>:
SYSCALL(chdir)
3a2: b8 09 00 00 00 mov $0x9,%eax
3a7: cd 40 int $0x40
3a9: c3 ret
000003aa <dup>:
SYSCALL(dup)
3aa: b8 0a 00 00 00 mov $0xa,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <getpid>:
SYSCALL(getpid)
3b2: b8 0b 00 00 00 mov $0xb,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <getppid>:
SYSCALL(getppid)
3ba: b8 18 00 00 00 mov $0x18,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <sbrk>:
SYSCALL(sbrk)
3c2: b8 0c 00 00 00 mov $0xc,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <sleep>:
SYSCALL(sleep)
3ca: b8 0d 00 00 00 mov $0xd,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <uptime>:
SYSCALL(uptime)
3d2: b8 0e 00 00 00 mov $0xe,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
3da: 66 90 xchg %ax,%ax
3dc: 66 90 xchg %ax,%ax
3de: 66 90 xchg %ax,%ax
000003e0 <printint>:
3e0: 55 push %ebp
3e1: 89 e5 mov %esp,%ebp
3e3: 57 push %edi
3e4: 56 push %esi
3e5: 53 push %ebx
3e6: 83 ec 3c sub $0x3c,%esp
3e9: 85 d2 test %edx,%edx
3eb: 89 45 c0 mov %eax,-0x40(%ebp)
3ee: 89 d0 mov %edx,%eax
3f0: 79 76 jns 468 <printint+0x88>
3f2: f6 45 08 01 testb $0x1,0x8(%ebp)
3f6: 74 70 je 468 <printint+0x88>
3f8: f7 d8 neg %eax
3fa: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
401: 31 f6 xor %esi,%esi
403: 8d 5d d7 lea -0x29(%ebp),%ebx
406: eb 0a jmp 412 <printint+0x32>
408: 90 nop
409: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
410: 89 fe mov %edi,%esi
412: 31 d2 xor %edx,%edx
414: 8d 7e 01 lea 0x1(%esi),%edi
417: f7 f1 div %ecx
419: 0f b6 92 3c 08 00 00 movzbl 0x83c(%edx),%edx
420: 85 c0 test %eax,%eax
422: 88 14 3b mov %dl,(%ebx,%edi,1)
425: 75 e9 jne 410 <printint+0x30>
427: 8b 45 c4 mov -0x3c(%ebp),%eax
42a: 85 c0 test %eax,%eax
42c: 74 08 je 436 <printint+0x56>
42e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
433: 8d 7e 02 lea 0x2(%esi),%edi
436: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
43a: 8b 7d c0 mov -0x40(%ebp),%edi
43d: 8d 76 00 lea 0x0(%esi),%esi
440: 0f b6 06 movzbl (%esi),%eax
443: 83 ec 04 sub $0x4,%esp
446: 83 ee 01 sub $0x1,%esi
449: 6a 01 push $0x1
44b: 53 push %ebx
44c: 57 push %edi
44d: 88 45 d7 mov %al,-0x29(%ebp)
450: e8 fd fe ff ff call 352 <write>
455: 83 c4 10 add $0x10,%esp
458: 39 de cmp %ebx,%esi
45a: 75 e4 jne 440 <printint+0x60>
45c: 8d 65 f4 lea -0xc(%ebp),%esp
45f: 5b pop %ebx
460: 5e pop %esi
461: 5f pop %edi
462: 5d pop %ebp
463: c3 ret
464: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
468: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
46f: eb 90 jmp 401 <printint+0x21>
471: eb 0d jmp 480 <printf>
473: 90 nop
474: 90 nop
475: 90 nop
476: 90 nop
477: 90 nop
478: 90 nop
479: 90 nop
47a: 90 nop
47b: 90 nop
47c: 90 nop
47d: 90 nop
47e: 90 nop
47f: 90 nop
00000480 <printf>:
480: 55 push %ebp
481: 89 e5 mov %esp,%ebp
483: 57 push %edi
484: 56 push %esi
485: 53 push %ebx
486: 83 ec 2c sub $0x2c,%esp
489: 8b 75 0c mov 0xc(%ebp),%esi
48c: 0f b6 1e movzbl (%esi),%ebx
48f: 84 db test %bl,%bl
491: 0f 84 b3 00 00 00 je 54a <printf+0xca>
497: 8d 45 10 lea 0x10(%ebp),%eax
49a: 83 c6 01 add $0x1,%esi
49d: 31 ff xor %edi,%edi
49f: 89 45 d4 mov %eax,-0x2c(%ebp)
4a2: eb 2f jmp 4d3 <printf+0x53>
4a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
4a8: 83 f8 25 cmp $0x25,%eax
4ab: 0f 84 a7 00 00 00 je 558 <printf+0xd8>
4b1: 8d 45 e2 lea -0x1e(%ebp),%eax
4b4: 83 ec 04 sub $0x4,%esp
4b7: 88 5d e2 mov %bl,-0x1e(%ebp)
4ba: 6a 01 push $0x1
4bc: 50 push %eax
4bd: ff 75 08 pushl 0x8(%ebp)
4c0: e8 8d fe ff ff call 352 <write>
4c5: 83 c4 10 add $0x10,%esp
4c8: 83 c6 01 add $0x1,%esi
4cb: 0f b6 5e ff movzbl -0x1(%esi),%ebx
4cf: 84 db test %bl,%bl
4d1: 74 77 je 54a <printf+0xca>
4d3: 85 ff test %edi,%edi
4d5: 0f be cb movsbl %bl,%ecx
4d8: 0f b6 c3 movzbl %bl,%eax
4db: 74 cb je 4a8 <printf+0x28>
4dd: 83 ff 25 cmp $0x25,%edi
4e0: 75 e6 jne 4c8 <printf+0x48>
4e2: 83 f8 64 cmp $0x64,%eax
4e5: 0f 84 05 01 00 00 je 5f0 <printf+0x170>
4eb: 81 e1 f7 00 00 00 and $0xf7,%ecx
4f1: 83 f9 70 cmp $0x70,%ecx
4f4: 74 72 je 568 <printf+0xe8>
4f6: 83 f8 73 cmp $0x73,%eax
4f9: 0f 84 99 00 00 00 je 598 <printf+0x118>
4ff: 83 f8 63 cmp $0x63,%eax
502: 0f 84 08 01 00 00 je 610 <printf+0x190>
508: 83 f8 25 cmp $0x25,%eax
50b: 0f 84 ef 00 00 00 je 600 <printf+0x180>
511: 8d 45 e7 lea -0x19(%ebp),%eax
514: 83 ec 04 sub $0x4,%esp
517: c6 45 e7 25 movb $0x25,-0x19(%ebp)
51b: 6a 01 push $0x1
51d: 50 push %eax
51e: ff 75 08 pushl 0x8(%ebp)
521: e8 2c fe ff ff call 352 <write>
526: 83 c4 0c add $0xc,%esp
529: 8d 45 e6 lea -0x1a(%ebp),%eax
52c: 88 5d e6 mov %bl,-0x1a(%ebp)
52f: 6a 01 push $0x1
531: 50 push %eax
532: ff 75 08 pushl 0x8(%ebp)
535: 83 c6 01 add $0x1,%esi
538: 31 ff xor %edi,%edi
53a: e8 13 fe ff ff call 352 <write>
53f: 0f b6 5e ff movzbl -0x1(%esi),%ebx
543: 83 c4 10 add $0x10,%esp
546: 84 db test %bl,%bl
548: 75 89 jne 4d3 <printf+0x53>
54a: 8d 65 f4 lea -0xc(%ebp),%esp
54d: 5b pop %ebx
54e: 5e pop %esi
54f: 5f pop %edi
550: 5d pop %ebp
551: c3 ret
552: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
558: bf 25 00 00 00 mov $0x25,%edi
55d: e9 66 ff ff ff jmp 4c8 <printf+0x48>
562: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
568: 83 ec 0c sub $0xc,%esp
56b: b9 10 00 00 00 mov $0x10,%ecx
570: 6a 00 push $0x0
572: 8b 7d d4 mov -0x2c(%ebp),%edi
575: 8b 45 08 mov 0x8(%ebp),%eax
578: 8b 17 mov (%edi),%edx
57a: e8 61 fe ff ff call 3e0 <printint>
57f: 89 f8 mov %edi,%eax
581: 83 c4 10 add $0x10,%esp
584: 31 ff xor %edi,%edi
586: 83 c0 04 add $0x4,%eax
589: 89 45 d4 mov %eax,-0x2c(%ebp)
58c: e9 37 ff ff ff jmp 4c8 <printf+0x48>
591: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
598: 8b 45 d4 mov -0x2c(%ebp),%eax
59b: 8b 08 mov (%eax),%ecx
59d: 83 c0 04 add $0x4,%eax
5a0: 89 45 d4 mov %eax,-0x2c(%ebp)
5a3: 85 c9 test %ecx,%ecx
5a5: 0f 84 8e 00 00 00 je 639 <printf+0x1b9>
5ab: 0f b6 01 movzbl (%ecx),%eax
5ae: 31 ff xor %edi,%edi
5b0: 89 cb mov %ecx,%ebx
5b2: 84 c0 test %al,%al
5b4: 0f 84 0e ff ff ff je 4c8 <printf+0x48>
5ba: 89 75 d0 mov %esi,-0x30(%ebp)
5bd: 89 de mov %ebx,%esi
5bf: 8b 5d 08 mov 0x8(%ebp),%ebx
5c2: 8d 7d e3 lea -0x1d(%ebp),%edi
5c5: 8d 76 00 lea 0x0(%esi),%esi
5c8: 83 ec 04 sub $0x4,%esp
5cb: 83 c6 01 add $0x1,%esi
5ce: 88 45 e3 mov %al,-0x1d(%ebp)
5d1: 6a 01 push $0x1
5d3: 57 push %edi
5d4: 53 push %ebx
5d5: e8 78 fd ff ff call 352 <write>
5da: 0f b6 06 movzbl (%esi),%eax
5dd: 83 c4 10 add $0x10,%esp
5e0: 84 c0 test %al,%al
5e2: 75 e4 jne 5c8 <printf+0x148>
5e4: 8b 75 d0 mov -0x30(%ebp),%esi
5e7: 31 ff xor %edi,%edi
5e9: e9 da fe ff ff jmp 4c8 <printf+0x48>
5ee: 66 90 xchg %ax,%ax
5f0: 83 ec 0c sub $0xc,%esp
5f3: b9 0a 00 00 00 mov $0xa,%ecx
5f8: 6a 01 push $0x1
5fa: e9 73 ff ff ff jmp 572 <printf+0xf2>
5ff: 90 nop
600: 83 ec 04 sub $0x4,%esp
603: 88 5d e5 mov %bl,-0x1b(%ebp)
606: 8d 45 e5 lea -0x1b(%ebp),%eax
609: 6a 01 push $0x1
60b: e9 21 ff ff ff jmp 531 <printf+0xb1>
610: 8b 7d d4 mov -0x2c(%ebp),%edi
613: 83 ec 04 sub $0x4,%esp
616: 8b 07 mov (%edi),%eax
618: 6a 01 push $0x1
61a: 83 c7 04 add $0x4,%edi
61d: 88 45 e4 mov %al,-0x1c(%ebp)
620: 8d 45 e4 lea -0x1c(%ebp),%eax
623: 50 push %eax
624: ff 75 08 pushl 0x8(%ebp)
627: e8 26 fd ff ff call 352 <write>
62c: 89 7d d4 mov %edi,-0x2c(%ebp)
62f: 83 c4 10 add $0x10,%esp
632: 31 ff xor %edi,%edi
634: e9 8f fe ff ff jmp 4c8 <printf+0x48>
639: bb 35 08 00 00 mov $0x835,%ebx
63e: b8 28 00 00 00 mov $0x28,%eax
643: e9 72 ff ff ff jmp 5ba <printf+0x13a>
648: 66 90 xchg %ax,%ax
64a: 66 90 xchg %ax,%ax
64c: 66 90 xchg %ax,%ax
64e: 66 90 xchg %ax,%ax
00000650 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
650: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
651: a1 20 0b 00 00 mov 0xb20,%eax
{
656: 89 e5 mov %esp,%ebp
658: 57 push %edi
659: 56 push %esi
65a: 53 push %ebx
65b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
65e: 8d 4b f8 lea -0x8(%ebx),%ecx
661: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
668: 39 c8 cmp %ecx,%eax
66a: 8b 10 mov (%eax),%edx
66c: 73 32 jae 6a0 <free+0x50>
66e: 39 d1 cmp %edx,%ecx
670: 72 04 jb 676 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
672: 39 d0 cmp %edx,%eax
674: 72 32 jb 6a8 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
676: 8b 73 fc mov -0x4(%ebx),%esi
679: 8d 3c f1 lea (%ecx,%esi,8),%edi
67c: 39 fa cmp %edi,%edx
67e: 74 30 je 6b0 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
680: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
683: 8b 50 04 mov 0x4(%eax),%edx
686: 8d 34 d0 lea (%eax,%edx,8),%esi
689: 39 f1 cmp %esi,%ecx
68b: 74 3a je 6c7 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
68d: 89 08 mov %ecx,(%eax)
freep = p;
68f: a3 20 0b 00 00 mov %eax,0xb20
}
694: 5b pop %ebx
695: 5e pop %esi
696: 5f pop %edi
697: 5d pop %ebp
698: c3 ret
699: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6a0: 39 d0 cmp %edx,%eax
6a2: 72 04 jb 6a8 <free+0x58>
6a4: 39 d1 cmp %edx,%ecx
6a6: 72 ce jb 676 <free+0x26>
{
6a8: 89 d0 mov %edx,%eax
6aa: eb bc jmp 668 <free+0x18>
6ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
6b0: 03 72 04 add 0x4(%edx),%esi
6b3: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
6b6: 8b 10 mov (%eax),%edx
6b8: 8b 12 mov (%edx),%edx
6ba: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
6bd: 8b 50 04 mov 0x4(%eax),%edx
6c0: 8d 34 d0 lea (%eax,%edx,8),%esi
6c3: 39 f1 cmp %esi,%ecx
6c5: 75 c6 jne 68d <free+0x3d>
p->s.size += bp->s.size;
6c7: 03 53 fc add -0x4(%ebx),%edx
freep = p;
6ca: a3 20 0b 00 00 mov %eax,0xb20
p->s.size += bp->s.size;
6cf: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6d2: 8b 53 f8 mov -0x8(%ebx),%edx
6d5: 89 10 mov %edx,(%eax)
}
6d7: 5b pop %ebx
6d8: 5e pop %esi
6d9: 5f pop %edi
6da: 5d pop %ebp
6db: c3 ret
6dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000006e0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
6e0: 55 push %ebp
6e1: 89 e5 mov %esp,%ebp
6e3: 57 push %edi
6e4: 56 push %esi
6e5: 53 push %ebx
6e6: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6e9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
6ec: 8b 15 20 0b 00 00 mov 0xb20,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6f2: 8d 78 07 lea 0x7(%eax),%edi
6f5: c1 ef 03 shr $0x3,%edi
6f8: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
6fb: 85 d2 test %edx,%edx
6fd: 0f 84 9d 00 00 00 je 7a0 <malloc+0xc0>
703: 8b 02 mov (%edx),%eax
705: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
708: 39 cf cmp %ecx,%edi
70a: 76 6c jbe 778 <malloc+0x98>
70c: 81 ff 00 10 00 00 cmp $0x1000,%edi
712: bb 00 10 00 00 mov $0x1000,%ebx
717: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
71a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
721: eb 0e jmp 731 <malloc+0x51>
723: 90 nop
724: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
728: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
72a: 8b 48 04 mov 0x4(%eax),%ecx
72d: 39 f9 cmp %edi,%ecx
72f: 73 47 jae 778 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
731: 39 05 20 0b 00 00 cmp %eax,0xb20
737: 89 c2 mov %eax,%edx
739: 75 ed jne 728 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
73b: 83 ec 0c sub $0xc,%esp
73e: 56 push %esi
73f: e8 7e fc ff ff call 3c2 <sbrk>
if(p == (char*)-1)
744: 83 c4 10 add $0x10,%esp
747: 83 f8 ff cmp $0xffffffff,%eax
74a: 74 1c je 768 <malloc+0x88>
hp->s.size = nu;
74c: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
74f: 83 ec 0c sub $0xc,%esp
752: 83 c0 08 add $0x8,%eax
755: 50 push %eax
756: e8 f5 fe ff ff call 650 <free>
return freep;
75b: 8b 15 20 0b 00 00 mov 0xb20,%edx
if((p = morecore(nunits)) == 0)
761: 83 c4 10 add $0x10,%esp
764: 85 d2 test %edx,%edx
766: 75 c0 jne 728 <malloc+0x48>
return 0;
}
}
768: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
76b: 31 c0 xor %eax,%eax
}
76d: 5b pop %ebx
76e: 5e pop %esi
76f: 5f pop %edi
770: 5d pop %ebp
771: c3 ret
772: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
778: 39 cf cmp %ecx,%edi
77a: 74 54 je 7d0 <malloc+0xf0>
p->s.size -= nunits;
77c: 29 f9 sub %edi,%ecx
77e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
781: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
784: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
787: 89 15 20 0b 00 00 mov %edx,0xb20
}
78d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
790: 83 c0 08 add $0x8,%eax
}
793: 5b pop %ebx
794: 5e pop %esi
795: 5f pop %edi
796: 5d pop %ebp
797: c3 ret
798: 90 nop
799: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
7a0: c7 05 20 0b 00 00 24 movl $0xb24,0xb20
7a7: 0b 00 00
7aa: c7 05 24 0b 00 00 24 movl $0xb24,0xb24
7b1: 0b 00 00
base.s.size = 0;
7b4: b8 24 0b 00 00 mov $0xb24,%eax
7b9: c7 05 28 0b 00 00 00 movl $0x0,0xb28
7c0: 00 00 00
7c3: e9 44 ff ff ff jmp 70c <malloc+0x2c>
7c8: 90 nop
7c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
7d0: 8b 08 mov (%eax),%ecx
7d2: 89 0a mov %ecx,(%edx)
7d4: eb b1 jmp 787 <malloc+0xa7>
|
_tests/trkleene/t1.g4 | SKalt/Domemtech.Trash | 16 | 7748 | <filename>_tests/trkleene/t1.g4
grammar t1;
a : | 'a' a;
|
oeis/195/A195148.asm | neoneye/loda-programs | 11 | 176375 | <reponame>neoneye/loda-programs
; A195148: Concentric 20-gonal numbers.
; 0,1,20,41,80,121,180,241,320,401,500,601,720,841,980,1121,1280,1441,1620,1801,2000,2201,2420,2641,2880,3121,3380,3641,3920,4201,4500,4801,5120,5441,5780,6121,6480,6841,7220,7601,8000,8401,8820,9241,9680,10121,10580,11041,11520,12001,12500,13001,13520,14041,14580,15121,15680,16241,16820,17401,18000,18601,19220,19841,20480,21121,21780,22441,23120,23801,24500,25201,25920,26641,27380,28121,28880,29641,30420,31201,32000,32801,33620,34441,35280,36121,36980,37841,38720,39601,40500,41401,42320,43241
pow $0,2
mov $1,$0
div $0,2
mul $0,8
add $0,$1
|
oeis/168/A168372.asm | neoneye/loda-programs | 11 | 87466 | <filename>oeis/168/A168372.asm
; A168372: a(n) = n^5*(n^4 + 1)/2.
; 0,1,272,9963,131584,978125,5042736,20185207,67125248,193739769,500050000,1179054371,2580014592,5302435333,10330792304,19222059375,34360262656,59294648177,99180589968,161345086939,256001600000,397142065341,603637185712,900579548903,1320907751424,1907353515625,2714757780176,3812805916947,5289236581888,7253583243509,9841512150000,13219825394911,17592202821632,23205761768673,30358519100944,39407845596875,50780008567296,64980904569517,82608090249008,104364225691479,131072051200000,163691025125081
mov $1,$0
pow $0,5
pow $1,9
add $0,$1
div $0,2
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c4/c4a013a.ada | best08618/asylo | 7 | 25556 | -- C4A013A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT CONSTRAINT_ERROR IS RAISED FOR A NONSTATIC
-- UNIVERSAL_REAL EXPRESSION IF THE VALUE WOULD LIE OUTSIDE THE RANGE OF
-- THE BASE TYPE OF THE MOST ACCURATE PREDEFINED FLOATING POINT TYPE AND
-- MACHINE_OVERFLOWS IS TRUE FOR THAT TYPE.
-- *** NOTE: This test has been modified since ACVC version 1.11 to -- 9X
-- *** remove incompatibilities associated with the transition -- 9X
-- *** to Ada 9X. -- 9X
-- *** -- 9X
-- BAW 29 SEPT 80
-- TBN 10/30/85 RENAMED FROM C4A013A.ADA.
-- JRK 1/13/86 COMPLETELY REVISED TO CHECK NONSTATIC UNIVERSAL_REAL
-- EXPRESSIONS WHOSE RESULTS OVERFLOW. REVISED
-- NUMERIC_ERROR/CONSTRAINT_ERROR ACCORDING TO
-- AI-00387.
-- MRM 03/30/93 REMOVED NUMERIC_ERROR FOR 9X COMPATIBILITY
WITH SYSTEM, REPORT;
USE SYSTEM, REPORT;
PROCEDURE C4A013A IS
TYPE F IS DIGITS MAX_DIGITS;
B : BOOLEAN;
BEGIN
TEST ("C4A013A", "CHECK NONSTATIC UNIVERSAL_REAL EXPRESSIONS " &
"WHOSE RESULTS OVERFLOW");
BEGIN
B := 1.0 < 1.0 / (1.0 * INTEGER'POS (IDENT_INT (0)));
IF F'MACHINE_OVERFLOWS THEN
FAILED ("MACHINE_OVERFLOWS IS TRUE, BUT NO EXCEPTION " &
"WAS RAISED");
ELSE COMMENT ("MACHINE_OVERFLOWS IS FALSE AND NO EXCEPTION " &
"WAS RAISED");
END IF;
IF NOT B THEN -- USE B TO PREVENT DEAD VARIABLE OPTIMIZATION.
COMMENT ("1.0 < 1.0 / 0.0 YIELDS FALSE");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COMMENT ("CONSTRAINT_ERROR RAISED");
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED");
END;
RESULT;
END C4A013A;
|
test/Compiler/simple/CompilingQNamePats.agda | shlevy/agda | 1,989 | 16177 | <filename>test/Compiler/simple/CompilingQNamePats.agda
open import Common.Prelude
open import Common.Reflection
postulate
X Y : Set
isX : QName → Bool
isX (quote X) = true
isX _ = false
main : IO Unit
main = putStrLn ((if isX (quote X) then "yes" else "no") +S+
(if isX (quote Y) then "yes" else "no"))
|
exercises/ch4/num7.asm | gr0uch0dev/AssemblyExercisesAndNotes | 0 | 22236 | <reponame>gr0uch0dev/AssemblyExercisesAndNotes
;4.7
; Write a program with a loop and indirect addressing that copies a string from source to target,
; reversing the character order in the process. Use the following
.386
.model flat, STDCALL
ExitProcess PROTO, choice:DWORD
.data
source BYTE "This is the source string",0
lenSourceWithNull = ($ - source)
target BYTE SIZEOF source DUP('#')
.code
main PROC
mov ecx, lenSourceWithNull
dec ecx; remove 0
mov edx, OFFSET source
add edx, ecx
dec edx; edx starts from the last non null char and go backwards
mov ebx, OFFSET target
L1:
mov al, BYTE PTR [edx]
push eax; store in the stack
mov al, BYTE PTR[ebx]
mov BYTE PTR [edx], al
pop eax; the one we stored is in al
mov BYTE PTR[ebx], al
inc ebx
dec edx
loop L1
mov BYTE PTR[ebx], 0; add null char
push 0
call ExitProcess
main ENDP
end main
|
tools/scitools/conf/understand/ada/ada12/s-conca7.ads | brucegua/moocos | 1 | 11143 | <filename>tools/scitools/conf/understand/ada/ada12/s-conca7.ads
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . C O N C A T _ 7 --
-- --
-- S p e c --
-- --
-- Copyright (C) 2008-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains a procedure for runtime concatenation of seven string
-- operands. It is used when we want to save space in the generated code.
pragma Compiler_Unit;
package System.Concat_7 is
procedure Str_Concat_7
(R : out String;
S1, S2, S3, S4, S5, S6, S7 : String);
-- Performs the operation R := S1 & S2 & S3 & S4 & S5 & S6 & S7. The
-- bounds of R are known to be correct (usually set by a call to the
-- Str_Concat_Bounds_8 procedure below), so no bounds checks are required,
-- and it is known that none of the input operands overlaps R. No
-- assumptions can be made about the lower bounds of any of the operands.
procedure Str_Concat_Bounds_7
(Lo, Hi : out Natural;
S1, S2, S3, S4, S5, S6, S7 : String);
-- Assigns to Lo..Hi the bounds of the result of concatenating the seven
-- given strings, following the rules in the RM regarding null operands.
end System.Concat_7;
|
iod/con2/ptr/spcch.asm | olifink/smsqe | 0 | 21003 | ; General sprite cache V2.14 1999 <NAME>
; 2002 <NAME>
;
; 2001-06-29 2.01 Fixed severe bug in cache setup (MK)
; 2002-11-12 2.10 Added 24bit sprite routines (MK)
; 2002-12-15 2.11 Increase the support of sprite mode (JG)
; 2003-01-12 2.12 Added support for bigger sprites (MK)
; Added mode 33 support for QPC/QXL (MK)
; 2003-02-17 2.13 Moved sprite list scan to pt_fsprd (MK)
; 2003-02-21 2.14 Added RLE compression and Alpha channel support (MK)
; Moved generic code to ptr_spcch_asm (MK)
section driver
xdef pt_cchset
xdef pt_cchloc
xref.s pt.spmax
xref.s pt.blmax
xref.s pt.sppref
xref.s pt.spxsw
xref pt_fsprd
xref pt_derle
xref ptc_convert
xref ptc_pattern
xref ptc_mask
xref pt_sppref ; sprite preference table
xref pt_spnative ; and native mode
xref sp_zero
xref gu_achpp
xref gu_rchp
include 'dev8_keys_con'
include 'dev8_keys_qdos_pt'
include 'dev8_keys_qdos_sms'
include 'dev8_keys_sysspr'
;+++
; Sprite cache setup
;
; a3 c p pointer to pointer linkage
; a5 c p pointer to sprite cache
;
;---
pt_cchset
movem.l a1/a2,-(sp)
; the cache table has 16 byte entries
;
ptc_defn equ $00 ; long pointer to definition
ptc_native equ $04 ; long pointer to native version
ptc_tcache equ $08 ; long temporary cache pointer (for big sprites)
ptc_vcch equ $0c ; byte cache control version number
ptc_mcch equ $0e ; word cache control original mode ident
ptc.length equ $10
lea (a5),a1
lea 4*ptc.length(a5),a2
clr.l (a1)+
move.l a2,(a1)+
clr.l (a1)+
lea ptc.length-ptc_vcch(a1),a1
lea pt.spmax(a2),a2
clr.l (a1)+
move.l a2,(a1)+
clr.l (a1)+
lea ptc.length-ptc_vcch(a1),a1
lea pt.spmax(a2),a2
clr.l (a1)+
move.l a2,(a1)+
clr.l (a1)+
lea ptc.length-ptc_vcch(a1),a1
lea pt.blmax(a2),a2
clr.l (a1)+
move.l a2,(a1)+
clr.l (a1)+
movem.l (sp)+,a1/a2
moveq #0,d0
rts
;+++
; Sprite cache locate sprite
;
; d0 c s -ve pointer,
; 0 ordinary sprite (or pattern with mask!!!)
; 1 pattern
; 2 blob
; d2 r pointer to the correct form sprite
; a1 c r pointer to sprite type 0 / pointer to native mode sprite
; a3 c p pointer to pointer linkage
;
;---
pt_cchloc
ptcc.reg reg d1-d7/a0/a2-a6
stk_d2 equ 4
movem.l ptcc.reg,-(sp)
move.b d0,d7 ; mask of pattern / blob to convert
bne.s ptc_cchent ; ok, look for cache entry
moveq #3,d7 ; 0 is actually both
ptc_cchent
addq.w #1,d0
lsl.w #4,d0 ; 4 long word entries
move.l pt_spcch(a3),a5 ; sprite cache table
add.w d0,a5
move.l ptc_tcache(a5),d0 ; remove temp cache if any
beq.s ptc_fspr
move.l d0,a0
movem.l a1/a3,-(sp)
moveq #sms.rchp,d0
trap #1
movem.l (sp)+,a1/a3
clr.l ptc_tcache(a5) ; no temp cache anymore
ptc_fspr
jsr pt_fsprd ; find fitting sprite definition
move.l a1,stk_d2(sp) ; return this
sub.w #pt.sppref-1,d3 ; adjust for table (native = 0)
bne.s ptc_checkcache
move.b pto_ctrl(a1),d0 ; sprite control
andi.b #pto.cmp,d0 ; can sprite really be used directly?
beq ptc_retnative ; yes
ptc_checkcache
move.b pto_ctrl(a1),d0 ; sprite control
andi.b #pto.cver,d0 ; only get sprite cache version
cmp.b #pto.fupd,d0 ; force conversion?
beq.s ptc_index ; ... yes
cmp.l ptc_defn(a5),a1 ; object is cached?
bne.s ptc_index ; ... no, go ahead and convert
cmp.b ptc_vcch(a5),d0 ; ... is version the same?
bne.s ptc_index ; ... no
cmp.w ptc_mcch(a5),d5 ; ... is also converted mode the same ?
beq ptc_retcch ; ... yes
ptc_index
move.l a1,ptc_defn(a5) ; save address
move.b d0,ptc_vcch(a5) ; set version
move.w d5,ptc_mcch(a5) ; set original mode
add.w d3,d3 ; index convert code
move.l ptc_native(a5),a0 ; cache entry address
lea pto.hdrl(a0),a4 ; start of data
move.l (a1)+,d0
move.w pt_spnative,(a0)+
move.w d0,(a0)+
moveq #0,d1
moveq #0,d2
move.w (a1)+,d1 ; x size
move.w (a1)+,d2 ; y size
move.w d1,(a0)+
move.w d2,(a0)+
move.w d1,d0
or.w d2,d0
lsr.w #6,d0 ; big sprite?
beq.s ptc_setorg
move.l d1,d0
addq.w #1,d0
bclr #0,d0
mulu d2,d0
cmp.l #pt.spspx*pt.spspy,d0 ; giant sprite?
ble.s ptc_setorg
clr.l ptc_defn(a5) ; ... yes, do not cache
move.w #pt.spxsw,d4
lsl.l d4,d0 ; and try to allocate mem on the fly
cmp.b #3,d7 ; if sprite we need twice as much mem
bne.s ptc_notempspr
add.l d0,d0
ptc_notempspr
move.l a0,a4
jsr gu_achpp
exg a4,a0 ; a4 is now new start of data
beq.s ptc_tempcache
lea sp_zero(pc),a1 ; couldn't allocate mem, do not draw
bra ptc_fspr
ptc_tempcache
move.l a4,ptc_tcache(a5) ; save temporary cache address
ptc_setorg
move.l (a1)+,(a0)+ ; origin
move.w d3,-(sp)
bsr.s ptc_setpattern
move.w (sp)+,d3
bsr.s ptc_setmask
clr.l (a0)+ ; ... no next
ptc_retcch
move.l ptc_native(a5),a1 ; native mode object is here
ptc_retnative
movem.l (sp)+,ptcc.reg
moveq #0,d0
rts
ptc_nofill
addq.l #4,a1 ; skip in source
ptc_nodata
clr.l (a0)+ ; no data
rts
; Get a valid mask. Also handle alpha channel correctly
ptc_setmask
asr.b #1,d7 ; fill this bit?
bcc.s ptc_nofill
lea ptc_mask(pc),a6
move.w (a6,d3.w),d4 ; routine to use
move.l a1,a2
move.l (a1)+,d0 ; original data offset
beq.s ptc_nodata
add.l d0,a2 ; make absolute
move.b pto_ctrl-pto_nobj(a1),d0
andi.b #pto.mcmp,d0 ; d0 > 0 = mask compressed
btst #pto..alph,pto_ctrl-pto_nobj(a1) ; is it an alpha channel?
beq.s pst_noalpha
tst.b d0 ; data compressed?
beq.s pst_directa ; no, use it directly
move.l a4,a6
jsr pt_derle ; decompress into cache
move.l a4,a2
pst_directa
sub.l a0,a2 ; make relative
move.l a2,(a0)+ ; set pointer to data
rts
; This is like ptc_setmask, we just don't need to check for an alpha channel.
ptc_setpattern
asr.b #1,d7 ; fill this bit?
bcc.s ptc_nofill
lea ptc_pattern(pc),a6
move.w (a6,d3.w),d4 ; routine to use
move.l a1,a2
move.l (a1)+,d0 ; original data offset
beq.s ptc_nodata
add.l d0,a2 ; make absolute
move.b pto_ctrl-pto_mask(a1),d0
andi.b #pto.pcmp,d0 ; d0 > 0 = pattern compressed
pst_noalpha
tst.b d0 ; data compressed?
beq.s pst_norle ; ...no
tst.w d3 ; native mode sprite?
beq.s pst_native ; yes, decompress into cache
suba.l a6,a6 ; allocate buffer for conversion
jsr pt_derle ; decompress RLE
move.l a6,a2 ; new buffer as source for conversion
bsr.s psc_convert
move.l a0,-(sp)
move.l a6,a0
jsr gu_rchp ; release RLE buffer
move.l (sp)+,a0
rts
pst_native
move.l a4,a6
jsr pt_derle ; decompress into cache
move.l a4,a2
add.l d0,a4 ; update cache pointer
pst_direct
sub.l a0,a2 ; make relative
move.l a2,(a0)+ ; set pointer to data
rts
pst_norle
tst.w d3 ; native mode sprite?
beq.s pst_direct ; yes, use source directly
psc_convert
move.l a4,d0 ; address of data
sub.l a0,d0
move.l d0,(a0)+ ; offset to data
jmp ptc_convert(pc,d4.w)
end
|
runtime/ravenscar-sfp-stm32f427/gnarl-common/a-retide.adb | TUM-EI-RCS/StratoX | 12 | 12230 | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . R E A L _ T I M E . D E L A Y S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2010, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
with System.Task_Primitives.Operations;
-- Used for Timed_Delay
-- Self
package body Ada.Real_Time.Delays is
package STPO renames System.Task_Primitives.Operations;
-----------------
-- Delay_Until --
-----------------
procedure Delay_Until (T : Time) is
begin
-- pragma Detect_Blocking is mandatory in this run time, so that
-- Program_Error must be raised if this delay (potentially blocking
-- operation) is called from a protected operation.
if STPO.Self.Common.Protected_Action_Nesting > 0 then
raise Program_Error;
else
STPO.Delay_Until (STPO.Time (T));
end if;
end Delay_Until;
-----------------
-- To_Duration --
-----------------
-- This function is not supposed to be used by the Ravenscar run time and
-- it is not supposed to be with'ed by the user either (because it is an
-- internal GNAT unit). It is kept here (returning a junk value) just for
-- sharing the same package specification with the regular run time.
function To_Duration (T : Time) return Duration is
pragma Unreferenced (T);
begin
return 0.0;
end To_Duration;
end Ada.Real_Time.Delays;
|
bad_lunch.adb | charlesincharge/Intro_to_Ada | 0 | 28027 | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Exceptions; use Ada.Exceptions;
procedure Bad_Lunch is
-- Enumeration type
type Lunch_Spot_t is (WS, Nine, Home);
type Day_t is (Sun, Mon, Tue, Wed, Thu, Fri, Sat);
-- Subtype Weekday_t is a constrained Day_t
subtype Weekday_t is Day_t range Mon .. Fri;
-- Declaring a fixed-size array
Where_To_Eat : array(Weekday_t) of Lunch_Spot_t;
begin
-- Array is the same size as number of Day_t values
Where_To_Eat := (Nine, WS, Nine, WS, Nine);
-- Can loop over a fixed-size array, or over a type/subtype itself
for Day in Day_t loop
case Where_To_Eat (Day) is
when Home =>
Put_Line("Eating at home.");
when Nine =>
Put_Line("Eating on 9.");
when WS =>
Put_Line("Eating at Wise Sons");
-- case statement must include all cases
end case;
end loop;
exception
when Error : Constraint_Error =>
Put_Line("It's the weekend, no lunch at Square.");
Put_Line(Exception_Information(Error));
end Bad_Lunch;
|
middleware/src/filesystem/filesystem-fat.ads | rocher/Ada_Drivers_Library | 192 | 15301 | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2019, 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 packages provide a low level driver for the FAT file system
-- architecture. It is recommended to _not_ use this interface directly but to
-- access the file system using the File_IO package. For more info, see the
-- file system chapter of the documentation.
with System;
with Interfaces; use Interfaces;
with HAL; use HAL;
with HAL.Block_Drivers; use HAL.Block_Drivers;
with HAL.Filesystem; use HAL.Filesystem;
package Filesystem.FAT is
MAX_VOLUMES : constant := 1;
-- Maximum number of mounted volumes
MAX_FILENAME_LENGTH : constant := 255;
-- Maximum size of a file or directory name
MAX_FILE_HANDLES : constant := 10;
-- Maximum number of handles opened simultaneously.
MAX_DIR_HANDLES : constant := 10;
-- Maximum number of handles opened simultaneously.
type FAT_Name is private;
type FAT_Filesystem is limited new Filesystem_Driver with private;
type FAT_Filesystem_Access is access all FAT_Filesystem;
type FAT_Node is new Node_Handle with private;
-----------------------
-- PATH MANIPULATION --
-----------------------
function "-" (Name : FAT_Name) return String;
function "-" (Name : String) return FAT_Name
with Pre => Name'Length < MAX_FILENAME_LENGTH;
overriding function "=" (Name1, Name2 : FAT_Name) return Boolean;
function Is_Root (Path : String) return Boolean with Inline_Always;
function Parent (Path : String) return String;
function Basename (Path : String) return String;
function Normalize (Path : String;
Ensure_Dir : Boolean := False) return String;
------------------------
-- DIRECTORY HANDLING --
------------------------
overriding function Open
(FS : in out FAT_Filesystem;
Path : String;
Handle : out Any_Directory_Handle) return Status_Code;
overriding function Root_Node
(FS : in out FAT_Filesystem;
As : String;
Handle : out Any_Node_Handle)
return Status_Code;
function Long_Name (E : FAT_Node) return FAT_Name;
function Short_Name (E : FAT_Node) return FAT_Name;
overriding function Basename (E : FAT_Node) return String;
overriding function Is_Read_Only (E : FAT_Node) return Boolean;
overriding function Is_Hidden (E : FAT_Node) return Boolean;
function Is_System_File (E : FAT_Node) return Boolean;
overriding function Is_Symlink (E : FAT_Node) return Boolean;
overriding function Is_Subdirectory
(E : FAT_Node) return Boolean;
function Is_Archive (E : FAT_Node) return Boolean;
overriding function Size (E : FAT_Node) return File_Size;
overriding procedure Close (E : in out FAT_Node);
overriding function Get_FS
(E : FAT_Node) return Any_Filesystem_Driver;
-------------------
-- FILE HANDLING --
-------------------
overriding function Open
(FS : in out FAT_Filesystem;
Path : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code;
overriding function Open
(Parent : FAT_Node;
Name : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code
with Pre => Name'Length <= MAX_FILENAME_LENGTH;
--------------------
-- FAT FILESYSTEM --
--------------------
function Open
(Controller : HAL.Block_Drivers.Any_Block_Driver;
LBA : Block_Number;
FS : in out FAT_Filesystem)
return Status_Code;
-- Opens a FAT partition at the given LBA
overriding procedure Close (FS : in out FAT_Filesystem);
-----------------------
-- FAT FS PROPERTIES --
-----------------------
type FAT_Version is
(FAT16,
FAT32);
function Version (FS : FAT_Filesystem) return FAT_Version;
-- The FAT version of the volume
function OEM_Name (FS : FAT_Filesystem) return String;
-- The OEM Name of the Volume. Different from the Volume Label.
function Is_Volume
(FS : FAT_Filesystem) return Boolean;
function Volume_ID
(FS : FAT_Filesystem) return Unsigned_32;
function Volume_Label
(FS : FAT_Filesystem) return String;
function File_System_Type
(FS : FAT_Filesystem) return String;
private
type Cluster_Type is new Interfaces.Unsigned_32;
subtype Valid_Cluster is Cluster_Type range 2 .. 16#0FFF_FFFF#;
type Block_Offset is new Interfaces.Unsigned_32;
type FAT_File_Size is new Interfaces.Unsigned_32;
-- FAT Filesystem does not support files >= 4GB (e.g. 2**32)
INVALID_CLUSTER : constant Cluster_Type := 0;
FREE_CLUSTER_VALUE : constant Cluster_Type := 16#0000_0000#;
LAST_CLUSTER_VALUE : constant Cluster_Type := 16#0FFF_FFFF#;
BAD_CLUSTER_VALUE : constant Cluster_Type := 16#0FFF_FFF7#;
function Get_Start_Cluster
(E : FAT_Node) return Cluster_Type;
function Size (E : FAT_Node) return FAT_File_Size;
function Block_Size
(FS : FAT_Filesystem) return FAT_File_Size;
function Blocks_Per_Cluster
(FS : FAT_Filesystem) return Block_Offset;
function Cluster_Size
(FS : FAT_Filesystem) return FAT_File_Size;
function Reserved_Blocks
(FS : FAT_Filesystem) return Unsigned_16;
function Number_Of_FATs
(FS : FAT_Filesystem) return Unsigned_8;
function Total_Number_Of_Blocks
(FS : FAT_Filesystem) return Unsigned_32;
function FAT_Table_Size_In_Blocks
(FS : FAT_Filesystem) return Unsigned_32;
function Number_Of_Hidden_Blocks
(FS : FAT_Filesystem) return Unsigned_32;
function Root_Dir_Cluster
(FS : FAT_Filesystem) return Cluster_Type;
function FAT16_Root_Dir_Num_Entries
(FS : FAT_Filesystem) return Unsigned_16;
function Flags_For_FAT_Mirroring
(FS : FAT_Filesystem) return Unsigned_16
with Pre => Version (FS) = FAT32;
function FS_Version_Number
(FS : FAT_Filesystem) return Unsigned_16
with Pre => Version (FS) = FAT32;
function FSInfo_Block_Number
(FS : FAT_Filesystem) return Unsigned_16
with Pre => Version (FS) = FAT32;
function Boot_Block_Backup_Block_Number
(FS : FAT_Filesystem) return Unsigned_16
with Pre => Version (FS) = FAT32;
function Last_Known_Free_Data_Clusters_Number
(FS : FAT_Filesystem) return Unsigned_32
with Pre => Version (FS) = FAT32;
function Most_Recently_Allocated_Cluster
(FS : FAT_Filesystem) return Cluster_Type
with Pre => Version (FS) = FAT32;
type FAT_Name is record
Name : String (1 .. MAX_FILENAME_LENGTH);
Len : Natural := 0;
end record;
type FAT_Disk_Parameter is record
OEM_Name : String (1 .. 8);
Block_Size_In_Bytes : Unsigned_16;
Blocks_Per_Cluster : Unsigned_8;
Reserved_Blocks : Unsigned_16;
Number_Of_FATs : Unsigned_8;
Root_Dir_Entries_Fat16 : Unsigned_16;
Number_Of_Blocks_Fat16 : Unsigned_16;
Removable_Drive : Boolean;
Table_Size_Fat16 : Unsigned_16;
Blocks_Per_Cylinder : Unsigned_16;
Number_Of_Heads : Unsigned_16;
Hidden_Blocks : Unsigned_32;
Number_Of_Blocks_Fat32 : Unsigned_32;
Table_Size_Fat32 : Unsigned_32;
Fat_Mirroring_Flags : Unsigned_16;
FS_Version_Number : Unsigned_16;
Root_Directory_Cluster : Cluster_Type;
FSInfo_Block_Number : Unsigned_16;
Boot_Block_Backup_Block : Unsigned_16;
Drive_Number_Fat32 : Unsigned_8;
Current_Head_Fat32 : Unsigned_8;
Boot_Signature_Fat32 : Unsigned_8;
Volume_Id_Fat32 : Unsigned_32;
Volume_Label_Fat32 : String (1 .. 11);
FS_Type_Fat32 : String (1 .. 8);
end record with Size => 92 * 8;
for FAT_Disk_Parameter use record
OEM_Name at 16#03# range 0 .. 63;
Block_Size_In_Bytes at 16#0B# range 0 .. 15;
Blocks_Per_Cluster at 16#0D# range 0 .. 7;
Reserved_Blocks at 16#0E# range 0 .. 15;
Number_Of_FATs at 16#10# range 0 .. 7;
Root_Dir_Entries_Fat16 at 16#11# range 0 .. 15;
Number_Of_Blocks_Fat16 at 16#13# range 0 .. 15;
Removable_Drive at 16#15# range 2 .. 2;
Table_Size_Fat16 at 16#16# range 0 .. 15;
Blocks_Per_Cylinder at 16#18# range 0 .. 15;
Number_Of_Heads at 16#1A# range 0 .. 15;
Hidden_Blocks at 16#1C# range 0 .. 31;
Number_Of_Blocks_Fat32 at 16#20# range 0 .. 31;
Table_Size_Fat32 at 16#24# range 0 .. 31;
Fat_Mirroring_Flags at 16#28# range 0 .. 15;
FS_Version_Number at 16#2A# range 0 .. 15;
Root_Directory_Cluster at 16#2C# range 0 .. 31;
FSInfo_Block_Number at 16#30# range 0 .. 15;
Boot_Block_Backup_Block at 16#32# range 0 .. 15;
Drive_Number_Fat32 at 16#40# range 0 .. 7;
Current_Head_Fat32 at 16#41# range 0 .. 7;
Boot_Signature_Fat32 at 16#42# range 0 .. 7;
Volume_Id_Fat32 at 16#43# range 0 .. 31;
Volume_Label_Fat32 at 16#47# range 0 .. 87;
FS_Type_Fat32 at 16#52# range 0 .. 63;
end record;
function Trim (S : String) return String;
type FAT_FS_Info is record
Signature : String (1 .. 4);
Free_Clusters : Unsigned_32;
Last_Allocated_Cluster : Cluster_Type;
end record;
for FAT_FS_Info use record
Signature at 0 range 0 .. 31;
Free_Clusters at 4 range 0 .. 31;
Last_Allocated_Cluster at 8 range 0 .. 31;
end record;
type FAT_Filesystem is limited new Filesystem_Driver with record
Initialized : Boolean := False;
Disk_Parameters : FAT_Disk_Parameter;
LBA : Block_Number;
Controller : Any_Block_Driver;
FSInfo : FAT_FS_Info;
FSInfo_Changed : Boolean := False;
Root_Dir_Area : Block_Offset := 0;
Data_Area : Block_Offset; -- address to the data area, rel. to LBA
FAT_Addr : Block_Offset; -- address to the FAT table, rel. to LBA
Num_Clusters : Cluster_Type;
Window_Block : Block_Offset := Block_Offset'Last;
Window : Block (0 .. 511);
FAT_Block : Block_Offset := Block_Offset'Last;
FAT_Window : Block (0 .. 511);
Root_Entry : aliased FAT_Node;
end record;
function Ensure_Block
(FS : in out FAT_Filesystem;
Block : Block_Offset)
return Status_Code;
-- Ensures the block is visible within the FS window.
-- Block_Base_OFfset returns the index within the FS window of the block
function Write_Window (FS : in out FAT_Filesystem)
return Status_Code;
function Cluster_To_Block
(FS : FAT_Filesystem;
Cluster : Cluster_Type) return Block_Offset
is (FS.Data_Area + Block_Offset (Cluster - 2) * FS.Blocks_Per_Cluster);
function "+" (Base : Block_Number;
Off : Block_Offset) return Block_Number
is (Base + Block_Number (Off));
function Get_FAT
(FS : in out FAT_Filesystem;
Cluster : Cluster_Type) return Cluster_Type;
function Set_FAT
(FS : in out FAT_Filesystem;
Cluster : Cluster_Type;
Value : Cluster_Type)
return Status_Code;
function Get_Free_Cluster
(FS : in out FAT_Filesystem;
Previous : Cluster_Type := INVALID_CLUSTER) return Cluster_Type;
-- Retrieve a free cluster from the filesystem.
-- Returns INVALID_CLUSTER in case the filesystem is full.
procedure Write_FSInfo
(FS : in out FAT_Filesystem);
-- Writes back the FSInfo structure on the Filesystem
function Is_Last_Cluster
(FS : FAT_Filesystem;
Ent : Cluster_Type) return Boolean
is (case Version (FS) is
when FAT16 => (Ent and 16#FFF8#) = 16#FFF8#,
when FAT32 => (Ent and 16#0FFF_FFF8#) = 16#0FFF_FFF8#);
-- return true if this is the last cluster for an entry
function Is_Reserved_Cluster
(FS : FAT_Filesystem;
Ent : Cluster_Type) return Boolean
is (case Version (FS) is
when FAT16 => Ent > FS.Num_Clusters and Ent <= 16#FFF6#,
when FAT32 => Ent > FS.Num_Clusters and Ent <= 16#0FFF_FFF6#);
-- return true if this cluster is reserved
function Is_Bad_Cluster
(FS : FAT_Filesystem;
Ent : Cluster_Type) return Boolean
is (case Version (FS) is
when FAT16 => (Ent and 16#FFF7#) = 16#FFF7#,
when FAT32 => (Ent and 16#FFFF_FFF7#) = 16#FFFF_FFF7#);
-- return true if this cluster is defective
function Is_Free_Cluster
(FS : FAT_Filesystem;
Ent : Cluster_Type) return Boolean
is ((Ent and 16#0FFF_FFFF#) = FREE_CLUSTER_VALUE);
-- return true if the FAT entry indicates the cluster being unused
function New_Cluster
(FS : in out FAT_Filesystem) return Cluster_Type;
function New_Cluster
(FS : in out FAT_Filesystem;
Previous : Cluster_Type) return Cluster_Type;
type Entry_Index is new Unsigned_16;
Null_Index : Entry_Index := 16#FFFF#;
type FAT_Directory_Handle is limited new Directory_Handle with record
Is_Free : Boolean := True;
FS : FAT_Filesystem_Access;
Current_Index : Entry_Index;
Start_Cluster : Cluster_Type;
Current_Cluster : Cluster_Type;
Current_Block : Block_Offset;
Current_Node : aliased FAT_Node;
end record;
type FAT_Directory_Handle_Access is access all FAT_Directory_Handle;
type Any_FAT_Directory_Handle is access all FAT_Directory_Handle'Class;
overriding function Get_FS
(Dir : FAT_Directory_Handle) return Any_Filesystem_Driver;
overriding function Read
(Dir : in out FAT_Directory_Handle;
Handle : out Any_Node_Handle)
return Status_Code;
overriding procedure Reset (Dir : in out FAT_Directory_Handle);
overriding procedure Close (Dir : in out FAT_Directory_Handle);
overriding
function Create_File (This : in out FAT_Filesystem;
Path : String)
return Status_Code;
overriding
function Unlink (This : in out FAT_Filesystem;
Path : String)
return Status_Code;
overriding
function Remove_Directory (This : in out FAT_Filesystem;
Path : String)
return Status_Code;
function FAT_Open
(FS : in out FAT_Filesystem;
Path : String;
Handle : out FAT_Directory_Handle_Access)
return Status_Code;
function FAT_Open
(D_Entry : FAT_Node;
Handle : out FAT_Directory_Handle_Access)
return Status_Code;
type FAT_Directory_Entry_Attribute is record
Read_Only : Boolean;
Hidden : Boolean;
System_File : Boolean;
Volume_Label : Boolean;
Subdirectory : Boolean;
Archive : Boolean;
end record with Size => 8, Pack;
type FAT_Node is new Node_Handle with record
FS : FAT_Filesystem_Access;
L_Name : FAT_Name;
S_Name : String (1 .. 8);
S_Name_Ext : String (1 .. 3);
Attributes : FAT_Directory_Entry_Attribute;
Start_Cluster : Cluster_Type; -- The content of this entry
Size : FAT_File_Size;
Index : Entry_Index;
-- Index of the FAT_Directory_Intry within Parent's content
Is_Root : Boolean := False;
-- Is it the root directory ?
Is_Dirty : Boolean := False;
-- Whether changes need to be written on disk
end record;
type FAT_File_Handle is limited new File_Handle with record
Is_Free : Boolean := True;
FS : FAT_Filesystem_Access;
Mode : File_Mode;
-- The current cluster from which we read or write
Current_Cluster : Cluster_Type := 0;
-- The current block from which we read or write, offset from
-- current_cluster base block
Current_Block : Block_Offset := 0;
-- Buffer with the content of the current block
Buffer : Block (0 .. 511);
-- How much data in Buffer is meaningful
Buffer_Filled : Boolean := False;
-- Whether there's a discrepency between the disk data and the buffer
Buffer_Dirty : Boolean := False;
-- The actual file index
File_Index : FAT_File_Size := 0;
-- The associated directory entry
D_Entry : FAT_Node;
-- The parent's directory directory entry
Parent : FAT_Node;
end record;
type FAT_File_Handle_Access is access all FAT_File_Handle;
overriding function Get_FS
(File : in out FAT_File_Handle) return Any_Filesystem_Driver;
overriding function Size (File : FAT_File_Handle)
return File_Size;
overriding function Mode (File : FAT_File_Handle)
return File_Mode;
overriding function Read
(File : in out FAT_File_Handle;
Addr : System.Address;
Length : in out File_Size)
return Status_Code;
-- read data from file.
-- @return number of bytes read (at most Data'Length), or -1 on error.
overriding function Offset
(File : FAT_File_Handle)
return File_Size;
-- Current index within the file
overriding function Write
(File : in out FAT_File_Handle;
Addr : System.Address;
Length : File_Size)
return Status_Code;
-- write to file
-- @return number of bytes written (at most Data'Length), or -1 on error.
overriding function Flush
(File : in out FAT_File_Handle)
return Status_Code;
-- force writing file to disk at this very moment (slow!)
overriding function Seek
(File : in out FAT_File_Handle;
Origin : Seek_Mode;
Amount : in out File_Size)
return Status_Code;
-- Moves the current file position to "Amount", according to the Origin
-- parameter. If the command makes the file pointer move outside of the
-- file, it stops at the file boundary and returns the actual amount of
-- bytes moved.
overriding procedure Close (File : in out FAT_File_Handle);
-- invalidates the handle, and ensures that
-- everything is flushed to the disk
-- Type definition for implementation details, make them visible to all
-- children of the package
type FAT_Directory_Entry is record
Filename : String (1 .. 8);
Extension : String (1 .. 3);
Attributes : FAT_Directory_Entry_Attribute;
Reserved : String (1 .. 8);
Cluster_H : Unsigned_16;
Time : Unsigned_16;
Date : Unsigned_16;
Cluster_L : Unsigned_16;
Size : FAT_File_Size;
end record with Size => 32 * 8;
for FAT_Directory_Entry use record
Filename at 16#00# range 0 .. 63;
Extension at 16#08# range 0 .. 23;
Attributes at 16#0B# range 0 .. 7;
Reserved at 16#0C# range 0 .. 63;
Cluster_H at 16#14# range 0 .. 15;
Time at 16#16# range 0 .. 15;
Date at 16#18# range 0 .. 15;
Cluster_L at 16#1A# range 0 .. 15;
Size at 16#1C# range 0 .. 31;
end record;
VFAT_Directory_Entry_Attribute : constant FAT_Directory_Entry_Attribute :=
(Subdirectory => False,
Archive => False,
others => True);
-- Attrite value 16#F0# defined at offset 16#0B# and identifying a VFAT
-- entry rather than a regular directory entry
type VFAT_Sequence_Number is mod 2 ** 6
with Size => 6;
type VFAT_Sequence is record
Sequence : VFAT_Sequence_Number;
Stop_Bit : Boolean;
end record with Size => 8;
for VFAT_Sequence use record
Sequence at 0 range 0 .. 5;
Stop_Bit at 0 range 6 .. 7;
end record;
type VFAT_Directory_Entry is record
VFAT_Attr : VFAT_Sequence;
Name_1 : Wide_String (1 .. 5);
Attribute : FAT_Directory_Entry_Attribute;
Reserved : Unsigned_8 := 0;
Checksum : Unsigned_8;
Name_2 : Wide_String (1 .. 6);
Cluster : Unsigned_16 := 0;
Name_3 : Wide_String (1 .. 2);
end record with Pack, Size => 32 * 8;
--------------------------------------------------
-- Inlined implementations of utility functions --
--------------------------------------------------
function Version
(FS : FAT_Filesystem) return FAT_Version
is (if FS.Disk_Parameters.Root_Dir_Entries_Fat16 /= 0
then FAT16 else FAT32);
function OEM_Name (FS : FAT_Filesystem) return String
is (FS.Disk_Parameters.OEM_Name);
function Block_Size
(FS : FAT_Filesystem) return FAT_File_Size
is (FAT_File_Size (FS.Disk_Parameters.Block_Size_In_Bytes));
function Blocks_Per_Cluster
(FS : FAT_Filesystem) return Block_Offset
is (Block_Offset (FS.Disk_Parameters.Blocks_Per_Cluster));
function Cluster_Size
(FS : FAT_Filesystem) return FAT_File_Size
is (FAT_File_Size (FS.Blocks_Per_Cluster) * FS.Block_Size);
function Reserved_Blocks
(FS : FAT_Filesystem) return Unsigned_16
is (FS.Disk_Parameters.Reserved_Blocks);
function Number_Of_FATs
(FS : FAT_Filesystem) return Unsigned_8
is (FS.Disk_Parameters.Number_Of_FATs);
function Total_Number_Of_Blocks
(FS : FAT_Filesystem) return Unsigned_32
is (FS.Disk_Parameters.Number_Of_Blocks_Fat32);
function FAT_Table_Size_In_Blocks
(FS : FAT_Filesystem) return Unsigned_32
is ((if FS.Version = FAT16
then Unsigned_32 (FS.Disk_Parameters.Table_Size_Fat16)
else FS.Disk_Parameters.Table_Size_Fat32));
function Number_Of_Hidden_Blocks
(FS : FAT_Filesystem) return Unsigned_32
is (FS.Disk_Parameters.Hidden_Blocks);
function Is_Volume
(FS : FAT_Filesystem) return Boolean
is (FS.Disk_Parameters.Boot_Signature_Fat32 = 16#29#);
function Volume_ID
(FS : FAT_Filesystem) return Unsigned_32
is (if not Is_Volume (FS)
then 0
else FS.Disk_Parameters.Volume_Id_Fat32);
function Volume_Label
(FS : FAT_Filesystem) return String
is (if FS.Version = FAT16 then "UNKNOWN"
elsif not Is_Volume (FS)
then "UNKNOWN"
else Trim (FS.Disk_Parameters.Volume_Label_Fat32));
function File_System_Type
(FS : FAT_Filesystem) return String
is (if FS.Version = FAT16 then "FAT16"
elsif not Is_Volume (FS) then "FAT32"
else Trim (FS.Disk_Parameters.FS_Type_Fat32));
function Flags_For_FAT_Mirroring
(FS : FAT_Filesystem) return Unsigned_16
is (FS.Disk_Parameters.Fat_Mirroring_Flags);
function FS_Version_Number
(FS : FAT_Filesystem) return Unsigned_16
is (FS.Disk_Parameters.FS_Version_Number);
function Root_Dir_Cluster
(FS : FAT_Filesystem) return Cluster_Type
is (FS.Disk_Parameters.Root_Directory_Cluster);
function FAT16_Root_Dir_Num_Entries
(FS : FAT_Filesystem) return Unsigned_16
is (FS.Disk_Parameters.Root_Dir_Entries_Fat16);
function FSInfo_Block_Number
(FS : FAT_Filesystem) return Unsigned_16
is (FS.Disk_Parameters.FSInfo_Block_Number);
function Boot_Block_Backup_Block_Number
(FS : FAT_Filesystem) return Unsigned_16
is (FS.Disk_Parameters.Boot_Block_Backup_Block);
function Last_Known_Free_Data_Clusters_Number
(FS : FAT_Filesystem) return Unsigned_32
is (FS.FSInfo.Free_Clusters);
function Most_Recently_Allocated_Cluster
(FS : FAT_Filesystem) return Cluster_Type
is (FS.FSInfo.Last_Allocated_Cluster);
function Get_Num_VFAT_Entries (Name : FAT_Name) return Natural
is ((Name.Len + 12) / 13);
-- Returns the number of VFAT Entries needed to encode 'Name'
-- There's 13 characters in each entry, and we need Name.Len + 2 characters
-- for the trailing ASCII.NUL + 0xFFFF sequence.
overriding function Get_FS
(Dir : FAT_Directory_Handle) return Any_Filesystem_Driver
is (Any_Filesystem_Driver (Dir.FS));
overriding function Get_FS
(File : in out FAT_File_Handle) return Any_Filesystem_Driver
is (Any_Filesystem_Driver (File.FS));
overriding function Get_FS (E : FAT_Node) return Any_Filesystem_Driver
is (Any_Filesystem_Driver (E.FS));
function Long_Name (E : FAT_Node) return FAT_Name
is (if E.L_Name.Len > 0 then E.L_Name else Short_Name (E));
function Short_Name (E : FAT_Node) return FAT_Name
is (-(Trim (E.S_Name) &
(if E.S_Name_Ext /= " "
then "." & E.S_Name_Ext
else "")));
overriding function Basename (E : FAT_Node) return String
is (-E.Long_Name);
overriding function Is_Read_Only (E : FAT_Node) return Boolean
is (E.Attributes.Read_Only);
overriding function Is_Hidden (E : FAT_Node) return Boolean
is (E.Attributes.Hidden);
function Is_System_File (E : FAT_Node) return Boolean
is (E.Attributes.System_File);
overriding function Is_Subdirectory (E : FAT_Node) return Boolean
is (E.Attributes.Subdirectory);
function Is_Archive (E : FAT_Node) return Boolean
is (E.Attributes.Archive);
function Get_Start_Cluster (E : FAT_Node) return Cluster_Type
is (E.Start_Cluster);
function Size (E : FAT_Node) return FAT_File_Size
is (E.Size);
overriding function Is_Symlink (E : FAT_Node) return Boolean
is (False);
end Filesystem.FAT;
|
src/LibraBFT/Impl/Consensus/ConsensusTypes/VoteData.agda | LaudateCorpus1/bft-consensus-agda | 0 | 14254 | {- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.Impl.OBM.Logging.Logging
open import Optics.All
open import Util.Prelude
module LibraBFT.Impl.Consensus.ConsensusTypes.VoteData where
verify : VoteData → Either ErrLog Unit
verify self = do
lcheck (self ^∙ vdParent ∙ biEpoch == self ^∙ vdProposed ∙ biEpoch)
("parent and proposed epochs do not match" ∷ [])
lcheck (⌊ self ^∙ vdParent ∙ biRound <? self ^∙ vdProposed ∙ biRound ⌋)
("proposed round is less than parent round" ∷ [])
-- lcheck (self^.vdParent.biTimestamp <= self^.vdProposed.biTimestamp)
-- ["proposed happened before parent"]
lcheck (⌊ (self ^∙ vdParent ∙ biVersion) ≤?-Version (self ^∙ vdProposed ∙ biVersion) ⌋)
("proposed version is less than parent version" ∷ [])
-- , lsVersion (self^.vdProposed.biVersion), lsVersion (self^.vdParent.biVersion)]
new : BlockInfo → BlockInfo → VoteData
new = VoteData∙new
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.