content
stringlengths
23
1.05M
with GDNative; use GDNative; with GDNative.Thin; package Engine_Hooks is procedure On_GDNative_Init (p_options : access Thin.godot_gdnative_init_options) with Export => True, Convention => C, External_Name => "adventure_gdnative_init"; procedure On_GDNative_Terminate (p_options : access Thin.godot_gdnative_terminate_options) with Export => True, Convention => C, External_Name => "adventure_gdnative_terminate"; procedure On_Nativescript_Init (p_handle : Thin.Nativescript_Handle) with Export => True, Convention => C, External_Name => "adventure_nativescript_init"; end;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" package Glfw.Input.Mouse is type Button is new Interfaces.C.int range 0 .. 7; type Enter_Action is (Leaving, Entering); type Cursor_Mode is (Normal, Hidden, Disabled); Left_Button : constant := 0; Right_Button : constant := 1; Middle_Button : constant := 2; subtype Coordinate is Interfaces.C.double; subtype Scroll_Offset is Interfaces.C.double; private for Button'Size use Interfaces.C.int'Size; for Enter_Action use (Leaving => 0, Entering => 1); for Enter_Action'Size use C.int'Size; for Cursor_Mode use (Normal => 16#34001#, Hidden => 16#34002#, Disabled => 16#34003#); for Cursor_Mode'Size use Interfaces.C.int'Size; end Glfw.Input.Mouse;
with Ada.Text_IO; with Interfaces.C; with a_nodes_h.Support; with Generic_Logging; with Lal_Adapter.Tool; package body lal_adapter_wrapper_h is package anhS renames a_nodes_h.Support; ------------ -- EXPORTED: ------------ function lal_adapter_wrapper (project_file_name : in Interfaces.C.Strings.chars_ptr; input_file_name : in Interfaces.C.Strings.chars_ptr; output_dir_name : in Interfaces.C.Strings.chars_ptr; process_predefined_units : in Interfaces.C.Extensions.bool; process_implementation_units : in Interfaces.C.Extensions.bool; debug : in Interfaces.C.Extensions.bool ) return a_nodes_h.Nodes_Struct is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".lal_adapter_wrapper"; package Logging is new Generic_Logging (Module_Name); use Logging; Auto : Logging.Auto_Logger; -- Logs BEGIN and END function To_String (This : in Interfaces.C.Strings.chars_ptr) return String is begin return Interfaces.C.To_Ada (Interfaces.C.Strings.Value (This)); end To_String; Tool : Lal_Adapter.Tool.Class; -- Initialized Result : a_nodes_h.Nodes_Struct := anhs.Default_Nodes_Struct; -- For = functions: use a_nodes_h; begin Tool.Process (Project_File_Name => To_String (project_file_name), Input_File_Name => To_String (input_file_name), Output_Dir_Name => To_String (output_dir_name), Process_Predefined_Units => Boolean (process_predefined_units), Process_Implementation_Units => Boolean (process_implementation_units), Debug => Boolean (debug)); Result := Tool.Get_Nodes; if Result.Units = null then Log ("Returning NO Units."); else declare -- Can't take 'Image of an expression, so new object below: Count : constant Integer := Integer (Result.Units.Next_Count) + 1; begin Log ("Returning " & Count'Image & " + 1 Units."); end; end if; if Result.Elements = null then Log ("Returning NO Elements."); else declare -- Can't take 'Image of an expression, so new object below: Count : constant Integer := Integer (Result.Elements.Next_Count) + 1; begin Log ("Returning " & Count'Image & " + 1 Elements."); end; end if; return Result; exception when X: others => -- Now we are probably leaving the Ada call stack and returning to C. -- This is our last chance to log the Ada exception info, so do that. Logging.Log_Exception (X); -- Reraise the exception so the caller knows there was one. Logging.Log ("Reraising exception."); raise; end lal_adapter_wrapper; end lal_adapter_wrapper_h;
-- ----------------------------------------------------------------- -- -- AdaSDL -- -- Binding to Simple Direct Media Layer -- -- Copyright (C) 2001 A.M.F.Vargas -- -- Antonio M. F. Vargas -- -- Ponta Delgada - Azores - Portugal -- -- http://www.adapower.net/~avargas -- -- E-mail: avargas@adapower.net -- -- ----------------------------------------------------------------- -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- -- ----------------------------------------------------------------- -- -- **************************************************************** -- -- This is an Ada binding to SDL ( Simple DirectMedia Layer from -- -- Sam Lantinga - www.libsld.org ) -- -- **************************************************************** -- -- In order to help the Ada programmer, the comments in this file -- -- are, in great extent, a direct copy of the original text in the -- -- SDL header files. -- -- **************************************************************** -- with System; with Interfaces.C; with SDL.Types; use SDL.Types; with SDL.Video; package SDL.Mouse is package I renames Interfaces; type WMcursor is private; -- Implementation dependent type Save_Cursor_Array is array (0 .. 1) of Uint8_ptr; pragma Convention (C, Save_Cursor_Array); type Cursor is record area : SDL.Video.Rect; -- The area of the mouse cursor hot_x, hot_y : Sint16; -- The "tip" of the cursor data : Uint8_ptr; -- B/W cursor data mask : Uint8_ptr; -- B/W cursor mask save : Save_Cursor_Array; -- Place de save cursor area wm_cursor : WMcursor; -- Window-manager cursor end record; pragma Convention (C, Cursor); type Cursor_ptr is access all Cursor; pragma Convention (C, Cursor_ptr); -- ------------------- -- Function prototypes -- ------------------- -- type Mouse_State is mod 2**8; for Mouse_State'Size use 8; pragma Convention (C, Mouse_State); -- -- Retrieve the current state of the mouse. -- The current button state is returned as a button bitmask, which can -- be tested using the SDL_BUTTON(X) macros, and x and y are set to the -- current mouse cursor position. You can pass NULL for either x or y. function GetMouseState (x, y : int_ptr) return Mouse_State; pragma Import (C, GetMouseState, "SDL_GetMouseState"); procedure Get_Mouse_State ( state : out Mouse_State; x : in out C.int; y : in out C.int); pragma Import (C, Get_Mouse_State, "SDL_GetMouseState"); pragma Import_Valued_Procedure (Get_Mouse_State); procedure Get_Mouse_State_X ( state : out Mouse_State; x : in out C.int); pragma Inline (Get_Mouse_State_X); procedure Get_Mouse_State_Y ( state : out Mouse_State; y : in out C.int); pragma Inline (Get_Mouse_State_Y); -- Retrieve the current state of the mouse. -- The current button state is returned as a button bitmask, which can -- be tested using the SDL_BUTTON(X) macros, and x and y are set to the -- mouse deltas since the last call to SDL_GetRelativeMouseState(). function GetRelativeMouseState (x, y : int_ptr) return Mouse_State; pragma Import (C, GetRelativeMouseState, "SDL_GetRelativeMouseState"); -- Set the position of the mouse cursor (generates a mouse motion event) procedure WarpMouse (x, y : Uint16); pragma Import (C, WarpMouse, "SDL_WarpMouse"); -- Create a cursor using the specified data and mask (in MSB format). -- The cursor width must be a multiple of 8 bits. -- -- The cursor is created in black and white according to the following: -- data mask resulting pixel on screen -- 0 1 White -- 1 1 Black -- 0 0 Transparent -- 1 0 Inverted color if possible, black if not. -- Cursors created with this function must be freed with SDL_FreeCursor(). function CreateCursor ( data : Uint8_ptr; mask : Uint8_ptr; w, h : C.int; hot_x, hot_y : C.int) return Cursor_ptr; pragma Import (C, CreateCursor, "SDL_CreateCursor"); -- Set the currently active cursor to the specified one. -- If the cursor is currently visible, the change will be immediately -- represented on the display. procedure SetCursor (the_cursor : Cursor_ptr); pragma Import (C, SetCursor, "SDL_SetCursor2"); -- Returns the currently active cursor. function GetCursor return Cursor_ptr; pragma Import (C, GetCursor, "SDL_GetCursor"); -- Deallocates a cursor created with SDL_CreateCursor(). procedure FreeCursor (the_cursor : Cursor_ptr); pragma Import (C, FreeCursor, "SDL_FreeCursor"); -- Toggle whether or not the cursor is shown on the screen. -- The cursor start off displayed, but can be turned off. -- SDL_ShowCursor returns 1 if the cursor was being displayed -- before the call, or 0 if it was not. function ShowCursor (toggle : C.int) return C.int; procedure ShowCursor (toggle : C.int); pragma Import (C, ShowCursor, "SDL_ShowCursor"); type Button_ID is new C.int range 1 .. 3; pragma Convention (C, Button_ID); type Button_Mask is mod 2**32; pragma Convention (C, Button_Mask); BUTTON_LEFT : constant Button_ID := 1; BUTTON_MIDDLE : constant Button_ID := 2; BUTTON_RIGHT : constant Button_ID := 3; BUTTON_LAMSK : constant Button_Mask := Button_Mask (I.Shift_Left ( I.Unsigned_32 (SDL_PRESSED), Natural (BUTTON_LEFT - 1))); BUTTON_MMASK : constant Button_Mask := Button_Mask (I.Shift_Left ( I.Unsigned_32 (SDL_PRESSED), Natural (BUTTON_MIDDLE - 1))); BUTTON_RMASK : constant Button_Mask := Button_Mask (I.Shift_Left ( I.Unsigned_32 (SDL_PRESSED), Natural (BUTTON_RIGHT - 1))); type Mouse_Button_State is mod 2**8; for Mouse_Button_State'Size use 8; pragma Convention (C, Mouse_Button_State); PRESSED : constant Mouse_Button_State := Mouse_Button_State (SDL_PRESSED); RELEASED : constant Mouse_Button_State := Mouse_Button_State (SDL_RELEASED); private type WMcursor is new System.Address; end SDL.Mouse;
pragma License (Unrestricted); -- implementation unit required by compiler package System.Val_Char is pragma Pure; -- required for Character'Value by compiler (s-valcha.ads) function Value_Character (Str : String) return Character; -- helper HEX_Prefix : constant String := "HEX_"; -- upper case procedure Get_Named ( S : String; Value : out Character; Error : out Boolean); end System.Val_Char;
-- Code originally generated by dginstr.go - there have been edits... -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -- THE SOFTWARE. with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with DG_Types; use DG_Types; package CPU_Instructions is -- Instruction Classes type Instr_Class_T is ( NOVA_MEMREF, NOVA_OP, NOVA_IO, NOVA_MATH, NOVA_PC, ECLIPSE_FPU, ECLIPSE_MEMREF, ECLIPSE_OP, ECLIPSE_PC, ECLIPSE_STACK, EAGLE_DECIMAL, EAGLE_IO, EAGLE_PC, EAGLE_OP, EAGLE_MEMREF, EAGLE_STACK, EAGLE_FPU ); -- Instruction Formats type Instr_Format_T is ( DERR_FMT, IMM_MODE_2_WORD_FMT, IMM_ONEACC_FMT, IO_FLAGS_DEV_FMT, IO_TEST_DEV_FMT, LNDO_4_WORD_FMT, NOACC_MODE_2_WORD_FMT, NOACC_MODE_3_WORD_FMT, NOACC_MODE_IMM_IND_3_WORD_FMT, NOACC_MODE_IND_2_WORD_E_FMT, NOACC_MODE_IND_2_WORD_X_FMT, NOACC_MODE_IND_3_WORD_FMT, NOACC_MODE_IND_3_WORD_XCALL_FMT, NOACC_MODE_IND_4_WORD_FMT, NOVA_DATA_IO_FMT, NOVA_NOACC_EFF_ADDR_FMT, NOVA_ONEACC_EFF_ADDR_FMT, NOVA_TWOACC_MULT_OP_FMT, ONEACC_IMM_2_WORD_FMT, ONEACC_IMMWD_2_WORD_FMT, ONEACC_IMM_3_WORD_FMT, ONEACC_IMMDWD_3_WORD_FMT, ONEACC_MODE_2_WORD_E_FMT, ONEACC_MODE_2_WORD_X_B_FMT, ONEACC_MODE_3_WORD_FMT, ONEACC_MODE_IND_2_WORD_E_FMT, ONEACC_MODE_IND_2_WORD_X_FMT, ONEACC_MODE_IND_3_WORD_FMT, ONEACC_1_WORD_FMT, UNIQUE_1_WORD_FMT, UNIQUE_2_WORD_FMT, SPLIT_8BIT_DISP_FMT, THREE_WORD_DO_FMT, TWOACC_1_WORD_FMT, TWOACC_IMM_2_WORD_FMT, WIDE_DEC_SPECIAL_FMT, WSKB_FMT ); -- Instruction Mnemonic Consts type Instr_Mnemonic_T is ( I_ADC, I_ADD, I_ADDI, I_ADI, I_ANC, I_AND, I_ANDI, I_BAM, I_BKPT, I_BLM, I_BTO, I_BTZ, I_CIO, I_CIOI, I_CLM, I_CMP, I_CMT, I_CMV, I_COB, I_COM, I_CRYTC, I_CRYTO, I_CRYTZ, I_CTR, I_CVWN, I_DAD, I_DEQUE, I_DERR, I_DHXL, I_DHXR, I_DIA, I_DIB, I_DIC, I_DIV, I_DIVS, I_DIVX, I_DLSH, I_DOA, I_DOB, I_DOC, I_DSB, I_DSPA, I_DSZ, I_DSZTS, I_ECLID, I_EDIT, I_EDSZ, I_EISZ, I_EJMP, I_EJSR, I_ELDA, I_ELDB, I_ELEF, I_ENQH, I_ENQT, I_ESTA, I_ESTB, I_FAD, I_FAS, I_FCLE, I_FCMP, I_FAB, I_FDD, I_FDS, I_FEXP, I_FFAS, I_FHLV, I_FINT, I_FLAS, I_FLDS, I_FLST, I_FMD, I_FMOV, I_FMS, I_FNEG, I_FNS, I_FPOP, I_FPSH, I_FRDS, I_FRH, I_FSA, I_FSD, I_FSEQ, I_FSGE, I_FSGT, I_FSLE, I_FSLT, I_FSNE, I_FSNER, I_FSS, I_FSST, I_FSTS, I_FTD, I_FTE, I_FXTD, I_FXTE, I_HALT, I_HLV, I_HXL, I_HXR, I_INC, I_INTA, I_INTDS, I_INTEN, I_IOR, I_IORI, I_IORST, I_ISZ, I_ISZTS, I_JMP, I_JSR, I_LCALL, I_LCPID, I_LDA, I_LDAFP, I_LDASB, I_LDASL, I_LDASP, I_LDATS, I_LDB, I_LDSP, I_LEF, I_LFAMD, I_LFDMD, I_LFDMS, I_LFLDD, I_LFLDS, I_LFMMD, I_LFMMS, I_LFSMD, I_LFSTD, I_LFSTS, I_LJMP, I_LJSR, I_LLDB, I_LLEF, I_LLEFB, I_LMRF, I_LNADD, I_LNADI, I_LNDIV, I_LNDO, I_LNDSZ, I_LNISZ, I_LNLDA, I_LNMUL, I_LNSBI, I_LNSTA, I_LNSUB, I_LOB, I_LPEF, I_LPEFB, I_LPHY, I_LPSHJ, I_LPSR, I_LRB, I_LSH, I_LSTB, I_LWADD, I_LWADI, I_LWDO, I_LWDSZ, I_LWISZ, I_LWLDA, I_LWMUL, I_LWSTA, I_LWSUB, I_MOV, I_MSP, I_MUL, I_MULS, I_NADD, I_NADDI, I_NADI, I_NCLID, I_NDIV, I_NEG, I_NIO, I_NLDAI, I_NMUL, I_NNEG, I_NSALA, I_NSANA, I_NSBI, I_NSUB, I_PIO, I_POP, I_POPB, I_POPJ, I_PRTSEL, I_PSH, I_PSHJ, I_PSHR, I_READS, I_RSTR, I_RTN, I_SAVE, I_SBI, I_SEX, I_SGE, I_SGT, I_SKP, I_SNB, I_SNOVR, I_SPSR, I_SPTE, I_SSPT, I_STA, I_STAFP, I_STASB, I_STASL, I_STASP, I_STATS, I_STB, I_SUB, I_SZB, I_SZBO, I_WADC, I_WADD, I_WADDI, I_WADI, I_WANC, I_WAND, I_WANDI, I_WASH, I_WASHI, I_WBLM, I_WBR, I_WBTO, I_WBTZ, I_WCLM, I_WCMP, I_WCMV, I_WCOM, I_WCST, I_WCTR, I_WDecOp, I_WDIV, I_WDIVS, I_WFFAD, I_WFLAD, I_WFPOP, I_WFPSH, I_WHLV, I_WINC, I_WIOR, I_WIORI, I_WLDAI, I_WLDB, I_WLDI, I_WLMP, I_WLSH, I_WLSHI, I_WLSI, I_WMESS, I_WMOV, I_WMOVR, I_WMSP, I_WMUL, I_WMULS, I_WNADI, I_WNEG, I_WPOP, I_WPOPB, I_WPOPJ, I_WPSH, I_WRTN, I_WSANA, I_WSAVR, I_WSAVS, I_WSBI, I_WSEQ, I_WSEQI, I_WSGE, I_WSGT, I_WSGTI, I_WSKBO, I_WSKBZ, I_WSLE, I_WSLEI, I_WSLT, I_WSNB, I_WSNE, I_WSNEI, I_WSSVR, I_WSSVS, I_WSTB, I_WSTI, I_WSUB, I_WSZB, I_WSZBO, I_WUSGE, I_WUSGT, I_WUGTI, I_WULEI, I_WXCH, I_WXOR, I_WXORI, I_XCALL, I_XCH, I_XCT, I_XFAMD, I_XFAMS, I_XFDMS, I_XFLDD, I_XFLDS, I_XFMMD, I_XFMMS, I_XFSTD, I_XFSTS, I_XJMP, I_XJSR, I_XLDB, I_XLEF, I_XLEFB, I_XNADD, I_XNADI, I_XNDO, I_XNDSZ, I_XNISZ, I_XNLDA, I_XNMUL, I_XNSBI, I_XNSTA, I_XNSUB, I_XOR, I_XORI, I_XPEF, I_XPEFB, I_XPSHJ, I_XSTB, I_XWADD, I_XWADI, I_XWDIV, I_XWDO, I_XWDSZ, I_XWISZ, I_XWLDA, I_XWMUL, I_XWSBI, I_XWSTA, I_XWSUB, I_ZEX ); type Instr_Char_Rec is record Mnemonic : Unbounded_String; Bits : Word_T; Mask : Word_T; Instr_Len : Positive; Instr_Fmt : Instr_Format_T; Instr_Class : Instr_Class_T; Disp_Offset : Natural; end record; type Instructions is array (Instr_Mnemonic_T range Instr_Mnemonic_T'Range) of Instr_Char_Rec; Instruction_Set : constant Instructions := ( I_ADC => (To_Unbounded_String("ADC"), 16#8400#, 16#8700#, 1, NOVA_TWOACC_MULT_OP_FMT, NOVA_OP, 0), I_ADD => (To_Unbounded_String("ADD"), 16#8600#, 16#8700#, 1, NOVA_TWOACC_MULT_OP_FMT, NOVA_OP, 0), I_ADDI => (To_Unbounded_String("ADDI"), 16#e7f8#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, ECLIPSE_OP, 0), I_ADI => (To_Unbounded_String("ADI"), 16#8008#, 16#87ff#, 1, IMM_ONEACC_FMT, ECLIPSE_OP, 0), I_ANC => (To_Unbounded_String("ANC"), 16#8188#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_AND => (To_Unbounded_String("AND"), 16#8700#, 16#8700#, 1, NOVA_TWOACC_MULT_OP_FMT, NOVA_OP, 0), I_ANDI => (To_Unbounded_String("ANDI"), 16#c7f8#, 16#e7ff#, 2, ONEACC_IMMWD_2_WORD_FMT, ECLIPSE_OP, 0), I_BAM => (To_Unbounded_String("BAM"), 16#97c8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_BKPT => (To_Unbounded_String("BKPT"), 16#c789#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_PC, 0), I_BLM => (To_Unbounded_String("BLM"), 16#b7c8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_BTO => (To_Unbounded_String("BTO"), 16#8408#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_BTZ => (To_Unbounded_String("BTZ"), 16#8448#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_CIO => (To_Unbounded_String("CIO"), 16#85e9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_IO, 0), I_CIOI => (To_Unbounded_String("CIOI"), 16#85f9#, 16#87ff#, 2, TWOACC_IMM_2_WORD_FMT, EAGLE_IO, 0), I_CLM => (To_Unbounded_String("CLM"), 16#84f8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_PC, 0), I_CMP => (To_Unbounded_String("CMP"), 16#dfa8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_CMT => (To_Unbounded_String("CMT"), 16#efa8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_CMV => (To_Unbounded_String("CMV"), 16#d7a8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_COB => (To_Unbounded_String("COB"), 16#8588#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_COM => (To_Unbounded_String("COM"), 16#8000#, 16#8700#, 1, NOVA_TWOACC_MULT_OP_FMT, NOVA_OP, 0), I_CRYTC => (To_Unbounded_String("CRYTC"), 16#a7e9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_CRYTO => (To_Unbounded_String("CRYTO"), 16#a7c9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_CRYTZ => (To_Unbounded_String("CRYTZ"), 16#a7d9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_CTR => (To_Unbounded_String("CTR"), 16#e7a8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_OP, 0), I_CVWN => (To_Unbounded_String("CVWN"), 16#e669#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_OP, 0), I_DAD => (To_Unbounded_String("DAD"), 16#8088#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_DEQUE => (To_Unbounded_String("DEQUE"), 16#e7c9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_DERR => (To_Unbounded_String("DERR"), 16#8f09#, 16#8fcf#, 1, DERR_FMT, EAGLE_PC, 0), I_DHXL => (To_Unbounded_String("DHXL"), 16#8388#, 16#87ff#, 1, IMM_ONEACC_FMT, ECLIPSE_OP, 0), I_DHXR => (To_Unbounded_String("DHXR"), 16#83c8#, 16#87ff#, 1, IMM_ONEACC_FMT, ECLIPSE_OP, 0), I_DIA => (To_Unbounded_String("DIA"), 16#6100#, 16#e700#, 1, NOVA_DATA_IO_FMT, NOVA_IO, 0), I_DIB => (To_Unbounded_String("DIB"), 16#6300#, 16#e700#, 1, NOVA_DATA_IO_FMT, NOVA_IO, 0), I_DIC => (To_Unbounded_String("DIC"), 16#6500#, 16#e700#, 1, NOVA_DATA_IO_FMT, NOVA_IO, 0), I_DIV => (To_Unbounded_String("DIV"), 16#d7c8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, NOVA_MATH, 0), I_DIVS => (To_Unbounded_String("DIVS"), 16#dfc8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_OP, 0), I_DIVX => (To_Unbounded_String("DIVX"), 16#bfc8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_OP, 0), I_DLSH => (To_Unbounded_String("DLSH"), 16#82c8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_DOA => (To_Unbounded_String("DOA"), 16#6200#, 16#e700#, 1, NOVA_DATA_IO_FMT, NOVA_IO, 0), I_DOB => (To_Unbounded_String("DOB"), 16#6400#, 16#e700#, 1, NOVA_DATA_IO_FMT, NOVA_IO, 0), I_DOC => (To_Unbounded_String("DOC"), 16#6600#, 16#e700#, 1, NOVA_DATA_IO_FMT, NOVA_IO, 0), I_DSB => (To_Unbounded_String("DSB"), 16#80c8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_DSPA => (To_Unbounded_String("DSPA"), 16#c478#, 16#e4ff#, 2, ONEACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_PC, 1), I_DSZ => (To_Unbounded_String("DSZ"), 16#1800#, 16#f800#, 1, NOVA_NOACC_EFF_ADDR_FMT, NOVA_MEMREF, 0), I_DSZTS => (To_Unbounded_String("DSZTS"), 16#c7d9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_PC, 0), I_ECLID => (To_Unbounded_String("ECLID"), 16#ffc8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_IO, 0), I_EDIT => (To_Unbounded_String("EDIT"), 16#f7a8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_OP, 0), I_EDSZ => (To_Unbounded_String("EDSZ"), 16#9c38#, 16#fcff#, 2, NOACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_PC, 1), I_EISZ => (To_Unbounded_String("EISZ"), 16#9438#, 16#fcff#, 2, NOACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_PC, 1), I_EJMP => (To_Unbounded_String("EJMP"), 16#8438#, 16#fcff#, 2, NOACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_PC, 1), I_EJSR => (To_Unbounded_String("EJSR"), 16#8c38#, 16#fcff#, 2, NOACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_PC, 1), I_ELDA => (To_Unbounded_String("ELDA"), 16#a438#, 16#e4ff#, 2, ONEACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_MEMREF, 1), I_ELDB => (To_Unbounded_String("ELDB"), 16#8478#, 16#e4ff#, 2, ONEACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_MEMREF, 1), I_ELEF => (To_Unbounded_String("ELEF"), 16#e438#, 16#e4ff#, 2, ONEACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_MEMREF, 1), I_ENQH => (To_Unbounded_String("ENQH"), 16#c7e9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_ENQT => (To_Unbounded_String("ENQT"), 16#c7f9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_ESTA => (To_Unbounded_String("ESTA"), 16#c438#, 16#e4ff#, 2, ONEACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_MEMREF, 1), I_ESTB => (To_Unbounded_String("ESTB"), 16#a478#, 16#e4ff#, 2, ONEACC_MODE_2_WORD_E_FMT, ECLIPSE_OP, 1), I_FAD => (To_Unbounded_String("FAD"), 16#8068#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FAS => (To_Unbounded_String("FAS"), 16#8028#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FCLE => (To_Unbounded_String("FCLE"), 16#d6e8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FCMP => (To_Unbounded_String("FCMP"), 16#8728#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FAB => (To_Unbounded_String("FAB"), 16#c628#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FDD => (To_Unbounded_String("FDD"), 16#81e8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FDS => (To_Unbounded_String("FDS"), 16#81a8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FEXP => (To_Unbounded_String("FEXP"), 16#a668#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FFAS => (To_Unbounded_String("FFAS"), 16#85a8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FHLV => (To_Unbounded_String("FHLV"), 16#e668#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FINT => (To_Unbounded_String("FINT"), 16#c668#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FLAS => (To_Unbounded_String("FLAS"), 16#8528#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FLDS => (To_Unbounded_String("FLDS"), 16#8428#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, ECLIPSE_FPU, 1), I_FLST => (To_Unbounded_String("FLST"), 16#a6e8#, 16#e7ff#, 2, NOACC_MODE_IND_2_WORD_X_FMT, ECLIPSE_FPU, 0), I_FMD => (To_Unbounded_String("FMD"), 16#8168#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FMOV => (To_Unbounded_String("FMOV"), 16#8768#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FMS => (To_Unbounded_String("FMS"), 16#8128#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FNEG => (To_Unbounded_String("FNEG"), 16#e628#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FNS => (To_Unbounded_String("FNS"), 16#86a8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_PC, 0), I_FPOP => (To_Unbounded_String("FPOP"), 16#eee8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_STACK, 0), I_FPSH => (To_Unbounded_String("FPSH"), 16#e6e8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_STACK, 0), I_FRDS => (To_Unbounded_String("FRDS"), 16#84d8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FRH => (To_Unbounded_String("FRH"), 16#a628#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSA => (To_Unbounded_String("FSA"), 16#8ea8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_PC, 0), I_FSD => (To_Unbounded_String("FSD"), 16#80e8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSEQ => (To_Unbounded_String("FSEQ"), 16#96a8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSGE => (To_Unbounded_String("FSGE"), 16#aea8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSGT => (To_Unbounded_String("FSGT"), 16#bea8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSLE => (To_Unbounded_String("FSLE"), 16#b6a8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSLT => (To_Unbounded_String("FSLT"), 16#a6a8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSNE => (To_Unbounded_String("FSNE"), 16#9ea8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSNER => (To_Unbounded_String("FSNER"), 16#fea8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSS => (To_Unbounded_String("FSS"), 16#80a8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_FPU, 0), I_FSST => (To_Unbounded_String("FSST"), 16#86e8#, 16#e7ff#, 2, NOACC_MODE_IND_2_WORD_X_FMT, ECLIPSE_FPU, 0), I_FSTS => (To_Unbounded_String("FSTS"), 16#84a8#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, ECLIPSE_FPU, 0), I_FTD => (To_Unbounded_String("FTD"), 16#cee8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FTE => (To_Unbounded_String("FTE"), 16#c6e8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_FPU, 0), I_FXTD => (To_Unbounded_String("FXTD"), 16#a779#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_OP, 0), I_FXTE => (To_Unbounded_String("FXTE"), 16#c749#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_OP, 0), I_HALT => (To_Unbounded_String("HALT"), 16#647f#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, NOVA_IO, 0), I_HLV => (To_Unbounded_String("HLV"), 16#c6f8#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_OP, 0), I_HXL => (To_Unbounded_String("HXL"), 16#8308#, 16#87ff#, 1, IMM_ONEACC_FMT, ECLIPSE_OP, 0), I_HXR => (To_Unbounded_String("HXR"), 16#8348#, 16#87ff#, 1, IMM_ONEACC_FMT, ECLIPSE_OP, 0), I_INC => (To_Unbounded_String("INC"), 16#8300#, 16#8700#, 1, NOVA_TWOACC_MULT_OP_FMT, NOVA_OP, 0), I_INTA => (To_Unbounded_String("INTA"), 16#633f#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, NOVA_IO, 0), I_INTDS => (To_Unbounded_String("INTDS"), 16#60bf#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, NOVA_IO, 0), I_INTEN => (To_Unbounded_String("INTEN"), 16#607f#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, NOVA_IO, 0), I_IOR => (To_Unbounded_String("IOR"), 16#8108#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_IORI => (To_Unbounded_String("IORI"), 16#87f8#, 16#e7ff#, 2, ONEACC_IMMWD_2_WORD_FMT, ECLIPSE_OP, 0), I_IORST => (To_Unbounded_String("IORST"), 16#653f#, 16#e73f#, 1, ONEACC_1_WORD_FMT, NOVA_IO, 0), I_ISZ => (To_Unbounded_String("ISZ"), 16#1000#, 16#f800#, 1, NOVA_NOACC_EFF_ADDR_FMT, NOVA_MEMREF, 0), I_ISZTS => (To_Unbounded_String("ISZTS"), 16#c7c9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_PC, 0), I_JMP => (To_Unbounded_String("JMP"), 16#0000#, 16#f800#, 1, NOVA_NOACC_EFF_ADDR_FMT, NOVA_PC, 0), I_JSR => (To_Unbounded_String("JSR"), 16#0800#, 16#f800#, 1, NOVA_NOACC_EFF_ADDR_FMT, NOVA_PC, 0), I_LCALL => (To_Unbounded_String("LCALL"), 16#a6c9#, 16#e7ff#, 4, NOACC_MODE_IND_4_WORD_FMT, EAGLE_STACK, 1), I_LCPID => (To_Unbounded_String("LCPID"), 16#8759#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_IO, 0), I_LDA => (To_Unbounded_String("LDA"), 16#2000#, 16#e000#, 1, NOVA_ONEACC_EFF_ADDR_FMT, NOVA_MEMREF, 0), I_LDAFP => (To_Unbounded_String("LDAFP"), 16#c669#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_LDASB => (To_Unbounded_String("LDASB"), 16#c649#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_LDASL => (To_Unbounded_String("LDASL"), 16#a669#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_LDASP => (To_Unbounded_String("LDASP"), 16#a649#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_LDATS => (To_Unbounded_String("LDATS"), 16#8649#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_LDB => (To_Unbounded_String("LDB"), 16#85c8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_LDSP => (To_Unbounded_String("LDSP"), 16#8519#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_PC, 1), I_LEF => (To_Unbounded_String("LEF"), 16#6000#, 16#e000#, 1, NOVA_ONEACC_EFF_ADDR_FMT, ECLIPSE_MEMREF, 0), I_LFAMD => (To_Unbounded_String("LFAMD"), 16#80d9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFDMD => (To_Unbounded_String("LFDMD"), 16#81f9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFDMS => (To_Unbounded_String("LFDMS"), 16#81e9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFLDD => (To_Unbounded_String("LFLDD"), 16#82d9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFLDS => (To_Unbounded_String("LFLDS"), 16#82c9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFMMD => (To_Unbounded_String("LFMMD"), 16#81d9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFMMS => (To_Unbounded_String("LFMMS"), 16#81c9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFSMD => (To_Unbounded_String("LFSMD"), 16#80f9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFSTD => (To_Unbounded_String("LFSTD"), 16#82f9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LFSTS => (To_Unbounded_String("LFSTS"), 16#82e9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_FPU, 1), I_LJMP => (To_Unbounded_String("LJMP"), 16#a6d9#, 16#e7ff#, 3, NOACC_MODE_IND_3_WORD_FMT, EAGLE_PC, 1), I_LJSR => (To_Unbounded_String("LJSR"), 16#a6e9#, 16#e7ff#, 3, NOACC_MODE_IND_3_WORD_FMT, EAGLE_PC, 1), I_LLDB => (To_Unbounded_String("LLDB"), 16#84c9#, 16#87ff#, 3, ONEACC_MODE_3_WORD_FMT, EAGLE_MEMREF, 1), I_LLEF => (To_Unbounded_String("LLEF"), 16#83e9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LLEFB => (To_Unbounded_String("LLEFB"), 16#84e9#, 16#87ff#, 3, ONEACC_MODE_3_WORD_FMT, EAGLE_MEMREF, 1), I_LMRF => (To_Unbounded_String("LMRF"), 16#87c9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_LNADD => (To_Unbounded_String("LNADD"), 16#8218#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LNADI => (To_Unbounded_String("LNADI"), 16#8618#, 16#87ff#, 3, NOACC_MODE_IMM_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LNDIV => (To_Unbounded_String("LNDIV"), 16#82d8#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_OP, 1), I_LNDO => (To_Unbounded_String("LNDO"), 16#8698#, 16#87ff#, 4, LNDO_4_WORD_FMT, EAGLE_PC, 1), I_LNDSZ => (To_Unbounded_String("LNDSZ"), 16#86d9#, 16#e7ff#, 3, NOACC_MODE_IND_3_WORD_FMT, EAGLE_PC, 1), I_LNISZ => (To_Unbounded_String("LNISZ"), 16#86c9#, 16#e7ff#, 3, NOACC_MODE_IND_3_WORD_FMT, EAGLE_PC, 1), I_LNLDA => (To_Unbounded_String("LNLDA"), 16#83c9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LNMUL => (To_Unbounded_String("LNMUL"), 16#8298#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LNSBI => (To_Unbounded_String("LNSBI"), 16#8658#, 16#87ff#, 3, NOACC_MODE_IMM_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LNSTA => (To_Unbounded_String("LNSTA"), 16#83d9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LNSUB => (To_Unbounded_String("LNSUB"), 16#8258#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LOB => (To_Unbounded_String("LOB"), 16#8508#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_LPEF => (To_Unbounded_String("LPEF"), 16#a6f9#, 16#e7ff#, 3, NOACC_MODE_IND_3_WORD_FMT, EAGLE_STACK, 1), I_LPEFB => (To_Unbounded_String("LPEFB"), 16#c6f9#, 16#e7ff#, 3, NOACC_MODE_3_WORD_FMT, EAGLE_STACK, 1), I_LPHY => (To_Unbounded_String("LPHY"), 16#87e9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_LPSHJ => (To_Unbounded_String("LPSHJ"), 16#C6C9#, 16#E7FF#, 3, NOACC_MODE_IND_3_WORD_FMT, EAGLE_PC, 1), I_LPSR => (To_Unbounded_String("LPSR"), 16#a799#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_LRB => (To_Unbounded_String("LRB"), 16#8548#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_LSH => (To_Unbounded_String("LSH"), 16#8288#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_LSTB => (To_Unbounded_String("LSTB"), 16#84d9#, 16#87ff#, 3, ONEACC_MODE_3_WORD_FMT, EAGLE_MEMREF, 1), I_LWADD => (To_Unbounded_String("LWADD"), 16#8318#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LWADI => (To_Unbounded_String("LWADI"), 16#8718#, 16#87ff#, 3, NOACC_MODE_IMM_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LWDO => (To_Unbounded_String("LWDO"), 16#8798#, 16#87ff#, 4, LNDO_4_WORD_FMT, EAGLE_PC, 1), I_LWDSZ => (To_Unbounded_String("LWDSZ"), 16#86f9#, 16#e7ff#, 3, NOACC_MODE_IND_3_WORD_FMT, EAGLE_PC, 1), I_LWISZ => (To_Unbounded_String("LWISZ"), 16#86e9#, 16#e7ff#, 3, NOACC_MODE_IND_3_WORD_FMT, EAGLE_PC, 1), I_LWLDA => (To_Unbounded_String("LWLDA"), 16#83f9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LWMUL => (To_Unbounded_String("LWMUL"), 16#8398#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LWSTA => (To_Unbounded_String("LWSTA"), 16#84f9#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_LWSUB => (To_Unbounded_String("LWSUB"), 16#8358#, 16#87ff#, 3, ONEACC_MODE_IND_3_WORD_FMT, EAGLE_MEMREF, 1), I_MOV => (To_Unbounded_String("MOV"), 16#8200#, 16#8700#, 1, NOVA_TWOACC_MULT_OP_FMT, NOVA_OP, 0), I_MSP => (To_Unbounded_String("MSP"), 16#86f8#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_STACK, 0), I_MUL => (To_Unbounded_String("MUL"), 16#c7c8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, NOVA_MATH, 0), I_MULS => (To_Unbounded_String("MULS"), 16#cfc8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_OP, 0), I_NADD => (To_Unbounded_String("NADD"), 16#8049#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_NADDI => (To_Unbounded_String("NADDI"), 16#c639#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_OP, 0), I_NADI => (To_Unbounded_String("NADI"), 16#8599#, 16#87ff#, 1, IMM_ONEACC_FMT, EAGLE_OP, 0), I_NCLID => (To_Unbounded_String("NCLID"), 16#683f#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_IO, 0), I_NDIV => (To_Unbounded_String("NDIV"), 16#8079#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_NEG => (To_Unbounded_String("NEG"), 16#8100#, 16#8700#, 1, NOVA_TWOACC_MULT_OP_FMT, NOVA_OP, 0), I_NIO => (To_Unbounded_String("NIO"), 16#6000#, 16#ff00#, 1, IO_FLAGS_DEV_FMT, NOVA_IO, 0), I_NLDAI => (To_Unbounded_String("NLDAI"), 16#c629#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_OP, 0), I_NMUL => (To_Unbounded_String("NMUL"), 16#8069#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_NNEG => (To_Unbounded_String("NNEG"), 16#8509#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_NSALA => (To_Unbounded_String("NSALA"), 16#e609#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_PC, 0), I_NSANA => (To_Unbounded_String("NSANA"), 16#e629#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_PC, 0), I_NSBI => (To_Unbounded_String("NSBI"), 16#85a9#, 16#87ff#, 1, IMM_ONEACC_FMT, EAGLE_OP, 0), I_NSUB => (To_Unbounded_String("NSUB"), 16#8059#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_PIO => (To_Unbounded_String("PIO"), 16#85d9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_IO, 0), I_POP => (To_Unbounded_String("POP"), 16#8688#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_STACK, 0), I_POPB => (To_Unbounded_String("POPB"), 16#8fc8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_STACK, 0), I_POPJ => (To_Unbounded_String("POPJ"), 16#9fc8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_STACK, 0), I_PRTSEL => (To_Unbounded_String("PRTSEL"), 16#783f#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_IO, 0), I_PSH => (To_Unbounded_String("PSH"), 16#8648#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_STACK, 0), I_PSHJ => (To_Unbounded_String("PSHJ"), 16#84b8#, 16#fcff#, 2, NOACC_MODE_IND_2_WORD_E_FMT, ECLIPSE_STACK, 1), I_PSHR => (To_Unbounded_String("PSHR"), 16#87c8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_STACK, 0), I_READS => (To_Unbounded_String("READS"), 16#613f#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_IO, 0), I_RSTR => (To_Unbounded_String("RSTR"), 16#efc8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_STACK, 0), I_RTN => (To_Unbounded_String("RTN"), 16#afc8#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, ECLIPSE_STACK, 0), I_SAVE => (To_Unbounded_String("SAVE"), 16#e7c8#, 16#ffff#, 2, UNIQUE_2_WORD_FMT, ECLIPSE_STACK, 0), I_SBI => (To_Unbounded_String("SBI"), 16#8048#, 16#87ff#, 1, IMM_ONEACC_FMT, ECLIPSE_OP, 0), I_SEX => (To_Unbounded_String("SEX"), 16#8349#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_SGE => (To_Unbounded_String("SGE"), 16#8248#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_PC, 0), I_SGT => (To_Unbounded_String("SGT"), 16#8208#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_PC, 0), I_SKP => (To_Unbounded_String("SKP"), 16#6700#, 16#ff00#, 1, IO_TEST_DEV_FMT, NOVA_IO, 0), I_SNB => (To_Unbounded_String("SNB"), 16#85f8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_PC, 0), I_SNOVR => (To_Unbounded_String("SNOVR"), 16#a7b9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_PC, 0), I_SPSR => (To_Unbounded_String("SPSR"), 16#a7a9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_SPTE => (To_Unbounded_String("SPTE"), 16#e729#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_SSPT => (To_Unbounded_String("SSPT"), 16#e7d9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_STA => (To_Unbounded_String("STA"), 16#4000#, 16#e000#, 1, NOVA_ONEACC_EFF_ADDR_FMT, NOVA_MEMREF, 0), I_STAFP => (To_Unbounded_String("STAFP"), 16#c679#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_STASB => (To_Unbounded_String("STASB"), 16#c659#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_STASL => (To_Unbounded_String("STASL"), 16#a679#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_STASP => (To_Unbounded_String("STASP"), 16#a659#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_STATS => (To_Unbounded_String("STATS"), 16#8659#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_STB => (To_Unbounded_String("STB"), 16#8608#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_MEMREF, 0), I_SUB => (To_Unbounded_String("SUB"), 16#8500#, 16#8700#, 1, NOVA_TWOACC_MULT_OP_FMT, NOVA_OP, 0), I_SZB => (To_Unbounded_String("SZB"), 16#8488#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_PC, 0), I_SZBO => (To_Unbounded_String("SZBO"), 16#84c8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_PC, 0), I_WADC => (To_Unbounded_String("WADC"), 16#8249#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WADD => (To_Unbounded_String("WADD"), 16#8149#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WADDI => (To_Unbounded_String("WADDI"), 16#8689#, 16#e7ff#, 3, ONEACC_IMM_3_WORD_FMT, EAGLE_OP, 0), I_WADI => (To_Unbounded_String("WADI"), 16#84b9#, 16#87ff#, 1, IMM_ONEACC_FMT, EAGLE_OP, 0), I_WANC => (To_Unbounded_String("WANC"), 16#8549#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WAND => (To_Unbounded_String("WAND"), 16#8449#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WANDI => (To_Unbounded_String("WANDI"), 16#8699#, 16#e7ff#, 3, ONEACC_IMMDWD_3_WORD_FMT, EAGLE_OP, 0), I_WASH => (To_Unbounded_String("WASH"), 16#8279#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WASHI => (To_Unbounded_String("WASHI"), 16#c6a9#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_OP, 0), I_WBLM => (To_Unbounded_String("WBLM"), 16#e749#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_MEMREF, 0), I_WBR => (To_Unbounded_String("WBR"), 16#8038#, 16#843f#, 1, SPLIT_8BIT_DISP_FMT, EAGLE_PC, 0), I_WBTO => (To_Unbounded_String("WBTO"), 16#8299#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_MEMREF, 0), I_WBTZ => (To_Unbounded_String("WBTZ"), 16#82a9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_MEMREF, 0), I_WCLM => (To_Unbounded_String("WCLM"), 16#8569#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WCMP => (To_Unbounded_String("WCMP"), 16#a759#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_MEMREF, 0), I_WCMV => (To_Unbounded_String("WCMV"), 16#8779#, 16#FFFF#, 1, UNIQUE_1_WORD_FMT, EAGLE_MEMREF, 0), I_WCOM => (To_Unbounded_String("WCOM"), 16#8459#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WCST => (To_Unbounded_String("WCST"), 16#e709#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_MEMREF, 0), I_WCTR => (To_Unbounded_String("WCTR"), 16#8769#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_MEMREF, 0), I_WDecOp => (To_Unbounded_String("WDecOp"), 16#8719#, 16#ffff#, 2, WIDE_DEC_SPECIAL_FMT, EAGLE_DECIMAL, 1), I_WDIV => (To_Unbounded_String("WDIV"), 16#8179#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WDIVS => (To_Unbounded_String("WDIVS"), 16#e769#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_WFFAD => (To_Unbounded_String("WFFAD"), 16#8499#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_FPU, 0), I_WFLAD => (To_Unbounded_String("WFLAD"), 16#84a9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_FPU, 0), I_WFPOP => (To_Unbounded_String("WFPOP"), 16#a789#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_STACK, 0), I_WFPSH => (To_Unbounded_String("WFPSH"), 16#87b9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_STACK, 0), I_WHLV => (To_Unbounded_String("WHLV"), 16#e659#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_OP, 0), I_WINC => (To_Unbounded_String("WINC"), 16#8259#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WIOR => (To_Unbounded_String("WIOR"), 16#8469#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WIORI => (To_Unbounded_String("WIORI"), 16#86a9#, 16#e7ff#, 3, ONEACC_IMMDWD_3_WORD_FMT, EAGLE_OP, 0), I_WLDAI => (To_Unbounded_String("WLDAI"), 16#c689#, 16#e7ff#, 3, ONEACC_IMMDWD_3_WORD_FMT, EAGLE_OP, 0), I_WLDB => (To_Unbounded_String("WLDB"), 16#8529#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_MEMREF, 0), I_WLDI => (To_Unbounded_String("WLDI"), 16#e679#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_FPU, 0), I_WLMP => (To_Unbounded_String("WLMP"), 16#a7f9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_IO, 0), I_WLSH => (To_Unbounded_String("WLSH"), 16#8559#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WLSHI => (To_Unbounded_String("WLSHI"), 16#e6d9#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_OP, 0), I_WLSI => (To_Unbounded_String("WLSI"), 16#85b9#, 16#87ff#, 1, IMM_ONEACC_FMT, EAGLE_OP, 0), I_WMESS => (To_Unbounded_String("WMESS"), 16#e719#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_PC, 0), I_WMOV => (To_Unbounded_String("WMOV"), 16#8379#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WMOVR => (To_Unbounded_String("WMOVR"), 16#e699#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_OP, 0), I_WMSP => (To_Unbounded_String("WMSP"), 16#e649#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_STACK, 0), I_WMUL => (To_Unbounded_String("WMUL"), 16#8169#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WMULS => (To_Unbounded_String("WMULS"), 16#e759#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_OP, 0), I_WNADI => (To_Unbounded_String("WNADI"), 16#e6f9#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_OP, 0), I_WNEG => (To_Unbounded_String("WNEG"), 16#8269#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WPOP => (To_Unbounded_String("WPOP"), 16#8089#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_STACK, 0), I_WPOPB => (To_Unbounded_String("WPOPB"), 16#e779#, 16#FFFF#, 1, UNIQUE_1_WORD_FMT, EAGLE_STACK, 0), I_WPOPJ => (To_Unbounded_String("WPOPJ"), 16#8789#, 16#FFFF#, 1, UNIQUE_1_WORD_FMT, EAGLE_STACK, 0), I_WPSH => (To_Unbounded_String("WPSH"), 16#8579#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_STACK, 0), I_WRTN => (To_Unbounded_String("WRTN"), 16#87a9#, 16#ffff#, 1, UNIQUE_1_WORD_FMT, EAGLE_STACK, 0), I_WSANA => (To_Unbounded_String("WSANA"), 16#a689#, 16#e7ff#, 3, ONEACC_IMM_3_WORD_FMT, EAGLE_PC, 0), I_WSAVR => (To_Unbounded_String("WSAVR"), 16#A729#, 16#FFFF#, 2, UNIQUE_2_WORD_FMT, EAGLE_STACK, 0), I_WSAVS => (To_Unbounded_String("WSAVS"), 16#A739#, 16#FFFF#, 2, UNIQUE_2_WORD_FMT, EAGLE_STACK, 0), I_WSBI => (To_Unbounded_String("WSBI"), 16#8589#, 16#87ff#, 1, IMM_ONEACC_FMT, EAGLE_OP, 0), I_WSEQ => (To_Unbounded_String("WSEQ"), 16#80b9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WSEQI => (To_Unbounded_String("WSEQI"), 16#e6c9#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_PC, 0), I_WSGE => (To_Unbounded_String("WSGE"), 16#8199#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WSGT => (To_Unbounded_String("WSGT"), 16#81b9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WSGTI => (To_Unbounded_String("WSGTI"), 16#e689#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_PC, 0), I_WSKBO => (To_Unbounded_String("WSKBO"), 16#8f49#, 16#8fcf#, 1, WSKB_FMT, EAGLE_PC, 0), I_WSKBZ => (To_Unbounded_String("WSKBZ"), 16#8f89#, 16#8fcf#, 1, WSKB_FMT, EAGLE_PC, 0), I_WSLE => (To_Unbounded_String("WSLE"), 16#81a9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WSLEI => (To_Unbounded_String("WSLEI"), 16#e6a9#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_PC, 0), I_WSLT => (To_Unbounded_String("WSLT"), 16#8289#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WSNB => (To_Unbounded_String("WSNB"), 16#8389#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WSNE => (To_Unbounded_String("WSNE"), 16#8189#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WSNEI => (To_Unbounded_String("WSNEI"), 16#e6e9#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, EAGLE_PC, 0), I_WSSVR => (To_Unbounded_String("WSSVR"), 16#8729#, 16#ffff#, 2, UNIQUE_2_WORD_FMT, EAGLE_STACK, 0), I_WSSVS => (To_Unbounded_String("WSSVS"), 16#8739#, 16#ffff#, 2, UNIQUE_2_WORD_FMT, EAGLE_STACK, 0), I_WSTB => (To_Unbounded_String("WSTB"), 16#8539#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_MEMREF, 0), I_WSTI => (To_Unbounded_String("WSTI"), 16#e6b9#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, EAGLE_FPU, 0), I_WSUB => (To_Unbounded_String("WSUB"), 16#8159#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WSZB => (To_Unbounded_String("WSZB"), 16#82b9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WSZBO => (To_Unbounded_String("WSZBO"), 16#8399#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WUSGE => (To_Unbounded_String("WUSGE"), 16#8099#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WUSGT => (To_Unbounded_String("WUSGT"), 16#80a9#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_PC, 0), I_WUGTI => (To_Unbounded_String("WUGTI"), 16#c699#, 16#e7ff#, 3, ONEACC_IMM_3_WORD_FMT, EAGLE_PC, 0), I_WULEI => (To_Unbounded_String("WULEI"), 16#c6b9#, 16#e7ff#, 3, ONEACC_IMM_3_WORD_FMT, EAGLE_PC, 0), I_WXCH => (To_Unbounded_String("WXCH"), 16#8369#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WXOR => (To_Unbounded_String("WXOR"), 16#8479#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0), I_WXORI => (To_Unbounded_String("WXORI"), 16#86b9#, 16#e7ff#, 3, ONEACC_IMM_3_WORD_FMT, EAGLE_OP, 0), I_XCALL => (To_Unbounded_String("XCALL"), 16#8609#, 16#e7ff#, 3, NOACC_MODE_IND_3_WORD_XCALL_FMT, EAGLE_PC, 1), I_XCH => (To_Unbounded_String("XCH"), 16#81c8#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_XCT => (To_Unbounded_String("XCT"), 16#a6f8#, 16#e7ff#, 1, ONEACC_1_WORD_FMT, ECLIPSE_OP, 0), I_XFAMD => (To_Unbounded_String("XFAMD"), 16#8019#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XFAMS => (To_Unbounded_String("XFAMS"), 16#8009#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XFDMS => (To_Unbounded_String("XFDMS"), 16#8129#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XFLDD => (To_Unbounded_String("XFLDD"), 16#8219#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XFLDS => (To_Unbounded_String("XFLDS"), 16#8209#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XFMMD => (To_Unbounded_String("XFMMD"), 16#8039#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XFMMS => (To_Unbounded_String("XFMMS"), 16#8029#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XFSTD => (To_Unbounded_String("XFSTD"), 16#8239#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XFSTS => (To_Unbounded_String("XFSTS"), 16#8229#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_FPU, 0), I_XJMP => (To_Unbounded_String("XJMP"), 16#c609#, 16#e7ff#, 2, NOACC_MODE_IND_2_WORD_X_FMT, EAGLE_PC, 1), I_XJSR => (To_Unbounded_String("XJSR"), 16#c619#, 16#e7ff#, 2, NOACC_MODE_IND_2_WORD_X_FMT, EAGLE_PC, 1), I_XLDB => (To_Unbounded_String("XLDB"), 16#8419#, 16#87ff#, 2, ONEACC_MODE_2_WORD_X_B_FMT, EAGLE_MEMREF, 1), I_XLEF => (To_Unbounded_String("XLEF"), 16#8409#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XLEFB => (To_Unbounded_String("XLEFB"), 16#8439#, 16#87ff#, 2, ONEACC_MODE_2_WORD_X_B_FMT, EAGLE_MEMREF, 1), I_XNADD => (To_Unbounded_String("XNADD"), 16#8018#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XNADI => (To_Unbounded_String("XNADI"), 16#8418#, 16#87ff#, 2, IMM_MODE_2_WORD_FMT, EAGLE_MEMREF, 1), I_XNDO => (To_Unbounded_String("XNDO"), 16#8498#, 16#87ff#, 3, THREE_WORD_DO_FMT, EAGLE_PC, 1), I_XNDSZ => (To_Unbounded_String("XNDSZ"), 16#a609#, 16#e7ff#, 2, NOACC_MODE_IND_2_WORD_X_FMT, EAGLE_PC, 1), I_XNISZ => (To_Unbounded_String("XNISZ"), 16#8639#, 16#e7ff#, 2, NOACC_MODE_IND_2_WORD_X_FMT, EAGLE_PC, 1), I_XNLDA => (To_Unbounded_String("XNLDA"), 16#8329#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XNMUL => (To_Unbounded_String("XNMUL"), 16#8098#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XNSBI => (To_Unbounded_String("XNSBI"), 16#8458#, 16#87ff#, 2, IMM_MODE_2_WORD_FMT, EAGLE_MEMREF, 1), I_XNSTA => (To_Unbounded_String("XNSTA"), 16#8339#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XNSUB => (To_Unbounded_String("XNSUB"), 16#8058#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XOR => (To_Unbounded_String("XOR"), 16#8148#, 16#87ff#, 1, TWOACC_1_WORD_FMT, ECLIPSE_OP, 0), I_XORI => (To_Unbounded_String("XORI"), 16#a7f8#, 16#e7ff#, 2, ONEACC_IMM_2_WORD_FMT, ECLIPSE_OP, 0), I_XPEF => (To_Unbounded_String("XPEF"), 16#8629#, 16#e7ff#, 2, NOACC_MODE_IND_2_WORD_X_FMT, EAGLE_STACK, 1), I_XPEFB => (To_Unbounded_String("XPEFB"), 16#a629#, 16#e7ff#, 2, NOACC_MODE_2_WORD_FMT, EAGLE_STACK, 1), I_XPSHJ => (To_Unbounded_String("XPSHJ"), 16#8619#, 16#e7ff#, 2, IMM_MODE_2_WORD_FMT, EAGLE_STACK, 1), I_XSTB => (To_Unbounded_String("XSTB"), 16#8429#, 16#87ff#, 2, ONEACC_MODE_2_WORD_X_B_FMT, EAGLE_MEMREF, 1), I_XWADD => (To_Unbounded_String("XWADD"), 16#8118#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XWADI => (To_Unbounded_String("XWADI"), 16#8518#, 16#87ff#, 2, IMM_MODE_2_WORD_FMT, EAGLE_MEMREF, 1), I_XWDIV => (To_Unbounded_String("XWDIV"), 16#81d8#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XWDO => (To_Unbounded_String("XWDO"), 16#8598#, 16#87ff#, 3, THREE_WORD_DO_FMT, EAGLE_PC, 1), I_XWDSZ => (To_Unbounded_String("XWDSZ"), 16#A639#, 16#e7FF#, 2, NOACC_MODE_IND_2_WORD_X_FMT, EAGLE_PC, 1), I_XWISZ => (To_Unbounded_String("XWISZ"), 16#a619#, 16#e7ff#, 2, NOACC_MODE_IND_2_WORD_X_FMT, EAGLE_PC, 1), I_XWLDA => (To_Unbounded_String("XWLDA"), 16#8309#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XWMUL => (To_Unbounded_String("XWMUL"), 16#8198#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XWSBI => (To_Unbounded_String("XWSBI"), 16#8558#, 16#87ff#, 2, IMM_MODE_2_WORD_FMT, EAGLE_MEMREF, 1), I_XWSTA => (To_Unbounded_String("XWSTA"), 16#8319#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_XWSUB => (To_Unbounded_String("XWSUB"), 16#8158#, 16#87ff#, 2, ONEACC_MODE_IND_2_WORD_X_FMT, EAGLE_MEMREF, 1), I_ZEX => (To_Unbounded_String("ZEX"), 16#8359#, 16#87ff#, 1, TWOACC_1_WORD_FMT, EAGLE_OP, 0) ); end CPU_Instructions;
-- -- aPLib compression library - the smaller the better :) -- -- Ada binding for aplib.a -- -- Copyright (c) 1998-2009 by Joergen Ibsen / Jibz -- All Rights Reserved -- -- http://www.ibsensoftware.com/ -- -- Ada binding by Gautier de Montmollin - gdemont@hotmail.com, gdm@mydiax.ch -- package aPLib is -- Give the maximum "packed" size possible - it can be more than -- the unpacked size in case of uncompressible data: function Evaluate_max_packed_space( unpacked_size: Integer ) return Integer; pragma Import(C, Evaluate_max_packed_space, "aP_max_packed_size"); -- Was, before v0.34 b4: (((unpacked_size * 9) / 8) + 16) -- A template for packing data: generic type packed_data is private; type unpacked_data is private; with procedure Call_back( unpacked_bytes, packed_bytes: in integer; continue : out boolean ); procedure Pack( source : in unpacked_data; destination : out packed_data; packed_length: out integer ); -- A template for unpacking data: generic type packed_data is private; type unpacked_data is private; procedure Depack( source : in packed_data; destination: out unpacked_data ); -- Exceptions for errors that could occur: pack_failed, unpack_failed: exception; -- Just for information function aP_workmem_size(inputsize: integer) return integer; pragma Import(C, aP_workmem_size, "aP_workmem_size"); end aPLib;
package body Generic_Types with SPARK_Mode is ------------------------ -- Saturated_Cast_Int ------------------------ function Saturated_Cast_Int (f : Float) return T is ret : T; ff : constant Float := Float'Floor (f); begin if ff >= Float (T'Last) then ret := T'Last; elsif ff < Float (T'First) then ret := T'First; else ret := T (ff); end if; return ret; end Saturated_Cast_Int; ------------------------ -- Saturated_Cast_Mod ------------------------ function Saturated_Cast_Mod (f : Float) return T is ret : T; ff : constant Float := Float'Floor (f); begin if ff >= Float (T'Last) then ret := T'Last; elsif ff < Float (T'First) then ret := T'First; else ret := T (ff); end if; return ret; end Saturated_Cast_Mod; ------------------ -- Saturate_Mod ------------------ function Saturate_Mod (val : T; min : T; max : T) return T is ret : T; begin if val < min then ret := min; elsif val > max then ret := max; else ret := val; end if; return ret; end Saturate_Mod; end Generic_Types;
------------------------------------------------------------------------------ -- -- -- Giza -- -- -- -- Copyright (C) 2015 Fabien Chouteau (chouteau@adacore.com) -- -- -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Giza.Timers; package body Giza.Widget.Scrolling is --------------- -- Triggered -- --------------- overriding function Triggered (This : Repeat_Event) return Boolean is Reset : Boolean := False; begin if This.Scroll = null then return False; end if; if This.Scroll.Up.Active then Reset := True; This.Scroll.Go_Up; elsif This.Scroll.Down.Active then Reset := True; This.Scroll.Go_Down; end if; if Reset then -- Reset timer Giza.Timers.Set_Timer (This'Unchecked_Access, Clock + This.Scroll.Repeat_Time); end if; return Reset; end Triggered; --------------- -- Set_Dirty -- --------------- overriding procedure Set_Dirty (This : in out Instance; Dirty : Boolean := True) is begin Set_Dirty (Parent (This), Dirty); This.Up.Set_Dirty (Dirty); This.Down.Set_Dirty (Dirty); if This.Child /= null then This.Child.Set_Dirty (Dirty); end if; end Set_Dirty; ---------- -- Draw -- ---------- overriding procedure Draw (This : in out Instance; Ctx : in out Context.Class; Force : Boolean := True) is begin if not This.Dirty and then not Force then return; end if; if This.Child /= null then Ctx.Save; Ctx.Set_Bounds (((0, 0), This.Get_Size)); Ctx.Save; Ctx.Translate (This.Child_Pos); This.Child.Draw (Ctx); Ctx.Restore; if This.Child_Pos.Y < 0 then Ctx.Save; This.Up.Draw (Ctx, True); Ctx.Restore; end if; if This.Child_Pos.Y > -(This.Child.Size.H - This.Get_Size.H) then Ctx.Save; Ctx.Translate ((0, This.Get_Size.H - This.Down.Get_Size.H)); This.Down.Draw (Ctx, True); Ctx.Restore; end if; Ctx.Restore; end if; end Draw; ----------------------- -- On_Position_Event -- ----------------------- overriding function On_Position_Event (This : in out Instance; Evt : Position_Event_Ref; Pos : Point_T) return Boolean is begin if This.Child /= null then if This.Child_Pos.Y < 0 and then Evt.Pos.Y < This.Up.Get_Size.H then if This.Up.On_Position_Event (Evt, Pos) and then This.Up.Active then This.Go_Up; Giza.Timers.Set_Timer (This.Repeat_Evt'Unchecked_Access, Clock + This.Repeat_Time); return True; end if; elsif This.Child_Pos.Y > -(This.Child.Size.H - This.Get_Size.H) and then Evt.Pos.Y > This.Get_Size.H - This.Up.Get_Size.H then if This.Down.On_Position_Event (Evt, Pos - (0, This.Get_Size.H - This.Up.Get_Size.H)) and then This.Down.Active then This.Go_Down; This.Repeat_Evt.Scroll := This'Unchecked_Access; Giza.Timers.Set_Timer (This.Repeat_Evt'Unchecked_Access, Clock + This.Repeat_Time); return True; end if; else return This.Child.On_Position_Event (Evt, Pos - This.Child_Pos); end if; end if; return False; end On_Position_Event; -------------- -- On_Event -- -------------- overriding function On_Event (This : in out Instance; Evt : Event_Not_Null_Ref) return Boolean is begin return (This.Child = null or else This.Child.On_Event (Evt)) or This.Up.On_Event (Evt) or This.Down.On_Event (Evt); end On_Event; --------------- -- Set_Child -- --------------- procedure Set_Child (This : in out Instance; Child : not null Widget.Reference) is begin This.Child := Child; This.Up.Set_Size ((This.Get_Size.W, This.Get_Size.H / 10)); This.Down.Set_Size ((This.Get_Size.W, This.Get_Size.H / 10)); end Set_Child; ----------- -- Go_Up -- ----------- procedure Go_Up (This : in out Instance) is begin if This.Child /= null then This.Child_Pos := This.Child_Pos + Size_T'(0, 5); if This.Child_Pos.Y > 0 then This.Child_Pos.Y := 0; end if; end if; end Go_Up; ------------- -- Go_Down -- ------------- procedure Go_Down (This : in out Instance) is begin if This.Child /= null then This.Child_Pos := This.Child_Pos - (0, 5); if This.Child_Pos.Y < This.Get_Size.H - This.Child.Get_Size.H then This.Child_Pos.Y := This.Get_Size.H - This.Child.Get_Size.H; end if; end if; end Go_Down; ------------- -- Go_Left -- ------------- procedure Go_Left (This : in out Instance) is begin if This.Child /= null then This.Child_Pos := This.Child_Pos + Size_T'(5, 0); if This.Child_Pos.X > 0 then This.Child_Pos.X := 0; end if; end if; end Go_Left; -------------- -- Go_Right -- -------------- procedure Go_Right (This : in out Instance) is begin if This.Child /= null then This.Child_Pos := This.Child_Pos - (5, 0); if This.Child_Pos.X < (This.Get_Size.W - This.Child.Get_Size.W) then This.Child_Pos.X := (This.Get_Size.W - This.Child.Get_Size.W); end if; end if; end Go_Right; end Giza.Widget.Scrolling;
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Core -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- 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 copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; with Ada.Assertions; with Workers; with Registrar.Registry; with Registrar.Executive.Unit_Entry; with Registrar.Registration.Unchecked_Deregister_Unit; package body Registrar.Registration is -- -- All Enter_Units simply fill and submit Work_Orders to the worker pool -- ---------------- -- Enter_Unit -- ---------------- procedure Set_File_Name (Order: out Executive.Unit_Entry.Unit_Entry_Order; File : in Ada.Directories.Directory_Entry_Type) is begin Executive.Unit_Entry.UBS.Set_Unbounded_String (Target => Order.File_Full_Name, Source => Ada.Directories.Full_Name (File)); end Set_File_Name; ---------------------------------------------------------------------------- -- Non-AURA units procedure Enter_Unit (File: in Ada.Directories.Directory_Entry_Type) is Order: Executive.Unit_Entry.Unit_Entry_Order := (Tracker => Entry_Progress'Access, AURA => False, others => <>); begin Set_File_Name (Order => Order, File => File); Entry_Progress.Increment_Total_Items; Workers.Enqueue_Order (Order); end Enter_Unit; ---------------------------------------------------------------------------- -- AURA units procedure Enter_Unit (File : in Ada.Directories.Directory_Entry_Type; AURA_Subsystem: in Registrar.Subsystems.Subsystem) is Order: Executive.Unit_Entry.Unit_Entry_Order := (Tracker => Entry_Progress'Access, AURA => True, AURA_Subsystem => AURA_Subsystem, others => <>); begin Set_File_Name (Order => Order, File => File); Entry_Progress.Increment_Total_Items; Workers.Enqueue_Order (Order); end Enter_Unit; --------------------- -- Enter_Directory -- --------------------- procedure Enter_Directory (Directory_Path: in String; Order_Template: in Executive.Unit_Entry.Unit_Entry_Order) is use Ada.Directories; Search: Search_Type; File : Directory_Entry_Type; Order: Executive.Unit_Entry.Unit_Entry_Order := Order_Template; procedure Enter_Extension (Extension: in String) is begin Start_Search (Search => Search, Directory => Directory_Path, Pattern => "*." & Extension, Filter => (Ordinary_File => True, others => False)); while More_Entries (Search) loop Get_Next_Entry (Search => Search, Directory_Entry => File); Set_File_Name (Order, File); Entry_Progress.Increment_Total_Items; Workers.Enqueue_Order (Order); end loop; End_Search (Search); end Enter_Extension; begin Order.Tracker := Entry_Progress'Access; Enter_Extension ("ads"); Enter_Extension ("adb"); Enter_Extension ("c"); end Enter_Directory; -------------------------------------------------- procedure Enter_Directory (Directory : in Ada.Directories.Directory_Entry_Type; AURA_Subsystem: in Subsystems.Subsystem) is use Ada.Directories; begin Enter_Directory (Directory_Path => Full_Name (Directory), Order_Template => (AURA => True, AURA_Subsystem => AURA_Subsystem, others => <>)); end Enter_Directory; ---------------- -- Enter_Root -- ---------------- procedure Enter_Root is use Ada.Directories; begin Enter_Directory (Directory_Path => Full_Name (Current_Directory), Order_Template => (AURA => False, others => <>)); end Enter_Root; ---------------------------- -- Request_AURA_Subsystem -- ---------------------------- procedure Request_AURA_Subsystem (Name: in Unit_Names.Unit_Name; OK : out Boolean) is use Subsystems; package All_Subsystems renames Registry.All_Subsystems; Requested_Subsys: constant Subsystem := (AURA => True, Name => Name.Subsystem_Name, State => Requested, others => <>); begin if All_Subsystems.Contains_Element (Requested_Subsys) then OK := All_Subsystems.Extract_Element(Requested_Subsys).AURA; -- The registry already contains this subsystem. If it is not AURA -- then that means the Root Project is already claiming this subsystem, -- and therefore we can't aquire it. -- -- Otherwise it's already been requested or aquired, and so no action -- needs to be taken else -- Add it All_Subsystems.Insert (New_Item => Requested_Subsys, Inserted => OK); pragma Assert (OK); -- There are no cases where OK should be False. First of all, we -- have already determined that it doesn't already exist in the set. -- So if OK is False, this should mean it was inserted sometime between -- that check and our attempt. That shouldn't happen because -- Request_AURA_Subsystem should only be called from the CLI driver -- before any work orders are executing. end if; end Request_AURA_Subsystem; ---------------------- -- Update_Subsystem -- ---------------------- procedure Update_Subsystem (Update: Subsystems.Subsystem) is begin Registry.All_Subsystems.Replace (Update); end Update_Subsystem; ------------------------- -- Update_Library_Unit -- ------------------------- procedure Update_Library_Unit (Update: in Library_Units.Library_Unit) is begin Registry.All_Library_Units.Replace (Update); end Update_Library_Unit; -------------------------------- -- Update_Library_Unit_Subset -- -------------------------------- procedure Update_Library_Unit_Subset (Update: in Library_Units.Library_Unit_Sets.Set) is begin if not Registry.All_Library_Units.Is_Subset (Update) then raise Constraint_Error with "Update_Library_Unit_Subset cannot add new units"; end if; Registry.All_Library_Units.Include_Subset (Update); end Update_Library_Unit_Subset; ----------------------- -- Exclude_Manifests -- ----------------------- procedure Exclude_Manifests is use Unit_Names; use Library_Units; Manifest: Library_Unit; begin for Subsys of Registry.All_Subsystems.Extract_Set loop Manifest.Name := Subsys.Name & ".aura"; if Registry.All_Library_Units.Contains_Element (Manifest) then Manifest := Registry.All_Library_Units.Extract_Element (Manifest); Registrar.Registration.Unchecked_Deregister_Unit (Manifest); end if; end loop; end Exclude_Manifests; end Registrar.Registration;
-- { dg-do run } -- { dg-options "-gnatp" } procedure Lhs_View_Convert is type Root is tagged record RV : Natural; end record; type Derived is new Root with null record; Root_Instance : Root := (RV => 1); Derived_Instance : Derived; procedure Process is X : Natural := Derived_Instance.RV; begin null; end; begin Derived_Instance.RV := 2; Root (Derived_Instance) := Root (Root_Instance); if Derived_Instance.RV /= Root_Instance.RV then raise Program_Error; end if; end;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M L I B . U T L -- -- -- -- S p e c -- -- -- -- Copyright (C) 2001-2008, 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. 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. -- -- -- ------------------------------------------------------------------------------ -- This package provides an easy way of calling various tools such as gcc, -- ar, etc... package MLib.Utl is procedure Delete_File (Filename : String); -- Delete the file Filename and output the name of the deleted file in -- verbose mode. procedure Gcc (Output_File : String; Objects : Argument_List; Options : Argument_List; Options_2 : Argument_List; Driver_Name : Name_Id := No_Name); -- Driver_Name indicates the "driver" to invoke; by default, the "driver" -- is gcc. This procedure invokes the driver to create a shared library. -- Options are passed to gcc before the objects, Options_2 after. -- Output_File is the name of the library file to create. Objects are the -- names of the object files to put in the library. procedure Ar (Output_File : String; Objects : Argument_List); -- Run ar to move all the binaries inside the archive. If ranlib is on -- the path, run it also. Output_File is the path name of the archive to -- create. Objects is the list of the path names of the object files to be -- put in the archive. This procedure currently assumes that it is always -- called in the context of gnatmake. If other executables start using this -- procedure, an additional parameter would need to be added, and calls to -- Osint.Program_Name updated accordingly in the body. function Lib_Directory return String; -- Return the directory containing libgnat procedure Specify_Adalib_Dir (Path : String); -- Specify the path of the GNAT adalib directory, to be returned by -- function Lib_Directory without looking for it. This is used only in -- gprlib, because we cannot rely on the search in Lib_Directory, as the -- GNAT version may be different for gprbuild/gprlib and the compiler. end MLib.Utl;
-- Standard Ada library specification -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- generic type Cursor; with function Has_Element (Position : Cursor) return Boolean; package Ada.Iterator_Interfaces is pragma Pure (Iterator_Interfaces); type Forward_Iterator is limited interface; function First (Object : Forward_Iterator) return Cursor is abstract; function Next (Object : Forward_Iterator; Position : Cursor) return Cursor is abstract; type Reversible_Iterator is limited interface and Forward_Iterator; function Last (Object : Reversible_Iterator) return Cursor is abstract; function Previous (Object : Reversible_Iterator; Position : Cursor) return Cursor is abstract; end Ada.Iterator_Interfaces;
package formal_procedure_declaration is generic with procedure Put_Line; procedure SS_Info; end formal_procedure_declaration;
package Aliasing with SPARK_Mode => On is type Rec is record F, G : Integer; end Record; procedure Multiply (X, Y : in Rec; Z : out Rec); procedure Test; end Aliasing;
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package ia32intrin_h is -- Copyright (C) 2009-2017 Free Software Foundation, Inc. -- This file is part of GCC. -- GCC is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- GCC is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- 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/>. -- 32bit bsf -- skipped func __bsfd -- 32bit bsr -- skipped func __bsrd -- 32bit bswap -- skipped func __bswapd -- 32bit accumulate CRC32 (polynomial 0x11EDC6F41) value. -- skipped func __crc32b -- skipped func __crc32w -- skipped func __crc32d -- 32bit popcnt -- skipped func __popcntd -- rdpmc -- skipped func __rdpmc -- rdtsc -- skipped func __rdtsc -- rdtscp -- skipped func __rdtscp -- 8bit rol -- skipped func __rolb -- 16bit rol -- skipped func __rolw -- 32bit rol -- skipped func __rold -- 8bit ror -- skipped func __rorb -- 16bit ror -- skipped func __rorw -- 32bit ror -- skipped func __rord -- Pause -- skipped func __pause -- 64bit bsf -- skipped func __bsfq -- 64bit bsr -- skipped func __bsrq -- 64bit bswap -- skipped func __bswapq -- 64bit accumulate CRC32 (polynomial 0x11EDC6F41) value. -- skipped func __crc32q -- 64bit popcnt -- skipped func __popcntq -- 64bit rol -- skipped func __rolq -- 64bit ror -- skipped func __rorq -- Read flags register -- skipped func __readeflags -- Write flags register -- skipped func __writeeflags -- Read flags register -- Write flags register -- On LP64 systems, longs are 64-bit. Use the appropriate rotate -- * function. end ia32intrin_h;
with FLTK.Widgets.Inputs; package FLTK.Widgets.Valuators.Value_Inputs is type Value_Input is new Valuator with private; type Value_Input_Reference (Data : not null access Value_Input'Class) is limited null record with Implicit_Dereference => Data; package Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Value_Input; end Forge; function Input (This : in Value_Input) return FLTK.Widgets.Inputs.Input_Reference; function Get_Cursor_Color (This : in Value_Input) return Color; procedure Set_Cursor_Color (This : in out Value_Input; Col : in Color); function Get_Shortcut (This : in Value_Input) return Key_Combo; procedure Set_Shortcut (This : in out Value_Input; Key : in Key_Combo); function Is_Soft (This : in Value_Input) return Boolean; procedure Set_Soft (This : in out Value_Input; To : in Boolean); function Get_Text_Color (This : in Value_Input) return Color; procedure Set_Text_Color (This : in out Value_Input; Col : in Color); function Get_Text_Font (This : in Value_Input) return Font_Kind; procedure Set_Text_Font (This : in out Value_Input; Font : in Font_Kind); function Get_Text_Size (This : in Value_Input) return Font_Size; procedure Set_Text_Size (This : in out Value_Input; Size : in Font_Size); procedure Draw (This : in out Value_Input); function Handle (This : in out Value_Input; Event : in Event_Kind) return Event_Outcome; private package INP renames FLTK.Widgets.Inputs; type Input_Access is access INP.Input; type Value_Input is new Valuator with record My_Input : Input_Access; end record; overriding procedure Finalize (This : in out Value_Input); pragma Inline (Input); pragma Inline (Get_Cursor_Color); pragma Inline (Set_Cursor_Color); pragma Inline (Get_Shortcut); pragma Inline (Set_Shortcut); pragma Inline (Is_Soft); pragma Inline (Set_Soft); pragma Inline (Get_Text_Color); pragma Inline (Set_Text_Color); pragma Inline (Get_Text_Font); pragma Inline (Set_Text_Font); pragma Inline (Get_Text_Size); pragma Inline (Set_Text_Size); pragma Inline (Draw); pragma Inline (Handle); end FLTK.Widgets.Valuators.Value_Inputs;
with Interfaces.C.Strings, System; use type System.Address; package body FLTK.Widgets.Valuators.Counters is procedure counter_set_draw_hook (W, D : in System.Address); pragma Import (C, counter_set_draw_hook, "counter_set_draw_hook"); pragma Inline (counter_set_draw_hook); procedure counter_set_handle_hook (W, H : in System.Address); pragma Import (C, counter_set_handle_hook, "counter_set_handle_hook"); pragma Inline (counter_set_handle_hook); function new_fl_counter (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) return System.Address; pragma Import (C, new_fl_counter, "new_fl_counter"); pragma Inline (new_fl_counter); procedure free_fl_counter (A : in System.Address); pragma Import (C, free_fl_counter, "free_fl_counter"); pragma Inline (free_fl_counter); function fl_counter_get_step (C : in System.Address) return Interfaces.C.double; pragma Import (C, fl_counter_get_step, "fl_counter_get_step"); pragma Inline (fl_counter_get_step); procedure fl_counter_set_step (C : in System.Address; T : in Interfaces.C.double); pragma Import (C, fl_counter_set_step, "fl_counter_set_step"); pragma Inline (fl_counter_set_step); procedure fl_counter_set_lstep (C : in System.Address; T : in Interfaces.C.double); pragma Import (C, fl_counter_set_lstep, "fl_counter_set_lstep"); pragma Inline (fl_counter_set_lstep); function fl_counter_get_textcolor (C : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_counter_get_textcolor, "fl_counter_get_textcolor"); pragma Inline (fl_counter_get_textcolor); procedure fl_counter_set_textcolor (C : in System.Address; T : in Interfaces.C.unsigned); pragma Import (C, fl_counter_set_textcolor, "fl_counter_set_textcolor"); pragma Inline (fl_counter_set_textcolor); function fl_counter_get_textfont (C : in System.Address) return Interfaces.C.int; pragma Import (C, fl_counter_get_textfont, "fl_counter_get_textfont"); pragma Inline (fl_counter_get_textfont); procedure fl_counter_set_textfont (C : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_counter_set_textfont, "fl_counter_set_textfont"); pragma Inline (fl_counter_set_textfont); function fl_counter_get_textsize (C : in System.Address) return Interfaces.C.int; pragma Import (C, fl_counter_get_textsize, "fl_counter_get_textsize"); pragma Inline (fl_counter_get_textsize); procedure fl_counter_set_textsize (C : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_counter_set_textsize, "fl_counter_set_textsize"); pragma Inline (fl_counter_set_textsize); procedure fl_counter_draw (W : in System.Address); pragma Import (C, fl_counter_draw, "fl_counter_draw"); pragma Inline (fl_counter_draw); function fl_counter_handle (W : in System.Address; E : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_counter_handle, "fl_counter_handle"); pragma Inline (fl_counter_handle); procedure Finalize (This : in out Counter) is begin if This.Void_Ptr /= System.Null_Address and then This in Counter'Class then free_fl_counter (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; Finalize (Valuator (This)); end Finalize; package body Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Counter is begin return This : Counter do This.Void_Ptr := new_fl_counter (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.To_C (Text)); fl_widget_set_user_data (This.Void_Ptr, Widget_Convert.To_Address (This'Unchecked_Access)); counter_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); counter_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); end return; end Create; end Forge; function Get_Step (This : in Counter) return Long_Float is begin return Long_Float (fl_counter_get_step (This.Void_Ptr)); end Get_Step; procedure Set_Step (This : in out Counter; To : in Long_Float) is begin fl_counter_set_step (This.Void_Ptr, Interfaces.C.double (To)); end Set_Step; function Get_Long_Step (This : in Counter) return Long_Float is begin return This.Long_Step; end Get_Long_Step; procedure Set_Long_Step (This : in out Counter; To : in Long_Float) is begin This.Long_Step := To; fl_counter_set_lstep (This.Void_Ptr, Interfaces.C.double (To)); end Set_Long_Step; function Get_Text_Color (This : in Counter) return Color is begin return Color (fl_counter_get_textcolor (This.Void_Ptr)); end Get_Text_Color; procedure Set_Text_Color (This : in out Counter; To : in Color) is begin fl_counter_set_textcolor (This.Void_Ptr, Interfaces.C.unsigned (To)); end Set_Text_Color; function Get_Text_Font (This : in Counter) return Font_Kind is begin return Font_Kind'Val (fl_counter_get_textfont (This.Void_Ptr)); end Get_Text_Font; procedure Set_Text_Font (This : in out Counter; To : in Font_Kind) is begin fl_counter_set_textfont (This.Void_Ptr, Font_Kind'Pos (To)); end Set_Text_Font; function Get_Text_Size (This : in Counter) return Font_Size is begin return Font_Size (fl_counter_get_textsize (This.Void_Ptr)); end Get_Text_Size; procedure Set_Text_Size (This : in out Counter; To : in Font_Size) is begin fl_counter_set_textsize (This.Void_Ptr, Interfaces.C.int (To)); end Set_Text_Size; procedure Draw (This : in out Counter) is begin fl_counter_draw (This.Void_Ptr); end Draw; function Handle (This : in out Counter; Event : in Event_Kind) return Event_Outcome is begin return Event_Outcome'Val (fl_counter_handle (This.Void_Ptr, Event_Kind'Pos (Event))); end Handle; end FLTK.Widgets.Valuators.Counters;
----------------------------------------------------------------------- -- keystore-tools-tests -- Tests for files -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Util.Test_Caller; with Util.Strings; with Keystore.Files; package body Keystore.Tools.Tests is use Ada.Directories; use type Interfaces.Unsigned_64; package Caller is new Util.Test_Caller (Test, "Keystore.Tools"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Keystore.Files.Create+Open", Test_Store_Directory'Access); end Add_Tests; -- ------------------------------ -- Test storing a directory tree -- ------------------------------ procedure Test_Store_Directory (T : in out Test) is function Filter (Ent : in Directory_Entry_Type) return Boolean; function Filter (Ent : in Directory_Entry_Type) return Boolean is Name : constant String := Ada.Directories.Simple_Name (Ent); Kind : constant File_Kind := Ada.Directories.Kind (Ent); begin if Kind = Ada.Directories.Ordinary_File then return Util.Strings.Ends_With (Name, ".ads"); else return Name /= ".git" and Name /= "result"; end if; end Filter; Path : constant String := Util.Tests.Get_Test_Path ("regtests/result/test-store.akt"); Password : Keystore.Secret_Key := Keystore.Create ("mypassword"); Config : Keystore.Wallet_Config := Unsecure_Config; begin declare W : Keystore.Files.Wallet_File; begin Config.Overwrite := True; W.Create (Path => Path, Password => Password, Config => Config); Keystore.Tools.Store (Wallet => W, Path => ".", Prefix => "store/", Pattern => "*", Filter => Filter'Access); end; declare procedure Check (Name : in String); W : Keystore.Files.Wallet_File; procedure Check (Name : in String) is Item : Keystore.Entry_Info; begin Item := W.Find (Name); T.Assert (Item.Size > 8192, "Invalid item size for " & Name); T.Assert (Item.Size < 128 * 1024, "Invalid item size for " & Name); T.Assert (Item.Block_Count > 2, "Invalid item for " & Name); T.Assert (Item.Kind = T_FILE, "Invalid item type for " & Name); end Check; begin W.Open (Password => Password, Path => Path); Check ("store/src/keystore.ads"); Check ("store/src/keystore-repository.ads"); Check ("store/obj/b__akt-main.ads"); end; end Test_Store_Directory; end Keystore.Tools.Tests;
with TOML; package CLIC.Config.Load is procedure From_TOML (C : in out CLIC.Config.Instance; Origin : String; Path : String; Check : Check_Import := null); function Load_TOML_File (Path : String) return TOML.TOML_Value; end CLIC.Config.Load;
with Ada.Finalization; with Ada.Unchecked_Deallocation; with Atomic.Signed; generic type T (<>) is private; type T_Access is access T; package SP.Memory with Preelaborate is -- Atomic reference counting pointer. type Arc is new Ada.Finalization.Controlled with private; type Reference_Type (Element : access T) is limited null record with Implicit_Dereference => Element; type Reference_Count is new Integer; package Atomic_Integer is new Atomic.Signed (Reference_Count); function Make (Allocated : T_Access) return Arc with Post => Is_Valid (Make'Result); function Make_Null return Arc with Post => not Is_Valid (Make_Null'Result); function Is_Valid (Self : Arc) return Boolean; function Get (Self : Arc) return Reference_Type with Pre => Is_Valid (Self); procedure Reset (Self : aliased in out Arc) with Post => not Is_Valid (Self); -- Debugging function to get number of reference counts. function Count (Self : aliased in out Arc) return Reference_Count; overriding procedure Initialize (Self : in out Arc); overriding procedure Adjust (Self : in out Arc); overriding procedure Finalize (Self : in out Arc) with Post => not Is_Valid (Self); private -- The backing type which actually tracks the reference count, as well as -- tracking the value being pointed to. type Control_Block is limited record Value : T_Access := null; Count : aliased Atomic_Integer.Instance := Atomic_Integer.Init (0); end record; type Control_Block_Access is access Control_Block; type Arc is new Ada.Finalization.Controlled with record Block : Control_Block_Access := null; end record; procedure Free is new Ada.Unchecked_Deallocation (T, T_Access); procedure Free is new Ada.Unchecked_Deallocation (Control_Block, Control_Block_Access); end SP.Memory;
----------------------------------------------------------------------- -- echo_server -- A simple UDP echo server -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Net.Sockets.Udp; with Net.Buffers; package Echo_Server is type Message is record Id : Natural := 0; Content : String (1 .. 80) := (others => ' '); end record; type Message_List is array (1 .. 10) of Message; -- Logger that saves the message received by the echo UDP socket. protected type Logger is procedure Echo (Content : in Message); function Get return Message_List; private Id : Natural := 0; List : Message_List; end Logger; type Echo_Server is new Net.Sockets.Udp.Socket with record Count : Natural := 0; Messages : Logger; end record; overriding procedure Receive (Endpoint : in out Echo_Server; From : in Net.Sockets.Sockaddr_In; Packet : in out Net.Buffers.Buffer_Type); Server : aliased Echo_Server; end Echo_Server;
with Fann_C; with Interfaces.C.pointers; use Interfaces; private package Neural.Privvy is package fann_type_Pointers is new interfaces.c.Pointers (index => c.size_t, element => fann_c.fann_type, element_array => fann_c.fann_type_array, default_terminator => fann_c.fann_type'Last); procedure dummy; end Neural.Privvy;
with Ada.Strings.UTF_Encoding, Ada.Sequential_IO, Interfaces.C_Streams, Ada.Text_IO.Text_Streams, Ada.Streams.Stream_IO; use Ada.Strings.UTF_Encoding; -- Library to Encrypt raw data with variable length UTF8 Passwords, making -- it possible to simply memorize the Passwords as a poem or as random- -- length stored keys. zero to three Passwords may be specified. If none,.u -- then a default built in key is used for the encryption, but the longer -- and more Passwords their are the more impossible the encryption becomes -- to break. package Password_Encode is type Byte is mod 2**8; for Byte'Size use 8; type Byte7 is mod 2 ** 7; for Byte7'Size use 7; type Byte6 is mod 2 ** 6; for Byte6'Size use 6; type Byte5 is mod 2 ** 5; for Byte5'Size use 5; type Byte4 is mod 2 ** 4; for Byte4'Size use 4; type Byte3 is mod 2 ** 4; for Byte3'Size use 4; type Byte2 is mod 2 ** 2; for Byte2'Size use 4; type Byte1 is mod 2 ** 1; for Byte1'Size use 4; -- subtype Byte_Index is Integer range 1..57; type Bytes is array (Positive range <>) of Byte; type Bytes7 is array (Positive range <>) of Byte7; type Bytes6 is array (Positive range <>) of Byte6; type Bytes5 is array (Positive range <>) of Byte5; type Bytes4 is array (Positive range <>) of Byte4; type Bytes3 is array (Positive range <>) of Byte3; type Bytes2 is array (Positive range <>) of Byte2; type Bytes1 is array (Positive range <>) of Byte1; type Offset is mod 2**64; for Offset'Size use 64; type Offsets is array(Positive range <>) of Offset; -- **Modular codec is the primary codec that simply adds to the value of -- a six-bit unit, wrapping to zero again. **Low_Swap swaps two consecutive -- chunks starting at the beginning of the 76 six-bit units in a block. -- **Incrementing is Modular, but every call to it's value Increments to a -- higher value than it would have -- increasing seeming randomness in the -- encoded bits. **High_Swap is Low_Swap, but on the end of the block. type Password_Codec is (Modular, Low_Swap, Incrementing, High_Swap, Bit_Select); package IO renames Ada.Text_IO; use IO; -- Base64 encode/decode & test driver. -- Copyright 2001 Tom Moran (tmoran@acm.org, PGP signed tmoran@bix.com), -- anyone may use for any purpose. -- RFC 1521, MIME Base64 encode/decode -- Modified by Micah Waddoups (makesharp.net) 2016. package Base64 is -- Appropriate range for the index of possible Base64 charaters/values. subtype Six_Bits is Byte range 0 .. 63; -- Take any Base64 Character and return it's Base64 modulus six value. To_ModSix: constant array (Character) of Six_Bits := ('A' => 0,'B' => 1,'C' => 2,'D' => 3,'E' => 4,'F' => 5,'G' => 6, 'H' => 7,'I' => 8,'J' => 9,'K' =>10,'L' =>11,'M' =>12,'N' =>13, 'O' =>14,'P' =>15,'Q' =>16,'R' =>17,'S' =>18,'T' =>19,'U' =>20, 'V' =>21,'W' =>22,'X' =>23,'Y' =>24,'Z' =>25,'a' =>26,'b' =>27, 'c' =>28,'d' =>29,'e' =>30,'f' =>31,'g' =>32,'h' =>33,'i' =>34, 'j' =>35,'k' =>36,'l' =>37,'m' =>38,'n' =>39,'o' =>40,'p' =>41, 'q' =>42,'r' =>43,'s' =>44,'t' =>45,'u' =>46,'v' =>47,'w' =>48, 'x' =>49,'y' =>50,'z' =>51,'0' =>52,'1' =>53,'2' =>54,'3' =>55, '4' =>56,'5' =>57,'6' =>58,'7' =>59,'8' =>60,'9' =>61,'+' =>62, '/' =>63, others => 0); -- Take any modulus six (6-bit) number and return it's Base64 Character. To_Char64: constant array (Six_Bits) of Character := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -- -- decode Source into Target(Target'first .. Last) -- Note: it may be appropriate to prescan Source for '=' procedure Decode( -- Base64 String to by converted into Bytes Source : in String; -- Variable to hold output Bytes. Target : out Bytes; -- Variable to put actual NUMBER of created bytes (Bytes -- output buffer may be larger than what Base64 String stores). Last : out Natural); -- -- decode Source and return Bytes. -- Note: it may be appropriate to prescan Source for '=' function Decode(Source : in String) return Bytes; -- -- Target is filled in four character increments. -- Target'length must be at least: (4/3) * Source'length; AND modulus 4 procedure Encode(Source : in Bytes; Target : out String; Last : out Natural); function Encode(Source : in Bytes) return String; end Base64; -- -- -- Standard In and Out for command-pipe encoding. function Standard_Input return IO.File_Type; function Standard_Output return IO.File_Type; -- The next Encoder_Module created is to use this as it's codec, then bump -- this value to the Password_Codec'Succ, wrapping around, for as many -- Password_Modules as will be created. Codec : Password_Codec := Modular; function Get_Codec return Password_Codec; -- Print line of text to standard output. (16-bit String, International) procedure Report_Wide(Message: Wide_String); -- Print line of text to standard output. (8-bit UTF String, International) procedure Report(Message: UTF_8_String); -- Encryption Key which pulls an appropriate value each time it is accessed. -- Used by Encoder. protected type Encoder_Module ( -- How many characters/units in this Encoder_Module. Size: Positive := 8**4) is -- Assign out the next value, looping the length of this Encoder_Module. -- The Increment is just a way to efficiently get an incrementing value. procedure Get_Next(Target : out Natural); procedure Get_Next(Target : out Natural; Increment : Boolean); -- Codec associated with this Encoder_Module. function Codec return Password_Codec; -- Assign the values by the derived value of each character in S. procedure Set(S : in Wide_String := " "); -- Return whether the Module has been assign to. function Status return Boolean; -- Reset Module to initial, just-set state for re-use on another file or stream. procedure Reset; private -- Banks of values that will be used during encoding/decoding. Data : Offsets (1 .. Size) := (1 => 1, others => 0); -- Whether assignment has been made to this module. Initial is False. Is_Set : Boolean := False; -- Current cell to pull value from. Position : Positive := 1; -- Incrementing value. Inc : Offset := 0; -- The Codec used when pulling from this key. Module_Codec : Password_Codec := Modular; -- Position of last offset from first (1..Finish). Finish : Positive := 1; -- Holding space for security measure decoy blocks. Start : Positive := 1; -- -- Necessary link incase future use as a List. Next : access Encoder_Module; end Encoder_Module; -- Collection of encryption keys. type Encoder_Matrix is array(Positive range <>) of Encoder_Module; -- Make a new encoder for every File Input/Output to be performed within -- any given time -- only one for One file at a time using the same -- password set. protected type Encoder ( -- The number of Encoder_Modules (password/key's) in -- this Encoder. Size : Positive := 1; -- The maximum number of character/units allowed in -- any password/key. Max_Key_Size : Positive := 8**4) is -- Simply return how many passwords have been set. function Status return Integer; -- Reset password data to its state just after being assigned, and -- unlock the encoder or decoder. procedure Reset; -- Assign a Wide_String or UTF_8_String value to the Password. -- Each assignment defines the first unassigned password/key -- in a series of three. Further assignments do nothing. procedure Set_Wide (S : in Wide_String); procedure Set (S : in UTF_8_String); procedure Set; -- Using this Encoder (or set of passwords), encode the given input bytes, -- File_Type, or Filename. !! Only the exact same set of passwords will be -- able to recover the data after it has been encoded. procedure Encode(Input : in Bytes; Output : out Bytes); procedure Encode(Input : in IO.File_Type; Output : out IO.File_Type); procedure Encode(In_Filename : in String; Out_Filename : out String); private -- Data is the raw buffer space in which the Password is held. Data : Encoder_Matrix(1 .. Size); Status_Count : Natural := 0; -- Signals whether the Password has been set with a set() instruction. Is_Set : Boolean := False; Is_Set2 : Boolean := False; Is_Set3 : Boolean := False; -- Sygnals whether An incomplete block of Bytes has been encountered -- while encoding (less than 57 Bytes). If it has, then require a Reset -- to be run before anything more can be coded. This is to prevent data -- curruption, and is a modest precaution. Is_Clean : Boolean := True; -- Start, Finish, and current_position control where in the Password -- buffer the Wide_String is and which Wide_Character to pull from -- it next. Start, Current_Position : Positive := 1; Finish : Natural := 0; Start2, Current_Position2 : Positive := 1; Finish2 : Natural := 0; Start3, Current_Position3 : Positive := 1; Finish3 : Natural := 0; end Encoder; end Password_Encode;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 onox <denkpadje@gmail.com> -- -- 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 GL.Context; with GL.Viewports; with Orka.Loggers; with Orka.Logging; package body Orka.Contexts.EGL is use all type Orka.Logging.Source; use all type Orka.Logging.Severity; use Orka.Logging; package Messages is new Orka.Logging.Messages (Window_System); procedure Print_Error (Error : Standard.EGL.Errors.Error_Code; Level : Standard.EGL.Debug.Severity; Command, Message : String) is package Debug renames Standard.EGL.Debug; Severity : constant Orka.Loggers.Severity := (case Level is when Debug.Critical => Loggers.Error, when Debug.Error => Loggers.Error, when Debug.Warning => Loggers.Warning, when Debug.Info => Loggers.Debug); begin Messages.Log (Severity, Error'Image & " in " & Command & ": " & Trim (Message)); end Print_Error; procedure Print_Debug (Display : Standard.EGL.Objects.Displays.Display; Flags : Context_Flags) is begin Messages.Log (Debug, "Created EGL context"); Messages.Log (Debug, " platform: " & Display.Platform'Image); declare Name : constant String := Display.Device.Name; begin Messages.Log (Debug, " device: " & (if Name /= "" then Name else "unknown")); end; Messages.Log (Debug, " vendor: " & Display.Vendor); Messages.Log (Debug, " version: " & Display.Version); Messages.Log (Debug, " context:"); Messages.Log (Debug, " flags: " & Image (Flags)); Messages.Log (Debug, " version: " & GL.Context.Version_String); Messages.Log (Debug, " renderer: " & GL.Context.Renderer); end Print_Debug; procedure Post_Initialize (Object : in out EGL_Context'Class) is Flags : constant GL.Context.Context_Flags := GL.Context.Flags; begin Object.Version := (Major => GL.Context.Major_Version, Minor => GL.Context.Minor_Version); pragma Assert (Flags.Forward_Compatible); Object.Flags.Debug := Flags.Debug; Object.Flags.Robust := Flags.Robust_Access; Object.Flags.No_Error := Flags.No_Error; -- Other information about context can be read back as well with -- GL.Context.Reset_Notification and GL.Context.Release_Behavior GL.Viewports.Set_Clipping (GL.Viewports.Lower_Left, GL.Viewports.Zero_To_One); Object.Vertex_Array.Create; end Post_Initialize; function Create_Context (Device : Standard.EGL.Objects.Devices.Device; Version : Context_Version; Flags : Context_Flags := (others => False)) return Device_EGL_Context is package EGL_Contexts renames Standard.EGL.Objects.Contexts; package EGL_Displays renames Standard.EGL.Objects.Displays; begin Standard.EGL.Debug.Set_Message_Callback (Print_Error'Access); declare Display : constant EGL_Displays.Display := EGL_Displays.Create_Display (Device); begin return Result : Device_EGL_Context do Result.Context := EGL_Contexts.Create_Context (Display, (Major => Version.Major, Minor => Version.Minor), (Debug => Flags.Debug, Robust => Flags.Robust, No_Error => Flags.No_Error)); Result.Context.Make_Current; Post_Initialize (Result); Print_Debug (Display, Flags); end return; end; end Create_Context; overriding function Create_Context (Version : Context_Version; Flags : Context_Flags := (others => False)) return Device_EGL_Context is package EGL_Devices renames Standard.EGL.Objects.Devices; Devices : constant EGL_Devices.Device_List := EGL_Devices.Devices; begin Messages.Log (Debug, "EGL devices:"); for Device of Devices loop declare Name : constant String := Device.Name; begin Messages.Log (Debug, " - " & (if Name /= "" then Name else "unknown")); end; end loop; return Create_Context (Devices (Devices'First), Version, Flags); end Create_Context; overriding procedure Finalize (Object : in out EGL_Context) is begin if Object.Flags.Debug then Messages.Log (Debug, "Shutting down EGL"); end if; Object.Vertex_Array.Delete; end Finalize; overriding procedure Enable (Object : in out EGL_Context; Subject : Feature) is begin Contexts.Enable (Object.Features, Subject); end Enable; overriding function Enabled (Object : EGL_Context; Subject : Feature) return Boolean is (Contexts.Enabled (Object.Features, Subject)); overriding procedure Make_Current (Object : Device_EGL_Context) is begin Object.Context.Make_Current; end Make_Current; overriding procedure Make_Not_Current (Object : Device_EGL_Context) is begin Object.Context.Make_Not_Current; end Make_Not_Current; end Orka.Contexts.EGL;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Editor_Package; use Editor_Package; with Utilities_Package; use Utilities_Package; package Command_Package is type Cmd_Flag_Type is ( NOFLAGS, MARK, CLEARSBLOCK, NEEDSLINE, NEEDSBLOCK, SETSHILITE, NOLOCATOR); type Arg_Type is (ARG_STRING); type Arg is record T : Arg_Type; S1 : Unbounded_String; end record; type Cmd_Func_Type is access procedure (E : in out Editor; V : in out View; A : Arg); procedure Run_File (E : Editor; V : in out View; A : Arg); function Command (E : in out Editor; V : in out View; F : Cmd_Flag_Type; Func : Cmd_Func_Type; A : Arg) return Boolean; procedure Cmd_Insert_File (E : in out Editor; V : in out View; A : Arg); procedure Fix_Block (V : in out View); private function Test_None (V : View) return Boolean; end Command_Package;
-- SPDX-FileCopyrightText: 2020-2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- procedure Program.Nodes.Operator_Symbols.Set_Defining_Name (Self : not null Program.Elements.Operator_Symbols.Operator_Symbol_Access; Value : Program.Elements.Defining_Operator_Symbols .Defining_Operator_Symbol_Access) is begin Base_Operator_Symbol (Self.all).Corresponding_Defining_Operator_Symbol := Value; end Program.Nodes.Operator_Symbols.Set_Defining_Name;
------------------------------------------------------------------------------ -- -- -- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! -- -- -- -- WAVEFILES -- -- -- -- Wavefile data I/O operations -- -- -- -- The MIT License (MIT) -- -- -- -- Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann -- -- -- -- 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. -- ------------------------------------------------------------------------------ #if (NUM_TYPE = "FLOAT") then with Audio.Wavefiles.Generic_Float_Wav_IO; #else with Audio.Wavefiles.Generic_Fixed_Wav_IO; #end if; #if (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FLOAT") then package body Audio.Wavefiles.Generic_Float_Wav_Float_PCM_IO is #elsif (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FIXED") then package body Audio.Wavefiles.Generic_Float_Wav_Fixed_PCM_IO is #elsif (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FLOAT") then package body Audio.Wavefiles.Generic_Fixed_Wav_Float_PCM_IO is #elsif (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FIXED") then package body Audio.Wavefiles.Generic_Fixed_Wav_Fixed_PCM_IO is #end if; type Wav_MC_Sample is array (Channel_Range range <>) of Wav_Sample; #if (NUM_TYPE = "FLOAT") then package Wav_IO is new Audio.Wavefiles.Generic_Float_Wav_IO #else package Wav_IO is new Audio.Wavefiles.Generic_Fixed_Wav_IO #end if; (Wav_Sample => Wav_Sample, Channel_Range => Channel_Range, Wav_MC_Sample => Wav_MC_Sample); use Wav_IO; procedure Convert (Wav : Wav_MC_Sample; PCM : out PCM_MC_Sample) with Inline; procedure Convert (PCM : PCM_MC_Sample; Wav : out Wav_MC_Sample) with Inline; function Convert (Wav : Wav_MC_Sample) return PCM_MC_Sample with Inline; function Convert (PCM : PCM_MC_Sample) return Wav_MC_Sample with Inline; pragma Unreferenced (Convert); #if (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FIXED") then function Saturate (Wav : Wav_Sample) return PCM_Sample with Inline; #end if; #if (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FLOAT") then function Saturate (PCM : PCM_Sample) return Wav_Sample with Inline; #end if; #if (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FIXED") then -------------- -- Saturate -- -------------- function Saturate (Wav : Wav_Sample) return PCM_Sample is begin if Wav > Wav_Sample (PCM_Sample'Last) then return PCM_Sample'Last; elsif Wav < Wav_Sample (PCM_Sample'First) then return PCM_Sample'First; else return PCM_Sample (Wav); end if; end Saturate; #end if; #if (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FLOAT") then -------------- -- Saturate -- -------------- function Saturate (PCM : PCM_Sample) return Wav_Sample is begin if PCM > PCM_Sample (Wav_Sample'Last) then return Wav_Sample'Last; elsif PCM < PCM_Sample (Wav_Sample'First) then return Wav_Sample'First; else return Wav_Sample (PCM); end if; end Saturate; #end if; ------------- -- Convert -- ------------- procedure Convert (Wav : Wav_MC_Sample; PCM : out PCM_MC_Sample) is begin for I in PCM'Range loop #if (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FIXED") then PCM (I) := Saturate (Wav (I)); #else PCM (I) := PCM_Sample (Wav (I)); #end if; end loop; end Convert; ------------- -- Convert -- ------------- procedure Convert (PCM : PCM_MC_Sample; Wav : out Wav_MC_Sample) is begin for I in Wav'Range loop #if (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FLOAT") then Wav (I) := Saturate (PCM (I)); #else Wav (I) := Wav_Sample (PCM (I)); #end if; end loop; end Convert; ------------- -- Convert -- ------------- function Convert (Wav : Wav_MC_Sample) return PCM_MC_Sample is begin return PCM : PCM_MC_Sample (Wav'Range) do Convert (Wav, PCM); end return; end Convert; ------------- -- Convert -- ------------- function Convert (PCM : PCM_MC_Sample) return Wav_MC_Sample is begin return Wav : Wav_MC_Sample (PCM'Range) do Convert (PCM, Wav); end return; end Convert; --------- -- Get -- --------- function Get (WF : in out Wavefile) return PCM_MC_Sample is Wav : constant Wav_MC_Sample := Get (WF); PCM : constant PCM_MC_Sample := Convert (Wav); begin return PCM; end Get; --------- -- Get -- --------- procedure Get (WF : in out Wavefile; PCM : out PCM_MC_Sample) is Wav : Wav_MC_Sample (PCM'Range); begin Get (WF, Wav); Convert (Wav, PCM); end Get; --------- -- Put -- --------- procedure Put (WF : in out Wavefile; PCM : PCM_MC_Sample) is Wav : Wav_MC_Sample (PCM'Range); begin Convert (PCM, Wav); Put (WF, Wav); end Put; #if (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FLOAT") then end Audio.Wavefiles.Generic_Float_Wav_Float_PCM_IO; #elsif (NUM_TYPE = "FLOAT") and then (NUM_TYPE_2 = "FIXED") then end Audio.Wavefiles.Generic_Float_Wav_Fixed_PCM_IO; #elsif (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FLOAT") then end Audio.Wavefiles.Generic_Fixed_Wav_Float_PCM_IO; #elsif (NUM_TYPE = "FIXED") and then (NUM_TYPE_2 = "FIXED") then end Audio.Wavefiles.Generic_Fixed_Wav_Fixed_PCM_IO; #end if;
with Ada.Unchecked_Conversion; with System.Runtime_Context; with System.Unwind.Occurrences; package body System.Soft_Links is pragma Suppress (All_Checks); -- implementation function Do_Get_Current_Excep return Ada.Exceptions.Exception_Occurrence_Access is function Cast is new Ada.Unchecked_Conversion ( Unwind.Exception_Occurrence_Access, Ada.Exceptions.Exception_Occurrence_Access); TLS : constant not null Runtime_Context.Task_Local_Storage_Access := Runtime_Context.Get_Task_Local_Storage; begin return Cast (Unwind.Occurrences.Get_Current_Occurrence (TLS)); end Do_Get_Current_Excep; function Get_GNAT_Exception return Ada.Exceptions.Exception_Id is function Cast is new Ada.Unchecked_Conversion ( Ada.Exceptions.Exception_Occurrence_Access, Unwind.Exception_Occurrence_Access); function Cast is new Ada.Unchecked_Conversion ( Unwind.Exception_Data_Access, Ada.Exceptions.Exception_Id); begin return Cast (Cast (Get_Current_Excep.all).Id); end Get_GNAT_Exception; end System.Soft_Links;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with GL.API; with GL.Culling; with GL.Enums.Getter; package body GL.Rasterization is procedure Set_Line_Width (Value : Single) is begin API.Line_Width (Value); Raise_Exception_On_OpenGL_Error; end Set_Line_Width; function Line_Width return Single is Ret : aliased Single; begin API.Get_Single (Enums.Getter.Line_Width, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Line_Width; function Aliased_Line_Width_Range return Line_Width_Range is Ret : Singles.Vector2 := (others => <>); begin API.Get_Single_Vec2 (Enums.Getter.Aliased_Line_Width_Range, Ret); Raise_Exception_On_OpenGL_Error; return Ret; end Aliased_Line_Width_Range; function Smooth_Line_Width_Range return Line_Width_Range is Ret : Singles.Vector2 := (others => <>); begin API.Get_Single_Vec2 (Enums.Getter.Smooth_Line_Width_Range, Ret); Raise_Exception_On_OpenGL_Error; return Ret; end Smooth_Line_Width_Range; function Smooth_Line_Width_Granularity return Single is Ret : aliased Single; begin API.Get_Single (Enums.Getter.Smooth_Line_Width_Granularity, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Smooth_Line_Width_Granularity; procedure Set_Polygon_Mode (Value : Polygon_Mode_Type) is begin API.Polygon_Mode (Culling.Front_And_Back, Value); Raise_Exception_On_OpenGL_Error; end Set_Polygon_Mode; function Polygon_Mode return Polygon_Mode_Type is Ret : aliased Polygon_Mode_Type; begin API.Get_Polygon_Mode (Enums.Getter.Polygon_Mode, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Polygon_Mode; procedure Set_Polygon_Offset (Factor, Units : Single := 0.0) is begin API.Set_Polygon_Offset (Factor, Units); Raise_Exception_On_OpenGL_Error; end Set_Polygon_Offset; procedure Set_Point_Size (Value : Single) is begin API.Set_Point_Size (Value); Raise_Exception_On_OpenGL_Error; end Set_Point_Size; function Point_Size return Single is Ret : aliased Single := 0.0; begin API.Get_Single (Enums.Getter.Point_Size, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Point_Size; function Point_Size_Range return Singles.Vector2 is Ret : Singles.Vector2 := Singles.Vector2'(0.0, 0.0); begin API.Get_Single_Vec2 (Enums.Getter.Point_Size_Range, Ret); Raise_Exception_On_OpenGL_Error; return Ret; end Point_Size_Range; function Point_Size_Granularity return Single is Ret : aliased Single := 0.0; begin API.Get_Single (Enums.Getter.Point_Size_Granularity, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Point_Size_Granularity; procedure Set_Point_Fade_Threshold_Size (Value : Single) is begin API.Set_Point_Parameter_Single (Enums.Fade_Threshold_Size, Value); Raise_Exception_On_OpenGL_Error; end Set_Point_Fade_Threshold_Size; function Point_Fade_Threshold_Size return Single is Ret : aliased Single := 0.0; begin API.Get_Single (Enums.Getter.Point_Fade_Threshold_Size, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Point_Fade_Threshold_Size; end GL.Rasterization;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 4 -- -- -- -- 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 Checks; use Checks; with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Exp_Aggr; use Exp_Aggr; with Exp_Atag; use Exp_Atag; with Exp_Ch2; use Exp_Ch2; with Exp_Ch3; use Exp_Ch3; with Exp_Ch6; use Exp_Ch6; with Exp_Ch7; use Exp_Ch7; with Exp_Ch9; use Exp_Ch9; with Exp_Disp; use Exp_Disp; with Exp_Fixd; use Exp_Fixd; with Exp_Intr; use Exp_Intr; with Exp_Pakd; use Exp_Pakd; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Inline; use Inline; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Par_SCO; use Par_SCO; 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_Ch13; use Sem_Ch13; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Type; use Sem_Type; with Sem_Util; use Sem_Util; with Sem_Warn; use Sem_Warn; with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with SCIL_LL; use SCIL_LL; with Targparm; use Targparm; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Uintp; use Uintp; with Urealp; use Urealp; with Validsw; use Validsw; package body Exp_Ch4 is ----------------------- -- Local Subprograms -- ----------------------- procedure Binary_Op_Validity_Checks (N : Node_Id); pragma Inline (Binary_Op_Validity_Checks); -- Performs validity checks for a binary operator procedure Build_Boolean_Array_Proc_Call (N : Node_Id; Op1 : Node_Id; Op2 : Node_Id); -- If a boolean array assignment can be done in place, build call to -- corresponding library procedure. procedure Displace_Allocator_Pointer (N : Node_Id); -- Ada 2005 (AI-251): Subsidiary procedure to Expand_N_Allocator and -- Expand_Allocator_Expression. Allocating class-wide interface objects -- this routine displaces the pointer to the allocated object to reference -- the component referencing the corresponding secondary dispatch table. procedure Expand_Allocator_Expression (N : Node_Id); -- Subsidiary to Expand_N_Allocator, for the case when the expression -- is a qualified expression or an aggregate. procedure Expand_Array_Comparison (N : Node_Id); -- This routine handles expansion of the comparison operators (N_Op_Lt, -- N_Op_Le, N_Op_Gt, N_Op_Ge) when operating on an array type. The basic -- code for these operators is similar, differing only in the details of -- the actual comparison call that is made. Special processing (call a -- run-time routine) function Expand_Array_Equality (Nod : Node_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id; Typ : Entity_Id) return Node_Id; -- Expand an array equality into a call to a function implementing this -- equality, and a call to it. Loc is the location for the generated nodes. -- Lhs and Rhs are the array expressions to be compared. Bodies is a list -- on which to attach bodies of local functions that are created in the -- process. It is the responsibility of the caller to insert those bodies -- at the right place. Nod provides the Sloc value for the generated code. -- Normally the types used for the generated equality routine are taken -- from Lhs and Rhs. However, in some situations of generated code, the -- Etype fields of Lhs and Rhs are not set yet. In such cases, Typ supplies -- the type to be used for the formal parameters. procedure Expand_Boolean_Operator (N : Node_Id); -- Common expansion processing for Boolean operators (And, Or, Xor) for the -- case of array type arguments. procedure Expand_Short_Circuit_Operator (N : Node_Id); -- Common expansion processing for short-circuit boolean operators procedure Expand_Compare_Minimize_Eliminate_Overflow (N : Node_Id); -- Deal with comparison in MINIMIZED/ELIMINATED overflow mode. This is -- where we allow comparison of "out of range" values. function Expand_Composite_Equality (Nod : Node_Id; Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id; -- Local recursive function used to expand equality for nested composite -- types. Used by Expand_Record/Array_Equality, Bodies is a list on which -- to attach bodies of local functions that are created in the process. It -- is the responsibility of the caller to insert those bodies at the right -- place. Nod provides the Sloc value for generated code. Lhs and Rhs are -- the left and right sides for the comparison, and Typ is the type of the -- objects to compare. procedure Expand_Concatenate (Cnode : Node_Id; Opnds : List_Id); -- Routine to expand concatenation of a sequence of two or more operands -- (in the list Operands) and replace node Cnode with the result of the -- concatenation. The operands can be of any appropriate type, and can -- include both arrays and singleton elements. procedure Expand_Membership_Minimize_Eliminate_Overflow (N : Node_Id); -- N is an N_In membership test mode, with the overflow check mode set to -- MINIMIZED or ELIMINATED, and the type of the left operand is a signed -- integer type. This is a case where top level processing is required to -- handle overflow checks in subtrees. procedure Fixup_Universal_Fixed_Operation (N : Node_Id); -- N is a N_Op_Divide or N_Op_Multiply node whose result is universal -- fixed. We do not have such a type at runtime, so the purpose of this -- routine is to find the real type by looking up the tree. We also -- determine if the operation must be rounded. function Has_Inferable_Discriminants (N : Node_Id) return Boolean; -- Ada 2005 (AI-216): A view of an Unchecked_Union object has inferable -- discriminants if it has a constrained nominal type, unless the object -- is a component of an enclosing Unchecked_Union object that is subject -- to a per-object constraint and the enclosing object lacks inferable -- discriminants. -- -- An expression of an Unchecked_Union type has inferable discriminants -- if it is either a name of an object with inferable discriminants or a -- qualified expression whose subtype mark denotes a constrained subtype. procedure Insert_Dereference_Action (N : Node_Id); -- N is an expression whose type is an access. When the type of the -- associated storage pool is derived from Checked_Pool, generate a -- call to the 'Dereference' primitive operation. function Make_Array_Comparison_Op (Typ : Entity_Id; Nod : Node_Id) return Node_Id; -- Comparisons between arrays are expanded in line. This function produces -- the body of the implementation of (a > b), where a and b are one- -- dimensional arrays of some discrete type. The original node is then -- expanded into the appropriate call to this function. Nod provides the -- Sloc value for the generated code. function Make_Boolean_Array_Op (Typ : Entity_Id; N : Node_Id) return Node_Id; -- Boolean operations on boolean arrays are expanded in line. This function -- produce the body for the node N, which is (a and b), (a or b), or (a xor -- b). It is used only the normal case and not the packed case. The type -- involved, Typ, is the Boolean array type, and the logical operations in -- the body are simple boolean operations. Note that Typ is always a -- constrained type (the caller has ensured this by using -- Convert_To_Actual_Subtype if necessary). function Minimized_Eliminated_Overflow_Check (N : Node_Id) return Boolean; -- For signed arithmetic operations when the current overflow mode is -- MINIMIZED or ELIMINATED, we must call Apply_Arithmetic_Overflow_Checks -- as the first thing we do. We then return. We count on the recursive -- apparatus for overflow checks to call us back with an equivalent -- operation that is in CHECKED mode, avoiding a recursive entry into this -- routine, and that is when we will proceed with the expansion of the -- operator (e.g. converting X+0 to X, or X**2 to X*X). We cannot do -- these optimizations without first making this check, since there may be -- operands further down the tree that are relying on the recursive calls -- triggered by the top level nodes to properly process overflow checking -- and remaining expansion on these nodes. Note that this call back may be -- skipped if the operation is done in Bignum mode but that's fine, since -- the Bignum call takes care of everything. procedure Optimize_Length_Comparison (N : Node_Id); -- Given an expression, if it is of the form X'Length op N (or the other -- way round), where N is known at compile time to be 0 or 1, and X is a -- simple entity, and op is a comparison operator, optimizes it into a -- comparison of First and Last. procedure Process_If_Case_Statements (N : Node_Id; Stmts : List_Id); -- Inspect and process statement list Stmt of if or case expression N for -- transient objects. If such objects are found, the routine generates code -- to clean them up when the context of the expression is evaluated. procedure Process_Transient_In_Expression (Obj_Decl : Node_Id; Expr : Node_Id; Stmts : List_Id); -- Subsidiary routine to the expansion of expression_with_actions, if and -- case expressions. Generate all necessary code to finalize a transient -- object when the enclosing context is elaborated or evaluated. Obj_Decl -- denotes the declaration of the transient object, which is usually the -- result of a controlled function call. Expr denotes the expression with -- actions, if expression, or case expression node. Stmts denotes the -- statement list which contains Decl, either at the top level or within a -- nested construct. procedure Rewrite_Comparison (N : Node_Id); -- If N is the node for a comparison whose outcome can be determined at -- compile time, then the node N can be rewritten with True or False. If -- the outcome cannot be determined at compile time, the call has no -- effect. If N is a type conversion, then this processing is applied to -- its expression. If N is neither comparison nor a type conversion, the -- call has no effect. procedure Tagged_Membership (N : Node_Id; SCIL_Node : out Node_Id; Result : out Node_Id); -- Construct the expression corresponding to the tagged membership test. -- Deals with a second operand being (or not) a class-wide type. function Safe_In_Place_Array_Op (Lhs : Node_Id; Op1 : Node_Id; Op2 : Node_Id) return Boolean; -- In the context of an assignment, where the right-hand side is a boolean -- operation on arrays, check whether operation can be performed in place. procedure Unary_Op_Validity_Checks (N : Node_Id); pragma Inline (Unary_Op_Validity_Checks); -- Performs validity checks for a unary operator ------------------------------- -- Binary_Op_Validity_Checks -- ------------------------------- procedure Binary_Op_Validity_Checks (N : Node_Id) is begin if Validity_Checks_On and Validity_Check_Operands then Ensure_Valid (Left_Opnd (N)); Ensure_Valid (Right_Opnd (N)); end if; end Binary_Op_Validity_Checks; ------------------------------------ -- Build_Boolean_Array_Proc_Call -- ------------------------------------ procedure Build_Boolean_Array_Proc_Call (N : Node_Id; Op1 : Node_Id; Op2 : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Kind : constant Node_Kind := Nkind (Expression (N)); Target : constant Node_Id := Make_Attribute_Reference (Loc, Prefix => Name (N), Attribute_Name => Name_Address); Arg1 : Node_Id := Op1; Arg2 : Node_Id := Op2; Call_Node : Node_Id; Proc_Name : Entity_Id; begin if Kind = N_Op_Not then if Nkind (Op1) in N_Binary_Op then -- Use negated version of the binary operators if Nkind (Op1) = N_Op_And then Proc_Name := RTE (RE_Vector_Nand); elsif Nkind (Op1) = N_Op_Or then Proc_Name := RTE (RE_Vector_Nor); else pragma Assert (Nkind (Op1) = N_Op_Xor); Proc_Name := RTE (RE_Vector_Xor); end if; Call_Node := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Proc_Name, Loc), Parameter_Associations => New_List ( Target, Make_Attribute_Reference (Loc, Prefix => Left_Opnd (Op1), Attribute_Name => Name_Address), Make_Attribute_Reference (Loc, Prefix => Right_Opnd (Op1), Attribute_Name => Name_Address), Make_Attribute_Reference (Loc, Prefix => Left_Opnd (Op1), Attribute_Name => Name_Length))); else Proc_Name := RTE (RE_Vector_Not); Call_Node := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Proc_Name, Loc), Parameter_Associations => New_List ( Target, Make_Attribute_Reference (Loc, Prefix => Op1, Attribute_Name => Name_Address), Make_Attribute_Reference (Loc, Prefix => Op1, Attribute_Name => Name_Length))); end if; else -- We use the following equivalences: -- (not X) or (not Y) = not (X and Y) = Nand (X, Y) -- (not X) and (not Y) = not (X or Y) = Nor (X, Y) -- (not X) xor (not Y) = X xor Y -- X xor (not Y) = not (X xor Y) = Nxor (X, Y) if Nkind (Op1) = N_Op_Not then Arg1 := Right_Opnd (Op1); Arg2 := Right_Opnd (Op2); if Kind = N_Op_And then Proc_Name := RTE (RE_Vector_Nor); elsif Kind = N_Op_Or then Proc_Name := RTE (RE_Vector_Nand); else Proc_Name := RTE (RE_Vector_Xor); end if; else if Kind = N_Op_And then Proc_Name := RTE (RE_Vector_And); elsif Kind = N_Op_Or then Proc_Name := RTE (RE_Vector_Or); elsif Nkind (Op2) = N_Op_Not then Proc_Name := RTE (RE_Vector_Nxor); Arg2 := Right_Opnd (Op2); else Proc_Name := RTE (RE_Vector_Xor); end if; end if; Call_Node := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Proc_Name, Loc), Parameter_Associations => New_List ( Target, Make_Attribute_Reference (Loc, Prefix => Arg1, Attribute_Name => Name_Address), Make_Attribute_Reference (Loc, Prefix => Arg2, Attribute_Name => Name_Address), Make_Attribute_Reference (Loc, Prefix => Arg1, Attribute_Name => Name_Length))); end if; Rewrite (N, Call_Node); Analyze (N); exception when RE_Not_Available => return; end Build_Boolean_Array_Proc_Call; -------------------------------- -- Displace_Allocator_Pointer -- -------------------------------- procedure Displace_Allocator_Pointer (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Orig_Node : constant Node_Id := Original_Node (N); Dtyp : Entity_Id; Etyp : Entity_Id; PtrT : Entity_Id; begin -- Do nothing in case of VM targets: the virtual machine will handle -- interfaces directly. if not Tagged_Type_Expansion then return; end if; pragma Assert (Nkind (N) = N_Identifier and then Nkind (Orig_Node) = N_Allocator); PtrT := Etype (Orig_Node); Dtyp := Available_View (Designated_Type (PtrT)); Etyp := Etype (Expression (Orig_Node)); if Is_Class_Wide_Type (Dtyp) and then Is_Interface (Dtyp) then -- If the type of the allocator expression is not an interface type -- we can generate code to reference the record component containing -- the pointer to the secondary dispatch table. if not Is_Interface (Etyp) then declare Saved_Typ : constant Entity_Id := Etype (Orig_Node); begin -- 1) Get access to the allocated object Rewrite (N, Make_Explicit_Dereference (Loc, Relocate_Node (N))); Set_Etype (N, Etyp); Set_Analyzed (N); -- 2) Add the conversion to displace the pointer to reference -- the secondary dispatch table. Rewrite (N, Convert_To (Dtyp, Relocate_Node (N))); Analyze_And_Resolve (N, Dtyp); -- 3) The 'access to the secondary dispatch table will be used -- as the value returned by the allocator. Rewrite (N, Make_Attribute_Reference (Loc, Prefix => Relocate_Node (N), Attribute_Name => Name_Access)); Set_Etype (N, Saved_Typ); Set_Analyzed (N); end; -- If the type of the allocator expression is an interface type we -- generate a run-time call to displace "this" to reference the -- component containing the pointer to the secondary dispatch table -- or else raise Constraint_Error if the actual object does not -- implement the target interface. This case corresponds to the -- following example: -- function Op (Obj : Iface_1'Class) return access Iface_2'Class is -- begin -- return new Iface_2'Class'(Obj); -- end Op; else Rewrite (N, Unchecked_Convert_To (PtrT, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Displace), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_Address), Relocate_Node (N)), New_Occurrence_Of (Elists.Node (First_Elmt (Access_Disp_Table (Etype (Base_Type (Dtyp))))), Loc))))); Analyze_And_Resolve (N, PtrT); end if; end if; end Displace_Allocator_Pointer; --------------------------------- -- Expand_Allocator_Expression -- --------------------------------- procedure Expand_Allocator_Expression (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Exp : constant Node_Id := Expression (Expression (N)); PtrT : constant Entity_Id := Etype (N); DesigT : constant Entity_Id := Designated_Type (PtrT); procedure Apply_Accessibility_Check (Ref : Node_Id; Built_In_Place : Boolean := False); -- Ada 2005 (AI-344): For an allocator with a class-wide designated -- type, generate an accessibility check to verify that the level of the -- type of the created object is not deeper than the level of the access -- type. If the type of the qualified expression is class-wide, then -- always generate the check (except in the case where it is known to be -- unnecessary, see comment below). Otherwise, only generate the check -- if the level of the qualified expression type is statically deeper -- than the access type. -- -- Although the static accessibility will generally have been performed -- as a legality check, it won't have been done in cases where the -- allocator appears in generic body, so a run-time check is needed in -- general. One special case is when the access type is declared in the -- same scope as the class-wide allocator, in which case the check can -- never fail, so it need not be generated. -- -- As an open issue, there seem to be cases where the static level -- associated with the class-wide object's underlying type is not -- sufficient to perform the proper accessibility check, such as for -- allocators in nested subprograms or accept statements initialized by -- class-wide formals when the actual originates outside at a deeper -- static level. The nested subprogram case might require passing -- accessibility levels along with class-wide parameters, and the task -- case seems to be an actual gap in the language rules that needs to -- be fixed by the ARG. ??? ------------------------------- -- Apply_Accessibility_Check -- ------------------------------- procedure Apply_Accessibility_Check (Ref : Node_Id; Built_In_Place : Boolean := False) is Pool_Id : constant Entity_Id := Associated_Storage_Pool (PtrT); Cond : Node_Id; Fin_Call : Node_Id; Free_Stmt : Node_Id; Obj_Ref : Node_Id; Stmts : List_Id; begin if Ada_Version >= Ada_2005 and then Is_Class_Wide_Type (DesigT) and then Tagged_Type_Expansion and then not Scope_Suppress.Suppress (Accessibility_Check) and then (Type_Access_Level (Etype (Exp)) > Type_Access_Level (PtrT) or else (Is_Class_Wide_Type (Etype (Exp)) and then Scope (PtrT) /= Current_Scope)) then -- If the allocator was built in place, Ref is already a reference -- to the access object initialized to the result of the allocator -- (see Exp_Ch6.Make_Build_In_Place_Call_In_Allocator). We call -- Remove_Side_Effects for cases where the build-in-place call may -- still be the prefix of the reference (to avoid generating -- duplicate calls). Otherwise, it is the entity associated with -- the object containing the address of the allocated object. if Built_In_Place then Remove_Side_Effects (Ref); Obj_Ref := New_Copy_Tree (Ref); else Obj_Ref := New_Occurrence_Of (Ref, Loc); end if; -- For access to interface types we must generate code to displace -- the pointer to the base of the object since the subsequent code -- references components located in the TSD of the object (which -- is associated with the primary dispatch table --see a-tags.ads) -- and also generates code invoking Free, which requires also a -- reference to the base of the unallocated object. if Is_Interface (DesigT) and then Tagged_Type_Expansion then Obj_Ref := Unchecked_Convert_To (Etype (Obj_Ref), Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Base_Address), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_Address), New_Copy_Tree (Obj_Ref))))); end if; -- Step 1: Create the object clean up code Stmts := New_List; -- Deallocate the object if the accessibility check fails. This -- is done only on targets or profiles that support deallocation. -- Free (Obj_Ref); if RTE_Available (RE_Free) then Free_Stmt := Make_Free_Statement (Loc, New_Copy_Tree (Obj_Ref)); Set_Storage_Pool (Free_Stmt, Pool_Id); Append_To (Stmts, Free_Stmt); -- The target or profile cannot deallocate objects else Free_Stmt := Empty; end if; -- Finalize the object if applicable. Generate: -- [Deep_]Finalize (Obj_Ref.all); if Needs_Finalization (DesigT) then Fin_Call := Make_Final_Call (Obj_Ref => Make_Explicit_Dereference (Loc, New_Copy (Obj_Ref)), Typ => DesigT); -- Guard against a missing [Deep_]Finalize when the designated -- type was not properly frozen. if No (Fin_Call) then Fin_Call := Make_Null_Statement (Loc); end if; -- When the target or profile supports deallocation, wrap the -- finalization call in a block to ensure proper deallocation -- even if finalization fails. Generate: -- begin -- <Fin_Call> -- exception -- when others => -- <Free_Stmt> -- raise; -- end; if Present (Free_Stmt) then Fin_Call := Make_Block_Statement (Loc, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Fin_Call), Exception_Handlers => New_List ( Make_Exception_Handler (Loc, Exception_Choices => New_List ( Make_Others_Choice (Loc)), Statements => New_List ( New_Copy_Tree (Free_Stmt), Make_Raise_Statement (Loc)))))); end if; Prepend_To (Stmts, Fin_Call); end if; -- Signal the accessibility failure through a Program_Error Append_To (Stmts, Make_Raise_Program_Error (Loc, Condition => New_Occurrence_Of (Standard_True, Loc), Reason => PE_Accessibility_Check_Failed)); -- Step 2: Create the accessibility comparison -- Generate: -- Ref'Tag Obj_Ref := Make_Attribute_Reference (Loc, Prefix => Obj_Ref, Attribute_Name => Name_Tag); -- For tagged types, determine the accessibility level by looking -- at the type specific data of the dispatch table. Generate: -- Type_Specific_Data (Address (Ref'Tag)).Access_Level if Tagged_Type_Expansion then Cond := Build_Get_Access_Level (Loc, Obj_Ref); -- Use a runtime call to determine the accessibility level when -- compiling on virtual machine targets. Generate: -- Get_Access_Level (Ref'Tag) else Cond := Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Get_Access_Level), Loc), Parameter_Associations => New_List (Obj_Ref)); end if; Cond := Make_Op_Gt (Loc, Left_Opnd => Cond, Right_Opnd => Make_Integer_Literal (Loc, Type_Access_Level (PtrT))); -- Due to the complexity and side effects of the check, utilize an -- if statement instead of the regular Program_Error circuitry. Insert_Action (N, Make_Implicit_If_Statement (N, Condition => Cond, Then_Statements => Stmts)); end if; end Apply_Accessibility_Check; -- Local variables Aggr_In_Place : constant Boolean := Is_Delayed_Aggregate (Exp); Indic : constant Node_Id := Subtype_Mark (Expression (N)); T : constant Entity_Id := Entity (Indic); Adj_Call : Node_Id; Node : Node_Id; Tag_Assign : Node_Id; Temp : Entity_Id; Temp_Decl : Node_Id; TagT : Entity_Id := Empty; -- Type used as source for tag assignment TagR : Node_Id := Empty; -- Target reference for tag assignment -- Start of processing for Expand_Allocator_Expression begin -- Handle call to C++ constructor if Is_CPP_Constructor_Call (Exp) then Make_CPP_Constructor_Call_In_Allocator (Allocator => N, Function_Call => Exp); return; end if; -- In the case of an Ada 2012 allocator whose initial value comes from a -- function call, pass "the accessibility level determined by the point -- of call" (AI05-0234) to the function. Conceptually, this belongs in -- Expand_Call but it couldn't be done there (because the Etype of the -- allocator wasn't set then) so we generate the parameter here. See -- the Boolean variable Defer in (a block within) Expand_Call. if Ada_Version >= Ada_2012 and then Nkind (Exp) = N_Function_Call then declare Subp : Entity_Id; begin if Nkind (Name (Exp)) = N_Explicit_Dereference then Subp := Designated_Type (Etype (Prefix (Name (Exp)))); else Subp := Entity (Name (Exp)); end if; Subp := Ultimate_Alias (Subp); if Present (Extra_Accessibility_Of_Result (Subp)) then Add_Extra_Actual_To_Call (Subprogram_Call => Exp, Extra_Formal => Extra_Accessibility_Of_Result (Subp), Extra_Actual => Dynamic_Accessibility_Level (PtrT)); end if; end; end if; -- Case of tagged type or type requiring finalization if Is_Tagged_Type (T) or else Needs_Finalization (T) then -- Ada 2005 (AI-318-02): If the initialization expression is a call -- to a build-in-place function, then access to the allocated object -- must be passed to the function. Currently we limit such functions -- to those with constrained limited result subtypes, but eventually -- we plan to expand the allowed forms of functions that are treated -- as build-in-place. if Ada_Version >= Ada_2005 and then Is_Build_In_Place_Function_Call (Exp) then Make_Build_In_Place_Call_In_Allocator (N, Exp); Apply_Accessibility_Check (N, Built_In_Place => True); return; end if; -- Actions inserted before: -- Temp : constant ptr_T := new T'(Expression); -- Temp._tag = T'tag; -- when not class-wide -- [Deep_]Adjust (Temp.all); -- We analyze by hand the new internal allocator to avoid any -- recursion and inappropriate call to Initialize. -- We don't want to remove side effects when the expression must be -- built in place. In the case of a build-in-place function call, -- that could lead to a duplication of the call, which was already -- substituted for the allocator. if not Aggr_In_Place then Remove_Side_Effects (Exp); end if; Temp := Make_Temporary (Loc, 'P', N); -- For a class wide allocation generate the following code: -- type Equiv_Record is record ... end record; -- implicit subtype CW is <Class_Wide_Subytpe>; -- temp : PtrT := new CW'(CW!(expr)); if Is_Class_Wide_Type (T) then Expand_Subtype_From_Expr (Empty, T, Indic, Exp); -- Ada 2005 (AI-251): If the expression is a class-wide interface -- object we generate code to move up "this" to reference the -- base of the object before allocating the new object. -- Note that Exp'Address is recursively expanded into a call -- to Base_Address (Exp.Tag) if Is_Class_Wide_Type (Etype (Exp)) and then Is_Interface (Etype (Exp)) and then Tagged_Type_Expansion then Set_Expression (Expression (N), Unchecked_Convert_To (Entity (Indic), Make_Explicit_Dereference (Loc, Unchecked_Convert_To (RTE (RE_Tag_Ptr), Make_Attribute_Reference (Loc, Prefix => Exp, Attribute_Name => Name_Address))))); else Set_Expression (Expression (N), Unchecked_Convert_To (Entity (Indic), Exp)); end if; Analyze_And_Resolve (Expression (N), Entity (Indic)); end if; -- Processing for allocators returning non-interface types if not Is_Interface (Directly_Designated_Type (PtrT)) then if Aggr_In_Place then Temp_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Object_Definition => New_Occurrence_Of (PtrT, Loc), Expression => Make_Allocator (Loc, Expression => New_Occurrence_Of (Etype (Exp), Loc))); -- Copy the Comes_From_Source flag for the allocator we just -- built, since logically this allocator is a replacement of -- the original allocator node. This is for proper handling of -- restriction No_Implicit_Heap_Allocations. Set_Comes_From_Source (Expression (Temp_Decl), Comes_From_Source (N)); Set_No_Initialization (Expression (Temp_Decl)); Insert_Action (N, Temp_Decl); Build_Allocate_Deallocate_Proc (Temp_Decl, True); Convert_Aggr_In_Allocator (N, Temp_Decl, Exp); else Node := Relocate_Node (N); Set_Analyzed (Node); Temp_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Constant_Present => True, Object_Definition => New_Occurrence_Of (PtrT, Loc), Expression => Node); Insert_Action (N, Temp_Decl); Build_Allocate_Deallocate_Proc (Temp_Decl, True); end if; -- Ada 2005 (AI-251): Handle allocators whose designated type is an -- interface type. In this case we use the type of the qualified -- expression to allocate the object. else declare Def_Id : constant Entity_Id := Make_Temporary (Loc, 'T'); New_Decl : Node_Id; begin New_Decl := Make_Full_Type_Declaration (Loc, Defining_Identifier => Def_Id, Type_Definition => Make_Access_To_Object_Definition (Loc, All_Present => True, Null_Exclusion_Present => False, Constant_Present => Is_Access_Constant (Etype (N)), Subtype_Indication => New_Occurrence_Of (Etype (Exp), Loc))); Insert_Action (N, New_Decl); -- Inherit the allocation-related attributes from the original -- access type. Set_Finalization_Master (Def_Id, Finalization_Master (PtrT)); Set_Associated_Storage_Pool (Def_Id, Associated_Storage_Pool (PtrT)); -- Declare the object using the previous type declaration if Aggr_In_Place then Temp_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Object_Definition => New_Occurrence_Of (Def_Id, Loc), Expression => Make_Allocator (Loc, New_Occurrence_Of (Etype (Exp), Loc))); -- Copy the Comes_From_Source flag for the allocator we just -- built, since logically this allocator is a replacement of -- the original allocator node. This is for proper handling -- of restriction No_Implicit_Heap_Allocations. Set_Comes_From_Source (Expression (Temp_Decl), Comes_From_Source (N)); Set_No_Initialization (Expression (Temp_Decl)); Insert_Action (N, Temp_Decl); Build_Allocate_Deallocate_Proc (Temp_Decl, True); Convert_Aggr_In_Allocator (N, Temp_Decl, Exp); else Node := Relocate_Node (N); Set_Analyzed (Node); Temp_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Constant_Present => True, Object_Definition => New_Occurrence_Of (Def_Id, Loc), Expression => Node); Insert_Action (N, Temp_Decl); Build_Allocate_Deallocate_Proc (Temp_Decl, True); end if; -- Generate an additional object containing the address of the -- returned object. The type of this second object declaration -- is the correct type required for the common processing that -- is still performed by this subprogram. The displacement of -- this pointer to reference the component associated with the -- interface type will be done at the end of common processing. New_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Make_Temporary (Loc, 'P'), Object_Definition => New_Occurrence_Of (PtrT, Loc), Expression => Unchecked_Convert_To (PtrT, New_Occurrence_Of (Temp, Loc))); Insert_Action (N, New_Decl); Temp_Decl := New_Decl; Temp := Defining_Identifier (New_Decl); end; end if; -- Generate the tag assignment -- Suppress the tag assignment for VM targets because VM tags are -- represented implicitly in objects. if not Tagged_Type_Expansion then null; -- Ada 2005 (AI-251): Suppress the tag assignment with class-wide -- interface objects because in this case the tag does not change. elsif Is_Interface (Directly_Designated_Type (Etype (N))) then pragma Assert (Is_Class_Wide_Type (Directly_Designated_Type (Etype (N)))); null; elsif Is_Tagged_Type (T) and then not Is_Class_Wide_Type (T) then TagT := T; TagR := New_Occurrence_Of (Temp, Loc); elsif Is_Private_Type (T) and then Is_Tagged_Type (Underlying_Type (T)) then TagT := Underlying_Type (T); TagR := Unchecked_Convert_To (Underlying_Type (T), Make_Explicit_Dereference (Loc, Prefix => New_Occurrence_Of (Temp, Loc))); end if; if Present (TagT) then declare Full_T : constant Entity_Id := Underlying_Type (TagT); begin Tag_Assign := Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => TagR, Selector_Name => New_Occurrence_Of (First_Tag_Component (Full_T), Loc)), Expression => Unchecked_Convert_To (RTE (RE_Tag), New_Occurrence_Of (Elists.Node (First_Elmt (Access_Disp_Table (Full_T))), Loc))); end; -- The previous assignment has to be done in any case Set_Assignment_OK (Name (Tag_Assign)); Insert_Action (N, Tag_Assign); end if; -- Generate an Adjust call if the object will be moved. In Ada 2005, -- the object may be inherently limited, in which case there is no -- Adjust procedure, and the object is built in place. In Ada 95, the -- object can be limited but not inherently limited if this allocator -- came from a return statement (we're allocating the result on the -- secondary stack). In that case, the object will be moved, so we do -- want to Adjust. if Needs_Finalization (DesigT) and then Needs_Finalization (T) and then not Aggr_In_Place and then not Is_Limited_View (T) then -- An unchecked conversion is needed in the classwide case because -- the designated type can be an ancestor of the subtype mark of -- the allocator. Adj_Call := Make_Adjust_Call (Obj_Ref => Unchecked_Convert_To (T, Make_Explicit_Dereference (Loc, Prefix => New_Occurrence_Of (Temp, Loc))), Typ => T); if Present (Adj_Call) then Insert_Action (N, Adj_Call); end if; end if; -- Note: the accessibility check must be inserted after the call to -- [Deep_]Adjust to ensure proper completion of the assignment. Apply_Accessibility_Check (Temp); Rewrite (N, New_Occurrence_Of (Temp, Loc)); Analyze_And_Resolve (N, PtrT); -- Ada 2005 (AI-251): Displace the pointer to reference the record -- component containing the secondary dispatch table of the interface -- type. if Is_Interface (Directly_Designated_Type (PtrT)) then Displace_Allocator_Pointer (N); end if; -- Always force the generation of a temporary for aggregates when -- generating C code, to simplify the work in the code generator. elsif Aggr_In_Place or else (Modify_Tree_For_C and then Nkind (Exp) = N_Aggregate) then Temp := Make_Temporary (Loc, 'P', N); Temp_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Object_Definition => New_Occurrence_Of (PtrT, Loc), Expression => Make_Allocator (Loc, Expression => New_Occurrence_Of (Etype (Exp), Loc))); -- Copy the Comes_From_Source flag for the allocator we just built, -- since logically this allocator is a replacement of the original -- allocator node. This is for proper handling of restriction -- No_Implicit_Heap_Allocations. Set_Comes_From_Source (Expression (Temp_Decl), Comes_From_Source (N)); Set_No_Initialization (Expression (Temp_Decl)); Insert_Action (N, Temp_Decl); Build_Allocate_Deallocate_Proc (Temp_Decl, True); Convert_Aggr_In_Allocator (N, Temp_Decl, Exp); Rewrite (N, New_Occurrence_Of (Temp, Loc)); Analyze_And_Resolve (N, PtrT); elsif Is_Access_Type (T) and then Can_Never_Be_Null (T) then Install_Null_Excluding_Check (Exp); elsif Is_Access_Type (DesigT) and then Nkind (Exp) = N_Allocator and then Nkind (Expression (Exp)) /= N_Qualified_Expression then -- Apply constraint to designated subtype indication Apply_Constraint_Check (Expression (Exp), Designated_Type (DesigT), No_Sliding => True); if Nkind (Expression (Exp)) = N_Raise_Constraint_Error then -- Propagate constraint_error to enclosing allocator Rewrite (Exp, New_Copy (Expression (Exp))); end if; else Build_Allocate_Deallocate_Proc (N, True); -- If we have: -- type A is access T1; -- X : A := new T2'(...); -- T1 and T2 can be different subtypes, and we might need to check -- both constraints. First check against the type of the qualified -- expression. Apply_Constraint_Check (Exp, T, No_Sliding => True); if Do_Range_Check (Exp) then Generate_Range_Check (Exp, DesigT, CE_Range_Check_Failed); end if; -- A check is also needed in cases where the designated subtype is -- constrained and differs from the subtype given in the qualified -- expression. Note that the check on the qualified expression does -- not allow sliding, but this check does (a relaxation from Ada 83). if Is_Constrained (DesigT) and then not Subtypes_Statically_Match (T, DesigT) then Apply_Constraint_Check (Exp, DesigT, No_Sliding => False); if Do_Range_Check (Exp) then Generate_Range_Check (Exp, DesigT, CE_Range_Check_Failed); end if; end if; -- For an access to unconstrained packed array, GIGI needs to see an -- expression with a constrained subtype in order to compute the -- proper size for the allocator. if Is_Array_Type (T) and then not Is_Constrained (T) and then Is_Packed (T) then declare ConstrT : constant Entity_Id := Make_Temporary (Loc, 'A'); Internal_Exp : constant Node_Id := Relocate_Node (Exp); begin Insert_Action (Exp, Make_Subtype_Declaration (Loc, Defining_Identifier => ConstrT, Subtype_Indication => Make_Subtype_From_Expr (Internal_Exp, T))); Freeze_Itype (ConstrT, Exp); Rewrite (Exp, OK_Convert_To (ConstrT, Internal_Exp)); end; end if; -- Ada 2005 (AI-318-02): If the initialization expression is a call -- to a build-in-place function, then access to the allocated object -- must be passed to the function. Currently we limit such functions -- to those with constrained limited result subtypes, but eventually -- we plan to expand the allowed forms of functions that are treated -- as build-in-place. if Ada_Version >= Ada_2005 and then Is_Build_In_Place_Function_Call (Exp) then Make_Build_In_Place_Call_In_Allocator (N, Exp); end if; end if; exception when RE_Not_Available => return; end Expand_Allocator_Expression; ----------------------------- -- Expand_Array_Comparison -- ----------------------------- -- Expansion is only required in the case of array types. For the unpacked -- case, an appropriate runtime routine is called. For packed cases, and -- also in some other cases where a runtime routine cannot be called, the -- form of the expansion is: -- [body for greater_nn; boolean_expression] -- The body is built by Make_Array_Comparison_Op, and the form of the -- Boolean expression depends on the operator involved. procedure Expand_Array_Comparison (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Op1 : Node_Id := Left_Opnd (N); Op2 : Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); Ctyp : constant Entity_Id := Component_Type (Typ1); Expr : Node_Id; Func_Body : Node_Id; Func_Name : Entity_Id; Comp : RE_Id; Byte_Addressable : constant Boolean := System_Storage_Unit = Byte'Size; -- True for byte addressable target function Length_Less_Than_4 (Opnd : Node_Id) return Boolean; -- Returns True if the length of the given operand is known to be less -- than 4. Returns False if this length is known to be four or greater -- or is not known at compile time. ------------------------ -- Length_Less_Than_4 -- ------------------------ function Length_Less_Than_4 (Opnd : Node_Id) return Boolean is Otyp : constant Entity_Id := Etype (Opnd); begin if Ekind (Otyp) = E_String_Literal_Subtype then return String_Literal_Length (Otyp) < 4; else declare Ityp : constant Entity_Id := Etype (First_Index (Otyp)); Lo : constant Node_Id := Type_Low_Bound (Ityp); Hi : constant Node_Id := Type_High_Bound (Ityp); Lov : Uint; Hiv : Uint; begin if Compile_Time_Known_Value (Lo) then Lov := Expr_Value (Lo); else return False; end if; if Compile_Time_Known_Value (Hi) then Hiv := Expr_Value (Hi); else return False; end if; return Hiv < Lov + 3; end; end if; end Length_Less_Than_4; -- Start of processing for Expand_Array_Comparison begin -- Deal first with unpacked case, where we can call a runtime routine -- except that we avoid this for targets for which are not addressable -- by bytes. if not Is_Bit_Packed_Array (Typ1) and then Byte_Addressable then -- The call we generate is: -- Compare_Array_xn[_Unaligned] -- (left'address, right'address, left'length, right'length) <op> 0 -- x = U for unsigned, S for signed -- n = 8,16,32,64 for component size -- Add _Unaligned if length < 4 and component size is 8. -- <op> is the standard comparison operator if Component_Size (Typ1) = 8 then if Length_Less_Than_4 (Op1) or else Length_Less_Than_4 (Op2) then if Is_Unsigned_Type (Ctyp) then Comp := RE_Compare_Array_U8_Unaligned; else Comp := RE_Compare_Array_S8_Unaligned; end if; else if Is_Unsigned_Type (Ctyp) then Comp := RE_Compare_Array_U8; else Comp := RE_Compare_Array_S8; end if; end if; elsif Component_Size (Typ1) = 16 then if Is_Unsigned_Type (Ctyp) then Comp := RE_Compare_Array_U16; else Comp := RE_Compare_Array_S16; end if; elsif Component_Size (Typ1) = 32 then if Is_Unsigned_Type (Ctyp) then Comp := RE_Compare_Array_U32; else Comp := RE_Compare_Array_S32; end if; else pragma Assert (Component_Size (Typ1) = 64); if Is_Unsigned_Type (Ctyp) then Comp := RE_Compare_Array_U64; else Comp := RE_Compare_Array_S64; end if; end if; if RTE_Available (Comp) then -- Expand to a call only if the runtime function is available, -- otherwise fall back to inline code. Remove_Side_Effects (Op1, Name_Req => True); Remove_Side_Effects (Op2, Name_Req => True); Rewrite (Op1, Make_Function_Call (Sloc (Op1), Name => New_Occurrence_Of (RTE (Comp), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, Prefix => Relocate_Node (Op1), Attribute_Name => Name_Address), Make_Attribute_Reference (Loc, Prefix => Relocate_Node (Op2), Attribute_Name => Name_Address), Make_Attribute_Reference (Loc, Prefix => Relocate_Node (Op1), Attribute_Name => Name_Length), Make_Attribute_Reference (Loc, Prefix => Relocate_Node (Op2), Attribute_Name => Name_Length)))); Rewrite (Op2, Make_Integer_Literal (Sloc (Op2), Intval => Uint_0)); Analyze_And_Resolve (Op1, Standard_Integer); Analyze_And_Resolve (Op2, Standard_Integer); return; end if; end if; -- Cases where we cannot make runtime call -- For (a <= b) we convert to not (a > b) if Chars (N) = Name_Op_Le then Rewrite (N, Make_Op_Not (Loc, Right_Opnd => Make_Op_Gt (Loc, Left_Opnd => Op1, Right_Opnd => Op2))); Analyze_And_Resolve (N, Standard_Boolean); return; -- For < the Boolean expression is -- greater__nn (op2, op1) elsif Chars (N) = Name_Op_Lt then Func_Body := Make_Array_Comparison_Op (Typ1, N); -- Switch operands Op1 := Right_Opnd (N); Op2 := Left_Opnd (N); -- For (a >= b) we convert to not (a < b) elsif Chars (N) = Name_Op_Ge then Rewrite (N, Make_Op_Not (Loc, Right_Opnd => Make_Op_Lt (Loc, Left_Opnd => Op1, Right_Opnd => Op2))); Analyze_And_Resolve (N, Standard_Boolean); return; -- For > the Boolean expression is -- greater__nn (op1, op2) else pragma Assert (Chars (N) = Name_Op_Gt); Func_Body := Make_Array_Comparison_Op (Typ1, N); end if; Func_Name := Defining_Unit_Name (Specification (Func_Body)); Expr := Make_Function_Call (Loc, Name => New_Occurrence_Of (Func_Name, Loc), Parameter_Associations => New_List (Op1, Op2)); Insert_Action (N, Func_Body); Rewrite (N, Expr); Analyze_And_Resolve (N, Standard_Boolean); end Expand_Array_Comparison; --------------------------- -- Expand_Array_Equality -- --------------------------- -- Expand an equality function for multi-dimensional arrays. Here is an -- example of such a function for Nb_Dimension = 2 -- function Enn (A : atyp; B : btyp) return boolean is -- begin -- if (A'length (1) = 0 or else A'length (2) = 0) -- and then -- (B'length (1) = 0 or else B'length (2) = 0) -- then -- return True; -- RM 4.5.2(22) -- end if; -- if A'length (1) /= B'length (1) -- or else -- A'length (2) /= B'length (2) -- then -- return False; -- RM 4.5.2(23) -- end if; -- declare -- A1 : Index_T1 := A'first (1); -- B1 : Index_T1 := B'first (1); -- begin -- loop -- declare -- A2 : Index_T2 := A'first (2); -- B2 : Index_T2 := B'first (2); -- begin -- loop -- if A (A1, A2) /= B (B1, B2) then -- return False; -- end if; -- exit when A2 = A'last (2); -- A2 := Index_T2'succ (A2); -- B2 := Index_T2'succ (B2); -- end loop; -- end; -- exit when A1 = A'last (1); -- A1 := Index_T1'succ (A1); -- B1 := Index_T1'succ (B1); -- end loop; -- end; -- return true; -- end Enn; -- Note on the formal types used (atyp and btyp). If either of the arrays -- is of a private type, we use the underlying type, and do an unchecked -- conversion of the actual. If either of the arrays has a bound depending -- on a discriminant, then we use the base type since otherwise we have an -- escaped discriminant in the function. -- If both arrays are constrained and have the same bounds, we can generate -- a loop with an explicit iteration scheme using a 'Range attribute over -- the first array. function Expand_Array_Equality (Nod : Node_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id; Typ : Entity_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Nod); Decls : constant List_Id := New_List; Index_List1 : constant List_Id := New_List; Index_List2 : constant List_Id := New_List; Actuals : List_Id; Formals : List_Id; Func_Name : Entity_Id; Func_Body : Node_Id; A : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uA); B : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uB); Ltyp : Entity_Id; Rtyp : Entity_Id; -- The parameter types to be used for the formals function Arr_Attr (Arr : Entity_Id; Nam : Name_Id; Num : Int) return Node_Id; -- This builds the attribute reference Arr'Nam (Expr) function Component_Equality (Typ : Entity_Id) return Node_Id; -- Create one statement to compare corresponding components, designated -- by a full set of indexes. function Get_Arg_Type (N : Node_Id) return Entity_Id; -- Given one of the arguments, computes the appropriate type to be used -- for that argument in the corresponding function formal function Handle_One_Dimension (N : Int; Index : Node_Id) return Node_Id; -- This procedure returns the following code -- -- declare -- Bn : Index_T := B'First (N); -- begin -- loop -- xxx -- exit when An = A'Last (N); -- An := Index_T'Succ (An) -- Bn := Index_T'Succ (Bn) -- end loop; -- end; -- -- If both indexes are constrained and identical, the procedure -- returns a simpler loop: -- -- for An in A'Range (N) loop -- xxx -- end loop -- -- N is the dimension for which we are generating a loop. Index is the -- N'th index node, whose Etype is Index_Type_n in the above code. The -- xxx statement is either the loop or declare for the next dimension -- or if this is the last dimension the comparison of corresponding -- components of the arrays. -- -- The actual way the code works is to return the comparison of -- corresponding components for the N+1 call. That's neater. function Test_Empty_Arrays return Node_Id; -- This function constructs the test for both arrays being empty -- (A'length (1) = 0 or else A'length (2) = 0 or else ...) -- and then -- (B'length (1) = 0 or else B'length (2) = 0 or else ...) function Test_Lengths_Correspond return Node_Id; -- This function constructs the test for arrays having different lengths -- in at least one index position, in which case the resulting code is: -- A'length (1) /= B'length (1) -- or else -- A'length (2) /= B'length (2) -- or else -- ... -------------- -- Arr_Attr -- -------------- function Arr_Attr (Arr : Entity_Id; Nam : Name_Id; Num : Int) return Node_Id is begin return Make_Attribute_Reference (Loc, Attribute_Name => Nam, Prefix => New_Occurrence_Of (Arr, Loc), Expressions => New_List (Make_Integer_Literal (Loc, Num))); end Arr_Attr; ------------------------ -- Component_Equality -- ------------------------ function Component_Equality (Typ : Entity_Id) return Node_Id is Test : Node_Id; L, R : Node_Id; begin -- if a(i1...) /= b(j1...) then return false; end if; L := Make_Indexed_Component (Loc, Prefix => Make_Identifier (Loc, Chars (A)), Expressions => Index_List1); R := Make_Indexed_Component (Loc, Prefix => Make_Identifier (Loc, Chars (B)), Expressions => Index_List2); Test := Expand_Composite_Equality (Nod, Component_Type (Typ), L, R, Decls); -- If some (sub)component is an unchecked_union, the whole operation -- will raise program error. if Nkind (Test) = N_Raise_Program_Error then -- This node is going to be inserted at a location where a -- statement is expected: clear its Etype so analysis will set -- it to the expected Standard_Void_Type. Set_Etype (Test, Empty); return Test; else return Make_Implicit_If_Statement (Nod, Condition => Make_Op_Not (Loc, Right_Opnd => Test), Then_Statements => New_List ( Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_False, Loc)))); end if; end Component_Equality; ------------------ -- Get_Arg_Type -- ------------------ function Get_Arg_Type (N : Node_Id) return Entity_Id is T : Entity_Id; X : Node_Id; begin T := Etype (N); if No (T) then return Typ; else T := Underlying_Type (T); X := First_Index (T); while Present (X) loop if Denotes_Discriminant (Type_Low_Bound (Etype (X))) or else Denotes_Discriminant (Type_High_Bound (Etype (X))) then T := Base_Type (T); exit; end if; Next_Index (X); end loop; return T; end if; end Get_Arg_Type; -------------------------- -- Handle_One_Dimension -- --------------------------- function Handle_One_Dimension (N : Int; Index : Node_Id) return Node_Id is Need_Separate_Indexes : constant Boolean := Ltyp /= Rtyp or else not Is_Constrained (Ltyp); -- If the index types are identical, and we are working with -- constrained types, then we can use the same index for both -- of the arrays. An : constant Entity_Id := Make_Temporary (Loc, 'A'); Bn : Entity_Id; Index_T : Entity_Id; Stm_List : List_Id; Loop_Stm : Node_Id; begin if N > Number_Dimensions (Ltyp) then return Component_Equality (Ltyp); end if; -- Case where we generate a loop Index_T := Base_Type (Etype (Index)); if Need_Separate_Indexes then Bn := Make_Temporary (Loc, 'B'); else Bn := An; end if; Append (New_Occurrence_Of (An, Loc), Index_List1); Append (New_Occurrence_Of (Bn, Loc), Index_List2); Stm_List := New_List ( Handle_One_Dimension (N + 1, Next_Index (Index))); if Need_Separate_Indexes then -- Generate guard for loop, followed by increments of indexes Append_To (Stm_List, Make_Exit_Statement (Loc, Condition => Make_Op_Eq (Loc, Left_Opnd => New_Occurrence_Of (An, Loc), Right_Opnd => Arr_Attr (A, Name_Last, N)))); Append_To (Stm_List, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (An, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Index_T, Loc), Attribute_Name => Name_Succ, Expressions => New_List ( New_Occurrence_Of (An, Loc))))); Append_To (Stm_List, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Bn, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Index_T, Loc), Attribute_Name => Name_Succ, Expressions => New_List ( New_Occurrence_Of (Bn, Loc))))); end if; -- If separate indexes, we need a declare block for An and Bn, and a -- loop without an iteration scheme. if Need_Separate_Indexes then Loop_Stm := Make_Implicit_Loop_Statement (Nod, Statements => Stm_List); return Make_Block_Statement (Loc, Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => An, Object_Definition => New_Occurrence_Of (Index_T, Loc), Expression => Arr_Attr (A, Name_First, N)), Make_Object_Declaration (Loc, Defining_Identifier => Bn, Object_Definition => New_Occurrence_Of (Index_T, Loc), Expression => Arr_Attr (B, Name_First, N))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Loop_Stm))); -- If no separate indexes, return loop statement with explicit -- iteration scheme on its own else Loop_Stm := Make_Implicit_Loop_Statement (Nod, Statements => Stm_List, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => An, Discrete_Subtype_Definition => Arr_Attr (A, Name_Range, N)))); return Loop_Stm; end if; end Handle_One_Dimension; ----------------------- -- Test_Empty_Arrays -- ----------------------- function Test_Empty_Arrays return Node_Id is Alist : Node_Id; Blist : Node_Id; Atest : Node_Id; Btest : Node_Id; begin Alist := Empty; Blist := Empty; for J in 1 .. Number_Dimensions (Ltyp) loop Atest := Make_Op_Eq (Loc, Left_Opnd => Arr_Attr (A, Name_Length, J), Right_Opnd => Make_Integer_Literal (Loc, 0)); Btest := Make_Op_Eq (Loc, Left_Opnd => Arr_Attr (B, Name_Length, J), Right_Opnd => Make_Integer_Literal (Loc, 0)); if No (Alist) then Alist := Atest; Blist := Btest; else Alist := Make_Or_Else (Loc, Left_Opnd => Relocate_Node (Alist), Right_Opnd => Atest); Blist := Make_Or_Else (Loc, Left_Opnd => Relocate_Node (Blist), Right_Opnd => Btest); end if; end loop; return Make_And_Then (Loc, Left_Opnd => Alist, Right_Opnd => Blist); end Test_Empty_Arrays; ----------------------------- -- Test_Lengths_Correspond -- ----------------------------- function Test_Lengths_Correspond return Node_Id is Result : Node_Id; Rtest : Node_Id; begin Result := Empty; for J in 1 .. Number_Dimensions (Ltyp) loop Rtest := Make_Op_Ne (Loc, Left_Opnd => Arr_Attr (A, Name_Length, J), Right_Opnd => Arr_Attr (B, Name_Length, J)); if No (Result) then Result := Rtest; else Result := Make_Or_Else (Loc, Left_Opnd => Relocate_Node (Result), Right_Opnd => Rtest); end if; end loop; return Result; end Test_Lengths_Correspond; -- Start of processing for Expand_Array_Equality begin Ltyp := Get_Arg_Type (Lhs); Rtyp := Get_Arg_Type (Rhs); -- For now, if the argument types are not the same, go to the base type, -- since the code assumes that the formals have the same type. This is -- fixable in future ??? if Ltyp /= Rtyp then Ltyp := Base_Type (Ltyp); Rtyp := Base_Type (Rtyp); pragma Assert (Ltyp = Rtyp); end if; -- Build list of formals for function Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => A, Parameter_Type => New_Occurrence_Of (Ltyp, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => B, Parameter_Type => New_Occurrence_Of (Rtyp, Loc))); Func_Name := Make_Temporary (Loc, 'E'); -- Build statement sequence for function Func_Body := Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Func_Name, Parameter_Specifications => Formals, Result_Definition => New_Occurrence_Of (Standard_Boolean, Loc)), Declarations => Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Make_Implicit_If_Statement (Nod, Condition => Test_Empty_Arrays, Then_Statements => New_List ( Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_True, Loc)))), Make_Implicit_If_Statement (Nod, Condition => Test_Lengths_Correspond, Then_Statements => New_List ( Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_False, Loc)))), Handle_One_Dimension (1, First_Index (Ltyp)), Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_True, Loc))))); Set_Has_Completion (Func_Name, True); Set_Is_Inlined (Func_Name); -- If the array type is distinct from the type of the arguments, it -- is the full view of a private type. Apply an unchecked conversion -- to insure that analysis of the call succeeds. declare L, R : Node_Id; begin L := Lhs; R := Rhs; if No (Etype (Lhs)) or else Base_Type (Etype (Lhs)) /= Base_Type (Ltyp) then L := OK_Convert_To (Ltyp, Lhs); end if; if No (Etype (Rhs)) or else Base_Type (Etype (Rhs)) /= Base_Type (Rtyp) then R := OK_Convert_To (Rtyp, Rhs); end if; Actuals := New_List (L, R); end; Append_To (Bodies, Func_Body); return Make_Function_Call (Loc, Name => New_Occurrence_Of (Func_Name, Loc), Parameter_Associations => Actuals); end Expand_Array_Equality; ----------------------------- -- Expand_Boolean_Operator -- ----------------------------- -- Note that we first get the actual subtypes of the operands, since we -- always want to deal with types that have bounds. procedure Expand_Boolean_Operator (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin -- Special case of bit packed array where both operands are known to be -- properly aligned. In this case we use an efficient run time routine -- to carry out the operation (see System.Bit_Ops). if Is_Bit_Packed_Array (Typ) and then not Is_Possibly_Unaligned_Object (Left_Opnd (N)) and then not Is_Possibly_Unaligned_Object (Right_Opnd (N)) then Expand_Packed_Boolean_Operator (N); return; end if; -- For the normal non-packed case, the general expansion is to build -- function for carrying out the comparison (use Make_Boolean_Array_Op) -- and then inserting it into the tree. The original operator node is -- then rewritten as a call to this function. We also use this in the -- packed case if either operand is a possibly unaligned object. declare Loc : constant Source_Ptr := Sloc (N); L : constant Node_Id := Relocate_Node (Left_Opnd (N)); R : constant Node_Id := Relocate_Node (Right_Opnd (N)); Func_Body : Node_Id; Func_Name : Entity_Id; begin Convert_To_Actual_Subtype (L); Convert_To_Actual_Subtype (R); Ensure_Defined (Etype (L), N); Ensure_Defined (Etype (R), N); Apply_Length_Check (R, Etype (L)); if Nkind (N) = N_Op_Xor then Silly_Boolean_Array_Xor_Test (N, Etype (L)); end if; if Nkind (Parent (N)) = N_Assignment_Statement and then Safe_In_Place_Array_Op (Name (Parent (N)), L, R) then Build_Boolean_Array_Proc_Call (Parent (N), L, R); elsif Nkind (Parent (N)) = N_Op_Not and then Nkind (N) = N_Op_And and then Nkind (Parent (Parent (N))) = N_Assignment_Statement and then Safe_In_Place_Array_Op (Name (Parent (Parent (N))), L, R) then return; else Func_Body := Make_Boolean_Array_Op (Etype (L), N); Func_Name := Defining_Unit_Name (Specification (Func_Body)); Insert_Action (N, Func_Body); -- Now rewrite the expression with a call Rewrite (N, Make_Function_Call (Loc, Name => New_Occurrence_Of (Func_Name, Loc), Parameter_Associations => New_List ( L, Make_Type_Conversion (Loc, New_Occurrence_Of (Etype (L), Loc), R)))); Analyze_And_Resolve (N, Typ); end if; end; end Expand_Boolean_Operator; ------------------------------------------------ -- Expand_Compare_Minimize_Eliminate_Overflow -- ------------------------------------------------ procedure Expand_Compare_Minimize_Eliminate_Overflow (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Result_Type : constant Entity_Id := Etype (N); -- Capture result type (could be a derived boolean type) Llo, Lhi : Uint; Rlo, Rhi : Uint; LLIB : constant Entity_Id := Base_Type (Standard_Long_Long_Integer); -- Entity for Long_Long_Integer'Base Check : constant Overflow_Mode_Type := Overflow_Check_Mode; -- Current overflow checking mode procedure Set_True; procedure Set_False; -- These procedures rewrite N with an occurrence of Standard_True or -- Standard_False, and then makes a call to Warn_On_Known_Condition. --------------- -- Set_False -- --------------- procedure Set_False is begin Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); Warn_On_Known_Condition (N); end Set_False; -------------- -- Set_True -- -------------- procedure Set_True is begin Rewrite (N, New_Occurrence_Of (Standard_True, Loc)); Warn_On_Known_Condition (N); end Set_True; -- Start of processing for Expand_Compare_Minimize_Eliminate_Overflow begin -- Nothing to do unless we have a comparison operator with operands -- that are signed integer types, and we are operating in either -- MINIMIZED or ELIMINATED overflow checking mode. if Nkind (N) not in N_Op_Compare or else Check not in Minimized_Or_Eliminated or else not Is_Signed_Integer_Type (Etype (Left_Opnd (N))) then return; end if; -- OK, this is the case we are interested in. First step is to process -- our operands using the Minimize_Eliminate circuitry which applies -- this processing to the two operand subtrees. Minimize_Eliminate_Overflows (Left_Opnd (N), Llo, Lhi, Top_Level => False); Minimize_Eliminate_Overflows (Right_Opnd (N), Rlo, Rhi, Top_Level => False); -- See if the range information decides the result of the comparison. -- We can only do this if we in fact have full range information (which -- won't be the case if either operand is bignum at this stage). if Llo /= No_Uint and then Rlo /= No_Uint then case N_Op_Compare (Nkind (N)) is when N_Op_Eq => if Llo = Lhi and then Rlo = Rhi and then Llo = Rlo then Set_True; elsif Llo > Rhi or else Lhi < Rlo then Set_False; end if; when N_Op_Ge => if Llo >= Rhi then Set_True; elsif Lhi < Rlo then Set_False; end if; when N_Op_Gt => if Llo > Rhi then Set_True; elsif Lhi <= Rlo then Set_False; end if; when N_Op_Le => if Llo > Rhi then Set_False; elsif Lhi <= Rlo then Set_True; end if; when N_Op_Lt => if Llo >= Rhi then Set_False; elsif Lhi < Rlo then Set_True; end if; when N_Op_Ne => if Llo = Lhi and then Rlo = Rhi and then Llo = Rlo then Set_False; elsif Llo > Rhi or else Lhi < Rlo then Set_True; end if; end case; -- All done if we did the rewrite if Nkind (N) not in N_Op_Compare then return; end if; end if; -- Otherwise, time to do the comparison declare Ltype : constant Entity_Id := Etype (Left_Opnd (N)); Rtype : constant Entity_Id := Etype (Right_Opnd (N)); begin -- If the two operands have the same signed integer type we are -- all set, nothing more to do. This is the case where either -- both operands were unchanged, or we rewrote both of them to -- be Long_Long_Integer. -- Note: Entity for the comparison may be wrong, but it's not worth -- the effort to change it, since the back end does not use it. if Is_Signed_Integer_Type (Ltype) and then Base_Type (Ltype) = Base_Type (Rtype) then return; -- Here if bignums are involved (can only happen in ELIMINATED mode) elsif Is_RTE (Ltype, RE_Bignum) or else Is_RTE (Rtype, RE_Bignum) then declare Left : Node_Id := Left_Opnd (N); Right : Node_Id := Right_Opnd (N); -- Bignum references for left and right operands begin if not Is_RTE (Ltype, RE_Bignum) then Left := Convert_To_Bignum (Left); elsif not Is_RTE (Rtype, RE_Bignum) then Right := Convert_To_Bignum (Right); end if; -- We rewrite our node with: -- do -- Bnn : Result_Type; -- declare -- M : Mark_Id := SS_Mark; -- begin -- Bnn := Big_xx (Left, Right); (xx = EQ, NT etc) -- SS_Release (M); -- end; -- in -- Bnn -- end declare Blk : constant Node_Id := Make_Bignum_Block (Loc); Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N); Ent : RE_Id; begin case N_Op_Compare (Nkind (N)) is when N_Op_Eq => Ent := RE_Big_EQ; when N_Op_Ge => Ent := RE_Big_GE; when N_Op_Gt => Ent := RE_Big_GT; when N_Op_Le => Ent := RE_Big_LE; when N_Op_Lt => Ent := RE_Big_LT; when N_Op_Ne => Ent := RE_Big_NE; end case; -- Insert assignment to Bnn into the bignum block Insert_Before (First (Statements (Handled_Statement_Sequence (Blk))), Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Bnn, Loc), Expression => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (Ent), Loc), Parameter_Associations => New_List (Left, Right)))); -- Now do the rewrite with expression actions Rewrite (N, Make_Expression_With_Actions (Loc, Actions => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Bnn, Object_Definition => New_Occurrence_Of (Result_Type, Loc)), Blk), Expression => New_Occurrence_Of (Bnn, Loc))); Analyze_And_Resolve (N, Result_Type); end; end; -- No bignums involved, but types are different, so we must have -- rewritten one of the operands as a Long_Long_Integer but not -- the other one. -- If left operand is Long_Long_Integer, convert right operand -- and we are done (with a comparison of two Long_Long_Integers). elsif Ltype = LLIB then Convert_To_And_Rewrite (LLIB, Right_Opnd (N)); Analyze_And_Resolve (Right_Opnd (N), LLIB, Suppress => All_Checks); return; -- If right operand is Long_Long_Integer, convert left operand -- and we are done (with a comparison of two Long_Long_Integers). -- This is the only remaining possibility else pragma Assert (Rtype = LLIB); Convert_To_And_Rewrite (LLIB, Left_Opnd (N)); Analyze_And_Resolve (Left_Opnd (N), LLIB, Suppress => All_Checks); return; end if; end; end Expand_Compare_Minimize_Eliminate_Overflow; ------------------------------- -- Expand_Composite_Equality -- ------------------------------- -- This function is only called for comparing internal fields of composite -- types when these fields are themselves composites. This is a special -- case because it is not possible to respect normal Ada visibility rules. function Expand_Composite_Equality (Nod : Node_Id; Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Nod); Full_Type : Entity_Id; Prim : Elmt_Id; Eq_Op : Entity_Id; function Find_Primitive_Eq return Node_Id; -- AI05-0123: Locate primitive equality for type if it exists, and -- build the corresponding call. If operation is abstract, replace -- call with an explicit raise. Return Empty if there is no primitive. ----------------------- -- Find_Primitive_Eq -- ----------------------- function Find_Primitive_Eq return Node_Id is Prim_E : Elmt_Id; Prim : Node_Id; begin Prim_E := First_Elmt (Collect_Primitive_Operations (Typ)); while Present (Prim_E) loop Prim := Node (Prim_E); -- Locate primitive equality with the right signature if Chars (Prim) = Name_Op_Eq and then Etype (First_Formal (Prim)) = Etype (Next_Formal (First_Formal (Prim))) and then Etype (Prim) = Standard_Boolean then if Is_Abstract_Subprogram (Prim) then return Make_Raise_Program_Error (Loc, Reason => PE_Explicit_Raise); else return Make_Function_Call (Loc, Name => New_Occurrence_Of (Prim, Loc), Parameter_Associations => New_List (Lhs, Rhs)); end if; end if; Next_Elmt (Prim_E); end loop; -- If not found, predefined operation will be used return Empty; end Find_Primitive_Eq; -- Start of processing for Expand_Composite_Equality begin if Is_Private_Type (Typ) then Full_Type := Underlying_Type (Typ); else Full_Type := Typ; end if; -- If the private type has no completion the context may be the -- expansion of a composite equality for a composite type with some -- still incomplete components. The expression will not be analyzed -- until the enclosing type is completed, at which point this will be -- properly expanded, unless there is a bona fide completion error. if No (Full_Type) then return Make_Op_Eq (Loc, Left_Opnd => Lhs, Right_Opnd => Rhs); end if; Full_Type := Base_Type (Full_Type); -- When the base type itself is private, use the full view to expand -- the composite equality. if Is_Private_Type (Full_Type) then Full_Type := Underlying_Type (Full_Type); end if; -- Case of array types if Is_Array_Type (Full_Type) then -- If the operand is an elementary type other than a floating-point -- type, then we can simply use the built-in block bitwise equality, -- since the predefined equality operators always apply and bitwise -- equality is fine for all these cases. if Is_Elementary_Type (Component_Type (Full_Type)) and then not Is_Floating_Point_Type (Component_Type (Full_Type)) then return Make_Op_Eq (Loc, Left_Opnd => Lhs, Right_Opnd => Rhs); -- For composite component types, and floating-point types, use the -- expansion. This deals with tagged component types (where we use -- the applicable equality routine) and floating-point, (where we -- need to worry about negative zeroes), and also the case of any -- composite type recursively containing such fields. else return Expand_Array_Equality (Nod, Lhs, Rhs, Bodies, Full_Type); end if; -- Case of tagged record types elsif Is_Tagged_Type (Full_Type) then -- Call the primitive operation "=" of this type if Is_Class_Wide_Type (Full_Type) then Full_Type := Root_Type (Full_Type); end if; -- If this is derived from an untagged private type completed with a -- tagged type, it does not have a full view, so we use the primitive -- operations of the private type. This check should no longer be -- necessary when these types receive their full views ??? if Is_Private_Type (Typ) and then not Is_Tagged_Type (Typ) and then not Is_Controlled (Typ) and then Is_Derived_Type (Typ) and then No (Full_View (Typ)) then Prim := First_Elmt (Collect_Primitive_Operations (Typ)); else Prim := First_Elmt (Primitive_Operations (Full_Type)); end if; loop Eq_Op := Node (Prim); exit when Chars (Eq_Op) = Name_Op_Eq and then Etype (First_Formal (Eq_Op)) = Etype (Next_Formal (First_Formal (Eq_Op))) and then Base_Type (Etype (Eq_Op)) = Standard_Boolean; Next_Elmt (Prim); pragma Assert (Present (Prim)); end loop; Eq_Op := Node (Prim); return Make_Function_Call (Loc, Name => New_Occurrence_Of (Eq_Op, Loc), Parameter_Associations => New_List (Unchecked_Convert_To (Etype (First_Formal (Eq_Op)), Lhs), Unchecked_Convert_To (Etype (First_Formal (Eq_Op)), Rhs))); -- Case of untagged record types elsif Is_Record_Type (Full_Type) then Eq_Op := TSS (Full_Type, TSS_Composite_Equality); if Present (Eq_Op) then if Etype (First_Formal (Eq_Op)) /= Full_Type then -- Inherited equality from parent type. Convert the actuals to -- match signature of operation. declare T : constant Entity_Id := Etype (First_Formal (Eq_Op)); begin return Make_Function_Call (Loc, Name => New_Occurrence_Of (Eq_Op, Loc), Parameter_Associations => New_List ( OK_Convert_To (T, Lhs), OK_Convert_To (T, Rhs))); end; else -- Comparison between Unchecked_Union components if Is_Unchecked_Union (Full_Type) then declare Lhs_Type : Node_Id := Full_Type; Rhs_Type : Node_Id := Full_Type; Lhs_Discr_Val : Node_Id; Rhs_Discr_Val : Node_Id; begin -- Lhs subtype if Nkind (Lhs) = N_Selected_Component then Lhs_Type := Etype (Entity (Selector_Name (Lhs))); end if; -- Rhs subtype if Nkind (Rhs) = N_Selected_Component then Rhs_Type := Etype (Entity (Selector_Name (Rhs))); end if; -- Lhs of the composite equality if Is_Constrained (Lhs_Type) then -- Since the enclosing record type can never be an -- Unchecked_Union (this code is executed for records -- that do not have variants), we may reference its -- discriminant(s). if Nkind (Lhs) = N_Selected_Component and then Has_Per_Object_Constraint (Entity (Selector_Name (Lhs))) then Lhs_Discr_Val := Make_Selected_Component (Loc, Prefix => Prefix (Lhs), Selector_Name => New_Copy (Get_Discriminant_Value (First_Discriminant (Lhs_Type), Lhs_Type, Stored_Constraint (Lhs_Type)))); else Lhs_Discr_Val := New_Copy (Get_Discriminant_Value (First_Discriminant (Lhs_Type), Lhs_Type, Stored_Constraint (Lhs_Type))); end if; else -- It is not possible to infer the discriminant since -- the subtype is not constrained. return Make_Raise_Program_Error (Loc, Reason => PE_Unchecked_Union_Restriction); end if; -- Rhs of the composite equality if Is_Constrained (Rhs_Type) then if Nkind (Rhs) = N_Selected_Component and then Has_Per_Object_Constraint (Entity (Selector_Name (Rhs))) then Rhs_Discr_Val := Make_Selected_Component (Loc, Prefix => Prefix (Rhs), Selector_Name => New_Copy (Get_Discriminant_Value (First_Discriminant (Rhs_Type), Rhs_Type, Stored_Constraint (Rhs_Type)))); else Rhs_Discr_Val := New_Copy (Get_Discriminant_Value (First_Discriminant (Rhs_Type), Rhs_Type, Stored_Constraint (Rhs_Type))); end if; else return Make_Raise_Program_Error (Loc, Reason => PE_Unchecked_Union_Restriction); end if; -- Call the TSS equality function with the inferred -- discriminant values. return Make_Function_Call (Loc, Name => New_Occurrence_Of (Eq_Op, Loc), Parameter_Associations => New_List ( Lhs, Rhs, Lhs_Discr_Val, Rhs_Discr_Val)); end; -- All cases other than comparing Unchecked_Union types else declare T : constant Entity_Id := Etype (First_Formal (Eq_Op)); begin return Make_Function_Call (Loc, Name => New_Occurrence_Of (Eq_Op, Loc), Parameter_Associations => New_List ( OK_Convert_To (T, Lhs), OK_Convert_To (T, Rhs))); end; end if; end if; -- Equality composes in Ada 2012 for untagged record types. It also -- composes for bounded strings, because they are part of the -- predefined environment. We could make it compose for bounded -- strings by making them tagged, or by making sure all subcomponents -- are set to the same value, even when not used. Instead, we have -- this special case in the compiler, because it's more efficient. elsif Ada_Version >= Ada_2012 or else Is_Bounded_String (Typ) then -- If no TSS has been created for the type, check whether there is -- a primitive equality declared for it. declare Op : constant Node_Id := Find_Primitive_Eq; begin -- Use user-defined primitive if it exists, otherwise use -- predefined equality. if Present (Op) then return Op; else return Make_Op_Eq (Loc, Lhs, Rhs); end if; end; else return Expand_Record_Equality (Nod, Full_Type, Lhs, Rhs, Bodies); end if; -- Non-composite types (always use predefined equality) else return Make_Op_Eq (Loc, Left_Opnd => Lhs, Right_Opnd => Rhs); end if; end Expand_Composite_Equality; ------------------------ -- Expand_Concatenate -- ------------------------ procedure Expand_Concatenate (Cnode : Node_Id; Opnds : List_Id) is Loc : constant Source_Ptr := Sloc (Cnode); Atyp : constant Entity_Id := Base_Type (Etype (Cnode)); -- Result type of concatenation Ctyp : constant Entity_Id := Base_Type (Component_Type (Etype (Cnode))); -- Component type. Elements of this component type can appear as one -- of the operands of concatenation as well as arrays. Istyp : constant Entity_Id := Etype (First_Index (Atyp)); -- Index subtype Ityp : constant Entity_Id := Base_Type (Istyp); -- Index type. This is the base type of the index subtype, and is used -- for all computed bounds (which may be out of range of Istyp in the -- case of null ranges). Artyp : Entity_Id; -- This is the type we use to do arithmetic to compute the bounds and -- lengths of operands. The choice of this type is a little subtle and -- is discussed in a separate section at the start of the body code. Concatenation_Error : exception; -- Raised if concatenation is sure to raise a CE Result_May_Be_Null : Boolean := True; -- Reset to False if at least one operand is encountered which is known -- at compile time to be non-null. Used for handling the special case -- of setting the high bound to the last operand high bound for a null -- result, thus ensuring a proper high bound in the super-flat case. N : constant Nat := List_Length (Opnds); -- Number of concatenation operands including possibly null operands NN : Nat := 0; -- Number of operands excluding any known to be null, except that the -- last operand is always retained, in case it provides the bounds for -- a null result. Opnd : Node_Id; -- Current operand being processed in the loop through operands. After -- this loop is complete, always contains the last operand (which is not -- the same as Operands (NN), since null operands are skipped). -- Arrays describing the operands, only the first NN entries of each -- array are set (NN < N when we exclude known null operands). Is_Fixed_Length : array (1 .. N) of Boolean; -- True if length of corresponding operand known at compile time Operands : array (1 .. N) of Node_Id; -- Set to the corresponding entry in the Opnds list (but note that null -- operands are excluded, so not all entries in the list are stored). Fixed_Length : array (1 .. N) of Uint; -- Set to length of operand. Entries in this array are set only if the -- corresponding entry in Is_Fixed_Length is True. Opnd_Low_Bound : array (1 .. N) of Node_Id; -- Set to lower bound of operand. Either an integer literal in the case -- where the bound is known at compile time, else actual lower bound. -- The operand low bound is of type Ityp. Var_Length : array (1 .. N) of Entity_Id; -- Set to an entity of type Natural that contains the length of an -- operand whose length is not known at compile time. Entries in this -- array are set only if the corresponding entry in Is_Fixed_Length -- is False. The entity is of type Artyp. Aggr_Length : array (0 .. N) of Node_Id; -- The J'th entry in an expression node that represents the total length -- of operands 1 through J. It is either an integer literal node, or a -- reference to a constant entity with the right value, so it is fine -- to just do a Copy_Node to get an appropriate copy. The extra zero'th -- entry always is set to zero. The length is of type Artyp. Low_Bound : Node_Id; -- A tree node representing the low bound of the result (of type Ityp). -- This is either an integer literal node, or an identifier reference to -- a constant entity initialized to the appropriate value. Last_Opnd_Low_Bound : Node_Id; -- A tree node representing the low bound of the last operand. This -- need only be set if the result could be null. It is used for the -- special case of setting the right low bound for a null result. -- This is of type Ityp. Last_Opnd_High_Bound : Node_Id; -- A tree node representing the high bound of the last operand. This -- need only be set if the result could be null. It is used for the -- special case of setting the right high bound for a null result. -- This is of type Ityp. High_Bound : Node_Id; -- A tree node representing the high bound of the result (of type Ityp) Result : Node_Id; -- Result of the concatenation (of type Ityp) Actions : constant List_Id := New_List; -- Collect actions to be inserted Known_Non_Null_Operand_Seen : Boolean; -- Set True during generation of the assignments of operands into -- result once an operand known to be non-null has been seen. function Make_Artyp_Literal (Val : Nat) return Node_Id; -- This function makes an N_Integer_Literal node that is returned in -- analyzed form with the type set to Artyp. Importantly this literal -- is not flagged as static, so that if we do computations with it that -- result in statically detected out of range conditions, we will not -- generate error messages but instead warning messages. function To_Artyp (X : Node_Id) return Node_Id; -- Given a node of type Ityp, returns the corresponding value of type -- Artyp. For non-enumeration types, this is a plain integer conversion. -- For enum types, the Pos of the value is returned. function To_Ityp (X : Node_Id) return Node_Id; -- The inverse function (uses Val in the case of enumeration types) ------------------------ -- Make_Artyp_Literal -- ------------------------ function Make_Artyp_Literal (Val : Nat) return Node_Id is Result : constant Node_Id := Make_Integer_Literal (Loc, Val); begin Set_Etype (Result, Artyp); Set_Analyzed (Result, True); Set_Is_Static_Expression (Result, False); return Result; end Make_Artyp_Literal; -------------- -- To_Artyp -- -------------- function To_Artyp (X : Node_Id) return Node_Id is begin if Ityp = Base_Type (Artyp) then return X; elsif Is_Enumeration_Type (Ityp) then return Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Ityp, Loc), Attribute_Name => Name_Pos, Expressions => New_List (X)); else return Convert_To (Artyp, X); end if; end To_Artyp; ------------- -- To_Ityp -- ------------- function To_Ityp (X : Node_Id) return Node_Id is begin if Is_Enumeration_Type (Ityp) then return Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Ityp, Loc), Attribute_Name => Name_Val, Expressions => New_List (X)); -- Case where we will do a type conversion else if Ityp = Base_Type (Artyp) then return X; else return Convert_To (Ityp, X); end if; end if; end To_Ityp; -- Local Declarations Lib_Level_Target : constant Boolean := Nkind (Parent (Cnode)) = N_Object_Declaration and then Is_Library_Level_Entity (Defining_Identifier (Parent (Cnode))); -- If the concatenation declares a library level entity, we call the -- built-in concatenation routines to prevent code bloat, regardless -- of optimization level. This is space-efficient, and prevent linking -- problems when units are compiled with different optimizations. Opnd_Typ : Entity_Id; Ent : Entity_Id; Len : Uint; J : Nat; Clen : Node_Id; Set : Boolean; -- Start of processing for Expand_Concatenate begin -- Choose an appropriate computational type -- We will be doing calculations of lengths and bounds in this routine -- and computing one from the other in some cases, e.g. getting the high -- bound by adding the length-1 to the low bound. -- We can't just use the index type, or even its base type for this -- purpose for two reasons. First it might be an enumeration type which -- is not suitable for computations of any kind, and second it may -- simply not have enough range. For example if the index type is -- -128..+127 then lengths can be up to 256, which is out of range of -- the type. -- For enumeration types, we can simply use Standard_Integer, this is -- sufficient since the actual number of enumeration literals cannot -- possibly exceed the range of integer (remember we will be doing the -- arithmetic with POS values, not representation values). if Is_Enumeration_Type (Ityp) then Artyp := Standard_Integer; -- If index type is Positive, we use the standard unsigned type, to give -- more room on the top of the range, obviating the need for an overflow -- check when creating the upper bound. This is needed to avoid junk -- overflow checks in the common case of String types. -- ??? Disabled for now -- elsif Istyp = Standard_Positive then -- Artyp := Standard_Unsigned; -- For modular types, we use a 32-bit modular type for types whose size -- is in the range 1-31 bits. For 32-bit unsigned types, we use the -- identity type, and for larger unsigned types we use 64-bits. elsif Is_Modular_Integer_Type (Ityp) then if RM_Size (Ityp) < RM_Size (Standard_Unsigned) then Artyp := Standard_Unsigned; elsif RM_Size (Ityp) = RM_Size (Standard_Unsigned) then Artyp := Ityp; else Artyp := RTE (RE_Long_Long_Unsigned); end if; -- Similar treatment for signed types else if RM_Size (Ityp) < RM_Size (Standard_Integer) then Artyp := Standard_Integer; elsif RM_Size (Ityp) = RM_Size (Standard_Integer) then Artyp := Ityp; else Artyp := Standard_Long_Long_Integer; end if; end if; -- Supply dummy entry at start of length array Aggr_Length (0) := Make_Artyp_Literal (0); -- Go through operands setting up the above arrays J := 1; while J <= N loop Opnd := Remove_Head (Opnds); Opnd_Typ := Etype (Opnd); -- The parent got messed up when we put the operands in a list, -- so now put back the proper parent for the saved operand, that -- is to say the concatenation node, to make sure that each operand -- is seen as a subexpression, e.g. if actions must be inserted. Set_Parent (Opnd, Cnode); -- Set will be True when we have setup one entry in the array Set := False; -- Singleton element (or character literal) case if Base_Type (Opnd_Typ) = Ctyp then NN := NN + 1; Operands (NN) := Opnd; Is_Fixed_Length (NN) := True; Fixed_Length (NN) := Uint_1; Result_May_Be_Null := False; -- Set low bound of operand (no need to set Last_Opnd_High_Bound -- since we know that the result cannot be null). Opnd_Low_Bound (NN) := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Istyp, Loc), Attribute_Name => Name_First); Set := True; -- String literal case (can only occur for strings of course) elsif Nkind (Opnd) = N_String_Literal then Len := String_Literal_Length (Opnd_Typ); if Len /= 0 then Result_May_Be_Null := False; end if; -- Capture last operand low and high bound if result could be null if J = N and then Result_May_Be_Null then Last_Opnd_Low_Bound := New_Copy_Tree (String_Literal_Low_Bound (Opnd_Typ)); Last_Opnd_High_Bound := Make_Op_Subtract (Loc, Left_Opnd => New_Copy_Tree (String_Literal_Low_Bound (Opnd_Typ)), Right_Opnd => Make_Integer_Literal (Loc, 1)); end if; -- Skip null string literal if J < N and then Len = 0 then goto Continue; end if; NN := NN + 1; Operands (NN) := Opnd; Is_Fixed_Length (NN) := True; -- Set length and bounds Fixed_Length (NN) := Len; Opnd_Low_Bound (NN) := New_Copy_Tree (String_Literal_Low_Bound (Opnd_Typ)); Set := True; -- All other cases else -- Check constrained case with known bounds if Is_Constrained (Opnd_Typ) then declare Index : constant Node_Id := First_Index (Opnd_Typ); Indx_Typ : constant Entity_Id := Etype (Index); Lo : constant Node_Id := Type_Low_Bound (Indx_Typ); Hi : constant Node_Id := Type_High_Bound (Indx_Typ); begin -- Fixed length constrained array type with known at compile -- time bounds is last case of fixed length operand. if Compile_Time_Known_Value (Lo) and then Compile_Time_Known_Value (Hi) then declare Loval : constant Uint := Expr_Value (Lo); Hival : constant Uint := Expr_Value (Hi); Len : constant Uint := UI_Max (Hival - Loval + 1, Uint_0); begin if Len > 0 then Result_May_Be_Null := False; end if; -- Capture last operand bounds if result could be null if J = N and then Result_May_Be_Null then Last_Opnd_Low_Bound := Convert_To (Ityp, Make_Integer_Literal (Loc, Expr_Value (Lo))); Last_Opnd_High_Bound := Convert_To (Ityp, Make_Integer_Literal (Loc, Expr_Value (Hi))); end if; -- Exclude null length case unless last operand if J < N and then Len = 0 then goto Continue; end if; NN := NN + 1; Operands (NN) := Opnd; Is_Fixed_Length (NN) := True; Fixed_Length (NN) := Len; Opnd_Low_Bound (NN) := To_Ityp (Make_Integer_Literal (Loc, Expr_Value (Lo))); Set := True; end; end if; end; end if; -- All cases where the length is not known at compile time, or the -- special case of an operand which is known to be null but has a -- lower bound other than 1 or is other than a string type. if not Set then NN := NN + 1; -- Capture operand bounds Opnd_Low_Bound (NN) := Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr (Opnd, Name_Req => True), Attribute_Name => Name_First); -- Capture last operand bounds if result could be null if J = N and Result_May_Be_Null then Last_Opnd_Low_Bound := Convert_To (Ityp, Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr (Opnd, Name_Req => True), Attribute_Name => Name_First)); Last_Opnd_High_Bound := Convert_To (Ityp, Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr (Opnd, Name_Req => True), Attribute_Name => Name_Last)); end if; -- Capture length of operand in entity Operands (NN) := Opnd; Is_Fixed_Length (NN) := False; Var_Length (NN) := Make_Temporary (Loc, 'L'); Append_To (Actions, Make_Object_Declaration (Loc, Defining_Identifier => Var_Length (NN), Constant_Present => True, Object_Definition => New_Occurrence_Of (Artyp, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr (Opnd, Name_Req => True), Attribute_Name => Name_Length))); end if; end if; -- Set next entry in aggregate length array -- For first entry, make either integer literal for fixed length -- or a reference to the saved length for variable length. if NN = 1 then if Is_Fixed_Length (1) then Aggr_Length (1) := Make_Integer_Literal (Loc, Fixed_Length (1)); else Aggr_Length (1) := New_Occurrence_Of (Var_Length (1), Loc); end if; -- If entry is fixed length and only fixed lengths so far, make -- appropriate new integer literal adding new length. elsif Is_Fixed_Length (NN) and then Nkind (Aggr_Length (NN - 1)) = N_Integer_Literal then Aggr_Length (NN) := Make_Integer_Literal (Loc, Intval => Fixed_Length (NN) + Intval (Aggr_Length (NN - 1))); -- All other cases, construct an addition node for the length and -- create an entity initialized to this length. else Ent := Make_Temporary (Loc, 'L'); if Is_Fixed_Length (NN) then Clen := Make_Integer_Literal (Loc, Fixed_Length (NN)); else Clen := New_Occurrence_Of (Var_Length (NN), Loc); end if; Append_To (Actions, Make_Object_Declaration (Loc, Defining_Identifier => Ent, Constant_Present => True, Object_Definition => New_Occurrence_Of (Artyp, Loc), Expression => Make_Op_Add (Loc, Left_Opnd => New_Copy (Aggr_Length (NN - 1)), Right_Opnd => Clen))); Aggr_Length (NN) := Make_Identifier (Loc, Chars => Chars (Ent)); end if; <<Continue>> J := J + 1; end loop; -- If we have only skipped null operands, return the last operand if NN = 0 then Result := Opnd; goto Done; end if; -- If we have only one non-null operand, return it and we are done. -- There is one case in which this cannot be done, and that is when -- the sole operand is of the element type, in which case it must be -- converted to an array, and the easiest way of doing that is to go -- through the normal general circuit. if NN = 1 and then Base_Type (Etype (Operands (1))) /= Ctyp then Result := Operands (1); goto Done; end if; -- Cases where we have a real concatenation -- Next step is to find the low bound for the result array that we -- will allocate. The rules for this are in (RM 4.5.6(5-7)). -- If the ultimate ancestor of the index subtype is a constrained array -- definition, then the lower bound is that of the index subtype as -- specified by (RM 4.5.3(6)). -- The right test here is to go to the root type, and then the ultimate -- ancestor is the first subtype of this root type. if Is_Constrained (First_Subtype (Root_Type (Atyp))) then Low_Bound := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (First_Subtype (Root_Type (Atyp)), Loc), Attribute_Name => Name_First); -- If the first operand in the list has known length we know that -- the lower bound of the result is the lower bound of this operand. elsif Is_Fixed_Length (1) then Low_Bound := Opnd_Low_Bound (1); -- OK, we don't know the lower bound, we have to build a horrible -- if expression node of the form -- if Cond1'Length /= 0 then -- Opnd1 low bound -- else -- if Opnd2'Length /= 0 then -- Opnd2 low bound -- else -- ... -- The nesting ends either when we hit an operand whose length is known -- at compile time, or on reaching the last operand, whose low bound we -- take unconditionally whether or not it is null. It's easiest to do -- this with a recursive procedure: else declare function Get_Known_Bound (J : Nat) return Node_Id; -- Returns the lower bound determined by operands J .. NN --------------------- -- Get_Known_Bound -- --------------------- function Get_Known_Bound (J : Nat) return Node_Id is begin if Is_Fixed_Length (J) or else J = NN then return New_Copy (Opnd_Low_Bound (J)); else return Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Ne (Loc, Left_Opnd => New_Occurrence_Of (Var_Length (J), Loc), Right_Opnd => Make_Integer_Literal (Loc, 0)), New_Copy (Opnd_Low_Bound (J)), Get_Known_Bound (J + 1))); end if; end Get_Known_Bound; begin Ent := Make_Temporary (Loc, 'L'); Append_To (Actions, Make_Object_Declaration (Loc, Defining_Identifier => Ent, Constant_Present => True, Object_Definition => New_Occurrence_Of (Ityp, Loc), Expression => Get_Known_Bound (1))); Low_Bound := New_Occurrence_Of (Ent, Loc); end; end if; -- Now we can safely compute the upper bound, normally -- Low_Bound + Length - 1. High_Bound := To_Ityp (Make_Op_Add (Loc, Left_Opnd => To_Artyp (New_Copy (Low_Bound)), Right_Opnd => Make_Op_Subtract (Loc, Left_Opnd => New_Copy (Aggr_Length (NN)), Right_Opnd => Make_Artyp_Literal (1)))); -- Note that calculation of the high bound may cause overflow in some -- very weird cases, so in the general case we need an overflow check on -- the high bound. We can avoid this for the common case of string types -- and other types whose index is Positive, since we chose a wider range -- for the arithmetic type. If checks are suppressed we do not set the -- flag, and possibly superfluous warnings will be omitted. if Istyp /= Standard_Positive and then not Overflow_Checks_Suppressed (Istyp) then Activate_Overflow_Check (High_Bound); end if; -- Handle the exceptional case where the result is null, in which case -- case the bounds come from the last operand (so that we get the proper -- bounds if the last operand is super-flat). if Result_May_Be_Null then Low_Bound := Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Eq (Loc, Left_Opnd => New_Copy (Aggr_Length (NN)), Right_Opnd => Make_Artyp_Literal (0)), Last_Opnd_Low_Bound, Low_Bound)); High_Bound := Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Eq (Loc, Left_Opnd => New_Copy (Aggr_Length (NN)), Right_Opnd => Make_Artyp_Literal (0)), Last_Opnd_High_Bound, High_Bound)); end if; -- Here is where we insert the saved up actions Insert_Actions (Cnode, Actions, Suppress => All_Checks); -- Now we construct an array object with appropriate bounds. We mark -- the target as internal to prevent useless initialization when -- Initialize_Scalars is enabled. Also since this is the actual result -- entity, we make sure we have debug information for the result. Ent := Make_Temporary (Loc, 'S'); Set_Is_Internal (Ent); Set_Needs_Debug_Info (Ent); -- If the bound is statically known to be out of range, we do not want -- to abort, we want a warning and a runtime constraint error. Note that -- we have arranged that the result will not be treated as a static -- constant, so we won't get an illegality during this insertion. Insert_Action (Cnode, Make_Object_Declaration (Loc, Defining_Identifier => Ent, Object_Definition => Make_Subtype_Indication (Loc, Subtype_Mark => New_Occurrence_Of (Atyp, Loc), Constraint => Make_Index_Or_Discriminant_Constraint (Loc, Constraints => New_List ( Make_Range (Loc, Low_Bound => Low_Bound, High_Bound => High_Bound))))), Suppress => All_Checks); -- If the result of the concatenation appears as the initializing -- expression of an object declaration, we can just rename the -- result, rather than copying it. Set_OK_To_Rename (Ent); -- Catch the static out of range case now if Raises_Constraint_Error (High_Bound) then raise Concatenation_Error; end if; -- Now we will generate the assignments to do the actual concatenation -- There is one case in which we will not do this, namely when all the -- following conditions are met: -- The result type is Standard.String -- There are nine or fewer retained (non-null) operands -- The optimization level is -O0 -- The corresponding System.Concat_n.Str_Concat_n routine is -- available in the run time. -- The debug flag gnatd.c is not set -- If all these conditions are met then we generate a call to the -- relevant concatenation routine. The purpose of this is to avoid -- undesirable code bloat at -O0. if Atyp = Standard_String and then NN in 2 .. 9 and then (Lib_Level_Target or else ((Optimization_Level = 0 or else Debug_Flag_Dot_CC) and then not Debug_Flag_Dot_C)) then declare RR : constant array (Nat range 2 .. 9) of RE_Id := (RE_Str_Concat_2, RE_Str_Concat_3, RE_Str_Concat_4, RE_Str_Concat_5, RE_Str_Concat_6, RE_Str_Concat_7, RE_Str_Concat_8, RE_Str_Concat_9); begin if RTE_Available (RR (NN)) then declare Opnds : constant List_Id := New_List (New_Occurrence_Of (Ent, Loc)); begin for J in 1 .. NN loop if Is_List_Member (Operands (J)) then Remove (Operands (J)); end if; if Base_Type (Etype (Operands (J))) = Ctyp then Append_To (Opnds, Make_Aggregate (Loc, Component_Associations => New_List ( Make_Component_Association (Loc, Choices => New_List ( Make_Integer_Literal (Loc, 1)), Expression => Operands (J))))); else Append_To (Opnds, Operands (J)); end if; end loop; Insert_Action (Cnode, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RR (NN)), Loc), Parameter_Associations => Opnds)); Result := New_Occurrence_Of (Ent, Loc); goto Done; end; end if; end; end if; -- Not special case so generate the assignments Known_Non_Null_Operand_Seen := False; for J in 1 .. NN loop declare Lo : constant Node_Id := Make_Op_Add (Loc, Left_Opnd => To_Artyp (New_Copy (Low_Bound)), Right_Opnd => Aggr_Length (J - 1)); Hi : constant Node_Id := Make_Op_Add (Loc, Left_Opnd => To_Artyp (New_Copy (Low_Bound)), Right_Opnd => Make_Op_Subtract (Loc, Left_Opnd => Aggr_Length (J), Right_Opnd => Make_Artyp_Literal (1))); begin -- Singleton case, simple assignment if Base_Type (Etype (Operands (J))) = Ctyp then Known_Non_Null_Operand_Seen := True; Insert_Action (Cnode, Make_Assignment_Statement (Loc, Name => Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (Ent, Loc), Expressions => New_List (To_Ityp (Lo))), Expression => Operands (J)), Suppress => All_Checks); -- Array case, slice assignment, skipped when argument is fixed -- length and known to be null. elsif (not Is_Fixed_Length (J)) or else (Fixed_Length (J) > 0) then declare Assign : Node_Id := Make_Assignment_Statement (Loc, Name => Make_Slice (Loc, Prefix => New_Occurrence_Of (Ent, Loc), Discrete_Range => Make_Range (Loc, Low_Bound => To_Ityp (Lo), High_Bound => To_Ityp (Hi))), Expression => Operands (J)); begin if Is_Fixed_Length (J) then Known_Non_Null_Operand_Seen := True; elsif not Known_Non_Null_Operand_Seen then -- Here if operand length is not statically known and no -- operand known to be non-null has been processed yet. -- If operand length is 0, we do not need to perform the -- assignment, and we must avoid the evaluation of the -- high bound of the slice, since it may underflow if the -- low bound is Ityp'First. Assign := Make_Implicit_If_Statement (Cnode, Condition => Make_Op_Ne (Loc, Left_Opnd => New_Occurrence_Of (Var_Length (J), Loc), Right_Opnd => Make_Integer_Literal (Loc, 0)), Then_Statements => New_List (Assign)); end if; Insert_Action (Cnode, Assign, Suppress => All_Checks); end; end if; end; end loop; -- Finally we build the result, which is a reference to the array object Result := New_Occurrence_Of (Ent, Loc); <<Done>> Rewrite (Cnode, Result); Analyze_And_Resolve (Cnode, Atyp); exception when Concatenation_Error => -- Kill warning generated for the declaration of the static out of -- range high bound, and instead generate a Constraint_Error with -- an appropriate specific message. Kill_Dead_Code (Declaration_Node (Entity (High_Bound))); Apply_Compile_Time_Constraint_Error (N => Cnode, Msg => "concatenation result upper bound out of range??", Reason => CE_Range_Check_Failed); end Expand_Concatenate; --------------------------------------------------- -- Expand_Membership_Minimize_Eliminate_Overflow -- --------------------------------------------------- procedure Expand_Membership_Minimize_Eliminate_Overflow (N : Node_Id) is pragma Assert (Nkind (N) = N_In); -- Despite the name, this routine applies only to N_In, not to -- N_Not_In. The latter is always rewritten as not (X in Y). Result_Type : constant Entity_Id := Etype (N); -- Capture result type, may be a derived boolean type Loc : constant Source_Ptr := Sloc (N); Lop : constant Node_Id := Left_Opnd (N); Rop : constant Node_Id := Right_Opnd (N); -- Note: there are many referencs to Etype (Lop) and Etype (Rop). It -- is thus tempting to capture these values, but due to the rewrites -- that occur as a result of overflow checking, these values change -- as we go along, and it is safe just to always use Etype explicitly. Restype : constant Entity_Id := Etype (N); -- Save result type Lo, Hi : Uint; -- Bounds in Minimize calls, not used currently LLIB : constant Entity_Id := Base_Type (Standard_Long_Long_Integer); -- Entity for Long_Long_Integer'Base (Standard should export this???) begin Minimize_Eliminate_Overflows (Lop, Lo, Hi, Top_Level => False); -- If right operand is a subtype name, and the subtype name has no -- predicate, then we can just replace the right operand with an -- explicit range T'First .. T'Last, and use the explicit range code. if Nkind (Rop) /= N_Range and then No (Predicate_Function (Etype (Rop))) then declare Rtyp : constant Entity_Id := Etype (Rop); begin Rewrite (Rop, Make_Range (Loc, Low_Bound => Make_Attribute_Reference (Loc, Attribute_Name => Name_First, Prefix => New_Occurrence_Of (Rtyp, Loc)), High_Bound => Make_Attribute_Reference (Loc, Attribute_Name => Name_Last, Prefix => New_Occurrence_Of (Rtyp, Loc)))); Analyze_And_Resolve (Rop, Rtyp, Suppress => All_Checks); end; end if; -- Here for the explicit range case. Note that the bounds of the range -- have not been processed for minimized or eliminated checks. if Nkind (Rop) = N_Range then Minimize_Eliminate_Overflows (Low_Bound (Rop), Lo, Hi, Top_Level => False); Minimize_Eliminate_Overflows (High_Bound (Rop), Lo, Hi, Top_Level => False); -- We have A in B .. C, treated as A >= B and then A <= C -- Bignum case if Is_RTE (Etype (Lop), RE_Bignum) or else Is_RTE (Etype (Low_Bound (Rop)), RE_Bignum) or else Is_RTE (Etype (High_Bound (Rop)), RE_Bignum) then declare Blk : constant Node_Id := Make_Bignum_Block (Loc); Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N); L : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uL); Lopnd : constant Node_Id := Convert_To_Bignum (Lop); Lbound : constant Node_Id := Convert_To_Bignum (Low_Bound (Rop)); Hbound : constant Node_Id := Convert_To_Bignum (High_Bound (Rop)); -- Now we rewrite the membership test node to look like -- do -- Bnn : Result_Type; -- declare -- M : Mark_Id := SS_Mark; -- L : Bignum := Lopnd; -- begin -- Bnn := Big_GE (L, Lbound) and then Big_LE (L, Hbound) -- SS_Release (M); -- end; -- in -- Bnn -- end begin -- Insert declaration of L into declarations of bignum block Insert_After (Last (Declarations (Blk)), Make_Object_Declaration (Loc, Defining_Identifier => L, Object_Definition => New_Occurrence_Of (RTE (RE_Bignum), Loc), Expression => Lopnd)); -- Insert assignment to Bnn into expressions of bignum block Insert_Before (First (Statements (Handled_Statement_Sequence (Blk))), Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Bnn, Loc), Expression => Make_And_Then (Loc, Left_Opnd => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Big_GE), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (L, Loc), Lbound)), Right_Opnd => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Big_LE), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (L, Loc), Hbound))))); -- Now rewrite the node Rewrite (N, Make_Expression_With_Actions (Loc, Actions => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Bnn, Object_Definition => New_Occurrence_Of (Result_Type, Loc)), Blk), Expression => New_Occurrence_Of (Bnn, Loc))); Analyze_And_Resolve (N, Result_Type); return; end; -- Here if no bignums around else -- Case where types are all the same if Base_Type (Etype (Lop)) = Base_Type (Etype (Low_Bound (Rop))) and then Base_Type (Etype (Lop)) = Base_Type (Etype (High_Bound (Rop))) then null; -- If types are not all the same, it means that we have rewritten -- at least one of them to be of type Long_Long_Integer, and we -- will convert the other operands to Long_Long_Integer. else Convert_To_And_Rewrite (LLIB, Lop); Set_Analyzed (Lop, False); Analyze_And_Resolve (Lop, LLIB); -- For the right operand, avoid unnecessary recursion into -- this routine, we know that overflow is not possible. Convert_To_And_Rewrite (LLIB, Low_Bound (Rop)); Convert_To_And_Rewrite (LLIB, High_Bound (Rop)); Set_Analyzed (Rop, False); Analyze_And_Resolve (Rop, LLIB, Suppress => Overflow_Check); end if; -- Now the three operands are of the same signed integer type, -- so we can use the normal expansion routine for membership, -- setting the flag to prevent recursion into this procedure. Set_No_Minimize_Eliminate (N); Expand_N_In (N); end if; -- Right operand is a subtype name and the subtype has a predicate. We -- have to make sure the predicate is checked, and for that we need to -- use the standard N_In circuitry with appropriate types. else pragma Assert (Present (Predicate_Function (Etype (Rop)))); -- If types are "right", just call Expand_N_In preventing recursion if Base_Type (Etype (Lop)) = Base_Type (Etype (Rop)) then Set_No_Minimize_Eliminate (N); Expand_N_In (N); -- Bignum case elsif Is_RTE (Etype (Lop), RE_Bignum) then -- For X in T, we want to rewrite our node as -- do -- Bnn : Result_Type; -- declare -- M : Mark_Id := SS_Mark; -- Lnn : Long_Long_Integer'Base -- Nnn : Bignum; -- begin -- Nnn := X; -- if not Bignum_In_LLI_Range (Nnn) then -- Bnn := False; -- else -- Lnn := From_Bignum (Nnn); -- Bnn := -- Lnn in LLIB (T'Base'First) .. LLIB (T'Base'Last) -- and then T'Base (Lnn) in T; -- end if; -- SS_Release (M); -- end -- in -- Bnn -- end -- A bit gruesome, but there doesn't seem to be a simpler way declare Blk : constant Node_Id := Make_Bignum_Block (Loc); Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N); Lnn : constant Entity_Id := Make_Temporary (Loc, 'L', N); Nnn : constant Entity_Id := Make_Temporary (Loc, 'N', N); T : constant Entity_Id := Etype (Rop); TB : constant Entity_Id := Base_Type (T); Nin : Node_Id; begin -- Mark the last membership operation to prevent recursion Nin := Make_In (Loc, Left_Opnd => Convert_To (TB, New_Occurrence_Of (Lnn, Loc)), Right_Opnd => New_Occurrence_Of (T, Loc)); Set_No_Minimize_Eliminate (Nin); -- Now decorate the block Insert_After (Last (Declarations (Blk)), Make_Object_Declaration (Loc, Defining_Identifier => Lnn, Object_Definition => New_Occurrence_Of (LLIB, Loc))); Insert_After (Last (Declarations (Blk)), Make_Object_Declaration (Loc, Defining_Identifier => Nnn, Object_Definition => New_Occurrence_Of (RTE (RE_Bignum), Loc))); Insert_List_Before (First (Statements (Handled_Statement_Sequence (Blk))), New_List ( Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Nnn, Loc), Expression => Relocate_Node (Lop)), Make_Implicit_If_Statement (N, Condition => Make_Op_Not (Loc, Right_Opnd => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Bignum_In_LLI_Range), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Nnn, Loc)))), Then_Statements => New_List ( Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Bnn, Loc), Expression => New_Occurrence_Of (Standard_False, Loc))), Else_Statements => New_List ( Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Lnn, Loc), Expression => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_From_Bignum), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Nnn, Loc)))), Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Bnn, Loc), Expression => Make_And_Then (Loc, Left_Opnd => Make_In (Loc, Left_Opnd => New_Occurrence_Of (Lnn, Loc), Right_Opnd => Make_Range (Loc, Low_Bound => Convert_To (LLIB, Make_Attribute_Reference (Loc, Attribute_Name => Name_First, Prefix => New_Occurrence_Of (TB, Loc))), High_Bound => Convert_To (LLIB, Make_Attribute_Reference (Loc, Attribute_Name => Name_Last, Prefix => New_Occurrence_Of (TB, Loc))))), Right_Opnd => Nin)))))); -- Now we can do the rewrite Rewrite (N, Make_Expression_With_Actions (Loc, Actions => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Bnn, Object_Definition => New_Occurrence_Of (Result_Type, Loc)), Blk), Expression => New_Occurrence_Of (Bnn, Loc))); Analyze_And_Resolve (N, Result_Type); return; end; -- Not bignum case, but types don't match (this means we rewrote the -- left operand to be Long_Long_Integer). else pragma Assert (Base_Type (Etype (Lop)) = LLIB); -- We rewrite the membership test as (where T is the type with -- the predicate, i.e. the type of the right operand) -- Lop in LLIB (T'Base'First) .. LLIB (T'Base'Last) -- and then T'Base (Lop) in T declare T : constant Entity_Id := Etype (Rop); TB : constant Entity_Id := Base_Type (T); Nin : Node_Id; begin -- The last membership test is marked to prevent recursion Nin := Make_In (Loc, Left_Opnd => Convert_To (TB, Duplicate_Subexpr (Lop)), Right_Opnd => New_Occurrence_Of (T, Loc)); Set_No_Minimize_Eliminate (Nin); -- Now do the rewrite Rewrite (N, Make_And_Then (Loc, Left_Opnd => Make_In (Loc, Left_Opnd => Lop, Right_Opnd => Make_Range (Loc, Low_Bound => Convert_To (LLIB, Make_Attribute_Reference (Loc, Attribute_Name => Name_First, Prefix => New_Occurrence_Of (TB, Loc))), High_Bound => Convert_To (LLIB, Make_Attribute_Reference (Loc, Attribute_Name => Name_Last, Prefix => New_Occurrence_Of (TB, Loc))))), Right_Opnd => Nin)); Set_Analyzed (N, False); Analyze_And_Resolve (N, Restype); end; end if; end if; end Expand_Membership_Minimize_Eliminate_Overflow; ------------------------ -- Expand_N_Allocator -- ------------------------ procedure Expand_N_Allocator (N : Node_Id) is Etyp : constant Entity_Id := Etype (Expression (N)); Loc : constant Source_Ptr := Sloc (N); PtrT : constant Entity_Id := Etype (N); procedure Rewrite_Coextension (N : Node_Id); -- Static coextensions have the same lifetime as the entity they -- constrain. Such occurrences can be rewritten as aliased objects -- and their unrestricted access used instead of the coextension. function Size_In_Storage_Elements (E : Entity_Id) return Node_Id; -- Given a constrained array type E, returns a node representing the -- code to compute the size in storage elements for the given type. -- This is done without using the attribute (which malfunctions for -- large sizes ???) ------------------------- -- Rewrite_Coextension -- ------------------------- procedure Rewrite_Coextension (N : Node_Id) is Temp_Id : constant Node_Id := Make_Temporary (Loc, 'C'); Temp_Decl : Node_Id; begin -- Generate: -- Cnn : aliased Etyp; Temp_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp_Id, Aliased_Present => True, Object_Definition => New_Occurrence_Of (Etyp, Loc)); if Nkind (Expression (N)) = N_Qualified_Expression then Set_Expression (Temp_Decl, Expression (Expression (N))); end if; Insert_Action (N, Temp_Decl); Rewrite (N, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Temp_Id, Loc), Attribute_Name => Name_Unrestricted_Access)); Analyze_And_Resolve (N, PtrT); end Rewrite_Coextension; ------------------------------ -- Size_In_Storage_Elements -- ------------------------------ function Size_In_Storage_Elements (E : Entity_Id) return Node_Id is begin -- Logically this just returns E'Max_Size_In_Storage_Elements. -- However, the reason for the existence of this function is -- to construct a test for sizes too large, which means near the -- 32-bit limit on a 32-bit machine, and precisely the trouble -- is that we get overflows when sizes are greater than 2**31. -- So what we end up doing for array types is to use the expression: -- number-of-elements * component_type'Max_Size_In_Storage_Elements -- which avoids this problem. All this is a bit bogus, but it does -- mean we catch common cases of trying to allocate arrays that -- are too large, and which in the absence of a check results in -- undetected chaos ??? -- Note in particular that this is a pessimistic estimate in the -- case of packed array types, where an array element might occupy -- just a fraction of a storage element??? declare Len : Node_Id; Res : Node_Id; begin for J in 1 .. Number_Dimensions (E) loop Len := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (E, Loc), Attribute_Name => Name_Length, Expressions => New_List (Make_Integer_Literal (Loc, J))); if J = 1 then Res := Len; else Res := Make_Op_Multiply (Loc, Left_Opnd => Res, Right_Opnd => Len); end if; end loop; return Make_Op_Multiply (Loc, Left_Opnd => Len, Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Component_Type (E), Loc), Attribute_Name => Name_Max_Size_In_Storage_Elements)); end; end Size_In_Storage_Elements; -- Local variables Dtyp : constant Entity_Id := Available_View (Designated_Type (PtrT)); Desig : Entity_Id; Nod : Node_Id; Pool : Entity_Id; Rel_Typ : Entity_Id; Temp : Entity_Id; -- Start of processing for Expand_N_Allocator begin -- RM E.2.3(22). We enforce that the expected type of an allocator -- shall not be a remote access-to-class-wide-limited-private type -- Why is this being done at expansion time, seems clearly wrong ??? Validate_Remote_Access_To_Class_Wide_Type (N); -- Processing for anonymous access-to-controlled types. These access -- types receive a special finalization master which appears in the -- declarations of the enclosing semantic unit. This expansion is done -- now to ensure that any additional types generated by this routine or -- Expand_Allocator_Expression inherit the proper type attributes. if (Ekind (PtrT) = E_Anonymous_Access_Type or else (Is_Itype (PtrT) and then No (Finalization_Master (PtrT)))) and then Needs_Finalization (Dtyp) then -- Detect the allocation of an anonymous controlled object where the -- type of the context is named. For example: -- procedure Proc (Ptr : Named_Access_Typ); -- Proc (new Designated_Typ); -- Regardless of the anonymous-to-named access type conversion, the -- lifetime of the object must be associated with the named access -- type. Use the finalization-related attributes of this type. if Nkind_In (Parent (N), N_Type_Conversion, N_Unchecked_Type_Conversion) and then Ekind_In (Etype (Parent (N)), E_Access_Subtype, E_Access_Type, E_General_Access_Type) then Rel_Typ := Etype (Parent (N)); else Rel_Typ := Empty; end if; -- Anonymous access-to-controlled types allocate on the global pool. -- Note that this is a "root type only" attribute. if No (Associated_Storage_Pool (PtrT)) then if Present (Rel_Typ) then Set_Associated_Storage_Pool (Root_Type (PtrT), Associated_Storage_Pool (Rel_Typ)); else Set_Associated_Storage_Pool (Root_Type (PtrT), RTE (RE_Global_Pool_Object)); end if; end if; -- The finalization master must be inserted and analyzed as part of -- the current semantic unit. Note that the master is updated when -- analysis changes current units. Note that this is a "root type -- only" attribute. if Present (Rel_Typ) then Set_Finalization_Master (Root_Type (PtrT), Finalization_Master (Rel_Typ)); else Build_Anonymous_Master (Root_Type (PtrT)); end if; end if; -- Set the storage pool and find the appropriate version of Allocate to -- call. Do not overwrite the storage pool if it is already set, which -- can happen for build-in-place function returns (see -- Exp_Ch4.Expand_N_Extended_Return_Statement). if No (Storage_Pool (N)) then Pool := Associated_Storage_Pool (Root_Type (PtrT)); if Present (Pool) then Set_Storage_Pool (N, Pool); if Is_RTE (Pool, RE_SS_Pool) then Set_Procedure_To_Call (N, RTE (RE_SS_Allocate)); -- In the case of an allocator for a simple storage pool, locate -- and save a reference to the pool type's Allocate routine. elsif Present (Get_Rep_Pragma (Etype (Pool), Name_Simple_Storage_Pool_Type)) then declare Pool_Type : constant Entity_Id := Base_Type (Etype (Pool)); Alloc_Op : Entity_Id; begin Alloc_Op := Get_Name_Entity_Id (Name_Allocate); while Present (Alloc_Op) loop if Scope (Alloc_Op) = Scope (Pool_Type) and then Present (First_Formal (Alloc_Op)) and then Etype (First_Formal (Alloc_Op)) = Pool_Type then Set_Procedure_To_Call (N, Alloc_Op); exit; else Alloc_Op := Homonym (Alloc_Op); end if; end loop; end; elsif Is_Class_Wide_Type (Etype (Pool)) then Set_Procedure_To_Call (N, RTE (RE_Allocate_Any)); else Set_Procedure_To_Call (N, Find_Prim_Op (Etype (Pool), Name_Allocate)); end if; end if; end if; -- Under certain circumstances we can replace an allocator by an access -- to statically allocated storage. The conditions, as noted in AARM -- 3.10 (10c) are as follows: -- Size and initial value is known at compile time -- Access type is access-to-constant -- The allocator is not part of a constraint on a record component, -- because in that case the inserted actions are delayed until the -- record declaration is fully analyzed, which is too late for the -- analysis of the rewritten allocator. if Is_Access_Constant (PtrT) and then Nkind (Expression (N)) = N_Qualified_Expression and then Compile_Time_Known_Value (Expression (Expression (N))) and then Size_Known_At_Compile_Time (Etype (Expression (Expression (N)))) and then not Is_Record_Type (Current_Scope) then -- Here we can do the optimization. For the allocator -- new x'(y) -- We insert an object declaration -- Tnn : aliased x := y; -- and replace the allocator by Tnn'Unrestricted_Access. Tnn is -- marked as requiring static allocation. Temp := Make_Temporary (Loc, 'T', Expression (Expression (N))); Desig := Subtype_Mark (Expression (N)); -- If context is constrained, use constrained subtype directly, -- so that the constant is not labelled as having a nominally -- unconstrained subtype. if Entity (Desig) = Base_Type (Dtyp) then Desig := New_Occurrence_Of (Dtyp, Loc); end if; Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Temp, Aliased_Present => True, Constant_Present => Is_Access_Constant (PtrT), Object_Definition => Desig, Expression => Expression (Expression (N)))); Rewrite (N, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Temp, Loc), Attribute_Name => Name_Unrestricted_Access)); Analyze_And_Resolve (N, PtrT); -- We set the variable as statically allocated, since we don't want -- it going on the stack of the current procedure. Set_Is_Statically_Allocated (Temp); return; end if; -- Same if the allocator is an access discriminant for a local object: -- instead of an allocator we create a local value and constrain the -- enclosing object with the corresponding access attribute. if Is_Static_Coextension (N) then Rewrite_Coextension (N); return; end if; -- Check for size too large, we do this because the back end misses -- proper checks here and can generate rubbish allocation calls when -- we are near the limit. We only do this for the 32-bit address case -- since that is from a practical point of view where we see a problem. if System_Address_Size = 32 and then not Storage_Checks_Suppressed (PtrT) and then not Storage_Checks_Suppressed (Dtyp) and then not Storage_Checks_Suppressed (Etyp) then -- The check we want to generate should look like -- if Etyp'Max_Size_In_Storage_Elements > 3.5 gigabytes then -- raise Storage_Error; -- end if; -- where 3.5 gigabytes is a constant large enough to accommodate any -- reasonable request for. But we can't do it this way because at -- least at the moment we don't compute this attribute right, and -- can silently give wrong results when the result gets large. Since -- this is all about large results, that's bad, so instead we only -- apply the check for constrained arrays, and manually compute the -- value of the attribute ??? if Is_Array_Type (Etyp) and then Is_Constrained (Etyp) then Insert_Action (N, Make_Raise_Storage_Error (Loc, Condition => Make_Op_Gt (Loc, Left_Opnd => Size_In_Storage_Elements (Etyp), Right_Opnd => Make_Integer_Literal (Loc, Uint_7 * (Uint_2 ** 29))), Reason => SE_Object_Too_Large)); end if; end if; -- If no storage pool has been specified and we have the restriction -- No_Standard_Allocators_After_Elaboration is present, then generate -- a call to Elaboration_Allocators.Check_Standard_Allocator. if Nkind (N) = N_Allocator and then No (Storage_Pool (N)) and then Restriction_Active (No_Standard_Allocators_After_Elaboration) then Insert_Action (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Check_Standard_Allocator), Loc))); end if; -- Handle case of qualified expression (other than optimization above) -- First apply constraint checks, because the bounds or discriminants -- in the aggregate might not match the subtype mark in the allocator. if Nkind (Expression (N)) = N_Qualified_Expression then declare Exp : constant Node_Id := Expression (Expression (N)); Typ : constant Entity_Id := Etype (Expression (N)); begin Apply_Constraint_Check (Exp, Typ); Apply_Predicate_Check (Exp, Typ); end; Expand_Allocator_Expression (N); return; end if; -- If the allocator is for a type which requires initialization, and -- there is no initial value (i.e. operand is a subtype indication -- rather than a qualified expression), then we must generate a call to -- the initialization routine using an expressions action node: -- [Pnnn : constant ptr_T := new (T); Init (Pnnn.all,...); Pnnn] -- Here ptr_T is the pointer type for the allocator, and T is the -- subtype of the allocator. A special case arises if the designated -- type of the access type is a task or contains tasks. In this case -- the call to Init (Temp.all ...) is replaced by code that ensures -- that tasks get activated (see Exp_Ch9.Build_Task_Allocate_Block -- for details). In addition, if the type T is a task type, then the -- first argument to Init must be converted to the task record type. declare T : constant Entity_Id := Entity (Expression (N)); Args : List_Id; Decls : List_Id; Decl : Node_Id; Discr : Elmt_Id; Init : Entity_Id; Init_Arg1 : Node_Id; Init_Call : Node_Id; Temp_Decl : Node_Id; Temp_Type : Entity_Id; begin if No_Initialization (N) then -- Even though this might be a simple allocation, create a custom -- Allocate if the context requires it. if Present (Finalization_Master (PtrT)) then Build_Allocate_Deallocate_Proc (N => N, Is_Allocate => True); end if; -- Case of no initialization procedure present elsif not Has_Non_Null_Base_Init_Proc (T) then -- Case of simple initialization required if Needs_Simple_Initialization (T) then Check_Restriction (No_Default_Initialization, N); Rewrite (Expression (N), Make_Qualified_Expression (Loc, Subtype_Mark => New_Occurrence_Of (T, Loc), Expression => Get_Simple_Init_Val (T, N))); Analyze_And_Resolve (Expression (Expression (N)), T); Analyze_And_Resolve (Expression (N), T); Set_Paren_Count (Expression (Expression (N)), 1); Expand_N_Allocator (N); -- No initialization required else null; end if; -- Case of initialization procedure present, must be called else Check_Restriction (No_Default_Initialization, N); if not Restriction_Active (No_Default_Initialization) then Init := Base_Init_Proc (T); Nod := N; Temp := Make_Temporary (Loc, 'P'); -- Construct argument list for the initialization routine call Init_Arg1 := Make_Explicit_Dereference (Loc, Prefix => New_Occurrence_Of (Temp, Loc)); Set_Assignment_OK (Init_Arg1); Temp_Type := PtrT; -- The initialization procedure expects a specific type. if the -- context is access to class wide, indicate that the object -- being allocated has the right specific type. if Is_Class_Wide_Type (Dtyp) then Init_Arg1 := Unchecked_Convert_To (T, Init_Arg1); end if; -- If designated type is a concurrent type or if it is private -- type whose definition is a concurrent type, the first -- argument in the Init routine has to be unchecked conversion -- to the corresponding record type. If the designated type is -- a derived type, also convert the argument to its root type. if Is_Concurrent_Type (T) then Init_Arg1 := Unchecked_Convert_To ( Corresponding_Record_Type (T), Init_Arg1); elsif Is_Private_Type (T) and then Present (Full_View (T)) and then Is_Concurrent_Type (Full_View (T)) then Init_Arg1 := Unchecked_Convert_To (Corresponding_Record_Type (Full_View (T)), Init_Arg1); elsif Etype (First_Formal (Init)) /= Base_Type (T) then declare Ftyp : constant Entity_Id := Etype (First_Formal (Init)); begin Init_Arg1 := OK_Convert_To (Etype (Ftyp), Init_Arg1); Set_Etype (Init_Arg1, Ftyp); end; end if; Args := New_List (Init_Arg1); -- For the task case, pass the Master_Id of the access type as -- the value of the _Master parameter, and _Chain as the value -- of the _Chain parameter (_Chain will be defined as part of -- the generated code for the allocator). -- In Ada 2005, the context may be a function that returns an -- anonymous access type. In that case the Master_Id has been -- created when expanding the function declaration. if Has_Task (T) then if No (Master_Id (Base_Type (PtrT))) then -- The designated type was an incomplete type, and the -- access type did not get expanded. Salvage it now. if not Restriction_Active (No_Task_Hierarchy) then if Present (Parent (Base_Type (PtrT))) then Expand_N_Full_Type_Declaration (Parent (Base_Type (PtrT))); -- The only other possibility is an itype. For this -- case, the master must exist in the context. This is -- the case when the allocator initializes an access -- component in an init-proc. else pragma Assert (Is_Itype (PtrT)); Build_Master_Renaming (PtrT, N); end if; end if; end if; -- If the context of the allocator is a declaration or an -- assignment, we can generate a meaningful image for it, -- even though subsequent assignments might remove the -- connection between task and entity. We build this image -- when the left-hand side is a simple variable, a simple -- indexed assignment or a simple selected component. if Nkind (Parent (N)) = N_Assignment_Statement then declare Nam : constant Node_Id := Name (Parent (N)); begin if Is_Entity_Name (Nam) then Decls := Build_Task_Image_Decls (Loc, New_Occurrence_Of (Entity (Nam), Sloc (Nam)), T); elsif Nkind_In (Nam, N_Indexed_Component, N_Selected_Component) and then Is_Entity_Name (Prefix (Nam)) then Decls := Build_Task_Image_Decls (Loc, Nam, Etype (Prefix (Nam))); else Decls := Build_Task_Image_Decls (Loc, T, T); end if; end; elsif Nkind (Parent (N)) = N_Object_Declaration then Decls := Build_Task_Image_Decls (Loc, Defining_Identifier (Parent (N)), T); else Decls := Build_Task_Image_Decls (Loc, T, T); end if; if Restriction_Active (No_Task_Hierarchy) then Append_To (Args, New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc)); else Append_To (Args, New_Occurrence_Of (Master_Id (Base_Type (Root_Type (PtrT))), Loc)); end if; Append_To (Args, Make_Identifier (Loc, Name_uChain)); Decl := Last (Decls); Append_To (Args, New_Occurrence_Of (Defining_Identifier (Decl), Loc)); -- Has_Task is false, Decls not used else Decls := No_List; end if; -- Add discriminants if discriminated type declare Dis : Boolean := False; Typ : Entity_Id; begin if Has_Discriminants (T) then Dis := True; Typ := T; -- Type may be a private type with no visible discriminants -- in which case check full view if in scope, or the -- underlying_full_view if dealing with a type whose full -- view may be derived from a private type whose own full -- view has discriminants. elsif Is_Private_Type (T) then if Present (Full_View (T)) and then Has_Discriminants (Full_View (T)) then Dis := True; Typ := Full_View (T); elsif Present (Underlying_Full_View (T)) and then Has_Discriminants (Underlying_Full_View (T)) then Dis := True; Typ := Underlying_Full_View (T); end if; end if; if Dis then -- If the allocated object will be constrained by the -- default values for discriminants, then build a subtype -- with those defaults, and change the allocated subtype -- to that. Note that this happens in fewer cases in Ada -- 2005 (AI-363). if not Is_Constrained (Typ) and then Present (Discriminant_Default_Value (First_Discriminant (Typ))) and then (Ada_Version < Ada_2005 or else not Object_Type_Has_Constrained_Partial_View (Typ, Current_Scope)) then Typ := Build_Default_Subtype (Typ, N); Set_Expression (N, New_Occurrence_Of (Typ, Loc)); end if; Discr := First_Elmt (Discriminant_Constraint (Typ)); while Present (Discr) loop Nod := Node (Discr); Append (New_Copy_Tree (Node (Discr)), Args); -- AI-416: when the discriminant constraint is an -- anonymous access type make sure an accessibility -- check is inserted if necessary (3.10.2(22.q/2)) if Ada_Version >= Ada_2005 and then Ekind (Etype (Nod)) = E_Anonymous_Access_Type then Apply_Accessibility_Check (Nod, Typ, Insert_Node => Nod); end if; Next_Elmt (Discr); end loop; end if; end; -- We set the allocator as analyzed so that when we analyze -- the if expression node, we do not get an unwanted recursive -- expansion of the allocator expression. Set_Analyzed (N, True); Nod := Relocate_Node (N); -- Here is the transformation: -- input: new Ctrl_Typ -- output: Temp : constant Ctrl_Typ_Ptr := new Ctrl_Typ; -- Ctrl_TypIP (Temp.all, ...); -- [Deep_]Initialize (Temp.all); -- Here Ctrl_Typ_Ptr is the pointer type for the allocator, and -- is the subtype of the allocator. Temp_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Constant_Present => True, Object_Definition => New_Occurrence_Of (Temp_Type, Loc), Expression => Nod); Set_Assignment_OK (Temp_Decl); Insert_Action (N, Temp_Decl, Suppress => All_Checks); Build_Allocate_Deallocate_Proc (Temp_Decl, True); -- If the designated type is a task type or contains tasks, -- create block to activate created tasks, and insert -- declaration for Task_Image variable ahead of call. if Has_Task (T) then declare L : constant List_Id := New_List; Blk : Node_Id; begin Build_Task_Allocate_Block (L, Nod, Args); Blk := Last (L); Insert_List_Before (First (Declarations (Blk)), Decls); Insert_Actions (N, L); end; else Insert_Action (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Init, Loc), Parameter_Associations => Args)); end if; if Needs_Finalization (T) then -- Generate: -- [Deep_]Initialize (Init_Arg1); Init_Call := Make_Init_Call (Obj_Ref => New_Copy_Tree (Init_Arg1), Typ => T); -- Guard against a missing [Deep_]Initialize when the -- designated type was not properly frozen. if Present (Init_Call) then Insert_Action (N, Init_Call); end if; end if; Rewrite (N, New_Occurrence_Of (Temp, Loc)); Analyze_And_Resolve (N, PtrT); end if; end if; end; -- Ada 2005 (AI-251): If the allocator is for a class-wide interface -- object that has been rewritten as a reference, we displace "this" -- to reference properly its secondary dispatch table. if Nkind (N) = N_Identifier and then Is_Interface (Dtyp) then Displace_Allocator_Pointer (N); end if; exception when RE_Not_Available => return; end Expand_N_Allocator; ----------------------- -- Expand_N_And_Then -- ----------------------- procedure Expand_N_And_Then (N : Node_Id) renames Expand_Short_Circuit_Operator; ------------------------------ -- Expand_N_Case_Expression -- ------------------------------ procedure Expand_N_Case_Expression (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Par : constant Node_Id := Parent (N); Typ : constant Entity_Id := Etype (N); Acts : List_Id; Alt : Node_Id; Case_Stmt : Node_Id; Decl : Node_Id; Expr : Node_Id; Target : Entity_Id; Target_Typ : Entity_Id; In_Predicate : Boolean := False; -- Flag set when the case expression appears within a predicate Optimize_Return_Stmt : Boolean := False; -- Flag set when the case expression can be optimized in the context of -- a simple return statement. begin -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- If the case expression is a predicate specification, and the type -- to which it applies has a static predicate aspect, do not expand, -- because it will be converted to the proper predicate form later. if Ekind_In (Current_Scope, E_Function, E_Procedure) and then Is_Predicate_Function (Current_Scope) then In_Predicate := True; if Has_Static_Predicate_Aspect (Etype (First_Entity (Current_Scope))) then return; end if; end if; -- When the type of the case expression is elementary, expand -- (case X is when A => AX, when B => BX ...) -- into -- do -- Target : Typ; -- case X is -- when A => -- Target := AX; -- when B => -- Target := BX; -- ... -- end case; -- in Target end; -- In all other cases expand into -- do -- type Ptr_Typ is access all Typ; -- Target : Ptr_Typ; -- case X is -- when A => -- Target := AX'Unrestricted_Access; -- when B => -- Target := BX'Unrestricted_Access; -- ... -- end case; -- in Target.all end; -- This approach avoids extra copies of potentially large objects. It -- also allows handling of values of limited or unconstrained types. -- Small optimization: when the case expression appears in the context -- of a simple return statement, expand into -- case X is -- when A => -- return AX; -- when B => -- return BX; -- ... -- end case; Case_Stmt := Make_Case_Statement (Loc, Expression => Expression (N), Alternatives => New_List); -- Preserve the original context for which the case statement is being -- generated. This is needed by the finalization machinery to prevent -- the premature finalization of controlled objects found within the -- case statement. Set_From_Conditional_Expression (Case_Stmt); Acts := New_List; -- Scalar case if Is_Elementary_Type (Typ) then Target_Typ := Typ; -- ??? Do not perform the optimization when the return statement is -- within a predicate function as this causes supurious errors. Could -- this be a possible mismatch in handling this case somewhere else -- in semantic analysis? Optimize_Return_Stmt := Nkind (Par) = N_Simple_Return_Statement and then not In_Predicate; -- Otherwise create an access type to handle the general case using -- 'Unrestricted_Access. -- Generate: -- type Ptr_Typ is access all Typ; else Target_Typ := Make_Temporary (Loc, 'P'); Append_To (Acts, Make_Full_Type_Declaration (Loc, Defining_Identifier => Target_Typ, Type_Definition => Make_Access_To_Object_Definition (Loc, All_Present => True, Subtype_Indication => New_Occurrence_Of (Typ, Loc)))); end if; -- Create the declaration of the target which captures the value of the -- expression. -- Generate: -- Target : [Ptr_]Typ; if not Optimize_Return_Stmt then Target := Make_Temporary (Loc, 'T'); Decl := Make_Object_Declaration (Loc, Defining_Identifier => Target, Object_Definition => New_Occurrence_Of (Target_Typ, Loc)); Set_No_Initialization (Decl); Append_To (Acts, Decl); end if; -- Process the alternatives Alt := First (Alternatives (N)); while Present (Alt) loop declare Alt_Expr : Node_Id := Expression (Alt); Alt_Loc : constant Source_Ptr := Sloc (Alt_Expr); Stmts : List_Id; begin -- Take the unrestricted access of the expression value for non- -- scalar types. This approach avoids big copies and covers the -- limited and unconstrained cases. -- Generate: -- AX'Unrestricted_Access if not Is_Elementary_Type (Typ) then Alt_Expr := Make_Attribute_Reference (Alt_Loc, Prefix => Relocate_Node (Alt_Expr), Attribute_Name => Name_Unrestricted_Access); end if; -- Generate: -- return AX['Unrestricted_Access]; if Optimize_Return_Stmt then Stmts := New_List ( Make_Simple_Return_Statement (Alt_Loc, Expression => Alt_Expr)); -- Generate: -- Target := AX['Unrestricted_Access]; else Stmts := New_List ( Make_Assignment_Statement (Alt_Loc, Name => New_Occurrence_Of (Target, Loc), Expression => Alt_Expr)); end if; -- Propagate declarations inserted in the node by Insert_Actions -- (for example, temporaries generated to remove side effects). -- These actions must remain attached to the alternative, given -- that they are generated by the corresponding expression. if Present (Actions (Alt)) then Prepend_List (Actions (Alt), Stmts); end if; -- Finalize any transient objects on exit from the alternative. -- This is done only in the return optimization case because -- otherwise the case expression is converted into an expression -- with actions which already contains this form of processing. if Optimize_Return_Stmt then Process_If_Case_Statements (N, Stmts); end if; Append_To (Alternatives (Case_Stmt), Make_Case_Statement_Alternative (Sloc (Alt), Discrete_Choices => Discrete_Choices (Alt), Statements => Stmts)); end; Next (Alt); end loop; -- Rewrite the parent return statement as a case statement if Optimize_Return_Stmt then Rewrite (Par, Case_Stmt); Analyze (Par); -- Otherwise convert the case expression into an expression with actions else Append_To (Acts, Case_Stmt); if Is_Elementary_Type (Typ) then Expr := New_Occurrence_Of (Target, Loc); else Expr := Make_Explicit_Dereference (Loc, Prefix => New_Occurrence_Of (Target, Loc)); end if; -- Generate: -- do -- ... -- in Target[.all] end; Rewrite (N, Make_Expression_With_Actions (Loc, Expression => Expr, Actions => Acts)); Analyze_And_Resolve (N, Typ); end if; end Expand_N_Case_Expression; ----------------------------------- -- Expand_N_Explicit_Dereference -- ----------------------------------- procedure Expand_N_Explicit_Dereference (N : Node_Id) is begin -- Insert explicit dereference call for the checked storage pool case Insert_Dereference_Action (Prefix (N)); -- If the type is an Atomic type for which Atomic_Sync is enabled, then -- we set the atomic sync flag. if Is_Atomic (Etype (N)) and then not Atomic_Synchronization_Disabled (Etype (N)) then Activate_Atomic_Synchronization (N); end if; end Expand_N_Explicit_Dereference; -------------------------------------- -- Expand_N_Expression_With_Actions -- -------------------------------------- procedure Expand_N_Expression_With_Actions (N : Node_Id) is Acts : constant List_Id := Actions (N); procedure Force_Boolean_Evaluation (Expr : Node_Id); -- Force the evaluation of Boolean expression Expr function Process_Action (Act : Node_Id) return Traverse_Result; -- Inspect and process a single action of an expression_with_actions for -- transient objects. If such objects are found, the routine generates -- code to clean them up when the context of the expression is evaluated -- or elaborated. ------------------------------ -- Force_Boolean_Evaluation -- ------------------------------ procedure Force_Boolean_Evaluation (Expr : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Flag_Decl : Node_Id; Flag_Id : Entity_Id; begin -- Relocate the expression to the actions list by capturing its value -- in a Boolean flag. Generate: -- Flag : constant Boolean := Expr; Flag_Id := Make_Temporary (Loc, 'F'); Flag_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Flag_Id, Constant_Present => True, Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc), Expression => Relocate_Node (Expr)); Append (Flag_Decl, Acts); Analyze (Flag_Decl); -- Replace the expression with a reference to the flag Rewrite (Expression (N), New_Occurrence_Of (Flag_Id, Loc)); Analyze (Expression (N)); end Force_Boolean_Evaluation; -------------------- -- Process_Action -- -------------------- function Process_Action (Act : Node_Id) return Traverse_Result is begin if Nkind (Act) = N_Object_Declaration and then Is_Finalizable_Transient (Act, N) then Process_Transient_In_Expression (Act, N, Acts); return Abandon; -- Avoid processing temporary function results multiple times when -- dealing with nested expression_with_actions. elsif Nkind (Act) = N_Expression_With_Actions then return Abandon; -- Do not process temporary function results in loops. This is done -- by Expand_N_Loop_Statement and Build_Finalizer. elsif Nkind (Act) = N_Loop_Statement then return Abandon; end if; return OK; end Process_Action; procedure Process_Single_Action is new Traverse_Proc (Process_Action); -- Local variables Act : Node_Id; -- Start of processing for Expand_N_Expression_With_Actions begin -- Do not evaluate the expression when it denotes an entity because the -- expression_with_actions node will be replaced by the reference. if Is_Entity_Name (Expression (N)) then null; -- Do not evaluate the expression when there are no actions because the -- expression_with_actions node will be replaced by the expression. elsif No (Acts) or else Is_Empty_List (Acts) then null; -- Force the evaluation of the expression by capturing its value in a -- temporary. This ensures that aliases of transient objects do not leak -- to the expression of the expression_with_actions node: -- do -- Trans_Id : Ctrl_Typ := ...; -- Alias : ... := Trans_Id; -- in ... Alias ... end; -- In the example above, Trans_Id cannot be finalized at the end of the -- actions list because this may affect the alias and the final value of -- the expression_with_actions. Forcing the evaluation encapsulates the -- reference to the Alias within the actions list: -- do -- Trans_Id : Ctrl_Typ := ...; -- Alias : ... := Trans_Id; -- Val : constant Boolean := ... Alias ...; -- <finalize Trans_Id> -- in Val end; -- Once this transformation is performed, it is safe to finalize the -- transient object at the end of the actions list. -- Note that Force_Evaluation does not remove side effects in operators -- because it assumes that all operands are evaluated and side effect -- free. This is not the case when an operand depends implicitly on the -- transient object through the use of access types. elsif Is_Boolean_Type (Etype (Expression (N))) then Force_Boolean_Evaluation (Expression (N)); -- The expression of an expression_with_actions node may not necessarily -- be Boolean when the node appears in an if expression. In this case do -- the usual forced evaluation to encapsulate potential aliasing. else Force_Evaluation (Expression (N)); end if; -- Process all transient objects found within the actions of the EWA -- node. Act := First (Acts); while Present (Act) loop Process_Single_Action (Act); Next (Act); end loop; -- Deal with case where there are no actions. In this case we simply -- rewrite the node with its expression since we don't need the actions -- and the specification of this node does not allow a null action list. -- Note: we use Rewrite instead of Replace, because Codepeer is using -- the expanded tree and relying on being able to retrieve the original -- tree in cases like this. This raises a whole lot of issues of whether -- we have problems elsewhere, which will be addressed in the future??? if Is_Empty_List (Acts) then Rewrite (N, Relocate_Node (Expression (N))); end if; end Expand_N_Expression_With_Actions; ---------------------------- -- Expand_N_If_Expression -- ---------------------------- -- Deal with limited types and condition actions procedure Expand_N_If_Expression (N : Node_Id) is Cond : constant Node_Id := First (Expressions (N)); Loc : constant Source_Ptr := Sloc (N); Thenx : constant Node_Id := Next (Cond); Elsex : constant Node_Id := Next (Thenx); Typ : constant Entity_Id := Etype (N); Actions : List_Id; Cnn : Entity_Id; Decl : Node_Id; Expr : Node_Id; New_If : Node_Id; New_N : Node_Id; Ptr_Typ : Entity_Id; begin -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- Fold at compile time if condition known. We have already folded -- static if expressions, but it is possible to fold any case in which -- the condition is known at compile time, even though the result is -- non-static. -- Note that we don't do the fold of such cases in Sem_Elab because -- it can cause infinite loops with the expander adding a conditional -- expression, and Sem_Elab circuitry removing it repeatedly. if Compile_Time_Known_Value (Cond) then declare function Fold_Known_Value (Cond : Node_Id) return Boolean; -- Fold at compile time. Assumes condition known. Return True if -- folding occurred, meaning we're done. ---------------------- -- Fold_Known_Value -- ---------------------- function Fold_Known_Value (Cond : Node_Id) return Boolean is begin if Is_True (Expr_Value (Cond)) then Expr := Thenx; Actions := Then_Actions (N); else Expr := Elsex; Actions := Else_Actions (N); end if; Remove (Expr); if Present (Actions) then -- To minimize the use of Expression_With_Actions, just skip -- the optimization as it is not critical for correctness. if Minimize_Expression_With_Actions then return False; end if; Rewrite (N, Make_Expression_With_Actions (Loc, Expression => Relocate_Node (Expr), Actions => Actions)); Analyze_And_Resolve (N, Typ); else Rewrite (N, Relocate_Node (Expr)); end if; -- Note that the result is never static (legitimate cases of -- static if expressions were folded in Sem_Eval). Set_Is_Static_Expression (N, False); return True; end Fold_Known_Value; begin if Fold_Known_Value (Cond) then return; end if; end; end if; -- If the type is limited, and the back end does not handle limited -- types, then we expand as follows to avoid the possibility of -- improper copying. -- type Ptr is access all Typ; -- Cnn : Ptr; -- if cond then -- <<then actions>> -- Cnn := then-expr'Unrestricted_Access; -- else -- <<else actions>> -- Cnn := else-expr'Unrestricted_Access; -- end if; -- and replace the if expression by a reference to Cnn.all. -- This special case can be skipped if the back end handles limited -- types properly and ensures that no incorrect copies are made. if Is_By_Reference_Type (Typ) and then not Back_End_Handles_Limited_Types then -- When the "then" or "else" expressions involve controlled function -- calls, generated temporaries are chained on the corresponding list -- of actions. These temporaries need to be finalized after the if -- expression is evaluated. Process_If_Case_Statements (N, Then_Actions (N)); Process_If_Case_Statements (N, Else_Actions (N)); -- Generate: -- type Ann is access all Typ; Ptr_Typ := Make_Temporary (Loc, 'A'); Insert_Action (N, Make_Full_Type_Declaration (Loc, Defining_Identifier => Ptr_Typ, Type_Definition => Make_Access_To_Object_Definition (Loc, All_Present => True, Subtype_Indication => New_Occurrence_Of (Typ, Loc)))); -- Generate: -- Cnn : Ann; Cnn := Make_Temporary (Loc, 'C', N); Decl := Make_Object_Declaration (Loc, Defining_Identifier => Cnn, Object_Definition => New_Occurrence_Of (Ptr_Typ, Loc)); -- Generate: -- if Cond then -- Cnn := <Thenx>'Unrestricted_Access; -- else -- Cnn := <Elsex>'Unrestricted_Access; -- end if; New_If := Make_Implicit_If_Statement (N, Condition => Relocate_Node (Cond), Then_Statements => New_List ( Make_Assignment_Statement (Sloc (Thenx), Name => New_Occurrence_Of (Cnn, Sloc (Thenx)), Expression => Make_Attribute_Reference (Loc, Prefix => Relocate_Node (Thenx), Attribute_Name => Name_Unrestricted_Access))), Else_Statements => New_List ( Make_Assignment_Statement (Sloc (Elsex), Name => New_Occurrence_Of (Cnn, Sloc (Elsex)), Expression => Make_Attribute_Reference (Loc, Prefix => Relocate_Node (Elsex), Attribute_Name => Name_Unrestricted_Access)))); -- Preserve the original context for which the if statement is being -- generated. This is needed by the finalization machinery to prevent -- the premature finalization of controlled objects found within the -- if statement. Set_From_Conditional_Expression (New_If); New_N := Make_Explicit_Dereference (Loc, Prefix => New_Occurrence_Of (Cnn, Loc)); -- If the result is an unconstrained array and the if expression is in a -- context other than the initializing expression of the declaration of -- an object, then we pull out the if expression as follows: -- Cnn : constant typ := if-expression -- and then replace the if expression with an occurrence of Cnn. This -- avoids the need in the back end to create on-the-fly variable length -- temporaries (which it cannot do!) -- Note that the test for being in an object declaration avoids doing an -- unnecessary expansion, and also avoids infinite recursion. elsif Is_Array_Type (Typ) and then not Is_Constrained (Typ) and then (Nkind (Parent (N)) /= N_Object_Declaration or else Expression (Parent (N)) /= N) then declare Cnn : constant Node_Id := Make_Temporary (Loc, 'C', N); begin Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Cnn, Constant_Present => True, Object_Definition => New_Occurrence_Of (Typ, Loc), Expression => Relocate_Node (N), Has_Init_Expression => True)); Rewrite (N, New_Occurrence_Of (Cnn, Loc)); return; end; -- For other types, we only need to expand if there are other actions -- associated with either branch. elsif Present (Then_Actions (N)) or else Present (Else_Actions (N)) then -- We now wrap the actions into the appropriate expression if Minimize_Expression_With_Actions and then (Is_Elementary_Type (Underlying_Type (Typ)) or else Is_Constrained (Underlying_Type (Typ))) then -- If we can't use N_Expression_With_Actions nodes, then we insert -- the following sequence of actions (using Insert_Actions): -- Cnn : typ; -- if cond then -- <<then actions>> -- Cnn := then-expr; -- else -- <<else actions>> -- Cnn := else-expr -- end if; -- and replace the if expression by a reference to Cnn Cnn := Make_Temporary (Loc, 'C', N); Decl := Make_Object_Declaration (Loc, Defining_Identifier => Cnn, Object_Definition => New_Occurrence_Of (Typ, Loc)); New_If := Make_Implicit_If_Statement (N, Condition => Relocate_Node (Cond), Then_Statements => New_List ( Make_Assignment_Statement (Sloc (Thenx), Name => New_Occurrence_Of (Cnn, Sloc (Thenx)), Expression => Relocate_Node (Thenx))), Else_Statements => New_List ( Make_Assignment_Statement (Sloc (Elsex), Name => New_Occurrence_Of (Cnn, Sloc (Elsex)), Expression => Relocate_Node (Elsex)))); Set_Assignment_OK (Name (First (Then_Statements (New_If)))); Set_Assignment_OK (Name (First (Else_Statements (New_If)))); New_N := New_Occurrence_Of (Cnn, Loc); -- Regular path using Expression_With_Actions else if Present (Then_Actions (N)) then Rewrite (Thenx, Make_Expression_With_Actions (Sloc (Thenx), Actions => Then_Actions (N), Expression => Relocate_Node (Thenx))); Set_Then_Actions (N, No_List); Analyze_And_Resolve (Thenx, Typ); end if; if Present (Else_Actions (N)) then Rewrite (Elsex, Make_Expression_With_Actions (Sloc (Elsex), Actions => Else_Actions (N), Expression => Relocate_Node (Elsex))); Set_Else_Actions (N, No_List); Analyze_And_Resolve (Elsex, Typ); end if; return; end if; -- If no actions then no expansion needed, gigi will handle it using the -- same approach as a C conditional expression. else return; end if; -- Fall through here for either the limited expansion, or the case of -- inserting actions for non-limited types. In both these cases, we must -- move the SLOC of the parent If statement to the newly created one and -- change it to the SLOC of the expression which, after expansion, will -- correspond to what is being evaluated. if Present (Parent (N)) and then Nkind (Parent (N)) = N_If_Statement then Set_Sloc (New_If, Sloc (Parent (N))); Set_Sloc (Parent (N), Loc); end if; -- Make sure Then_Actions and Else_Actions are appropriately moved -- to the new if statement. if Present (Then_Actions (N)) then Insert_List_Before (First (Then_Statements (New_If)), Then_Actions (N)); end if; if Present (Else_Actions (N)) then Insert_List_Before (First (Else_Statements (New_If)), Else_Actions (N)); end if; Insert_Action (N, Decl); Insert_Action (N, New_If); Rewrite (N, New_N); Analyze_And_Resolve (N, Typ); end Expand_N_If_Expression; ----------------- -- Expand_N_In -- ----------------- procedure Expand_N_In (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Restyp : constant Entity_Id := Etype (N); Lop : constant Node_Id := Left_Opnd (N); Rop : constant Node_Id := Right_Opnd (N); Static : constant Boolean := Is_OK_Static_Expression (N); procedure Substitute_Valid_Check; -- Replaces node N by Lop'Valid. This is done when we have an explicit -- test for the left operand being in range of its subtype. ---------------------------- -- Substitute_Valid_Check -- ---------------------------- procedure Substitute_Valid_Check is function Is_OK_Object_Reference (Nod : Node_Id) return Boolean; -- Determine whether arbitrary node Nod denotes a source object that -- may safely act as prefix of attribute 'Valid. ---------------------------- -- Is_OK_Object_Reference -- ---------------------------- function Is_OK_Object_Reference (Nod : Node_Id) return Boolean is Obj_Ref : Node_Id; begin -- Inspect the original operand Obj_Ref := Original_Node (Nod); -- The object reference must be a source construct, otherwise the -- codefix suggestion may refer to nonexistent code from a user -- perspective. if Comes_From_Source (Obj_Ref) then -- Recover the actual object reference. There may be more cases -- to consider??? loop if Nkind_In (Obj_Ref, N_Type_Conversion, N_Unchecked_Type_Conversion) then Obj_Ref := Expression (Obj_Ref); else exit; end if; end loop; return Is_Object_Reference (Obj_Ref); end if; return False; end Is_OK_Object_Reference; -- Start of processing for Substitute_Valid_Check begin Rewrite (N, Make_Attribute_Reference (Loc, Prefix => Relocate_Node (Lop), Attribute_Name => Name_Valid)); Analyze_And_Resolve (N, Restyp); -- Emit a warning when the left-hand operand of the membership test -- is a source object, otherwise the use of attribute 'Valid would be -- illegal. The warning is not given when overflow checking is either -- MINIMIZED or ELIMINATED, as the danger of optimization has been -- eliminated above. if Is_OK_Object_Reference (Lop) and then Overflow_Check_Mode not in Minimized_Or_Eliminated then Error_Msg_N ("??explicit membership test may be optimized away", N); Error_Msg_N -- CODEFIX ("\??use ''Valid attribute instead", N); end if; end Substitute_Valid_Check; -- Local variables Ltyp : Entity_Id; Rtyp : Entity_Id; -- Start of processing for Expand_N_In begin -- If set membership case, expand with separate procedure if Present (Alternatives (N)) then Expand_Set_Membership (N); return; end if; -- Not set membership, proceed with expansion Ltyp := Etype (Left_Opnd (N)); Rtyp := Etype (Right_Opnd (N)); -- If MINIMIZED/ELIMINATED overflow mode and type is a signed integer -- type, then expand with a separate procedure. Note the use of the -- flag No_Minimize_Eliminate to prevent infinite recursion. if Overflow_Check_Mode in Minimized_Or_Eliminated and then Is_Signed_Integer_Type (Ltyp) and then not No_Minimize_Eliminate (N) then Expand_Membership_Minimize_Eliminate_Overflow (N); return; end if; -- Check case of explicit test for an expression in range of its -- subtype. This is suspicious usage and we replace it with a 'Valid -- test and give a warning for scalar types. if Is_Scalar_Type (Ltyp) -- Only relevant for source comparisons and then Comes_From_Source (N) -- In floating-point this is a standard way to check for finite values -- and using 'Valid would typically be a pessimization. and then not Is_Floating_Point_Type (Ltyp) -- Don't give the message unless right operand is a type entity and -- the type of the left operand matches this type. Note that this -- eliminates the cases where MINIMIZED/ELIMINATED mode overflow -- checks have changed the type of the left operand. and then Nkind (Rop) in N_Has_Entity and then Ltyp = Entity (Rop) -- Skip this for predicated types, where such expressions are a -- reasonable way of testing if something meets the predicate. and then not Present (Predicate_Function (Ltyp)) then Substitute_Valid_Check; return; end if; -- Do validity check on operands if Validity_Checks_On and Validity_Check_Operands then Ensure_Valid (Left_Opnd (N)); Validity_Check_Range (Right_Opnd (N)); end if; -- Case of explicit range if Nkind (Rop) = N_Range then declare Lo : constant Node_Id := Low_Bound (Rop); Hi : constant Node_Id := High_Bound (Rop); Lo_Orig : constant Node_Id := Original_Node (Lo); Hi_Orig : constant Node_Id := Original_Node (Hi); Lcheck : Compare_Result; Ucheck : Compare_Result; Warn1 : constant Boolean := Constant_Condition_Warnings and then Comes_From_Source (N) and then not In_Instance; -- This must be true for any of the optimization warnings, we -- clearly want to give them only for source with the flag on. We -- also skip these warnings in an instance since it may be the -- case that different instantiations have different ranges. Warn2 : constant Boolean := Warn1 and then Nkind (Original_Node (Rop)) = N_Range and then Is_Integer_Type (Etype (Lo)); -- For the case where only one bound warning is elided, we also -- insist on an explicit range and an integer type. The reason is -- that the use of enumeration ranges including an end point is -- common, as is the use of a subtype name, one of whose bounds is -- the same as the type of the expression. begin -- If test is explicit x'First .. x'Last, replace by valid check -- Could use some individual comments for this complex test ??? if Is_Scalar_Type (Ltyp) -- And left operand is X'First where X matches left operand -- type (this eliminates cases of type mismatch, including -- the cases where ELIMINATED/MINIMIZED mode has changed the -- type of the left operand. and then Nkind (Lo_Orig) = N_Attribute_Reference and then Attribute_Name (Lo_Orig) = Name_First and then Nkind (Prefix (Lo_Orig)) in N_Has_Entity and then Entity (Prefix (Lo_Orig)) = Ltyp -- Same tests for right operand and then Nkind (Hi_Orig) = N_Attribute_Reference and then Attribute_Name (Hi_Orig) = Name_Last and then Nkind (Prefix (Hi_Orig)) in N_Has_Entity and then Entity (Prefix (Hi_Orig)) = Ltyp -- Relevant only for source cases and then Comes_From_Source (N) then Substitute_Valid_Check; goto Leave; end if; -- If bounds of type are known at compile time, and the end points -- are known at compile time and identical, this is another case -- for substituting a valid test. We only do this for discrete -- types, since it won't arise in practice for float types. if Comes_From_Source (N) and then Is_Discrete_Type (Ltyp) and then Compile_Time_Known_Value (Type_High_Bound (Ltyp)) and then Compile_Time_Known_Value (Type_Low_Bound (Ltyp)) and then Compile_Time_Known_Value (Lo) and then Compile_Time_Known_Value (Hi) and then Expr_Value (Type_High_Bound (Ltyp)) = Expr_Value (Hi) and then Expr_Value (Type_Low_Bound (Ltyp)) = Expr_Value (Lo) -- Kill warnings in instances, since they may be cases where we -- have a test in the generic that makes sense with some types -- and not with other types. and then not In_Instance then Substitute_Valid_Check; goto Leave; end if; -- If we have an explicit range, do a bit of optimization based on -- range analysis (we may be able to kill one or both checks). Lcheck := Compile_Time_Compare (Lop, Lo, Assume_Valid => False); Ucheck := Compile_Time_Compare (Lop, Hi, Assume_Valid => False); -- If either check is known to fail, replace result by False since -- the other check does not matter. Preserve the static flag for -- legality checks, because we are constant-folding beyond RM 4.9. if Lcheck = LT or else Ucheck = GT then if Warn1 then Error_Msg_N ("?c?range test optimized away", N); Error_Msg_N ("\?c?value is known to be out of range", N); end if; Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); Analyze_And_Resolve (N, Restyp); Set_Is_Static_Expression (N, Static); goto Leave; -- If both checks are known to succeed, replace result by True, -- since we know we are in range. elsif Lcheck in Compare_GE and then Ucheck in Compare_LE then if Warn1 then Error_Msg_N ("?c?range test optimized away", N); Error_Msg_N ("\?c?value is known to be in range", N); end if; Rewrite (N, New_Occurrence_Of (Standard_True, Loc)); Analyze_And_Resolve (N, Restyp); Set_Is_Static_Expression (N, Static); goto Leave; -- If lower bound check succeeds and upper bound check is not -- known to succeed or fail, then replace the range check with -- a comparison against the upper bound. elsif Lcheck in Compare_GE then if Warn2 and then not In_Instance then Error_Msg_N ("??lower bound test optimized away", Lo); Error_Msg_N ("\??value is known to be in range", Lo); end if; Rewrite (N, Make_Op_Le (Loc, Left_Opnd => Lop, Right_Opnd => High_Bound (Rop))); Analyze_And_Resolve (N, Restyp); goto Leave; -- If upper bound check succeeds and lower bound check is not -- known to succeed or fail, then replace the range check with -- a comparison against the lower bound. elsif Ucheck in Compare_LE then if Warn2 and then not In_Instance then Error_Msg_N ("??upper bound test optimized away", Hi); Error_Msg_N ("\??value is known to be in range", Hi); end if; Rewrite (N, Make_Op_Ge (Loc, Left_Opnd => Lop, Right_Opnd => Low_Bound (Rop))); Analyze_And_Resolve (N, Restyp); goto Leave; end if; -- We couldn't optimize away the range check, but there is one -- more issue. If we are checking constant conditionals, then we -- see if we can determine the outcome assuming everything is -- valid, and if so give an appropriate warning. if Warn1 and then not Assume_No_Invalid_Values then Lcheck := Compile_Time_Compare (Lop, Lo, Assume_Valid => True); Ucheck := Compile_Time_Compare (Lop, Hi, Assume_Valid => True); -- Result is out of range for valid value if Lcheck = LT or else Ucheck = GT then Error_Msg_N ("?c?value can only be in range if it is invalid", N); -- Result is in range for valid value elsif Lcheck in Compare_GE and then Ucheck in Compare_LE then Error_Msg_N ("?c?value can only be out of range if it is invalid", N); -- Lower bound check succeeds if value is valid elsif Warn2 and then Lcheck in Compare_GE then Error_Msg_N ("?c?lower bound check only fails if it is invalid", Lo); -- Upper bound check succeeds if value is valid elsif Warn2 and then Ucheck in Compare_LE then Error_Msg_N ("?c?upper bound check only fails for invalid values", Hi); end if; end if; end; -- For all other cases of an explicit range, nothing to be done goto Leave; -- Here right operand is a subtype mark else declare Typ : Entity_Id := Etype (Rop); Is_Acc : constant Boolean := Is_Access_Type (Typ); Cond : Node_Id := Empty; New_N : Node_Id; Obj : Node_Id := Lop; SCIL_Node : Node_Id; begin Remove_Side_Effects (Obj); -- For tagged type, do tagged membership operation if Is_Tagged_Type (Typ) then -- No expansion will be performed for VM targets, as the VM -- back-ends will handle the membership tests directly. if Tagged_Type_Expansion then Tagged_Membership (N, SCIL_Node, New_N); Rewrite (N, New_N); Analyze_And_Resolve (N, Restyp); -- Update decoration of relocated node referenced by the -- SCIL node. if Generate_SCIL and then Present (SCIL_Node) then Set_SCIL_Node (N, SCIL_Node); end if; end if; goto Leave; -- If type is scalar type, rewrite as x in t'First .. t'Last. -- This reason we do this is that the bounds may have the wrong -- type if they come from the original type definition. Also this -- way we get all the processing above for an explicit range. -- Don't do this for predicated types, since in this case we -- want to check the predicate. elsif Is_Scalar_Type (Typ) then if No (Predicate_Function (Typ)) then Rewrite (Rop, Make_Range (Loc, Low_Bound => Make_Attribute_Reference (Loc, Attribute_Name => Name_First, Prefix => New_Occurrence_Of (Typ, Loc)), High_Bound => Make_Attribute_Reference (Loc, Attribute_Name => Name_Last, Prefix => New_Occurrence_Of (Typ, Loc)))); Analyze_And_Resolve (N, Restyp); end if; goto Leave; -- Ada 2005 (AI-216): Program_Error is raised when evaluating -- a membership test if the subtype mark denotes a constrained -- Unchecked_Union subtype and the expression lacks inferable -- discriminants. elsif Is_Unchecked_Union (Base_Type (Typ)) and then Is_Constrained (Typ) and then not Has_Inferable_Discriminants (Lop) then Insert_Action (N, Make_Raise_Program_Error (Loc, Reason => PE_Unchecked_Union_Restriction)); -- Prevent Gigi from generating incorrect code by rewriting the -- test as False. What is this undocumented thing about ??? Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); goto Leave; end if; -- Here we have a non-scalar type if Is_Acc then Typ := Designated_Type (Typ); end if; if not Is_Constrained (Typ) then Rewrite (N, New_Occurrence_Of (Standard_True, Loc)); Analyze_And_Resolve (N, Restyp); -- For the constrained array case, we have to check the subscripts -- for an exact match if the lengths are non-zero (the lengths -- must match in any case). elsif Is_Array_Type (Typ) then Check_Subscripts : declare function Build_Attribute_Reference (E : Node_Id; Nam : Name_Id; Dim : Nat) return Node_Id; -- Build attribute reference E'Nam (Dim) ------------------------------- -- Build_Attribute_Reference -- ------------------------------- function Build_Attribute_Reference (E : Node_Id; Nam : Name_Id; Dim : Nat) return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => E, Attribute_Name => Nam, Expressions => New_List ( Make_Integer_Literal (Loc, Dim))); end Build_Attribute_Reference; -- Start of processing for Check_Subscripts begin for J in 1 .. Number_Dimensions (Typ) loop Evolve_And_Then (Cond, Make_Op_Eq (Loc, Left_Opnd => Build_Attribute_Reference (Duplicate_Subexpr_No_Checks (Obj), Name_First, J), Right_Opnd => Build_Attribute_Reference (New_Occurrence_Of (Typ, Loc), Name_First, J))); Evolve_And_Then (Cond, Make_Op_Eq (Loc, Left_Opnd => Build_Attribute_Reference (Duplicate_Subexpr_No_Checks (Obj), Name_Last, J), Right_Opnd => Build_Attribute_Reference (New_Occurrence_Of (Typ, Loc), Name_Last, J))); end loop; if Is_Acc then Cond := Make_Or_Else (Loc, Left_Opnd => Make_Op_Eq (Loc, Left_Opnd => Obj, Right_Opnd => Make_Null (Loc)), Right_Opnd => Cond); end if; Rewrite (N, Cond); Analyze_And_Resolve (N, Restyp); end Check_Subscripts; -- These are the cases where constraint checks may be required, -- e.g. records with possible discriminants else -- Expand the test into a series of discriminant comparisons. -- The expression that is built is the negation of the one that -- is used for checking discriminant constraints. Obj := Relocate_Node (Left_Opnd (N)); if Has_Discriminants (Typ) then Cond := Make_Op_Not (Loc, Right_Opnd => Build_Discriminant_Checks (Obj, Typ)); if Is_Acc then Cond := Make_Or_Else (Loc, Left_Opnd => Make_Op_Eq (Loc, Left_Opnd => Obj, Right_Opnd => Make_Null (Loc)), Right_Opnd => Cond); end if; else Cond := New_Occurrence_Of (Standard_True, Loc); end if; Rewrite (N, Cond); Analyze_And_Resolve (N, Restyp); end if; -- Ada 2012 (AI05-0149): Handle membership tests applied to an -- expression of an anonymous access type. This can involve an -- accessibility test and a tagged type membership test in the -- case of tagged designated types. if Ada_Version >= Ada_2012 and then Is_Acc and then Ekind (Ltyp) = E_Anonymous_Access_Type then declare Expr_Entity : Entity_Id := Empty; New_N : Node_Id; Param_Level : Node_Id; Type_Level : Node_Id; begin if Is_Entity_Name (Lop) then Expr_Entity := Param_Entity (Lop); if not Present (Expr_Entity) then Expr_Entity := Entity (Lop); end if; end if; -- If a conversion of the anonymous access value to the -- tested type would be illegal, then the result is False. if not Valid_Conversion (Lop, Rtyp, Lop, Report_Errs => False) then Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); Analyze_And_Resolve (N, Restyp); -- Apply an accessibility check if the access object has an -- associated access level and when the level of the type is -- less deep than the level of the access parameter. This -- only occur for access parameters and stand-alone objects -- of an anonymous access type. else if Present (Expr_Entity) and then Present (Effective_Extra_Accessibility (Expr_Entity)) and then UI_Gt (Object_Access_Level (Lop), Type_Access_Level (Rtyp)) then Param_Level := New_Occurrence_Of (Effective_Extra_Accessibility (Expr_Entity), Loc); Type_Level := Make_Integer_Literal (Loc, Type_Access_Level (Rtyp)); -- Return True only if the accessibility level of the -- expression entity is not deeper than the level of -- the tested access type. Rewrite (N, Make_And_Then (Loc, Left_Opnd => Relocate_Node (N), Right_Opnd => Make_Op_Le (Loc, Left_Opnd => Param_Level, Right_Opnd => Type_Level))); Analyze_And_Resolve (N); end if; -- If the designated type is tagged, do tagged membership -- operation. -- *** NOTE: we have to check not null before doing the -- tagged membership test (but maybe that can be done -- inside Tagged_Membership?). if Is_Tagged_Type (Typ) then Rewrite (N, Make_And_Then (Loc, Left_Opnd => Relocate_Node (N), Right_Opnd => Make_Op_Ne (Loc, Left_Opnd => Obj, Right_Opnd => Make_Null (Loc)))); -- No expansion will be performed for VM targets, as -- the VM back-ends will handle the membership tests -- directly. if Tagged_Type_Expansion then -- Note that we have to pass Original_Node, because -- the membership test might already have been -- rewritten by earlier parts of membership test. Tagged_Membership (Original_Node (N), SCIL_Node, New_N); -- Update decoration of relocated node referenced -- by the SCIL node. if Generate_SCIL and then Present (SCIL_Node) then Set_SCIL_Node (New_N, SCIL_Node); end if; Rewrite (N, Make_And_Then (Loc, Left_Opnd => Relocate_Node (N), Right_Opnd => New_N)); Analyze_And_Resolve (N, Restyp); end if; end if; end if; end; end if; end; end if; -- At this point, we have done the processing required for the basic -- membership test, but not yet dealt with the predicate. <<Leave>> -- If a predicate is present, then we do the predicate test, but we -- most certainly want to omit this if we are within the predicate -- function itself, since otherwise we have an infinite recursion. -- The check should also not be emitted when testing against a range -- (the check is only done when the right operand is a subtype; see -- RM12-4.5.2 (28.1/3-30/3)). Predicate_Check : declare function In_Range_Check return Boolean; -- Within an expanded range check that may raise Constraint_Error do -- not generate a predicate check as well. It is redundant because -- the context will add an explicit predicate check, and it will -- raise the wrong exception if it fails. -------------------- -- In_Range_Check -- -------------------- function In_Range_Check return Boolean is P : Node_Id; begin P := Parent (N); while Present (P) loop if Nkind (P) = N_Raise_Constraint_Error then return True; elsif Nkind (P) in N_Statement_Other_Than_Procedure_Call or else Nkind (P) = N_Procedure_Call_Statement or else Nkind (P) in N_Declaration then return False; end if; P := Parent (P); end loop; return False; end In_Range_Check; -- Local variables PFunc : constant Entity_Id := Predicate_Function (Rtyp); R_Op : Node_Id; -- Start of processing for Predicate_Check begin if Present (PFunc) and then Current_Scope /= PFunc and then Nkind (Rop) /= N_Range then if not In_Range_Check then R_Op := Make_Predicate_Call (Rtyp, Lop, Mem => True); else R_Op := New_Occurrence_Of (Standard_True, Loc); end if; Rewrite (N, Make_And_Then (Loc, Left_Opnd => Relocate_Node (N), Right_Opnd => R_Op)); -- Analyze new expression, mark left operand as analyzed to -- avoid infinite recursion adding predicate calls. Similarly, -- suppress further range checks on the call. Set_Analyzed (Left_Opnd (N)); Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks); -- All done, skip attempt at compile time determination of result return; end if; end Predicate_Check; end Expand_N_In; -------------------------------- -- Expand_N_Indexed_Component -- -------------------------------- procedure Expand_N_Indexed_Component (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); P : constant Node_Id := Prefix (N); T : constant Entity_Id := Etype (P); Atp : Entity_Id; begin -- A special optimization, if we have an indexed component that is -- selecting from a slice, then we can eliminate the slice, since, for -- example, x (i .. j)(k) is identical to x(k). The only difference is -- the range check required by the slice. The range check for the slice -- itself has already been generated. The range check for the -- subscripting operation is ensured by converting the subject to -- the subtype of the slice. -- This optimization not only generates better code, avoiding slice -- messing especially in the packed case, but more importantly bypasses -- some problems in handling this peculiar case, for example, the issue -- of dealing specially with object renamings. if Nkind (P) = N_Slice -- This optimization is disabled for CodePeer because it can transform -- an index-check constraint_error into a range-check constraint_error -- and CodePeer cares about that distinction. and then not CodePeer_Mode then Rewrite (N, Make_Indexed_Component (Loc, Prefix => Prefix (P), Expressions => New_List ( Convert_To (Etype (First_Index (Etype (P))), First (Expressions (N)))))); Analyze_And_Resolve (N, Typ); return; end if; -- Ada 2005 (AI-318-02): If the prefix is a call to a build-in-place -- function, then additional actuals must be passed. if Ada_Version >= Ada_2005 and then Is_Build_In_Place_Function_Call (P) then Make_Build_In_Place_Call_In_Anonymous_Context (P); end if; -- If the prefix is an access type, then we unconditionally rewrite if -- as an explicit dereference. This simplifies processing for several -- cases, including packed array cases and certain cases in which checks -- must be generated. We used to try to do this only when it was -- necessary, but it cleans up the code to do it all the time. if Is_Access_Type (T) then Insert_Explicit_Dereference (P); Analyze_And_Resolve (P, Designated_Type (T)); Atp := Designated_Type (T); else Atp := T; end if; -- Generate index and validity checks Generate_Index_Checks (N); if Validity_Checks_On and then Validity_Check_Subscripts then Apply_Subscript_Validity_Checks (N); end if; -- If selecting from an array with atomic components, and atomic sync -- is not suppressed for this array type, set atomic sync flag. if (Has_Atomic_Components (Atp) and then not Atomic_Synchronization_Disabled (Atp)) or else (Is_Atomic (Typ) and then not Atomic_Synchronization_Disabled (Typ)) or else (Is_Entity_Name (P) and then Has_Atomic_Components (Entity (P)) and then not Atomic_Synchronization_Disabled (Entity (P))) then Activate_Atomic_Synchronization (N); end if; -- All done if the prefix is not a packed array implemented specially if not (Is_Packed (Etype (Prefix (N))) and then Present (Packed_Array_Impl_Type (Etype (Prefix (N))))) then return; end if; -- For packed arrays that are not bit-packed (i.e. the case of an array -- with one or more index types with a non-contiguous enumeration type), -- we can always use the normal packed element get circuit. if not Is_Bit_Packed_Array (Etype (Prefix (N))) then Expand_Packed_Element_Reference (N); return; end if; -- For a reference to a component of a bit packed array, we convert it -- to a reference to the corresponding Packed_Array_Impl_Type. We only -- want to do this for simple references, and not for: -- Left side of assignment, or prefix of left side of assignment, or -- prefix of the prefix, to handle packed arrays of packed arrays, -- This case is handled in Exp_Ch5.Expand_N_Assignment_Statement -- Renaming objects in renaming associations -- This case is handled when a use of the renamed variable occurs -- Actual parameters for a procedure call -- This case is handled in Exp_Ch6.Expand_Actuals -- The second expression in a 'Read attribute reference -- The prefix of an address or bit or size attribute reference -- The following circuit detects these exceptions. Note that we need to -- deal with implicit dereferences when climbing up the parent chain, -- with the additional difficulty that the type of parents may have yet -- to be resolved since prefixes are usually resolved first. declare Child : Node_Id := N; Parnt : Node_Id := Parent (N); begin loop if Nkind (Parnt) = N_Unchecked_Expression then null; elsif Nkind_In (Parnt, N_Object_Renaming_Declaration, N_Procedure_Call_Statement) or else (Nkind (Parnt) = N_Parameter_Association and then Nkind (Parent (Parnt)) = N_Procedure_Call_Statement) then return; elsif Nkind (Parnt) = N_Attribute_Reference and then Nam_In (Attribute_Name (Parnt), Name_Address, Name_Bit, Name_Size) and then Prefix (Parnt) = Child then return; elsif Nkind (Parnt) = N_Assignment_Statement and then Name (Parnt) = Child then return; -- If the expression is an index of an indexed component, it must -- be expanded regardless of context. elsif Nkind (Parnt) = N_Indexed_Component and then Child /= Prefix (Parnt) then Expand_Packed_Element_Reference (N); return; elsif Nkind (Parent (Parnt)) = N_Assignment_Statement and then Name (Parent (Parnt)) = Parnt then return; elsif Nkind (Parnt) = N_Attribute_Reference and then Attribute_Name (Parnt) = Name_Read and then Next (First (Expressions (Parnt))) = Child then return; elsif Nkind (Parnt) = N_Indexed_Component and then Prefix (Parnt) = Child then null; elsif Nkind (Parnt) = N_Selected_Component and then Prefix (Parnt) = Child and then not (Present (Etype (Selector_Name (Parnt))) and then Is_Access_Type (Etype (Selector_Name (Parnt)))) then null; -- If the parent is a dereference, either implicit or explicit, -- then the packed reference needs to be expanded. else Expand_Packed_Element_Reference (N); return; end if; -- Keep looking up tree for unchecked expression, or if we are the -- prefix of a possible assignment left side. Child := Parnt; Parnt := Parent (Child); end loop; end; end Expand_N_Indexed_Component; --------------------- -- Expand_N_Not_In -- --------------------- -- Replace a not in b by not (a in b) so that the expansions for (a in b) -- can be done. This avoids needing to duplicate this expansion code. procedure Expand_N_Not_In (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Cfs : constant Boolean := Comes_From_Source (N); begin Rewrite (N, Make_Op_Not (Loc, Right_Opnd => Make_In (Loc, Left_Opnd => Left_Opnd (N), Right_Opnd => Right_Opnd (N)))); -- If this is a set membership, preserve list of alternatives Set_Alternatives (Right_Opnd (N), Alternatives (Original_Node (N))); -- We want this to appear as coming from source if original does (see -- transformations in Expand_N_In). Set_Comes_From_Source (N, Cfs); Set_Comes_From_Source (Right_Opnd (N), Cfs); -- Now analyze transformed node Analyze_And_Resolve (N, Typ); end Expand_N_Not_In; ------------------- -- Expand_N_Null -- ------------------- -- The only replacement required is for the case of a null of a type that -- is an access to protected subprogram, or a subtype thereof. We represent -- such access values as a record, and so we must replace the occurrence of -- null by the equivalent record (with a null address and a null pointer in -- it), so that the backend creates the proper value. procedure Expand_N_Null (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Base_Type (Etype (N)); Agg : Node_Id; begin if Is_Access_Protected_Subprogram_Type (Typ) then Agg := Make_Aggregate (Loc, Expressions => New_List ( New_Occurrence_Of (RTE (RE_Null_Address), Loc), Make_Null (Loc))); Rewrite (N, Agg); Analyze_And_Resolve (N, Equivalent_Type (Typ)); -- For subsequent semantic analysis, the node must retain its type. -- Gigi in any case replaces this type by the corresponding record -- type before processing the node. Set_Etype (N, Typ); end if; exception when RE_Not_Available => return; end Expand_N_Null; --------------------- -- Expand_N_Op_Abs -- --------------------- procedure Expand_N_Op_Abs (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Expr : constant Node_Id := Right_Opnd (N); begin Unary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- Deal with software overflow checking if not Backend_Overflow_Checks_On_Target and then Is_Signed_Integer_Type (Etype (N)) and then Do_Overflow_Check (N) then -- The only case to worry about is when the argument is equal to the -- largest negative number, so what we do is to insert the check: -- [constraint_error when Expr = typ'Base'First] -- with the usual Duplicate_Subexpr use coding for expr Insert_Action (N, Make_Raise_Constraint_Error (Loc, Condition => Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Expr), Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Base_Type (Etype (Expr)), Loc), Attribute_Name => Name_First)), Reason => CE_Overflow_Check_Failed)); end if; end Expand_N_Op_Abs; --------------------- -- Expand_N_Op_Add -- --------------------- procedure Expand_N_Op_Add (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- N + 0 = 0 + N = N for integer types if Is_Integer_Type (Typ) then if Compile_Time_Known_Value (Right_Opnd (N)) and then Expr_Value (Right_Opnd (N)) = Uint_0 then Rewrite (N, Left_Opnd (N)); return; elsif Compile_Time_Known_Value (Left_Opnd (N)) and then Expr_Value (Left_Opnd (N)) = Uint_0 then Rewrite (N, Right_Opnd (N)); return; end if; end if; -- Arithmetic overflow checks for signed integer/fixed point types if Is_Signed_Integer_Type (Typ) or else Is_Fixed_Point_Type (Typ) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- Overflow checks for floating-point if -gnateF mode active Check_Float_Op_Overflow (N); end Expand_N_Op_Add; --------------------- -- Expand_N_Op_And -- --------------------- procedure Expand_N_Op_And (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); if Is_Array_Type (Etype (N)) then Expand_Boolean_Operator (N); elsif Is_Boolean_Type (Etype (N)) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); elsif Is_Intrinsic_Subprogram (Entity (N)) then Expand_Intrinsic_Call (N, Entity (N)); end if; end Expand_N_Op_And; ------------------------ -- Expand_N_Op_Concat -- ------------------------ procedure Expand_N_Op_Concat (N : Node_Id) is Opnds : List_Id; -- List of operands to be concatenated Cnode : Node_Id; -- Node which is to be replaced by the result of concatenating the nodes -- in the list Opnds. begin -- Ensure validity of both operands Binary_Op_Validity_Checks (N); -- If we are the left operand of a concatenation higher up the tree, -- then do nothing for now, since we want to deal with a series of -- concatenations as a unit. if Nkind (Parent (N)) = N_Op_Concat and then N = Left_Opnd (Parent (N)) then return; end if; -- We get here with a concatenation whose left operand may be a -- concatenation itself with a consistent type. We need to process -- these concatenation operands from left to right, which means -- from the deepest node in the tree to the highest node. Cnode := N; while Nkind (Left_Opnd (Cnode)) = N_Op_Concat loop Cnode := Left_Opnd (Cnode); end loop; -- Now Cnode is the deepest concatenation, and its parents are the -- concatenation nodes above, so now we process bottom up, doing the -- operands. -- The outer loop runs more than once if more than one concatenation -- type is involved. Outer : loop Opnds := New_List (Left_Opnd (Cnode), Right_Opnd (Cnode)); Set_Parent (Opnds, N); -- The inner loop gathers concatenation operands Inner : while Cnode /= N and then Base_Type (Etype (Cnode)) = Base_Type (Etype (Parent (Cnode))) loop Cnode := Parent (Cnode); Append (Right_Opnd (Cnode), Opnds); end loop Inner; -- Note: The following code is a temporary workaround for N731-034 -- and N829-028 and will be kept until the general issue of internal -- symbol serialization is addressed. The workaround is kept under a -- debug switch to avoid permiating into the general case. -- Wrap the node to concatenate into an expression actions node to -- keep it nicely packaged. This is useful in the case of an assert -- pragma with a concatenation where we want to be able to delete -- the concatenation and all its expansion stuff. if Debug_Flag_Dot_H then declare Cnod : constant Node_Id := Relocate_Node (Cnode); Typ : constant Entity_Id := Base_Type (Etype (Cnode)); begin -- Note: use Rewrite rather than Replace here, so that for -- example Why_Not_Static can find the original concatenation -- node OK! Rewrite (Cnode, Make_Expression_With_Actions (Sloc (Cnode), Actions => New_List (Make_Null_Statement (Sloc (Cnode))), Expression => Cnod)); Expand_Concatenate (Cnod, Opnds); Analyze_And_Resolve (Cnode, Typ); end; -- Default case else Expand_Concatenate (Cnode, Opnds); end if; exit Outer when Cnode = N; Cnode := Parent (Cnode); end loop Outer; end Expand_N_Op_Concat; ------------------------ -- Expand_N_Op_Divide -- ------------------------ procedure Expand_N_Op_Divide (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Lopnd : constant Node_Id := Left_Opnd (N); Ropnd : constant Node_Id := Right_Opnd (N); Ltyp : constant Entity_Id := Etype (Lopnd); Rtyp : constant Entity_Id := Etype (Ropnd); Typ : Entity_Id := Etype (N); Rknow : constant Boolean := Is_Integer_Type (Typ) and then Compile_Time_Known_Value (Ropnd); Rval : Uint; begin Binary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- Otherwise proceed with expansion of division if Rknow then Rval := Expr_Value (Ropnd); end if; -- N / 1 = N for integer types if Rknow and then Rval = Uint_1 then Rewrite (N, Lopnd); return; end if; -- Convert x / 2 ** y to Shift_Right (x, y). Note that the fact that -- Is_Power_Of_2_For_Shift is set means that we know that our left -- operand is an unsigned integer, as required for this to work. if Nkind (Ropnd) = N_Op_Expon and then Is_Power_Of_2_For_Shift (Ropnd) -- We cannot do this transformation in configurable run time mode if we -- have 64-bit integers and long shifts are not available. and then (Esize (Ltyp) <= 32 or else Support_Long_Shifts_On_Target) then Rewrite (N, Make_Op_Shift_Right (Loc, Left_Opnd => Lopnd, Right_Opnd => Convert_To (Standard_Natural, Right_Opnd (Ropnd)))); Analyze_And_Resolve (N, Typ); return; end if; -- Do required fixup of universal fixed operation if Typ = Universal_Fixed then Fixup_Universal_Fixed_Operation (N); Typ := Etype (N); end if; -- Divisions with fixed-point results if Is_Fixed_Point_Type (Typ) then -- Deal with divide-by-zero check if back end cannot handle them -- and the flag is set indicating that we need such a check. Note -- that we don't need to bother here with the case of mixed-mode -- (Right operand an integer type), since these will be rewritten -- with conversions to a divide with a fixed-point right operand. if Do_Division_Check (N) and then not Backend_Divide_Checks_On_Target and then not Is_Integer_Type (Rtyp) then Set_Do_Division_Check (N, False); Insert_Action (N, Make_Raise_Constraint_Error (Loc, Condition => Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr_Move_Checks (Ropnd), Right_Opnd => Make_Real_Literal (Loc, Ureal_0)), Reason => CE_Divide_By_Zero)); end if; -- No special processing if Treat_Fixed_As_Integer is set, since -- from a semantic point of view such operations are simply integer -- operations and will be treated that way. if not Treat_Fixed_As_Integer (N) then if Is_Integer_Type (Rtyp) then Expand_Divide_Fixed_By_Integer_Giving_Fixed (N); else Expand_Divide_Fixed_By_Fixed_Giving_Fixed (N); end if; end if; -- Other cases of division of fixed-point operands. Again we exclude the -- case where Treat_Fixed_As_Integer is set. elsif (Is_Fixed_Point_Type (Ltyp) or else Is_Fixed_Point_Type (Rtyp)) and then not Treat_Fixed_As_Integer (N) then if Is_Integer_Type (Typ) then Expand_Divide_Fixed_By_Fixed_Giving_Integer (N); else pragma Assert (Is_Floating_Point_Type (Typ)); Expand_Divide_Fixed_By_Fixed_Giving_Float (N); end if; -- Mixed-mode operations can appear in a non-static universal context, -- in which case the integer argument must be converted explicitly. elsif Typ = Universal_Real and then Is_Integer_Type (Rtyp) then Rewrite (Ropnd, Convert_To (Universal_Real, Relocate_Node (Ropnd))); Analyze_And_Resolve (Ropnd, Universal_Real); elsif Typ = Universal_Real and then Is_Integer_Type (Ltyp) then Rewrite (Lopnd, Convert_To (Universal_Real, Relocate_Node (Lopnd))); Analyze_And_Resolve (Lopnd, Universal_Real); -- Non-fixed point cases, do integer zero divide and overflow checks elsif Is_Integer_Type (Typ) then Apply_Divide_Checks (N); end if; -- Overflow checks for floating-point if -gnateF mode active Check_Float_Op_Overflow (N); end Expand_N_Op_Divide; -------------------- -- Expand_N_Op_Eq -- -------------------- procedure Expand_N_Op_Eq (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Lhs : constant Node_Id := Left_Opnd (N); Rhs : constant Node_Id := Right_Opnd (N); Bodies : constant List_Id := New_List; A_Typ : constant Entity_Id := Etype (Lhs); Typl : Entity_Id := A_Typ; Op_Name : Entity_Id; Prim : Elmt_Id; procedure Build_Equality_Call (Eq : Entity_Id); -- If a constructed equality exists for the type or for its parent, -- build and analyze call, adding conversions if the operation is -- inherited. function Has_Unconstrained_UU_Component (Typ : Node_Id) return Boolean; -- Determines whether a type has a subcomponent of an unconstrained -- Unchecked_Union subtype. Typ is a record type. ------------------------- -- Build_Equality_Call -- ------------------------- procedure Build_Equality_Call (Eq : Entity_Id) is Op_Type : constant Entity_Id := Etype (First_Formal (Eq)); L_Exp : Node_Id := Relocate_Node (Lhs); R_Exp : Node_Id := Relocate_Node (Rhs); begin -- Adjust operands if necessary to comparison type if Base_Type (Op_Type) /= Base_Type (A_Typ) and then not Is_Class_Wide_Type (A_Typ) then L_Exp := OK_Convert_To (Op_Type, L_Exp); R_Exp := OK_Convert_To (Op_Type, R_Exp); end if; -- If we have an Unchecked_Union, we need to add the inferred -- discriminant values as actuals in the function call. At this -- point, the expansion has determined that both operands have -- inferable discriminants. if Is_Unchecked_Union (Op_Type) then declare Lhs_Type : constant Node_Id := Etype (L_Exp); Rhs_Type : constant Node_Id := Etype (R_Exp); Lhs_Discr_Vals : Elist_Id; -- List of inferred discriminant values for left operand. Rhs_Discr_Vals : Elist_Id; -- List of inferred discriminant values for right operand. Discr : Entity_Id; begin Lhs_Discr_Vals := New_Elmt_List; Rhs_Discr_Vals := New_Elmt_List; -- Per-object constrained selected components require special -- attention. If the enclosing scope of the component is an -- Unchecked_Union, we cannot reference its discriminants -- directly. This is why we use the extra parameters of the -- equality function of the enclosing Unchecked_Union. -- type UU_Type (Discr : Integer := 0) is -- . . . -- end record; -- pragma Unchecked_Union (UU_Type); -- 1. Unchecked_Union enclosing record: -- type Enclosing_UU_Type (Discr : Integer := 0) is record -- . . . -- Comp : UU_Type (Discr); -- . . . -- end Enclosing_UU_Type; -- pragma Unchecked_Union (Enclosing_UU_Type); -- Obj1 : Enclosing_UU_Type; -- Obj2 : Enclosing_UU_Type (1); -- [. . .] Obj1 = Obj2 [. . .] -- Generated code: -- if not (uu_typeEQ (obj1.comp, obj2.comp, a, b)) then -- A and B are the formal parameters of the equality function -- of Enclosing_UU_Type. The function always has two extra -- formals to capture the inferred discriminant values for -- each discriminant of the type. -- 2. Non-Unchecked_Union enclosing record: -- type -- Enclosing_Non_UU_Type (Discr : Integer := 0) -- is record -- . . . -- Comp : UU_Type (Discr); -- . . . -- end Enclosing_Non_UU_Type; -- Obj1 : Enclosing_Non_UU_Type; -- Obj2 : Enclosing_Non_UU_Type (1); -- ... Obj1 = Obj2 ... -- Generated code: -- if not (uu_typeEQ (obj1.comp, obj2.comp, -- obj1.discr, obj2.discr)) then -- In this case we can directly reference the discriminants of -- the enclosing record. -- Process left operand of equality if Nkind (Lhs) = N_Selected_Component and then Has_Per_Object_Constraint (Entity (Selector_Name (Lhs))) then -- If enclosing record is an Unchecked_Union, use formals -- corresponding to each discriminant. The name of the -- formal is that of the discriminant, with added suffix, -- see Exp_Ch3.Build_Record_Equality for details. if Is_Unchecked_Union (Scope (Entity (Selector_Name (Lhs)))) then Discr := First_Discriminant (Scope (Entity (Selector_Name (Lhs)))); while Present (Discr) loop Append_Elmt (Make_Identifier (Loc, Chars => New_External_Name (Chars (Discr), 'A')), To => Lhs_Discr_Vals); Next_Discriminant (Discr); end loop; -- If enclosing record is of a non-Unchecked_Union type, it -- is possible to reference its discriminants directly. else Discr := First_Discriminant (Lhs_Type); while Present (Discr) loop Append_Elmt (Make_Selected_Component (Loc, Prefix => Prefix (Lhs), Selector_Name => New_Copy (Get_Discriminant_Value (Discr, Lhs_Type, Stored_Constraint (Lhs_Type)))), To => Lhs_Discr_Vals); Next_Discriminant (Discr); end loop; end if; -- Otherwise operand is on object with a constrained type. -- Infer the discriminant values from the constraint. else Discr := First_Discriminant (Lhs_Type); while Present (Discr) loop Append_Elmt (New_Copy (Get_Discriminant_Value (Discr, Lhs_Type, Stored_Constraint (Lhs_Type))), To => Lhs_Discr_Vals); Next_Discriminant (Discr); end loop; end if; -- Similar processing for right operand of equality if Nkind (Rhs) = N_Selected_Component and then Has_Per_Object_Constraint (Entity (Selector_Name (Rhs))) then if Is_Unchecked_Union (Scope (Entity (Selector_Name (Rhs)))) then Discr := First_Discriminant (Scope (Entity (Selector_Name (Rhs)))); while Present (Discr) loop Append_Elmt (Make_Identifier (Loc, Chars => New_External_Name (Chars (Discr), 'B')), To => Rhs_Discr_Vals); Next_Discriminant (Discr); end loop; else Discr := First_Discriminant (Rhs_Type); while Present (Discr) loop Append_Elmt (Make_Selected_Component (Loc, Prefix => Prefix (Rhs), Selector_Name => New_Copy (Get_Discriminant_Value (Discr, Rhs_Type, Stored_Constraint (Rhs_Type)))), To => Rhs_Discr_Vals); Next_Discriminant (Discr); end loop; end if; else Discr := First_Discriminant (Rhs_Type); while Present (Discr) loop Append_Elmt (New_Copy (Get_Discriminant_Value (Discr, Rhs_Type, Stored_Constraint (Rhs_Type))), To => Rhs_Discr_Vals); Next_Discriminant (Discr); end loop; end if; -- Now merge the list of discriminant values so that values -- of corresponding discriminants are adjacent. declare Params : List_Id; L_Elmt : Elmt_Id; R_Elmt : Elmt_Id; begin Params := New_List (L_Exp, R_Exp); L_Elmt := First_Elmt (Lhs_Discr_Vals); R_Elmt := First_Elmt (Rhs_Discr_Vals); while Present (L_Elmt) loop Append_To (Params, Node (L_Elmt)); Append_To (Params, Node (R_Elmt)); Next_Elmt (L_Elmt); Next_Elmt (R_Elmt); end loop; Rewrite (N, Make_Function_Call (Loc, Name => New_Occurrence_Of (Eq, Loc), Parameter_Associations => Params)); end; end; -- Normal case, not an unchecked union else Rewrite (N, Make_Function_Call (Loc, Name => New_Occurrence_Of (Eq, Loc), Parameter_Associations => New_List (L_Exp, R_Exp))); end if; Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks); end Build_Equality_Call; ------------------------------------ -- Has_Unconstrained_UU_Component -- ------------------------------------ function Has_Unconstrained_UU_Component (Typ : Node_Id) return Boolean is Tdef : constant Node_Id := Type_Definition (Declaration_Node (Base_Type (Typ))); Clist : Node_Id; Vpart : Node_Id; function Component_Is_Unconstrained_UU (Comp : Node_Id) return Boolean; -- Determines whether the subtype of the component is an -- unconstrained Unchecked_Union. function Variant_Is_Unconstrained_UU (Variant : Node_Id) return Boolean; -- Determines whether a component of the variant has an unconstrained -- Unchecked_Union subtype. ----------------------------------- -- Component_Is_Unconstrained_UU -- ----------------------------------- function Component_Is_Unconstrained_UU (Comp : Node_Id) return Boolean is begin if Nkind (Comp) /= N_Component_Declaration then return False; end if; declare Sindic : constant Node_Id := Subtype_Indication (Component_Definition (Comp)); begin -- Unconstrained nominal type. In the case of a constraint -- present, the node kind would have been N_Subtype_Indication. if Nkind (Sindic) = N_Identifier then return Is_Unchecked_Union (Base_Type (Etype (Sindic))); end if; return False; end; end Component_Is_Unconstrained_UU; --------------------------------- -- Variant_Is_Unconstrained_UU -- --------------------------------- function Variant_Is_Unconstrained_UU (Variant : Node_Id) return Boolean is Clist : constant Node_Id := Component_List (Variant); begin if Is_Empty_List (Component_Items (Clist)) then return False; end if; -- We only need to test one component declare Comp : Node_Id := First (Component_Items (Clist)); begin while Present (Comp) loop if Component_Is_Unconstrained_UU (Comp) then return True; end if; Next (Comp); end loop; end; -- None of the components withing the variant were of -- unconstrained Unchecked_Union type. return False; end Variant_Is_Unconstrained_UU; -- Start of processing for Has_Unconstrained_UU_Component begin if Null_Present (Tdef) then return False; end if; Clist := Component_List (Tdef); Vpart := Variant_Part (Clist); -- Inspect available components if Present (Component_Items (Clist)) then declare Comp : Node_Id := First (Component_Items (Clist)); begin while Present (Comp) loop -- One component is sufficient if Component_Is_Unconstrained_UU (Comp) then return True; end if; Next (Comp); end loop; end; end if; -- Inspect available components withing variants if Present (Vpart) then declare Variant : Node_Id := First (Variants (Vpart)); begin while Present (Variant) loop -- One component within a variant is sufficient if Variant_Is_Unconstrained_UU (Variant) then return True; end if; Next (Variant); end loop; end; end if; -- Neither the available components, nor the components inside the -- variant parts were of an unconstrained Unchecked_Union subtype. return False; end Has_Unconstrained_UU_Component; -- Start of processing for Expand_N_Op_Eq begin Binary_Op_Validity_Checks (N); -- Deal with private types if Ekind (Typl) = E_Private_Type then Typl := Underlying_Type (Typl); elsif Ekind (Typl) = E_Private_Subtype then Typl := Underlying_Type (Base_Type (Typl)); else null; end if; -- It may happen in error situations that the underlying type is not -- set. The error will be detected later, here we just defend the -- expander code. if No (Typl) then return; end if; -- Now get the implementation base type (note that plain Base_Type here -- might lead us back to the private type, which is not what we want!) Typl := Implementation_Base_Type (Typl); -- Equality between variant records results in a call to a routine -- that has conditional tests of the discriminant value(s), and hence -- violates the No_Implicit_Conditionals restriction. if Has_Variant_Part (Typl) then declare Msg : Boolean; begin Check_Restriction (Msg, No_Implicit_Conditionals, N); if Msg then Error_Msg_N ("\comparison of variant records tests discriminants", N); return; end if; end; end if; -- Deal with overflow checks in MINIMIZED/ELIMINATED mode and if that -- means we no longer have a comparison operation, we are all done. Expand_Compare_Minimize_Eliminate_Overflow (N); if Nkind (N) /= N_Op_Eq then return; end if; -- Boolean types (requiring handling of non-standard case) if Is_Boolean_Type (Typl) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); -- Array types elsif Is_Array_Type (Typl) then -- If we are doing full validity checking, and it is possible for the -- array elements to be invalid then expand out array comparisons to -- make sure that we check the array elements. if Validity_Check_Operands and then not Is_Known_Valid (Component_Type (Typl)) then declare Save_Force_Validity_Checks : constant Boolean := Force_Validity_Checks; begin Force_Validity_Checks := True; Rewrite (N, Expand_Array_Equality (N, Relocate_Node (Lhs), Relocate_Node (Rhs), Bodies, Typl)); Insert_Actions (N, Bodies); Analyze_And_Resolve (N, Standard_Boolean); Force_Validity_Checks := Save_Force_Validity_Checks; end; -- Packed case where both operands are known aligned elsif Is_Bit_Packed_Array (Typl) and then not Is_Possibly_Unaligned_Object (Lhs) and then not Is_Possibly_Unaligned_Object (Rhs) then Expand_Packed_Eq (N); -- Where the component type is elementary we can use a block bit -- comparison (if supported on the target) exception in the case -- of floating-point (negative zero issues require element by -- element comparison), and atomic/VFA types (where we must be sure -- to load elements independently) and possibly unaligned arrays. elsif Is_Elementary_Type (Component_Type (Typl)) and then not Is_Floating_Point_Type (Component_Type (Typl)) and then not Is_Atomic_Or_VFA (Component_Type (Typl)) and then not Is_Possibly_Unaligned_Object (Lhs) and then not Is_Possibly_Unaligned_Object (Rhs) and then Support_Composite_Compare_On_Target then null; -- For composite and floating-point cases, expand equality loop to -- make sure of using proper comparisons for tagged types, and -- correctly handling the floating-point case. else Rewrite (N, Expand_Array_Equality (N, Relocate_Node (Lhs), Relocate_Node (Rhs), Bodies, Typl)); Insert_Actions (N, Bodies, Suppress => All_Checks); Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks); end if; -- Record Types elsif Is_Record_Type (Typl) then -- For tagged types, use the primitive "=" if Is_Tagged_Type (Typl) then -- No need to do anything else compiling under restriction -- No_Dispatching_Calls. During the semantic analysis we -- already notified such violation. if Restriction_Active (No_Dispatching_Calls) then return; end if; -- If this is derived from an untagged private type completed with -- a tagged type, it does not have a full view, so we use the -- primitive operations of the private type. This check should no -- longer be necessary when these types get their full views??? if Is_Private_Type (A_Typ) and then not Is_Tagged_Type (A_Typ) and then Is_Derived_Type (A_Typ) and then No (Full_View (A_Typ)) then -- Search for equality operation, checking that the operands -- have the same type. Note that we must find a matching entry, -- or something is very wrong. Prim := First_Elmt (Collect_Primitive_Operations (A_Typ)); while Present (Prim) loop exit when Chars (Node (Prim)) = Name_Op_Eq and then Etype (First_Formal (Node (Prim))) = Etype (Next_Formal (First_Formal (Node (Prim)))) and then Base_Type (Etype (Node (Prim))) = Standard_Boolean; Next_Elmt (Prim); end loop; pragma Assert (Present (Prim)); Op_Name := Node (Prim); -- Find the type's predefined equality or an overriding -- user-defined equality. The reason for not simply calling -- Find_Prim_Op here is that there may be a user-defined -- overloaded equality op that precedes the equality that we -- want, so we have to explicitly search (e.g., there could be -- an equality with two different parameter types). else if Is_Class_Wide_Type (Typl) then Typl := Find_Specific_Type (Typl); end if; Prim := First_Elmt (Primitive_Operations (Typl)); while Present (Prim) loop exit when Chars (Node (Prim)) = Name_Op_Eq and then Etype (First_Formal (Node (Prim))) = Etype (Next_Formal (First_Formal (Node (Prim)))) and then Base_Type (Etype (Node (Prim))) = Standard_Boolean; Next_Elmt (Prim); end loop; pragma Assert (Present (Prim)); Op_Name := Node (Prim); end if; Build_Equality_Call (Op_Name); -- Ada 2005 (AI-216): Program_Error is raised when evaluating the -- predefined equality operator for a type which has a subcomponent -- of an Unchecked_Union type whose nominal subtype is unconstrained. elsif Has_Unconstrained_UU_Component (Typl) then Insert_Action (N, Make_Raise_Program_Error (Loc, Reason => PE_Unchecked_Union_Restriction)); -- Prevent Gigi from generating incorrect code by rewriting the -- equality as a standard False. (is this documented somewhere???) Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); elsif Is_Unchecked_Union (Typl) then -- If we can infer the discriminants of the operands, we make a -- call to the TSS equality function. if Has_Inferable_Discriminants (Lhs) and then Has_Inferable_Discriminants (Rhs) then Build_Equality_Call (TSS (Root_Type (Typl), TSS_Composite_Equality)); else -- Ada 2005 (AI-216): Program_Error is raised when evaluating -- the predefined equality operator for an Unchecked_Union type -- if either of the operands lack inferable discriminants. Insert_Action (N, Make_Raise_Program_Error (Loc, Reason => PE_Unchecked_Union_Restriction)); -- Emit a warning on source equalities only, otherwise the -- message may appear out of place due to internal use. The -- warning is unconditional because it is required by the -- language. if Comes_From_Source (N) then Error_Msg_N ("Unchecked_Union discriminants cannot be determined??", N); Error_Msg_N ("\Program_Error will be raised for equality operation??", N); end if; -- Prevent Gigi from generating incorrect code by rewriting -- the equality as a standard False (documented where???). Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); end if; -- If a type support function is present (for complex cases), use it elsif Present (TSS (Root_Type (Typl), TSS_Composite_Equality)) then Build_Equality_Call (TSS (Root_Type (Typl), TSS_Composite_Equality)); -- When comparing two Bounded_Strings, use the primitive equality of -- the root Super_String type. elsif Is_Bounded_String (Typl) then Prim := First_Elmt (Collect_Primitive_Operations (Root_Type (Typl))); while Present (Prim) loop exit when Chars (Node (Prim)) = Name_Op_Eq and then Etype (First_Formal (Node (Prim))) = Etype (Next_Formal (First_Formal (Node (Prim)))) and then Base_Type (Etype (Node (Prim))) = Standard_Boolean; Next_Elmt (Prim); end loop; -- A Super_String type should always have a primitive equality pragma Assert (Present (Prim)); Build_Equality_Call (Node (Prim)); -- Otherwise expand the component by component equality. Note that -- we never use block-bit comparisons for records, because of the -- problems with gaps. The backend will often be able to recombine -- the separate comparisons that we generate here. else Remove_Side_Effects (Lhs); Remove_Side_Effects (Rhs); Rewrite (N, Expand_Record_Equality (N, Typl, Lhs, Rhs, Bodies)); Insert_Actions (N, Bodies, Suppress => All_Checks); Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks); end if; end if; -- Test if result is known at compile time Rewrite_Comparison (N); -- Special optimization of length comparison Optimize_Length_Comparison (N); -- One more special case: if we have a comparison of X'Result = expr -- in floating-point, then if not already there, change expr to be -- f'Machine (expr) to eliminate surprise from extra precision. if Is_Floating_Point_Type (Typl) and then Nkind (Original_Node (Lhs)) = N_Attribute_Reference and then Attribute_Name (Original_Node (Lhs)) = Name_Result then -- Stick in the Typ'Machine call if not already there if Nkind (Rhs) /= N_Attribute_Reference or else Attribute_Name (Rhs) /= Name_Machine then Rewrite (Rhs, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Typl, Loc), Attribute_Name => Name_Machine, Expressions => New_List (Relocate_Node (Rhs)))); Analyze_And_Resolve (Rhs, Typl); end if; end if; end Expand_N_Op_Eq; ----------------------- -- Expand_N_Op_Expon -- ----------------------- procedure Expand_N_Op_Expon (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Rtyp : constant Entity_Id := Root_Type (Typ); Base : constant Node_Id := Relocate_Node (Left_Opnd (N)); Bastyp : constant Node_Id := Etype (Base); Exp : constant Node_Id := Relocate_Node (Right_Opnd (N)); Exptyp : constant Entity_Id := Etype (Exp); Ovflo : constant Boolean := Do_Overflow_Check (N); Expv : Uint; Temp : Node_Id; Rent : RE_Id; Ent : Entity_Id; Etyp : Entity_Id; Xnode : Node_Id; function Wrap_MA (Exp : Node_Id) return Node_Id; -- Given an expression Exp, if the root type is Float or Long_Float, -- then wrap the expression in a call of Bastyp'Machine, to stop any -- extra precision. This is done to ensure that X**A = X**B when A is -- a static constant and B is a variable with the same value. For any -- other type, the node Exp is returned unchanged. ------------- -- Wrap_MA -- ------------- function Wrap_MA (Exp : Node_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Exp); begin if Rtyp = Standard_Float or else Rtyp = Standard_Long_Float then return Make_Attribute_Reference (Loc, Attribute_Name => Name_Machine, Prefix => New_Occurrence_Of (Bastyp, Loc), Expressions => New_List (Relocate_Node (Exp))); else return Exp; end if; end Wrap_MA; -- Start of processing for Expand_N_Op begin Binary_Op_Validity_Checks (N); -- CodePeer wants to see the unexpanded N_Op_Expon node if CodePeer_Mode then return; end if; -- If either operand is of a private type, then we have the use of an -- intrinsic operator, and we get rid of the privateness, by using root -- types of underlying types for the actual operation. Otherwise the -- private types will cause trouble if we expand multiplications or -- shifts etc. We also do this transformation if the result type is -- different from the base type. if Is_Private_Type (Etype (Base)) or else Is_Private_Type (Typ) or else Is_Private_Type (Exptyp) or else Rtyp /= Root_Type (Bastyp) then declare Bt : constant Entity_Id := Root_Type (Underlying_Type (Bastyp)); Et : constant Entity_Id := Root_Type (Underlying_Type (Exptyp)); begin Rewrite (N, Unchecked_Convert_To (Typ, Make_Op_Expon (Loc, Left_Opnd => Unchecked_Convert_To (Bt, Base), Right_Opnd => Unchecked_Convert_To (Et, Exp)))); Analyze_And_Resolve (N, Typ); return; end; end if; -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- Test for case of known right argument where we can replace the -- exponentiation by an equivalent expression using multiplication. -- Note: use CRT_Safe version of Compile_Time_Known_Value because in -- configurable run-time mode, we may not have the exponentiation -- routine available, and we don't want the legality of the program -- to depend on how clever the compiler is in knowing values. if CRT_Safe_Compile_Time_Known_Value (Exp) then Expv := Expr_Value (Exp); -- We only fold small non-negative exponents. You might think we -- could fold small negative exponents for the real case, but we -- can't because we are required to raise Constraint_Error for -- the case of 0.0 ** (negative) even if Machine_Overflows = False. -- See ACVC test C4A012B, and it is not worth generating the test. -- For small negative exponents, we return the reciprocal of -- the folding of the exponentiation for the opposite (positive) -- exponent, as required by Ada RM 4.5.6(11/3). if abs Expv <= 4 then -- X ** 0 = 1 (or 1.0) if Expv = 0 then -- Call Remove_Side_Effects to ensure that any side effects -- in the ignored left operand (in particular function calls -- to user defined functions) are properly executed. Remove_Side_Effects (Base); if Ekind (Typ) in Integer_Kind then Xnode := Make_Integer_Literal (Loc, Intval => 1); else Xnode := Make_Real_Literal (Loc, Ureal_1); end if; -- X ** 1 = X elsif Expv = 1 then Xnode := Base; -- X ** 2 = X * X elsif Expv = 2 then Xnode := Wrap_MA ( Make_Op_Multiply (Loc, Left_Opnd => Duplicate_Subexpr (Base), Right_Opnd => Duplicate_Subexpr_No_Checks (Base))); -- X ** 3 = X * X * X elsif Expv = 3 then Xnode := Wrap_MA ( Make_Op_Multiply (Loc, Left_Opnd => Make_Op_Multiply (Loc, Left_Opnd => Duplicate_Subexpr (Base), Right_Opnd => Duplicate_Subexpr_No_Checks (Base)), Right_Opnd => Duplicate_Subexpr_No_Checks (Base))); -- X ** 4 -> -- do -- En : constant base'type := base * base; -- in -- En * En elsif Expv = 4 then Temp := Make_Temporary (Loc, 'E', Base); Xnode := Make_Expression_With_Actions (Loc, Actions => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Temp, Constant_Present => True, Object_Definition => New_Occurrence_Of (Typ, Loc), Expression => Wrap_MA ( Make_Op_Multiply (Loc, Left_Opnd => Duplicate_Subexpr (Base), Right_Opnd => Duplicate_Subexpr_No_Checks (Base))))), Expression => Wrap_MA ( Make_Op_Multiply (Loc, Left_Opnd => New_Occurrence_Of (Temp, Loc), Right_Opnd => New_Occurrence_Of (Temp, Loc)))); -- X ** N = 1.0 / X ** (-N) -- N in -4 .. -1 else pragma Assert (Expv = -1 or Expv = -2 or Expv = -3 or Expv = -4); Xnode := Make_Op_Divide (Loc, Left_Opnd => Make_Float_Literal (Loc, Radix => Uint_1, Significand => Uint_1, Exponent => Uint_0), Right_Opnd => Make_Op_Expon (Loc, Left_Opnd => Duplicate_Subexpr (Base), Right_Opnd => Make_Integer_Literal (Loc, Intval => -Expv))); end if; Rewrite (N, Xnode); Analyze_And_Resolve (N, Typ); return; end if; end if; -- Deal with optimizing 2 ** expression to shift where possible -- Note: we used to check that Exptyp was an unsigned type. But that is -- an unnecessary check, since if Exp is negative, we have a run-time -- error that is either caught (so we get the right result) or we have -- suppressed the check, in which case the code is erroneous anyway. if Is_Integer_Type (Rtyp) -- The base value must be "safe compile-time known", and exactly 2 and then Nkind (Base) = N_Integer_Literal and then CRT_Safe_Compile_Time_Known_Value (Base) and then Expr_Value (Base) = Uint_2 -- We only handle cases where the right type is a integer and then Is_Integer_Type (Root_Type (Exptyp)) and then Esize (Root_Type (Exptyp)) <= Esize (Standard_Integer) -- This transformation is not applicable for a modular type with a -- nonbinary modulus because we do not handle modular reduction in -- a correct manner if we attempt this transformation in this case. and then not Non_Binary_Modulus (Typ) then -- Handle the cases where our parent is a division or multiplication -- specially. In these cases we can convert to using a shift at the -- parent level if we are not doing overflow checking, since it is -- too tricky to combine the overflow check at the parent level. if not Ovflo and then Nkind_In (Parent (N), N_Op_Divide, N_Op_Multiply) then declare P : constant Node_Id := Parent (N); L : constant Node_Id := Left_Opnd (P); R : constant Node_Id := Right_Opnd (P); begin if (Nkind (P) = N_Op_Multiply and then ((Is_Integer_Type (Etype (L)) and then R = N) or else (Is_Integer_Type (Etype (R)) and then L = N)) and then not Do_Overflow_Check (P)) or else (Nkind (P) = N_Op_Divide and then Is_Integer_Type (Etype (L)) and then Is_Unsigned_Type (Etype (L)) and then R = N and then not Do_Overflow_Check (P)) then Set_Is_Power_Of_2_For_Shift (N); return; end if; end; -- Here we just have 2 ** N on its own, so we can convert this to a -- shift node. We are prepared to deal with overflow here, and we -- also have to handle proper modular reduction for binary modular. else declare OK : Boolean; Lo : Uint; Hi : Uint; MaxS : Uint; -- Maximum shift count with no overflow TestS : Boolean; -- Set True if we must test the shift count Test_Gt : Node_Id; -- Node for test against TestS begin -- Compute maximum shift based on the underlying size. For a -- modular type this is one less than the size. if Is_Modular_Integer_Type (Typ) then -- For modular integer types, this is the size of the value -- being shifted minus one. Any larger values will cause -- modular reduction to a result of zero. Note that we do -- want the RM_Size here (e.g. mod 2 ** 7, we want a result -- of 6, since 2**7 should be reduced to zero). MaxS := RM_Size (Rtyp) - 1; -- For signed integer types, we use the size of the value -- being shifted minus 2. Larger values cause overflow. else MaxS := Esize (Rtyp) - 2; end if; -- Determine range to see if it can be larger than MaxS Determine_Range (Right_Opnd (N), OK, Lo, Hi, Assume_Valid => True); TestS := (not OK) or else Hi > MaxS; -- Signed integer case if Is_Signed_Integer_Type (Typ) then -- Generate overflow check if overflow is active. Note that -- we can simply ignore the possibility of overflow if the -- flag is not set (means that overflow cannot happen or -- that overflow checks are suppressed). if Ovflo and TestS then Insert_Action (N, Make_Raise_Constraint_Error (Loc, Condition => Make_Op_Gt (Loc, Left_Opnd => Duplicate_Subexpr (Right_Opnd (N)), Right_Opnd => Make_Integer_Literal (Loc, MaxS)), Reason => CE_Overflow_Check_Failed)); end if; -- Now rewrite node as Shift_Left (1, right-operand) Rewrite (N, Make_Op_Shift_Left (Loc, Left_Opnd => Make_Integer_Literal (Loc, Uint_1), Right_Opnd => Right_Opnd (N))); -- Modular integer case else pragma Assert (Is_Modular_Integer_Type (Typ)); -- If shift count can be greater than MaxS, we need to wrap -- the shift in a test that will reduce the result value to -- zero if this shift count is exceeded. if TestS then -- Note: build node for the comparison first, before we -- reuse the Right_Opnd, so that we have proper parents -- in place for the Duplicate_Subexpr call. Test_Gt := Make_Op_Gt (Loc, Left_Opnd => Duplicate_Subexpr (Right_Opnd (N)), Right_Opnd => Make_Integer_Literal (Loc, MaxS)); Rewrite (N, Make_If_Expression (Loc, Expressions => New_List ( Test_Gt, Make_Integer_Literal (Loc, Uint_0), Make_Op_Shift_Left (Loc, Left_Opnd => Make_Integer_Literal (Loc, Uint_1), Right_Opnd => Right_Opnd (N))))); -- If we know shift count cannot be greater than MaxS, then -- it is safe to just rewrite as a shift with no test. else Rewrite (N, Make_Op_Shift_Left (Loc, Left_Opnd => Make_Integer_Literal (Loc, Uint_1), Right_Opnd => Right_Opnd (N))); end if; end if; Analyze_And_Resolve (N, Typ); return; end; end if; end if; -- Fall through if exponentiation must be done using a runtime routine -- First deal with modular case if Is_Modular_Integer_Type (Rtyp) then -- Nonbinary modular case, we call the special exponentiation -- routine for the nonbinary case, converting the argument to -- Long_Long_Integer and passing the modulus value. Then the -- result is converted back to the base type. if Non_Binary_Modulus (Rtyp) then Rewrite (N, Convert_To (Typ, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Exp_Modular), Loc), Parameter_Associations => New_List ( Convert_To (RTE (RE_Unsigned), Base), Make_Integer_Literal (Loc, Modulus (Rtyp)), Exp)))); -- Binary modular case, in this case, we call one of two routines, -- either the unsigned integer case, or the unsigned long long -- integer case, with a final "and" operation to do the required mod. else if UI_To_Int (Esize (Rtyp)) <= Standard_Integer_Size then Ent := RTE (RE_Exp_Unsigned); else Ent := RTE (RE_Exp_Long_Long_Unsigned); end if; Rewrite (N, Convert_To (Typ, Make_Op_And (Loc, Left_Opnd => Make_Function_Call (Loc, Name => New_Occurrence_Of (Ent, Loc), Parameter_Associations => New_List ( Convert_To (Etype (First_Formal (Ent)), Base), Exp)), Right_Opnd => Make_Integer_Literal (Loc, Modulus (Rtyp) - 1)))); end if; -- Common exit point for modular type case Analyze_And_Resolve (N, Typ); return; -- Signed integer cases, done using either Integer or Long_Long_Integer. -- It is not worth having routines for Short_[Short_]Integer, since for -- most machines it would not help, and it would generate more code that -- might need certification when a certified run time is required. -- In the integer cases, we have two routines, one for when overflow -- checks are required, and one when they are not required, since there -- is a real gain in omitting checks on many machines. elsif Rtyp = Base_Type (Standard_Long_Long_Integer) or else (Rtyp = Base_Type (Standard_Long_Integer) and then Esize (Standard_Long_Integer) > Esize (Standard_Integer)) or else Rtyp = Universal_Integer then Etyp := Standard_Long_Long_Integer; if Ovflo then Rent := RE_Exp_Long_Long_Integer; else Rent := RE_Exn_Long_Long_Integer; end if; elsif Is_Signed_Integer_Type (Rtyp) then Etyp := Standard_Integer; if Ovflo then Rent := RE_Exp_Integer; else Rent := RE_Exn_Integer; end if; -- Floating-point cases. We do not need separate routines for the -- overflow case here, since in the case of floating-point, we generate -- infinities anyway as a rule (either that or we automatically trap -- overflow), and if there is an infinity generated and a range check -- is required, the check will fail anyway. -- Historical note: we used to convert everything to Long_Long_Float -- and call a single common routine, but this had the undesirable effect -- of giving different results for small static exponent values and the -- same dynamic values. else pragma Assert (Is_Floating_Point_Type (Rtyp)); if Rtyp = Standard_Float then Etyp := Standard_Float; Rent := RE_Exn_Float; elsif Rtyp = Standard_Long_Float then Etyp := Standard_Long_Float; Rent := RE_Exn_Long_Float; else Etyp := Standard_Long_Long_Float; Rent := RE_Exn_Long_Long_Float; end if; end if; -- Common processing for integer cases and floating-point cases. -- If we are in the right type, we can call runtime routine directly if Typ = Etyp and then Rtyp /= Universal_Integer and then Rtyp /= Universal_Real then Rewrite (N, Wrap_MA ( Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (Rent), Loc), Parameter_Associations => New_List (Base, Exp)))); -- Otherwise we have to introduce conversions (conversions are also -- required in the universal cases, since the runtime routine is -- typed using one of the standard types). else Rewrite (N, Convert_To (Typ, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (Rent), Loc), Parameter_Associations => New_List ( Convert_To (Etyp, Base), Exp)))); end if; Analyze_And_Resolve (N, Typ); return; exception when RE_Not_Available => return; end Expand_N_Op_Expon; -------------------- -- Expand_N_Op_Ge -- -------------------- procedure Expand_N_Op_Ge (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); begin Binary_Op_Validity_Checks (N); -- Deal with overflow checks in MINIMIZED/ELIMINATED mode and if that -- means we no longer have a comparison operation, we are all done. Expand_Compare_Minimize_Eliminate_Overflow (N); if Nkind (N) /= N_Op_Ge then return; end if; -- Array type case if Is_Array_Type (Typ1) then Expand_Array_Comparison (N); return; end if; -- Deal with boolean operands if Is_Boolean_Type (Typ1) then Adjust_Condition (Op1); Adjust_Condition (Op2); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); Optimize_Length_Comparison (N); end Expand_N_Op_Ge; -------------------- -- Expand_N_Op_Gt -- -------------------- procedure Expand_N_Op_Gt (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); begin Binary_Op_Validity_Checks (N); -- Deal with overflow checks in MINIMIZED/ELIMINATED mode and if that -- means we no longer have a comparison operation, we are all done. Expand_Compare_Minimize_Eliminate_Overflow (N); if Nkind (N) /= N_Op_Gt then return; end if; -- Deal with array type operands if Is_Array_Type (Typ1) then Expand_Array_Comparison (N); return; end if; -- Deal with boolean type operands if Is_Boolean_Type (Typ1) then Adjust_Condition (Op1); Adjust_Condition (Op2); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); Optimize_Length_Comparison (N); end Expand_N_Op_Gt; -------------------- -- Expand_N_Op_Le -- -------------------- procedure Expand_N_Op_Le (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); begin Binary_Op_Validity_Checks (N); -- Deal with overflow checks in MINIMIZED/ELIMINATED mode and if that -- means we no longer have a comparison operation, we are all done. Expand_Compare_Minimize_Eliminate_Overflow (N); if Nkind (N) /= N_Op_Le then return; end if; -- Deal with array type operands if Is_Array_Type (Typ1) then Expand_Array_Comparison (N); return; end if; -- Deal with Boolean type operands if Is_Boolean_Type (Typ1) then Adjust_Condition (Op1); Adjust_Condition (Op2); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); Optimize_Length_Comparison (N); end Expand_N_Op_Le; -------------------- -- Expand_N_Op_Lt -- -------------------- procedure Expand_N_Op_Lt (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); begin Binary_Op_Validity_Checks (N); -- Deal with overflow checks in MINIMIZED/ELIMINATED mode and if that -- means we no longer have a comparison operation, we are all done. Expand_Compare_Minimize_Eliminate_Overflow (N); if Nkind (N) /= N_Op_Lt then return; end if; -- Deal with array type operands if Is_Array_Type (Typ1) then Expand_Array_Comparison (N); return; end if; -- Deal with Boolean type operands if Is_Boolean_Type (Typ1) then Adjust_Condition (Op1); Adjust_Condition (Op2); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); Optimize_Length_Comparison (N); end Expand_N_Op_Lt; ----------------------- -- Expand_N_Op_Minus -- ----------------------- procedure Expand_N_Op_Minus (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); begin Unary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; if not Backend_Overflow_Checks_On_Target and then Is_Signed_Integer_Type (Etype (N)) and then Do_Overflow_Check (N) then -- Software overflow checking expands -expr into (0 - expr) Rewrite (N, Make_Op_Subtract (Loc, Left_Opnd => Make_Integer_Literal (Loc, 0), Right_Opnd => Right_Opnd (N))); Analyze_And_Resolve (N, Typ); end if; end Expand_N_Op_Minus; --------------------- -- Expand_N_Op_Mod -- --------------------- procedure Expand_N_Op_Mod (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); DDC : constant Boolean := Do_Division_Check (N); Left : Node_Id; Right : Node_Id; LLB : Uint; Llo : Uint; Lhi : Uint; LOK : Boolean; Rlo : Uint; Rhi : Uint; ROK : Boolean; pragma Warnings (Off, Lhi); begin Binary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; if Is_Integer_Type (Etype (N)) then Apply_Divide_Checks (N); -- All done if we don't have a MOD any more, which can happen as a -- result of overflow expansion in MINIMIZED or ELIMINATED modes. if Nkind (N) /= N_Op_Mod then return; end if; end if; -- Proceed with expansion of mod operator Left := Left_Opnd (N); Right := Right_Opnd (N); Determine_Range (Right, ROK, Rlo, Rhi, Assume_Valid => True); Determine_Range (Left, LOK, Llo, Lhi, Assume_Valid => True); -- Convert mod to rem if operands are both known to be non-negative, or -- both known to be non-positive (these are the cases in which rem and -- mod are the same, see (RM 4.5.5(28-30)). We do this since it is quite -- likely that this will improve the quality of code, (the operation now -- corresponds to the hardware remainder), and it does not seem likely -- that it could be harmful. It also avoids some cases of the elaborate -- expansion in Modify_Tree_For_C mode below (since Ada rem = C %). if (LOK and ROK) and then ((Llo >= 0 and then Rlo >= 0) or else (Lhi <= 0 and then Rhi <= 0)) then Rewrite (N, Make_Op_Rem (Sloc (N), Left_Opnd => Left_Opnd (N), Right_Opnd => Right_Opnd (N))); -- Instead of reanalyzing the node we do the analysis manually. This -- avoids anomalies when the replacement is done in an instance and -- is epsilon more efficient. Set_Entity (N, Standard_Entity (S_Op_Rem)); Set_Etype (N, Typ); Set_Do_Division_Check (N, DDC); Expand_N_Op_Rem (N); Set_Analyzed (N); return; -- Otherwise, normal mod processing else -- Apply optimization x mod 1 = 0. We don't really need that with -- gcc, but it is useful with other back ends and is certainly -- harmless. if Is_Integer_Type (Etype (N)) and then Compile_Time_Known_Value (Right) and then Expr_Value (Right) = Uint_1 then -- Call Remove_Side_Effects to ensure that any side effects in -- the ignored left operand (in particular function calls to -- user defined functions) are properly executed. Remove_Side_Effects (Left); Rewrite (N, Make_Integer_Literal (Loc, 0)); Analyze_And_Resolve (N, Typ); return; end if; -- If we still have a mod operator and we are in Modify_Tree_For_C -- mode, and we have a signed integer type, then here is where we do -- the rewrite in terms of Rem. Note this rewrite bypasses the need -- for the special handling of the annoying case of largest negative -- number mod minus one. if Nkind (N) = N_Op_Mod and then Is_Signed_Integer_Type (Typ) and then Modify_Tree_For_C then -- In the general case, we expand A mod B as -- Tnn : constant typ := A rem B; -- .. -- (if (A >= 0) = (B >= 0) then Tnn -- elsif Tnn = 0 then 0 -- else Tnn + B) -- The comparison can be written simply as A >= 0 if we know that -- B >= 0 which is a very common case. -- An important optimization is when B is known at compile time -- to be 2**K for some constant. In this case we can simply AND -- the left operand with the bit string 2**K-1 (i.e. K 1-bits) -- and that works for both the positive and negative cases. declare P2 : constant Nat := Power_Of_Two (Right); begin if P2 /= 0 then Rewrite (N, Unchecked_Convert_To (Typ, Make_Op_And (Loc, Left_Opnd => Unchecked_Convert_To (Corresponding_Unsigned_Type (Typ), Left), Right_Opnd => Make_Integer_Literal (Loc, 2 ** P2 - 1)))); Analyze_And_Resolve (N, Typ); return; end if; end; -- Here for the full rewrite declare Tnn : constant Entity_Id := Make_Temporary (Sloc (N), 'T', N); Cmp : Node_Id; begin Cmp := Make_Op_Ge (Loc, Left_Opnd => Duplicate_Subexpr_No_Checks (Left), Right_Opnd => Make_Integer_Literal (Loc, 0)); if not LOK or else Rlo < 0 then Cmp := Make_Op_Eq (Loc, Left_Opnd => Cmp, Right_Opnd => Make_Op_Ge (Loc, Left_Opnd => Duplicate_Subexpr_No_Checks (Right), Right_Opnd => Make_Integer_Literal (Loc, 0))); end if; Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Tnn, Constant_Present => True, Object_Definition => New_Occurrence_Of (Typ, Loc), Expression => Make_Op_Rem (Loc, Left_Opnd => Left, Right_Opnd => Right))); Rewrite (N, Make_If_Expression (Loc, Expressions => New_List ( Cmp, New_Occurrence_Of (Tnn, Loc), Make_If_Expression (Loc, Is_Elsif => True, Expressions => New_List ( Make_Op_Eq (Loc, Left_Opnd => New_Occurrence_Of (Tnn, Loc), Right_Opnd => Make_Integer_Literal (Loc, 0)), Make_Integer_Literal (Loc, 0), Make_Op_Add (Loc, Left_Opnd => New_Occurrence_Of (Tnn, Loc), Right_Opnd => Duplicate_Subexpr_No_Checks (Right))))))); Analyze_And_Resolve (N, Typ); return; end; end if; -- Deal with annoying case of largest negative number mod minus one. -- Gigi may not handle this case correctly, because on some targets, -- the mod value is computed using a divide instruction which gives -- an overflow trap for this case. -- It would be a bit more efficient to figure out which targets -- this is really needed for, but in practice it is reasonable -- to do the following special check in all cases, since it means -- we get a clearer message, and also the overhead is minimal given -- that division is expensive in any case. -- In fact the check is quite easy, if the right operand is -1, then -- the mod value is always 0, and we can just ignore the left operand -- completely in this case. -- This only applies if we still have a mod operator. Skip if we -- have already rewritten this (e.g. in the case of eliminated -- overflow checks which have driven us into bignum mode). if Nkind (N) = N_Op_Mod then -- The operand type may be private (e.g. in the expansion of an -- intrinsic operation) so we must use the underlying type to get -- the bounds, and convert the literals explicitly. LLB := Expr_Value (Type_Low_Bound (Base_Type (Underlying_Type (Etype (Left))))); if ((not ROK) or else (Rlo <= (-1) and then (-1) <= Rhi)) and then ((not LOK) or else (Llo = LLB)) then Rewrite (N, Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Right), Right_Opnd => Unchecked_Convert_To (Typ, Make_Integer_Literal (Loc, -1))), Unchecked_Convert_To (Typ, Make_Integer_Literal (Loc, Uint_0)), Relocate_Node (N)))); Set_Analyzed (Next (Next (First (Expressions (N))))); Analyze_And_Resolve (N, Typ); end if; end if; end if; end Expand_N_Op_Mod; -------------------------- -- Expand_N_Op_Multiply -- -------------------------- procedure Expand_N_Op_Multiply (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Lop : constant Node_Id := Left_Opnd (N); Rop : constant Node_Id := Right_Opnd (N); Lp2 : constant Boolean := Nkind (Lop) = N_Op_Expon and then Is_Power_Of_2_For_Shift (Lop); Rp2 : constant Boolean := Nkind (Rop) = N_Op_Expon and then Is_Power_Of_2_For_Shift (Rop); Ltyp : constant Entity_Id := Etype (Lop); Rtyp : constant Entity_Id := Etype (Rop); Typ : Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- Special optimizations for integer types if Is_Integer_Type (Typ) then -- N * 0 = 0 for integer types if Compile_Time_Known_Value (Rop) and then Expr_Value (Rop) = Uint_0 then -- Call Remove_Side_Effects to ensure that any side effects in -- the ignored left operand (in particular function calls to -- user defined functions) are properly executed. Remove_Side_Effects (Lop); Rewrite (N, Make_Integer_Literal (Loc, Uint_0)); Analyze_And_Resolve (N, Typ); return; end if; -- Similar handling for 0 * N = 0 if Compile_Time_Known_Value (Lop) and then Expr_Value (Lop) = Uint_0 then Remove_Side_Effects (Rop); Rewrite (N, Make_Integer_Literal (Loc, Uint_0)); Analyze_And_Resolve (N, Typ); return; end if; -- N * 1 = 1 * N = N for integer types -- This optimisation is not done if we are going to -- rewrite the product 1 * 2 ** N to a shift. if Compile_Time_Known_Value (Rop) and then Expr_Value (Rop) = Uint_1 and then not Lp2 then Rewrite (N, Lop); return; elsif Compile_Time_Known_Value (Lop) and then Expr_Value (Lop) = Uint_1 and then not Rp2 then Rewrite (N, Rop); return; end if; end if; -- Convert x * 2 ** y to Shift_Left (x, y). Note that the fact that -- Is_Power_Of_2_For_Shift is set means that we know that our left -- operand is an integer, as required for this to work. if Rp2 then if Lp2 then -- Convert 2 ** A * 2 ** B into 2 ** (A + B) Rewrite (N, Make_Op_Expon (Loc, Left_Opnd => Make_Integer_Literal (Loc, 2), Right_Opnd => Make_Op_Add (Loc, Left_Opnd => Right_Opnd (Lop), Right_Opnd => Right_Opnd (Rop)))); Analyze_And_Resolve (N, Typ); return; else -- If the result is modular, perform the reduction of the result -- appropriately. if Is_Modular_Integer_Type (Typ) and then not Non_Binary_Modulus (Typ) then Rewrite (N, Make_Op_And (Loc, Left_Opnd => Make_Op_Shift_Left (Loc, Left_Opnd => Lop, Right_Opnd => Convert_To (Standard_Natural, Right_Opnd (Rop))), Right_Opnd => Make_Integer_Literal (Loc, Modulus (Typ) - 1))); else Rewrite (N, Make_Op_Shift_Left (Loc, Left_Opnd => Lop, Right_Opnd => Convert_To (Standard_Natural, Right_Opnd (Rop)))); end if; Analyze_And_Resolve (N, Typ); return; end if; -- Same processing for the operands the other way round elsif Lp2 then if Is_Modular_Integer_Type (Typ) and then not Non_Binary_Modulus (Typ) then Rewrite (N, Make_Op_And (Loc, Left_Opnd => Make_Op_Shift_Left (Loc, Left_Opnd => Rop, Right_Opnd => Convert_To (Standard_Natural, Right_Opnd (Lop))), Right_Opnd => Make_Integer_Literal (Loc, Modulus (Typ) - 1))); else Rewrite (N, Make_Op_Shift_Left (Loc, Left_Opnd => Rop, Right_Opnd => Convert_To (Standard_Natural, Right_Opnd (Lop)))); end if; Analyze_And_Resolve (N, Typ); return; end if; -- Do required fixup of universal fixed operation if Typ = Universal_Fixed then Fixup_Universal_Fixed_Operation (N); Typ := Etype (N); end if; -- Multiplications with fixed-point results if Is_Fixed_Point_Type (Typ) then -- No special processing if Treat_Fixed_As_Integer is set, since from -- a semantic point of view such operations are simply integer -- operations and will be treated that way. if not Treat_Fixed_As_Integer (N) then -- Case of fixed * integer => fixed if Is_Integer_Type (Rtyp) then Expand_Multiply_Fixed_By_Integer_Giving_Fixed (N); -- Case of integer * fixed => fixed elsif Is_Integer_Type (Ltyp) then Expand_Multiply_Integer_By_Fixed_Giving_Fixed (N); -- Case of fixed * fixed => fixed else Expand_Multiply_Fixed_By_Fixed_Giving_Fixed (N); end if; end if; -- Other cases of multiplication of fixed-point operands. Again we -- exclude the cases where Treat_Fixed_As_Integer flag is set. elsif (Is_Fixed_Point_Type (Ltyp) or else Is_Fixed_Point_Type (Rtyp)) and then not Treat_Fixed_As_Integer (N) then if Is_Integer_Type (Typ) then Expand_Multiply_Fixed_By_Fixed_Giving_Integer (N); else pragma Assert (Is_Floating_Point_Type (Typ)); Expand_Multiply_Fixed_By_Fixed_Giving_Float (N); end if; -- Mixed-mode operations can appear in a non-static universal context, -- in which case the integer argument must be converted explicitly. elsif Typ = Universal_Real and then Is_Integer_Type (Rtyp) then Rewrite (Rop, Convert_To (Universal_Real, Relocate_Node (Rop))); Analyze_And_Resolve (Rop, Universal_Real); elsif Typ = Universal_Real and then Is_Integer_Type (Ltyp) then Rewrite (Lop, Convert_To (Universal_Real, Relocate_Node (Lop))); Analyze_And_Resolve (Lop, Universal_Real); -- Non-fixed point cases, check software overflow checking required elsif Is_Signed_Integer_Type (Etype (N)) then Apply_Arithmetic_Overflow_Check (N); end if; -- Overflow checks for floating-point if -gnateF mode active Check_Float_Op_Overflow (N); end Expand_N_Op_Multiply; -------------------- -- Expand_N_Op_Ne -- -------------------- procedure Expand_N_Op_Ne (N : Node_Id) is Typ : constant Entity_Id := Etype (Left_Opnd (N)); begin -- Case of elementary type with standard operator if Is_Elementary_Type (Typ) and then Sloc (Entity (N)) = Standard_Location then Binary_Op_Validity_Checks (N); -- Deal with overflow checks in MINIMIZED/ELIMINATED mode and if -- means we no longer have a /= operation, we are all done. Expand_Compare_Minimize_Eliminate_Overflow (N); if Nkind (N) /= N_Op_Ne then return; end if; -- Boolean types (requiring handling of non-standard case) if Is_Boolean_Type (Typ) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); -- For all cases other than elementary types, we rewrite node as the -- negation of an equality operation, and reanalyze. The equality to be -- used is defined in the same scope and has the same signature. This -- signature must be set explicitly since in an instance it may not have -- the same visibility as in the generic unit. This avoids duplicating -- or factoring the complex code for record/array equality tests etc. else declare Loc : constant Source_Ptr := Sloc (N); Neg : Node_Id; Ne : constant Entity_Id := Entity (N); begin Binary_Op_Validity_Checks (N); Neg := Make_Op_Not (Loc, Right_Opnd => Make_Op_Eq (Loc, Left_Opnd => Left_Opnd (N), Right_Opnd => Right_Opnd (N))); Set_Paren_Count (Right_Opnd (Neg), 1); if Scope (Ne) /= Standard_Standard then Set_Entity (Right_Opnd (Neg), Corresponding_Equality (Ne)); end if; -- For navigation purposes, we want to treat the inequality as an -- implicit reference to the corresponding equality. Preserve the -- Comes_From_ source flag to generate proper Xref entries. Preserve_Comes_From_Source (Neg, N); Preserve_Comes_From_Source (Right_Opnd (Neg), N); Rewrite (N, Neg); Analyze_And_Resolve (N, Standard_Boolean); end; end if; Optimize_Length_Comparison (N); end Expand_N_Op_Ne; --------------------- -- Expand_N_Op_Not -- --------------------- -- If the argument is other than a Boolean array type, there is no special -- expansion required, except for dealing with validity checks, and non- -- standard boolean representations. -- For the packed array case, we call the special routine in Exp_Pakd, -- except that if the component size is greater than one, we use the -- standard routine generating a gruesome loop (it is so peculiar to have -- packed arrays with non-standard Boolean representations anyway, so it -- does not matter that we do not handle this case efficiently). -- For the unpacked array case (and for the special packed case where we -- have non standard Booleans, as discussed above), we generate and insert -- into the tree the following function definition: -- function Nnnn (A : arr) is -- B : arr; -- begin -- for J in a'range loop -- B (J) := not A (J); -- end loop; -- return B; -- end Nnnn; -- Here arr is the actual subtype of the parameter (and hence always -- constrained). Then we replace the not with a call to this function. procedure Expand_N_Op_Not (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Opnd : Node_Id; Arr : Entity_Id; A : Entity_Id; B : Entity_Id; J : Entity_Id; A_J : Node_Id; B_J : Node_Id; Func_Name : Entity_Id; Loop_Statement : Node_Id; begin Unary_Op_Validity_Checks (N); -- For boolean operand, deal with non-standard booleans if Is_Boolean_Type (Typ) then Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); return; end if; -- Only array types need any other processing if not Is_Array_Type (Typ) then return; end if; -- Case of array operand. If bit packed with a component size of 1, -- handle it in Exp_Pakd if the operand is known to be aligned. if Is_Bit_Packed_Array (Typ) and then Component_Size (Typ) = 1 and then not Is_Possibly_Unaligned_Object (Right_Opnd (N)) then Expand_Packed_Not (N); return; end if; -- Case of array operand which is not bit-packed. If the context is -- a safe assignment, call in-place operation, If context is a larger -- boolean expression in the context of a safe assignment, expansion is -- done by enclosing operation. Opnd := Relocate_Node (Right_Opnd (N)); Convert_To_Actual_Subtype (Opnd); Arr := Etype (Opnd); Ensure_Defined (Arr, N); Silly_Boolean_Array_Not_Test (N, Arr); if Nkind (Parent (N)) = N_Assignment_Statement then if Safe_In_Place_Array_Op (Name (Parent (N)), N, Empty) then Build_Boolean_Array_Proc_Call (Parent (N), Opnd, Empty); return; -- Special case the negation of a binary operation elsif Nkind_In (Opnd, N_Op_And, N_Op_Or, N_Op_Xor) and then Safe_In_Place_Array_Op (Name (Parent (N)), Left_Opnd (Opnd), Right_Opnd (Opnd)) then Build_Boolean_Array_Proc_Call (Parent (N), Opnd, Empty); return; end if; elsif Nkind (Parent (N)) in N_Binary_Op and then Nkind (Parent (Parent (N))) = N_Assignment_Statement then declare Op1 : constant Node_Id := Left_Opnd (Parent (N)); Op2 : constant Node_Id := Right_Opnd (Parent (N)); Lhs : constant Node_Id := Name (Parent (Parent (N))); begin if Safe_In_Place_Array_Op (Lhs, Op1, Op2) then -- (not A) op (not B) can be reduced to a single call if N = Op1 and then Nkind (Op2) = N_Op_Not then return; elsif N = Op2 and then Nkind (Op1) = N_Op_Not then return; -- A xor (not B) can also be special-cased elsif N = Op2 and then Nkind (Parent (N)) = N_Op_Xor then return; end if; end if; end; end if; A := Make_Defining_Identifier (Loc, Name_uA); B := Make_Defining_Identifier (Loc, Name_uB); J := Make_Defining_Identifier (Loc, Name_uJ); A_J := Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (A, Loc), Expressions => New_List (New_Occurrence_Of (J, Loc))); B_J := Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (B, Loc), Expressions => New_List (New_Occurrence_Of (J, Loc))); Loop_Statement := Make_Implicit_Loop_Statement (N, Identifier => Empty, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => J, Discrete_Subtype_Definition => Make_Attribute_Reference (Loc, Prefix => Make_Identifier (Loc, Chars (A)), Attribute_Name => Name_Range))), Statements => New_List ( Make_Assignment_Statement (Loc, Name => B_J, Expression => Make_Op_Not (Loc, A_J)))); Func_Name := Make_Temporary (Loc, 'N'); Set_Is_Inlined (Func_Name); Insert_Action (N, Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Func_Name, Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => A, Parameter_Type => New_Occurrence_Of (Typ, Loc))), Result_Definition => New_Occurrence_Of (Typ, Loc)), Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => B, Object_Definition => New_Occurrence_Of (Arr, Loc))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Loop_Statement, Make_Simple_Return_Statement (Loc, Expression => Make_Identifier (Loc, Chars (B))))))); Rewrite (N, Make_Function_Call (Loc, Name => New_Occurrence_Of (Func_Name, Loc), Parameter_Associations => New_List (Opnd))); Analyze_And_Resolve (N, Typ); end Expand_N_Op_Not; -------------------- -- Expand_N_Op_Or -- -------------------- procedure Expand_N_Op_Or (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); if Is_Array_Type (Etype (N)) then Expand_Boolean_Operator (N); elsif Is_Boolean_Type (Etype (N)) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); elsif Is_Intrinsic_Subprogram (Entity (N)) then Expand_Intrinsic_Call (N, Entity (N)); end if; end Expand_N_Op_Or; ---------------------- -- Expand_N_Op_Plus -- ---------------------- procedure Expand_N_Op_Plus (N : Node_Id) is begin Unary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; end Expand_N_Op_Plus; --------------------- -- Expand_N_Op_Rem -- --------------------- procedure Expand_N_Op_Rem (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Left : Node_Id; Right : Node_Id; Lo : Uint; Hi : Uint; OK : Boolean; Lneg : Boolean; Rneg : Boolean; -- Set if corresponding operand can be negative pragma Unreferenced (Hi); begin Binary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; if Is_Integer_Type (Etype (N)) then Apply_Divide_Checks (N); -- All done if we don't have a REM any more, which can happen as a -- result of overflow expansion in MINIMIZED or ELIMINATED modes. if Nkind (N) /= N_Op_Rem then return; end if; end if; -- Proceed with expansion of REM Left := Left_Opnd (N); Right := Right_Opnd (N); -- Apply optimization x rem 1 = 0. We don't really need that with gcc, -- but it is useful with other back ends, and is certainly harmless. if Is_Integer_Type (Etype (N)) and then Compile_Time_Known_Value (Right) and then Expr_Value (Right) = Uint_1 then -- Call Remove_Side_Effects to ensure that any side effects in the -- ignored left operand (in particular function calls to user defined -- functions) are properly executed. Remove_Side_Effects (Left); Rewrite (N, Make_Integer_Literal (Loc, 0)); Analyze_And_Resolve (N, Typ); return; end if; -- Deal with annoying case of largest negative number remainder minus -- one. Gigi may not handle this case correctly, because on some -- targets, the mod value is computed using a divide instruction -- which gives an overflow trap for this case. -- It would be a bit more efficient to figure out which targets this -- is really needed for, but in practice it is reasonable to do the -- following special check in all cases, since it means we get a clearer -- message, and also the overhead is minimal given that division is -- expensive in any case. -- In fact the check is quite easy, if the right operand is -1, then -- the remainder is always 0, and we can just ignore the left operand -- completely in this case. Determine_Range (Right, OK, Lo, Hi, Assume_Valid => True); Lneg := (not OK) or else Lo < 0; Determine_Range (Left, OK, Lo, Hi, Assume_Valid => True); Rneg := (not OK) or else Lo < 0; -- We won't mess with trying to find out if the left operand can really -- be the largest negative number (that's a pain in the case of private -- types and this is really marginal). We will just assume that we need -- the test if the left operand can be negative at all. if Lneg and Rneg then Rewrite (N, Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Right), Right_Opnd => Unchecked_Convert_To (Typ, Make_Integer_Literal (Loc, -1))), Unchecked_Convert_To (Typ, Make_Integer_Literal (Loc, Uint_0)), Relocate_Node (N)))); Set_Analyzed (Next (Next (First (Expressions (N))))); Analyze_And_Resolve (N, Typ); end if; end Expand_N_Op_Rem; ----------------------------- -- Expand_N_Op_Rotate_Left -- ----------------------------- procedure Expand_N_Op_Rotate_Left (N : Node_Id) is begin Binary_Op_Validity_Checks (N); -- If we are in Modify_Tree_For_C mode, there is no rotate left in C, -- so we rewrite in terms of logical shifts -- Shift_Left (Num, Bits) or Shift_Right (num, Esize - Bits) -- where Bits is the shift count mod Esize (the mod operation here -- deals with ludicrous large shift counts, which are apparently OK). -- What about nonbinary modulus ??? declare Loc : constant Source_Ptr := Sloc (N); Rtp : constant Entity_Id := Etype (Right_Opnd (N)); Typ : constant Entity_Id := Etype (N); begin if Modify_Tree_For_C then Rewrite (Right_Opnd (N), Make_Op_Rem (Loc, Left_Opnd => Relocate_Node (Right_Opnd (N)), Right_Opnd => Make_Integer_Literal (Loc, Esize (Typ)))); Analyze_And_Resolve (Right_Opnd (N), Rtp); Rewrite (N, Make_Op_Or (Loc, Left_Opnd => Make_Op_Shift_Left (Loc, Left_Opnd => Left_Opnd (N), Right_Opnd => Right_Opnd (N)), Right_Opnd => Make_Op_Shift_Right (Loc, Left_Opnd => Duplicate_Subexpr_No_Checks (Left_Opnd (N)), Right_Opnd => Make_Op_Subtract (Loc, Left_Opnd => Make_Integer_Literal (Loc, Esize (Typ)), Right_Opnd => Duplicate_Subexpr_No_Checks (Right_Opnd (N)))))); Analyze_And_Resolve (N, Typ); end if; end; end Expand_N_Op_Rotate_Left; ------------------------------ -- Expand_N_Op_Rotate_Right -- ------------------------------ procedure Expand_N_Op_Rotate_Right (N : Node_Id) is begin Binary_Op_Validity_Checks (N); -- If we are in Modify_Tree_For_C mode, there is no rotate right in C, -- so we rewrite in terms of logical shifts -- Shift_Right (Num, Bits) or Shift_Left (num, Esize - Bits) -- where Bits is the shift count mod Esize (the mod operation here -- deals with ludicrous large shift counts, which are apparently OK). -- What about nonbinary modulus ??? declare Loc : constant Source_Ptr := Sloc (N); Rtp : constant Entity_Id := Etype (Right_Opnd (N)); Typ : constant Entity_Id := Etype (N); begin Rewrite (Right_Opnd (N), Make_Op_Rem (Loc, Left_Opnd => Relocate_Node (Right_Opnd (N)), Right_Opnd => Make_Integer_Literal (Loc, Esize (Typ)))); Analyze_And_Resolve (Right_Opnd (N), Rtp); if Modify_Tree_For_C then Rewrite (N, Make_Op_Or (Loc, Left_Opnd => Make_Op_Shift_Right (Loc, Left_Opnd => Left_Opnd (N), Right_Opnd => Right_Opnd (N)), Right_Opnd => Make_Op_Shift_Left (Loc, Left_Opnd => Duplicate_Subexpr_No_Checks (Left_Opnd (N)), Right_Opnd => Make_Op_Subtract (Loc, Left_Opnd => Make_Integer_Literal (Loc, Esize (Typ)), Right_Opnd => Duplicate_Subexpr_No_Checks (Right_Opnd (N)))))); Analyze_And_Resolve (N, Typ); end if; end; end Expand_N_Op_Rotate_Right; ---------------------------- -- Expand_N_Op_Shift_Left -- ---------------------------- -- Note: nothing in this routine depends on left as opposed to right shifts -- so we share the routine for expanding shift right operations. procedure Expand_N_Op_Shift_Left (N : Node_Id) is begin Binary_Op_Validity_Checks (N); -- If we are in Modify_Tree_For_C mode, then ensure that the right -- operand is not greater than the word size (since that would not -- be defined properly by the corresponding C shift operator). if Modify_Tree_For_C then declare Right : constant Node_Id := Right_Opnd (N); Loc : constant Source_Ptr := Sloc (Right); Typ : constant Entity_Id := Etype (N); Siz : constant Uint := Esize (Typ); Orig : Node_Id; OK : Boolean; Lo : Uint; Hi : Uint; begin if Compile_Time_Known_Value (Right) then if Expr_Value (Right) >= Siz then Rewrite (N, Make_Integer_Literal (Loc, 0)); Analyze_And_Resolve (N, Typ); end if; -- Not compile time known, find range else Determine_Range (Right, OK, Lo, Hi, Assume_Valid => True); -- Nothing to do if known to be OK range, otherwise expand if not OK or else Hi >= Siz then -- Prevent recursion on copy of shift node Orig := Relocate_Node (N); Set_Analyzed (Orig); -- Now do the rewrite Rewrite (N, Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Ge (Loc, Left_Opnd => Duplicate_Subexpr_Move_Checks (Right), Right_Opnd => Make_Integer_Literal (Loc, Siz)), Make_Integer_Literal (Loc, 0), Orig))); Analyze_And_Resolve (N, Typ); end if; end if; end; end if; end Expand_N_Op_Shift_Left; ----------------------------- -- Expand_N_Op_Shift_Right -- ----------------------------- procedure Expand_N_Op_Shift_Right (N : Node_Id) is begin -- Share shift left circuit Expand_N_Op_Shift_Left (N); end Expand_N_Op_Shift_Right; ---------------------------------------- -- Expand_N_Op_Shift_Right_Arithmetic -- ---------------------------------------- procedure Expand_N_Op_Shift_Right_Arithmetic (N : Node_Id) is begin Binary_Op_Validity_Checks (N); -- If we are in Modify_Tree_For_C mode, there is no shift right -- arithmetic in C, so we rewrite in terms of logical shifts. -- Shift_Right (Num, Bits) or -- (if Num >= Sign -- then not (Shift_Right (Mask, bits)) -- else 0) -- Here Mask is all 1 bits (2**size - 1), and Sign is 2**(size - 1) -- Note: in almost all C compilers it would work to just shift a -- signed integer right, but it's undefined and we cannot rely on it. -- Note: the above works fine for shift counts greater than or equal -- to the word size, since in this case (not (Shift_Right (Mask, bits))) -- generates all 1'bits. -- What about nonbinary modulus ??? declare Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Sign : constant Uint := 2 ** (Esize (Typ) - 1); Mask : constant Uint := (2 ** Esize (Typ)) - 1; Left : constant Node_Id := Left_Opnd (N); Right : constant Node_Id := Right_Opnd (N); Maskx : Node_Id; begin if Modify_Tree_For_C then -- Here if not (Shift_Right (Mask, bits)) can be computed at -- compile time as a single constant. if Compile_Time_Known_Value (Right) then declare Val : constant Uint := Expr_Value (Right); begin if Val >= Esize (Typ) then Maskx := Make_Integer_Literal (Loc, Mask); else Maskx := Make_Integer_Literal (Loc, Intval => Mask - (Mask / (2 ** Expr_Value (Right)))); end if; end; else Maskx := Make_Op_Not (Loc, Right_Opnd => Make_Op_Shift_Right (Loc, Left_Opnd => Make_Integer_Literal (Loc, Mask), Right_Opnd => Duplicate_Subexpr_No_Checks (Right))); end if; -- Now do the rewrite Rewrite (N, Make_Op_Or (Loc, Left_Opnd => Make_Op_Shift_Right (Loc, Left_Opnd => Left, Right_Opnd => Right), Right_Opnd => Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Ge (Loc, Left_Opnd => Duplicate_Subexpr_No_Checks (Left), Right_Opnd => Make_Integer_Literal (Loc, Sign)), Maskx, Make_Integer_Literal (Loc, 0))))); Analyze_And_Resolve (N, Typ); end if; end; end Expand_N_Op_Shift_Right_Arithmetic; -------------------------- -- Expand_N_Op_Subtract -- -------------------------- procedure Expand_N_Op_Subtract (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); -- Check for MINIMIZED/ELIMINATED overflow mode if Minimized_Eliminated_Overflow_Check (N) then Apply_Arithmetic_Overflow_Check (N); return; end if; -- N - 0 = N for integer types if Is_Integer_Type (Typ) and then Compile_Time_Known_Value (Right_Opnd (N)) and then Expr_Value (Right_Opnd (N)) = 0 then Rewrite (N, Left_Opnd (N)); return; end if; -- Arithmetic overflow checks for signed integer/fixed point types if Is_Signed_Integer_Type (Typ) or else Is_Fixed_Point_Type (Typ) then Apply_Arithmetic_Overflow_Check (N); end if; -- Overflow checks for floating-point if -gnateF mode active Check_Float_Op_Overflow (N); end Expand_N_Op_Subtract; --------------------- -- Expand_N_Op_Xor -- --------------------- procedure Expand_N_Op_Xor (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); if Is_Array_Type (Etype (N)) then Expand_Boolean_Operator (N); elsif Is_Boolean_Type (Etype (N)) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); elsif Is_Intrinsic_Subprogram (Entity (N)) then Expand_Intrinsic_Call (N, Entity (N)); end if; end Expand_N_Op_Xor; ---------------------- -- Expand_N_Or_Else -- ---------------------- procedure Expand_N_Or_Else (N : Node_Id) renames Expand_Short_Circuit_Operator; ----------------------------------- -- Expand_N_Qualified_Expression -- ----------------------------------- procedure Expand_N_Qualified_Expression (N : Node_Id) is Operand : constant Node_Id := Expression (N); Target_Type : constant Entity_Id := Entity (Subtype_Mark (N)); begin -- Do validity check if validity checking operands if Validity_Checks_On and Validity_Check_Operands then Ensure_Valid (Operand); end if; -- Apply possible constraint check Apply_Constraint_Check (Operand, Target_Type, No_Sliding => True); if Do_Range_Check (Operand) then Set_Do_Range_Check (Operand, False); Generate_Range_Check (Operand, Target_Type, CE_Range_Check_Failed); end if; end Expand_N_Qualified_Expression; ------------------------------------ -- Expand_N_Quantified_Expression -- ------------------------------------ -- We expand: -- for all X in range => Cond -- into: -- T := True; -- for X in range loop -- if not Cond then -- T := False; -- exit; -- end if; -- end loop; -- Similarly, an existentially quantified expression: -- for some X in range => Cond -- becomes: -- T := False; -- for X in range loop -- if Cond then -- T := True; -- exit; -- end if; -- end loop; -- In both cases, the iteration may be over a container in which case it is -- given by an iterator specification, not a loop parameter specification. procedure Expand_N_Quantified_Expression (N : Node_Id) is Actions : constant List_Id := New_List; For_All : constant Boolean := All_Present (N); Iter_Spec : constant Node_Id := Iterator_Specification (N); Loc : constant Source_Ptr := Sloc (N); Loop_Spec : constant Node_Id := Loop_Parameter_Specification (N); Cond : Node_Id; Flag : Entity_Id; Scheme : Node_Id; Stmts : List_Id; begin -- Create the declaration of the flag which tracks the status of the -- quantified expression. Generate: -- Flag : Boolean := (True | False); Flag := Make_Temporary (Loc, 'T', N); Append_To (Actions, Make_Object_Declaration (Loc, Defining_Identifier => Flag, Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc), Expression => New_Occurrence_Of (Boolean_Literals (For_All), Loc))); -- Construct the circuitry which tracks the status of the quantified -- expression. Generate: -- if [not] Cond then -- Flag := (False | True); -- exit; -- end if; Cond := Relocate_Node (Condition (N)); if For_All then Cond := Make_Op_Not (Loc, Cond); end if; Stmts := New_List ( Make_Implicit_If_Statement (N, Condition => Cond, Then_Statements => New_List ( Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Flag, Loc), Expression => New_Occurrence_Of (Boolean_Literals (not For_All), Loc)), Make_Exit_Statement (Loc)))); -- Build the loop equivalent of the quantified expression if Present (Iter_Spec) then Scheme := Make_Iteration_Scheme (Loc, Iterator_Specification => Iter_Spec); else Scheme := Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Loop_Spec); end if; Append_To (Actions, Make_Loop_Statement (Loc, Iteration_Scheme => Scheme, Statements => Stmts, End_Label => Empty)); -- Transform the quantified expression Rewrite (N, Make_Expression_With_Actions (Loc, Expression => New_Occurrence_Of (Flag, Loc), Actions => Actions)); Analyze_And_Resolve (N, Standard_Boolean); end Expand_N_Quantified_Expression; --------------------------------- -- Expand_N_Selected_Component -- --------------------------------- procedure Expand_N_Selected_Component (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Par : constant Node_Id := Parent (N); P : constant Node_Id := Prefix (N); S : constant Node_Id := Selector_Name (N); Ptyp : Entity_Id := Underlying_Type (Etype (P)); Disc : Entity_Id; New_N : Node_Id; Dcon : Elmt_Id; Dval : Node_Id; function In_Left_Hand_Side (Comp : Node_Id) return Boolean; -- Gigi needs a temporary for prefixes that depend on a discriminant, -- unless the context of an assignment can provide size information. -- Don't we have a general routine that does this??? function Is_Subtype_Declaration return Boolean; -- The replacement of a discriminant reference by its value is required -- if this is part of the initialization of an temporary generated by a -- change of representation. This shows up as the construction of a -- discriminant constraint for a subtype declared at the same point as -- the entity in the prefix of the selected component. We recognize this -- case when the context of the reference is: -- subtype ST is T(Obj.D); -- where the entity for Obj comes from source, and ST has the same sloc. ----------------------- -- In_Left_Hand_Side -- ----------------------- function In_Left_Hand_Side (Comp : Node_Id) return Boolean is begin return (Nkind (Parent (Comp)) = N_Assignment_Statement and then Comp = Name (Parent (Comp))) or else (Present (Parent (Comp)) and then Nkind (Parent (Comp)) in N_Subexpr and then In_Left_Hand_Side (Parent (Comp))); end In_Left_Hand_Side; ----------------------------- -- Is_Subtype_Declaration -- ----------------------------- function Is_Subtype_Declaration return Boolean is Par : constant Node_Id := Parent (N); begin return Nkind (Par) = N_Index_Or_Discriminant_Constraint and then Nkind (Parent (Parent (Par))) = N_Subtype_Declaration and then Comes_From_Source (Entity (Prefix (N))) and then Sloc (Par) = Sloc (Entity (Prefix (N))); end Is_Subtype_Declaration; -- Start of processing for Expand_N_Selected_Component begin -- Insert explicit dereference if required if Is_Access_Type (Ptyp) then -- First set prefix type to proper access type, in case it currently -- has a private (non-access) view of this type. Set_Etype (P, Ptyp); Insert_Explicit_Dereference (P); Analyze_And_Resolve (P, Designated_Type (Ptyp)); if Ekind (Etype (P)) = E_Private_Subtype and then Is_For_Access_Subtype (Etype (P)) then Set_Etype (P, Base_Type (Etype (P))); end if; Ptyp := Etype (P); end if; -- Deal with discriminant check required if Do_Discriminant_Check (N) then if Present (Discriminant_Checking_Func (Original_Record_Component (Entity (S)))) then -- Present the discriminant checking function to the backend, so -- that it can inline the call to the function. Add_Inlined_Body (Discriminant_Checking_Func (Original_Record_Component (Entity (S))), N); -- Now reset the flag and generate the call Set_Do_Discriminant_Check (N, False); Generate_Discriminant_Check (N); -- In the case of Unchecked_Union, no discriminant checking is -- actually performed. else Set_Do_Discriminant_Check (N, False); end if; end if; -- Ada 2005 (AI-318-02): If the prefix is a call to a build-in-place -- function, then additional actuals must be passed. if Ada_Version >= Ada_2005 and then Is_Build_In_Place_Function_Call (P) then Make_Build_In_Place_Call_In_Anonymous_Context (P); end if; -- Gigi cannot handle unchecked conversions that are the prefix of a -- selected component with discriminants. This must be checked during -- expansion, because during analysis the type of the selector is not -- known at the point the prefix is analyzed. If the conversion is the -- target of an assignment, then we cannot force the evaluation. if Nkind (Prefix (N)) = N_Unchecked_Type_Conversion and then Has_Discriminants (Etype (N)) and then not In_Left_Hand_Side (N) then Force_Evaluation (Prefix (N)); end if; -- Remaining processing applies only if selector is a discriminant if Ekind (Entity (Selector_Name (N))) = E_Discriminant then -- If the selector is a discriminant of a constrained record type, -- we may be able to rewrite the expression with the actual value -- of the discriminant, a useful optimization in some cases. if Is_Record_Type (Ptyp) and then Has_Discriminants (Ptyp) and then Is_Constrained (Ptyp) then -- Do this optimization for discrete types only, and not for -- access types (access discriminants get us into trouble). if not Is_Discrete_Type (Etype (N)) then null; -- Don't do this on the left-hand side of an assignment statement. -- Normally one would think that references like this would not -- occur, but they do in generated code, and mean that we really -- do want to assign the discriminant. elsif Nkind (Par) = N_Assignment_Statement and then Name (Par) = N then null; -- Don't do this optimization for the prefix of an attribute or -- the name of an object renaming declaration since these are -- contexts where we do not want the value anyway. elsif (Nkind (Par) = N_Attribute_Reference and then Prefix (Par) = N) or else Is_Renamed_Object (N) then null; -- Don't do this optimization if we are within the code for a -- discriminant check, since the whole point of such a check may -- be to verify the condition on which the code below depends. elsif Is_In_Discriminant_Check (N) then null; -- Green light to see if we can do the optimization. There is -- still one condition that inhibits the optimization below but -- now is the time to check the particular discriminant. else -- Loop through discriminants to find the matching discriminant -- constraint to see if we can copy it. Disc := First_Discriminant (Ptyp); Dcon := First_Elmt (Discriminant_Constraint (Ptyp)); Discr_Loop : while Present (Dcon) loop Dval := Node (Dcon); -- Check if this is the matching discriminant and if the -- discriminant value is simple enough to make sense to -- copy. We don't want to copy complex expressions, and -- indeed to do so can cause trouble (before we put in -- this guard, a discriminant expression containing an -- AND THEN was copied, causing problems for coverage -- analysis tools). -- However, if the reference is part of the initialization -- code generated for an object declaration, we must use -- the discriminant value from the subtype constraint, -- because the selected component may be a reference to the -- object being initialized, whose discriminant is not yet -- set. This only happens in complex cases involving changes -- or representation. if Disc = Entity (Selector_Name (N)) and then (Is_Entity_Name (Dval) or else Compile_Time_Known_Value (Dval) or else Is_Subtype_Declaration) then -- Here we have the matching discriminant. Check for -- the case of a discriminant of a component that is -- constrained by an outer discriminant, which cannot -- be optimized away. if Denotes_Discriminant (Dval, Check_Concurrent => True) then exit Discr_Loop; elsif Nkind (Original_Node (Dval)) = N_Selected_Component and then Denotes_Discriminant (Selector_Name (Original_Node (Dval)), True) then exit Discr_Loop; -- Do not retrieve value if constraint is not static. It -- is generally not useful, and the constraint may be a -- rewritten outer discriminant in which case it is in -- fact incorrect. elsif Is_Entity_Name (Dval) and then Nkind (Parent (Entity (Dval))) = N_Object_Declaration and then Present (Expression (Parent (Entity (Dval)))) and then not Is_OK_Static_Expression (Expression (Parent (Entity (Dval)))) then exit Discr_Loop; -- In the context of a case statement, the expression may -- have the base type of the discriminant, and we need to -- preserve the constraint to avoid spurious errors on -- missing cases. elsif Nkind (Parent (N)) = N_Case_Statement and then Etype (Dval) /= Etype (Disc) then Rewrite (N, Make_Qualified_Expression (Loc, Subtype_Mark => New_Occurrence_Of (Etype (Disc), Loc), Expression => New_Copy_Tree (Dval))); Analyze_And_Resolve (N, Etype (Disc)); -- In case that comes out as a static expression, -- reset it (a selected component is never static). Set_Is_Static_Expression (N, False); return; -- Otherwise we can just copy the constraint, but the -- result is certainly not static. In some cases the -- discriminant constraint has been analyzed in the -- context of the original subtype indication, but for -- itypes the constraint might not have been analyzed -- yet, and this must be done now. else Rewrite (N, New_Copy_Tree (Dval)); Analyze_And_Resolve (N); Set_Is_Static_Expression (N, False); return; end if; end if; Next_Elmt (Dcon); Next_Discriminant (Disc); end loop Discr_Loop; -- Note: the above loop should always find a matching -- discriminant, but if it does not, we just missed an -- optimization due to some glitch (perhaps a previous -- error), so ignore. end if; end if; -- The only remaining processing is in the case of a discriminant of -- a concurrent object, where we rewrite the prefix to denote the -- corresponding record type. If the type is derived and has renamed -- discriminants, use corresponding discriminant, which is the one -- that appears in the corresponding record. if not Is_Concurrent_Type (Ptyp) then return; end if; Disc := Entity (Selector_Name (N)); if Is_Derived_Type (Ptyp) and then Present (Corresponding_Discriminant (Disc)) then Disc := Corresponding_Discriminant (Disc); end if; New_N := Make_Selected_Component (Loc, Prefix => Unchecked_Convert_To (Corresponding_Record_Type (Ptyp), New_Copy_Tree (P)), Selector_Name => Make_Identifier (Loc, Chars (Disc))); Rewrite (N, New_N); Analyze (N); end if; -- Set Atomic_Sync_Required if necessary for atomic component if Nkind (N) = N_Selected_Component then declare E : constant Entity_Id := Entity (Selector_Name (N)); Set : Boolean; begin -- If component is atomic, but type is not, setting depends on -- disable/enable state for the component. if Is_Atomic (E) and then not Is_Atomic (Etype (E)) then Set := not Atomic_Synchronization_Disabled (E); -- If component is not atomic, but its type is atomic, setting -- depends on disable/enable state for the type. elsif not Is_Atomic (E) and then Is_Atomic (Etype (E)) then Set := not Atomic_Synchronization_Disabled (Etype (E)); -- If both component and type are atomic, we disable if either -- component or its type have sync disabled. elsif Is_Atomic (E) and then Is_Atomic (Etype (E)) then Set := (not Atomic_Synchronization_Disabled (E)) and then (not Atomic_Synchronization_Disabled (Etype (E))); else Set := False; end if; -- Set flag if required if Set then Activate_Atomic_Synchronization (N); end if; end; end if; end Expand_N_Selected_Component; -------------------- -- Expand_N_Slice -- -------------------- procedure Expand_N_Slice (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); function Is_Procedure_Actual (N : Node_Id) return Boolean; -- Check whether the argument is an actual for a procedure call, in -- which case the expansion of a bit-packed slice is deferred until the -- call itself is expanded. The reason this is required is that we might -- have an IN OUT or OUT parameter, and the copy out is essential, and -- that copy out would be missed if we created a temporary here in -- Expand_N_Slice. Note that we don't bother to test specifically for an -- IN OUT or OUT mode parameter, since it is a bit tricky to do, and it -- is harmless to defer expansion in the IN case, since the call -- processing will still generate the appropriate copy in operation, -- which will take care of the slice. procedure Make_Temporary_For_Slice; -- Create a named variable for the value of the slice, in cases where -- the back-end cannot handle it properly, e.g. when packed types or -- unaligned slices are involved. ------------------------- -- Is_Procedure_Actual -- ------------------------- function Is_Procedure_Actual (N : Node_Id) return Boolean is Par : Node_Id := Parent (N); begin loop -- If our parent is a procedure call we can return if Nkind (Par) = N_Procedure_Call_Statement then return True; -- If our parent is a type conversion, keep climbing the tree, -- since a type conversion can be a procedure actual. Also keep -- climbing if parameter association or a qualified expression, -- since these are additional cases that do can appear on -- procedure actuals. elsif Nkind_In (Par, N_Type_Conversion, N_Parameter_Association, N_Qualified_Expression) then Par := Parent (Par); -- Any other case is not what we are looking for else return False; end if; end loop; end Is_Procedure_Actual; ------------------------------ -- Make_Temporary_For_Slice -- ------------------------------ procedure Make_Temporary_For_Slice is Ent : constant Entity_Id := Make_Temporary (Loc, 'T', N); Decl : Node_Id; begin Decl := Make_Object_Declaration (Loc, Defining_Identifier => Ent, Object_Definition => New_Occurrence_Of (Typ, Loc)); Set_No_Initialization (Decl); Insert_Actions (N, New_List ( Decl, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Ent, Loc), Expression => Relocate_Node (N)))); Rewrite (N, New_Occurrence_Of (Ent, Loc)); Analyze_And_Resolve (N, Typ); end Make_Temporary_For_Slice; -- Local variables Pref : constant Node_Id := Prefix (N); Pref_Typ : Entity_Id := Etype (Pref); -- Start of processing for Expand_N_Slice begin -- Special handling for access types if Is_Access_Type (Pref_Typ) then Pref_Typ := Designated_Type (Pref_Typ); Rewrite (Pref, Make_Explicit_Dereference (Sloc (N), Prefix => Relocate_Node (Pref))); Analyze_And_Resolve (Pref, Pref_Typ); end if; -- Ada 2005 (AI-318-02): If the prefix is a call to a build-in-place -- function, then additional actuals must be passed. if Ada_Version >= Ada_2005 and then Is_Build_In_Place_Function_Call (Pref) then Make_Build_In_Place_Call_In_Anonymous_Context (Pref); end if; -- The remaining case to be handled is packed slices. We can leave -- packed slices as they are in the following situations: -- 1. Right or left side of an assignment (we can handle this -- situation correctly in the assignment statement expansion). -- 2. Prefix of indexed component (the slide is optimized away in this -- case, see the start of Expand_N_Slice.) -- 3. Object renaming declaration, since we want the name of the -- slice, not the value. -- 4. Argument to procedure call, since copy-in/copy-out handling may -- be required, and this is handled in the expansion of call -- itself. -- 5. Prefix of an address attribute (this is an error which is caught -- elsewhere, and the expansion would interfere with generating the -- error message). if not Is_Packed (Typ) then -- Apply transformation for actuals of a function call, where -- Expand_Actuals is not used. if Nkind (Parent (N)) = N_Function_Call and then Is_Possibly_Unaligned_Slice (N) then Make_Temporary_For_Slice; end if; elsif Nkind (Parent (N)) = N_Assignment_Statement or else (Nkind (Parent (Parent (N))) = N_Assignment_Statement and then Parent (N) = Name (Parent (Parent (N)))) then return; elsif Nkind (Parent (N)) = N_Indexed_Component or else Is_Renamed_Object (N) or else Is_Procedure_Actual (N) then return; elsif Nkind (Parent (N)) = N_Attribute_Reference and then Attribute_Name (Parent (N)) = Name_Address then return; else Make_Temporary_For_Slice; end if; end Expand_N_Slice; ------------------------------ -- Expand_N_Type_Conversion -- ------------------------------ procedure Expand_N_Type_Conversion (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Operand : constant Node_Id := Expression (N); Target_Type : constant Entity_Id := Etype (N); Operand_Type : Entity_Id := Etype (Operand); procedure Handle_Changed_Representation; -- This is called in the case of record and array type conversions to -- see if there is a change of representation to be handled. Change of -- representation is actually handled at the assignment statement level, -- and what this procedure does is rewrite node N conversion as an -- assignment to temporary. If there is no change of representation, -- then the conversion node is unchanged. procedure Raise_Accessibility_Error; -- Called when we know that an accessibility check will fail. Rewrites -- node N to an appropriate raise statement and outputs warning msgs. -- The Etype of the raise node is set to Target_Type. Note that in this -- case the rest of the processing should be skipped (i.e. the call to -- this procedure will be followed by "goto Done"). procedure Real_Range_Check; -- Handles generation of range check for real target value function Has_Extra_Accessibility (Id : Entity_Id) return Boolean; -- True iff Present (Effective_Extra_Accessibility (Id)) successfully -- evaluates to True. ----------------------------------- -- Handle_Changed_Representation -- ----------------------------------- procedure Handle_Changed_Representation is Temp : Entity_Id; Decl : Node_Id; Odef : Node_Id; Disc : Node_Id; N_Ix : Node_Id; Cons : List_Id; begin -- Nothing else to do if no change of representation if Same_Representation (Operand_Type, Target_Type) then return; -- The real change of representation work is done by the assignment -- statement processing. So if this type conversion is appearing as -- the expression of an assignment statement, nothing needs to be -- done to the conversion. elsif Nkind (Parent (N)) = N_Assignment_Statement then return; -- Otherwise we need to generate a temporary variable, and do the -- change of representation assignment into that temporary variable. -- The conversion is then replaced by a reference to this variable. else Cons := No_List; -- If type is unconstrained we have to add a constraint, copied -- from the actual value of the left-hand side. if not Is_Constrained (Target_Type) then if Has_Discriminants (Operand_Type) then Disc := First_Discriminant (Operand_Type); if Disc /= First_Stored_Discriminant (Operand_Type) then Disc := First_Stored_Discriminant (Operand_Type); end if; Cons := New_List; while Present (Disc) loop Append_To (Cons, Make_Selected_Component (Loc, Prefix => Duplicate_Subexpr_Move_Checks (Operand), Selector_Name => Make_Identifier (Loc, Chars (Disc)))); Next_Discriminant (Disc); end loop; elsif Is_Array_Type (Operand_Type) then N_Ix := First_Index (Target_Type); Cons := New_List; for J in 1 .. Number_Dimensions (Operand_Type) loop -- We convert the bounds explicitly. We use an unchecked -- conversion because bounds checks are done elsewhere. Append_To (Cons, Make_Range (Loc, Low_Bound => Unchecked_Convert_To (Etype (N_Ix), Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr_No_Checks (Operand, Name_Req => True), Attribute_Name => Name_First, Expressions => New_List ( Make_Integer_Literal (Loc, J)))), High_Bound => Unchecked_Convert_To (Etype (N_Ix), Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr_No_Checks (Operand, Name_Req => True), Attribute_Name => Name_Last, Expressions => New_List ( Make_Integer_Literal (Loc, J)))))); Next_Index (N_Ix); end loop; end if; end if; Odef := New_Occurrence_Of (Target_Type, Loc); if Present (Cons) then Odef := Make_Subtype_Indication (Loc, Subtype_Mark => Odef, Constraint => Make_Index_Or_Discriminant_Constraint (Loc, Constraints => Cons)); end if; Temp := Make_Temporary (Loc, 'C'); Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Object_Definition => Odef); Set_No_Initialization (Decl, True); -- Insert required actions. It is essential to suppress checks -- since we have suppressed default initialization, which means -- that the variable we create may have no discriminants. Insert_Actions (N, New_List ( Decl, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Temp, Loc), Expression => Relocate_Node (N))), Suppress => All_Checks); Rewrite (N, New_Occurrence_Of (Temp, Loc)); return; end if; end Handle_Changed_Representation; ------------------------------- -- Raise_Accessibility_Error -- ------------------------------- procedure Raise_Accessibility_Error is begin Error_Msg_Warn := SPARK_Mode /= On; Rewrite (N, Make_Raise_Program_Error (Sloc (N), Reason => PE_Accessibility_Check_Failed)); Set_Etype (N, Target_Type); Error_Msg_N ("<<accessibility check failure", N); Error_Msg_NE ("\<<& [", N, Standard_Program_Error); end Raise_Accessibility_Error; ---------------------- -- Real_Range_Check -- ---------------------- -- Case of conversions to floating-point or fixed-point. If range checks -- are enabled and the target type has a range constraint, we convert: -- typ (x) -- to -- Tnn : typ'Base := typ'Base (x); -- [constraint_error when Tnn < typ'First or else Tnn > typ'Last] -- Tnn -- This is necessary when there is a conversion of integer to float or -- to fixed-point to ensure that the correct checks are made. It is not -- necessary for float to float where it is enough to simply set the -- Do_Range_Check flag. procedure Real_Range_Check is Btyp : constant Entity_Id := Base_Type (Target_Type); Lo : constant Node_Id := Type_Low_Bound (Target_Type); Hi : constant Node_Id := Type_High_Bound (Target_Type); Xtyp : constant Entity_Id := Etype (Operand); Conv : Node_Id; Tnn : Entity_Id; begin -- Nothing to do if conversion was rewritten if Nkind (N) /= N_Type_Conversion then return; end if; -- Nothing to do if range checks suppressed, or target has the same -- range as the base type (or is the base type). if Range_Checks_Suppressed (Target_Type) or else (Lo = Type_Low_Bound (Btyp) and then Hi = Type_High_Bound (Btyp)) then return; end if; -- Nothing to do if expression is an entity on which checks have been -- suppressed. if Is_Entity_Name (Operand) and then Range_Checks_Suppressed (Entity (Operand)) then return; end if; -- Nothing to do if bounds are all static and we can tell that the -- expression is within the bounds of the target. Note that if the -- operand is of an unconstrained floating-point type, then we do -- not trust it to be in range (might be infinite) declare S_Lo : constant Node_Id := Type_Low_Bound (Xtyp); S_Hi : constant Node_Id := Type_High_Bound (Xtyp); begin if (not Is_Floating_Point_Type (Xtyp) or else Is_Constrained (Xtyp)) and then Compile_Time_Known_Value (S_Lo) and then Compile_Time_Known_Value (S_Hi) and then Compile_Time_Known_Value (Hi) and then Compile_Time_Known_Value (Lo) then declare D_Lov : constant Ureal := Expr_Value_R (Lo); D_Hiv : constant Ureal := Expr_Value_R (Hi); S_Lov : Ureal; S_Hiv : Ureal; begin if Is_Real_Type (Xtyp) then S_Lov := Expr_Value_R (S_Lo); S_Hiv := Expr_Value_R (S_Hi); else S_Lov := UR_From_Uint (Expr_Value (S_Lo)); S_Hiv := UR_From_Uint (Expr_Value (S_Hi)); end if; if D_Hiv > D_Lov and then S_Lov >= D_Lov and then S_Hiv <= D_Hiv then -- Unset the range check flag on the current value of -- Expression (N), since the captured Operand may have -- been rewritten (such as for the case of a conversion -- to a fixed-point type). Set_Do_Range_Check (Expression (N), False); return; end if; end; end if; end; -- For float to float conversions, we are done if Is_Floating_Point_Type (Xtyp) and then Is_Floating_Point_Type (Btyp) then return; end if; -- Otherwise rewrite the conversion as described above Conv := Relocate_Node (N); Rewrite (Subtype_Mark (Conv), New_Occurrence_Of (Btyp, Loc)); Set_Etype (Conv, Btyp); -- Enable overflow except for case of integer to float conversions, -- where it is never required, since we can never have overflow in -- this case. if not Is_Integer_Type (Etype (Operand)) then Enable_Overflow_Check (Conv); end if; Tnn := Make_Temporary (Loc, 'T', Conv); Insert_Actions (N, New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Tnn, Object_Definition => New_Occurrence_Of (Btyp, Loc), Constant_Present => True, Expression => Conv), Make_Raise_Constraint_Error (Loc, Condition => Make_Or_Else (Loc, Left_Opnd => Make_Op_Lt (Loc, Left_Opnd => New_Occurrence_Of (Tnn, Loc), Right_Opnd => Make_Attribute_Reference (Loc, Attribute_Name => Name_First, Prefix => New_Occurrence_Of (Target_Type, Loc))), Right_Opnd => Make_Op_Gt (Loc, Left_Opnd => New_Occurrence_Of (Tnn, Loc), Right_Opnd => Make_Attribute_Reference (Loc, Attribute_Name => Name_Last, Prefix => New_Occurrence_Of (Target_Type, Loc)))), Reason => CE_Range_Check_Failed))); Rewrite (N, New_Occurrence_Of (Tnn, Loc)); Analyze_And_Resolve (N, Btyp); end Real_Range_Check; ----------------------------- -- Has_Extra_Accessibility -- ----------------------------- -- Returns true for a formal of an anonymous access type or for -- an Ada 2012-style stand-alone object of an anonymous access type. function Has_Extra_Accessibility (Id : Entity_Id) return Boolean is begin if Is_Formal (Id) or else Ekind_In (Id, E_Constant, E_Variable) then return Present (Effective_Extra_Accessibility (Id)); else return False; end if; end Has_Extra_Accessibility; -- Start of processing for Expand_N_Type_Conversion begin -- First remove check marks put by the semantic analysis on the type -- conversion between array types. We need these checks, and they will -- be generated by this expansion routine, but we do not depend on these -- flags being set, and since we do intend to expand the checks in the -- front end, we don't want them on the tree passed to the back end. if Is_Array_Type (Target_Type) then if Is_Constrained (Target_Type) then Set_Do_Length_Check (N, False); else Set_Do_Range_Check (Operand, False); end if; end if; -- Nothing at all to do if conversion is to the identical type so remove -- the conversion completely, it is useless, except that it may carry -- an Assignment_OK attribute, which must be propagated to the operand. if Operand_Type = Target_Type then if Assignment_OK (N) then Set_Assignment_OK (Operand); end if; Rewrite (N, Relocate_Node (Operand)); goto Done; end if; -- Nothing to do if this is the second argument of read. This is a -- "backwards" conversion that will be handled by the specialized code -- in attribute processing. if Nkind (Parent (N)) = N_Attribute_Reference and then Attribute_Name (Parent (N)) = Name_Read and then Next (First (Expressions (Parent (N)))) = N then goto Done; end if; -- Check for case of converting to a type that has an invariant -- associated with it. This requires an invariant check. We insert -- a call: -- invariant_check (typ (expr)) -- in the code, after removing side effects from the expression. -- This is clearer than replacing the conversion into an expression -- with actions, because the context may impose additional actions -- (tag checks, membership tests, etc.) that conflict with this -- rewriting (used previously). -- Note: the Comes_From_Source check, and then the resetting of this -- flag prevents what would otherwise be an infinite recursion. if Has_Invariants (Target_Type) and then Present (Invariant_Procedure (Target_Type)) and then Comes_From_Source (N) then Set_Comes_From_Source (N, False); Remove_Side_Effects (N); Insert_Action (N, Make_Invariant_Call (Duplicate_Subexpr (N))); goto Done; end if; -- Here if we may need to expand conversion -- If the operand of the type conversion is an arithmetic operation on -- signed integers, and the based type of the signed integer type in -- question is smaller than Standard.Integer, we promote both of the -- operands to type Integer. -- For example, if we have -- target-type (opnd1 + opnd2) -- and opnd1 and opnd2 are of type short integer, then we rewrite -- this as: -- target-type (integer(opnd1) + integer(opnd2)) -- We do this because we are always allowed to compute in a larger type -- if we do the right thing with the result, and in this case we are -- going to do a conversion which will do an appropriate check to make -- sure that things are in range of the target type in any case. This -- avoids some unnecessary intermediate overflows. -- We might consider a similar transformation in the case where the -- target is a real type or a 64-bit integer type, and the operand -- is an arithmetic operation using a 32-bit integer type. However, -- we do not bother with this case, because it could cause significant -- inefficiencies on 32-bit machines. On a 64-bit machine it would be -- much cheaper, but we don't want different behavior on 32-bit and -- 64-bit machines. Note that the exclusion of the 64-bit case also -- handles the configurable run-time cases where 64-bit arithmetic -- may simply be unavailable. -- Note: this circuit is partially redundant with respect to the circuit -- in Checks.Apply_Arithmetic_Overflow_Check, but we catch more cases in -- the processing here. Also we still need the Checks circuit, since we -- have to be sure not to generate junk overflow checks in the first -- place, since it would be trick to remove them here. if Integer_Promotion_Possible (N) then -- All conditions met, go ahead with transformation declare Opnd : Node_Id; L, R : Node_Id; begin R := Make_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (Standard_Integer, Loc), Expression => Relocate_Node (Right_Opnd (Operand))); Opnd := New_Op_Node (Nkind (Operand), Loc); Set_Right_Opnd (Opnd, R); if Nkind (Operand) in N_Binary_Op then L := Make_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (Standard_Integer, Loc), Expression => Relocate_Node (Left_Opnd (Operand))); Set_Left_Opnd (Opnd, L); end if; Rewrite (N, Make_Type_Conversion (Loc, Subtype_Mark => Relocate_Node (Subtype_Mark (N)), Expression => Opnd)); Analyze_And_Resolve (N, Target_Type); goto Done; end; end if; -- Do validity check if validity checking operands if Validity_Checks_On and Validity_Check_Operands then Ensure_Valid (Operand); end if; -- Special case of converting from non-standard boolean type if Is_Boolean_Type (Operand_Type) and then (Nonzero_Is_True (Operand_Type)) then Adjust_Condition (Operand); Set_Etype (Operand, Standard_Boolean); Operand_Type := Standard_Boolean; end if; -- Case of converting to an access type if Is_Access_Type (Target_Type) then -- Apply an accessibility check when the conversion operand is an -- access parameter (or a renaming thereof), unless conversion was -- expanded from an Unchecked_ or Unrestricted_Access attribute. -- Note that other checks may still need to be applied below (such -- as tagged type checks). if Is_Entity_Name (Operand) and then Has_Extra_Accessibility (Entity (Operand)) and then Ekind (Etype (Operand)) = E_Anonymous_Access_Type and then (Nkind (Original_Node (N)) /= N_Attribute_Reference or else Attribute_Name (Original_Node (N)) = Name_Access) then Apply_Accessibility_Check (Operand, Target_Type, Insert_Node => Operand); -- If the level of the operand type is statically deeper than the -- level of the target type, then force Program_Error. Note that this -- can only occur for cases where the attribute is within the body of -- an instantiation, otherwise the conversion will already have been -- rejected as illegal. -- Note: warnings are issued by the analyzer for the instance cases elsif In_Instance_Body -- The case where the target type is an anonymous access type of -- a discriminant is excluded, because the level of such a type -- depends on the context and currently the level returned for such -- types is zero, resulting in warnings about about check failures -- in certain legal cases involving class-wide interfaces as the -- designated type (some cases, such as return statements, are -- checked at run time, but not clear if these are handled right -- in general, see 3.10.2(12/2-12.5/3) ???). and then not (Ekind (Target_Type) = E_Anonymous_Access_Type and then Present (Associated_Node_For_Itype (Target_Type)) and then Nkind (Associated_Node_For_Itype (Target_Type)) = N_Discriminant_Specification) and then Type_Access_Level (Operand_Type) > Type_Access_Level (Target_Type) then Raise_Accessibility_Error; goto Done; -- When the operand is a selected access discriminant the check needs -- to be made against the level of the object denoted by the prefix -- of the selected name. Force Program_Error for this case as well -- (this accessibility violation can only happen if within the body -- of an instantiation). elsif In_Instance_Body and then Ekind (Operand_Type) = E_Anonymous_Access_Type and then Nkind (Operand) = N_Selected_Component and then Object_Access_Level (Operand) > Type_Access_Level (Target_Type) then Raise_Accessibility_Error; goto Done; end if; end if; -- Case of conversions of tagged types and access to tagged types -- When needed, that is to say when the expression is class-wide, Add -- runtime a tag check for (strict) downward conversion by using the -- membership test, generating: -- [constraint_error when Operand not in Target_Type'Class] -- or in the access type case -- [constraint_error -- when Operand /= null -- and then Operand.all not in -- Designated_Type (Target_Type)'Class] if (Is_Access_Type (Target_Type) and then Is_Tagged_Type (Designated_Type (Target_Type))) or else Is_Tagged_Type (Target_Type) then -- Do not do any expansion in the access type case if the parent is a -- renaming, since this is an error situation which will be caught by -- Sem_Ch8, and the expansion can interfere with this error check. if Is_Access_Type (Target_Type) and then Is_Renamed_Object (N) then goto Done; end if; -- Otherwise, proceed with processing tagged conversion Tagged_Conversion : declare Actual_Op_Typ : Entity_Id; Actual_Targ_Typ : Entity_Id; Make_Conversion : Boolean := False; Root_Op_Typ : Entity_Id; procedure Make_Tag_Check (Targ_Typ : Entity_Id); -- Create a membership check to test whether Operand is a member -- of Targ_Typ. If the original Target_Type is an access, include -- a test for null value. The check is inserted at N. -------------------- -- Make_Tag_Check -- -------------------- procedure Make_Tag_Check (Targ_Typ : Entity_Id) is Cond : Node_Id; begin -- Generate: -- [Constraint_Error -- when Operand /= null -- and then Operand.all not in Targ_Typ] if Is_Access_Type (Target_Type) then Cond := Make_And_Then (Loc, Left_Opnd => Make_Op_Ne (Loc, Left_Opnd => Duplicate_Subexpr_No_Checks (Operand), Right_Opnd => Make_Null (Loc)), Right_Opnd => Make_Not_In (Loc, Left_Opnd => Make_Explicit_Dereference (Loc, Prefix => Duplicate_Subexpr_No_Checks (Operand)), Right_Opnd => New_Occurrence_Of (Targ_Typ, Loc))); -- Generate: -- [Constraint_Error when Operand not in Targ_Typ] else Cond := Make_Not_In (Loc, Left_Opnd => Duplicate_Subexpr_No_Checks (Operand), Right_Opnd => New_Occurrence_Of (Targ_Typ, Loc)); end if; Insert_Action (N, Make_Raise_Constraint_Error (Loc, Condition => Cond, Reason => CE_Tag_Check_Failed)); end Make_Tag_Check; -- Start of processing for Tagged_Conversion begin -- Handle entities from the limited view if Is_Access_Type (Operand_Type) then Actual_Op_Typ := Available_View (Designated_Type (Operand_Type)); else Actual_Op_Typ := Operand_Type; end if; if Is_Access_Type (Target_Type) then Actual_Targ_Typ := Available_View (Designated_Type (Target_Type)); else Actual_Targ_Typ := Target_Type; end if; Root_Op_Typ := Root_Type (Actual_Op_Typ); -- Ada 2005 (AI-251): Handle interface type conversion if Is_Interface (Actual_Op_Typ) or else Is_Interface (Actual_Targ_Typ) then Expand_Interface_Conversion (N); goto Done; end if; if not Tag_Checks_Suppressed (Actual_Targ_Typ) then -- Create a runtime tag check for a downward class-wide type -- conversion. if Is_Class_Wide_Type (Actual_Op_Typ) and then Actual_Op_Typ /= Actual_Targ_Typ and then Root_Op_Typ /= Actual_Targ_Typ and then Is_Ancestor (Root_Op_Typ, Actual_Targ_Typ, Use_Full_View => True) then Make_Tag_Check (Class_Wide_Type (Actual_Targ_Typ)); Make_Conversion := True; end if; -- AI05-0073: If the result subtype of the function is defined -- by an access_definition designating a specific tagged type -- T, a check is made that the result value is null or the tag -- of the object designated by the result value identifies T. -- Constraint_Error is raised if this check fails. if Nkind (Parent (N)) = N_Simple_Return_Statement then declare Func : Entity_Id; Func_Typ : Entity_Id; begin -- Climb scope stack looking for the enclosing function Func := Current_Scope; while Present (Func) and then Ekind (Func) /= E_Function loop Func := Scope (Func); end loop; -- The function's return subtype must be defined using -- an access definition. if Nkind (Result_Definition (Parent (Func))) = N_Access_Definition then Func_Typ := Directly_Designated_Type (Etype (Func)); -- The return subtype denotes a specific tagged type, -- in other words, a non class-wide type. if Is_Tagged_Type (Func_Typ) and then not Is_Class_Wide_Type (Func_Typ) then Make_Tag_Check (Actual_Targ_Typ); Make_Conversion := True; end if; end if; end; end if; -- We have generated a tag check for either a class-wide type -- conversion or for AI05-0073. if Make_Conversion then declare Conv : Node_Id; begin Conv := Make_Unchecked_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (Target_Type, Loc), Expression => Relocate_Node (Expression (N))); Rewrite (N, Conv); Analyze_And_Resolve (N, Target_Type); end; end if; end if; end Tagged_Conversion; -- Case of other access type conversions elsif Is_Access_Type (Target_Type) then Apply_Constraint_Check (Operand, Target_Type); -- Case of conversions from a fixed-point type -- These conversions require special expansion and processing, found in -- the Exp_Fixd package. We ignore cases where Conversion_OK is set, -- since from a semantic point of view, these are simple integer -- conversions, which do not need further processing. elsif Is_Fixed_Point_Type (Operand_Type) and then not Conversion_OK (N) then -- We should never see universal fixed at this case, since the -- expansion of the constituent divide or multiply should have -- eliminated the explicit mention of universal fixed. pragma Assert (Operand_Type /= Universal_Fixed); -- Check for special case of the conversion to universal real that -- occurs as a result of the use of a round attribute. In this case, -- the real type for the conversion is taken from the target type of -- the Round attribute and the result must be marked as rounded. if Target_Type = Universal_Real and then Nkind (Parent (N)) = N_Attribute_Reference and then Attribute_Name (Parent (N)) = Name_Round then Set_Rounded_Result (N); Set_Etype (N, Etype (Parent (N))); end if; -- Otherwise do correct fixed-conversion, but skip these if the -- Conversion_OK flag is set, because from a semantic point of view -- these are simple integer conversions needing no further processing -- (the backend will simply treat them as integers). if not Conversion_OK (N) then if Is_Fixed_Point_Type (Etype (N)) then Expand_Convert_Fixed_To_Fixed (N); Real_Range_Check; elsif Is_Integer_Type (Etype (N)) then Expand_Convert_Fixed_To_Integer (N); else pragma Assert (Is_Floating_Point_Type (Etype (N))); Expand_Convert_Fixed_To_Float (N); Real_Range_Check; end if; end if; -- Case of conversions to a fixed-point type -- These conversions require special expansion and processing, found in -- the Exp_Fixd package. Again, ignore cases where Conversion_OK is set, -- since from a semantic point of view, these are simple integer -- conversions, which do not need further processing. elsif Is_Fixed_Point_Type (Target_Type) and then not Conversion_OK (N) then if Is_Integer_Type (Operand_Type) then Expand_Convert_Integer_To_Fixed (N); Real_Range_Check; else pragma Assert (Is_Floating_Point_Type (Operand_Type)); Expand_Convert_Float_To_Fixed (N); Real_Range_Check; end if; -- Case of float-to-integer conversions -- We also handle float-to-fixed conversions with Conversion_OK set -- since semantically the fixed-point target is treated as though it -- were an integer in such cases. elsif Is_Floating_Point_Type (Operand_Type) and then (Is_Integer_Type (Target_Type) or else (Is_Fixed_Point_Type (Target_Type) and then Conversion_OK (N))) then -- One more check here, gcc is still not able to do conversions of -- this type with proper overflow checking, and so gigi is doing an -- approximation of what is required by doing floating-point compares -- with the end-point. But that can lose precision in some cases, and -- give a wrong result. Converting the operand to Universal_Real is -- helpful, but still does not catch all cases with 64-bit integers -- on targets with only 64-bit floats. -- The above comment seems obsoleted by Apply_Float_Conversion_Check -- Can this code be removed ??? if Do_Range_Check (Operand) then Rewrite (Operand, Make_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (Universal_Real, Loc), Expression => Relocate_Node (Operand))); Set_Etype (Operand, Universal_Real); Enable_Range_Check (Operand); Set_Do_Range_Check (Expression (Operand), False); end if; -- Case of array conversions -- Expansion of array conversions, add required length/range checks but -- only do this if there is no change of representation. For handling of -- this case, see Handle_Changed_Representation. elsif Is_Array_Type (Target_Type) then if Is_Constrained (Target_Type) then Apply_Length_Check (Operand, Target_Type); else Apply_Range_Check (Operand, Target_Type); end if; Handle_Changed_Representation; -- Case of conversions of discriminated types -- Add required discriminant checks if target is constrained. Again this -- change is skipped if we have a change of representation. elsif Has_Discriminants (Target_Type) and then Is_Constrained (Target_Type) then Apply_Discriminant_Check (Operand, Target_Type); Handle_Changed_Representation; -- Case of all other record conversions. The only processing required -- is to check for a change of representation requiring the special -- assignment processing. elsif Is_Record_Type (Target_Type) then -- Ada 2005 (AI-216): Program_Error is raised when converting from -- a derived Unchecked_Union type to an unconstrained type that is -- not Unchecked_Union if the operand lacks inferable discriminants. if Is_Derived_Type (Operand_Type) and then Is_Unchecked_Union (Base_Type (Operand_Type)) and then not Is_Constrained (Target_Type) and then not Is_Unchecked_Union (Base_Type (Target_Type)) and then not Has_Inferable_Discriminants (Operand) then -- To prevent Gigi from generating illegal code, we generate a -- Program_Error node, but we give it the target type of the -- conversion (is this requirement documented somewhere ???) declare PE : constant Node_Id := Make_Raise_Program_Error (Loc, Reason => PE_Unchecked_Union_Restriction); begin Set_Etype (PE, Target_Type); Rewrite (N, PE); end; else Handle_Changed_Representation; end if; -- Case of conversions of enumeration types elsif Is_Enumeration_Type (Target_Type) then -- Special processing is required if there is a change of -- representation (from enumeration representation clauses). if not Same_Representation (Target_Type, Operand_Type) then -- Convert: x(y) to x'val (ytyp'val (y)) Rewrite (N, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Target_Type, Loc), Attribute_Name => Name_Val, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Operand_Type, Loc), Attribute_Name => Name_Pos, Expressions => New_List (Operand))))); Analyze_And_Resolve (N, Target_Type); end if; -- Case of conversions to floating-point elsif Is_Floating_Point_Type (Target_Type) then Real_Range_Check; end if; -- At this stage, either the conversion node has been transformed into -- some other equivalent expression, or left as a conversion that can be -- handled by Gigi, in the following cases: -- Conversions with no change of representation or type -- Numeric conversions involving integer, floating- and fixed-point -- values. Fixed-point values are allowed only if Conversion_OK is -- set, i.e. if the fixed-point values are to be treated as integers. -- No other conversions should be passed to Gigi -- Check: are these rules stated in sinfo??? if so, why restate here??? -- The only remaining step is to generate a range check if we still have -- a type conversion at this stage and Do_Range_Check is set. For now we -- do this only for conversions of discrete types and for float-to-float -- conversions. if Nkind (N) = N_Type_Conversion then -- For now we only support floating-point cases where both source -- and target are floating-point types. Conversions where the source -- and target involve integer or fixed-point types are still TBD, -- though not clear whether those can even happen at this point, due -- to transformations above. ??? if Is_Floating_Point_Type (Etype (N)) and then Is_Floating_Point_Type (Etype (Expression (N))) then if Do_Range_Check (Expression (N)) and then Is_Floating_Point_Type (Target_Type) then Generate_Range_Check (Expression (N), Target_Type, CE_Range_Check_Failed); end if; -- Discrete-to-discrete conversions elsif Is_Discrete_Type (Etype (N)) then declare Expr : constant Node_Id := Expression (N); Ftyp : Entity_Id; Ityp : Entity_Id; begin if Do_Range_Check (Expr) and then Is_Discrete_Type (Etype (Expr)) then Set_Do_Range_Check (Expr, False); -- Before we do a range check, we have to deal with treating -- a fixed-point operand as an integer. The way we do this -- is simply to do an unchecked conversion to an appropriate -- integer type large enough to hold the result. -- This code is not active yet, because we are only dealing -- with discrete types so far ??? if Nkind (Expr) in N_Has_Treat_Fixed_As_Integer and then Treat_Fixed_As_Integer (Expr) then Ftyp := Base_Type (Etype (Expr)); if Esize (Ftyp) >= Esize (Standard_Integer) then Ityp := Standard_Long_Long_Integer; else Ityp := Standard_Integer; end if; Rewrite (Expr, Unchecked_Convert_To (Ityp, Expr)); end if; -- Reset overflow flag, since the range check will include -- dealing with possible overflow, and generate the check. -- If Address is either a source type or target type, -- suppress range check to avoid typing anomalies when -- it is a visible integer type. Set_Do_Overflow_Check (N, False); if not Is_Descendant_Of_Address (Etype (Expr)) and then not Is_Descendant_Of_Address (Target_Type) then Generate_Range_Check (Expr, Target_Type, CE_Range_Check_Failed); end if; end if; end; end if; end if; -- Here at end of processing <<Done>> -- Apply predicate check if required. Note that we can't just call -- Apply_Predicate_Check here, because the type looks right after -- the conversion and it would omit the check. The Comes_From_Source -- guard is necessary to prevent infinite recursions when we generate -- internal conversions for the purpose of checking predicates. if Present (Predicate_Function (Target_Type)) and then not Predicates_Ignored (Target_Type) and then Target_Type /= Operand_Type and then Comes_From_Source (N) then declare New_Expr : constant Node_Id := Duplicate_Subexpr (N); begin -- Avoid infinite recursion on the subsequent expansion of -- of the copy of the original type conversion. Set_Comes_From_Source (New_Expr, False); Insert_Action (N, Make_Predicate_Check (Target_Type, New_Expr)); end; end if; end Expand_N_Type_Conversion; ----------------------------------- -- Expand_N_Unchecked_Expression -- ----------------------------------- -- Remove the unchecked expression node from the tree. Its job was simply -- to make sure that its constituent expression was handled with checks -- off, and now that that is done, we can remove it from the tree, and -- indeed must, since Gigi does not expect to see these nodes. procedure Expand_N_Unchecked_Expression (N : Node_Id) is Exp : constant Node_Id := Expression (N); begin Set_Assignment_OK (Exp, Assignment_OK (N) or else Assignment_OK (Exp)); Rewrite (N, Exp); end Expand_N_Unchecked_Expression; ---------------------------------------- -- Expand_N_Unchecked_Type_Conversion -- ---------------------------------------- -- If this cannot be handled by Gigi and we haven't already made a -- temporary for it, do it now. procedure Expand_N_Unchecked_Type_Conversion (N : Node_Id) is Target_Type : constant Entity_Id := Etype (N); Operand : constant Node_Id := Expression (N); Operand_Type : constant Entity_Id := Etype (Operand); begin -- Nothing at all to do if conversion is to the identical type so remove -- the conversion completely, it is useless, except that it may carry -- an Assignment_OK indication which must be propagated to the operand. if Operand_Type = Target_Type then -- Code duplicates Expand_N_Unchecked_Expression above, factor??? if Assignment_OK (N) then Set_Assignment_OK (Operand); end if; Rewrite (N, Relocate_Node (Operand)); return; end if; -- If we have a conversion of a compile time known value to a target -- type and the value is in range of the target type, then we can simply -- replace the construct by an integer literal of the correct type. We -- only apply this to integer types being converted. Possibly it may -- apply in other cases, but it is too much trouble to worry about. -- Note that we do not do this transformation if the Kill_Range_Check -- flag is set, since then the value may be outside the expected range. -- This happens in the Normalize_Scalars case. -- We also skip this if either the target or operand type is biased -- because in this case, the unchecked conversion is supposed to -- preserve the bit pattern, not the integer value. if Is_Integer_Type (Target_Type) and then not Has_Biased_Representation (Target_Type) and then Is_Integer_Type (Operand_Type) and then not Has_Biased_Representation (Operand_Type) and then Compile_Time_Known_Value (Operand) and then not Kill_Range_Check (N) then declare Val : constant Uint := Expr_Value (Operand); begin if Compile_Time_Known_Value (Type_Low_Bound (Target_Type)) and then Compile_Time_Known_Value (Type_High_Bound (Target_Type)) and then Val >= Expr_Value (Type_Low_Bound (Target_Type)) and then Val <= Expr_Value (Type_High_Bound (Target_Type)) then Rewrite (N, Make_Integer_Literal (Sloc (N), Val)); -- If Address is the target type, just set the type to avoid a -- spurious type error on the literal when Address is a visible -- integer type. if Is_Descendant_Of_Address (Target_Type) then Set_Etype (N, Target_Type); else Analyze_And_Resolve (N, Target_Type); end if; return; end if; end; end if; -- Nothing to do if conversion is safe if Safe_Unchecked_Type_Conversion (N) then return; end if; -- Otherwise force evaluation unless Assignment_OK flag is set (this -- flag indicates ??? More comments needed here) if Assignment_OK (N) then null; else Force_Evaluation (N); end if; end Expand_N_Unchecked_Type_Conversion; ---------------------------- -- Expand_Record_Equality -- ---------------------------- -- For non-variant records, Equality is expanded when needed into: -- and then Lhs.Discr1 = Rhs.Discr1 -- and then ... -- and then Lhs.Discrn = Rhs.Discrn -- and then Lhs.Cmp1 = Rhs.Cmp1 -- and then ... -- and then Lhs.Cmpn = Rhs.Cmpn -- The expression is folded by the back-end for adjacent fields. This -- function is called for tagged record in only one occasion: for imple- -- menting predefined primitive equality (see Predefined_Primitives_Bodies) -- otherwise the primitive "=" is used directly. function Expand_Record_Equality (Nod : Node_Id; Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Nod); Result : Node_Id; C : Entity_Id; First_Time : Boolean := True; function Element_To_Compare (C : Entity_Id) return Entity_Id; -- Return the next discriminant or component to compare, starting with -- C, skipping inherited components. ------------------------ -- Element_To_Compare -- ------------------------ function Element_To_Compare (C : Entity_Id) return Entity_Id is Comp : Entity_Id; begin Comp := C; loop -- Exit loop when the next element to be compared is found, or -- there is no more such element. exit when No (Comp); exit when Ekind_In (Comp, E_Discriminant, E_Component) and then not ( -- Skip inherited components -- Note: for a tagged type, we always generate the "=" primitive -- for the base type (not on the first subtype), so the test for -- Comp /= Original_Record_Component (Comp) is True for -- inherited components only. (Is_Tagged_Type (Typ) and then Comp /= Original_Record_Component (Comp)) -- Skip _Tag or else Chars (Comp) = Name_uTag -- Skip interface elements (secondary tags???) or else Is_Interface (Etype (Comp))); Next_Entity (Comp); end loop; return Comp; end Element_To_Compare; -- Start of processing for Expand_Record_Equality begin -- Generates the following code: (assuming that Typ has one Discr and -- component C2 is also a record) -- True -- and then Lhs.Discr1 = Rhs.Discr1 -- and then Lhs.C1 = Rhs.C1 -- and then Lhs.C2.C1=Rhs.C2.C1 and then ... Lhs.C2.Cn=Rhs.C2.Cn -- and then ... -- and then Lhs.Cmpn = Rhs.Cmpn Result := New_Occurrence_Of (Standard_True, Loc); C := Element_To_Compare (First_Entity (Typ)); while Present (C) loop declare New_Lhs : Node_Id; New_Rhs : Node_Id; Check : Node_Id; begin if First_Time then First_Time := False; New_Lhs := Lhs; New_Rhs := Rhs; else New_Lhs := New_Copy_Tree (Lhs); New_Rhs := New_Copy_Tree (Rhs); end if; Check := Expand_Composite_Equality (Nod, Etype (C), Lhs => Make_Selected_Component (Loc, Prefix => New_Lhs, Selector_Name => New_Occurrence_Of (C, Loc)), Rhs => Make_Selected_Component (Loc, Prefix => New_Rhs, Selector_Name => New_Occurrence_Of (C, Loc)), Bodies => Bodies); -- If some (sub)component is an unchecked_union, the whole -- operation will raise program error. if Nkind (Check) = N_Raise_Program_Error then Result := Check; Set_Etype (Result, Standard_Boolean); exit; else Result := Make_And_Then (Loc, Left_Opnd => Result, Right_Opnd => Check); end if; end; C := Element_To_Compare (Next_Entity (C)); end loop; return Result; end Expand_Record_Equality; --------------------------- -- Expand_Set_Membership -- --------------------------- procedure Expand_Set_Membership (N : Node_Id) is Lop : constant Node_Id := Left_Opnd (N); Alt : Node_Id; Res : Node_Id; function Make_Cond (Alt : Node_Id) return Node_Id; -- If the alternative is a subtype mark, create a simple membership -- test. Otherwise create an equality test for it. --------------- -- Make_Cond -- --------------- function Make_Cond (Alt : Node_Id) return Node_Id is Cond : Node_Id; L : constant Node_Id := New_Copy (Lop); R : constant Node_Id := Relocate_Node (Alt); begin if (Is_Entity_Name (Alt) and then Is_Type (Entity (Alt))) or else Nkind (Alt) = N_Range then Cond := Make_In (Sloc (Alt), Left_Opnd => L, Right_Opnd => R); else Cond := Make_Op_Eq (Sloc (Alt), Left_Opnd => L, Right_Opnd => R); end if; return Cond; end Make_Cond; -- Start of processing for Expand_Set_Membership begin Remove_Side_Effects (Lop); Alt := Last (Alternatives (N)); Res := Make_Cond (Alt); Prev (Alt); while Present (Alt) loop Res := Make_Or_Else (Sloc (Alt), Left_Opnd => Make_Cond (Alt), Right_Opnd => Res); Prev (Alt); end loop; Rewrite (N, Res); Analyze_And_Resolve (N, Standard_Boolean); end Expand_Set_Membership; ----------------------------------- -- Expand_Short_Circuit_Operator -- ----------------------------------- -- Deal with special expansion if actions are present for the right operand -- and deal with optimizing case of arguments being True or False. We also -- deal with the special case of non-standard boolean values. procedure Expand_Short_Circuit_Operator (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Left : constant Node_Id := Left_Opnd (N); Right : constant Node_Id := Right_Opnd (N); LocR : constant Source_Ptr := Sloc (Right); Actlist : List_Id; Shortcut_Value : constant Boolean := Nkind (N) = N_Or_Else; Shortcut_Ent : constant Entity_Id := Boolean_Literals (Shortcut_Value); -- If Left = Shortcut_Value then Right need not be evaluated function Make_Test_Expr (Opnd : Node_Id) return Node_Id; -- For Opnd a boolean expression, return a Boolean expression equivalent -- to Opnd /= Shortcut_Value. -------------------- -- Make_Test_Expr -- -------------------- function Make_Test_Expr (Opnd : Node_Id) return Node_Id is begin if Shortcut_Value then return Make_Op_Not (Sloc (Opnd), Opnd); else return Opnd; end if; end Make_Test_Expr; -- Local variables Op_Var : Entity_Id; -- Entity for a temporary variable holding the value of the operator, -- used for expansion in the case where actions are present. -- Start of processing for Expand_Short_Circuit_Operator begin -- Deal with non-standard booleans if Is_Boolean_Type (Typ) then Adjust_Condition (Left); Adjust_Condition (Right); Set_Etype (N, Standard_Boolean); end if; -- Check for cases where left argument is known to be True or False if Compile_Time_Known_Value (Left) then -- Mark SCO for left condition as compile time known if Generate_SCO and then Comes_From_Source (Left) then Set_SCO_Condition (Left, Expr_Value_E (Left) = Standard_True); end if; -- Rewrite True AND THEN Right / False OR ELSE Right to Right. -- Any actions associated with Right will be executed unconditionally -- and can thus be inserted into the tree unconditionally. if Expr_Value_E (Left) /= Shortcut_Ent then if Present (Actions (N)) then Insert_Actions (N, Actions (N)); end if; Rewrite (N, Right); -- Rewrite False AND THEN Right / True OR ELSE Right to Left. -- In this case we can forget the actions associated with Right, -- since they will never be executed. else Kill_Dead_Code (Right); Kill_Dead_Code (Actions (N)); Rewrite (N, New_Occurrence_Of (Shortcut_Ent, Loc)); end if; Adjust_Result_Type (N, Typ); return; end if; -- If Actions are present for the right operand, we have to do some -- special processing. We can't just let these actions filter back into -- code preceding the short circuit (which is what would have happened -- if we had not trapped them in the short-circuit form), since they -- must only be executed if the right operand of the short circuit is -- executed and not otherwise. if Present (Actions (N)) then Actlist := Actions (N); -- The old approach is to expand: -- left AND THEN right -- into -- C : Boolean := False; -- IF left THEN -- Actions; -- IF right THEN -- C := True; -- END IF; -- END IF; -- and finally rewrite the operator into a reference to C. Similarly -- for left OR ELSE right, with negated values. Note that this -- rewrite causes some difficulties for coverage analysis because -- of the introduction of the new variable C, which obscures the -- structure of the test. -- We use this "old approach" if Minimize_Expression_With_Actions -- is True. if Minimize_Expression_With_Actions then Op_Var := Make_Temporary (Loc, 'C', Related_Node => N); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Op_Var, Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc), Expression => New_Occurrence_Of (Shortcut_Ent, Loc))); Append_To (Actlist, Make_Implicit_If_Statement (Right, Condition => Make_Test_Expr (Right), Then_Statements => New_List ( Make_Assignment_Statement (LocR, Name => New_Occurrence_Of (Op_Var, LocR), Expression => New_Occurrence_Of (Boolean_Literals (not Shortcut_Value), LocR))))); Insert_Action (N, Make_Implicit_If_Statement (Left, Condition => Make_Test_Expr (Left), Then_Statements => Actlist)); Rewrite (N, New_Occurrence_Of (Op_Var, Loc)); Analyze_And_Resolve (N, Standard_Boolean); -- The new approach (the default) is to use an -- Expression_With_Actions node for the right operand of the -- short-circuit form. Note that this solves the traceability -- problems for coverage analysis. else Rewrite (Right, Make_Expression_With_Actions (LocR, Expression => Relocate_Node (Right), Actions => Actlist)); Set_Actions (N, No_List); Analyze_And_Resolve (Right, Standard_Boolean); end if; Adjust_Result_Type (N, Typ); return; end if; -- No actions present, check for cases of right argument True/False if Compile_Time_Known_Value (Right) then -- Mark SCO for left condition as compile time known if Generate_SCO and then Comes_From_Source (Right) then Set_SCO_Condition (Right, Expr_Value_E (Right) = Standard_True); end if; -- Change (Left and then True), (Left or else False) to Left. Note -- that we know there are no actions associated with the right -- operand, since we just checked for this case above. if Expr_Value_E (Right) /= Shortcut_Ent then Rewrite (N, Left); -- Change (Left and then False), (Left or else True) to Right, -- making sure to preserve any side effects associated with the Left -- operand. else Remove_Side_Effects (Left); Rewrite (N, New_Occurrence_Of (Shortcut_Ent, Loc)); end if; end if; Adjust_Result_Type (N, Typ); end Expand_Short_Circuit_Operator; ------------------------------------- -- Fixup_Universal_Fixed_Operation -- ------------------------------------- procedure Fixup_Universal_Fixed_Operation (N : Node_Id) is Conv : constant Node_Id := Parent (N); begin -- We must have a type conversion immediately above us pragma Assert (Nkind (Conv) = N_Type_Conversion); -- Normally the type conversion gives our target type. The exception -- occurs in the case of the Round attribute, where the conversion -- will be to universal real, and our real type comes from the Round -- attribute (as well as an indication that we must round the result) if Nkind (Parent (Conv)) = N_Attribute_Reference and then Attribute_Name (Parent (Conv)) = Name_Round then Set_Etype (N, Etype (Parent (Conv))); Set_Rounded_Result (N); -- Normal case where type comes from conversion above us else Set_Etype (N, Etype (Conv)); end if; end Fixup_Universal_Fixed_Operation; --------------------------------- -- Has_Inferable_Discriminants -- --------------------------------- function Has_Inferable_Discriminants (N : Node_Id) return Boolean is function Prefix_Is_Formal_Parameter (N : Node_Id) return Boolean; -- Determines whether the left-most prefix of a selected component is a -- formal parameter in a subprogram. Assumes N is a selected component. -------------------------------- -- Prefix_Is_Formal_Parameter -- -------------------------------- function Prefix_Is_Formal_Parameter (N : Node_Id) return Boolean is Sel_Comp : Node_Id; begin -- Move to the left-most prefix by climbing up the tree Sel_Comp := N; while Present (Parent (Sel_Comp)) and then Nkind (Parent (Sel_Comp)) = N_Selected_Component loop Sel_Comp := Parent (Sel_Comp); end loop; return Ekind (Entity (Prefix (Sel_Comp))) in Formal_Kind; end Prefix_Is_Formal_Parameter; -- Start of processing for Has_Inferable_Discriminants begin -- For selected components, the subtype of the selector must be a -- constrained Unchecked_Union. If the component is subject to a -- per-object constraint, then the enclosing object must have inferable -- discriminants. if Nkind (N) = N_Selected_Component then if Has_Per_Object_Constraint (Entity (Selector_Name (N))) then -- A small hack. If we have a per-object constrained selected -- component of a formal parameter, return True since we do not -- know the actual parameter association yet. if Prefix_Is_Formal_Parameter (N) then return True; -- Otherwise, check the enclosing object and the selector else return Has_Inferable_Discriminants (Prefix (N)) and then Has_Inferable_Discriminants (Selector_Name (N)); end if; -- The call to Has_Inferable_Discriminants will determine whether -- the selector has a constrained Unchecked_Union nominal type. else return Has_Inferable_Discriminants (Selector_Name (N)); end if; -- A qualified expression has inferable discriminants if its subtype -- mark is a constrained Unchecked_Union subtype. elsif Nkind (N) = N_Qualified_Expression then return Is_Unchecked_Union (Etype (Subtype_Mark (N))) and then Is_Constrained (Etype (Subtype_Mark (N))); -- For all other names, it is sufficient to have a constrained -- Unchecked_Union nominal subtype. else return Is_Unchecked_Union (Base_Type (Etype (N))) and then Is_Constrained (Etype (N)); end if; end Has_Inferable_Discriminants; ------------------------------- -- Insert_Dereference_Action -- ------------------------------- procedure Insert_Dereference_Action (N : Node_Id) is function Is_Checked_Storage_Pool (P : Entity_Id) return Boolean; -- Return true if type of P is derived from Checked_Pool; ----------------------------- -- Is_Checked_Storage_Pool -- ----------------------------- function Is_Checked_Storage_Pool (P : Entity_Id) return Boolean is T : Entity_Id; begin if No (P) then return False; end if; T := Etype (P); while T /= Etype (T) loop if Is_RTE (T, RE_Checked_Pool) then return True; else T := Etype (T); end if; end loop; return False; end Is_Checked_Storage_Pool; -- Local variables Typ : constant Entity_Id := Etype (N); Desig : constant Entity_Id := Available_View (Designated_Type (Typ)); Loc : constant Source_Ptr := Sloc (N); Pool : constant Entity_Id := Associated_Storage_Pool (Typ); Pnod : constant Node_Id := Parent (N); Addr : Entity_Id; Alig : Entity_Id; Deref : Node_Id; Size : Entity_Id; Size_Bits : Node_Id; Stmt : Node_Id; -- Start of processing for Insert_Dereference_Action begin pragma Assert (Nkind (Pnod) = N_Explicit_Dereference); -- Do not re-expand a dereference which has already been processed by -- this routine. if Has_Dereference_Action (Pnod) then return; -- Do not perform this type of expansion for internally-generated -- dereferences. elsif not Comes_From_Source (Original_Node (Pnod)) then return; -- A dereference action is only applicable to objects which have been -- allocated on a checked pool. elsif not Is_Checked_Storage_Pool (Pool) then return; end if; -- Extract the address of the dereferenced object. Generate: -- Addr : System.Address := <N>'Pool_Address; Addr := Make_Temporary (Loc, 'P'); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Addr, Object_Definition => New_Occurrence_Of (RTE (RE_Address), Loc), Expression => Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr_Move_Checks (N), Attribute_Name => Name_Pool_Address))); -- Calculate the size of the dereferenced object. Generate: -- Size : Storage_Count := <N>.all'Size / Storage_Unit; Deref := Make_Explicit_Dereference (Loc, Prefix => Duplicate_Subexpr_Move_Checks (N)); Set_Has_Dereference_Action (Deref); Size_Bits := Make_Attribute_Reference (Loc, Prefix => Deref, Attribute_Name => Name_Size); -- Special case of an unconstrained array: need to add descriptor size if Is_Array_Type (Desig) and then not Is_Constrained (First_Subtype (Desig)) then Size_Bits := Make_Op_Add (Loc, Left_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (First_Subtype (Desig), Loc), Attribute_Name => Name_Descriptor_Size), Right_Opnd => Size_Bits); end if; Size := Make_Temporary (Loc, 'S'); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Size, Object_Definition => New_Occurrence_Of (RTE (RE_Storage_Count), Loc), Expression => Make_Op_Divide (Loc, Left_Opnd => Size_Bits, Right_Opnd => Make_Integer_Literal (Loc, System_Storage_Unit)))); -- Calculate the alignment of the dereferenced object. Generate: -- Alig : constant Storage_Count := <N>.all'Alignment; Deref := Make_Explicit_Dereference (Loc, Prefix => Duplicate_Subexpr_Move_Checks (N)); Set_Has_Dereference_Action (Deref); Alig := Make_Temporary (Loc, 'A'); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Alig, Object_Definition => New_Occurrence_Of (RTE (RE_Storage_Count), Loc), Expression => Make_Attribute_Reference (Loc, Prefix => Deref, Attribute_Name => Name_Alignment))); -- A dereference of a controlled object requires special processing. The -- finalization machinery requests additional space from the underlying -- pool to allocate and hide two pointers. As a result, a checked pool -- may mark the wrong memory as valid. Since checked pools do not have -- knowledge of hidden pointers, we have to bring the two pointers back -- in view in order to restore the original state of the object. if Needs_Finalization (Desig) then -- Adjust the address and size of the dereferenced object. Generate: -- Adjust_Controlled_Dereference (Addr, Size, Alig); Stmt := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Adjust_Controlled_Dereference), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Addr, Loc), New_Occurrence_Of (Size, Loc), New_Occurrence_Of (Alig, Loc))); -- Class-wide types complicate things because we cannot determine -- statically whether the actual object is truly controlled. We must -- generate a runtime check to detect this property. Generate: -- -- if Needs_Finalization (<N>.all'Tag) then -- <Stmt>; -- end if; if Is_Class_Wide_Type (Desig) then Deref := Make_Explicit_Dereference (Loc, Prefix => Duplicate_Subexpr_Move_Checks (N)); Set_Has_Dereference_Action (Deref); Stmt := Make_Implicit_If_Statement (N, Condition => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Needs_Finalization), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, Prefix => Deref, Attribute_Name => Name_Tag))), Then_Statements => New_List (Stmt)); end if; Insert_Action (N, Stmt); end if; -- Generate: -- Dereference (Pool, Addr, Size, Alig); Insert_Action (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Find_Prim_Op (Etype (Pool), Name_Dereference), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Pool, Loc), New_Occurrence_Of (Addr, Loc), New_Occurrence_Of (Size, Loc), New_Occurrence_Of (Alig, Loc)))); -- Mark the explicit dereference as processed to avoid potential -- infinite expansion. Set_Has_Dereference_Action (Pnod); exception when RE_Not_Available => return; end Insert_Dereference_Action; -------------------------------- -- Integer_Promotion_Possible -- -------------------------------- function Integer_Promotion_Possible (N : Node_Id) return Boolean is Operand : constant Node_Id := Expression (N); Operand_Type : constant Entity_Id := Etype (Operand); Root_Operand_Type : constant Entity_Id := Root_Type (Operand_Type); begin pragma Assert (Nkind (N) = N_Type_Conversion); return -- We only do the transformation for source constructs. We assume -- that the expander knows what it is doing when it generates code. Comes_From_Source (N) -- If the operand type is Short_Integer or Short_Short_Integer, -- then we will promote to Integer, which is available on all -- targets, and is sufficient to ensure no intermediate overflow. -- Furthermore it is likely to be as efficient or more efficient -- than using the smaller type for the computation so we do this -- unconditionally. and then (Root_Operand_Type = Base_Type (Standard_Short_Integer) or else Root_Operand_Type = Base_Type (Standard_Short_Short_Integer)) -- Test for interesting operation, which includes addition, -- division, exponentiation, multiplication, subtraction, absolute -- value and unary negation. Unary "+" is omitted since it is a -- no-op and thus can't overflow. and then Nkind_In (Operand, N_Op_Abs, N_Op_Add, N_Op_Divide, N_Op_Expon, N_Op_Minus, N_Op_Multiply, N_Op_Subtract); end Integer_Promotion_Possible; ------------------------------ -- Make_Array_Comparison_Op -- ------------------------------ -- This is a hand-coded expansion of the following generic function: -- generic -- type elem is (<>); -- type index is (<>); -- type a is array (index range <>) of elem; -- function Gnnn (X : a; Y: a) return boolean is -- J : index := Y'first; -- begin -- if X'length = 0 then -- return false; -- elsif Y'length = 0 then -- return true; -- else -- for I in X'range loop -- if X (I) = Y (J) then -- if J = Y'last then -- exit; -- else -- J := index'succ (J); -- end if; -- else -- return X (I) > Y (J); -- end if; -- end loop; -- return X'length > Y'length; -- end if; -- end Gnnn; -- Note that since we are essentially doing this expansion by hand, we -- do not need to generate an actual or formal generic part, just the -- instantiated function itself. -- Perhaps we could have the actual generic available in the run-time, -- obtained by rtsfind, and actually expand a real instantiation ??? function Make_Array_Comparison_Op (Typ : Entity_Id; Nod : Node_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Nod); X : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uX); Y : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uY); I : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uI); J : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uJ); Index : constant Entity_Id := Base_Type (Etype (First_Index (Typ))); Loop_Statement : Node_Id; Loop_Body : Node_Id; If_Stat : Node_Id; Inner_If : Node_Id; Final_Expr : Node_Id; Func_Body : Node_Id; Func_Name : Entity_Id; Formals : List_Id; Length1 : Node_Id; Length2 : Node_Id; begin -- if J = Y'last then -- exit; -- else -- J := index'succ (J); -- end if; Inner_If := Make_Implicit_If_Statement (Nod, Condition => Make_Op_Eq (Loc, Left_Opnd => New_Occurrence_Of (J, Loc), Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Y, Loc), Attribute_Name => Name_Last)), Then_Statements => New_List ( Make_Exit_Statement (Loc)), Else_Statements => New_List ( Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (J, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Index, Loc), Attribute_Name => Name_Succ, Expressions => New_List (New_Occurrence_Of (J, Loc)))))); -- if X (I) = Y (J) then -- if ... end if; -- else -- return X (I) > Y (J); -- end if; Loop_Body := Make_Implicit_If_Statement (Nod, Condition => Make_Op_Eq (Loc, Left_Opnd => Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (X, Loc), Expressions => New_List (New_Occurrence_Of (I, Loc))), Right_Opnd => Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (Y, Loc), Expressions => New_List (New_Occurrence_Of (J, Loc)))), Then_Statements => New_List (Inner_If), Else_Statements => New_List ( Make_Simple_Return_Statement (Loc, Expression => Make_Op_Gt (Loc, Left_Opnd => Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (X, Loc), Expressions => New_List (New_Occurrence_Of (I, Loc))), Right_Opnd => Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (Y, Loc), Expressions => New_List ( New_Occurrence_Of (J, Loc))))))); -- for I in X'range loop -- if ... end if; -- end loop; Loop_Statement := Make_Implicit_Loop_Statement (Nod, Identifier => Empty, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => I, Discrete_Subtype_Definition => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (X, Loc), Attribute_Name => Name_Range))), Statements => New_List (Loop_Body)); -- if X'length = 0 then -- return false; -- elsif Y'length = 0 then -- return true; -- else -- for ... loop ... end loop; -- return X'length > Y'length; -- end if; Length1 := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (X, Loc), Attribute_Name => Name_Length); Length2 := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Y, Loc), Attribute_Name => Name_Length); Final_Expr := Make_Op_Gt (Loc, Left_Opnd => Length1, Right_Opnd => Length2); If_Stat := Make_Implicit_If_Statement (Nod, Condition => Make_Op_Eq (Loc, Left_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (X, Loc), Attribute_Name => Name_Length), Right_Opnd => Make_Integer_Literal (Loc, 0)), Then_Statements => New_List ( Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_False, Loc))), Elsif_Parts => New_List ( Make_Elsif_Part (Loc, Condition => Make_Op_Eq (Loc, Left_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Y, Loc), Attribute_Name => Name_Length), Right_Opnd => Make_Integer_Literal (Loc, 0)), Then_Statements => New_List ( Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_True, Loc))))), Else_Statements => New_List ( Loop_Statement, Make_Simple_Return_Statement (Loc, Expression => Final_Expr))); -- (X : a; Y: a) Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => X, Parameter_Type => New_Occurrence_Of (Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Y, Parameter_Type => New_Occurrence_Of (Typ, Loc))); -- function Gnnn (...) return boolean is -- J : index := Y'first; -- begin -- if ... end if; -- end Gnnn; Func_Name := Make_Temporary (Loc, 'G'); Func_Body := Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Func_Name, Parameter_Specifications => Formals, Result_Definition => New_Occurrence_Of (Standard_Boolean, Loc)), Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => J, Object_Definition => New_Occurrence_Of (Index, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Y, Loc), Attribute_Name => Name_First))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (If_Stat))); return Func_Body; end Make_Array_Comparison_Op; --------------------------- -- Make_Boolean_Array_Op -- --------------------------- -- For logical operations on boolean arrays, expand in line the following, -- replacing 'and' with 'or' or 'xor' where needed: -- function Annn (A : typ; B: typ) return typ is -- C : typ; -- begin -- for J in A'range loop -- C (J) := A (J) op B (J); -- end loop; -- return C; -- end Annn; -- Here typ is the boolean array type function Make_Boolean_Array_Op (Typ : Entity_Id; N : Node_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (N); A : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uA); B : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uB); C : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uC); J : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uJ); A_J : Node_Id; B_J : Node_Id; C_J : Node_Id; Op : Node_Id; Formals : List_Id; Func_Name : Entity_Id; Func_Body : Node_Id; Loop_Statement : Node_Id; begin A_J := Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (A, Loc), Expressions => New_List (New_Occurrence_Of (J, Loc))); B_J := Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (B, Loc), Expressions => New_List (New_Occurrence_Of (J, Loc))); C_J := Make_Indexed_Component (Loc, Prefix => New_Occurrence_Of (C, Loc), Expressions => New_List (New_Occurrence_Of (J, Loc))); if Nkind (N) = N_Op_And then Op := Make_Op_And (Loc, Left_Opnd => A_J, Right_Opnd => B_J); elsif Nkind (N) = N_Op_Or then Op := Make_Op_Or (Loc, Left_Opnd => A_J, Right_Opnd => B_J); else Op := Make_Op_Xor (Loc, Left_Opnd => A_J, Right_Opnd => B_J); end if; Loop_Statement := Make_Implicit_Loop_Statement (N, Identifier => Empty, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => J, Discrete_Subtype_Definition => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (A, Loc), Attribute_Name => Name_Range))), Statements => New_List ( Make_Assignment_Statement (Loc, Name => C_J, Expression => Op))); Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => A, Parameter_Type => New_Occurrence_Of (Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => B, Parameter_Type => New_Occurrence_Of (Typ, Loc))); Func_Name := Make_Temporary (Loc, 'A'); Set_Is_Inlined (Func_Name); Func_Body := Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Func_Name, Parameter_Specifications => Formals, Result_Definition => New_Occurrence_Of (Typ, Loc)), Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => C, Object_Definition => New_Occurrence_Of (Typ, Loc))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Loop_Statement, Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (C, Loc))))); return Func_Body; end Make_Boolean_Array_Op; ----------------------------------------- -- Minimized_Eliminated_Overflow_Check -- ----------------------------------------- function Minimized_Eliminated_Overflow_Check (N : Node_Id) return Boolean is begin return Is_Signed_Integer_Type (Etype (N)) and then Overflow_Check_Mode in Minimized_Or_Eliminated; end Minimized_Eliminated_Overflow_Check; -------------------------------- -- Optimize_Length_Comparison -- -------------------------------- procedure Optimize_Length_Comparison (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Result : Node_Id; Left : Node_Id; Right : Node_Id; -- First and Last attribute reference nodes, which end up as left and -- right operands of the optimized result. Is_Zero : Boolean; -- True for comparison operand of zero Comp : Node_Id; -- Comparison operand, set only if Is_Zero is false Ent : Entity_Id; -- Entity whose length is being compared Index : Node_Id; -- Integer_Literal node for length attribute expression, or Empty -- if there is no such expression present. Ityp : Entity_Id; -- Type of array index to which 'Length is applied Op : Node_Kind := Nkind (N); -- Kind of comparison operator, gets flipped if operands backwards function Is_Optimizable (N : Node_Id) return Boolean; -- Tests N to see if it is an optimizable comparison value (defined as -- constant zero or one, or something else where the value is known to -- be positive and in the range of 32-bits, and where the corresponding -- Length value is also known to be 32-bits. If result is true, sets -- Is_Zero, Ityp, and Comp accordingly. function Is_Entity_Length (N : Node_Id) return Boolean; -- Tests if N is a length attribute applied to a simple entity. If so, -- returns True, and sets Ent to the entity, and Index to the integer -- literal provided as an attribute expression, or to Empty if none. -- Also returns True if the expression is a generated type conversion -- whose expression is of the desired form. This latter case arises -- when Apply_Universal_Integer_Attribute_Check installs a conversion -- to check for being in range, which is not needed in this context. -- Returns False if neither condition holds. function Prepare_64 (N : Node_Id) return Node_Id; -- Given a discrete expression, returns a Long_Long_Integer typed -- expression representing the underlying value of the expression. -- This is done with an unchecked conversion to the result type. We -- use unchecked conversion to handle the enumeration type case. ---------------------- -- Is_Entity_Length -- ---------------------- function Is_Entity_Length (N : Node_Id) return Boolean is begin if Nkind (N) = N_Attribute_Reference and then Attribute_Name (N) = Name_Length and then Is_Entity_Name (Prefix (N)) then Ent := Entity (Prefix (N)); if Present (Expressions (N)) then Index := First (Expressions (N)); else Index := Empty; end if; return True; elsif Nkind (N) = N_Type_Conversion and then not Comes_From_Source (N) then return Is_Entity_Length (Expression (N)); else return False; end if; end Is_Entity_Length; -------------------- -- Is_Optimizable -- -------------------- function Is_Optimizable (N : Node_Id) return Boolean is Val : Uint; OK : Boolean; Lo : Uint; Hi : Uint; Indx : Node_Id; begin if Compile_Time_Known_Value (N) then Val := Expr_Value (N); if Val = Uint_0 then Is_Zero := True; Comp := Empty; return True; elsif Val = Uint_1 then Is_Zero := False; Comp := Empty; return True; end if; end if; -- Here we have to make sure of being within 32-bits Determine_Range (N, OK, Lo, Hi, Assume_Valid => True); if not OK or else Lo < Uint_1 or else Hi > UI_From_Int (Int'Last) then return False; end if; -- Comparison value was within range, so now we must check the index -- value to make sure it is also within 32-bits. Indx := First_Index (Etype (Ent)); if Present (Index) then for J in 2 .. UI_To_Int (Intval (Index)) loop Next_Index (Indx); end loop; end if; Ityp := Etype (Indx); if Esize (Ityp) > 32 then return False; end if; Is_Zero := False; Comp := N; return True; end Is_Optimizable; ---------------- -- Prepare_64 -- ---------------- function Prepare_64 (N : Node_Id) return Node_Id is begin return Unchecked_Convert_To (Standard_Long_Long_Integer, N); end Prepare_64; -- Start of processing for Optimize_Length_Comparison begin -- Nothing to do if not a comparison if Op not in N_Op_Compare then return; end if; -- Nothing to do if special -gnatd.P debug flag set. if Debug_Flag_Dot_PP then return; end if; -- Ent'Length op 0/1 if Is_Entity_Length (Left_Opnd (N)) and then Is_Optimizable (Right_Opnd (N)) then null; -- 0/1 op Ent'Length elsif Is_Entity_Length (Right_Opnd (N)) and then Is_Optimizable (Left_Opnd (N)) then -- Flip comparison to opposite sense case Op is when N_Op_Lt => Op := N_Op_Gt; when N_Op_Le => Op := N_Op_Ge; when N_Op_Gt => Op := N_Op_Lt; when N_Op_Ge => Op := N_Op_Le; when others => null; end case; -- Else optimization not possible else return; end if; -- Fall through if we will do the optimization -- Cases to handle: -- X'Length = 0 => X'First > X'Last -- X'Length = 1 => X'First = X'Last -- X'Length = n => X'First + (n - 1) = X'Last -- X'Length /= 0 => X'First <= X'Last -- X'Length /= 1 => X'First /= X'Last -- X'Length /= n => X'First + (n - 1) /= X'Last -- X'Length >= 0 => always true, warn -- X'Length >= 1 => X'First <= X'Last -- X'Length >= n => X'First + (n - 1) <= X'Last -- X'Length > 0 => X'First <= X'Last -- X'Length > 1 => X'First < X'Last -- X'Length > n => X'First + (n - 1) < X'Last -- X'Length <= 0 => X'First > X'Last (warn, could be =) -- X'Length <= 1 => X'First >= X'Last -- X'Length <= n => X'First + (n - 1) >= X'Last -- X'Length < 0 => always false (warn) -- X'Length < 1 => X'First > X'Last -- X'Length < n => X'First + (n - 1) > X'Last -- Note: for the cases of n (not constant 0,1), we require that the -- corresponding index type be integer or shorter (i.e. not 64-bit), -- and the same for the comparison value. Then we do the comparison -- using 64-bit arithmetic (actually long long integer), so that we -- cannot have overflow intefering with the result. -- First deal with warning cases if Is_Zero then case Op is -- X'Length >= 0 when N_Op_Ge => Rewrite (N, Convert_To (Typ, New_Occurrence_Of (Standard_True, Loc))); Analyze_And_Resolve (N, Typ); Warn_On_Known_Condition (N); return; -- X'Length < 0 when N_Op_Lt => Rewrite (N, Convert_To (Typ, New_Occurrence_Of (Standard_False, Loc))); Analyze_And_Resolve (N, Typ); Warn_On_Known_Condition (N); return; when N_Op_Le => if Constant_Condition_Warnings and then Comes_From_Source (Original_Node (N)) then Error_Msg_N ("could replace by ""'=""?c?", N); end if; Op := N_Op_Eq; when others => null; end case; end if; -- Build the First reference we will use Left := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Ent, Loc), Attribute_Name => Name_First); if Present (Index) then Set_Expressions (Left, New_List (New_Copy (Index))); end if; -- If general value case, then do the addition of (n - 1), and -- also add the needed conversions to type Long_Long_Integer. if Present (Comp) then Left := Make_Op_Add (Loc, Left_Opnd => Prepare_64 (Left), Right_Opnd => Make_Op_Subtract (Loc, Left_Opnd => Prepare_64 (Comp), Right_Opnd => Make_Integer_Literal (Loc, 1))); end if; -- Build the Last reference we will use Right := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Ent, Loc), Attribute_Name => Name_Last); if Present (Index) then Set_Expressions (Right, New_List (New_Copy (Index))); end if; -- If general operand, convert Last reference to Long_Long_Integer if Present (Comp) then Right := Prepare_64 (Right); end if; -- Check for cases to optimize -- X'Length = 0 => X'First > X'Last -- X'Length < 1 => X'First > X'Last -- X'Length < n => X'First + (n - 1) > X'Last if (Is_Zero and then Op = N_Op_Eq) or else (not Is_Zero and then Op = N_Op_Lt) then Result := Make_Op_Gt (Loc, Left_Opnd => Left, Right_Opnd => Right); -- X'Length = 1 => X'First = X'Last -- X'Length = n => X'First + (n - 1) = X'Last elsif not Is_Zero and then Op = N_Op_Eq then Result := Make_Op_Eq (Loc, Left_Opnd => Left, Right_Opnd => Right); -- X'Length /= 0 => X'First <= X'Last -- X'Length > 0 => X'First <= X'Last elsif Is_Zero and (Op = N_Op_Ne or else Op = N_Op_Gt) then Result := Make_Op_Le (Loc, Left_Opnd => Left, Right_Opnd => Right); -- X'Length /= 1 => X'First /= X'Last -- X'Length /= n => X'First + (n - 1) /= X'Last elsif not Is_Zero and then Op = N_Op_Ne then Result := Make_Op_Ne (Loc, Left_Opnd => Left, Right_Opnd => Right); -- X'Length >= 1 => X'First <= X'Last -- X'Length >= n => X'First + (n - 1) <= X'Last elsif not Is_Zero and then Op = N_Op_Ge then Result := Make_Op_Le (Loc, Left_Opnd => Left, Right_Opnd => Right); -- X'Length > 1 => X'First < X'Last -- X'Length > n => X'First + (n = 1) < X'Last elsif not Is_Zero and then Op = N_Op_Gt then Result := Make_Op_Lt (Loc, Left_Opnd => Left, Right_Opnd => Right); -- X'Length <= 1 => X'First >= X'Last -- X'Length <= n => X'First + (n - 1) >= X'Last elsif not Is_Zero and then Op = N_Op_Le then Result := Make_Op_Ge (Loc, Left_Opnd => Left, Right_Opnd => Right); -- Should not happen at this stage else raise Program_Error; end if; -- Rewrite and finish up Rewrite (N, Result); Analyze_And_Resolve (N, Typ); return; end Optimize_Length_Comparison; -------------------------------- -- Process_If_Case_Statements -- -------------------------------- procedure Process_If_Case_Statements (N : Node_Id; Stmts : List_Id) is Decl : Node_Id; begin Decl := First (Stmts); while Present (Decl) loop if Nkind (Decl) = N_Object_Declaration and then Is_Finalizable_Transient (Decl, N) then Process_Transient_In_Expression (Decl, N, Stmts); end if; Next (Decl); end loop; end Process_If_Case_Statements; ------------------------------------- -- Process_Transient_In_Expression -- ------------------------------------- procedure Process_Transient_In_Expression (Obj_Decl : Node_Id; Expr : Node_Id; Stmts : List_Id) is Loc : constant Source_Ptr := Sloc (Obj_Decl); Obj_Id : constant Entity_Id := Defining_Identifier (Obj_Decl); Hook_Context : constant Node_Id := Find_Hook_Context (Expr); -- The node on which to insert the hook as an action. This is usually -- the innermost enclosing non-transient construct. Fin_Call : Node_Id; Hook_Assign : Node_Id; Hook_Clear : Node_Id; Hook_Decl : Node_Id; Hook_Insert : Node_Id; Ptr_Decl : Node_Id; Fin_Context : Node_Id; -- The node after which to insert the finalization actions of the -- transient object. begin pragma Assert (Nkind_In (Expr, N_Case_Expression, N_Expression_With_Actions, N_If_Expression)); -- When the context is a Boolean evaluation, all three nodes capture the -- result of their computation in a local temporary: -- do -- Trans_Id : Ctrl_Typ := ...; -- Result : constant Boolean := ... Trans_Id ...; -- <finalize Trans_Id> -- in Result end; -- As a result, the finalization of any transient objects can safely -- take place after the result capture. -- ??? could this be extended to elementary types? if Is_Boolean_Type (Etype (Expr)) then Fin_Context := Last (Stmts); -- Otherwise the immediate context may not be safe enough to carry -- out transient object finalization due to aliasing and nesting of -- constructs. Insert calls to [Deep_]Finalize after the innermost -- enclosing non-transient construct. else Fin_Context := Hook_Context; end if; -- Mark the transient object as successfully processed to avoid double -- finalization. Set_Is_Finalized_Transient (Obj_Id); -- Construct all the pieces necessary to hook and finalize a transient -- object. Build_Transient_Object_Statements (Obj_Decl => Obj_Decl, Fin_Call => Fin_Call, Hook_Assign => Hook_Assign, Hook_Clear => Hook_Clear, Hook_Decl => Hook_Decl, Ptr_Decl => Ptr_Decl, Finalize_Obj => False); -- Add the access type which provides a reference to the transient -- object. Generate: -- type Ptr_Typ is access all Desig_Typ; Insert_Action (Hook_Context, Ptr_Decl); -- Add the temporary which acts as a hook to the transient object. -- Generate: -- Hook : Ptr_Id := null; Insert_Action (Hook_Context, Hook_Decl); -- When the transient object is initialized by an aggregate, the hook -- must capture the object after the last aggregate assignment takes -- place. Only then is the object considered initialized. Generate: -- Hook := Ptr_Typ (Obj_Id); -- <or> -- Hook := Obj_Id'Unrestricted_Access; if Ekind_In (Obj_Id, E_Constant, E_Variable) and then Present (Last_Aggregate_Assignment (Obj_Id)) then Hook_Insert := Last_Aggregate_Assignment (Obj_Id); -- Otherwise the hook seizes the related object immediately else Hook_Insert := Obj_Decl; end if; Insert_After_And_Analyze (Hook_Insert, Hook_Assign); -- When the node is part of a return statement, there is no need to -- insert a finalization call, as the general finalization mechanism -- (see Build_Finalizer) would take care of the transient object on -- subprogram exit. Note that it would also be impossible to insert the -- finalization code after the return statement as this will render it -- unreachable. if Nkind (Fin_Context) = N_Simple_Return_Statement then null; -- Finalize the hook after the context has been evaluated. Generate: -- if Hook /= null then -- [Deep_]Finalize (Hook.all); -- Hook := null; -- end if; else Insert_Action_After (Fin_Context, Make_Implicit_If_Statement (Obj_Decl, Condition => Make_Op_Ne (Loc, Left_Opnd => New_Occurrence_Of (Defining_Entity (Hook_Decl), Loc), Right_Opnd => Make_Null (Loc)), Then_Statements => New_List ( Fin_Call, Hook_Clear))); end if; end Process_Transient_In_Expression; ------------------------ -- Rewrite_Comparison -- ------------------------ procedure Rewrite_Comparison (N : Node_Id) is Warning_Generated : Boolean := False; -- Set to True if first pass with Assume_Valid generates a warning in -- which case we skip the second pass to avoid warning overloaded. Result : Node_Id; -- Set to Standard_True or Standard_False begin if Nkind (N) = N_Type_Conversion then Rewrite_Comparison (Expression (N)); return; elsif Nkind (N) not in N_Op_Compare then return; end if; -- Now start looking at the comparison in detail. We potentially go -- through this loop twice. The first time, Assume_Valid is set False -- in the call to Compile_Time_Compare. If this call results in a -- clear result of always True or Always False, that's decisive and -- we are done. Otherwise we repeat the processing with Assume_Valid -- set to True to generate additional warnings. We can skip that step -- if Constant_Condition_Warnings is False. for AV in False .. True loop declare Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Res : constant Compare_Result := Compile_Time_Compare (Op1, Op2, Assume_Valid => AV); -- Res indicates if compare outcome can be compile time determined True_Result : Boolean; False_Result : Boolean; begin case N_Op_Compare (Nkind (N)) is when N_Op_Eq => True_Result := Res = EQ; False_Result := Res = LT or else Res = GT or else Res = NE; when N_Op_Ge => True_Result := Res in Compare_GE; False_Result := Res = LT; if Res = LE and then Constant_Condition_Warnings and then Comes_From_Source (Original_Node (N)) and then Nkind (Original_Node (N)) = N_Op_Ge and then not In_Instance and then Is_Integer_Type (Etype (Left_Opnd (N))) and then not Has_Warnings_Off (Etype (Left_Opnd (N))) then Error_Msg_N ("can never be greater than, could replace by " & """'=""?c?", N); Warning_Generated := True; end if; when N_Op_Gt => True_Result := Res = GT; False_Result := Res in Compare_LE; when N_Op_Lt => True_Result := Res = LT; False_Result := Res in Compare_GE; when N_Op_Le => True_Result := Res in Compare_LE; False_Result := Res = GT; if Res = GE and then Constant_Condition_Warnings and then Comes_From_Source (Original_Node (N)) and then Nkind (Original_Node (N)) = N_Op_Le and then not In_Instance and then Is_Integer_Type (Etype (Left_Opnd (N))) and then not Has_Warnings_Off (Etype (Left_Opnd (N))) then Error_Msg_N ("can never be less than, could replace by ""'=""?c?", N); Warning_Generated := True; end if; when N_Op_Ne => True_Result := Res = NE or else Res = GT or else Res = LT; False_Result := Res = EQ; end case; -- If this is the first iteration, then we actually convert the -- comparison into True or False, if the result is certain. if AV = False then if True_Result or False_Result then Result := Boolean_Literals (True_Result); Rewrite (N, Convert_To (Typ, New_Occurrence_Of (Result, Sloc (N)))); Analyze_And_Resolve (N, Typ); Warn_On_Known_Condition (N); return; end if; -- If this is the second iteration (AV = True), and the original -- node comes from source and we are not in an instance, then give -- a warning if we know result would be True or False. Note: we -- know Constant_Condition_Warnings is set if we get here. elsif Comes_From_Source (Original_Node (N)) and then not In_Instance then if True_Result then Error_Msg_N ("condition can only be False if invalid values present??", N); elsif False_Result then Error_Msg_N ("condition can only be True if invalid values present??", N); end if; end if; end; -- Skip second iteration if not warning on constant conditions or -- if the first iteration already generated a warning of some kind or -- if we are in any case assuming all values are valid (so that the -- first iteration took care of the valid case). exit when not Constant_Condition_Warnings; exit when Warning_Generated; exit when Assume_No_Invalid_Values; end loop; end Rewrite_Comparison; ---------------------------- -- Safe_In_Place_Array_Op -- ---------------------------- function Safe_In_Place_Array_Op (Lhs : Node_Id; Op1 : Node_Id; Op2 : Node_Id) return Boolean is Target : Entity_Id; function Is_Safe_Operand (Op : Node_Id) return Boolean; -- Operand is safe if it cannot overlap part of the target of the -- operation. If the operand and the target are identical, the operand -- is safe. The operand can be empty in the case of negation. function Is_Unaliased (N : Node_Id) return Boolean; -- Check that N is a stand-alone entity ------------------ -- Is_Unaliased -- ------------------ function Is_Unaliased (N : Node_Id) return Boolean is begin return Is_Entity_Name (N) and then No (Address_Clause (Entity (N))) and then No (Renamed_Object (Entity (N))); end Is_Unaliased; --------------------- -- Is_Safe_Operand -- --------------------- function Is_Safe_Operand (Op : Node_Id) return Boolean is begin if No (Op) then return True; elsif Is_Entity_Name (Op) then return Is_Unaliased (Op); elsif Nkind_In (Op, N_Indexed_Component, N_Selected_Component) then return Is_Unaliased (Prefix (Op)); elsif Nkind (Op) = N_Slice then return Is_Unaliased (Prefix (Op)) and then Entity (Prefix (Op)) /= Target; elsif Nkind (Op) = N_Op_Not then return Is_Safe_Operand (Right_Opnd (Op)); else return False; end if; end Is_Safe_Operand; -- Start of processing for Safe_In_Place_Array_Op begin -- Skip this processing if the component size is different from system -- storage unit (since at least for NOT this would cause problems). if Component_Size (Etype (Lhs)) /= System_Storage_Unit then return False; -- Cannot do in place stuff if non-standard Boolean representation elsif Has_Non_Standard_Rep (Component_Type (Etype (Lhs))) then return False; elsif not Is_Unaliased (Lhs) then return False; else Target := Entity (Lhs); return Is_Safe_Operand (Op1) and then Is_Safe_Operand (Op2); end if; end Safe_In_Place_Array_Op; ----------------------- -- Tagged_Membership -- ----------------------- -- There are two different cases to consider depending on whether the right -- operand is a class-wide type or not. If not we just compare the actual -- tag of the left expr to the target type tag: -- -- Left_Expr.Tag = Right_Type'Tag; -- -- If it is a class-wide type we use the RT function CW_Membership which is -- usually implemented by looking in the ancestor tables contained in the -- dispatch table pointed by Left_Expr.Tag for Typ'Tag -- Ada 2005 (AI-251): If it is a class-wide interface type we use the RT -- function IW_Membership which is usually implemented by looking in the -- table of abstract interface types plus the ancestor table contained in -- the dispatch table pointed by Left_Expr.Tag for Typ'Tag procedure Tagged_Membership (N : Node_Id; SCIL_Node : out Node_Id; Result : out Node_Id) is Left : constant Node_Id := Left_Opnd (N); Right : constant Node_Id := Right_Opnd (N); Loc : constant Source_Ptr := Sloc (N); Full_R_Typ : Entity_Id; Left_Type : Entity_Id; New_Node : Node_Id; Right_Type : Entity_Id; Obj_Tag : Node_Id; begin SCIL_Node := Empty; -- Handle entities from the limited view Left_Type := Available_View (Etype (Left)); Right_Type := Available_View (Etype (Right)); -- In the case where the type is an access type, the test is applied -- using the designated types (needed in Ada 2012 for implicit anonymous -- access conversions, for AI05-0149). if Is_Access_Type (Right_Type) then Left_Type := Designated_Type (Left_Type); Right_Type := Designated_Type (Right_Type); end if; if Is_Class_Wide_Type (Left_Type) then Left_Type := Root_Type (Left_Type); end if; if Is_Class_Wide_Type (Right_Type) then Full_R_Typ := Underlying_Type (Root_Type (Right_Type)); else Full_R_Typ := Underlying_Type (Right_Type); end if; Obj_Tag := Make_Selected_Component (Loc, Prefix => Relocate_Node (Left), Selector_Name => New_Occurrence_Of (First_Tag_Component (Left_Type), Loc)); if Is_Class_Wide_Type (Right_Type) then -- No need to issue a run-time check if we statically know that the -- result of this membership test is always true. For example, -- considering the following declarations: -- type Iface is interface; -- type T is tagged null record; -- type DT is new T and Iface with null record; -- Obj1 : T; -- Obj2 : DT; -- These membership tests are always true: -- Obj1 in T'Class -- Obj2 in T'Class; -- Obj2 in Iface'Class; -- We do not need to handle cases where the membership is illegal. -- For example: -- Obj1 in DT'Class; -- Compile time error -- Obj1 in Iface'Class; -- Compile time error if not Is_Class_Wide_Type (Left_Type) and then (Is_Ancestor (Etype (Right_Type), Left_Type, Use_Full_View => True) or else (Is_Interface (Etype (Right_Type)) and then Interface_Present_In_Ancestor (Typ => Left_Type, Iface => Etype (Right_Type)))) then Result := New_Occurrence_Of (Standard_True, Loc); return; end if; -- Ada 2005 (AI-251): Class-wide applied to interfaces if Is_Interface (Etype (Class_Wide_Type (Right_Type))) -- Support to: "Iface_CW_Typ in Typ'Class" or else Is_Interface (Left_Type) then -- Issue error if IW_Membership operation not available in a -- configurable run time setting. if not RTE_Available (RE_IW_Membership) then Error_Msg_CRT ("dynamic membership test on interface types", N); Result := Empty; return; end if; Result := Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_IW_Membership), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, Prefix => Obj_Tag, Attribute_Name => Name_Address), New_Occurrence_Of ( Node (First_Elmt (Access_Disp_Table (Full_R_Typ))), Loc))); -- Ada 95: Normal case else Build_CW_Membership (Loc, Obj_Tag_Node => Obj_Tag, Typ_Tag_Node => New_Occurrence_Of ( Node (First_Elmt (Access_Disp_Table (Full_R_Typ))), Loc), Related_Nod => N, New_Node => New_Node); -- Generate the SCIL node for this class-wide membership test. -- Done here because the previous call to Build_CW_Membership -- relocates Obj_Tag. if Generate_SCIL then SCIL_Node := Make_SCIL_Membership_Test (Sloc (N)); Set_SCIL_Entity (SCIL_Node, Etype (Right_Type)); Set_SCIL_Tag_Value (SCIL_Node, Obj_Tag); end if; Result := New_Node; end if; -- Right_Type is not a class-wide type else -- No need to check the tag of the object if Right_Typ is abstract if Is_Abstract_Type (Right_Type) then Result := New_Occurrence_Of (Standard_False, Loc); else Result := Make_Op_Eq (Loc, Left_Opnd => Obj_Tag, Right_Opnd => New_Occurrence_Of (Node (First_Elmt (Access_Disp_Table (Full_R_Typ))), Loc)); end if; end if; end Tagged_Membership; ------------------------------ -- Unary_Op_Validity_Checks -- ------------------------------ procedure Unary_Op_Validity_Checks (N : Node_Id) is begin if Validity_Checks_On and Validity_Check_Operands then Ensure_Valid (Right_Opnd (N)); end if; end Unary_Op_Validity_Checks; end Exp_Ch4;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Elements.Type_Definitions; with Program.Lexical_Elements; with Program.Elements.Definitions; package Program.Elements.Record_Types is pragma Pure (Program.Elements.Record_Types); type Record_Type is limited interface and Program.Elements.Type_Definitions.Type_Definition; type Record_Type_Access is access all Record_Type'Class with Storage_Size => 0; not overriding function Record_Definition (Self : Record_Type) return not null Program.Elements.Definitions.Definition_Access is abstract; type Record_Type_Text is limited interface; type Record_Type_Text_Access is access all Record_Type_Text'Class with Storage_Size => 0; not overriding function To_Record_Type_Text (Self : in out Record_Type) return Record_Type_Text_Access is abstract; not overriding function Abstract_Token (Self : Record_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Tagged_Token (Self : Record_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Limited_Token (Self : Record_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Record_Types;
with Ada.Unchecked_Deallocation; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with GNAT.Source_Info; with System; with Interfaces; use Interfaces; with Interfaces.C; use Interfaces.C; with Simple_Logging; with Littlefs; use Littlefs; package body FSmaker.Target.LittleFS is function ftruncate (FS : int; Length : Long_Integer) return int; pragma Import (C, ftruncate, "ftruncate"); function fsync (FS : int) return int; pragma Import (C, fsync, "fsync"); procedure Free is new Ada.Unchecked_Deallocation (LFS_Config, LFS_Config_Access); package FD_Backend is function Create (FD : aliased GNAT.OS_Lib.File_Descriptor) return LFS_Config_Access; end FD_Backend; package body FD_Backend is function Read (C : access constant LFS_Config; Block : LFS_Block; Off : LFS_Offset; Buffer : System.Address; Size : LFS_Size) return int with Convention => C; function Prog (C : access constant LFS_Config; Block : LFS_Block; Off : LFS_Offset; Buffer : System.Address; Size : LFS_Size) return int with Convention => C; function Erase (C : access constant LFS_Config; Block : LFS_Block) return int with Convention => C; function Sync (C : access constant LFS_Config) return int with Convention => C; ---------- -- Read -- ---------- function Read (C : access constant LFS_Config; Block : LFS_Block; Off : LFS_Offset; Buffer : System.Address; Size : LFS_Size) return int is Offset : constant LFS_Offset := Off + C.Block_Size * LFS_Size (Block); FD : GNAT.OS_Lib.File_Descriptor with Address => C.Context; begin GNAT.OS_Lib.Lseek (FD => FD, offset => Long_Integer (Offset), origin => GNAT.OS_Lib.Seek_Set); if GNAT.OS_Lib.Read (FD, Buffer, Integer (Size)) = Integer (Size) then return 0; else Simple_Logging.Error (GNAT.Source_Info.Enclosing_Entity & ": " & GNAT.OS_Lib.Errno_Message); return LFS_ERR_IO; end if; end Read; ---------- -- Prog -- ---------- function Prog (C : access constant LFS_Config; Block : LFS_Block; Off : LFS_Offset; Buffer : System.Address; Size : LFS_Size) return int is Offset : constant LFS_Offset := Off + C.Block_Size * LFS_Size (Block); FD : GNAT.OS_Lib.File_Descriptor with Address => C.Context; begin GNAT.OS_Lib.Lseek (FD => FD, offset => Long_Integer (Offset), origin => GNAT.OS_Lib.Seek_Set); if GNAT.OS_Lib.Write (FD, Buffer, Integer (Size)) = Integer (Size) then return 0; else Simple_Logging.Error (GNAT.Source_Info.Enclosing_Entity & ": " & GNAT.OS_Lib.Errno_Message); return LFS_ERR_IO; end if; end Prog; ----------- -- Erase -- ----------- function Erase (C : access constant LFS_Config; Block : LFS_Block) return int is Offset : constant LFS_Offset := C.Block_Size * LFS_Size (Block); FD : GNAT.OS_Lib.File_Descriptor with Address => C.Context; Zeros : constant array (1 .. C.Block_Size) of Unsigned_8 := (others => 0); Size : constant Integer := Integer (C.Block_Size); begin GNAT.OS_Lib.Lseek (FD => FD, offset => Long_Integer (Offset), origin => GNAT.OS_Lib.Seek_Set); if GNAT.OS_Lib.Write (FD, Zeros'Address, Size) = Size then return 0; else Simple_Logging.Error (GNAT.Source_Info.Enclosing_Entity & ": " & GNAT.OS_Lib.Errno_Message); return LFS_ERR_IO; end if; end Erase; ---------- -- Sync -- ---------- function Sync (C : access constant LFS_Config) return int is pragma Unreferenced (C); begin return 0; end Sync; ------------ -- Create -- ------------ function Create (FD : aliased GNAT.OS_Lib.File_Descriptor) return LFS_Config_Access is Ret : constant LFS_Config_Access := new LFS_Config; begin Ret.Context := FD'Address; Ret.Read := Read'Access; Ret.Prog := Prog'Access; Ret.Erase := Erase'Access; Ret.Sync := Sync'Access; Ret.Read_Size := 2048; Ret.Prog_Size := 2048; Ret.Block_Size := 2048; Simple_Logging.Debug ("Create FD backend -> File size: " & GNAT.OS_Lib.File_Length (FD)'Img); Ret.Block_Count := LFS_Size (GNAT.OS_Lib.File_Length (FD)) / Ret.Block_Size; Ret.Block_Cycles := 700; Ret.Cache_Size := Ret.Block_Size; Ret.Lookahead_Size := Ret.Block_Size; Ret.Read_Buffer := System.Null_Address; Ret.Prog_Buffer := System.Null_Address; Ret.Lookahead_Buffer := System.Null_Address; Ret.Name_Max := 0; Ret.File_Max := 0; Ret.Attr_Max := 0; return Ret; end Create; end FD_Backend; --------------- -- Error_Img -- --------------- function Error_Img (Err : int) return String is (case Err is when LFS_ERR_OK => "No error", when LFS_ERR_IO => "Error during device operation", when LFS_ERR_CORRUPT => "Corrupted", when LFS_ERR_NOENT => "No directory entry", when LFS_ERR_EXIST => "Entry already exists", when LFS_ERR_NOTDIR => "Entry is not a dir", when LFS_ERR_ISDIR => "Entry is a dir", when LFS_ERR_NOTEMPTY => "Dir is not empty", when LFS_ERR_BADF => "Bad file number", when LFS_ERR_FBIG => "File too large", when LFS_ERR_INVAL => "Invalid parameter", when LFS_ERR_NOSPC => "No space left on device", when LFS_ERR_NOMEM => "No more memory available", when LFS_ERR_NOATTR => "No data/attr available", when LFS_ERR_NAMETOOLONG => "File name too long", when others => "Unknown LFS error (" & Err'Img & ")"); ------------ -- Format -- ------------ overriding procedure Format (This : in out Instance; FD : GNAT.OS_Lib.File_Descriptor; Size : Natural) is use GNAT.OS_Lib; Unused : Integer; Err : int; Config : LFS_Config_Access; FD_Aliased : aliased constant File_Descriptor := FD; begin Simple_Logging.Always ("File size: " & GNAT.OS_Lib.File_Length (FD)'Img); if GNAT.OS_Lib.File_Length (FD) /= Long_Integer (Size) then raise Program_Error with "File size different than expected"; end if; Config := FD_Backend.Create (FD_Aliased); Err := Format (This.LFS, Config.all); Free (Config); if Err /= 0 then raise Program_Error with "format: " & Error_Img (Err); end if; end Format; ----------- -- Mount -- ----------- overriding procedure Mount (This : in out Instance; FD : GNAT.OS_Lib.File_Descriptor) is Err : int; begin This.FD := FD; This.Config := FD_Backend.Create (This.FD); Err := Mount (This.LFS, This.Config.all); if Err /= 0 then raise Program_Error with "mount: " & Error_Img (Err); end if; end Mount; -------------- -- Make_Dir -- -------------- overriding procedure Make_Dir (This : in out Instance; Path : Target_Path) is Err : int; Full_Path : Ada.Strings.Unbounded.Unbounded_String; begin for Dir of Path loop Full_Path := Full_Path & "/" & Dir; Simple_Logging.Always ("LFS: Making dir: '" & To_String (Full_Path) & "'"); Err := Mkdir (This.LFS, To_String (Full_Path)); if Err not in LFS_ERR_OK | LFS_ERR_EXIST then raise Program_Error with "mkdir: " & Error_Img (Err); end if; end loop; end Make_Dir; ---------- -- Tree -- ---------- overriding function Tree (This : in out Instance; Path : Target_Path) return Directory_Tree is function Tree_Rec (Dir_Path : String) return Directory_Tree is Dir : aliased LFS_Dir; Err : int; Info : aliased Entry_Info; Res : Node_Vectors.Vector; begin Simple_Logging.Always ("Listing path: '" & Dir_Path & "'"); Err := Open (This.LFS, Dir, Dir_Path); if Err /= LFS_ERR_OK then raise Program_Error with "tree: " & Error_Img (Err); end if; loop Err := Read (This.LFS, Dir, Info); case Err is when LFS_ERR_OK => exit; -- End of directory when int'First .. -1 => raise Program_Error with "tree: " & Error_Img (Err); when 1 .. int'Last => declare Name : constant String := Standard.Littlefs.Name (Info); begin if Name /= "." and then Name /= ".." then case Kind (Info) is when Register => Res.Append (new Node'(Kind => File, Name => To_Unbounded_String (Name))); when Directory => Res.Append (new Node'(Kind => FSmaker.Dir, Name => To_Unbounded_String (Name), Entries => Tree_Rec (Dir_Path & Name & "/"))); end case; end if; end; end case; end loop; Err := Close (This.LFS, Dir); if Err /= LFS_ERR_OK then raise Program_Error with "tree: " & Error_Img (Err); end if; return Res; end Tree_Rec; Full_Path : constant String := "/" & Path.Flatten ("/") & "/"; begin return Tree_Rec (Full_Path); end Tree; ------------ -- Import -- ------------ procedure Import (This : in out Instance; Path : Target_Path; Src : in out Source.Instance) is Err : int; File : aliased LFS_File; Full_Path : constant String := "/" & Path.Flatten ("/"); Dir_Path : Target_Path := Path; begin -- Remove filename from the path Dir_Path.Delete_Last; -- Make sure the directory hierarchy exists This.Make_Dir (Dir_Path); Err := Open (This.LFS, File, Full_Path, LFS_O_CREAT or LFS_O_WRONLY); if Err /= LFS_ERR_OK then raise Program_Error with "import: " & Error_Img (Err); end if; declare Buffer : array (1 .. 4046) of Unsigned_8; Read_Len : Natural; Write_Len : Integer_32; begin loop Read_Len := Src.Read (Buffer'Address, Buffer'Length); exit when Read_Len = 0; Write_Len := Write (This.LFS, File, Buffer'Address, Unsigned_32 (Read_Len)); if Write_Len < 0 then raise Program_Error with "import: " & Error_Img (int (Write_Len)); end if; exit when Write_Len /= Integer_32 (Read_Len); end loop; end; Err := Close (This.LFS, File); if Err /= LFS_ERR_OK then raise Program_Error with "import: " & Error_Img (Err); end if; Src.Close; end Import; --------- -- Cat -- --------- procedure Cat (This : in out Instance; Path : Target_Path; Dst : in out FSmaker.Sink.Class) is Err : int; File : aliased LFS_File; Full_Path : constant String := "/" & Path.Flatten ("/"); begin Err := Open (This.LFS, File, Full_Path, LFS_O_RDONLY); if Err /= LFS_ERR_OK then raise Program_Error with "cat: " & Error_Img (Err); end if; loop declare Buffer : array (1 .. 4096) of Unsigned_8; Read_Len : Integer_32; Write_Len : Natural; begin Read_Len := Read (This.LFS, File, Buffer'Address, Buffer'Length); exit when Read_Len = 0; if Read_Len < 0 then raise Program_Error with "cat: " & Error_Img (int (Err)); end if; Write_Len := Dst.Write (Buffer'Address, Integer (Read_Len)); if Write_Len < 0 then raise Program_Error with "cat: GNAT.OS_Lib.Write: " & GNAT.OS_Lib.Errno_Message; end if; exit when Read_Len /= Buffer'Length; end; end loop; Dst.Close; end Cat; end FSmaker.Target.LittleFS;
-- Ada regular expression library -- (c) Kristian Klomsten Skordal 2020 <kristian.skordal@wafflemail.net> -- Report bugs and issues on <https://github.com/skordal/ada-regex> with Regex.Utilities.Sorted_Sets; package Regex.Syntax_Trees is -- Possible syntax tree node types: type Syntax_Tree_Node_Type is ( Acceptance, -- Acceptance node, indicates the current node is a possible end-node Single_Character, -- Node representing a single character input Any_Character, -- Node representing any character input, '.' Empty_Node, -- Character representing an empty node, ε Alternation, -- Node representing an alternation operator, '|' Concatenation, -- Node representing a concatenation of two subtrees Kleene_Star); -- Node representing the Kleene star/wildcard operator, '*' type Syntax_Tree_Node (Node_Type : Syntax_Tree_Node_Type); type Syntax_Tree_Node_Access is access all Syntax_Tree_Node; -- Comparison function, comparing nodes based on their IDs: function "<" (Left, Right : in Syntax_Tree_Node_Access) return Boolean; package Syntax_Tree_Node_Sets is new Utilities.Sorted_Sets ( Element_Type => Syntax_Tree_Node_Access); -- Syntax tree node object: type Syntax_Tree_Node (Node_Type : Syntax_Tree_Node_Type) is record Left_Child, Right_Child : Syntax_Tree_Node_Access; Id : Natural := 0; Followpos : Syntax_Tree_Node_Sets.Sorted_Set; case Node_Type is when Single_Character => Char : Character; when Acceptance => Acceptance_Id : Natural; when others => null; end case; end record; -- Allocates and initializes a syntax tree node: function Create_Node (Node_Type : in Syntax_Tree_Node_Type; Id : in Natural; Left_Child, Right_Child : in Syntax_Tree_Node_Access := null; Char : in Character := Character'Val (0)) return Syntax_Tree_Node_Access; -- Clones a syntax tree: function Clone_Tree (Root : in Syntax_Tree_Node_Access; Next_Id : in out Natural) return Syntax_Tree_Node_Access with Pre => Root /= null; function Clone_Tree (Root : in Syntax_Tree_Node_Access) return Syntax_Tree_Node_Access with Pre => Root /= null; -- Gets the acceptance node from a syntax tree: function Get_Acceptance_Node (Root : in Syntax_Tree_Node_Access) return Syntax_Tree_Node_Access with Pre => Root /= null; -- Frees a syntax tree recursively: procedure Free_Recursively (Root_Node : in out Syntax_Tree_Node_Access); -- Computes the nullable() function for the specified node: function Nullable (Node : in Syntax_Tree_Node_Access) return Boolean; -- Computes the firstpos() function for the specified node: function Firstpos (Node : in Syntax_Tree_Node_Access) return Syntax_Tree_Node_Sets.Sorted_Set; -- Computes the lastpos() function for the specified node: function Lastpos (Node : in Syntax_Tree_Node_Access) return Syntax_Tree_Node_Sets.Sorted_Set; -- Calculates the followpos() function for all nodes in the specified tree: procedure Calculate_Followpos (Tree : in Syntax_Tree_Node_Access); end Regex.Syntax_Trees;
----------------------------------------------------------------------- -- gen-commands -- Commands for dynamo -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Containers.Ordered_Maps; with Gen.Generator; package Gen.Commands is -- ------------------------------ -- Command -- ------------------------------ type Command is abstract tagged private; type Command_Access is access all Command'Class; -- Execute the command with the arguments. procedure Execute (Cmd : in Command; Generator : in out Gen.Generator.Handler) is abstract; -- Write the help associated with the command. procedure Help (Cmd : in Command; Generator : in out Gen.Generator.Handler) is abstract; -- Write the command usage. procedure Usage (Cmd : in Command); -- Print a message on the standard output. procedure Print (Cmd : in Command; Message : in String); -- ------------------------------ -- Help Command -- ------------------------------ type Help_Command is new Command with private; -- Execute the command with the arguments. procedure Execute (Cmd : in Help_Command; Generator : in out Gen.Generator.Handler); -- Write the help associated with the command. procedure Help (Cmd : in Help_Command; Generator : in out Gen.Generator.Handler); -- Register the command under the given name. procedure Add_Command (Cmd : in Command_Access; Name : in String); -- Find the command having the given name. function Find_Command (Name : in String) return Command_Access; -- Print dynamo usage procedure Usage; -- Print dynamo short usage. procedure Short_Help_Usage; private package Command_Maps is new Ada.Containers.Ordered_Maps (Key_Type => Ada.Strings.Unbounded.Unbounded_String, Element_Type => Command_Access, "<" => Ada.Strings.Unbounded."<"); type Command is abstract tagged null record; type Help_Command is new Command with null record; end Gen.Commands;
with System; use System; with System.Storage_Elements; with System.Address_To_Access_Conversions; package body Display.Basic.Utils is --------------- -- Put_Pixel -- --------------- package Address_To_Pixel is new System.Address_To_Access_Conversions (SDL_SDL_stdinc_h.Uint32); function RGBA_To_Uint32(Screen : access SDL_Surface; Color : RGBA_T) return Uint32 is begin return SDL_MapRGBA (Screen.format.all'Address, unsigned_char (Color.R), unsigned_char (Color.G), unsigned_char (Color.B), unsigned_char (Color.A)); end RGBA_To_Uint32; procedure Put_Pixel_Slow (Screen : access SDL_Surface; X, Y : Integer; Color : RGBA_T) is begin -- Just ignore out of screen draws if X >= Integer(Screen.w) or else X < 0 or else Y >= Integer(Screen.h) or else Y < 0 then return; end if; declare use System.Storage_Elements; Offset : Storage_Offset := Storage_Offset ((Y * Integer (Screen.w) + X) * Integer (Screen.format.BytesPerPixel)); Pixels : System.Address := Screen.pixels + Offset; begin Address_To_Pixel.To_Pointer (Pixels).all := SDL_MapRGBA (Screen.format.all'Address, unsigned_char (Color.R), unsigned_char (Color.G), unsigned_char (Color.B), unsigned_char (Color.A)); end; end Put_Pixel_Slow; procedure Put_Pixel (Screen : access SDL_Surface; X, Y : Integer; Color : Uint32) is begin -- Just ignore out of screen draws if X >= Integer(Screen.w) or else X < 0 or else Y >= Integer(Screen.h) or else Y < 0 then return; end if; declare use System.Storage_Elements; Offset : Storage_Offset := Storage_Offset ((Y * Integer (Screen.w) + X) * Integer (Screen.format.BytesPerPixel)); Pixels : System.Address := Screen.pixels + Offset; begin Address_To_Pixel.To_Pointer (Pixels).all := Color; end; end Put_Pixel; Nb_Canvas : Integer := 0; function Register_SDL_Surface(S : access SDL_Surface) return Canvas_ID is Current_Id : Canvas_ID; begin if Nb_Canvas = Internal_Canvas'Length then raise Too_Many_Canvas; end if; Current_Id := Canvas_ID(Integer(Internal_Canvas'First) + Nb_Canvas); Internal_Canvas(Current_Id) := T_Internal_Canvas'(Surface => S, Zoom_Factor => 1.0, Center => (0, 0)); Nb_Canvas := Nb_Canvas + 1; return Current_Id; end Register_SDL_Surface; function Get_Internal_Canvas(Canvas : Canvas_ID) return T_Internal_Canvas is begin return Internal_Canvas (Canvas); end Get_Internal_Canvas; procedure Set_Center (Canvas : Canvas_ID; Center : Screen_Point) is begin Internal_Canvas(Canvas).Center := Center; end Set_Center; function Get_Center (Canvas : Canvas_ID) return Screen_Point is begin return Internal_Canvas(Canvas).Center; end Get_Center; procedure Set_Zoom_Factor (Canvas : Canvas_ID; ZF : Float) is begin Internal_Canvas(Canvas).Zoom_Factor := ZF; end Set_Zoom_Factor; end Display.Basic.Utils;
procedure Parenthesis_Matter is subtype SmallIntType is Integer range 0..12; function SmallIntVal return SmallIntType is begin return 0; end SmallIntVal; begin case SmallIntVal is when 0 => null; -- when 13 => null; -- error when others => null; end case; case (SmallIntVal) is when 0 => null; when 13 => null; -- no error when others => null; end case; end Parenthesis_Matter;
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with System; with glib; with glib.Values; with System; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gst_h is -- GStreamer -- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> -- * 2000 Wim Taymans <wtay@chello.be> -- * -- * gst.h: Main header for GStreamer, apps should include this -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- -- API compatibility stuff procedure gst_init (argc : access int; argv : System.Address); -- gst/gst.h:86 pragma Import (C, gst_init, "gst_init"); function gst_init_check (argc : access int; argv : System.Address; err : System.Address) return GLIB.gboolean; -- gst/gst.h:87 pragma Import (C, gst_init_check, "gst_init_check"); function gst_is_initialized return GLIB.gboolean; -- gst/gst.h:89 pragma Import (C, gst_is_initialized, "gst_is_initialized"); function gst_init_get_option_group return System.Address; -- gst/gst.h:90 pragma Import (C, gst_init_get_option_group, "gst_init_get_option_group"); procedure gst_deinit; -- gst/gst.h:91 pragma Import (C, gst_deinit, "gst_deinit"); procedure gst_version (major : access GLIB.guint; minor : access GLIB.guint; micro : access GLIB.guint; nano : access GLIB.guint); -- gst/gst.h:93 pragma Import (C, gst_version, "gst_version"); function gst_version_string return access GLIB.gchar; -- gst/gst.h:95 pragma Import (C, gst_version_string, "gst_version_string"); function gst_segtrap_is_enabled return GLIB.gboolean; -- gst/gst.h:97 pragma Import (C, gst_segtrap_is_enabled, "gst_segtrap_is_enabled"); procedure gst_segtrap_set_enabled (enabled : GLIB.gboolean); -- gst/gst.h:98 pragma Import (C, gst_segtrap_set_enabled, "gst_segtrap_set_enabled"); function gst_registry_fork_is_enabled return GLIB.gboolean; -- gst/gst.h:100 pragma Import (C, gst_registry_fork_is_enabled, "gst_registry_fork_is_enabled"); procedure gst_registry_fork_set_enabled (enabled : GLIB.gboolean); -- gst/gst.h:101 pragma Import (C, gst_registry_fork_set_enabled, "gst_registry_fork_set_enabled"); function gst_update_registry return GLIB.gboolean; -- gst/gst.h:103 pragma Import (C, gst_update_registry, "gst_update_registry"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gst_h;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- 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. -- -- package body soc.nvic with spark_mode => off is function to_irq_number (intr : soc.interrupts.t_interrupt) return t_irq_index is begin return t_irq_index'val (soc.interrupts.t_interrupt'pos (intr) - 16); end to_irq_number; procedure enable_irq (irq : in t_irq_index) is begin case irq is when 0 .. 31 => NVIC.ISER0.irq(irq) := IRQ_ENABLED; when 32 .. 63 => NVIC.ISER1.irq(irq) := IRQ_ENABLED; when 64 .. 80 => NVIC.ISER2.irq(irq) := IRQ_ENABLED; end case; end enable_irq; procedure clear_pending_irq (irq : in t_irq_index) is begin case irq is when 0 .. 31 => NVIC.ICPR0.irq(irq) := CLEAR_PENDING; when 32 .. 63 => NVIC.ICPR1.irq(irq) := CLEAR_PENDING; when 64 .. 80 => NVIC.ICPR2.irq(irq) := CLEAR_PENDING; end case; end clear_pending_irq; end soc.nvic;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . A D D R E S S _ T O _ A C C E S S _ C O N V E R S I O N S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ generic type Object (<>) is limited private; package System.Address_To_Access_Conversions is pragma Preelaborate; pragma Elaborate_Body; -- This pragma Elaborate_Body is there to ensure the requirement of what is -- at the moment a dummy null body. The reason this null body is there is -- that we used to have a real body, and it causes bootstrap problems with -- old compilers if we try to remove the corresponding file. pragma Compile_Time_Warning (Object'Unconstrained_Array, "Object is unconstrained array type" & ASCII.LF & "To_Pointer results may not have bounds"); -- Capture constrained status, suppressing warnings, since this is -- an obsolescent feature to use Constrained in this way (RM J.4). pragma Warnings (Off); Xyz : Boolean := Object'Constrained; pragma Warnings (On); type Object_Pointer is access all Object; for Object_Pointer'Size use Standard'Address_Size; pragma No_Strict_Aliasing (Object_Pointer); -- Strictly speaking, this routine should not be used to generate pointers -- to other than proper values of the proper type, but in practice, this -- is done all the time. This pragma stops the compiler from doing some -- optimizations that may cause unexpected results based on the assumption -- of no strict aliasing. function To_Pointer (Value : Address) return Object_Pointer; function To_Address (Value : Object_Pointer) return Address; pragma Import (Intrinsic, To_Pointer); pragma Import (Intrinsic, To_Address); end System.Address_To_Access_Conversions;
-- { dg-do compile } procedure interface4 is generic type I1 is interface; type I2 is limited interface; type I3 is interface and I1; type I4 is limited interface and I2; package Pack_I is end Pack_I; begin null; end interface4;
with Ada.Containers.Vectors; package Atomic4 is type String is limited null record; type String_Access is access all String; pragma Atomic (String_Access); type Reference is record Text : String_Access; end record; package Reference_Vectors is new Ada.Containers.Vectors (Natural, Reference); type Reader is tagged limited record Current_Reference : Reference; Reference_Stack : Reference_Vectors.Vector; end record; procedure Next (Self : in out Reader'Class); end Atomic4;
with BBS.BBB; with BBS.BBB.i2c; with BBS.BBB.i2c.PCA9685; with BBS.units; use type BBS.units.temp_c; use type BBS.units.press_p; package WeatherCommon is -- -- This package contains assorted constants and procedures used by the -- Weather station project. -- -- -- Constants used for output. The min and max values for the servos and the -- temperature, pressure, and humidity units are used to scale the servo -- positions. -- servo_min : constant BBS.BBB.uint12 := 450; servo_max : constant BBS.BBB.uint12 := 2000; -- temp_min : constant BBS.units.temp_c := 10.0; temp_max : constant BBS.units.temp_c := 40.0; -- press_min : constant BBS.units.press_p := 80_000.0; press_max : constant BBS.units.press_p := 120_000.0; -- hum_min : constant float := 0.0; hum_max : constant float := 100.0; -- -- Channels used on the PWM controller. Each parameter has a servo output -- and a LED used to indicate out of range conditions. -- temp_chan : constant BBS.BBB.i2c.PCA9685.channel := 0; temp_range_chan : constant BBS.BBB.i2c.PCA9685.channel := 1; -- press_chan : constant BBS.BBB.i2c.PCA9685.channel := 4; press_range_chan : constant BBS.BBB.i2c.PCA9685.channel := 5; -- hum_chan : constant BBS.BBB.i2c.PCA9685.channel := 8; hum_range_chan : constant BBS.BBB.i2c.PCA9685.channel := 9; -- -- Activity LEDs -- act_1 : constant BBS.BBB.i2c.PCA9685.channel := 12; act_2 : constant BBS.BBB.i2c.PCA9685.channel := 13; -- -- Procedures to set the servos to point to the sensor values. -- procedure show_temp(servo: BBS.BBB.i2c.PCA9685.PS9685_ptr; temp : BBS.units.temp_c); procedure show_press(servo: BBS.BBB.i2c.PCA9685.PS9685_ptr; press : BBS.units.press_p); procedure show_hum(servo: BBS.BBB.i2c.PCA9685.PS9685_ptr; hum : float); end;
------------------------------------------------------------------------------ -- -- -- Copyright (c) 2016-2021 Vitalii Bondarenko <vibondare@gmail.com> -- -- -- ------------------------------------------------------------------------------ -- -- -- The MIT License (MIT) -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, sublicense, and/or sell copies of the Software, and to -- -- permit persons to whom the Software is furnished to do so, subject to -- -- the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; package Formatted_Output is type Format_Type is private; Empty_Format : constant Format_Type; function To_String (Fmt : Format_Type) return String; -- Convert formatted string to fixed-length string -- Example: -- Send_To_Terminal (To_String (+"Hello %s\n" & "world")); function "-" (Fmt : Format_Type) return String renames Formatted_Output.To_String; -- Convert formatted string to fixed-length string function To_Format (Fmt_String : String) return Format_Type; -- Converts String to Format_Type function "+" (Fmt_String : String) return Format_Type renames Formatted_Output.To_Format; -- Converts String to Format_Type function "&" (Fmt : Format_Type; Value : String) return Format_Type; -- Replaces leftmost formatting sequence in Fmt with formatted Value -- string, then returns Fmt. Raises exception Format_Error when invalid -- string formatting sequence is found or no formatting sequence found -- at all procedure Put (Fmt : Format_Type); -- Puts formatted string to console using Ada.Text_IO -- Defined as Ada.Text_IO.Put (To_String (Fmt)); -- Example: -- Put (+"%s %s %s\n" & "Just" & "a" & "test"); procedure Put (File : File_Type; Fmt : Format_Type); -- Puts formatted string to file using Ada.Text_IO -- Defined as Ada.Text_IO.Put (File, To_String (Fmt)); procedure Put_Line (Fmt : Format_Type); -- Puts formatted string to console using Ada.Text_IO procedure Put_Line (File : File_Type; Fmt : Format_Type); -- Puts formatted string to file using Ada.Text_IO Format_Error : exception; -- Format_Error exception raised when bad format detected Filler : constant Character := ' '; -- Filling character, used when padding strings private type Format_Type is new Ada.Strings.Unbounded.Unbounded_String; Empty_Format : constant Format_Type := To_Unbounded_String (""); Maximal_Item_Length : constant := 255; function Scan_To_Percent_Sign (Fmt : Format_Type) return Integer; -- Scans string to the first occurence of percent sign ignoring the double -- percent, returns index of the found sign or zero, if no percent sign is -- found function Decimal_Point_Character return String; function Thousands_Sep_Character return String; Ada_Dec_Point_Character : constant String := "."; Ada_Sep_Character : constant String := "_"; type Digit_Grouping is (None, Ada_Grouping_Style, NLS_Grouping_Style); type Base_Style_Kind is (None, C_Base_Style, Ada_Base_Style); function Separate_Digit_Groups (Text_Value : String; Separator : String; Group_Size : Integer) return String; -- Separate the digit groups for the image without base or decimal value. -- -- Text_Value : Image of the value as a string without leading and trailing -- spaces. -- Separator : The character used to separate groups of digits. -- Group_Size : Size of the group of digits. -- function Separate_Based_Digit_Groups -- (Text_Value : String; -- Separator : String; -- Group_Size : Integer) return String; -- -- Separate the digit groups for the image with base. -- -- -- -- Text_Value : Image of the value as a string without leading and trailing -- -- spaces. -- -- Separator : The character used to separate groups of digits. -- -- Group_Size : Size of the group of digits. function Set_Leading_Zero (Img : String) return String; function Set_Leading_Zero (Img : String; Separator : String; Group_Size : Integer) return String; end Formatted_Output;
package body Termbox_Package is function TB_Init return Integer is function Init return Integer; pragma Import (C, Init, "tb_init"); begin return Init; end TB_Init; function TB_Select_Output_Mode (Mode : Output_Mode) return Output_Mode is function Select_Mode (Mode : Output_Mode) return Output_Mode; pragma Import (C, Select_Mode, "tb_select_output_mode"); begin return Select_Mode (Mode); end TB_Select_Output_Mode; end Termbox_Package;
-- Copyright 2015,2016 Steven Stewart-Gallus -- -- 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 Interfaces.C.Strings; with Libc.Fcntl; with Libc.Unistd; with Libc.Errno; package body Linted.KOs is package C renames Interfaces.C; package Errno renames Libc.Errno; use type Libc.Sys.Types.ssize_t; function Open (Pathname : String; Flags : Open_Flags) return KO_Results.Result with Spark_Mode => Off is use type Linted.Errors.Error; use type C.unsigned; X : aliased C.char_array := C.To_C (Pathname); Err : Errors.Error; Fd : C.int; C_Flags : C.unsigned := Libc.Fcntl.O_CLOEXEC; Has_Read_Only : constant Boolean := (Flags and Read_Only) /= 0; Has_Write_Only : constant Boolean := (Flags and Write_Only) /= 0; Has_Read_Write : constant Boolean := (Flags and Read_Write) /= 0; begin if (Flags and not (Read_Only or Write_Only or Read_Write)) /= 0 then return (Erroneous => True, Err => Errors.Invalid_Parameter); end if; if Has_Read_Only and Has_Write_Only then return (Erroneous => True, Err => Errors.Invalid_Parameter); end if; if Has_Read_Only and Has_Read_Write then return (Erroneous => True, Err => Errors.Invalid_Parameter); end if; if Has_Write_Only and Has_Read_Write then return (Erroneous => True, Err => Errors.Invalid_Parameter); end if; if Has_Read_Only then C_Flags := C_Flags or Libc.Fcntl.O_RDONLY; end if; if Has_Write_Only then C_Flags := C_Flags or Libc.Fcntl.O_WRONLY; end if; if Has_Read_Write then C_Flags := C_Flags or Libc.Fcntl.O_RDWR; end if; Fd := Libc.Fcntl.open (Interfaces.C.Strings.To_Chars_Ptr (X'Unchecked_Access), C.int (C_Flags), 0); if Fd < 0 then declare Errno_Err : Interfaces.C.int; begin Errno.Errno_Get (Errno_Err); Err := Errors.Error (Errno_Err); end; else Err := 0; end if; if Err /= 0 then return (Erroneous => True, Err => Err); else return (Erroneous => False, Data => KO (Fd)); end if; end Open; function Close (Object : KOs.KO) return Errors.Error with Spark_Mode => Off is begin if Libc.Unistd.close (C.int (Object)) < 0 then declare Errno_Err : Interfaces.C.int; begin Errno.Errno_Get (Errno_Err); return Errors.Error (Errno_Err); end; else return 0; end if; end Close; function Pread (Object : KO; Buf : System.Address; Count : Interfaces.C.size_t; Offset : Libc.Sys.Types.off_t; Bytes_Read : out Interfaces.C.size_t) return Errors.Error with Spark_Mode => Off is Bytes : Libc.Sys.Types.ssize_t; begin Bytes := Libc.Unistd.pread (Interfaces.C.int (Object), Buf, Count, Offset); if Bytes < 0 then declare Errno_Err : Interfaces.C.int; begin Errno.Errno_Get (Errno_Err); Bytes_Read := 0; return Linted.Errors.Error (Errno_Err); end; end if; Bytes_Read := Interfaces.C.size_t (Bytes); return Linted.Errors.Success; end Pread; end Linted.KOs;
-- -- -- Copyright (c) 2015, John Leimon -- -- -- -- 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 Interfaces.C; use Interfaces.C; with stdint_h; use stdint_h; with stddef_h; use stddef_h; with Interfaces.C.Strings; package body SPI is procedure Open(device : access SPI_Device; device_path : Interfaces.C.Strings.chars_ptr; mode : Mode_Type; bits : uint8_t; freq : uint32_t) is result : int; begin result := c_open(device, device_path, uint32_t(mode), bits, freq); case result is when 0 => -- Success -- return; when 1 => -- Invalid mode -- raise Error_Mode; when 2 => -- Invalid number of bits -- raise Error_Bits; when 3 => -- Invalid frequency -- raise Error_Freq; when 4 => -- Device Error -- raise Error_Device; when others => -- Undefined Error -- raise Error_Unknown; end case; end Open; -------------------------------------------------------------------------------- procedure Transfer(device : access SPI_Device; transmit_buffer : access uint8_t; receive_buffer : access uint8_t; c_delay : uint16_t; length : stddef_h.size_t) is result : int; begin result := c_transfer(device, transmit_buffer, receive_buffer, c_delay, length); case result is when 0 => -- Success -- return; when 5 => -- Transfer Error -- raise Error_Xfer; when others => -- Undefined Error -- raise Error_Unknown; end case; end Transfer; -------------------------------------------------------------------------------- procedure Close(device : access SPI_Device) is begin c_close(device); end Close; begin null; end SPI;
pragma License (Unrestricted); -- implementation unit with System.Storage_Elements; package System.Reference_Counting is pragma Pure; type Counter is mod 2 ** 32; for Counter'Size use 32; pragma Atomic (Counter); Static : constant := 2 ** 32 - 1; -- This should be untyped. -- A typed atomic constant disables static elaboration. type Data_Access is access all Counter; for Data_Access'Storage_Size use 0; function Shared (Data : not null Data_Access) return Boolean with Convention => Intrinsic; pragma Inline_Always (Shared); subtype Container is not null Data_Access; -- should be initialized with a sentinel procedure Adjust ( Target : not null access Container); procedure Assign ( Target : not null access Container; Source : not null access constant Container; Free : not null access procedure (Object : in out Data_Access)); procedure Clear ( Target : not null access Container; Free : not null access procedure (Object : in out Data_Access)); procedure Move ( Target : not null access Container; Source : not null access Container; Sentinel : not null Data_Access; Free : not null access procedure (Object : in out Data_Access)); subtype Length_Type is Storage_Elements.Storage_Count; procedure Unique ( Target : not null access Container; Target_Length : Length_Type; Target_Capacity : Length_Type; New_Length : Length_Type; New_Capacity : Length_Type; Sentinel : not null Data_Access; Reallocate : not null access procedure ( Target : aliased in out not null Data_Access; Length : Length_Type; -- copying length Max_Length : Length_Type; -- new length Capacity : Length_Type); Copy : not null access procedure ( Target : out not null Data_Access; Source : not null Data_Access; Length : Length_Type; -- copying length Max_Length : Length_Type; -- new length Capacity : Length_Type); Free : not null access procedure (Object : in out Data_Access)); procedure In_Place_Set_Length ( Target_Data : not null Data_Access; Target_Length : Length_Type; Target_Max_Length : aliased in out Length_Type; -- may be updated Target_Capacity : Length_Type; New_Length : Length_Type; Failure : out Boolean) -- reallocation is needed with Convention => Intrinsic; pragma Inline_Always (In_Place_Set_Length); end System.Reference_Counting;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . R E D _ B L A C K _ T R E E S . -- -- G E N E R I C _ S E T _ O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2005, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 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. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with System; use type System.Address; package body Ada.Containers.Red_Black_Trees.Generic_Set_Operations is ----------------------- -- Local Subprograms -- ----------------------- procedure Clear (Tree : in out Tree_Type); function Copy (Source : Tree_Type) return Tree_Type; ----------- -- Clear -- ----------- procedure Clear (Tree : in out Tree_Type) is pragma Assert (Tree.Busy = 0); pragma Assert (Tree.Lock = 0); Root : Node_Access := Tree.Root; begin Tree.Root := null; Tree.First := null; Tree.Last := null; Tree.Length := 0; Delete_Tree (Root); end Clear; ---------- -- Copy -- ---------- function Copy (Source : Tree_Type) return Tree_Type is Target : Tree_Type; begin if Source.Length = 0 then return Target; end if; Target.Root := Copy_Tree (Source.Root); Target.First := Tree_Operations.Min (Target.Root); Target.Last := Tree_Operations.Max (Target.Root); Target.Length := Source.Length; return Target; end Copy; ---------------- -- Difference -- ---------------- procedure Difference (Target : in out Tree_Type; Source : Tree_Type) is Tgt : Node_Access := Target.First; Src : Node_Access := Source.First; begin if Target'Address = Source'Address then if Target.Busy > 0 then raise Program_Error with "attempt to tamper with cursors (container is busy)"; end if; Clear (Target); return; end if; if Source.Length = 0 then return; end if; if Target.Busy > 0 then raise Program_Error with "attempt to tamper with cursors (container is busy)"; end if; loop if Tgt = null then return; end if; if Src = null then return; end if; if Is_Less (Tgt, Src) then Tgt := Tree_Operations.Next (Tgt); elsif Is_Less (Src, Tgt) then Src := Tree_Operations.Next (Src); else declare X : Node_Access := Tgt; begin Tgt := Tree_Operations.Next (Tgt); Tree_Operations.Delete_Node_Sans_Free (Target, X); Free (X); end; Src := Tree_Operations.Next (Src); end if; end loop; end Difference; function Difference (Left, Right : Tree_Type) return Tree_Type is Tree : Tree_Type; L_Node : Node_Access := Left.First; R_Node : Node_Access := Right.First; Dst_Node : Node_Access; begin if Left'Address = Right'Address then return Tree; -- Empty set end if; if Left.Length = 0 then return Tree; -- Empty set end if; if Right.Length = 0 then return Copy (Left); end if; loop if L_Node = null then return Tree; end if; if R_Node = null then while L_Node /= null loop Insert_With_Hint (Dst_Tree => Tree, Dst_Hint => null, Src_Node => L_Node, Dst_Node => Dst_Node); L_Node := Tree_Operations.Next (L_Node); end loop; return Tree; end if; if Is_Less (L_Node, R_Node) then Insert_With_Hint (Dst_Tree => Tree, Dst_Hint => null, Src_Node => L_Node, Dst_Node => Dst_Node); L_Node := Tree_Operations.Next (L_Node); elsif Is_Less (R_Node, L_Node) then R_Node := Tree_Operations.Next (R_Node); else L_Node := Tree_Operations.Next (L_Node); R_Node := Tree_Operations.Next (R_Node); end if; end loop; exception when others => Delete_Tree (Tree.Root); raise; end Difference; ------------------ -- Intersection -- ------------------ procedure Intersection (Target : in out Tree_Type; Source : Tree_Type) is Tgt : Node_Access := Target.First; Src : Node_Access := Source.First; begin if Target'Address = Source'Address then return; end if; if Target.Busy > 0 then raise Program_Error with "attempt to tamper with cursors (container is busy)"; end if; if Source.Length = 0 then Clear (Target); return; end if; while Tgt /= null and then Src /= null loop if Is_Less (Tgt, Src) then declare X : Node_Access := Tgt; begin Tgt := Tree_Operations.Next (Tgt); Tree_Operations.Delete_Node_Sans_Free (Target, X); Free (X); end; elsif Is_Less (Src, Tgt) then Src := Tree_Operations.Next (Src); else Tgt := Tree_Operations.Next (Tgt); Src := Tree_Operations.Next (Src); end if; end loop; while Tgt /= null loop declare X : Node_Access := Tgt; begin Tgt := Tree_Operations.Next (Tgt); Tree_Operations.Delete_Node_Sans_Free (Target, X); Free (X); end; end loop; end Intersection; function Intersection (Left, Right : Tree_Type) return Tree_Type is Tree : Tree_Type; L_Node : Node_Access := Left.First; R_Node : Node_Access := Right.First; Dst_Node : Node_Access; begin if Left'Address = Right'Address then return Copy (Left); end if; loop if L_Node = null then return Tree; end if; if R_Node = null then return Tree; end if; if Is_Less (L_Node, R_Node) then L_Node := Tree_Operations.Next (L_Node); elsif Is_Less (R_Node, L_Node) then R_Node := Tree_Operations.Next (R_Node); else Insert_With_Hint (Dst_Tree => Tree, Dst_Hint => null, Src_Node => L_Node, Dst_Node => Dst_Node); L_Node := Tree_Operations.Next (L_Node); R_Node := Tree_Operations.Next (R_Node); end if; end loop; exception when others => Delete_Tree (Tree.Root); raise; end Intersection; --------------- -- Is_Subset -- --------------- function Is_Subset (Subset : Tree_Type; Of_Set : Tree_Type) return Boolean is begin if Subset'Address = Of_Set'Address then return True; end if; if Subset.Length > Of_Set.Length then return False; end if; declare Subset_Node : Node_Access := Subset.First; Set_Node : Node_Access := Of_Set.First; begin loop if Set_Node = null then return Subset_Node = null; end if; if Subset_Node = null then return True; end if; if Is_Less (Subset_Node, Set_Node) then return False; end if; if Is_Less (Set_Node, Subset_Node) then Set_Node := Tree_Operations.Next (Set_Node); else Set_Node := Tree_Operations.Next (Set_Node); Subset_Node := Tree_Operations.Next (Subset_Node); end if; end loop; end; end Is_Subset; ------------- -- Overlap -- ------------- function Overlap (Left, Right : Tree_Type) return Boolean is L_Node : Node_Access := Left.First; R_Node : Node_Access := Right.First; begin if Left'Address = Right'Address then return Left.Length /= 0; end if; loop if L_Node = null or else R_Node = null then return False; end if; if Is_Less (L_Node, R_Node) then L_Node := Tree_Operations.Next (L_Node); elsif Is_Less (R_Node, L_Node) then R_Node := Tree_Operations.Next (R_Node); else return True; end if; end loop; end Overlap; -------------------------- -- Symmetric_Difference -- -------------------------- procedure Symmetric_Difference (Target : in out Tree_Type; Source : Tree_Type) is Tgt : Node_Access := Target.First; Src : Node_Access := Source.First; New_Tgt_Node : Node_Access; begin if Target.Busy > 0 then raise Program_Error with "attempt to tamper with cursors (container is busy)"; end if; if Target'Address = Source'Address then Clear (Target); return; end if; loop if Tgt = null then while Src /= null loop Insert_With_Hint (Dst_Tree => Target, Dst_Hint => null, Src_Node => Src, Dst_Node => New_Tgt_Node); Src := Tree_Operations.Next (Src); end loop; return; end if; if Src = null then return; end if; if Is_Less (Tgt, Src) then Tgt := Tree_Operations.Next (Tgt); elsif Is_Less (Src, Tgt) then Insert_With_Hint (Dst_Tree => Target, Dst_Hint => Tgt, Src_Node => Src, Dst_Node => New_Tgt_Node); Src := Tree_Operations.Next (Src); else declare X : Node_Access := Tgt; begin Tgt := Tree_Operations.Next (Tgt); Tree_Operations.Delete_Node_Sans_Free (Target, X); Free (X); end; Src := Tree_Operations.Next (Src); end if; end loop; end Symmetric_Difference; function Symmetric_Difference (Left, Right : Tree_Type) return Tree_Type is Tree : Tree_Type; L_Node : Node_Access := Left.First; R_Node : Node_Access := Right.First; Dst_Node : Node_Access; begin if Left'Address = Right'Address then return Tree; -- Empty set end if; if Right.Length = 0 then return Copy (Left); end if; if Left.Length = 0 then return Copy (Right); end if; loop if L_Node = null then while R_Node /= null loop Insert_With_Hint (Dst_Tree => Tree, Dst_Hint => null, Src_Node => R_Node, Dst_Node => Dst_Node); R_Node := Tree_Operations.Next (R_Node); end loop; return Tree; end if; if R_Node = null then while L_Node /= null loop Insert_With_Hint (Dst_Tree => Tree, Dst_Hint => null, Src_Node => L_Node, Dst_Node => Dst_Node); L_Node := Tree_Operations.Next (L_Node); end loop; return Tree; end if; if Is_Less (L_Node, R_Node) then Insert_With_Hint (Dst_Tree => Tree, Dst_Hint => null, Src_Node => L_Node, Dst_Node => Dst_Node); L_Node := Tree_Operations.Next (L_Node); elsif Is_Less (R_Node, L_Node) then Insert_With_Hint (Dst_Tree => Tree, Dst_Hint => null, Src_Node => R_Node, Dst_Node => Dst_Node); R_Node := Tree_Operations.Next (R_Node); else L_Node := Tree_Operations.Next (L_Node); R_Node := Tree_Operations.Next (R_Node); end if; end loop; exception when others => Delete_Tree (Tree.Root); raise; end Symmetric_Difference; ----------- -- Union -- ----------- procedure Union (Target : in out Tree_Type; Source : Tree_Type) is Hint : Node_Access; procedure Process (Node : Node_Access); pragma Inline (Process); procedure Iterate is new Tree_Operations.Generic_Iteration (Process); ------------- -- Process -- ------------- procedure Process (Node : Node_Access) is begin Insert_With_Hint (Dst_Tree => Target, Dst_Hint => Hint, Src_Node => Node, Dst_Node => Hint); end Process; -- Start of processing for Union begin if Target'Address = Source'Address then return; end if; if Target.Busy > 0 then raise Program_Error with "attempt to tamper with cursors (container is busy)"; end if; Iterate (Source); end Union; function Union (Left, Right : Tree_Type) return Tree_Type is begin if Left'Address = Right'Address then return Copy (Left); end if; if Left.Length = 0 then return Copy (Right); end if; if Right.Length = 0 then return Copy (Left); end if; declare Tree : Tree_Type := Copy (Left); Hint : Node_Access; procedure Process (Node : Node_Access); pragma Inline (Process); procedure Iterate is new Tree_Operations.Generic_Iteration (Process); ------------- -- Process -- ------------- procedure Process (Node : Node_Access) is begin Insert_With_Hint (Dst_Tree => Tree, Dst_Hint => Hint, Src_Node => Node, Dst_Node => Hint); end Process; -- Start of processing for Union begin Iterate (Right); return Tree; exception when others => Delete_Tree (Tree.Root); raise; end; end Union; end Ada.Containers.Red_Black_Trees.Generic_Set_Operations;
with AdaBase; with Connect; with Ada.Text_IO; with AdaBase.Logger.Facility; procedure Wipe_Out is package CON renames Connect; package TIO renames Ada.Text_IO; package ALF renames AdaBase.Logger.Facility; numrows : AdaBase.Affected_Rows; bfast : constant String := "breakfast"; cmd1 : constant String := "CREATE TABLE " & bfast & " AS SELECT id, fruit FROM fruits"; begin CON.DR.command_standard_logger (device => ALF.screen, action => ALF.attach); CON.connect_database; -- delete breakfast table if it already exists -- No need to set cascade; it illustrates logging on MySQL (only) CON.DR.query_drop_table (tables => bfast, cascade => True, when_exists => True); -- create breakfast table numrows := CON.DR.execute (sql => cmd1); -- clear contents of breakfast table CON.DR.query_clear_table (table => bfast); -- drop breakfast table again (minimal arguments) CON.DR.query_drop_table (tables => bfast); CON.DR.commit; CON.DR.disconnect; end Wipe_Out;
package Planets.Earth is pragma Preelaborate; -- Based on WGS 84. See https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84 Planet : constant Planet_Characteristics := (Axial_Tilt_Deg => 23.439_2811, Mass_Kg => 5.972_37e24, Sidereal => 23.0 * 3600.0 + 56.0 * 60.0 + 4.0905, Flattening => 1.0 / 298.257_223_563, Semi_Major_Axis => 6_378_137.0); end Planets.Earth;
with Ada.Text_IO; use Ada.Text_IO; procedure Test is function Oups(N: Integer) return Integer is L : Integer := Oups(N); begin return 0; end; begin New_Line; end;
----------------------------------------------------------------------- -- Util.Beans.Objects.Records -- Generic Typed Data Representation -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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. ----------------------------------------------------------------------- generic type Element_Type is private; package Util.Beans.Objects.Records is type Element_Type_Access is access all Element_Type; -- Create an object which holds a record of the type <b>Element_Type</b>. function Create return Object; -- Create an object which is initialized with the given value. function To_Object (Value : in Element_Type) return Object; -- Returns the element function To_Element (Value : in Object) return Element_Type; -- Returns an access to the element. function To_Element_Access (Value : in Object) return Element_Type_Access; private type Element_Proxy is new Proxy with record Value : aliased Element_Type; end record; end Util.Beans.Objects.Records;
with Ada.Exceptions; with Ada.Text_IO; with App; --with Interfaces.C; --with System; procedure Future_Test is The_App : App.Object; -- function signal(sig: in interfaces.c.int; -- handler: system.address) -- return system.address; -- pragma Import(C, signal, "signal"); -- -- oldhandler: system.address; begin -- For debugging purposes only. -- This will disable default signal handling in the GNAT Runtime, -- in order to produce a corefile instead of STORAGE_ERROR with empty trace. --oldhandler := signal(8, system.null_address); --oldhandler := signal(10, system.null_address); --oldhandler := signal(11, system.null_address); -- for i in 1..1000000 loop The_App.Show_Search("foo"); -- end loop; exception when e : others => Ada.Text_IO.Put_Line("ERROR: " & Ada.Exceptions.Exception_Information(e)); end Future_Test;
-------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. (gh+owm@heisenbug.eu) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. -------------------------------------------------------------------------------- pragma License (Unrestricted); -------------------------------------------------------------------------------- --% @summary --% Open_Weather_Map.API.Service.Group -- --% @description --% Provides the query object implementing a group query (i.e. a list of Ids for --% which weather information shall be retrieved). -------------------------------------------------------------------------------- package Open_Weather_Map.API.Service.Group is ----------------------------------------------------------------------------- -- API: Current weather data (by list of city IDs) ----------------------------------------------------------------------------- type T is new Service.T with private; ----------------------------------------------------------------------------- -- Initialize ----------------------------------------------------------------------------- procedure Initialize (Self : out T; Configuration : in GNATCOLL.JSON.JSON_Value; Connection : not null Client.T_Access; Max_Cache_Interval : in Ada.Real_Time.Time_Span := Default_Cache_Interval; Ids : in Group_List); --% Initializes the group query instance. -- --% @param Self --% The instance of the group query to initialize. -- --% @param Configuration --% Used to configure necessary internals (proxy server etc.). -- --% @param Connection --% Access to the connection object to be used for client server --% communication. -- --% @param Max_Cache_Interval --% Denotes the maximum frequency of actual queries sent to the server. -- --% @param Ids --% The list of location ids to be queried. private type T is new Service.T with null record; ----------------------------------------------------------------------------- -- Decode_Response ----------------------------------------------------------------------------- overriding function Decode_Response (Self : in T; Root : in GNATCOLL.JSON.JSON_Value) return Data_Set; --% Decodes a group query response. -- --% @param Self --% The group query instance. -- --% @param Root --% The root of the JSON response sent by the server. -- --% @return --% The data set decoded from the JSON data in Root. end Open_Weather_Map.API.Service.Group;
package body Crypto is use type Ada.Streams.Stream_Element; procedure Value ( Image : String; Result : out Ada.Streams.Stream_Element_Array) is function Digit (C : Character) return Ada.Streams.Stream_Element is begin if C in '0' .. '9' then return Character'Pos (C) - Character'Pos ('0'); elsif C in 'a' .. 'f' then return Character'Pos (C) - Character'Pos ('a') + 10; elsif C in 'A' .. 'F' then return Character'Pos (C) - Character'Pos ('A') + 10; else raise Constraint_Error; end if; end Digit; begin for I in Result'Range loop declare Hi : constant Character := Image (2 * Integer (I) + 1); Lo : constant Character := Image (2 * Integer (I) + 2); begin Result (I) := Digit (Hi) * 16 + Digit (Lo); end; end loop; end Value; procedure Image ( Value : Ada.Streams.Stream_Element_Array; Result : out String) is Hex_Tab : constant array (0 .. 15) of Character := "0123456789abcdef"; begin for I in Value'Range loop declare Item : constant Ada.Streams.Stream_Element := Value (I); begin Result (2 * Integer (I) + 1) := Hex_Tab (Natural (Item / 16)); Result (2 * Integer (I) + 2) := Hex_Tab (Natural (Item mod 16)); end; end loop; end Image; end Crypto;
-- convert UCD/extracted/DerivedGeneralCategory.txt -- bin/ucd_generalcategory $UCD/extracted/DerivedGeneralCategory.txt > ../source/strings/a-ucgeca.ads with Ada.Command_Line; use Ada.Command_Line; with Ada.Containers.Doubly_Linked_Lists; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Maps; use Ada.Strings.Maps; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; procedure ucd_generalcategory is Hexadecimal_Digit_Set : constant Character_Set := To_Set ("0123456789ABCDEF"); Letter_Set : constant Character_Set := To_Set (Character_Ranges'(('A', 'Z'), ('a', 'z'))); function Value (S : String) return Wide_Wide_Character is Img : constant String := "Hex_" & (1 .. 8 - S'Length => '0') & S; begin return Wide_Wide_Character'Value (Img); end Value; procedure Put_16 (Item : Integer) is begin if Item >= 16#10000# then Put (Item, Width => 1, Base => 16); else declare S : String (1 .. 8); -- "16#XXXX#" begin Put (S, Item, Base => 16); S (1) := '1'; S (2) := '6'; S (3) := '#'; for I in reverse 4 .. 6 loop if S (I) = '#' then S (4 .. I) := (others => '0'); exit; end if; end loop; Put (S); end; end if; end Put_16; type Bit is (In_16, In_17, In_32); function Get_Bit (C : Wide_Wide_Character) return Bit is begin if C > Wide_Wide_Character'Val (16#1FFFF#) then return In_32; elsif C > Wide_Wide_Character'Val (16#FFFF#) then return In_17; else return In_16; end if; end Get_Bit; type Range_Item is record First : Wide_Wide_Character; Last : Wide_Wide_Character; end record; package Range_Lists is new Ada.Containers.Doubly_Linked_Lists (Range_Item); use Range_Lists; type Nums_Type is array (Bit, Boolean) of Natural; type Category_Item is record Name : Ada.Strings.Unbounded.Unbounded_String; Code_Points : aliased Range_Lists.List; Total_CP_Num : Natural; Total_Set_Num : Natural; Nums : Nums_Type; end record; package Category_Lists is new Ada.Containers.Doubly_Linked_Lists (Category_Item); use Category_Lists; function Find (Table : Category_Lists.List; Category : String) return Category_Lists.Cursor is I : Category_Lists.Cursor := First (Table); begin while Has_Element (I) loop if Table.Constant_Reference (I).Element.Name = Category then return I; end if; I := Next (I); end loop; return Category_Lists.No_Element; end Find; Table : aliased Category_Lists.List; begin declare File : Ada.Text_IO.File_Type; begin Open (File, In_File, Argument (1)); while not End_Of_File (File) loop declare Line : constant String := Get_Line (File); P : Positive := Line'First; N : Natural; Token_First : Positive; Token_Last : Natural; First, Last : Wide_Wide_Character; Category : Ada.Strings.Unbounded.Unbounded_String; Category_Pos : Category_Lists.Cursor; begin if Line'Length = 0 or else Line (P) = '#' then null; -- comment else Find_Token ( Line (P .. Line'Last), Hexadecimal_Digit_Set, Inside, Token_First, Token_Last); if Token_First /= P then raise Data_Error with Line & " -- A"; end if; First := Value (Line (Token_First .. Token_Last)); P := Token_Last + 1; if Line (P) = '.' and then Line (P + 1) = '.' then P := P + 2; Find_Token ( Line (P .. Line'Last), Hexadecimal_Digit_Set, Inside, Token_First, Token_Last); if Token_First /= P then raise Data_Error with Line & " -- B"; end if; Last := Value (Line (Token_First .. Token_Last)); P := Token_Last + 1; else Last := First; end if; N := Index_Non_Blank (Line (P .. Line'Last)); if N = 0 or else Line (N) /= ';' then raise Data_Error with Line & " -- C"; end if; P := N + 1; -- skip ';' N := Index_Non_Blank (Line (P .. Line'Last)); if N = 0 then raise Data_Error with Line & " -- D"; end if; P := N; Find_Token ( Line (P .. Line'Last), Letter_Set, Inside, Token_First, Token_Last); if Token_First /= P then raise Data_Error with Line & " -- E"; end if; Category := To_Unbounded_String (Line (Token_First .. Token_Last)); Category_Pos := Find (Table, To_String (Category)); if not Has_Element (Category_Pos) then Insert ( Table, Before => Category_Lists.No_Element, Position => Category_Pos); Table.Reference (Category_Pos).Element.Name := Category; end if; Append ( Table.Reference (Category_Pos).Element.Code_Points, (First => First, Last => Last)); end if; end; end loop; Close (File); end; declare I : Category_Lists.Cursor := First (Table); begin while Has_Element (I) loop declare Cat : Category_Item renames Table.Reference (I).Element.all; begin Cat.Total_CP_Num := 0; Cat.Total_Set_Num := 0; for J in Bit loop for K in Boolean loop Cat.Nums (J, K) := 0; end loop; end loop; declare J : Range_Lists.Cursor := First (Cat.Code_Points); begin while Has_Element (J) loop declare R : Range_Item renames Cat.Code_Points.Constant_Reference (J).Element.all; B : Bit := Get_Bit (R.Last); S : Boolean := R.First /= R.Last; begin Cat.Nums (B, S) := Cat.Nums (B, S) + 1; Cat.Total_CP_Num := Cat.Total_CP_Num + ( Wide_Wide_Character'Pos (R.Last) - Wide_Wide_Character'Pos (R.First) + 1); Cat.Total_Set_Num := Cat.Total_Set_Num + 1; end; J := Next (J); end loop; end; end; I := Next (I); end loop; end; Put_Line ("pragma License (Unrestricted);"); Put_Line ("-- implementation unit, translated from DerivedGeneralCategory.txt"); Put_Line ("package Ada.UCD.General_Category is"); Put_Line (" pragma Pure;"); New_Line; declare I : Category_Lists.Cursor := First (Table); begin while Has_Element (I) loop declare Cat : Category_Item renames Table.Reference (I).Element.all; begin Put (" "); Put (To_String (Cat.Name)); Put ("_Total : constant := "); Put (Cat.Total_CP_Num, Width => 1); Put (";"); New_Line; Put (" "); Put (To_String (Cat.Name)); Put ("_Range_Length : constant := "); Put (Cat.Total_Set_Num, Width => 1); Put (";"); New_Line; end; I := Next (I); end loop; end; New_Line; Put_Line (" Empty_XXXXx1 : constant UCS_2_Array (1 .. 0) := (others => 0);"); Put_Line (" Empty_XXXXx2 : constant Set_16_Type (1 .. 0) := (others => (0, 0));"); Put_Line (" Empty_1XXXXx1 : UCS_2_Array renames Empty_XXXXx1;"); Put_Line (" Empty_1XXXXx2 : Set_16_Type renames Empty_XXXXx2;"); Put_Line (" Empty_XXXXXXXXx1 : constant UCS_4_Array (1 .. 0) := (others => 0);"); Put_Line (" Empty_XXXXXXXXx2 : constant Set_32_Type (1 .. 0) := (others => (0, 0));"); New_Line; declare I : Category_Lists.Cursor := First (Table); begin while Has_Element (I) loop declare Cat : Category_Item renames Table.Reference (I).Element.all; begin for B in Bit loop for S in Boolean loop Put (" "); Put (To_String (Cat.Name)); Put ("_Table_"); case B is when In_32 => Put ("XXXXXXXX"); when In_17 => Put ("1XXXX"); when In_16 => Put ("XXXX"); end case; if S then Put ("x2"); else Put ("x1"); end if; Put (" : "); if Cat.Nums (B, S) > 0 then Put ("constant "); end if; if S then case B is when In_32 => Put ("Set_32_Type"); when In_16 | In_17 => Put ("Set_16_Type"); end case; else case B is when In_32 => Put ("UCS_4_Array"); when In_16 | In_17 => Put ("UCS_2_Array"); end case; end if; if Cat.Nums (B, S) = 0 then Put (" renames Empty_"); case B is when In_32 => Put ("XXXXXXXX"); when In_17 => Put ("1XXXX"); when In_16 => Put ("XXXX"); end case; if S then Put ("x2"); else Put ("x1"); end if; Put (";"); New_Line; else Put (" (1 .. "); Put (Cat.Nums (B, S), Width => 1); Put (") := ("); New_Line; declare J : Range_Lists.Cursor := First (Cat.Code_Points); Second : Boolean := False; begin while Has_Element (J) loop declare R : Range_Item renames Cat.Code_Points.Constant_Reference (J).Element.all; Item_B : Bit := Get_Bit (R.Last); Item_S : Boolean := R.First /= R.Last; Offset : Integer := 0; begin if Item_B = B and then Item_S = S then if B = In_17 then Offset := 16#10000#; end if; if Second then Put (","); New_Line; end if; Put (" "); if Cat.Nums (B, S) = 1 then Put ("1 => "); end if; if S then Put ("("); Put_16 ( Wide_Wide_Character'Pos (R.First) - Offset); Put (", "); Put_16 ( Wide_Wide_Character'Pos (R.Last) - Offset); Put (")"); else Put_16 ( Wide_Wide_Character'Pos (R.First) - Offset); end if; Second := True; end if; end; J := Next (J); end loop; end; Put (");"); New_Line; end if; New_Line; end loop; end loop; end; I := Next (I); end loop; end; Put_Line ("end Ada.UCD.General_Category;"); end ucd_generalcategory;
-- Institution: Technische Universität München -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- -- Authors: Emanuel Regnath (emanuel.regnath@tum.de) pragma SPARK_Mode (Off); with STM32.USARTs; with STM32.Device; with HIL.Devices; use HIL.Devices; -- @summary -- Target-specific mapping for HIL of UART package body HIL.UART with SPARK_Mode => Off is procedure configure is begin -- USART 1 (wifi) STM32.USARTs.Enable (STM32.Device.USART_1); STM32.USARTs.Set_Stop_Bits (STM32.Device.USART_1, STM32.USARTs.Stopbits_1); STM32.USARTs.Set_Word_Length (STM32.Device.USART_1, STM32.USARTs.Word_Length_8); STM32.USARTs.Set_Parity (STM32.Device.USART_1, STM32.USARTs.No_Parity); STM32.USARTs.Set_Baud_Rate (STM32.Device.USART_1, 115_200); STM32.USARTs.Set_Oversampling_Mode (STM32.Device.USART_1, STM32.USARTs.Oversampling_By_16); STM32.USARTs.Set_Mode (STM32.Device.USART_1, STM32.USARTs.Tx_Rx_Mode); STM32.USARTs.Set_Flow_Control (STM32.Device.USART_1, STM32.USARTs.No_Flow_Control); -- USART 2 (tele 1) STM32.USARTs.Enable (STM32.Device.USART_2); STM32.USARTs.Set_Stop_Bits (STM32.Device.USART_2, STM32.USARTs.Stopbits_1); STM32.USARTs.Set_Word_Length (STM32.Device.USART_2, STM32.USARTs.Word_Length_8); STM32.USARTs.Set_Parity (STM32.Device.USART_2, STM32.USARTs.No_Parity); STM32.USARTs.Set_Baud_Rate (STM32.Device.USART_2, 57_600); STM32.USARTs.Set_Oversampling_Mode (STM32.Device.USART_2, STM32.USARTs.Oversampling_By_16); STM32.USARTs.Set_Mode (STM32.Device.USART_2, STM32.USARTs.Tx_Rx_Mode); STM32.USARTs.Set_Flow_Control (STM32.Device.USART_2, STM32.USARTs.No_Flow_Control); -- USART 3 (tele 2) STM32.USARTs.Enable (STM32.Device.USART_3); STM32.USARTs.Set_Stop_Bits (STM32.Device.USART_3, STM32.USARTs.Stopbits_1); STM32.USARTs.Set_Word_Length (STM32.Device.USART_3, STM32.USARTs.Word_Length_8); STM32.USARTs.Set_Parity (STM32.Device.USART_3, STM32.USARTs.No_Parity); STM32.USARTs.Set_Baud_Rate (STM32.Device.USART_3, 115_200); STM32.USARTs.Set_Oversampling_Mode (STM32.Device.USART_3, STM32.USARTs.Oversampling_By_16); STM32.USARTs.Set_Mode (STM32.Device.USART_3, STM32.USARTs.Tx_Rx_Mode); STM32.USARTs.Set_Flow_Control (STM32.Device.USART_3, STM32.USARTs.No_Flow_Control); -- UART 4 (GPS) STM32.USARTs.Enable (STM32.Device.UART_4); STM32.USARTs.Set_Stop_Bits (STM32.Device.UART_4, STM32.USARTs.Stopbits_1); STM32.USARTs.Set_Word_Length (STM32.Device.UART_4, STM32.USARTs.Word_Length_8); STM32.USARTs.Set_Parity (STM32.Device.UART_4, STM32.USARTs.No_Parity); STM32.USARTs.Set_Baud_Rate (STM32.Device.UART_4, 38_400); STM32.USARTs.Set_Oversampling_Mode (STM32.Device.UART_4, STM32.USARTs.Oversampling_By_16); STM32.USARTs.Set_Mode (STM32.Device.UART_4, STM32.USARTs.Tx_Rx_Mode); STM32.USARTs.Set_Flow_Control (STM32.Device.UART_4, STM32.USARTs.No_Flow_Control); -- USART 7 (Console) STM32.USARTs.Enable (STM32.Device.USART_7); STM32.USARTs.Set_Stop_Bits (STM32.Device.USART_7, STM32.USARTs.Stopbits_1); STM32.USARTs.Set_Word_Length (STM32.Device.USART_7, STM32.USARTs.Word_Length_8); STM32.USARTs.Set_Parity (STM32.Device.USART_7, STM32.USARTs.No_Parity); STM32.USARTs.Set_Baud_Rate (STM32.Device.USART_7, 115_200); STM32.USARTs.Set_Oversampling_Mode (STM32.Device.USART_7, STM32.USARTs.Oversampling_By_16); STM32.USARTs.Set_Mode (STM32.Device.USART_7, STM32.USARTs.Tx_Rx_Mode); STM32.USARTs.Set_Flow_Control (STM32.Device.USART_7, STM32.USARTs.No_Flow_Control); end configure; -- writes devices by internally mapping to U(S)ART ports procedure write (Device : in Device_ID_Type; Data : in Data_Type) is procedure write_to_port (port : in out STM32.USARTs.USART; Data : in Data_Type) is flag : constant STM32.USARTS.USART_Status_Flag := STM32.USARTs.USART_Status_Flag'First; -- ret : Boolean := STM32.USARTS.Status (port, flag); begin for i in Data'Range loop STM32.USARTs.Transmit (port, HAL.UInt9 (Data (i))); end loop; end write_to_port; begin case (Device) is when CONSOLE => write_to_port (STM32.Device.USART_7, Data); when TELE1 => write_to_port (STM32.Device.USART_2, Data); when TELE2 => write_to_port (STM32.Device.USART_3, Data); when WIFI => write_to_port (STM32.Device.USART_1, Data); when GPS => write_to_port (STM32.Device.UART_4, Data); end case; end write; -- reads devices by internally mapping to U(S)ART ports procedure read (Device : in Device_ID_Type; Data : out Data_Type; n_read : out Natural) is procedure read_from_port (port : in out STM32.USARTs.USART; Data : out Data_Type; n_read : out Natural) is begin for i in Data'Range loop STM32.USARTs.Receive (port, HAL.UInt9 (Data (i))); end loop; n_read := Data'Length; end read_from_port; begin case (Device) is when CONSOLE => read_from_port (STM32.Device.USART_7, Data, n_read); when TELE1 => read_from_port (STM32.Device.USART_2, Data, n_read); when TELE2 => read_from_port (STM32.Device.USART_3, Data, n_read); when WIFI => read_from_port (STM32.Device.USART_1, Data, n_read); when GPS => read_from_port (STM32.Device.UART_4, Data, n_read); end case; end read; function toData_Type( Message : String ) return Data_Type is Bytes : Data_Type( Message'Range ) := (others => 0); begin for pos in Message'Range loop Bytes(pos) := Character'Pos( Message(pos) ); end loop; return Bytes; end toData_Type; end HIL.UART;
pragma Ada_2012; package body DDS.Request_Reply.Typed_Requester_Generic is ----------------------------- -- Get_Request_Data_Writer -- ----------------------------- function Get_Request_Data_Writer (Self : not null access Ref) return DDS.DataWriter.Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "Get_Request_Data_Writer unimplemented"); return raise Program_Error with "Unimplemented function Get_Request_Data_Writer"; end Get_Request_Data_Writer; --------------------------- -- Get_Reply_Data_Reader -- --------------------------- function Get_Reply_Data_Reader (Self : not null access Ref) return DDS.DataReader.Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "Get_Reply_Data_Reader unimplemented"); return raise Program_Error with "Unimplemented function Get_Reply_Data_Reader"; end Get_Reply_Data_Reader; ------------ -- Create -- ------------ function Create (Participant : DDS.DomainParticipant.Ref_Access; Service_Name : DDS.String; Qos_Library_Name : DDS.String; Qos_Profile_Name : DDS.String; Publisher : DDS.Publisher.Ref_Access := null; Subscriber : DDS.Subscriber.Ref_Access := null; A_Listner : Request_Listeners.Ref_Access := null; Mask : DDS.StatusMask := DDS.STATUS_MASK_NONE) return Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "Create unimplemented"); return raise Program_Error with "Unimplemented function Create"; end Create; ------------ -- Create -- ------------ function Create (Participant : DDS.DomainParticipant.Ref_Access; Request_Topic_Name : DDS.String; Reply_Topic_Name : DDS.String; Qos_Library_Name : DDS.String; Qos_Profile_Name : DDS.String; Publisher : DDS.Publisher.Ref_Access := null; Subscriber : DDS.Subscriber.Ref_Access := null; A_Listner : Request_Listeners.Ref_Access := null; Mask : DDS.StatusMask := DDS.STATUS_MASK_NONE) return Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "Create unimplemented"); return raise Program_Error with "Unimplemented function Create"; end Create; ------------ -- Create -- ------------ function Create (Participant : DDS.DomainParticipant.Ref_Access; Service_Name : DDS.String; Datawriter_Qos : DDS.DataWriterQos; Datareader_Qos : DDS.DataReaderQos; Publisher : DDS.Publisher.Ref_Access := null; Subscriber : DDS.Subscriber.Ref_Access := null; A_Listner : Request_Listeners.Ref_Access := null; Mask : DDS.StatusMask := DDS.STATUS_MASK_NONE) return Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "Create unimplemented"); return raise Program_Error with "Unimplemented function Create"; end Create; ------------ -- Create -- ------------ function Create (Participant : DDS.DomainParticipant.Ref_Access; Request_Topic_Name : DDS.String; Reply_Topic_Name : DDS.String; Datawriter_Qos : DDS.DataWriterQos; Datareader_Qos : DDS.DataReaderQos; Publisher : DDS.Publisher.Ref_Access := null; Subscriber : DDS.Subscriber.Ref_Access := null; A_Listner : Request_Listeners.Ref_Access := null; Mask : DDS.StatusMask := DDS.STATUS_MASK_NONE) return Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "Create unimplemented"); return raise Program_Error with "Unimplemented function Create"; end Create; ------------ -- Delete -- ------------ procedure Delete (Self : in out Ref_Access) is begin pragma Compile_Time_Warning (Standard.True, "Delete unimplemented"); raise Program_Error with "Unimplemented procedure Delete"; end Delete; ------------------ -- Send_Request -- ------------------ function Send_Request (Self : not null access Ref; Data : Request_DataWriters.Treats.Data_Type) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Send_Request unimplemented"); return raise Program_Error with "Unimplemented function Send_Request"; end Send_Request; ------------------ -- Send_Request -- ------------------ procedure Send_Request (Self : not null access Ref; Data : Request_DataWriters.Treats.Data_Type) is begin pragma Compile_Time_Warning (Standard.True, "Send_Request unimplemented"); raise Program_Error with "Unimplemented procedure Send_Request"; end Send_Request; ------------------ -- Send_Request -- ------------------ function Send_Request (Self : not null access Ref; Data : Request_DataWriters.Treats.Data_Type) return Reply_DataReaders.Treats.Data_Type is begin pragma Compile_Time_Warning (Standard.True, "Send_Request unimplemented"); return raise Program_Error with "Unimplemented function Send_Request"; end Send_Request; ------------------ -- Send_Request -- ------------------ procedure Send_Request (Self : not null access Ref; Request : access Request_DataWriters.Treats.Data_Type) is begin pragma Compile_Time_Warning (Standard.True, "Send_Request unimplemented"); raise Program_Error with "Unimplemented procedure Send_Request"; end Send_Request; ------------------ -- Send_Request -- ------------------ function Send_Request (Self : not null access Ref; Request : access Request_DataWriters.Treats.Data_Type) return Reply_DataReaders.Container is begin pragma Compile_Time_Warning (Standard.True, "Send_Request unimplemented"); return raise Program_Error with "Unimplemented function Send_Request"; end Send_Request; ------------------ -- Send_Request -- ------------------ function Send_Request (Self : not null access Ref; Request : Request_DataWriters.Treats.Data_Type) return Reply_DataReaders .Container is begin pragma Compile_Time_Warning (Standard.True, "Send_Request unimplemented"); return raise Program_Error with "Unimplemented function Send_Request"; end Send_Request; ------------------ -- Send_Request -- ------------------ function Send_Request (Self : not null access Ref; Request : access Request_DataWriters.Treats.Data_Type; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T := DURATION_INFINITE) return Reply_DataReaders .Container is begin pragma Compile_Time_Warning (Standard.True, "Send_Request unimplemented"); return raise Program_Error with "Unimplemented function Send_Request"; end Send_Request; ------------------ -- Send_Request -- ------------------ procedure Send_Request (Self : not null access Ref; Request : access Request_DataWriters.Treats.Data_Type; Request_Info : DDS.WriteParams_T) is begin pragma Compile_Time_Warning (Standard.True, "Send_Request unimplemented"); raise Program_Error with "Unimplemented procedure Send_Request"; end Send_Request; ------------------- -- Receive_Reply -- ------------------- function Receive_Reply (Self : not null access Ref; Replies : aliased Reply_DataReaders.Treats.Data_Type; Info_Seq : not null access DDS.SampleInfo_Seq.Sequence; Timeout : DDS.Duration_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Receive_Reply unimplemented"); return raise Program_Error with "Unimplemented function Receive_Reply"; end Receive_Reply; ------------------- -- Receive_Reply -- ------------------- function Receive_Reply (Self : not null access Ref; Timeout : DDS.Duration_T) return Reply_DataReaders.Container is begin pragma Compile_Time_Warning (Standard.True, "Receive_Reply unimplemented"); return raise Program_Error with "Unimplemented function Receive_Reply"; end Receive_Reply; --------------------- -- Receive_Replies -- --------------------- function Receive_Replies (Self : not null access Ref; Replies : not null Reply_DataReaders.Treats.Data_Sequences .Sequence_Access; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Receive_Replies unimplemented"); return raise Program_Error with "Unimplemented function Receive_Replies"; end Receive_Replies; --------------------- -- Receive_Replies -- --------------------- procedure Receive_Replies (Self : not null access Ref; Replies : not null Reply_DataReaders.Treats.Data_Sequences .Sequence_Access; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T) is begin pragma Compile_Time_Warning (Standard.True, "Receive_Replies unimplemented"); raise Program_Error with "Unimplemented procedure Receive_Replies"; end Receive_Replies; --------------------- -- Receive_Replies -- --------------------- function Receive_Replies (Self : not null access Ref; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T) return Reply_DataReaders.Container is begin pragma Compile_Time_Warning (Standard.True, "Receive_Replies unimplemented"); return raise Program_Error with "Unimplemented function Receive_Replies"; end Receive_Replies; --------------------- -- Receive_Replies -- --------------------- function Receive_Replies (Self : not null access Ref; Replies : not null Reply_DataReaders.Treats.Data_Sequences .Sequence_Access; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : Duration) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Receive_Replies unimplemented"); return raise Program_Error with "Unimplemented function Receive_Replies"; end Receive_Replies; --------------------- -- Receive_Replies -- --------------------- function Receive_Replies (Self : not null access Ref; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : Duration) return Reply_DataReaders .Container is begin pragma Compile_Time_Warning (Standard.True, "Receive_Replies unimplemented"); return raise Program_Error with "Unimplemented function Receive_Replies"; end Receive_Replies; ---------------- -- Take_Reply -- ---------------- function Take_Reply (Self : not null access Ref; Replies : aliased Reply_DataReaders.Treats.Data_Type; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Timeout : DDS.Duration_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Take_Reply unimplemented"); return raise Program_Error with "Unimplemented function Take_Reply"; end Take_Reply; ------------------ -- Take_Replies -- ------------------ function Take_Replies (Self : not null access Ref; Replies : not null Reply_DataReaders.Treats.Data_Sequences .Sequence_Access; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Take_Replies unimplemented"); return raise Program_Error with "Unimplemented function Take_Replies"; end Take_Replies; ------------------ -- Take_Replies -- ------------------ function Take_Replies (Self : not null access Ref; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T) return Reply_DataReaders.Container is begin pragma Compile_Time_Warning (Standard.True, "Take_Replies unimplemented"); return raise Program_Error with "Unimplemented function Take_Replies"; end Take_Replies; ------------------------------------ -- Take_Reply_For_Related_Request -- ------------------------------------ function Take_Reply_For_Related_Request (Self : not null access Ref; Replies : aliased Reply_DataReaders.Treats.Data_Type; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Related_Request_Info : not null access DDS.SampleIdentity_T) return DDS .ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Take_Reply_For_Related_Request unimplemented"); return raise Program_Error with "Unimplemented function Take_Reply_For_Related_Request"; end Take_Reply_For_Related_Request; -------------------------------------- -- Take_Replies_For_Related_Request -- -------------------------------------- function Take_Replies_For_Related_Request (Self : not null access Ref; Replies : not null Reply_DataReaders.Treats.Data_Sequences .Sequence_Access; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Related_Request_Info : not null access DDS.SampleIdentity_T) return DDS .ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Take_Replies_For_Related_Request unimplemented"); return raise Program_Error with "Unimplemented function Take_Replies_For_Related_Request"; end Take_Replies_For_Related_Request; -------------------------------------- -- Take_Replies_For_Related_Request -- -------------------------------------- function Take_Replies_For_Related_Request (Self : not null access Ref; Related_Request_Info : not null access DDS.SampleIdentity_T) return Reply_DataReaders.Container is begin pragma Compile_Time_Warning (Standard.True, "Take_Replies_For_Related_Request unimplemented"); return raise Program_Error with "Unimplemented function Take_Replies_For_Related_Request"; end Take_Replies_For_Related_Request; ---------------- -- Read_Reply -- ---------------- function Read_Reply (Self : not null access Ref; Replies : aliased Reply_DataReaders.Treats.Data_Type; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Timeout : DDS.Duration_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Read_Reply unimplemented"); return raise Program_Error with "Unimplemented function Read_Reply"; end Read_Reply; ------------------ -- Read_Replies -- ------------------ function Read_Replies (Self : not null access Ref; Replies : not null Reply_DataReaders.Treats.Data_Sequences .Sequence_Access; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Read_Replies unimplemented"); return raise Program_Error with "Unimplemented function Read_Replies"; end Read_Replies; ------------------ -- Read_Replies -- ------------------ function Read_Replies (Self : not null access Ref; Min_Reply_Count : DDS.Natural; Max_Reply_Count : DDS.long; Timeout : DDS.Duration_T) return Reply_DataReaders.Container'Class is begin pragma Compile_Time_Warning (Standard.True, "Read_Replies unimplemented"); return raise Program_Error with "Unimplemented function Read_Replies"; end Read_Replies; ------------------------------------ -- Read_Reply_For_Related_Request -- ------------------------------------ function Read_Reply_For_Related_Request (Self : not null access Ref; Replies : aliased Reply_DataReaders.Treats.Data_Type; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Related_Request_Info : DDS.SampleIdentity_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Read_Reply_For_Related_Request unimplemented"); return raise Program_Error with "Unimplemented function Read_Reply_For_Related_Request"; end Read_Reply_For_Related_Request; -------------------------------------- -- Read_Replies_For_Related_Request -- -------------------------------------- function Read_Replies_For_Related_Request (Self : not null access Ref; Replies : not null Reply_DataReaders.Treats.Data_Sequences .Sequence_Access; Sample_Info : not null access DDS.SampleInfo_Seq.Sequence; Related_Request_Info : DDS.SampleIdentity_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "Read_Replies_For_Related_Request unimplemented"); return raise Program_Error with "Unimplemented function Read_Replies_For_Related_Request"; end Read_Replies_For_Related_Request; -------------------------------------- -- Read_Replies_For_Related_Request -- -------------------------------------- function Read_Replies_For_Related_Request (Self : not null access Ref; Related_Request_Info : DDS.SampleIdentity_T) return Reply_DataReaders.Container'Class is begin pragma Compile_Time_Warning (Standard.True, "Read_Replies_For_Related_Request unimplemented"); return raise Program_Error with "Unimplemented function Read_Replies_For_Related_Request"; end Read_Replies_For_Related_Request; ----------------- -- Return_Loan -- ----------------- procedure Return_Loan (Self : not null access Ref; Replies : not null Reply_DataReaders.Treats.Data_Sequences .Sequence_Access; Sample_Info : DDS.SampleInfo_Seq.Sequence_Access) is begin pragma Compile_Time_Warning (Standard.True, "Return_Loan unimplemented"); raise Program_Error with "Unimplemented procedure Return_Loan"; end Return_Loan; ----------------- -- Return_Loan -- ----------------- procedure Return_Loan (Self : not null access Ref; Replies : Reply_DataReaders.Treats.Data_Sequences.Sequence; Sample_Info : DDS.SampleInfo_Seq.Sequence) is begin pragma Compile_Time_Warning (Standard.True, "Return_Loan unimplemented"); raise Program_Error with "Unimplemented procedure Return_Loan"; end Return_Loan; ------------ -- Delete -- ------------ procedure Delete (This : in out Ref) is begin pragma Compile_Time_Warning (Standard.True, "Delete unimplemented"); raise Program_Error with "Unimplemented procedure Delete"; end Delete; ---------------------- -- Wait_For_Replies -- ---------------------- procedure Wait_For_Replies (This : in out Ref; Min_Count : Dds.long; Max_Wait : DDS.Duration_T) is begin pragma Compile_Time_Warning (Standard.True, "Wait_For_Replies unimplemented"); raise Program_Error with "Unimplemented procedure Wait_For_Replies"; end Wait_For_Replies; ----------------------------------------- -- Wait_For_Replies_For_Related_Reques -- ----------------------------------------- procedure Wait_For_Replies_For_Related_Reques (This : in out Ref; Min_Count : Dds.long; Max_Wait : DDS.Duration_T; Related_Request_Id : DDS.SampleIdentity_T) is begin pragma Compile_Time_Warning (Standard.True, "Wait_For_Replies_For_Related_Reques unimplemented"); raise Program_Error with "Unimplemented procedure Wait_For_Replies_For_Related_Reques"; end Wait_For_Replies_For_Related_Reques; ---------------------------- -- Get_Request_DataWriter -- ---------------------------- function Get_Request_DataWriter (Self : not null access Ref) return Request_DataWriters.Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "Get_Request_DataWriter unimplemented"); return raise Program_Error with "Unimplemented function Get_Request_DataWriter"; end Get_Request_DataWriter; -------------------------- -- Get_Reply_DataReader -- -------------------------- function Get_Reply_DataReader (Self : not null access Ref) return Reply_DataReaders.Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "Get_Reply_DataReader unimplemented"); return raise Program_Error with "Unimplemented function Get_Reply_DataReader"; end Get_Reply_DataReader; -------------------------------- -- On_Offered_Deadline_Missed -- -------------------------------- procedure On_Offered_Deadline_Missed (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Status : in DDS.OfferedDeadlineMissedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Offered_Deadline_Missed unimplemented"); raise Program_Error with "Unimplemented procedure On_Offered_Deadline_Missed"; end On_Offered_Deadline_Missed; ----------------------- -- On_Data_Available -- ----------------------- procedure On_Data_Available (Self : not null access DataReader_Listner; The_Reader : in DDS.DataReaderListener.DataReader_Access) is begin pragma Compile_Time_Warning (Standard.True, "On_Data_Available unimplemented"); raise Program_Error with "Unimplemented procedure On_Data_Available"; end On_Data_Available; --------------------------------- -- On_Offered_Incompatible_Qos -- --------------------------------- procedure On_Offered_Incompatible_Qos (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Status : in DDS.OfferedIncompatibleQosStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Offered_Incompatible_Qos unimplemented"); raise Program_Error with "Unimplemented procedure On_Offered_Incompatible_Qos"; end On_Offered_Incompatible_Qos; ------------------------ -- On_Liveliness_Lost -- ------------------------ procedure On_Liveliness_Lost (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Status : in DDS.LivelinessLostStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Liveliness_Lost unimplemented"); raise Program_Error with "Unimplemented procedure On_Liveliness_Lost"; end On_Liveliness_Lost; ---------------------------- -- On_Publication_Matched -- ---------------------------- procedure On_Publication_Matched (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Status : in DDS.PublicationMatchedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Publication_Matched unimplemented"); raise Program_Error with "Unimplemented procedure On_Publication_Matched"; end On_Publication_Matched; -------------------------------------- -- On_Reliable_Writer_Cache_Changed -- -------------------------------------- procedure On_Reliable_Writer_Cache_Changed (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Status : in DDS.ReliableWriterCacheChangedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Reliable_Writer_Cache_Changed unimplemented"); raise Program_Error with "Unimplemented procedure On_Reliable_Writer_Cache_Changed"; end On_Reliable_Writer_Cache_Changed; ----------------------------------------- -- On_Reliable_Reader_Activity_Changed -- ----------------------------------------- procedure On_Reliable_Reader_Activity_Changed (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Status : in DDS.ReliableReaderActivityChangedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Reliable_Reader_Activity_Changed unimplemented"); raise Program_Error with "Unimplemented procedure On_Reliable_Reader_Activity_Changed"; end On_Reliable_Reader_Activity_Changed; -------------------------------- -- On_Destination_Unreachable -- -------------------------------- procedure On_Destination_Unreachable (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Instance : in DDS.InstanceHandle_T; Locator : in DDS.Locator_T) is begin pragma Compile_Time_Warning (Standard.True, "On_Destination_Unreachable unimplemented"); raise Program_Error with "Unimplemented procedure On_Destination_Unreachable"; end On_Destination_Unreachable; --------------------- -- On_Data_Request -- --------------------- procedure On_Data_Request (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Cookie : in DDS.Cookie_T; Request : in out System.Address) is begin pragma Compile_Time_Warning (Standard.True, "On_Data_Request unimplemented"); raise Program_Error with "Unimplemented procedure On_Data_Request"; end On_Data_Request; -------------------- -- On_Data_Return -- -------------------- procedure On_Data_Return (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Arg : System.Address; Cookie : in DDS.Cookie_T) is begin pragma Compile_Time_Warning (Standard.True, "On_Data_Return unimplemented"); raise Program_Error with "Unimplemented procedure On_Data_Return"; end On_Data_Return; ----------------------- -- On_Sample_Removed -- ----------------------- procedure On_Sample_Removed (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Cookie : in DDS.Cookie_T) is begin pragma Compile_Time_Warning (Standard.True, "On_Sample_Removed unimplemented"); raise Program_Error with "Unimplemented procedure On_Sample_Removed"; end On_Sample_Removed; -------------------------- -- On_Instance_Replaced -- -------------------------- procedure On_Instance_Replaced (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Instance : in DDS.InstanceHandle_T) is begin pragma Compile_Time_Warning (Standard.True, "On_Instance_Replaced unimplemented"); raise Program_Error with "Unimplemented procedure On_Instance_Replaced"; end On_Instance_Replaced; ----------------------------------- -- On_Application_Acknowledgment -- ----------------------------------- procedure On_Application_Acknowledgment (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Info : in DDS.AcknowledgmentInfo) is begin pragma Compile_Time_Warning (Standard.True, "On_Application_Acknowledgment unimplemented"); raise Program_Error with "Unimplemented procedure On_Application_Acknowledgment"; end On_Application_Acknowledgment; --------------------------------- -- On_Service_Request_Accepted -- --------------------------------- procedure On_Service_Request_Accepted (Self : not null access DataReader_Listner; Writer : access DDS.DataWriter.Ref'Class; Info : in DDS.ServiceRequestAcceptedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Service_Request_Accepted unimplemented"); raise Program_Error with "Unimplemented procedure On_Service_Request_Accepted"; end On_Service_Request_Accepted; ---------------------------------- -- On_Requested_Deadline_Missed -- ---------------------------------- procedure On_Requested_Deadline_Missed (Self : not null access DataWriter_Listner; The_Reader : in DDS.DataReaderListener.DataReader_Access; Status : in DDS.RequestedDeadlineMissedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Requested_Deadline_Missed unimplemented"); raise Program_Error with "Unimplemented procedure On_Requested_Deadline_Missed"; end On_Requested_Deadline_Missed; ----------------------------------- -- On_Requested_Incompatible_Qos -- ----------------------------------- procedure On_Requested_Incompatible_Qos (Self : not null access DataWriter_Listner; The_Reader : in DDS.DataReaderListener.DataReader_Access; Status : in DDS.RequestedIncompatibleQosStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Requested_Incompatible_Qos unimplemented"); raise Program_Error with "Unimplemented procedure On_Requested_Incompatible_Qos"; end On_Requested_Incompatible_Qos; ------------------------ -- On_Sample_Rejected -- ------------------------ procedure On_Sample_Rejected (Self : not null access DataWriter_Listner; The_Reader : in DDS.DataReaderListener.DataReader_Access; Status : in DDS.SampleRejectedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Sample_Rejected unimplemented"); raise Program_Error with "Unimplemented procedure On_Sample_Rejected"; end On_Sample_Rejected; --------------------------- -- On_Liveliness_Changed -- --------------------------- procedure On_Liveliness_Changed (Self : not null access DataWriter_Listner; The_Reader : in DDS.DataReaderListener.DataReader_Access; Status : in DDS.LivelinessChangedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Liveliness_Changed unimplemented"); raise Program_Error with "Unimplemented procedure On_Liveliness_Changed"; end On_Liveliness_Changed; ----------------------- -- On_Data_Available -- ----------------------- procedure On_Data_Available (Self : not null access DataWriter_Listner; The_Reader : in DDS.DataReaderListener.DataReader_Access) is begin pragma Compile_Time_Warning (Standard.True, "On_Data_Available unimplemented"); raise Program_Error with "Unimplemented procedure On_Data_Available"; end On_Data_Available; ----------------------------- -- On_Subscription_Matched -- ----------------------------- procedure On_Subscription_Matched (Self : not null access DataWriter_Listner; The_Reader : in DDS.DataReaderListener.DataReader_Access; Status : in DDS.SubscriptionMatchedStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Subscription_Matched unimplemented"); raise Program_Error with "Unimplemented procedure On_Subscription_Matched"; end On_Subscription_Matched; -------------------- -- On_Sample_Lost -- -------------------- procedure On_Sample_Lost (Self : not null access DataWriter_Listner; The_Reader : in DDS.DataReaderListener.DataReader_Access; Status : in DDS.SampleLostStatus) is begin pragma Compile_Time_Warning (Standard.True, "On_Sample_Lost unimplemented"); raise Program_Error with "Unimplemented procedure On_Sample_Lost"; end On_Sample_Lost; end DDS.Request_Reply.Typed_Requester_Generic;
generic type Value is private; Init_Val : Value; package Opt25_Pkg2 is type Stack (Size : Natural) is private; function Default_Stack return Stack; private type Value_Array is array (Natural range <>) of Value; type Stack (Size : Natural) is record Store : Value_Array (1 .. Size); end record; Default_Stack_Var : Stack (10); end Opt25_Pkg2;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- A very simple draw application. -- Use your finger to draw pixels. with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); -- The "last chance handler" is the user-defined routine that is called when -- an exception is propagated. We need it in the executable, therefore it -- must be somewhere in the closure of the context clauses. with STM32.Board; use STM32.Board; with HAL.Bitmap; use HAL.Bitmap; with HAL.Touch_Panel; use HAL.Touch_Panel; with STM32.User_Button; use STM32; with BMP_Fonts; with LCD_Std_Out; procedure Draw is BG : constant Bitmap_Color := (Alpha => 255, others => 64); procedure Clear; ----------- -- Clear -- ----------- procedure Clear is begin Display.Hidden_Buffer (1).Set_Source (BG); Display.Hidden_Buffer (1).Fill; LCD_Std_Out.Clear_Screen; LCD_Std_Out.Put_Line ("Touch the screen to draw or"); LCD_Std_Out.Put_Line ("press the blue button for"); LCD_Std_Out.Put_Line ("a demo of drawing primitives."); Display.Update_Layer (1, Copy_Back => True); end Clear; Last_X : Integer := -1; Last_Y : Integer := -1; type Mode is (Drawing_Mode, Bitmap_Showcase_Mode); Current_Mode : Mode := Drawing_Mode; begin -- Initialize LCD Display.Initialize; Display.Initialize_Layer (1, ARGB_8888); -- Initialize touch panel Touch_Panel.Initialize; -- Initialize button User_Button.Initialize; LCD_Std_Out.Set_Font (BMP_Fonts.Font8x8); LCD_Std_Out.Current_Background_Color := BG; -- Clear LCD (set background) Clear; -- The application: set pixel where the finger is (so that you -- cannot see what you are drawing). loop if User_Button.Has_Been_Pressed then case Current_Mode is when Drawing_Mode => Current_Mode := Bitmap_Showcase_Mode; when Bitmap_Showcase_Mode => Clear; Current_Mode := Drawing_Mode; end case; end if; if Current_Mode = Drawing_Mode then Display.Hidden_Buffer (1).Set_Source (HAL.Bitmap.Green); declare State : constant TP_State := Touch_Panel.Get_All_Touch_Points; begin if State'Length = 0 then Last_X := -1; Last_Y := -1; elsif State'Length = 1 then -- Lines can be drawn between two consecutive points only when -- one touch point is active: the order of the touch data is not -- necessarily preserved by the hardware. if Last_X > 0 then Draw_Line (Display.Hidden_Buffer (1).all, Start => (Last_X, Last_Y), Stop => (State (State'First).X, State (State'First).Y), Thickness => State (State'First).Weight / 2, Fast => False); end if; Last_X := State (State'First).X; Last_Y := State (State'First).Y; else Last_X := -1; Last_Y := -1; end if; for Id in State'Range loop Fill_Circle (Display.Hidden_Buffer (1).all, Center => (State (Id).X, State (Id).Y), Radius => State (Id).Weight / 4); end loop; if State'Length > 0 then Display.Update_Layer (1, Copy_Back => True); end if; end; else -- Show some of the supported drawing primitives Display.Hidden_Buffer (1).Set_Source (Black); Display.Hidden_Buffer (1).Fill; Display.Hidden_Buffer (1).Set_Source (Green); Display.Hidden_Buffer (1).Fill_Rounded_Rect (((10, 10), 100, 100), 20); Display.Hidden_Buffer (1).Set_Source (HAL.Bitmap.Red); Display.Hidden_Buffer (1).Draw_Rounded_Rect (((10, 10), 100, 100), 20, Thickness => 4); Display.Hidden_Buffer (1).Set_Source (HAL.Bitmap.Yellow); Display.Hidden_Buffer (1).Fill_Circle ((60, 60), 20); Display.Hidden_Buffer (1).Set_Source (HAL.Bitmap.Blue); Display.Hidden_Buffer (1).Draw_Circle ((60, 60), 20); Display.Hidden_Buffer (1).Set_Source (HAL.Bitmap.Violet); Display.Hidden_Buffer (1).Cubic_Bezier (P1 => (10, 10), P2 => (60, 10), P3 => (60, 60), P4 => (100, 100), N => 200, Thickness => 5); Copy_Rect (Src_Buffer => Display.Hidden_Buffer (1).all, Src_Pt => (0, 0), Dst_Buffer => Display.Hidden_Buffer (1).all, Dst_Pt => (100, 100), Width => 100, Height => 100, Synchronous => True); Display.Update_Layer (1, Copy_Back => False); end if; end loop; end Draw;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013-2014, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Holders; with League.JSON.Arrays; with League.JSON.Objects; with League.JSON.Values; with League.String_Vectors; package body Matreshka.JSON_Generator is -------------- -- Generate -- -------------- function Generate (Document : League.JSON.Documents.JSON_Document'Class) return League.Strings.Universal_String is Result : League.Strings.Universal_String; procedure Generate_Array (Value : League.JSON.Arrays.JSON_Array); procedure Generate_Object (Value : League.JSON.Objects.JSON_Object); procedure Generate_Value (Value : League.JSON.Values.JSON_Value); procedure Generate_String (Value : League.Strings.Universal_String); -------------------- -- Generate_Array -- -------------------- procedure Generate_Array (Value : League.JSON.Arrays.JSON_Array) is begin Result.Append ('['); for J in 1 .. Value.Length loop if J /= 1 then Result.Append (','); end if; Generate_Value (Value.Element (J)); end loop; Result.Append (']'); end Generate_Array; --------------------- -- Generate_Object -- --------------------- procedure Generate_Object (Value : League.JSON.Objects.JSON_Object) is Members : constant League.String_Vectors.Universal_String_Vector := Value.Keys; begin Result.Append ('{'); for J in 1 .. Members.Length loop if J /= 1 then Result.Append (','); end if; Generate_String (Members.Element (J)); Result.Append (':'); Generate_Value (Value.Value (Members.Element (J))); end loop; Result.Append ('}'); end Generate_Object; --------------------- -- Generate_String -- --------------------- procedure Generate_String (Value : League.Strings.Universal_String) is To_Hex : constant array (Natural range 0 .. 15) of Wide_Wide_Character := "0123456789ABCDEF"; Code : Natural; begin Result.Append ('"'); for J in 1 .. Value.Length loop case Value.Element (J).To_Wide_Wide_Character is when Wide_Wide_Character'Val (16#0000#) .. Wide_Wide_Character'Val (16#0007#) | Wide_Wide_Character'Val (16#000B#) | Wide_Wide_Character'Val (16#000E#) .. Wide_Wide_Character'Val (16#001F#) => Code := Wide_Wide_Character'Pos (Value.Element (J).To_Wide_Wide_Character); Result.Append ("\u00"); Result.Append (To_Hex ((Code / 16) mod 16)); Result.Append (To_Hex (Code mod 16)); when Wide_Wide_Character'Val (16#0008#) => -- backspace Result.Append ("\b"); when Wide_Wide_Character'Val (16#0009#) => -- carriage return Result.Append ("\r"); when Wide_Wide_Character'Val (16#000A#) => -- line feed Result.Append ("\n"); when Wide_Wide_Character'Val (16#000C#) => -- form feed Result.Append ("\f"); when Wide_Wide_Character'Val (16#000D#) => -- tab Result.Append ("\t"); when '"' => Result.Append ("\"""); when '\' => Result.Append ("\\"); when others => Result.Append (Value.Element (J)); end case; end loop; Result.Append ('"'); end Generate_String; -------------------- -- Generate_Value -- -------------------- procedure Generate_Value (Value : League.JSON.Values.JSON_Value) is begin case Value.Kind is when League.JSON.Values.Empty_Value => null; when League.JSON.Values.Boolean_Value => case Value.To_Boolean is when False => Result.Append ("false"); when True => Result.Append ("true"); end case; when League.JSON.Values.Number_Value => if Value.Is_Integer_Number then declare Image : constant Wide_Wide_String := League.Holders.Universal_Integer'Wide_Wide_Image (Value.To_Integer); begin if Image (Image'First) /= ' ' then Result.Append (Image); else Result.Append (Image (Image'First + 1 .. Image'Last)); end if; end; else declare Image : constant Wide_Wide_String := League.Holders.Universal_Float'Wide_Wide_Image (Value.To_Float); begin if Image (Image'First) /= ' ' then Result.Append (Image); else Result.Append (Image (Image'First + 1 .. Image'Last)); end if; end; end if; when League.JSON.Values.String_Value => Generate_String (Value.To_String); when League.JSON.Values.Array_Value => Generate_Array (Value.To_Array); when League.JSON.Values.Object_Value => Generate_Object (Value.To_Object); when League.JSON.Values.Null_Value => Result.Append ("null"); end case; end Generate_Value; begin if Document.Is_Object then Generate_Object (Document.To_JSON_Object); elsif Document.Is_Array then Generate_Array (Document.To_JSON_Array); end if; return Result; end Generate; end Matreshka.JSON_Generator;
with agar.core.tail_queue; with agar.core.types; with agar.gui.widget.menu; with agar.gui.widget.scrollbar; package agar.gui.widget.graph is use type c.unsigned; type vertex_t; type vertex_access_t is access all vertex_t; pragma convention (c, vertex_access_t); type edge_t; type edge_access_t is access all edge_t; pragma convention (c, edge_access_t); type graph_t; type graph_access_t is access all graph_t; pragma convention (c, graph_access_t); package vertex_tail_queue is new agar.core.tail_queue (entry_type => vertex_access_t); package edge_tail_queue is new agar.core.tail_queue (entry_type => edge_access_t); type vertex_style_t is (GRAPH_RECTANGLE, GRAPH_CIRCLE); for vertex_style_t use (GRAPH_RECTANGLE => 0, GRAPH_CIRCLE => 1); for vertex_style_t'size use c.unsigned'size; pragma convention (c, vertex_style_t); ndefcolors : constant := 16; label_max : constant := 64; type vertex_label_t is array (1 .. label_max) of aliased c.char; pragma convention (c, vertex_label_t); subtype vertex_flags_t is c.unsigned; GRAPH_MOUSEOVER : constant vertex_flags_t := 16#01#; GRAPH_SELECTED : constant vertex_flags_t := 16#02#; GRAPH_HIDDEN : constant vertex_flags_t := 16#04#; GRAPH_AUTOPLACED : constant vertex_flags_t := 16#08#; type vertex_t is record label_text : vertex_label_t; label_su : c.int; label_color : agar.core.types.uint32_t; bg_color : agar.core.types.uint32_t; style : vertex_style_t; flags : vertex_flags_t; x : c.int; y : c.int; w : c.unsigned; h : c.unsigned; ptr : agar.core.types.void_ptr_t; edges : access edge_access_t; nedges : c.unsigned; graph : graph_access_t; vertices : vertex_tail_queue.entry_t; sorted : vertex_tail_queue.entry_t; popup_menu : agar.gui.widget.menu.popup_menu_access_t; end record; pragma convention (c, vertex_t); subtype edge_flags_t is vertex_flags_t; type edge_t is record label_text : vertex_label_t; label_su : c.int; edge_color : agar.core.types.uint32_t; label_color : agar.core.types.uint32_t; flags : edge_flags_t; v1 : vertex_access_t; v2 : vertex_access_t; ptr : agar.core.types.void_ptr_t; graph : graph_access_t; edges : edge_tail_queue.entry_t; popup_menu : agar.gui.widget.menu.popup_menu_access_t; end record; pragma convention (c, edge_t); subtype graph_flags_t is c.unsigned; GRAPH_HFILL : constant graph_flags_t := 16#01#; GRAPH_VFILL : constant graph_flags_t := 16#02#; GRAPH_EXPAND : constant graph_flags_t := GRAPH_HFILL or GRAPH_VFILL; GRAPH_SCROLL : constant graph_flags_t := 16#04#; GRAPH_DRAGGING : constant graph_flags_t := 16#08#; GRAPH_PANNING : constant graph_flags_t := 16#10#; GRAPH_NO_MOVE : constant graph_flags_t := 16#20#; GRAPH_NO_SELECT : constant graph_flags_t := 16#40#; GRAPH_NO_MENUS : constant graph_flags_t := 16#80#; GRAPH_READONLY : constant graph_flags_t := GRAPH_NO_MOVE or GRAPH_NO_SELECT or GRAPH_NO_MENUS; type graph_t is record widget : aliased widget_t; flags : graph_flags_t; width_pre : c.int; height_pre : c.int; x_offset : c.int; y_offset : c.int; x_min : c.int; x_max : c.int; y_min : c.int; y_max : c.int; horiz_bar : agar.gui.widget.scrollbar.scrollbar_access_t; vertical_bar : agar.gui.widget.scrollbar.scrollbar_access_t; vertices : vertex_tail_queue.head_t; edges : edge_tail_queue.head_t; nvertices : c.unsigned; nedges : c.unsigned; px_min : c.int; px_max : c.int; py_min : c.int; py_max : c.int; r : agar.gui.rect.rect_t; end record; pragma convention (c, graph_t); -- API package vertex is function allocate (graph : graph_access_t; user_data : agar.core.types.void_ptr_t) return vertex_access_t; pragma import (c, allocate, "AG_GraphVertexNew"); function find (graph : graph_access_t; user_data : agar.core.types.void_ptr_t) return vertex_access_t; pragma import (c, find, "AG_GraphVertexFind"); procedure label (vertex : vertex_access_t; label : string); pragma inline (label); procedure color_label (vertex : vertex_access_t; r : agar.core.types.uint8_t; g : agar.core.types.uint8_t; b : agar.core.types.uint8_t); pragma import (c, color_label, "AG_GraphVertexColorLabel"); procedure color_background (vertex : vertex_access_t; r : agar.core.types.uint8_t; g : agar.core.types.uint8_t; b : agar.core.types.uint8_t); pragma import (c, color_background, "AG_GraphVertexColorBG"); procedure size (vertex : vertex_access_t; width : positive; height : positive); pragma inline (size); procedure position (vertex : vertex_access_t; x : natural; y : natural); pragma inline (position); procedure popup_menu (vertex : vertex_access_t; menu : agar.gui.widget.menu.popup_menu_access_t); pragma import (c, popup_menu, "AG_GraphVertexPopupMenu"); end vertex; package edge is function allocate (graph : graph_access_t; v1 : vertex_access_t; v2 : vertex_access_t; user_data : agar.core.types.void_ptr_t) return edge_access_t; pragma import (c, allocate, "AG_GraphEdgeNew"); function find (graph : graph_access_t; user_data : agar.core.types.void_ptr_t) return edge_access_t; pragma import (c, find, "AG_GraphEdgeFind"); procedure label (edge : edge_access_t; label : string); pragma inline (label); procedure color_label (edge : edge_access_t; r : agar.core.types.uint8_t; g : agar.core.types.uint8_t; b : agar.core.types.uint8_t); pragma import (c, color_label, "AG_GraphEdgeColorLabel"); procedure color_background (edge : edge_access_t; r : agar.core.types.uint8_t; g : agar.core.types.uint8_t; b : agar.core.types.uint8_t); pragma import (c, color_background, "AG_GraphEdgeColor"); procedure popup_menu (edge : edge_access_t; menu : agar.gui.widget.menu.popup_menu_access_t); pragma import (c, popup_menu, "AG_GraphEdgePopupMenu"); end edge; function widget (graph : graph_access_t) return widget_access_t; pragma inline (widget); end agar.gui.widget.graph;
----------------------------------------------------------------------- -- asf-views-nodes -- Facelet node tree representation -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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. ----------------------------------------------------------------------- -- The <b>ASF.Views.Nodes</b> package defines the nodes and attributes -- the represent the facelet node tree used to create the component tree. -- -- The facelet node tree is composed of nodes represented by <b>Tag_Node</b> -- and attributes represented by <b>Tag_Attribute</b>. In a sense, this -- is very close to an XML DOM tree. with Ada.Strings.Unbounded; with EL.Expressions; with EL.Objects; with Util.Strings; with ASF.Components.Base; with ASF.Contexts.Faces; with ASF.Contexts.Facelets; package ASF.Views.Nodes is use Ada.Strings.Unbounded; use ASF.Components.Base; use ASF.Contexts.Faces; use ASF.Contexts.Facelets; type Expression_Access_Array is array (Natural range <>) of EL.Expressions.Expression_Access; type Expression_Access_Array_Access is access Expression_Access_Array; -- ------------------------------ -- Attribute of a node. -- ------------------------------ -- The attribute has a name and a value. When the value is not -- a literal, an EL expression is created to allow its evaluation. type Tag_Attribute is limited private; type Tag_Attribute_Access is access all Tag_Attribute; type Tag_Attribute_Array is array (Natural range <>) of aliased Tag_Attribute; type Tag_Attribute_Array_Access is access Tag_Attribute_Array; function "=" (Left : in Tag_Attribute; Right : in String) return Boolean; function "=" (Left, Right : in Tag_Attribute) return Boolean; -- Get the attribute name. function Get_Name (Attribute : Tag_Attribute) return String; -- Returns True if the attribute is static (not an EL expression). function Is_Static (Attribute : Tag_Attribute) return Boolean; -- Get the attribute value. If the attribute is an EL expression -- evaluate that expression in the context of the given UI component. function Get_Value (Attribute : Tag_Attribute; UI : UIComponent'Class) return EL.Objects.Object; function Get_Value (Attribute : Tag_Attribute; Context : Faces_Context'Class) return EL.Objects.Object; function Get_Value (Attribute : Tag_Attribute; Context : Facelet_Context'Class) return EL.Objects.Object; -- Get the value from the attribute. If the attribute is null or evaluates to -- a NULL object, returns the default value. Convert the value into a string. function Get_Value (Attribute : in Tag_Attribute_Access; Context : in Facelet_Context'Class; Default : in String) return String; -- Get the EL expression associated with the given tag attribute. function Get_Expression (Attribute : in Tag_Attribute) return EL.Expressions.Expression; function Get_Value_Expression (Attribute : Tag_Attribute) return EL.Expressions.Value_Expression; function Get_Method_Expression (Attribute : Tag_Attribute) return EL.Expressions.Method_Expression; -- Reduce the expression by eliminating known variables and computing -- constant expressions. The result expression is either another -- expression or a computed constant value. function Reduce_Expression (Attribute : Tag_Attribute; Context : Facelet_Context'Class) return EL.Expressions.Expression; -- Find the tag attribute having the given name. -- Returns an access to the attribute cell within the array or null -- if the no attribute matches the name. function Find_Attribute (Attributes : Tag_Attribute_Array_Access; Name : String) return Tag_Attribute_Access; -- Report an error message for the attribute. procedure Error (Attribute : in Tag_Attribute; Message : in String; Param1 : in String; Param2 : in String := ""); -- ------------------------------ -- XHTML node -- ------------------------------ -- The <b>Tag_Node</b> represents a UI component node in a view. type Tag_Node is tagged limited private; type Tag_Node_Access is access all Tag_Node'Class; -- Get the node attribute with the given name. -- Returns null if the node does not have such attribute. function Get_Attribute (Node : Tag_Node; Name : String) return Tag_Attribute_Access; -- Get the line information where the tag node is defined. function Get_Line_Info (Node : Tag_Node) return Line_Info; -- Get the line information as a string. function Get_Line_Info (Node : Tag_Node) return String; -- Get the relative path name of the XHTML file in which this tag is defined. function Get_File_Name (Node : in Tag_Node) return String; -- Append a child tag node. procedure Append_Tag (Node : in Tag_Node_Access; Child : in Tag_Node_Access); -- Freeze the tag node tree and perform any initialization steps -- necessary to build the components efficiently. After this call -- the tag node tree should not be modified and it represents a read-only -- tree. procedure Freeze (Node : access Tag_Node); -- Build the component attributes from the facelet tag node and the facelet context. procedure Build_Attributes (UI : in out UIComponent'Class; Node : in Tag_Node'Class; Context : in out Facelet_Context'Class); -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. procedure Build_Components (Node : access Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- Build the component tree from the tag node and attach it as -- the last child of the given parent. Calls recursively the -- method to create children. procedure Build_Children (Node : access Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- Delete the node and its children freeing the memory as necessary procedure Delete (Node : access Tag_Node); procedure Destroy (Node : in out Tag_Node_Access); -- Report an error message procedure Error (Node : in Tag_Node'Class; Message : in String; Param1 : in String := ""; Param2 : in String := ""); -- Iterate over the attributes defined on the node and -- execute the <b>Process</b> procedure. generic with procedure Process (Attr : in Tag_Attribute_Access); procedure Iterate_Attributes (Node : in Tag_Node'Class); -- ------------------------------ -- Text nodes mixed with EL expressions. -- ------------------------------ -- The text node is used when the XHTML reader does not recognize an entity. -- The reader appends the content to a text node until an entity is recognized. -- The text node can contain attributes associated with the unrecognize entities. -- Attributes and raw text may contain EL expressions that will be evaluated -- when the component is rendered. The <b>Text_Tag_Node</b> contains a list -- of raw text and EL expression to evaluate. type Text_Tag_Node is new Tag_Node with private; type Text_Tag_Node_Access is access all Text_Tag_Node; -- Encode the content represented by this text node. -- The expressions are evaluated if necessary. procedure Encode_All (Node : in Text_Tag_Node; Expr : in Expression_Access_Array_Access; Context : in Faces_Context'Class); overriding procedure Build_Components (Node : access Text_Tag_Node; Parent : in UIComponent_Access; Context : in out Facelet_Context'Class); -- Freeze the tag node tree. -- Count the number of Tag_Content represented by this node. overriding procedure Freeze (Node : access Text_Tag_Node); -- Delete the node and its children freeing the memory as necessary procedure Delete (Node : access Text_Tag_Node); type Cursor is private; function First (Node : in Tag_Node_Access) return Cursor; function Has_Element (C : Cursor) return Boolean; function Element (Position : Cursor) return Tag_Node_Access; procedure Next (Position : in out Cursor); type Binding; type Binding_Access is access constant Binding; -- Create function to build a UIComponent type Create_Access is access function return ASF.Components.Base.UIComponent_Access; -- Create function to build a tag node type Tag_Node_Create_Access is access function (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; -- Create the When Tag function Create_Component_Node (Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access) return Tag_Node_Access; pragma Suppress (Elaboration_Check, On => Create_Component_Node); -- Binding name type Name_Access is new Util.Strings.Name_Access; -- ------------------------------ -- Binding definition. -- ------------------------------ -- The binding links an XHTML entity name to a tag node implementation -- and a component creation handler. When the XHTML entity is found, -- the associated binding is searched and when found the node is created -- by using the <b>Tag</b> create function. type Binding is limited record Name : Name_Access; Component : ASF.Views.Nodes.Create_Access; Tag : ASF.Views.Nodes.Tag_Node_Create_Access; end record; private type Cursor is record Node : Tag_Node_Access; end record; type Tag_Attribute is record Tag : Tag_Node_Access; Binding : EL.Expressions.Expression_Access; Name : Unbounded_String; Value : Unbounded_String; end record; type Tag_Node is tagged limited record -- The parent node. Parent : Tag_Node_Access; -- Attributes associated with this node. Attributes : Tag_Attribute_Array_Access; -- The UIComponent factory that must be used to create the component. Factory : Create_Access; Next : Tag_Node_Access; First_Child : Tag_Node_Access; Last_Child : Tag_Node_Access; -- Source line information where the tag node is defined (for error messages) Line : Line_Info; end record; -- Initialize the node procedure Initialize (Node : in Tag_Node_Access; Binding : in Binding_Access; Line : in Line_Info; Parent : in Tag_Node_Access; Attributes : in Tag_Attribute_Array_Access); type Tag_Content; type Tag_Content_Access is access all Tag_Content; type Tag_Content is record Next : Tag_Content_Access := null; Text : Unbounded_String; Expr : EL.Expressions.Expression; end record; type Text_Tag_Node is new Tag_Node with record Count : Natural := 0; Last : Tag_Content_Access := null; Content : aliased Tag_Content; end record; end ASF.Views.Nodes;
package ARM_Input is -- -- Ada reference manual formatter (ARM_Form). -- -- This package contains the abstract definition of reading an input file -- or other entity, and routines to lex the input entities. -- -- --------------------------------------- -- Copyright 2000, 2002, 2004, 2011 -- AXE Consultants. All rights reserved. -- P.O. Box 1512, Madison WI 53701 -- E-Mail: randy@rrsoftware.com -- -- ARM_Form is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License version 3 -- as published by the Free Software Foundation. -- -- AXE CONSULTANTS MAKES THIS TOOL AND SOURCE CODE AVAILABLE ON AN "AS IS" -- BASIS AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE ACCURACY, -- CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR FUNCTIONING OF THIS TOOL. -- IN NO EVENT WILL AXE CONSULTANTS BE LIABLE FOR ANY GENERAL, -- CONSEQUENTIAL, INDIRECT, INCIDENTAL, EXEMPLARY, OR SPECIAL DAMAGES, -- EVEN IF AXE CONSULTANTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -- DAMAGES. -- -- A copy of the GNU General Public License is available in the file -- gpl-3-0.txt in the standard distribution of the ARM_Form tool. -- Otherwise, see <http://www.gnu.org/licenses/>. -- -- If the GPLv3 license is not satisfactory for your needs, a commercial -- use license is available for this tool. Contact Randy at AXE Consultants -- for more information. -- -- --------------------------------------- -- -- Edit History: -- -- 5/15/00 - RLB - Created base package. -- 7/18/02 - RLB - Added Check_One_of_Parameter_Names. -- 12/06/04 - RLB - Expanded Check_One_of_Parameter_Names to take up to -- five names. -- 10/18/11 - RLB - Changed to GPLv3 license. type Input_Type is abstract tagged limited null record; MAX_RECORDING_SIZE : constant := 4000; Not_Valid_Error : exception; -- The Input_Object is not valid. -- procedure Open (Input_Object : in out Input_Type; -- -- Other parameters) is abstract; -- Open an input object for an entity. -- Each concrete type has its own Open routine, with possibly -- different parameters. procedure Close (Input_Object : in out Input_Type) is abstract; -- Close the input object (entity). -- May propagate exceptions from the underlying implementation -- (that is, I/O exceptions). procedure Get_Char (Input_Object : in out Input_Type; Char : out Character) is abstract; -- We represent end of line by Ascii.LF, and end of file by -- Ascii.SUB. -- Raises: Not_Valid_Error if Input_Object is not valid (open). procedure Replace_Char (Input_Object : in out Input_Type) is abstract; -- Replaces the last character read (with Get_Char); the next call -- to Get_Char will return it. -- Raises: Not_Valid_Error if Input_Object is not valid (open). function Line_String (Input_Object : in Input_Type) return String is abstract; -- Returns a string representing the line number and entity. -- Usually used in error messages. -- Raises: Not_Valid_Error if Input_Object is not valid (open). procedure Start_Recording (Input_Object : in out Input_Type) is abstract; -- Start recording all characters read into a local buffer. -- Use this when text needs to be formatted into the output -- file *and* be saved for future use. -- Raises: Not_Valid_Error if Input_Object is not valid (open). procedure Stop_Recording_and_Read_Result (Input_Object : in out Input_Type; Result : out String; Len : out Natural) is abstract; -- Stop recording characters read. Put the result into Result, -- and the number of characters written into Len. -- Raises: Not_Valid_Error if Input_Object is not valid (open). -- Lexical routines: subtype Command_Name_Type is String (1 .. 40); function Is_Open_Char (Open_Char : in Character) return Boolean; -- Return True if character is a parameter opening character -- ('<', '[', '{', '('), and False otherwise. function Get_Close_Char (Open_Char : in Character) return Character; -- Return the parameter closing character for an opening character. -- Raises Not_Valid_Error if Open_Char is not an opening character -- ('<', '[', '{', '('). function Get_Open_Char (Close_Char : in Character) return Character; -- Return the parameter opening character for an closing character. -- Raises Not_Valid_Error if Open_Char is not an closing character -- ('>', ']', '}', ')'). procedure Get_Name (Input_Object : in out Input_Type'Class; Name : out ARM_Input.Command_Name_Type; Null_Name_Allowed : in Boolean := False); -- Get a name from the Input_Object. "Names" are sequences of -- alphanumeric characters. If Null_Name_Allowed is False, -- an error is produced if no name is found. procedure Copy_to_String_until_Close_Char (Input_Object : in out Input_Type'Class; Close_Char : in Character; Buffer : out String; Len : out Natural); -- Copy text from Input_Object to Buffer until the matching -- Close_Char is found. Len is the number of characters copied. -- Use this when we only need a string; use recording when we -- need the string *and* we still must process the type. procedure Skip_until_Close_Char (Input_Object : in out Input_Type'Class; Close_Char : in Character); -- Skip text from Input_Object until the matching Close_Char is found. procedure Check_Parameter_Name (Input_Object : in out Input_Type'Class; Param_Name : in ARM_Input.Command_Name_Type; Is_First : in Boolean; Param_Close_Bracket : out Character); -- Check that the name of a parameter (if any) is Param_Name. -- This is the first parameter is Is_First is True; otherwise -- it is a later parameter. (For a later parameter, we'll skip -- the comma and any whitespace.) -- If the parameter has an argument, the opening character will -- be read, and the closing character will be returned in -- in Param_Close_Bracket. If the parameter wasn't found, an -- error message will be produced, and Param_Close_Bracket will -- be set to ' '. subtype Param_Num is Natural range 0 .. 5; procedure Check_One_of_Parameter_Names ( Input_Object : in out Input_Type'Class; Param_Name_1 : in ARM_Input.Command_Name_Type; Param_Name_2 : in ARM_Input.Command_Name_Type; Param_Name_3 : in ARM_Input.Command_Name_Type := (others => ' '); Param_Name_4 : in ARM_Input.Command_Name_Type := (others => ' '); Param_Name_5 : in ARM_Input.Command_Name_Type := (others => ' '); Is_First : in Boolean; Param_Close_Bracket : out Character; Param_Found : out Param_Num); -- Check that the name of a parameter (if any) is one of the given -- names. If the parameter is set to all blanks, it is not used. -- This is the first parameter is Is_First is True; -- otherwise it is a later parameter. (For a later parameter, we'll -- skip the comma and any whitespace.) -- Param_Found will be set to the number of the parameter that was -- found. -- If the parameter has an argument, the opening character will -- be read, and the closing character will be returned in -- in Param_Close_Bracket. If the parameter wasn't found, an -- error message will be produced, Param_Close_Bracket will -- be set to ' ', and Param_Found will be set to 0. end ARM_Input;
-- Copyright (c) 2020 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with GNAT.SHA256; with League.JSON.Values; with JWS.Integers; with JWS.To_Base_64_URL; package body JWS.RS256 is function "+" (V : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; type Private_Key (N, E, D, P, Q, E1, E2, C : Positive) is record Modulus : JWS.Integers.Number (1 .. N); -- n Public_Exponent : JWS.Integers.Number (1 .. E); -- e Private_Exponent : JWS.Integers.Number (1 .. D); -- d Prime_1 : JWS.Integers.Number (1 .. P); -- p Prime_2 : JWS.Integers.Number (1 .. Q); -- q Exponent_1 : JWS.Integers.Number (1 .. E1); -- d mod (p-1) Exponent_2 : JWS.Integers.Number (1 .. E2); -- d mod (q-1) Coefficient : JWS.Integers.Number (1 .. C); -- (inver. of q) mod p end record; type Public_Key (N, E : Positive) is record Modulus : JWS.Integers.Number (1 .. N); -- n Public_Exponent : JWS.Integers.Number (1 .. E); -- e end record; function Do_Sign (Data : Ada.Streams.Stream_Element_Array; Key : Private_Key) return Ada.Streams.Stream_Element_Array; function Do_Validate (Data : Ada.Streams.Stream_Element_Array; Key : Public_Key; Sign : Ada.Streams.Stream_Element_Array) return Boolean; package Read_DER is function Read_Private_Key (Input : Ada.Streams.Stream_Element_Array) return Private_Key; function Read_Public_Key (Input : Ada.Streams.Stream_Element_Array) return Public_Key; end Read_DER; function Signature (Data : League.Stream_Element_Vectors.Stream_Element_Vector; Secret : Ada.Streams.Stream_Element_Array) return League.Stream_Element_Vectors.Stream_Element_Vector; function Validate (Data : League.Stream_Element_Vectors.Stream_Element_Vector; Secret : Ada.Streams.Stream_Element_Array; Value : League.Stream_Element_Vectors.Stream_Element_Vector) return Boolean; package body Read_DER is separate; procedure Encode (Data : Ada.Streams.Stream_Element_Array; Value : out Ada.Streams.Stream_Element_Array); -- Calculate EMSA-PKCS1-V1_5-ENCODE from RFC 8017 ------------- -- Do_Sign -- ------------- function Do_Sign (Data : Ada.Streams.Stream_Element_Array; Key : Private_Key) return Ada.Streams.Stream_Element_Array is k : constant Ada.Streams.Stream_Element_Count := Ada.Streams.Stream_Element_Count (Key.N * 4); EM : Ada.Streams.Stream_Element_Array (1 .. k); M : JWS.Integers.Number (1 .. Key.N); S : JWS.Integers.Number (1 .. Key.N); begin Encode (Data, EM); JWS.Integers.BER_Decode (EM, M); -- s = m^d mod n. JWS.Integers.Power (M, Key.Private_Exponent, Key.Modulus, S); JWS.Integers.BER_Encode (S, EM); return EM; end Do_Sign; ----------------- -- Do_Validate -- ----------------- function Do_Validate (Data : Ada.Streams.Stream_Element_Array; Key : Public_Key; Sign : Ada.Streams.Stream_Element_Array) return Boolean is use type Ada.Streams.Stream_Element_Array; k : constant Ada.Streams.Stream_Element_Count := Ada.Streams.Stream_Element_Count (Key.N * 4); EM : Ada.Streams.Stream_Element_Array (1 .. k); ME : Ada.Streams.Stream_Element_Array (1 .. k); S : JWS.Integers.Number (1 .. Key.N); M : JWS.Integers.Number (1 .. Key.N); begin Encode (Data, EM); JWS.Integers.BER_Decode (Sign, S); JWS.Integers.Power (S, Key.Public_Exponent, Key.Modulus, M); JWS.Integers.BER_Encode (M, ME); return EM = ME; end Do_Validate; ------------ -- Encode -- ------------ procedure Encode (Data : Ada.Streams.Stream_Element_Array; Value : out Ada.Streams.Stream_Element_Array) is use type Ada.Streams.Stream_Element_Array; use type Ada.Streams.Stream_Element_Offset; H : constant GNAT.SHA256.Binary_Message_Digest := GNAT.SHA256.Digest (Data); T : constant Ada.Streams.Stream_Element_Array := (16#30#, 16#31#, 16#30#, 16#0d#, 16#06#, 16#09#, 16#60#, 16#86#, 16#48#, 16#01#, 16#65#, 16#03#, 16#04#, 16#02#, 16#01#, 16#05#, 16#00#, 16#04#, 16#20#) & H; begin Value := (00, 01) & (1 .. Value'Length - T'Length - 3 => 16#FF#) & 00 & T; null; end Encode; ---------------- -- Public_JWK -- ---------------- function Public_JWK (Raw_Key : Ada.Streams.Stream_Element_Array) return League.JSON.Objects.JSON_Object is function "-" (V : Wide_Wide_String) return League.JSON.Values.JSON_Value is (League.JSON.Values.To_JSON_Value (+V)); function "-" (V : JWS.Integers.Number) return League.JSON.Values.JSON_Value; --------- -- "-" -- --------- function "-" (V : JWS.Integers.Number) return League.JSON.Values.JSON_Value is use type Ada.Streams.Stream_Element; use type Ada.Streams.Stream_Element_Count; Raw : Ada.Streams.Stream_Element_Array (1 .. V'Length * 4); From : Ada.Streams.Stream_Element_Count := Raw'Last + 1; Vector : League.Stream_Element_Vectors.Stream_Element_Vector; begin JWS.Integers.BER_Encode (V, Raw); for J in Raw'Range loop if Raw (J) /= 0 then From := J; exit; end if; end loop; Vector.Append (Raw (From .. Raw'Last)); return League.JSON.Values.To_JSON_Value (JWS.To_Base_64_URL (Vector)); end "-"; Key : constant Public_Key := Read_DER.Read_Public_Key (Raw_Key); begin return Result : League.JSON.Objects.JSON_Object do Result.Insert (+"kty", -"RSA"); Result.Insert (+"e", -Key.Public_Exponent); Result.Insert (+"n", -Key.Modulus); end return; end Public_JWK; --------------- -- Signature -- --------------- function Signature (Data : League.Stream_Element_Vectors.Stream_Element_Vector; Secret : Ada.Streams.Stream_Element_Array) return League.Stream_Element_Vectors.Stream_Element_Vector is Key : constant Private_Key := Read_DER.Read_Private_Key (Secret); begin return League.Stream_Element_Vectors.To_Stream_Element_Vector (Do_Sign (Data.To_Stream_Element_Array, Key)); end Signature; -------------- -- Validate -- -------------- function Validate (Data : League.Stream_Element_Vectors.Stream_Element_Vector; Secret : Ada.Streams.Stream_Element_Array; Value : League.Stream_Element_Vectors.Stream_Element_Vector) return Boolean is Key : constant Public_Key := Read_DER.Read_Public_Key (Secret); begin return Do_Validate (Data.To_Stream_Element_Array, Key, Value.To_Stream_Element_Array); end Validate; begin RS256_Signature_Link := Signature'Access; RS256_Validation_Link := Validate'Access; end JWS.RS256;
with Agar.Core.Thin; with System; package Agar.Core.Event is subtype Event_Access_t is Thin.Event.Event_Access_t; subtype Event_Not_Null_Access_t is Thin.Event.Event_Not_Null_Access_t; subtype Long_Natural is Long_Integer range 0 .. Long_Integer'Last; procedure Init (Event : in Event_Not_Null_Access_t) renames Thin.Event.Init; procedure Push_Pointer (Event : in Event_Not_Null_Access_t; Key : in String; Value : in System.Address); procedure Push_String (Event : in Event_Not_Null_Access_t; Key : in String; Value : in String); procedure Push_Integer (Event : in Event_Not_Null_Access_t; Key : in String; Value : in Integer); procedure Push_Natural (Event : in Event_Not_Null_Access_t; Key : in String; Value : in Natural); procedure Push_Long (Event : in Event_Not_Null_Access_t; Key : in String; Value : in Long_Integer); procedure Push_Long_Natural (Event : in Event_Not_Null_Access_t; Key : in String; Value : in Long_Natural); procedure Push_Float (Event : in Event_Not_Null_Access_t; Key : in String; Value : in Float); procedure Push_Long_Float (Event : in Event_Not_Null_Access_t; Key : in String; Value : in Long_Float); procedure Pop_Argument (Event : in Event_Not_Null_Access_t) renames Thin.Event.Pop_Argument; generic type Element_Type is private; type Element_Access_Type is access Element_Type; procedure Push_Generic_Access (Event : in Event_Not_Null_Access_t; Key : in String; Value : in Element_Access_Type); end Agar.Core.Event;
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- generic type T (<>) is abstract tagged limited private; type Parameters (<>) is limited private; with function Constructor (Params : not null access Parameters) return T is abstract; function Ada.Tags.Generic_Dispatching_Constructor (The_Tag : in Tag; Params : not null access Parameters) return T'Class; pragma Preelaborate (Ada.Tags.Generic_Dispatching_Constructor); pragma Convention (Intrinsic, Ada.Tags.Generic_Dispatching_Constructor);
with Hello; procedure Hello3 is begin Hello; Hello; Hello; end Hello3;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 onox <denkpadje@gmail.com> -- -- 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. private with Ada.Finalization; private with GL.Objects.Vertex_Arrays; private with EGL.Debug; private with EGL.Errors; private with EGL.Objects.Displays; private with EGL.Objects.Contexts; with EGL.Objects.Devices; package Orka.Contexts.EGL is pragma Preelaborate; type Device_EGL_Context is limited new Context with private; overriding function Create_Context (Version : Context_Version; Flags : Context_Flags := (others => False)) return Device_EGL_Context; -- Return a surfaceless EGL context using the default device function Create_Context (Device : Standard.EGL.Objects.Devices.Device; Version : Context_Version; Flags : Context_Flags := (others => False)) return Device_EGL_Context; -- Return a surfaceless EGL context using the given device private type EGL_Context is abstract limited new Ada.Finalization.Limited_Controlled and Context with record Version : Context_Version; Flags : Context_Flags; Features : Feature_Array := (others => False); Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; end record; overriding procedure Finalize (Object : in out EGL_Context); overriding procedure Enable (Object : in out EGL_Context; Subject : Feature); overriding function Enabled (Object : EGL_Context; Subject : Feature) return Boolean; overriding function Version (Object : EGL_Context) return Context_Version is (Object.Version); overriding function Flags (Object : EGL_Context) return Context_Flags is (Object.Flags); type Device_EGL_Context is limited new EGL_Context with record Context : Standard.EGL.Objects.Contexts.Context (Standard.EGL.Objects.Displays.Device); end record; overriding function Is_Current (Object : Device_EGL_Context; Kind : Task_Kind) return Boolean is (Object.Context.Is_Current (case Kind is when Current_Task => Standard.EGL.Objects.Contexts.Current_Task, when Any_Task => Standard.EGL.Objects.Contexts.Any_Task)); overriding procedure Make_Current (Object : Device_EGL_Context); overriding procedure Make_Not_Current (Object : Device_EGL_Context); ---------------------------------------------------------------------------- procedure Print_Debug (Display : Standard.EGL.Objects.Displays.Display; Flags : Context_Flags); procedure Print_Error (Error : Standard.EGL.Errors.Error_Code; Level : Standard.EGL.Debug.Severity; Command, Message : String); procedure Post_Initialize (Object : in out EGL_Context'Class); end Orka.Contexts.EGL;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . O S _ I N T E R F A C E -- -- -- -- B o d y -- -- -- -- Copyright (C) 1997-2005 Free Software Foundation -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNARL; see file COPYING. If not, write -- -- to the Free Software Foundation, 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. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the VxWorks version. -- This package encapsulates all direct interfaces to OS services -- that are needed by children of System. pragma Polling (Off); -- Turn off polling, we do not want ATC polling to take place during -- tasking operations. It causes infinite loops and other problems. package body System.OS_Interface is use type Interfaces.C.int; Low_Priority : constant := 255; -- VxWorks native (default) lowest scheduling priority. ---------- -- kill -- ---------- function kill (pid : t_id; sig : Signal) return int is function c_kill (pid : t_id; sig : Signal) return int; pragma Import (C, c_kill, "kill"); begin return c_kill (pid, sig); end kill; -------------------- -- Set_Time_Slice -- -------------------- function Set_Time_Slice (ticks : int) return int is function kernelTimeSlice (ticks : int) return int; pragma Import (C, kernelTimeSlice, "kernelTimeSlice"); begin return kernelTimeSlice (ticks); end Set_Time_Slice; ------------- -- sigwait -- ------------- function sigwait (set : access sigset_t; sig : access Signal) return int is Result : int; function sigwaitinfo (set : access sigset_t; sigvalue : System.Address) return int; pragma Import (C, sigwaitinfo, "sigwaitinfo"); begin Result := sigwaitinfo (set, System.Null_Address); if Result /= -1 then sig.all := Signal (Result); return 0; else sig.all := 0; return errno; end if; end sigwait; ----------------- -- To_Duration -- ----------------- function To_Duration (TS : timespec) return Duration is begin return Duration (TS.ts_sec) + Duration (TS.ts_nsec) / 10#1#E9; end To_Duration; ----------------- -- To_Timespec -- ----------------- function To_Timespec (D : Duration) return timespec is S : time_t; F : Duration; begin S := time_t (Long_Long_Integer (D)); F := D - Duration (S); -- If F has negative value due to a round-up, adjust for positive F -- value. if F < 0.0 then S := S - 1; F := F + 1.0; end if; return timespec'(ts_sec => S, ts_nsec => long (Long_Long_Integer (F * 10#1#E9))); end To_Timespec; ------------------------- -- To_VxWorks_Priority -- ------------------------- function To_VxWorks_Priority (Priority : in int) return int is begin return Low_Priority - Priority; end To_VxWorks_Priority; -------------------- -- To_Clock_Ticks -- -------------------- -- ??? - For now, we'll always get the system clock rate -- since it is allowed to be changed during run-time in -- VxWorks. A better method would be to provide an operation -- to set it that so we can always know its value. -- -- Another thing we should probably allow for is a resultant -- tick count greater than int'Last. This should probably -- be a procedure with two output parameters, one in the -- range 0 .. int'Last, and another representing the overflow -- count. function To_Clock_Ticks (D : Duration) return int is Ticks : Long_Long_Integer; Rate_Duration : Duration; Ticks_Duration : Duration; begin if D < 0.0 then return -1; end if; -- Ensure that the duration can be converted to ticks -- at the current clock tick rate without overflowing. Rate_Duration := Duration (sysClkRateGet); if D > (Duration'Last / Rate_Duration) then Ticks := Long_Long_Integer (int'Last); else Ticks_Duration := D * Rate_Duration; Ticks := Long_Long_Integer (Ticks_Duration); if Ticks_Duration > Duration (Ticks) then Ticks := Ticks + 1; end if; if Ticks > Long_Long_Integer (int'Last) then Ticks := Long_Long_Integer (int'Last); end if; end if; return int (Ticks); end To_Clock_Ticks; ---------------- -- VX_FP_TASK -- ---------------- function VX_FP_TASK return int is begin return 16#0008#; end VX_FP_TASK; end System.OS_Interface;
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Package_Manifests; with PortScan.Log; with Parameters; with Unix; with Ada.Characters.Latin_1; with Ada.Directories; with Ada.Exceptions; package body PortScan.Tests is package MAN renames Package_Manifests; package LOG renames PortScan.Log; package PM renames Parameters; package LAT renames Ada.Characters.Latin_1; package DIR renames Ada.Directories; package EX renames Ada.Exceptions; -------------------------------------------------------------------------------------------- -- exec_phase_check_plist -------------------------------------------------------------------------------------------- function exec_check_plist (specification : PSP.Portspecs; log_handle : TIO.File_Type; phase_name : String; seq_id : port_id; port_prefix : String; rootdir : String) return Boolean is passed_check : Boolean := True; namebase : constant String := specification.get_namebase; variant : constant String := HT.USS (all_ports (seq_id).port_variant); directory_list : entry_crate.Map; dossier_list : entry_crate.Map; begin LOG.log_phase_begin (log_handle, phase_name); TIO.Put_Line (log_handle, "====> Checking for package manifest issues"); begin if not ingest_manifests (specification => specification, log_handle => log_handle, directory_list => directory_list, dossier_list => dossier_list, seq_id => seq_id, namebase => namebase, port_prefix => port_prefix, rootdir => rootdir) then passed_check := False; end if; exception when surprise : others => TIO.Put_Line (log_handle, "exec_check_plist/ingest_manifests: " & EX.Exception_Information (surprise)); passed_check := False; end; begin if orphaned_directories_detected (log_handle => log_handle, directory_list => directory_list, namebase => namebase, port_prefix => port_prefix, rootdir => rootdir) then passed_check := False; end if; exception when surprise : others => TIO.Put_Line (log_handle, "exec_check_plist/orphaned_directories_detected: " & EX.Exception_Information (surprise)); passed_check := False; end; begin if missing_directories_detected (log_handle, directory_list) then passed_check := False; end if; exception when surprise : others => TIO.Put_Line (log_handle, "exec_check_plist/missing_directories_detected: " & EX.Exception_Information (surprise)); passed_check := False; end; begin if orphaned_files_detected (log_handle => log_handle, dossier_list => dossier_list, namebase => namebase, port_prefix => port_prefix, rootdir => rootdir) then passed_check := False; end if; exception when surprise : others => TIO.Put_Line (log_handle, "exec_check_plist/orphaned_files_detected: " & EX.Exception_Information (surprise)); passed_check := False; end; begin if missing_files_detected (log_handle, dossier_list) then passed_check := False; end if; exception when surprise : others => TIO.Put_Line (log_handle, "exec_check_plist/missing_files_detected: " & EX.Exception_Information (surprise)); passed_check := False; end; if passed_check then TIO.Put_Line (log_handle, "====> No manifest issues found"); end if; create_single_file_manifest (log_handle => log_handle, namebase => namebase, variant => variant, port_prefix => port_prefix, rootdir => rootdir); LOG.log_phase_end (log_handle); return passed_check; end exec_check_plist; -------------------------------------------------------------------------------------------- -- ingest_manifests -------------------------------------------------------------------------------------------- function ingest_manifests (specification : PSP.Portspecs; log_handle : TIO.File_Type; directory_list : in out entry_crate.Map; dossier_list : in out entry_crate.Map; seq_id : port_id; namebase : String; port_prefix : String; rootdir : String) return Boolean is procedure eat_plist (position : subpackage_crate.Cursor); procedure insert_directory (directory : String; subpackage : HT.Text); result : Boolean := True; procedure insert_directory (directory : String; subpackage : HT.Text) is numsep : Natural := HT.count_char (directory, LAT.Solidus); canvas : HT.Text := HT.SUS (directory); begin for x in 1 .. numsep + 1 loop declare paint : String := HT.USS (canvas); my_new_rec : entry_record := (subpackage, False); begin if paint /= "" then if not directory_list.Contains (canvas) then directory_list.Insert (canvas, my_new_rec); end if; canvas := HT.SUS (HT.head (paint, "/")); end if; end; end loop; end insert_directory; procedure eat_plist (position : subpackage_crate.Cursor) is -- We cannot confidently use File_operations.get_file_contents because that function -- allocates on the stack and attempting to read sufficiently large manifests result -- in a Storage_Error during allocation subpackage : HT.Text renames subpackage_crate.Element (position).subpackage; manifest_file : String := "/construction/" & namebase & "/.manifest." & HT.USS (subpackage) & ".mktmp"; handle : TIO.File_Type; identifier : constant String := HT.USS (subpackage) & " manifest: "; begin TIO.Open (handle, TIO.In_File, rootdir & manifest_file); loop exit when TIO.End_Of_File (handle); declare line : constant String := TIO.Get_Line (handle); new_rec : entry_record := (subpackage, False); begin if HT.leads (line, "@comment ") or else HT.leads (line, "@desktop-file-utils") or else HT.leads (line, "@terminfo") or else HT.leads (line, "@fcfontsdir") or else HT.leads (line, "@fontsdir") or else HT.leads (line, "@fc") or else HT.leads (line, "@rmtry ") or else HT.leads (line, "@glib-schemas") or else HT.leads (line, "@shared-mime-info") or else HT.leads (line, "@group") or else HT.leads (line, "@owner") or else HT.leads (line, "@exec ") or else HT.leads (line, "@unexec ") or else HT.leads (line, "@postunexec ") or else HT.leads (line, "@postexec ") or else HT.leads (line, "@preexec ") or else HT.leads (line, "@preunexec ") then null; elsif HT.leads (line, "@dir") then -- handle @dir and @dir(x,y,z) declare nokey : constant String := HT.part_2 (line, " "); dir : constant String := convert_to_absolute_path (port_prefix, nokey); dir_text : HT.Text := HT.SUS (dir); excludeit : Boolean; begin if directory_list.Contains (dir_text) then -- There is one case where a redundant @dir symbol is desired: -- *) when a non-standard PREFIX is used. Pkg(8) needs to be given an -- explicit command to remove the package's root directory. excludeit := (LAT.Solidus & dir = port_prefix) and then (port_prefix /= HT.USS (PM.configuration.dir_localbase)); if not excludeit then result := False; declare spkg : String := HT.USS (directory_list.Element (dir_text).subpackage); begin if spkg /= "" then TIO.Put_Line (log_handle, "Redundant @dir symbol, " & identifier & dir & " will already be created by the " & spkg & " manifest"); else TIO.Put_Line (log_handle, "Redundant @dir symbol, " & identifier & dir & " will already be created by another manifest"); end if; end; end if; else insert_directory (dir, subpackage); end if; end; else declare modline : String := modify_file_if_necessary (port_prefix, line); ml_text : HT.Text := HT.SUS (modline); begin if dossier_list.Contains (ml_text) then result := False; declare spkg : String := HT.USS (dossier_list.Element (ml_text).subpackage); begin TIO.Put_Line (log_handle, "Duplicate file entry, " & identifier & modline & " already present in " & spkg & " manifest"); end; else dossier_list.Insert (ml_text, new_rec); declare plistdir : String := DIR.Containing_Directory (modline); begin insert_directory (plistdir, subpackage); end; end if; end; end if; end; end loop; TIO.Close (handle); exception when issue : others => if TIO.Is_Open (handle) then TIO.Close (handle); end if; TIO.Put_Line (log_handle, identifier & "check-plist error: " & EX.Exception_Message (issue)); end eat_plist; begin all_ports (seq_id).subpackages.Iterate (eat_plist'Access); return result; end ingest_manifests; -------------------------------------------------------------------------------------------- -- directory_excluded -------------------------------------------------------------------------------------------- function directory_excluded (port_prefix, candidate : String) return Boolean is -- mandatory candidate has ${STAGEDIR}/ stripped (no leading slash) localbase : constant String := HT.substring (port_prefix, 1, 0); lblen : constant Natural := localbase'Length; begin if candidate = localbase then return True; end if; declare shortcan : String := HT.substring (candidate, lblen + 1, 0); begin if shortcan = "bin" or else shortcan = "etc" or else shortcan = "etc/rc.d" or else shortcan = "include" or else shortcan = "lib" or else shortcan = "lib/pkgconfig" or else shortcan = "libdata" or else shortcan = "libexec" or else shortcan = "sbin" or else shortcan = "share" or else shortcan = "www" then return True; end if; if not HT.leads (shortcan, "share/") then return False; end if; end; declare shortcan : String := HT.substring (candidate, lblen + 7, 0); begin if shortcan = "doc" or else shortcan = "examples" or else shortcan = "info" or else shortcan = "locale" or else shortcan = "man" or else shortcan = "nls" then return True; end if; if shortcan'Length /= 8 or else not HT.leads (shortcan, "man/man") then return False; end if; case shortcan (shortcan'Last) is when '1' .. '9' | 'l' | 'n' => return True; when others => return False; end case; end; end directory_excluded; -------------------------------------------------------------------------------------------- -- file_excluded -------------------------------------------------------------------------------------------- function file_excluded (localbase, candidate : String) return Boolean is begin if HT.trails (candidate, "info/dir") then -- removal of info files leaves entry uneasy to cleanup in info/dir return True; end if; if candidate = "share/xml/catalog.ports" then -- xmlcatmgr is constantly updating catalog.ports; ignore modification to that file return True; end if; if HT.leads (candidate, localbase & "/share/fonts/") then -- these files are cleaned up by deinstall script; don't consider as orphans if HT.trails (candidate, "/fonts.dir") or else HT.trails (candidate, "/fonts.scale") then return True; end if; end if; return False; end file_excluded; -------------------------------------------------------------------------------------------- -- orphaned_directories_detected -------------------------------------------------------------------------------------------- function orphaned_directories_detected (log_handle : TIO.File_Type; directory_list : in out entry_crate.Map; namebase : String; port_prefix : String; rootdir : String) return Boolean is localbase : constant String := HT.substring (port_prefix, 1, 0); stagedir : String := rootdir & "/construction/" & namebase & "/stage"; command : String := rootdir & "/usr/bin/find " & stagedir & " -type d -printf " & HT.DQ ("%P\n"); status : Integer; comres : String := HT.USS (Unix.piped_command (command, status)); markers : HT.Line_Markers; lblen : constant Natural := localbase'Length; result : Boolean := False; errprefix : constant String := "Orphaned directory detected: "; begin if status /= 0 then TIO.Put_Line ("orphaned_directories_detected: command error: " & comres); return True; end if; HT.initialize_markers (comres, markers); loop exit when not HT.next_line_present (comres, markers); declare line : constant String := HT.extract_line (comres, markers); plist_dir : HT.Text := HT.SUS (line); begin if line /= "" then if directory_list.Contains (plist_dir) then directory_list.Update_Element (Position => directory_list.Find (plist_dir), Process => mark_verified'Access); else if not directory_excluded (port_prefix, line) then if HT.leads (line, localbase) then TIO.Put_Line (log_handle, errprefix & HT.substring (line, lblen + 1, 0)); else TIO.Put_Line (log_handle, errprefix & line); end if; result := True; end if; end if; end if; end; end loop; return result; end orphaned_directories_detected; -------------------------------------------------------------------------------------------- -- mark_verified -------------------------------------------------------------------------------------------- procedure mark_verified (key : HT.Text; Element : in out entry_record) is begin Element.verified := True; end mark_verified; -------------------------------------------------------------------------------------------- -- missing_directories_detected -------------------------------------------------------------------------------------------- function missing_directories_detected (log_handle : TIO.File_Type; directory_list : in out entry_crate.Map) return Boolean is procedure check (position : entry_crate.Cursor); result : Boolean := False; procedure check (position : entry_crate.Cursor) is rec : entry_record renames entry_crate.Element (position); plist_dir : String := HT.USS (entry_crate.Key (position)); begin if not rec.verified then TIO.Put_Line (log_handle, "Directory " & plist_dir & " listed on " & HT.USS (rec.subpackage) & " manifest is not present in the stage directory."); result := True; end if; end check; begin directory_list.Iterate (check'Access); return result; end missing_directories_detected; -------------------------------------------------------------------------------------------- -- missing_files_detected -------------------------------------------------------------------------------------------- function missing_files_detected (log_handle : TIO.File_Type; dossier_list : in out entry_crate.Map) return Boolean is procedure check (position : entry_crate.Cursor); result : Boolean := False; procedure check (position : entry_crate.Cursor) is rec : entry_record renames entry_crate.Element (position); plist_file : String := HT.USS (entry_crate.Key (position)); begin if not rec.verified then TIO.Put_Line (log_handle, "File " & plist_file & " listed on " & HT.USS (rec.subpackage) & " manifest is not present in the stage directory."); result := True; end if; end check; begin dossier_list.Iterate (check'Access); return result; end missing_files_detected; -------------------------------------------------------------------------------------------- -- orphaned_files_detected -------------------------------------------------------------------------------------------- function orphaned_files_detected (log_handle : TIO.File_Type; dossier_list : in out entry_crate.Map; namebase : String; port_prefix : String; rootdir : String) return Boolean is localbase : constant String := HT.substring (port_prefix, 1, 0); stagedir : String := rootdir & "/construction/" & namebase & "/stage"; command : String := rootdir & "/usr/bin/find " & stagedir & " \( -type f -o -type l \) -printf " & HT.DQ ("%P\n"); status : Integer; comres : String := HT.USS (Unix.piped_command (command, status)); markers : HT.Line_Markers; lblen : constant Natural := localbase'Length; result : Boolean := False; errprefix : constant String := "Orphaned file detected: "; begin if status /= 0 then TIO.Put_Line ("orphaned_files_detected: command error: " & comres); return True; end if; HT.initialize_markers (comres, markers); loop exit when not HT.next_line_present (comres, markers); declare line : constant String := HT.extract_line (comres, markers); plist_file : HT.Text := HT.SUS (line); begin if not HT.IsBlank (plist_file) then if dossier_list.Contains (plist_file) then dossier_list.Update_Element (Position => dossier_list.Find (plist_file), Process => mark_verified'Access); else if not file_excluded (localbase, line) then if HT.leads (line, localbase) then TIO.Put_Line (log_handle, errprefix & HT.substring (line, lblen + 1, 0)); else TIO.Put_Line (log_handle, errprefix & line); end if; result := True; end if; end if; end if; end; end loop; return result; end orphaned_files_detected; -------------------------------------------------------------------------------------------- -- modify_file_if_necessary -------------------------------------------------------------------------------------------- function modify_file_if_necessary (port_prefix, original : String) return String is begin if HT.leads (original, "@info ") then return convert_to_absolute_path (port_prefix, HT.substring (original, 6, 0)); elsif HT.leads (original, "@sample") then -- Handle both @sample and @sample(x,y,z) declare no_sample : constant String := HT.part_2 (original, " "); begin return convert_to_absolute_path (port_prefix, HT.part_1 (no_sample, " ")); end; elsif HT.leads (original, "@shell ") then return convert_to_absolute_path (port_prefix, HT.substring (original, 7, 0)); elsif HT.leads (original, "@xmlcatmgr ") then return convert_to_absolute_path (port_prefix, HT.substring (original, 11, 0)); elsif HT.leads (original, "@(") then return convert_to_absolute_path (port_prefix, HT.part_2 (original, ") ")); else return convert_to_absolute_path (port_prefix, original); end if; end modify_file_if_necessary; -------------------------------------------------------------------------------------------- -- convert_to_absolute_path -------------------------------------------------------------------------------------------- function convert_to_absolute_path (port_prefix, raw : String) return String is begin if raw'Length < 2 then return raw; end if; if raw (raw'First) = LAT.Solidus then return HT.substring (raw, 1, 0); end if; return HT.substring (port_prefix, 1, 0) & LAT.Solidus & raw; end convert_to_absolute_path; -------------------------------------------------------------------------------------------- -- create_single_file_manifest -------------------------------------------------------------------------------------------- procedure create_single_file_manifest (log_handle : TIO.File_Type; namebase : String; variant : String; port_prefix : String; rootdir : String) is localbase : constant String := HT.substring (port_prefix, 1, 0); stagedir : String := rootdir & "/construction/" & namebase & "/stage"; command : String := rootdir & "/usr/bin/find " & stagedir & " \( -type f -o -type l \) ! -wholename " & HT.DQ ("*/share/licenses/*") & " -printf " & HT.DQ ("%P\n"); status : Integer; handle : TIO.File_Type; markers : HT.Line_Markers; comres : String := HT.USS (Unix.piped_command (command, status)); instdir : constant String := HT.USS (PM.configuration.dir_profile) & "/manifests"; dossier : constant String := instdir & "/" & namebase & "___" & variant & ".txt"; si_string : constant String := "====> Full manifest saved at " & dossier; no_string : constant String := "====> Failed to create " & dossier & " manifest"; lblen : constant Natural := localbase'Length; begin if status /= 0 then TIO.Put_Line ("create_single_file_manifest: command error: " & comres); TIO.Put_Line (log_handle, no_string); return; end if; begin if not DIR.Exists (instdir) then DIR.Create_Path (instdir); end if; TIO.Create (handle, TIO.Out_File, dossier); exception when TIO.Use_Error | TIO.Status_Error => TIO.Put_Line ("create_single_file_manifest: failed to create " & dossier); TIO.Put_Line (log_handle, no_string); return; end; HT.initialize_markers (comres, markers); begin loop exit when not HT.next_line_present (comres, markers); declare line : constant String := HT.extract_line (comres, markers); begin if not file_excluded (localbase, line) then if HT.leads (line, localbase) then TIO.Put_Line (handle, HT.substring (line, lblen + 1, 0)); else TIO.Put_Line (handle, line); end if; end if; end; end loop; TIO.Close (handle); TIO.Put_Line (log_handle, si_string); MAN.sort_manifest (MAN.Filename (dossier)); return; exception when TIO.End_Error => if TIO.Is_Open (handle) then TIO.Close (handle); end if; TIO.Put_Line (log_handle, no_string); return; end; end create_single_file_manifest; end PortScan.Tests;
-------------------------------------------------------------------------------- -- Copyright (c) 2013, Felix Krause <contact@flyx.org> -- -- 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.Helpers; with CL.Enumerations; with CL.API; package body CL.Command_Queues is package body Constructors is function Create (Attach_To : Contexts.Context'Class; Device : Platforms.Device'Class; Properties : Platforms.CQ_Property_Vector) return Queue is Error : aliased Enumerations.Error_Code; Raw : System.Address; function To_Bitfield is new Helpers.Record_To_Bitfield (Bit_Vector_Record => Platforms.CQ_Property_Vector, Used_Bits => 2); begin Raw := API.Create_Command_Queue (CL_Object (Attach_To).Location, CL_Object (Device).Location, To_Bitfield (Properties), Error'Unchecked_Access); Helpers.Error_Handler (Error); return Queue'(Ada.Finalization.Controlled with Location => Raw); end Create; end Constructors; overriding procedure Adjust (Object : in out Queue) is use type System.Address; begin if Object.Location /= System.Null_Address then Helpers.Error_Handler (API.Retain_Command_Queue (Object.Location)); end if; end Adjust; overriding procedure Finalize (Object : in out Queue) is use type System.Address; begin if Object.Location /= System.Null_Address then Helpers.Error_Handler (API.Release_Command_Queue (Object.Location)); end if; end Finalize; function Context (Object : Queue) return Contexts.Context is function Getter is new Helpers.Get_Parameter (Return_T => System.Address, Parameter_T => Enumerations.Command_Queue_Info, C_Getter => API.Get_Command_Queue_Info); function New_Context_Reference is new Helpers.New_Reference (Object_T => Contexts.Context); begin return New_Context_Reference (Getter (Object, Enumerations.Queue_Context)); end Context; function Device (Object : Queue) return Platforms.Device is function Getter is new Helpers.Get_Parameter (Return_T => System.Address, Parameter_T => Enumerations.Command_Queue_Info, C_Getter => API.Get_Command_Queue_Info); begin return Platforms.Device'(Ada.Finalization.Controlled with Location => Getter (Object, Enumerations.Queue_Device)); end Device; function Reference_Count (Object : Queue) return CL.UInt is function Getter is new Helpers.Get_Parameter (Return_T => UInt, Parameter_T => Enumerations.Command_Queue_Info, C_Getter => API.Get_Command_Queue_Info); begin return Getter (Object, Enumerations.Reference_Count); end Reference_Count; function Properties (Object : Queue) return Platforms.CQ_Property_Vector is function Getter is new Helpers.Get_Parameter (Return_T => Platforms.CQ_Property_Vector, Parameter_T => Enumerations.Command_Queue_Info, C_Getter => API.Get_Command_Queue_Info); begin return Getter (Object, Enumerations.Properties); end Properties; procedure Flush (Target : Queue) is begin Helpers.Error_Handler (API.Flush (Target.Location)); end Flush; procedure Finish (Target : Queue) is begin Helpers.Error_Handler (API.Finish (Target.Location)); end Finish; end CL.Command_Queues;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2014, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Characters.Internals; with League.Characters.Latin; with Matreshka.Internals.Unicode; package body XML.SAX.Pretty_Writers is use Matreshka.Internals.Unicode; use type League.Strings.Universal_String; XML_Namespace : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("http://www.w3.org/XML/1998/namespace"); XML_Prefix : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("xml"); XMLNS_Prefix : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("xmlns"); Amp_Entity_Reference : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("&amp;"); Apos_Entity_Reference : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("&apos;"); Quot_Entity_Reference : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("&quot;"); Gt_Entity_Reference : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("&gt;"); Lt_Entity_Reference : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("&lt;"); XML_1_0_Image : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("1.0"); XML_1_1_Image : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("1.1"); procedure Output_Name (Self : in out XML_Pretty_Writer; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Success : in out Boolean); -- Do vilidity checks, resolve namespace prefix when necessary and output -- name (of the tag or attribute). function Image (X_V : XML_Version) return League.Strings.Universal_String; -- Returns text representation of XML version. ---------------- -- Characters -- ---------------- overriding procedure Characters (Self : in out XML_Pretty_Writer; Text : League.Strings.Universal_String; Success : in out Boolean) is pragma Unreferenced (Success); begin if Self.Tag_Opened then Self.Destination.Put ('>'); Self.Tag_Opened := False; end if; Self.Destination.Put (Self.Escape (Text)); Self.Chars := True; end Characters; ------------- -- Comment -- ------------- overriding procedure Comment (Self : in out XML_Pretty_Writer; Text : League.Strings.Universal_String; Success : in out Boolean) is pragma Unreferenced (Success); begin -- Closing DTD, which was opened before. if Self.DTD_Opened then Self.Destination.Put ('>'); Self.DTD_Opened := False; end if; Self.Destination.Put ("<!-- "); Self.Destination.Put (Text); Self.Destination.Put (" -->"); end Comment; --------------- -- End_CDATA -- --------------- overriding procedure End_CDATA (Self : in out XML_Pretty_Writer; Success : in out Boolean) is begin null; end End_CDATA; ------------------ -- End_Document -- ------------------ overriding procedure End_Document (Self : in out XML_Pretty_Writer; Success : in out Boolean) is begin if Self.Nesting /= 0 then Success := False; return; end if; end End_Document; ------------- -- End_DTD -- ------------- overriding procedure End_DTD (Self : in out XML_Pretty_Writer; Success : in out Boolean) is pragma Unreferenced (Success); begin Self.Destination.Put ('>'); Self.DTD_Opened := False; end End_DTD; ----------------- -- End_Element -- ----------------- overriding procedure End_Element (Self : in out XML_Pretty_Writer; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Success : in out Boolean) is begin -- Validity check: Namespace_URI, Local_Name and Qualified_Name of close -- tag must match open tag. if Self.Current.Namespace_URI /= Namespace_URI or Self.Current.Local_Name /= Local_Name or Self.Current.Qualified_Name /= Qualified_Name then Self.Error := League.Strings.To_Universal_String ("namespace URI, local name or qualified name doesn't match" & " open tag"); Success := False; return; end if; -- Use empty tag when there are no any content inside the tag. if Self.Tag_Opened then Self.Destination.Put ("/>"); Self.Tag_Opened := False; -- Do automatic indentation then necessary. if Self.Offset /= 0 then Self.Indent := Self.Indent - Self.Offset; end if; else -- Do automatic indentation then necessary. if Self.Offset /= 0 then Self.Indent := Self.Indent - Self.Offset; if Self.Chars then Self.Chars := False; else Self.Destination.Put (League.Characters.Latin.Line_Feed); for J in 1 .. Self.Indent loop Self.Destination.Put (' '); end loop; end if; end if; Self.Destination.Put ("</"); Output_Name (Self, Namespace_URI, Local_Name, Qualified_Name, Success); Self.Destination.Put ('>'); end if; -- Pop current element information. Self.Current := Self.Stack.Last_Element; Self.Stack.Delete_Last; Self.Nesting := Self.Nesting - 1; end End_Element; ---------------- -- End_Entity -- ---------------- overriding procedure End_Entity (Self : in out XML_Pretty_Writer; Name : League.Strings.Universal_String; Success : in out Boolean) is begin null; end End_Entity; ------------------------ -- End_Prefix_Mapping -- ------------------------ overriding procedure End_Prefix_Mapping (Self : in out XML_Pretty_Writer; Prefix : League.Strings.Universal_String := League.Strings.Empty_Universal_String; Success : in out Boolean) is begin null; end End_Prefix_Mapping; ------------------ -- Error_String -- ------------------ overriding function Error_String (Self : XML_Pretty_Writer) return League.Strings.Universal_String is begin return Self.Error; end Error_String; ------------ -- Escape -- ------------ function Escape (Self : XML_Pretty_Writer; Text : League.Strings.Universal_String; Escape_All : Boolean := False) return League.Strings.Universal_String is Code : Code_Point; begin return Result : League.Strings.Universal_String do for J in 1 .. Text.Length loop Code := League.Characters.Internals.Internal (Text.Element (J)); case Text.Element (J).To_Wide_Wide_Character is when '&' => Result.Append (Amp_Entity_Reference); when ''' => if Escape_All then Result.Append (Apos_Entity_Reference); else Result.Append (Text.Element (J).To_Wide_Wide_Character); end if; when '"' => if Escape_All then Result.Append (Quot_Entity_Reference); else Result.Append (Text.Element (J).To_Wide_Wide_Character); end if; when '>' => if Escape_All then Result.Append (Gt_Entity_Reference); else Result.Append (Text.Element (J).To_Wide_Wide_Character); end if; when '<' => Result.Append (Lt_Entity_Reference); when others => -- Add support of choosing of Hexademical -- or Digital representation of Character references -- XML_1_1 2.2 Characters if Self.Version = XML_1_1 and then (Code in 16#1# .. 16#8# or else Code in 16#B# .. 16#C# or else Code in 16#E# .. 16#1F# or else Code in 16#7F# .. 16#84# or else Code in 16#86# .. 16#9F#) then declare Image : constant Wide_Wide_String := Code_Unit_32'Wide_Wide_Image (Code); begin Result := Result & "&#" & Image (Image'First + 1 .. Image'Last) & ";"; end; else Result.Append (Text.Element (J).To_Wide_Wide_Character); end if; end case; end loop; end return; end Escape; -------------------------- -- Ignorable_Whitespace -- -------------------------- overriding procedure Ignorable_Whitespace (Self : in out XML_Pretty_Writer; Text : League.Strings.Universal_String; Success : in out Boolean) is begin null; end Ignorable_Whitespace; ----------- -- Image -- ----------- function Image (X_V : XML_Version) return League.Strings.Universal_String is begin case X_V is when XML_1_0 => return XML_1_0_Image; when XML_1_1 => return XML_1_1_Image; end case; end Image; ----------- -- Merge -- ----------- procedure Merge (Current : in out Mappings.Map; Bank : Banks.Map) is C : Banks.Cursor := Banks.First (Bank); begin while Banks.Has_Element (C) loop Mappings.Include (Current, Banks.Key (C), Banks.Element (C)); Banks.Next (C); end loop; end Merge; ----------------- -- Output_Name -- ----------------- procedure Output_Name (Self : in out XML_Pretty_Writer; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Success : in out Boolean) is begin if Namespace_URI.Is_Empty then -- Non-namespaces mode. -- Validity check: Qualified_Name must not be empty. if Qualified_Name.Is_Empty then Self.Error := League.Strings.To_Universal_String ("qualified name is empty"); Success := False; return; end if; -- Append qualified name of the tag. Self.Destination.Put (Qualified_Name); else -- Namespaces mode. -- Validity check: local name must not be empty. if Local_Name.Is_Empty then Self.Error := League.Strings.To_Universal_String ("namespace is provides but local name is empty"); Success := False; return; end if; -- Lookup for namespace prefix. declare Position : constant Mappings.Cursor := Self.Current.Mapping.Find (Namespace_URI); begin if not Mappings.Has_Element (Position) then Self.Error := League.Strings.To_Universal_String ("namespace is not mapped to any prefix"); Success := False; return; end if; -- Output namespace prexif when namespace is not default. if not Mappings.Element (Position).Is_Empty then Self.Destination.Put (Mappings.Element (Position)); Self.Destination.Put (':'); end if; end; Self.Destination.Put (Local_Name); end if; end Output_Name; ---------------------------- -- Processing_Instruction -- ---------------------------- overriding procedure Processing_Instruction (Self : in out XML_Pretty_Writer; Target : League.Strings.Universal_String; Data : League.Strings.Universal_String; Success : in out Boolean) is pragma Unreferenced (Success); begin -- Closing DTD, which was opened before. if Self.DTD_Opened then Self.Destination.Put ('>'); Self.DTD_Opened := False; end if; end Processing_Instruction; ---------------- -- Set_Offset -- ---------------- not overriding procedure Set_Offset (Self : in out XML_Pretty_Writer; Offset : Natural) is begin Self.Offset := Offset; end Set_Offset; ---------------------------- -- Set_Output_Destination -- ---------------------------- procedure Set_Output_Destination (Self : in out XML_Pretty_Writer'Class; Output : not null SAX_Output_Destination_Access) is begin Self.Destination := Output; end Set_Output_Destination; ------------------------- -- Set_Value_Delimiter -- ------------------------- not overriding procedure Set_Value_Delimiter (Self : in out XML_Pretty_Writer; Delimiter : League.Characters.Universal_Character) is begin Self.Delimiter := Delimiter; end Set_Value_Delimiter; ----------------- -- Set_Version -- ----------------- procedure Set_Version (Self : in out XML_Pretty_Writer; Version : XML_Version) is begin Self.Version := Version; end Set_Version; -------------------- -- Skipped_Entity -- -------------------- overriding procedure Skipped_Entity (Self : in out XML_Pretty_Writer; Name : League.Strings.Universal_String; Success : in out Boolean) is begin null; end Skipped_Entity; ----------------- -- Start_CDATA -- ----------------- overriding procedure Start_CDATA (Self : in out XML_Pretty_Writer; Success : in out Boolean) is begin null; end Start_CDATA; -------------------- -- Start_Document -- -------------------- overriding procedure Start_Document (Self : in out XML_Pretty_Writer; Success : in out Boolean) is pragma Unreferenced (Success); begin Self.Destination.Put (League.Strings.To_Universal_String ("<?xml version=") & Self.Delimiter & Image (Self.Version) & Self.Delimiter & "?>"); Self.Nesting := 0; -- Reset namespace mapping and initialize it by XML namespace URI mapped -- to 'xml' prefix. Self.Current.Mapping.Clear; Self.Current.Mapping.Insert (XML_Namespace, XML_Prefix); end Start_Document; --------------- -- Start_DTD -- --------------- overriding procedure Start_DTD (Self : in out XML_Pretty_Writer; Name : League.Strings.Universal_String; Public_Id : League.Strings.Universal_String; System_Id : League.Strings.Universal_String; Success : in out Boolean) is pragma Unreferenced (Success); begin Self.Destination.Put ("<!DOCTYPE " & Name); if not Public_Id.Is_Empty then Self.Destination.Put (" PUBLIC " & Public_Id & " " & System_Id); elsif not System_Id.Is_Empty then Self.Destination.Put (" SYSTEM' " & System_Id); end if; Self.DTD_Opened := True; end Start_DTD; ------------------- -- Start_Element -- ------------------- overriding procedure Start_Element (Self : in out XML_Pretty_Writer; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Attributes : XML.SAX.Attributes.SAX_Attributes; Success : in out Boolean) is begin -- Closing DTD, which was opened before. if Self.DTD_Opened then Self.Destination.Put ('>'); Self.DTD_Opened := False; end if; -- Closing Tag, which was opened before. if Self.Tag_Opened then Self.Destination.Put ('>'); Self.Tag_Opened := False; end if; -- Push to stack current element and namespace mapping Self.Stack.Append (Self.Current); Self.Current.Namespace_URI := Namespace_URI; Self.Current.Local_Name := Local_Name; Self.Current.Qualified_Name := Qualified_Name; if not Self.Requested_NS.Is_Empty then -- Append Bank and Current namespaces. Merge (Self.Current.Mapping, Self.Requested_NS); end if; if Self.Offset /= 0 then -- Do automatic indentation when necessary. if Self.Chars then Self.Chars := False; else Self.Destination.Put (League.Characters.Latin.Line_Feed); for J in 1 .. Self.Indent loop Self.Destination.Put (' '); end loop; end if; Self.Indent := Self.Indent + Self.Offset; end if; Self.Destination.Put ('<'); Output_Name (Self, Namespace_URI, Local_Name, Qualified_Name, Success); if not Success then return; end if; -- Output namespace mappings. declare Position : Banks.Cursor := Self.Requested_NS.First; begin while Banks.Has_Element (Position) loop Self.Destination.Put (' '); Self.Destination.Put (XMLNS_Prefix); if not Banks.Element (Position).Is_Empty then -- Non-default prefix. Self.Destination.Put (':'); Self.Destination.Put (Banks.Element (Position)); end if; Self.Destination.Put ('='); Self.Destination.Put (Self.Delimiter); Self.Destination.Put (Banks.Key (Position)); Self.Destination.Put (Self.Delimiter); Banks.Next (Position); end loop; end; -- Output attributes. for J in 1 .. Attributes.Length loop Self.Destination.Put (' '); Output_Name (Self, Attributes.Namespace_URI (J), Attributes.Local_Name (J), Attributes.Qualified_Name (J), Success); if not Success then return; end if; Self.Destination.Put ("="); Self.Destination.Put (Self.Delimiter); Self.Destination.Put (Self.Escape (Attributes.Value (J), True)); Self.Destination.Put (Self.Delimiter); end loop; Self.Nesting := Self.Nesting + 1; Self.Tag_Opened := True; Self.Requested_NS.Clear; end Start_Element; ------------------ -- Start_Entity -- ------------------ overriding procedure Start_Entity (Self : in out XML_Pretty_Writer; Name : League.Strings.Universal_String; Success : in out Boolean) is begin null; end Start_Entity; -------------------------- -- Start_Prefix_Mapping -- -------------------------- overriding procedure Start_Prefix_Mapping (Self : in out XML_Pretty_Writer; Prefix : League.Strings.Universal_String := League.Strings.Empty_Universal_String; Namespace_URI : League.Strings.Universal_String; Success : in out Boolean) is begin if Namespace_URI.Is_Empty then -- XXX error should be reported Success := False; return; end if; -- Append prefix mapping, to temp set of mapping scope Self.Requested_NS.Include (Namespace_URI, Prefix); end Start_Prefix_Mapping; end XML.SAX.Pretty_Writers;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Life is -- D: Die, S: Stay the same, G: Grow a new cell type Rules_Type is (D, S, G); type Rule_Set is array (Natural range 0 .. 8) of Rules_Type; type Grid_Type is array (Natural range <>, Natural range <>) of Boolean; type Points_Type is array(Natural range <>, Natural range <>) of Natural; type Life (Width : Natural := 10; Height : Natural := 10) is record Generation : Natural := 0; Rules : Rule_Set := (D, D, S, G, D, D, D, D, D); Grid : Grid_Type (1 .. Width, 1 .. Height) := (others => (others => false)); Next_Grid : Grid_Type (1 .. Width, 1 .. Height) := (others => (others => false)); end record; function Get(Self : Life; X : Natural; Y : Natural) return Boolean is begin if X > 0 and X <= Self.Width and Y > 0 and Y <= Self.Height then return Self.Grid (X, Y); end if; return false; end get; function Get_Neighbors(Self : Life; X : Natural; Y : Natural) return Natural is Neighbors: Natural; begin Neighbors := 0; for X_Offset in Integer range -1 .. 1 loop for Y_Offset in Integer range -1 .. 1 loop -- Don't count the offset 0, 0 if X_Offset /= 0 or Y_Offset /= 0 then if get(Self, X+X_Offset, Y+Y_Offset) then Neighbors := Neighbors + 1; end if; end if; end loop; end loop; return Neighbors; end Get_Neighbors; procedure Print_Grid(Self : Life) is begin Put ("Generation "); Put (Self.Generation); Put_Line(""); Put ("+"); for X in Self.Grid'Range (1) loop Put ("-"); end loop; Put_Line ("+"); for Y in Self.Grid'Range (2) loop Put ("|"); for X in Self.Grid'Range (1) loop if Get(Self, X, Y) then Put("0"); else Put(" "); end if; end loop; Put_Line ("|"); end loop; Put ("+"); for X in Self.Grid'Range (1) loop Put ("-"); end loop; Put_Line ("+"); end Print_Grid; procedure Next_Generation(Self : out Life) is Neighbors : Natural; Next_State : Rules_Type; begin for X in Integer range 1 .. Self.Width loop for Y in Integer range 1 .. Self.Height loop Neighbors := Get_Neighbors(Self, x, y); Next_State := Self.Rules (Neighbors); if Next_State = G then Self.Next_Grid (X, Y) := TRUE; elsif Next_State = D then Self.Next_Grid (X, Y) := FALSE; end if; end loop; end loop; Self.Generation := Self.Generation + 1; for X in Integer range 1 .. Self.Width loop for Y in Integer range 1 .. Self.Height loop Self.Grid (X, Y) := Self.Next_Grid(X, Y); end loop; end loop; end Next_Generation; procedure Add_Figure(Self : out Life; X : in Natural; Y : in Natural; Points : in Points_Type) is begin for I in points'Range loop Self.Grid(X+Points(I, 0), Y+Points(I, 1)) := TRUE; Self.Next_Grid(X+Points(I, 0), Y+Points(I, 1)) := TRUE; end loop; end Add_Figure; Rpentomino : Points_Type := ((1, 0), (2, 0), (0, 1), (1, 1), (1, 2)); Block : Points_Type := ((0, 0), (1, 0), (0, 1), (1, 1)); Blinker : Points_Type := ((1, 0), (1, 1), (1, 2)); Beacon : Points_Type := ((0, 0), (0, 1), (1, 0), (2, 3), (3, 2), (3, 3)); Rules : Rule_Set := (D, D, S, G, D, D, D, D, D); Game : Life(Width => 20, Height => 10); begin Add_Figure(Game, 15, 3, BEACON); Add_Figure(Game, 5, 5, Rpentomino); loop Print_Grid(Game); Next_Generation(Game); delay(1.0); end loop; end Life;
package Giza.Bitmap_Fonts.FreeSerifBoldItalic32pt7b is Font : constant Giza.Font.Ref_Const; private FreeSerifBoldItalic32pt7bBitmaps : aliased constant Font_Bitmap := ( 16#00#, 16#07#, 16#C0#, 16#00#, 16#FE#, 16#00#, 16#0F#, 16#F0#, 16#01#, 16#FF#, 16#00#, 16#1F#, 16#F0#, 16#01#, 16#FF#, 16#00#, 16#1F#, 16#F0#, 16#03#, 16#FE#, 16#00#, 16#3F#, 16#E0#, 16#03#, 16#FE#, 16#00#, 16#3F#, 16#C0#, 16#03#, 16#FC#, 16#00#, 16#3F#, 16#80#, 16#03#, 16#F8#, 16#00#, 16#3F#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#7E#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#7C#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#78#, 16#00#, 16#07#, 16#80#, 16#00#, 16#F0#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#1C#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#7F#, 16#80#, 16#07#, 16#F8#, 16#00#, 16#FF#, 16#C0#, 16#0F#, 16#FC#, 16#00#, 16#FF#, 16#C0#, 16#0F#, 16#FC#, 16#00#, 16#7F#, 16#80#, 16#01#, 16#E0#, 16#00#, 16#0F#, 16#00#, 16#0F#, 16#0F#, 16#C0#, 16#0F#, 16#CF#, 16#E0#, 16#0F#, 16#EF#, 16#F0#, 16#0F#, 16#F7#, 16#F8#, 16#07#, 16#FB#, 16#F8#, 16#03#, 16#F9#, 16#FC#, 16#01#, 16#FC#, 16#FC#, 16#00#, 16#FC#, 16#7E#, 16#00#, 16#7E#, 16#3E#, 16#00#, 16#3E#, 16#1F#, 16#00#, 16#1F#, 16#0F#, 16#80#, 16#1F#, 16#8F#, 16#80#, 16#0F#, 16#87#, 16#C0#, 16#07#, 16#C3#, 16#C0#, 16#03#, 16#C1#, 16#E0#, 16#01#, 16#E0#, 16#E0#, 16#00#, 16#E0#, 16#70#, 16#00#, 16#70#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#E0#, 16#3E#, 16#00#, 16#00#, 16#7C#, 16#03#, 16#C0#, 16#00#, 16#07#, 16#C0#, 16#7C#, 16#00#, 16#00#, 16#78#, 16#07#, 16#C0#, 16#00#, 16#0F#, 16#80#, 16#F8#, 16#00#, 16#00#, 16#F8#, 16#0F#, 16#80#, 16#00#, 16#1F#, 16#01#, 16#F0#, 16#00#, 16#01#, 16#F0#, 16#1F#, 16#00#, 16#00#, 16#1E#, 16#01#, 16#E0#, 16#00#, 16#03#, 16#E0#, 16#3E#, 16#00#, 16#00#, 16#3E#, 16#03#, 16#E0#, 16#00#, 16#07#, 16#C0#, 16#7C#, 16#00#, 16#3F#, 16#FF#, 16#FF#, 16#FE#, 16#03#, 16#FF#, 16#FF#, 16#FF#, 16#E0#, 16#3F#, 16#FF#, 16#FF#, 16#FE#, 16#03#, 16#FF#, 16#FF#, 16#FF#, 16#E0#, 16#7F#, 16#FF#, 16#FF#, 16#FC#, 16#00#, 16#1F#, 16#01#, 16#F0#, 16#00#, 16#01#, 16#F0#, 16#1F#, 16#00#, 16#00#, 16#3E#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#E0#, 16#3E#, 16#00#, 16#00#, 16#7C#, 16#07#, 16#C0#, 16#00#, 16#07#, 16#C0#, 16#7C#, 16#00#, 16#00#, 16#F8#, 16#07#, 16#80#, 16#00#, 16#0F#, 16#80#, 16#F8#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#FC#, 16#07#, 16#FF#, 16#FF#, 16#FF#, 16#C0#, 16#7F#, 16#FF#, 16#FF#, 16#FC#, 16#0F#, 16#FF#, 16#FF#, 16#FF#, 16#80#, 16#FF#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#3E#, 16#03#, 16#E0#, 16#00#, 16#07#, 16#C0#, 16#7C#, 16#00#, 16#00#, 16#7C#, 16#07#, 16#C0#, 16#00#, 16#07#, 16#80#, 16#78#, 16#00#, 16#00#, 16#F8#, 16#0F#, 16#80#, 16#00#, 16#0F#, 16#80#, 16#F8#, 16#00#, 16#01#, 16#F0#, 16#1F#, 16#00#, 16#00#, 16#1F#, 16#01#, 16#F0#, 16#00#, 16#03#, 16#E0#, 16#3E#, 16#00#, 16#00#, 16#3E#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#E0#, 16#3E#, 16#00#, 16#00#, 16#7C#, 16#07#, 16#C0#, 16#00#, 16#07#, 16#C0#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#80#, 16#00#, 16#7E#, 16#1F#, 16#F0#, 16#00#, 16#7C#, 16#0E#, 16#7C#, 16#00#, 16#7C#, 16#07#, 16#1F#, 16#80#, 16#3E#, 16#07#, 16#07#, 16#80#, 16#3E#, 16#03#, 16#83#, 16#C0#, 16#1F#, 16#01#, 16#C0#, 16#E0#, 16#1F#, 16#81#, 16#C0#, 16#60#, 16#0F#, 16#C0#, 16#E0#, 16#30#, 16#07#, 16#F0#, 16#70#, 16#18#, 16#03#, 16#F8#, 16#78#, 16#08#, 16#01#, 16#FE#, 16#38#, 16#04#, 16#00#, 16#FF#, 16#9C#, 16#00#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#0E#, 16#FF#, 16#80#, 16#00#, 16#0F#, 16#3F#, 16#E0#, 16#00#, 16#07#, 16#0F#, 16#F0#, 16#10#, 16#03#, 16#87#, 16#F8#, 16#18#, 16#01#, 16#C1#, 16#FC#, 16#0C#, 16#01#, 16#C0#, 16#FE#, 16#06#, 16#00#, 16#E0#, 16#7F#, 16#03#, 16#00#, 16#70#, 16#3F#, 16#83#, 16#C0#, 16#70#, 16#1F#, 16#81#, 16#E0#, 16#38#, 16#0F#, 16#C0#, 16#F8#, 16#1C#, 16#0F#, 16#C0#, 16#FC#, 16#1E#, 16#07#, 16#E0#, 16#3F#, 16#0E#, 16#07#, 16#E0#, 16#07#, 16#E7#, 16#07#, 16#E0#, 16#01#, 16#FF#, 16#8F#, 16#C0#, 16#00#, 16#3F#, 16#FF#, 16#C0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#78#, 16#00#, 16#01#, 16#FF#, 16#F0#, 16#01#, 16#F8#, 16#00#, 16#03#, 16#FC#, 16#7C#, 16#07#, 16#F0#, 16#00#, 16#07#, 16#F8#, 16#3F#, 16#FF#, 16#E0#, 16#00#, 16#0F#, 16#F0#, 16#0F#, 16#F8#, 16#E0#, 16#00#, 16#1F#, 16#F0#, 16#0C#, 16#01#, 16#C0#, 16#00#, 16#3F#, 16#E0#, 16#0C#, 16#03#, 16#C0#, 16#00#, 16#3F#, 16#C0#, 16#0C#, 16#03#, 16#80#, 16#00#, 16#7F#, 16#C0#, 16#0C#, 16#07#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#1C#, 16#07#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#18#, 16#0E#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#18#, 16#1E#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#38#, 16#1C#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#30#, 16#3C#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#70#, 16#38#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#60#, 16#70#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#E0#, 16#70#, 16#00#, 16#00#, 16#FE#, 16#01#, 16#C0#, 16#E0#, 16#00#, 16#00#, 16#7E#, 16#03#, 16#81#, 16#E0#, 16#07#, 16#E0#, 16#7F#, 16#0F#, 16#01#, 16#C0#, 16#1F#, 16#F8#, 16#3F#, 16#FE#, 16#03#, 16#80#, 16#7F#, 16#FC#, 16#1F#, 16#FC#, 16#03#, 16#80#, 16#FF#, 16#8E#, 16#07#, 16#E0#, 16#07#, 16#01#, 16#FE#, 16#07#, 16#00#, 16#00#, 16#0F#, 16#03#, 16#FC#, 16#03#, 16#00#, 16#00#, 16#0E#, 16#07#, 16#F8#, 16#03#, 16#00#, 16#00#, 16#1C#, 16#0F#, 16#F8#, 16#03#, 16#00#, 16#00#, 16#1C#, 16#0F#, 16#F0#, 16#03#, 16#00#, 16#00#, 16#38#, 16#1F#, 16#F0#, 16#03#, 16#00#, 16#00#, 16#38#, 16#1F#, 16#E0#, 16#03#, 16#00#, 16#00#, 16#70#, 16#1F#, 16#E0#, 16#06#, 16#00#, 16#00#, 16#F0#, 16#3F#, 16#C0#, 16#06#, 16#00#, 16#00#, 16#E0#, 16#3F#, 16#C0#, 16#06#, 16#00#, 16#01#, 16#C0#, 16#3F#, 16#C0#, 16#0C#, 16#00#, 16#01#, 16#C0#, 16#3F#, 16#80#, 16#1C#, 16#00#, 16#03#, 16#80#, 16#3F#, 16#80#, 16#18#, 16#00#, 16#07#, 16#80#, 16#3F#, 16#80#, 16#38#, 16#00#, 16#07#, 16#00#, 16#3F#, 16#80#, 16#70#, 16#00#, 16#0E#, 16#00#, 16#1F#, 16#80#, 16#E0#, 16#00#, 16#0E#, 16#00#, 16#1F#, 16#C1#, 16#E0#, 16#00#, 16#1C#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#00#, 16#3C#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#00#, 16#38#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#8F#, 16#80#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#7E#, 16#03#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#FC#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#3E#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#7E#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#C3#, 16#E0#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#03#, 16#FF#, 16#E0#, 16#07#, 16#FF#, 16#F0#, 16#3F#, 16#FE#, 16#01#, 16#FC#, 16#FF#, 16#00#, 16#FF#, 16#C0#, 16#3F#, 16#07#, 16#F8#, 16#07#, 16#F0#, 16#0F#, 16#E0#, 16#7F#, 16#80#, 16#3E#, 16#01#, 16#FC#, 16#07#, 16#F8#, 16#07#, 16#C0#, 16#1F#, 16#80#, 16#7F#, 16#C0#, 16#78#, 16#03#, 16#F8#, 16#03#, 16#FC#, 16#07#, 16#00#, 16#7F#, 16#00#, 16#3F#, 16#E0#, 16#E0#, 16#07#, 16#F0#, 16#03#, 16#FE#, 16#1C#, 16#00#, 16#FF#, 16#00#, 16#1F#, 16#F3#, 16#C0#, 16#0F#, 16#F0#, 16#01#, 16#FF#, 16#38#, 16#00#, 16#FF#, 16#00#, 16#0F#, 16#FF#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#FF#, 16#E0#, 16#00#, 16#FF#, 16#80#, 16#07#, 16#FE#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#FF#, 16#C0#, 16#03#, 16#FF#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#3F#, 16#F8#, 16#07#, 16#7F#, 16#FC#, 16#0F#, 16#FF#, 16#E0#, 16#E3#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FC#, 16#1F#, 16#FF#, 16#FE#, 16#7F#, 16#FF#, 16#80#, 16#FF#, 16#FF#, 16#83#, 16#FF#, 16#F0#, 16#07#, 16#FF#, 16#F0#, 16#0F#, 16#FE#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#3F#, 16#80#, 16#0F#, 16#0F#, 16#CF#, 16#EF#, 16#F7#, 16#FB#, 16#F9#, 16#FC#, 16#FC#, 16#7E#, 16#3E#, 16#1F#, 16#0F#, 16#8F#, 16#87#, 16#C3#, 16#C1#, 16#E0#, 16#E0#, 16#70#, 16#00#, 16#00#, 16#00#, 16#20#, 16#00#, 16#07#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#3C#, 16#00#, 16#07#, 16#80#, 16#00#, 16#F0#, 16#00#, 16#1E#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#7C#, 16#00#, 16#0F#, 16#80#, 16#01#, 16#F0#, 16#00#, 16#3F#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#7E#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#FC#, 16#00#, 16#1F#, 16#80#, 16#01#, 16#F8#, 16#00#, 16#3F#, 16#80#, 16#03#, 16#F0#, 16#00#, 16#7F#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#7E#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#7E#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#FE#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#FC#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#FC#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#FC#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#FC#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#7C#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#7C#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#7C#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#3C#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#1E#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#70#, 16#00#, 16#07#, 16#00#, 16#00#, 16#30#, 16#00#, 16#03#, 16#80#, 16#00#, 16#18#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#20#, 16#00#, 16#03#, 16#00#, 16#00#, 16#38#, 16#00#, 16#01#, 16#80#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#70#, 16#00#, 16#07#, 16#00#, 16#00#, 16#78#, 16#00#, 16#07#, 16#80#, 16#00#, 16#3C#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#3C#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#3E#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#3E#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#3F#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#3F#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#3F#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#7F#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#7F#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#7F#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#FE#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#FE#, 16#00#, 16#0F#, 16#C0#, 16#01#, 16#FC#, 16#00#, 16#1F#, 16#C0#, 16#01#, 16#F8#, 16#00#, 16#3F#, 16#80#, 16#03#, 16#F0#, 16#00#, 16#3E#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#7C#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#F0#, 16#00#, 16#1F#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#3C#, 16#00#, 16#07#, 16#80#, 16#00#, 16#F0#, 16#00#, 16#1C#, 16#00#, 16#03#, 16#80#, 16#00#, 16#70#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#01#, 16#C1#, 16#F0#, 16#71#, 16#F0#, 16#78#, 16#7D#, 16#FC#, 16#38#, 16#7F#, 16#FE#, 16#0C#, 16#3F#, 16#FF#, 16#84#, 16#3F#, 16#DF#, 16#E2#, 16#3F#, 16#C7#, 16#F9#, 16#3F#, 16#C0#, 16#07#, 16#B0#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#EC#, 16#00#, 16#7F#, 16#93#, 16#FC#, 16#7F#, 16#88#, 16#FF#, 16#FF#, 16#84#, 16#3F#, 16#FF#, 16#C3#, 16#0F#, 16#FF#, 16#C3#, 16#83#, 16#F7#, 16#C1#, 16#E1#, 16#F1#, 16#C1#, 16#F0#, 16#78#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#0F#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FC#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#80#, 16#FC#, 16#1F#, 16#E1#, 16#FF#, 16#1F#, 16#F1#, 16#FF#, 16#1F#, 16#F0#, 16#FF#, 16#07#, 16#F0#, 16#3E#, 16#01#, 16#E0#, 16#1E#, 16#01#, 16#C0#, 16#38#, 16#07#, 16#00#, 16#E0#, 16#1C#, 16#07#, 16#80#, 16#E0#, 16#08#, 16#00#, 16#7F#, 16#FF#, 16#BF#, 16#FF#, 16#DF#, 16#FF#, 16#CF#, 16#FF#, 16#E7#, 16#FF#, 16#F7#, 16#FF#, 16#FB#, 16#FF#, 16#FC#, 16#1E#, 16#1F#, 16#EF#, 16#FB#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FD#, 16#FE#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#03#, 16#F1#, 16#E0#, 16#00#, 16#3F#, 16#07#, 16#80#, 16#03#, 16#F0#, 16#1E#, 16#00#, 16#3F#, 16#00#, 16#F0#, 16#03#, 16#F8#, 16#07#, 16#C0#, 16#3F#, 16#80#, 16#3E#, 16#01#, 16#FC#, 16#01#, 16#F0#, 16#1F#, 16#C0#, 16#0F#, 16#81#, 16#FE#, 16#00#, 16#FE#, 16#0F#, 16#F0#, 16#07#, 16#F0#, 16#FF#, 16#00#, 16#3F#, 16#87#, 16#F8#, 16#01#, 16#FC#, 16#7F#, 16#C0#, 16#0F#, 16#E3#, 16#FC#, 16#00#, 16#FF#, 16#3F#, 16#E0#, 16#07#, 16#F9#, 16#FF#, 16#00#, 16#3F#, 16#CF#, 16#F0#, 16#01#, 16#FE#, 16#7F#, 16#80#, 16#1F#, 16#F7#, 16#FC#, 16#00#, 16#FF#, 16#BF#, 16#C0#, 16#07#, 16#F9#, 16#FE#, 16#00#, 16#3F#, 16#CF#, 16#F0#, 16#03#, 16#FE#, 16#FF#, 16#80#, 16#1F#, 16#F7#, 16#F8#, 16#00#, 16#FF#, 16#3F#, 16#C0#, 16#0F#, 16#F9#, 16#FE#, 16#00#, 16#7F#, 16#CF#, 16#F0#, 16#03#, 16#FC#, 16#7F#, 16#00#, 16#1F#, 16#E3#, 16#F8#, 16#01#, 16#FF#, 16#1F#, 16#C0#, 16#0F#, 16#F0#, 16#FE#, 16#00#, 16#7F#, 16#87#, 16#F0#, 16#07#, 16#F8#, 16#3F#, 16#00#, 16#3F#, 16#C0#, 16#F8#, 16#03#, 16#FC#, 16#07#, 16#C0#, 16#1F#, 16#C0#, 16#3E#, 16#00#, 16#FC#, 16#00#, 16#F0#, 16#0F#, 16#E0#, 16#07#, 16#80#, 16#FE#, 16#00#, 16#1E#, 16#07#, 16#C0#, 16#00#, 16#78#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#7F#, 16#FC#, 16#01#, 16#FF#, 16#FE#, 16#00#, 16#7F#, 16#FF#, 16#80#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#3F#, 16#FF#, 16#FF#, 16#0F#, 16#FF#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#F8#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#7F#, 16#FF#, 16#80#, 16#07#, 16#FF#, 16#FE#, 16#00#, 16#3F#, 16#FF#, 16#F8#, 16#03#, 16#C0#, 16#FF#, 16#C0#, 16#38#, 16#03#, 16#FF#, 16#01#, 16#80#, 16#0F#, 16#F8#, 16#18#, 16#00#, 16#7F#, 16#C1#, 16#80#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#07#, 16#00#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#07#, 16#00#, 16#04#, 16#00#, 16#70#, 16#00#, 16#60#, 16#07#, 16#00#, 16#06#, 16#00#, 16#70#, 16#00#, 16#70#, 16#06#, 16#00#, 16#0F#, 16#80#, 16#7F#, 16#FF#, 16#F8#, 16#07#, 16#FF#, 16#FF#, 16#C0#, 16#7F#, 16#FF#, 16#FC#, 16#07#, 16#FF#, 16#FF#, 16#E0#, 16#7F#, 16#FF#, 16#FF#, 16#07#, 16#FF#, 16#FF#, 16#F0#, 16#3F#, 16#FF#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#03#, 16#FF#, 16#F0#, 16#00#, 16#3F#, 16#FF#, 16#C0#, 16#03#, 16#FF#, 16#FF#, 16#00#, 16#3C#, 16#1F#, 16#F8#, 16#03#, 16#80#, 16#3F#, 16#E0#, 16#18#, 16#01#, 16#FF#, 16#01#, 16#80#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#80#, 16#00#, 16#FF#, 16#FE#, 16#00#, 16#07#, 16#FF#, 16#F8#, 16#00#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#03#, 16#C0#, 16#03#, 16#F0#, 16#3F#, 16#00#, 16#1F#, 16#03#, 16#FC#, 16#01#, 16#F0#, 16#1F#, 16#E0#, 16#0F#, 16#00#, 16#FF#, 16#80#, 16#F0#, 16#03#, 16#FE#, 16#1E#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#80#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#06#, 16#FF#, 16#00#, 16#00#, 16#06#, 16#7F#, 16#80#, 16#00#, 16#06#, 16#7F#, 16#C0#, 16#00#, 16#06#, 16#3F#, 16#C0#, 16#00#, 16#06#, 16#1F#, 16#E0#, 16#00#, 16#06#, 16#0F#, 16#F0#, 16#00#, 16#06#, 16#0F#, 16#F0#, 16#00#, 16#06#, 16#07#, 16#F8#, 16#00#, 16#06#, 16#03#, 16#FC#, 16#00#, 16#07#, 16#03#, 16#FE#, 16#00#, 16#07#, 16#01#, 16#FE#, 16#00#, 16#07#, 16#00#, 16#FF#, 16#00#, 16#07#, 16#00#, 16#7F#, 16#80#, 16#07#, 16#00#, 16#7F#, 16#C0#, 16#07#, 16#00#, 16#3F#, 16#C0#, 16#07#, 16#00#, 16#1F#, 16#E0#, 16#07#, 16#00#, 16#0F#, 16#F0#, 16#07#, 16#00#, 16#0F#, 16#F0#, 16#03#, 16#FF#, 16#FF#, 16#FF#, 16#C3#, 16#FF#, 16#FF#, 16#FF#, 16#C1#, 16#FF#, 16#FF#, 16#FF#, 16#E0#, 16#FF#, 16#FF#, 16#FF#, 16#F0#, 16#7F#, 16#FF#, 16#FF#, 16#F0#, 16#7F#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#FE#, 16#00#, 16#0F#, 16#FF#, 16#F8#, 16#00#, 16#1F#, 16#FF#, 16#F0#, 16#00#, 16#7F#, 16#FF#, 16#E0#, 16#00#, 16#FF#, 16#FF#, 16#80#, 16#03#, 16#FF#, 16#FF#, 16#00#, 16#07#, 16#FF#, 16#FE#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#FC#, 16#00#, 16#03#, 16#FF#, 16#FC#, 16#00#, 16#07#, 16#FF#, 16#FC#, 16#00#, 16#1F#, 16#FF#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#01#, 16#E0#, 16#00#, 16#F0#, 16#07#, 16#E0#, 16#03#, 16#E0#, 16#1F#, 16#E0#, 16#07#, 16#80#, 16#3F#, 16#C0#, 16#1E#, 16#00#, 16#7F#, 16#C0#, 16#78#, 16#00#, 16#7F#, 16#C3#, 16#C0#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#C0#, 16#01#, 16#FF#, 16#FF#, 16#C0#, 16#0F#, 16#FC#, 16#3F#, 16#80#, 16#3F#, 16#E0#, 16#7F#, 16#00#, 16#FF#, 16#80#, 16#FE#, 16#07#, 16#FC#, 16#03#, 16#F8#, 16#1F#, 16#F0#, 16#0F#, 16#F0#, 16#7F#, 16#C0#, 16#3F#, 16#C3#, 16#FE#, 16#00#, 16#FF#, 16#0F#, 16#F8#, 16#03#, 16#FC#, 16#3F#, 16#E0#, 16#1F#, 16#F0#, 16#FF#, 16#00#, 16#7F#, 16#C3#, 16#FC#, 16#01#, 16#FF#, 16#0F#, 16#F0#, 16#07#, 16#FC#, 16#3F#, 16#C0#, 16#1F#, 16#F0#, 16#FE#, 16#00#, 16#FF#, 16#83#, 16#F8#, 16#03#, 16#FE#, 16#0F#, 16#E0#, 16#0F#, 16#F8#, 16#3F#, 16#80#, 16#3F#, 16#C0#, 16#7E#, 16#01#, 16#FF#, 16#01#, 16#F8#, 16#07#, 16#F8#, 16#03#, 16#E0#, 16#3F#, 16#C0#, 16#0F#, 16#80#, 16#FE#, 16#00#, 16#1F#, 16#07#, 16#F0#, 16#00#, 16#3E#, 16#3F#, 16#80#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#FF#, 16#F8#, 16#3F#, 16#FF#, 16#FF#, 16#83#, 16#FF#, 16#FF#, 16#FC#, 16#1F#, 16#FF#, 16#FF#, 16#C1#, 16#FF#, 16#FF#, 16#FE#, 16#0F#, 16#FF#, 16#FF#, 16#E0#, 16#FF#, 16#FF#, 16#FF#, 16#07#, 16#80#, 16#01#, 16#F0#, 16#70#, 16#00#, 16#0F#, 16#03#, 16#00#, 16#00#, 16#F8#, 16#30#, 16#00#, 16#0F#, 16#81#, 16#80#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#3C#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#FE#, 16#00#, 16#01#, 16#F0#, 16#7E#, 16#00#, 16#1F#, 16#80#, 16#FC#, 16#00#, 16#FC#, 16#01#, 16#F8#, 16#03#, 16#E0#, 16#07#, 16#E0#, 16#1F#, 16#80#, 16#0F#, 16#C0#, 16#7E#, 16#00#, 16#3F#, 16#03#, 16#F8#, 16#00#, 16#FC#, 16#0F#, 16#E0#, 16#03#, 16#F0#, 16#3F#, 16#80#, 16#0F#, 16#C0#, 16#FF#, 16#00#, 16#3F#, 16#03#, 16#FC#, 16#01#, 16#F8#, 16#0F#, 16#F8#, 16#07#, 16#E0#, 16#3F#, 16#F0#, 16#3F#, 16#00#, 16#7F#, 16#E1#, 16#F8#, 16#01#, 16#FF#, 16#CF#, 16#C0#, 16#03#, 16#FF#, 16#FC#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#1F#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#0F#, 16#FF#, 16#E0#, 16#00#, 16#79#, 16#FF#, 16#C0#, 16#07#, 16#C3#, 16#FF#, 16#00#, 16#3E#, 16#07#, 16#FE#, 16#01#, 16#F0#, 16#0F#, 16#F8#, 16#0F#, 16#C0#, 16#3F#, 16#F0#, 16#7E#, 16#00#, 16#7F#, 16#C1#, 16#F8#, 16#00#, 16#FF#, 16#0F#, 16#E0#, 16#03#, 16#FC#, 16#3F#, 16#00#, 16#07#, 16#F0#, 16#FC#, 16#00#, 16#1F#, 16#C3#, 16#F0#, 16#00#, 16#7F#, 16#0F#, 16#C0#, 16#01#, 16#FC#, 16#3F#, 16#00#, 16#07#, 16#E0#, 16#FC#, 16#00#, 16#1F#, 16#81#, 16#F0#, 16#00#, 16#FC#, 16#07#, 16#E0#, 16#03#, 16#F0#, 16#0F#, 16#80#, 16#1F#, 16#80#, 16#1F#, 16#00#, 16#FC#, 16#00#, 16#3E#, 16#0F#, 16#C0#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#87#, 16#80#, 16#01#, 16#FE#, 16#0F#, 16#80#, 16#07#, 16#F8#, 16#0F#, 16#80#, 16#1F#, 16#E0#, 16#1F#, 16#00#, 16#7F#, 16#C0#, 16#3F#, 16#00#, 16#FF#, 16#00#, 16#7E#, 16#03#, 16#FE#, 16#00#, 16#FC#, 16#07#, 16#F8#, 16#01#, 16#FC#, 16#1F#, 16#F0#, 16#03#, 16#F8#, 16#3F#, 16#C0#, 16#0F#, 16#F0#, 16#FF#, 16#80#, 16#1F#, 16#E1#, 16#FF#, 16#00#, 16#3F#, 16#C3#, 16#FE#, 16#00#, 16#7F#, 16#87#, 16#FC#, 16#01#, 16#FF#, 16#0F#, 16#F0#, 16#03#, 16#FE#, 16#1F#, 16#E0#, 16#07#, 16#FC#, 16#3F#, 16#C0#, 16#1F#, 16#F0#, 16#7F#, 16#80#, 16#3F#, 16#E0#, 16#FF#, 16#00#, 16#7F#, 16#C0#, 16#FE#, 16#01#, 16#FF#, 16#81#, 16#FC#, 16#03#, 16#FE#, 16#01#, 16#FC#, 16#0F#, 16#FC#, 16#03#, 16#FC#, 16#1F#, 16#F0#, 16#03#, 16#FF#, 16#FF#, 16#E0#, 16#03#, 16#FF#, 16#FF#, 16#80#, 16#01#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#78#, 16#01#, 16#FE#, 16#01#, 16#FE#, 16#03#, 16#FF#, 16#03#, 16#FF#, 16#03#, 16#FF#, 16#03#, 16#FF#, 16#01#, 16#FE#, 16#00#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#7F#, 16#80#, 16#FF#, 16#80#, 16#FF#, 16#C0#, 16#FF#, 16#C0#, 16#FF#, 16#C0#, 16#FF#, 16#80#, 16#7F#, 16#80#, 16#1E#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#1F#, 16#E0#, 16#0F#, 16#F8#, 16#03#, 16#FF#, 16#00#, 16#FF#, 16#C0#, 16#3F#, 16#F0#, 16#0F#, 16#F8#, 16#01#, 16#FE#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#FE#, 16#00#, 16#7F#, 16#80#, 16#1F#, 16#F0#, 16#07#, 16#FC#, 16#01#, 16#FF#, 16#00#, 16#3F#, 16#C0#, 16#0F#, 16#F0#, 16#00#, 16#FC#, 16#00#, 16#1E#, 16#00#, 16#07#, 16#80#, 16#01#, 16#C0#, 16#00#, 16#F0#, 16#00#, 16#38#, 16#00#, 16#1C#, 16#00#, 16#0E#, 16#00#, 16#0F#, 16#00#, 16#07#, 16#00#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#FC#, 16#00#, 16#03#, 16#FF#, 16#F0#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#01#, 16#FF#, 16#F8#, 16#00#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#80#, 16#00#, 16#03#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#01#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#80#, 16#00#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#01#, 16#FF#, 16#F0#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#3F#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#F8#, 16#00#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#1F#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#FF#, 16#F8#, 16#00#, 16#F8#, 16#7F#, 16#00#, 16#F0#, 16#1F#, 16#C0#, 16#F8#, 16#07#, 16#F0#, 16#FC#, 16#03#, 16#F8#, 16#7F#, 16#01#, 16#FE#, 16#3F#, 16#80#, 16#FF#, 16#1F#, 16#C0#, 16#7F#, 16#8F#, 16#E0#, 16#3F#, 16#C3#, 16#E0#, 16#3F#, 16#E0#, 16#E0#, 16#1F#, 16#F0#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#1F#, 16#E0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#07#, 16#E0#, 16#00#, 16#3E#, 16#7E#, 16#78#, 16#3F#, 16#00#, 16#07#, 16#FB#, 16#E1#, 16#C3#, 16#F0#, 16#00#, 16#7C#, 16#DF#, 16#0F#, 16#1F#, 16#80#, 16#0F#, 16#C3#, 16#F8#, 16#39#, 16#F8#, 16#00#, 16#7C#, 16#1F#, 16#81#, 16#CF#, 16#C0#, 16#07#, 16#C0#, 16#FC#, 16#07#, 16#7E#, 16#00#, 16#7E#, 16#07#, 16#E0#, 16#3F#, 16#E0#, 16#07#, 16#E0#, 16#3F#, 16#01#, 16#FF#, 16#00#, 16#3F#, 16#01#, 16#F0#, 16#0F#, 16#F8#, 16#03#, 16#F0#, 16#0F#, 16#80#, 16#7F#, 16#C0#, 16#3F#, 16#80#, 16#FC#, 16#03#, 16#FE#, 16#01#, 16#F8#, 16#07#, 16#C0#, 16#1F#, 16#F0#, 16#0F#, 16#C0#, 16#3E#, 16#00#, 16#FF#, 16#80#, 16#FE#, 16#03#, 16#F0#, 16#0E#, 16#FC#, 16#07#, 16#E0#, 16#1F#, 16#00#, 16#77#, 16#E0#, 16#3F#, 16#01#, 16#F8#, 16#03#, 16#BF#, 16#01#, 16#F8#, 16#0F#, 16#C0#, 16#38#, 16#F8#, 16#0F#, 16#C0#, 16#FC#, 16#03#, 16#C7#, 16#E0#, 16#7E#, 16#0B#, 16#E0#, 16#1C#, 16#3F#, 16#03#, 16#F8#, 16#DF#, 16#01#, 16#C0#, 16#F8#, 16#0F#, 16#FC#, 16#F8#, 16#3C#, 16#07#, 16#E0#, 16#3F#, 16#C7#, 16#FF#, 16#C0#, 16#1F#, 16#00#, 16#F8#, 16#1F#, 16#FC#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#20#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#07#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#06#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#03#, 16#BF#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#CF#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#63#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#38#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0C#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#03#, 16#81#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#70#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#38#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#0C#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#07#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#C0#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#0E#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#07#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#E0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#70#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#1C#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#0E#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#07#, 16#80#, 16#00#, 16#1F#, 16#F0#, 16#01#, 16#C0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#F0#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#7C#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#3F#, 16#80#, 16#00#, 16#7F#, 16#FE#, 16#3F#, 16#FC#, 16#00#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#00#, 16#3F#, 16#FF#, 16#FC#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#03#, 16#FF#, 16#C3#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#7F#, 16#C0#, 16#00#, 16#7F#, 16#E0#, 16#3F#, 16#F0#, 16#00#, 16#3F#, 16#F0#, 16#0F#, 16#F8#, 16#00#, 16#1F#, 16#F0#, 16#07#, 16#FE#, 16#00#, 16#0F#, 16#F8#, 16#03#, 16#FF#, 16#00#, 16#0F#, 16#FC#, 16#01#, 16#FF#, 16#80#, 16#07#, 16#FC#, 16#00#, 16#FF#, 16#C0#, 16#03#, 16#FE#, 16#00#, 16#7F#, 16#E0#, 16#01#, 16#FF#, 16#00#, 16#3F#, 16#F0#, 16#01#, 16#FF#, 16#80#, 16#1F#, 16#F0#, 16#00#, 16#FF#, 16#80#, 16#1F#, 16#F8#, 16#00#, 16#7F#, 16#C0#, 16#0F#, 16#F8#, 16#00#, 16#3F#, 16#E0#, 16#0F#, 16#F8#, 16#00#, 16#3F#, 16#F0#, 16#0F#, 16#F8#, 16#00#, 16#1F#, 16#F0#, 16#0F#, 16#F8#, 16#00#, 16#0F#, 16#F8#, 16#3F#, 16#E0#, 16#00#, 16#0F#, 16#FF#, 16#FF#, 16#80#, 16#00#, 16#07#, 16#FF#, 16#FF#, 16#E0#, 16#00#, 16#03#, 16#FE#, 16#0F#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#FF#, 16#80#, 16#01#, 16#FF#, 16#80#, 16#3F#, 16#E0#, 16#00#, 16#FF#, 16#80#, 16#1F#, 16#F8#, 16#00#, 16#7F#, 16#C0#, 16#07#, 16#FC#, 16#00#, 16#3F#, 16#E0#, 16#03#, 16#FF#, 16#00#, 16#3F#, 16#F0#, 16#01#, 16#FF#, 16#80#, 16#1F#, 16#F0#, 16#00#, 16#FF#, 16#C0#, 16#0F#, 16#F8#, 16#00#, 16#7F#, 16#E0#, 16#0F#, 16#FC#, 16#00#, 16#3F#, 16#F0#, 16#07#, 16#FE#, 16#00#, 16#1F#, 16#F8#, 16#03#, 16#FE#, 16#00#, 16#1F#, 16#FC#, 16#01#, 16#FF#, 16#00#, 16#0F#, 16#FC#, 16#01#, 16#FF#, 16#80#, 16#0F#, 16#FE#, 16#00#, 16#FF#, 16#80#, 16#07#, 16#FE#, 16#00#, 16#7F#, 16#C0#, 16#07#, 16#FE#, 16#00#, 16#7F#, 16#E0#, 16#07#, 16#FE#, 16#00#, 16#3F#, 16#F0#, 16#07#, 16#FE#, 16#00#, 16#7F#, 16#FC#, 16#0F#, 16#FC#, 16#00#, 16#FF#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#03#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#EF#, 16#00#, 16#01#, 16#FF#, 16#03#, 16#FF#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#FE#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#7E#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#3E#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#3E#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#3E#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#1C#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#1C#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#1C#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#1C#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#18#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#18#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#18#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#C0#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#80#, 16#1F#, 16#F0#, 16#00#, 16#0F#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#1E#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#3C#, 16#00#, 16#03#, 16#FF#, 16#01#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#1F#, 16#FC#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#03#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#3F#, 16#E0#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#C0#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#07#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#0F#, 16#F8#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F8#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#E0#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#FC#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#F8#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#0F#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#0F#, 16#FE#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#1F#, 16#F8#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#E0#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#07#, 16#FC#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#FF#, 16#80#, 16#01#, 16#FF#, 16#80#, 16#03#, 16#FC#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#1F#, 16#FF#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#FF#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#FF#, 16#C0#, 16#1F#, 16#FF#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#FF#, 16#F0#, 16#0F#, 16#F8#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#7E#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#0F#, 16#80#, 16#01#, 16#FF#, 16#80#, 16#01#, 16#E0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#70#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#0C#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#03#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#20#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#08#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#70#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#18#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#0E#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#07#, 16#80#, 16#00#, 16#0F#, 16#F8#, 16#03#, 16#C0#, 16#00#, 16#03#, 16#FE#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#7F#, 16#80#, 16#00#, 16#07#, 16#FC#, 16#03#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#78#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#1C#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#07#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#01#, 16#C0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#60#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#18#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#02#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#C0#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#30#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#18#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#0E#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#07#, 16#80#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#E0#, 16#07#, 16#FC#, 16#00#, 16#01#, 16#F0#, 16#03#, 16#FF#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#FF#, 16#C0#, 16#01#, 16#FF#, 16#00#, 16#FF#, 16#F8#, 16#07#, 16#FF#, 16#C0#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#E0#, 16#3F#, 16#FF#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#FF#, 16#C0#, 16#1F#, 16#FF#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#FF#, 16#F0#, 16#0F#, 16#F8#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#7E#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#0F#, 16#80#, 16#01#, 16#FF#, 16#80#, 16#01#, 16#E0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#70#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#0C#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#03#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#20#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#08#, 16#00#, 16#0F#, 16#F8#, 16#01#, 16#80#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#38#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#1C#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#0F#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#07#, 16#C0#, 16#00#, 16#03#, 16#FE#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#7F#, 16#80#, 16#00#, 16#07#, 16#FC#, 16#03#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#70#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#1C#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#07#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#01#, 16#C0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#60#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#18#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#01#, 16#80#, 16#00#, 16#07#, 16#FF#, 16#FE#, 16#F0#, 16#00#, 16#07#, 16#FC#, 16#07#, 16#FC#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#FF#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#7E#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#07#, 16#80#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#F0#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#1E#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#01#, 16#C0#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#30#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#06#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#C0#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F8#, 16#00#, 16#1F#, 16#FF#, 16#FF#, 16#FF#, 16#00#, 16#03#, 16#FF#, 16#FF#, 16#FF#, 16#C0#, 16#00#, 16#0F#, 16#FF#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#C3#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#7F#, 16#E0#, 16#00#, 16#03#, 16#FE#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#C1#, 16#FF#, 16#80#, 16#00#, 16#0F#, 16#F8#, 16#3F#, 16#F0#, 16#00#, 16#01#, 16#FE#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#7F#, 16#C0#, 16#00#, 16#0F#, 16#F8#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#1F#, 16#F0#, 16#00#, 16#0F#, 16#F8#, 16#01#, 16#FE#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#3F#, 16#C0#, 16#03#, 16#FC#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#3F#, 16#C0#, 16#01#, 16#FF#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#1F#, 16#E0#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#F8#, 16#7F#, 16#FF#, 16#F0#, 16#07#, 16#FF#, 16#FF#, 16#87#, 16#FF#, 16#FF#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#FF#, 16#FF#, 16#E0#, 16#00#, 16#07#, 16#FF#, 16#FF#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#FF#, 16#E0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#0F#, 16#FE#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#03#, 16#FF#, 16#F0#, 16#00#, 16#FF#, 16#FF#, 16#E1#, 16#FF#, 16#FF#, 16#E0#, 16#0F#, 16#FF#, 16#FE#, 16#1F#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#E0#, 16#0F#, 16#FF#, 16#FC#, 16#00#, 16#3F#, 16#FE#, 16#00#, 16#03#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#01#, 16#FF#, 16#F0#, 16#00#, 16#FF#, 16#FF#, 16#E0#, 16#1F#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#F0#, 16#00#, 16#07#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#3C#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#E0#, 16#7F#, 16#C0#, 16#00#, 16#FF#, 16#0F#, 16#F8#, 16#00#, 16#0F#, 16#F0#, 16#FF#, 16#80#, 16#00#, 16#FF#, 16#1F#, 16#F0#, 16#00#, 16#0F#, 16#E1#, 16#FE#, 16#00#, 16#00#, 16#7C#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#C7#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#F0#, 16#FF#, 16#FC#, 16#01#, 16#FF#, 16#FF#, 16#C3#, 16#FF#, 16#F0#, 16#00#, 16#FF#, 16#FC#, 16#01#, 16#FE#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#03#, 16#E0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#78#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#03#, 16#C0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#07#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#38#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#01#, 16#C0#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#70#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#07#, 16#80#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F1#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#8F#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#FD#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#3F#, 16#F3#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#8F#, 16#FC#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#FF#, 16#80#, 16#00#, 16#01#, 16#FF#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#0F#, 16#F8#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#07#, 16#FE#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#FF#, 16#C0#, 16#03#, 16#FF#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#1F#, 16#FF#, 16#00#, 16#FF#, 16#FF#, 16#C3#, 16#FF#, 16#FF#, 16#03#, 16#FF#, 16#FF#, 16#0F#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#C0#, 16#FF#, 16#80#, 16#00#, 16#03#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#18#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#E0#, 16#7F#, 16#E0#, 16#00#, 16#07#, 16#81#, 16#FF#, 16#00#, 16#00#, 16#3C#, 16#07#, 16#FC#, 16#00#, 16#01#, 16#F0#, 16#3F#, 16#F0#, 16#00#, 16#1F#, 16#C0#, 16#FF#, 16#C0#, 16#01#, 16#FE#, 16#0F#, 16#FF#, 16#80#, 16#7F#, 16#F8#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#E3#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#FF#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#F0#, 16#07#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#80#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#01#, 16#FF#, 16#E0#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#07#, 16#FF#, 16#C0#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#00#, 16#77#, 16#FC#, 16#00#, 16#00#, 16#5F#, 16#F8#, 16#00#, 16#0E#, 16#FF#, 16#80#, 16#00#, 16#05#, 16#FF#, 16#80#, 16#01#, 16#EF#, 16#F8#, 16#00#, 16#00#, 16#CF#, 16#F8#, 16#00#, 16#1C#, 16#FF#, 16#80#, 16#00#, 16#08#, 16#FF#, 16#80#, 16#03#, 16#8F#, 16#F8#, 16#00#, 16#00#, 16#8F#, 16#F8#, 16#00#, 16#39#, 16#FF#, 16#00#, 16#00#, 16#18#, 16#FF#, 16#80#, 16#07#, 16#1F#, 16#F0#, 16#00#, 16#01#, 16#8F#, 16#F8#, 16#00#, 16#E1#, 16#FF#, 16#00#, 16#00#, 16#10#, 16#FF#, 16#80#, 16#0E#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#0F#, 16#F8#, 16#01#, 16#C3#, 16#FE#, 16#00#, 16#00#, 16#30#, 16#FF#, 16#C0#, 16#38#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#07#, 16#FC#, 16#03#, 16#83#, 16#FE#, 16#00#, 16#00#, 16#20#, 16#7F#, 16#C0#, 16#70#, 16#7F#, 16#C0#, 16#00#, 16#06#, 16#07#, 16#FC#, 16#0E#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#60#, 16#7F#, 16#C0#, 16#E0#, 16#7F#, 16#C0#, 16#00#, 16#04#, 16#07#, 16#FC#, 16#1C#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#C0#, 16#7F#, 16#C3#, 16#80#, 16#FF#, 16#80#, 16#00#, 16#0C#, 16#07#, 16#FC#, 16#38#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#C0#, 16#3F#, 16#C7#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#18#, 16#03#, 16#FE#, 16#60#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#80#, 16#3F#, 16#EE#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#18#, 16#03#, 16#FF#, 16#C0#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#80#, 16#3F#, 16#F8#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#30#, 16#03#, 16#FF#, 16#80#, 16#3F#, 16#F0#, 16#00#, 16#03#, 16#00#, 16#3F#, 16#F0#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#70#, 16#03#, 16#FE#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#07#, 16#00#, 16#1F#, 16#E0#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#70#, 16#01#, 16#FC#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#0F#, 16#00#, 16#1F#, 16#80#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#F0#, 16#01#, 16#F8#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#1F#, 16#00#, 16#1F#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#03#, 16#FC#, 16#01#, 16#E0#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#FF#, 16#F0#, 16#1E#, 16#01#, 16#FF#, 16#FF#, 16#E0#, 16#0F#, 16#FF#, 16#00#, 16#C0#, 16#1F#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#3F#, 16#FE#, 16#00#, 16#07#, 16#FF#, 16#C0#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#07#, 16#80#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#03#, 16#80#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#0F#, 16#FF#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#07#, 16#FF#, 16#80#, 16#00#, 16#E0#, 16#00#, 16#02#, 16#FF#, 16#E0#, 16#00#, 16#70#, 16#00#, 16#01#, 16#7F#, 16#F0#, 16#00#, 16#38#, 16#00#, 16#01#, 16#9F#, 16#FC#, 16#00#, 16#18#, 16#00#, 16#00#, 16#8F#, 16#FE#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#43#, 16#FF#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#61#, 16#FF#, 16#C0#, 16#06#, 16#00#, 16#00#, 16#30#, 16#7F#, 16#E0#, 16#03#, 16#00#, 16#00#, 16#10#, 16#3F#, 16#F8#, 16#03#, 16#80#, 16#00#, 16#18#, 16#0F#, 16#FC#, 16#01#, 16#C0#, 16#00#, 16#0C#, 16#07#, 16#FF#, 16#00#, 16#C0#, 16#00#, 16#04#, 16#01#, 16#FF#, 16#80#, 16#E0#, 16#00#, 16#06#, 16#00#, 16#FF#, 16#E0#, 16#70#, 16#00#, 16#03#, 16#00#, 16#3F#, 16#F0#, 16#30#, 16#00#, 16#01#, 16#80#, 16#1F#, 16#FC#, 16#18#, 16#00#, 16#00#, 16#80#, 16#07#, 16#FE#, 16#1C#, 16#00#, 16#00#, 16#C0#, 16#03#, 16#FF#, 16#8E#, 16#00#, 16#00#, 16#60#, 16#00#, 16#FF#, 16#C6#, 16#00#, 16#00#, 16#20#, 16#00#, 16#7F#, 16#F7#, 16#00#, 16#00#, 16#30#, 16#00#, 16#1F#, 16#FB#, 16#80#, 16#00#, 16#18#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#08#, 16#00#, 16#03#, 16#FF#, 16#C0#, 16#00#, 16#0C#, 16#00#, 16#01#, 16#FF#, 16#E0#, 16#00#, 16#06#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#78#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#07#, 16#80#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#7F#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#07#, 16#E0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#FC#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#3F#, 16#80#, 16#01#, 16#FC#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#FF#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#7F#, 16#80#, 16#3F#, 16#C0#, 16#00#, 16#1F#, 16#E0#, 16#1F#, 16#F0#, 16#00#, 16#07#, 16#F8#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C1#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#FF#, 16#C0#, 16#00#, 16#07#, 16#FC#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#C7#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#F3#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#FE#, 16#3F#, 16#F0#, 16#00#, 16#01#, 16#FF#, 16#9F#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#E7#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#F9#, 16#FF#, 16#80#, 16#00#, 16#0F#, 16#FC#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#FF#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#CF#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#E3#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#FF#, 16#C0#, 16#00#, 16#07#, 16#FC#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#83#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F0#, 16#1F#, 16#E0#, 16#00#, 16#0F#, 16#F8#, 16#07#, 16#F8#, 16#00#, 16#03#, 16#FC#, 16#01#, 16#FE#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#FF#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#3F#, 16#80#, 16#01#, 16#FC#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#3F#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#07#, 16#E0#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#FE#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#03#, 16#FF#, 16#C3#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#7F#, 16#C0#, 16#00#, 16#7F#, 16#E0#, 16#3F#, 16#E0#, 16#00#, 16#3F#, 16#E0#, 16#0F#, 16#F8#, 16#00#, 16#1F#, 16#F0#, 16#07#, 16#FC#, 16#00#, 16#0F#, 16#F8#, 16#03#, 16#FF#, 16#00#, 16#07#, 16#FC#, 16#01#, 16#FF#, 16#80#, 16#03#, 16#FC#, 16#00#, 16#FF#, 16#C0#, 16#03#, 16#FE#, 16#00#, 16#7F#, 16#E0#, 16#01#, 16#FF#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#FF#, 16#00#, 16#3F#, 16#F8#, 16#00#, 16#7F#, 16#80#, 16#1F#, 16#F8#, 16#00#, 16#7F#, 16#C0#, 16#0F#, 16#FC#, 16#00#, 16#3F#, 16#E0#, 16#0F#, 16#FC#, 16#00#, 16#1F#, 16#E0#, 16#07#, 16#FE#, 16#00#, 16#1F#, 16#F0#, 16#07#, 16#FE#, 16#00#, 16#0F#, 16#F8#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#FC#, 16#0F#, 16#FC#, 16#00#, 16#07#, 16#FF#, 16#FF#, 16#F8#, 16#00#, 16#03#, 16#FF#, 16#FF#, 16#C0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#7F#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#07#, 16#E0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#FC#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#3F#, 16#80#, 16#01#, 16#FC#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#FF#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#7F#, 16#80#, 16#3F#, 16#C0#, 16#00#, 16#1F#, 16#E0#, 16#1F#, 16#F0#, 16#00#, 16#07#, 16#F8#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#FF#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C1#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#FF#, 16#C0#, 16#00#, 16#07#, 16#FC#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#C7#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#F3#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#FF#, 16#C0#, 16#00#, 16#07#, 16#FF#, 16#7F#, 16#F0#, 16#00#, 16#01#, 16#FF#, 16#9F#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#E7#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#F9#, 16#FF#, 16#80#, 16#00#, 16#0F#, 16#FC#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#FF#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#CF#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#E3#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#FF#, 16#C0#, 16#00#, 16#0F#, 16#FC#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#83#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#F0#, 16#3F#, 16#E0#, 16#00#, 16#0F#, 16#F8#, 16#07#, 16#F8#, 16#00#, 16#07#, 16#FC#, 16#01#, 16#FE#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#FF#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#7F#, 16#80#, 16#01#, 16#FC#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#3F#, 16#80#, 16#1F#, 16#C0#, 16#00#, 16#07#, 16#F0#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#BF#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#80#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#70#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#38#, 16#03#, 16#FF#, 16#FC#, 16#00#, 16#3C#, 16#03#, 16#FF#, 16#FF#, 16#E0#, 16#3E#, 16#01#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#00#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#80#, 16#7F#, 16#FF#, 16#FF#, 16#FF#, 16#C0#, 16#3C#, 16#03#, 16#FF#, 16#FF#, 16#E0#, 16#04#, 16#00#, 16#1F#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#80#, 16#00#, 16#1F#, 16#FF#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#F0#, 16#7F#, 16#E0#, 16#00#, 16#1F#, 16#FC#, 16#0F#, 16#FC#, 16#00#, 16#07#, 16#FE#, 16#01#, 16#FF#, 16#80#, 16#01#, 16#FF#, 16#80#, 16#3F#, 16#E0#, 16#00#, 16#7F#, 16#E0#, 16#0F#, 16#FC#, 16#00#, 16#1F#, 16#F0#, 16#03#, 16#FF#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#FF#, 16#C0#, 16#01#, 16#FF#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#FF#, 16#80#, 16#0F#, 16#FC#, 16#00#, 16#3F#, 16#E0#, 16#07#, 16#FF#, 16#00#, 16#0F#, 16#F8#, 16#01#, 16#FF#, 16#80#, 16#03#, 16#FE#, 16#00#, 16#7F#, 16#E0#, 16#01#, 16#FF#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#7F#, 16#C0#, 16#1F#, 16#F8#, 16#00#, 16#1F#, 16#F0#, 16#07#, 16#FC#, 16#00#, 16#0F#, 16#F8#, 16#07#, 16#FE#, 16#00#, 16#03#, 16#FE#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#F9#, 16#FF#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#7F#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#FF#, 16#C3#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#FF#, 16#C0#, 16#00#, 16#0F#, 16#F8#, 16#3F#, 16#F0#, 16#00#, 16#07#, 16#FE#, 16#07#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#81#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#C0#, 16#7F#, 16#E0#, 16#00#, 16#1F#, 16#F0#, 16#0F#, 16#F8#, 16#00#, 16#0F#, 16#FC#, 16#03#, 16#FF#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#FF#, 16#80#, 16#1F#, 16#F8#, 16#00#, 16#7F#, 16#E0#, 16#07#, 16#FE#, 16#00#, 16#1F#, 16#F8#, 16#01#, 16#FF#, 16#80#, 16#07#, 16#FC#, 16#00#, 16#3F#, 16#E0#, 16#03#, 16#FF#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#FF#, 16#E0#, 16#03#, 16#FF#, 16#00#, 16#FF#, 16#FC#, 16#00#, 16#7F#, 16#F0#, 16#FF#, 16#FF#, 16#E0#, 16#1F#, 16#FF#, 16#BF#, 16#FF#, 16#F8#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#01#, 16#FE#, 16#03#, 16#00#, 16#07#, 16#FF#, 16#F3#, 16#80#, 16#07#, 16#E0#, 16#3F#, 16#C0#, 16#07#, 16#C0#, 16#0F#, 16#E0#, 16#07#, 16#C0#, 16#03#, 16#F0#, 16#07#, 16#E0#, 16#00#, 16#F0#, 16#07#, 16#E0#, 16#00#, 16#38#, 16#03#, 16#F0#, 16#00#, 16#1C#, 16#03#, 16#F8#, 16#00#, 16#0E#, 16#01#, 16#FC#, 16#00#, 16#07#, 16#00#, 16#FE#, 16#00#, 16#01#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#80#, 16#3F#, 16#C0#, 16#00#, 16#40#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#FE#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#80#, 16#00#, 16#01#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#FF#, 16#F0#, 16#00#, 16#01#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#C0#, 16#00#, 16#1F#, 16#E0#, 16#60#, 16#00#, 16#0F#, 16#F0#, 16#30#, 16#00#, 16#03#, 16#F8#, 16#38#, 16#00#, 16#01#, 16#FC#, 16#1E#, 16#00#, 16#00#, 16#FE#, 16#0F#, 16#00#, 16#00#, 16#7E#, 16#07#, 16#80#, 16#00#, 16#3F#, 16#03#, 16#E0#, 16#00#, 16#3F#, 16#81#, 16#F0#, 16#00#, 16#1F#, 16#81#, 16#FC#, 16#00#, 16#1F#, 16#80#, 16#FF#, 16#00#, 16#3F#, 16#80#, 16#7F#, 16#E0#, 16#7F#, 16#80#, 16#38#, 16#FF#, 16#FF#, 16#00#, 16#18#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#FF#, 16#FF#, 16#F3#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#7F#, 16#E0#, 16#FF#, 16#8F#, 16#F7#, 16#F0#, 16#0F#, 16#F0#, 16#3E#, 16#7E#, 16#01#, 16#FF#, 16#01#, 16#E7#, 16#80#, 16#1F#, 16#F0#, 16#0E#, 16#70#, 16#01#, 16#FE#, 16#00#, 16#E6#, 16#00#, 16#3F#, 16#E0#, 16#0E#, 16#E0#, 16#03#, 16#FE#, 16#00#, 16#4C#, 16#00#, 16#3F#, 16#E0#, 16#04#, 16#80#, 16#03#, 16#FC#, 16#00#, 16#40#, 16#00#, 16#7F#, 16#C0#, 16#04#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#0F#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#F8#, 16#07#, 16#FF#, 16#CF#, 16#FF#, 16#FE#, 16#01#, 16#FF#, 16#F0#, 16#7F#, 16#FC#, 16#00#, 16#0F#, 16#F0#, 16#0F#, 16#FE#, 16#00#, 16#01#, 16#F0#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#3C#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#0E#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#80#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#C0#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#30#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#06#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#01#, 16#80#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#60#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#18#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#0C#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#03#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#C0#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#60#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#18#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#06#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#01#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#C0#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#30#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#08#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#06#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#01#, 16#80#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#60#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#38#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#0C#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#01#, 16#C0#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#60#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#18#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#0E#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#07#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#E0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#70#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#3C#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#7E#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#E0#, 16#07#, 16#FF#, 16#FF#, 16#FF#, 16#F8#, 16#01#, 16#FF#, 16#F1#, 16#FF#, 16#F0#, 16#00#, 16#0F#, 16#F0#, 16#3F#, 16#F8#, 16#00#, 16#01#, 16#F8#, 16#0F#, 16#FE#, 16#00#, 16#00#, 16#3C#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#1E#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#07#, 16#80#, 16#1F#, 16#F8#, 16#00#, 16#03#, 16#C0#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#E0#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#78#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#1C#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#0E#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#07#, 16#80#, 16#00#, 16#FF#, 16#C0#, 16#01#, 16#C0#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#E0#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#78#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#0E#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#03#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#01#, 16#C0#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#30#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#1C#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#0E#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#83#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E1#, 16#C0#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#30#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#DC#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#C3#, 16#FF#, 16#FC#, 16#0F#, 16#FF#, 16#FF#, 16#FF#, 16#87#, 16#FF#, 16#F8#, 16#1F#, 16#FC#, 16#7F#, 16#FC#, 16#03#, 16#FF#, 16#C0#, 16#0F#, 16#F0#, 16#7F#, 16#E0#, 16#03#, 16#FE#, 16#00#, 16#0F#, 16#80#, 16#FF#, 16#C0#, 16#03#, 16#FC#, 16#00#, 16#0E#, 16#00#, 16#FF#, 16#80#, 16#07#, 16#F8#, 16#00#, 16#3C#, 16#01#, 16#FF#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#70#, 16#03#, 16#FE#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#E0#, 16#07#, 16#FE#, 16#00#, 16#3F#, 16#E0#, 16#03#, 16#80#, 16#0F#, 16#FC#, 16#00#, 16#7F#, 16#C0#, 16#07#, 16#00#, 16#1F#, 16#F8#, 16#01#, 16#FF#, 16#80#, 16#1C#, 16#00#, 16#3F#, 16#F0#, 16#03#, 16#FF#, 16#00#, 16#38#, 16#00#, 16#7F#, 16#E0#, 16#0F#, 16#FE#, 16#00#, 16#E0#, 16#00#, 16#FF#, 16#C0#, 16#1F#, 16#FC#, 16#01#, 16#C0#, 16#00#, 16#FF#, 16#80#, 16#6F#, 16#F8#, 16#07#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#DF#, 16#F0#, 16#0E#, 16#00#, 16#03#, 16#FE#, 16#03#, 16#3F#, 16#F0#, 16#38#, 16#00#, 16#07#, 16#FE#, 16#06#, 16#3F#, 16#E0#, 16#70#, 16#00#, 16#0F#, 16#FC#, 16#18#, 16#7F#, 16#C1#, 16#C0#, 16#00#, 16#1F#, 16#F8#, 16#30#, 16#FF#, 16#83#, 16#80#, 16#00#, 16#3F#, 16#F0#, 16#C1#, 16#FF#, 16#0E#, 16#00#, 16#00#, 16#3F#, 16#E1#, 16#83#, 16#FE#, 16#1C#, 16#00#, 16#00#, 16#7F#, 16#C6#, 16#07#, 16#FC#, 16#70#, 16#00#, 16#00#, 16#FF#, 16#8C#, 16#0F#, 16#F8#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#30#, 16#0F#, 16#F3#, 16#80#, 16#00#, 16#03#, 16#FE#, 16#60#, 16#1F#, 16#F7#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#80#, 16#3F#, 16#FC#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#3C#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#70#, 16#00#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#60#, 16#00#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#E0#, 16#FF#, 16#F8#, 16#07#, 16#FF#, 16#FF#, 16#07#, 16#FF#, 16#C0#, 16#07#, 16#FF#, 16#80#, 16#07#, 16#F8#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#F0#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#0F#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#0F#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#0F#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C7#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#70#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7B#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#07#, 16#9F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#78#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#83#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#78#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#80#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#78#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#80#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#78#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#03#, 16#80#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#7F#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#FF#, 16#FC#, 16#1F#, 16#FF#, 16#FC#, 16#07#, 16#FF#, 16#E0#, 16#FF#, 16#FF#, 16#E0#, 16#00#, 16#FF#, 16#FF#, 16#C0#, 16#FF#, 16#FF#, 16#FF#, 16#FE#, 16#07#, 16#FF#, 16#C7#, 16#FF#, 16#00#, 16#07#, 16#F8#, 16#1F#, 16#F0#, 16#00#, 16#1F#, 16#80#, 16#FF#, 16#80#, 16#00#, 16#F0#, 16#07#, 16#FE#, 16#00#, 16#07#, 16#80#, 16#1F#, 16#F0#, 16#00#, 16#38#, 16#00#, 16#FF#, 16#80#, 16#03#, 16#80#, 16#07#, 16#FE#, 16#00#, 16#38#, 16#00#, 16#1F#, 16#F0#, 16#01#, 16#C0#, 16#00#, 16#FF#, 16#80#, 16#1C#, 16#00#, 16#03#, 16#FC#, 16#01#, 16#C0#, 16#00#, 16#1F#, 16#F0#, 16#0C#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#E0#, 16#00#, 16#03#, 16#FC#, 16#0E#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#E0#, 16#00#, 16#00#, 16#FF#, 16#86#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#70#, 16#00#, 16#00#, 16#1F#, 16#F7#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#07#, 16#FF#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#FF#, 16#FC#, 16#03#, 16#FF#, 16#FF#, 16#FF#, 16#F0#, 16#0F#, 16#FC#, 16#00#, 16#FF#, 16#C0#, 16#3F#, 16#80#, 16#07#, 16#FE#, 16#01#, 16#F8#, 16#00#, 16#3F#, 16#F0#, 16#07#, 16#C0#, 16#00#, 16#FF#, 16#80#, 16#1E#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#F0#, 16#00#, 16#3F#, 16#F0#, 16#03#, 16#80#, 16#01#, 16#FF#, 16#80#, 16#0C#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#70#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#06#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#18#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#C0#, 16#1F#, 16#F8#, 16#00#, 16#07#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#3C#, 16#03#, 16#FF#, 16#00#, 16#01#, 16#F0#, 16#1F#, 16#F8#, 16#00#, 16#0F#, 16#80#, 16#FF#, 16#C0#, 16#00#, 16#7E#, 16#03#, 16#FE#, 16#00#, 16#07#, 16#F8#, 16#1F#, 16#F8#, 16#01#, 16#FF#, 16#E0#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#03#, 16#FF#, 16#FF#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#07#, 16#FF#, 16#80#, 16#03#, 16#F0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#3F#, 16#FF#, 16#00#, 16#1F#, 16#FF#, 16#80#, 16#00#, 16#F8#, 16#00#, 16#7E#, 16#00#, 16#1F#, 16#00#, 16#0F#, 16#80#, 16#07#, 16#C0#, 16#03#, 16#F0#, 16#00#, 16#F8#, 16#00#, 16#7C#, 16#00#, 16#3F#, 16#00#, 16#0F#, 16#80#, 16#07#, 16#C0#, 16#03#, 16#E0#, 16#01#, 16#F8#, 16#00#, 16#7C#, 16#00#, 16#3E#, 16#00#, 16#1F#, 16#00#, 16#0F#, 16#C0#, 16#03#, 16#E0#, 16#01#, 16#F0#, 16#00#, 16#F8#, 16#00#, 16#7E#, 16#00#, 16#1F#, 16#00#, 16#0F#, 16#80#, 16#07#, 16#E0#, 16#01#, 16#F0#, 16#00#, 16#F8#, 16#00#, 16#7C#, 16#00#, 16#3F#, 16#00#, 16#0F#, 16#80#, 16#07#, 16#C0#, 16#03#, 16#E0#, 16#01#, 16#F8#, 16#00#, 16#7C#, 16#00#, 16#3E#, 16#00#, 16#1F#, 16#00#, 16#0F#, 16#C0#, 16#03#, 16#E0#, 16#01#, 16#F0#, 16#00#, 16#FC#, 16#00#, 16#3E#, 16#00#, 16#1F#, 16#00#, 16#0F#, 16#80#, 16#07#, 16#E0#, 16#01#, 16#F0#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#07#, 16#FF#, 16#80#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#E0#, 16#00#, 16#07#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#0F#, 16#9F#, 16#00#, 16#01#, 16#F9#, 16#F8#, 16#00#, 16#1F#, 16#0F#, 16#80#, 16#03#, 16#F0#, 16#FC#, 16#00#, 16#3E#, 16#07#, 16#C0#, 16#07#, 16#E0#, 16#7E#, 16#00#, 16#7C#, 16#03#, 16#E0#, 16#0F#, 16#C0#, 16#3F#, 16#00#, 16#F8#, 16#01#, 16#F0#, 16#1F#, 16#80#, 16#1F#, 16#81#, 16#F0#, 16#01#, 16#F8#, 16#3F#, 16#00#, 16#0F#, 16#C3#, 16#F0#, 16#00#, 16#FC#, 16#7E#, 16#00#, 16#07#, 16#C7#, 16#E0#, 16#00#, 16#7E#, 16#FC#, 16#00#, 16#03#, 16#E0#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#70#, 16#07#, 16#E0#, 16#3F#, 16#81#, 16#FC#, 16#07#, 16#F0#, 16#1F#, 16#C0#, 16#7F#, 16#00#, 16#F8#, 16#03#, 16#E0#, 16#07#, 16#80#, 16#1E#, 16#00#, 16#03#, 16#E0#, 16#0C#, 16#00#, 16#3F#, 16#E7#, 16#E0#, 16#03#, 16#FF#, 16#BF#, 16#80#, 16#1F#, 16#C7#, 16#FE#, 16#00#, 16#FE#, 16#0F#, 16#F8#, 16#07#, 16#F0#, 16#3F#, 16#C0#, 16#3F#, 16#80#, 16#FF#, 16#01#, 16#FE#, 16#03#, 16#FC#, 16#07#, 16#F0#, 16#0F#, 16#E0#, 16#3F#, 16#C0#, 16#3F#, 16#81#, 16#FE#, 16#00#, 16#FE#, 16#07#, 16#F8#, 16#03#, 16#F0#, 16#3F#, 16#C0#, 16#0F#, 16#C0#, 16#FF#, 16#00#, 16#7F#, 16#07#, 16#FC#, 16#01#, 16#FC#, 16#1F#, 16#E0#, 16#07#, 16#E0#, 16#7F#, 16#80#, 16#3F#, 16#83#, 16#FE#, 16#00#, 16#FE#, 16#0F#, 16#F0#, 16#07#, 16#F0#, 16#3F#, 16#C0#, 16#1F#, 16#C0#, 16#FF#, 16#00#, 16#FF#, 16#03#, 16#FC#, 16#07#, 16#F8#, 16#2F#, 16#F0#, 16#1F#, 16#E1#, 16#BF#, 16#C0#, 16#FF#, 16#8C#, 16#FF#, 16#8E#, 16#FE#, 16#71#, 16#FF#, 16#FB#, 16#FF#, 16#87#, 16#FF#, 16#CF#, 16#FC#, 16#0F#, 16#FE#, 16#3F#, 16#E0#, 16#1F#, 16#F0#, 16#7F#, 16#00#, 16#3F#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#07#, 16#FF#, 16#80#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#C3#, 16#F0#, 16#01#, 16#FC#, 16#7F#, 16#C0#, 16#0F#, 16#E7#, 16#FF#, 16#00#, 16#7F#, 16#7F#, 16#FC#, 16#07#, 16#FF#, 16#1F#, 16#E0#, 16#3F#, 16#A0#, 16#7F#, 16#81#, 16#FF#, 16#03#, 16#FC#, 16#0F#, 16#F0#, 16#1F#, 16#E0#, 16#FF#, 16#00#, 16#FF#, 16#07#, 16#F8#, 16#07#, 16#F8#, 16#3F#, 16#80#, 16#3F#, 16#C3#, 16#FC#, 16#01#, 16#FE#, 16#1F#, 16#E0#, 16#0F#, 16#E0#, 16#FE#, 16#00#, 16#FF#, 16#07#, 16#F0#, 16#07#, 16#F8#, 16#7F#, 16#80#, 16#3F#, 16#C3#, 16#F8#, 16#01#, 16#FC#, 16#1F#, 16#C0#, 16#1F#, 16#E1#, 16#FE#, 16#00#, 16#FE#, 16#0F#, 16#F0#, 16#0F#, 16#F0#, 16#7F#, 16#00#, 16#7F#, 16#03#, 16#F8#, 16#07#, 16#F0#, 16#3F#, 16#C0#, 16#3F#, 16#01#, 16#FC#, 16#03#, 16#F0#, 16#1F#, 16#E0#, 16#3F#, 16#00#, 16#FF#, 16#01#, 16#F0#, 16#07#, 16#F8#, 16#1F#, 16#00#, 16#1F#, 16#E3#, 16#F0#, 16#00#, 16#7F#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#3E#, 16#3E#, 16#00#, 16#FC#, 16#3F#, 16#01#, 16#F8#, 16#3F#, 16#03#, 16#F0#, 16#7F#, 16#07#, 16#F0#, 16#7F#, 16#07#, 16#E0#, 16#7F#, 16#0F#, 16#E0#, 16#7E#, 16#1F#, 16#C0#, 16#3C#, 16#1F#, 16#C0#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#10#, 16#FF#, 16#00#, 16#18#, 16#FF#, 16#00#, 16#38#, 16#FF#, 16#80#, 16#70#, 16#7F#, 16#80#, 16#E0#, 16#7F#, 16#C3#, 16#C0#, 16#3F#, 16#FF#, 16#80#, 16#1F#, 16#FF#, 16#00#, 16#0F#, 16#FE#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#0F#, 16#9F#, 16#E0#, 16#00#, 16#0F#, 16#FB#, 16#FC#, 16#00#, 16#03#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#FE#, 16#3F#, 16#E0#, 16#00#, 16#7F#, 16#83#, 16#FC#, 16#00#, 16#1F#, 16#E0#, 16#7F#, 16#80#, 16#07#, 16#F8#, 16#0F#, 16#E0#, 16#00#, 16#FE#, 16#01#, 16#FC#, 16#00#, 16#3F#, 16#80#, 16#7F#, 16#80#, 16#0F#, 16#F0#, 16#0F#, 16#E0#, 16#01#, 16#FC#, 16#01#, 16#FC#, 16#00#, 16#7F#, 16#80#, 16#3F#, 16#80#, 16#1F#, 16#E0#, 16#0F#, 16#F0#, 16#03#, 16#FC#, 16#01#, 16#FE#, 16#00#, 16#7F#, 16#80#, 16#3F#, 16#80#, 16#1F#, 16#E0#, 16#0F#, 16#F0#, 16#03#, 16#FC#, 16#01#, 16#FE#, 16#00#, 16#7F#, 16#80#, 16#7F#, 16#C0#, 16#1F#, 16#E0#, 16#0F#, 16#F0#, 16#03#, 16#FC#, 16#03#, 16#FE#, 16#00#, 16#7F#, 16#80#, 16#7F#, 16#C0#, 16#0F#, 16#F0#, 16#1F#, 16#F8#, 16#C1#, 16#FE#, 16#03#, 16#FE#, 16#18#, 16#3F#, 16#C0#, 16#DF#, 16#C6#, 16#07#, 16#FC#, 16#7B#, 16#F9#, 16#80#, 16#7F#, 16#FE#, 16#7F#, 16#F0#, 16#0F#, 16#FF#, 16#8F#, 16#FC#, 16#00#, 16#FF#, 16#E1#, 16#FF#, 16#00#, 16#0F#, 16#F8#, 16#1F#, 16#C0#, 16#00#, 16#FC#, 16#01#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#3E#, 16#3E#, 16#00#, 16#FC#, 16#3F#, 16#01#, 16#F8#, 16#3F#, 16#03#, 16#F0#, 16#3F#, 16#07#, 16#F0#, 16#3F#, 16#07#, 16#E0#, 16#3F#, 16#0F#, 16#E0#, 16#7E#, 16#1F#, 16#E0#, 16#7E#, 16#1F#, 16#C0#, 16#FC#, 16#3F#, 16#C1#, 16#F8#, 16#3F#, 16#C3#, 16#F0#, 16#7F#, 16#87#, 16#E0#, 16#7F#, 16#9F#, 16#C0#, 16#7F#, 16#FF#, 16#00#, 16#FF#, 16#F8#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#38#, 16#FF#, 16#00#, 16#70#, 16#FF#, 16#00#, 16#E0#, 16#7F#, 16#81#, 16#E0#, 16#7F#, 16#C3#, 16#C0#, 16#3F#, 16#FF#, 16#80#, 16#1F#, 16#FF#, 16#00#, 16#0F#, 16#FE#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#E7#, 16#80#, 16#00#, 16#00#, 16#3F#, 16#1F#, 16#00#, 16#00#, 16#01#, 16#F8#, 16#FC#, 16#00#, 16#00#, 16#0F#, 16#C3#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#0F#, 16#C0#, 16#00#, 16#01#, 16#FC#, 16#1E#, 16#00#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#01#, 16#E0#, 16#FC#, 16#00#, 16#00#, 16#0F#, 16#C3#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#FC#, 16#7C#, 16#00#, 16#00#, 16#03#, 16#E1#, 16#F0#, 16#00#, 16#00#, 16#07#, 16#8F#, 16#80#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#0F#, 16#E1#, 16#FF#, 16#E0#, 16#0F#, 16#E0#, 16#7F#, 16#F0#, 16#0F#, 16#E0#, 16#3F#, 16#F8#, 16#0F#, 16#E0#, 16#1F#, 16#C0#, 16#0F#, 16#F0#, 16#0F#, 16#E0#, 16#07#, 16#F0#, 16#07#, 16#F0#, 16#07#, 16#F8#, 16#03#, 16#F8#, 16#03#, 16#FC#, 16#03#, 16#FC#, 16#01#, 16#FC#, 16#01#, 16#FE#, 16#00#, 16#FE#, 16#00#, 16#FF#, 16#00#, 16#7F#, 16#00#, 16#FF#, 16#00#, 16#3F#, 16#80#, 16#7F#, 16#80#, 16#1F#, 16#C0#, 16#7F#, 16#80#, 16#07#, 16#E0#, 16#3F#, 16#80#, 16#01#, 16#F0#, 16#3F#, 16#80#, 16#00#, 16#FC#, 16#3F#, 16#80#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#0F#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#F0#, 16#00#, 16#03#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#E0#, 16#00#, 16#3F#, 16#FF#, 16#F8#, 16#00#, 16#1F#, 16#FF#, 16#FE#, 16#00#, 16#7C#, 16#3F#, 16#FF#, 16#80#, 16#7C#, 16#03#, 16#FF#, 16#C0#, 16#7C#, 16#00#, 16#3F#, 16#E0#, 16#7C#, 16#00#, 16#0F#, 16#F0#, 16#3E#, 16#00#, 16#03#, 16#F8#, 16#1F#, 16#00#, 16#01#, 16#F8#, 16#0F#, 16#80#, 16#00#, 16#FC#, 16#07#, 16#E0#, 16#00#, 16#FC#, 16#01#, 16#F8#, 16#00#, 16#FC#, 16#00#, 16#7F#, 16#01#, 16#F8#, 16#00#, 16#1F#, 16#FF#, 16#F0#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#01#, 16#F0#, 16#01#, 16#FE#, 16#07#, 16#F8#, 16#01#, 16#FE#, 16#0F#, 16#FC#, 16#01#, 16#FC#, 16#3F#, 16#FC#, 16#01#, 16#FC#, 16#7F#, 16#FC#, 16#03#, 16#FC#, 16#71#, 16#FC#, 16#03#, 16#FC#, 16#E1#, 16#FC#, 16#03#, 16#F9#, 16#C1#, 16#FC#, 16#03#, 16#FB#, 16#81#, 16#FC#, 16#07#, 16#FF#, 16#03#, 16#FC#, 16#07#, 16#F6#, 16#03#, 16#FC#, 16#07#, 16#FE#, 16#03#, 16#FC#, 16#0F#, 16#FC#, 16#03#, 16#F8#, 16#0F#, 16#F8#, 16#07#, 16#F8#, 16#0F#, 16#F8#, 16#07#, 16#F8#, 16#0F#, 16#F0#, 16#07#, 16#F0#, 16#1F#, 16#F0#, 16#0F#, 16#F0#, 16#1F#, 16#E0#, 16#0F#, 16#F0#, 16#1F#, 16#E0#, 16#0F#, 16#E0#, 16#1F#, 16#E0#, 16#1F#, 16#E0#, 16#3F#, 16#C0#, 16#1F#, 16#E2#, 16#3F#, 16#C0#, 16#1F#, 16#C7#, 16#3F#, 16#C0#, 16#3F#, 16#C6#, 16#7F#, 16#80#, 16#3F#, 16#CC#, 16#7F#, 16#80#, 16#3F#, 16#98#, 16#7F#, 16#80#, 16#3F#, 16#F8#, 16#7F#, 16#00#, 16#3F#, 16#F0#, 16#FF#, 16#00#, 16#1F#, 16#C0#, 16#0F#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#78#, 16#01#, 16#F8#, 16#07#, 16#F8#, 16#0F#, 16#F0#, 16#1F#, 16#E0#, 16#3F#, 16#C0#, 16#7F#, 16#80#, 16#7E#, 16#00#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#06#, 16#03#, 16#FC#, 16#7F#, 16#F8#, 16#FF#, 16#E0#, 16#3F#, 16#C0#, 16#3F#, 16#80#, 16#FF#, 16#01#, 16#FC#, 16#03#, 16#F8#, 16#07#, 16#F0#, 16#1F#, 16#E0#, 16#3F#, 16#80#, 16#7F#, 16#00#, 16#FE#, 16#03#, 16#F8#, 16#07#, 16#F0#, 16#0F#, 16#E0#, 16#1F#, 16#C0#, 16#7F#, 16#00#, 16#FE#, 16#01#, 16#FC#, 16#67#, 16#F0#, 16#CF#, 16#E3#, 16#1F#, 16#CC#, 16#3F#, 16#F8#, 16#7F#, 16#E0#, 16#FF#, 16#80#, 16#FE#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#7F#, 16#FC#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#78#, 16#1F#, 16#80#, 16#07#, 16#E1#, 16#FC#, 16#00#, 16#3F#, 16#0F#, 16#C0#, 16#01#, 16#F8#, 16#FC#, 16#00#, 16#0F#, 16#87#, 16#E0#, 16#00#, 16#3C#, 16#7C#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#E0#, 16#00#, 16#03#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#1F#, 16#FF#, 16#00#, 16#FE#, 16#1F#, 16#FF#, 16#01#, 16#FC#, 16#07#, 16#F8#, 16#01#, 16#FC#, 16#03#, 16#E0#, 16#01#, 16#FC#, 16#07#, 16#C0#, 16#01#, 16#FC#, 16#07#, 16#00#, 16#03#, 16#F8#, 16#0E#, 16#00#, 16#03#, 16#F8#, 16#1C#, 16#00#, 16#03#, 16#F8#, 16#78#, 16#00#, 16#07#, 16#F8#, 16#E0#, 16#00#, 16#07#, 16#F1#, 16#E0#, 16#00#, 16#07#, 16#F3#, 16#F0#, 16#00#, 16#0F#, 16#FF#, 16#F0#, 16#00#, 16#0F#, 16#FF#, 16#F0#, 16#00#, 16#0F#, 16#FF#, 16#F0#, 16#00#, 16#0F#, 16#F7#, 16#F8#, 16#00#, 16#1F#, 16#E3#, 16#F8#, 16#00#, 16#1F#, 16#C3#, 16#F8#, 16#00#, 16#1F#, 16#C3#, 16#F8#, 16#00#, 16#3F#, 16#C3#, 16#FC#, 16#08#, 16#3F#, 16#C1#, 16#FC#, 16#18#, 16#3F#, 16#81#, 16#FC#, 16#18#, 16#3F#, 16#81#, 16#FE#, 16#30#, 16#7F#, 16#80#, 16#FF#, 16#E0#, 16#7F#, 16#80#, 16#FF#, 16#E0#, 16#7F#, 16#00#, 16#7F#, 16#C0#, 16#FF#, 16#00#, 16#7F#, 16#80#, 16#0F#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#01#, 16#C0#, 16#1F#, 16#E0#, 16#7F#, 16#F8#, 16#1F#, 16#FE#, 16#00#, 16#FF#, 16#00#, 16#3F#, 16#C0#, 16#0F#, 16#F0#, 16#03#, 16#F8#, 16#00#, 16#FE#, 16#00#, 16#3F#, 16#80#, 16#1F#, 16#E0#, 16#07#, 16#F0#, 16#01#, 16#FC#, 16#00#, 16#7F#, 16#00#, 16#1F#, 16#80#, 16#0F#, 16#E0#, 16#03#, 16#F8#, 16#00#, 16#FE#, 16#00#, 16#7F#, 16#00#, 16#1F#, 16#C0#, 16#07#, 16#F0#, 16#01#, 16#F8#, 16#00#, 16#FE#, 16#00#, 16#3F#, 16#80#, 16#0F#, 16#E0#, 16#07#, 16#F0#, 16#01#, 16#FC#, 16#00#, 16#7F#, 16#00#, 16#3F#, 16#80#, 16#0F#, 16#E0#, 16#03#, 16#F8#, 16#00#, 16#FC#, 16#00#, 16#7F#, 16#00#, 16#1F#, 16#C0#, 16#07#, 16#F0#, 16#01#, 16#FC#, 16#30#, 16#FE#, 16#18#, 16#3F#, 16#8E#, 16#0F#, 16#E7#, 16#03#, 16#FF#, 16#80#, 16#FF#, 16#C0#, 16#3F#, 16#E0#, 16#07#, 16#F0#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#06#, 16#03#, 16#E0#, 16#07#, 16#C0#, 16#0F#, 16#F0#, 16#7F#, 16#80#, 16#FF#, 16#0F#, 16#FF#, 16#07#, 16#FE#, 16#0F#, 16#F8#, 16#7F#, 16#F8#, 16#7F#, 16#F0#, 16#FF#, 16#E0#, 16#7F#, 16#87#, 16#FF#, 16#8F#, 16#FF#, 16#01#, 16#FC#, 16#71#, 16#FC#, 16#E3#, 16#F8#, 16#0F#, 16#E7#, 16#0F#, 16#EE#, 16#1F#, 16#C0#, 16#FE#, 16#70#, 16#7F#, 16#60#, 16#FE#, 16#07#, 16#F3#, 16#03#, 16#F6#, 16#07#, 16#F0#, 16#3F#, 16#B0#, 16#3F#, 16#E0#, 16#7F#, 16#81#, 16#FB#, 16#81#, 16#FF#, 16#03#, 16#F8#, 16#1F#, 16#D8#, 16#0F#, 16#F0#, 16#1F#, 16#C0#, 16#FF#, 16#80#, 16#FF#, 16#81#, 16#FE#, 16#07#, 16#FC#, 16#07#, 16#F8#, 16#0F#, 16#F0#, 16#7F#, 16#C0#, 16#3F#, 16#C0#, 16#FF#, 16#03#, 16#FE#, 16#03#, 16#FC#, 16#07#, 16#F8#, 16#1F#, 16#E0#, 16#1F#, 16#E0#, 16#3F#, 16#80#, 16#FF#, 16#00#, 16#FE#, 16#03#, 16#FC#, 16#0F#, 16#F0#, 16#0F#, 16#F0#, 16#1F#, 16#E0#, 16#7F#, 16#80#, 16#7F#, 16#80#, 16#FF#, 16#03#, 16#FC#, 16#03#, 16#F8#, 16#07#, 16#F0#, 16#3F#, 16#C0#, 16#3F#, 16#C0#, 16#7F#, 16#8D#, 16#FE#, 16#01#, 16#FE#, 16#03#, 16#F8#, 16#CF#, 16#F0#, 16#0F#, 16#E0#, 16#1F#, 16#C6#, 16#7F#, 16#00#, 16#FF#, 16#00#, 16#FE#, 16#67#, 16#F8#, 16#07#, 16#F8#, 16#07#, 16#FE#, 16#3F#, 16#C0#, 16#3F#, 16#80#, 16#3F#, 16#E1#, 16#FC#, 16#01#, 16#FC#, 16#01#, 16#FE#, 16#01#, 16#E0#, 16#1F#, 16#E0#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#01#, 16#F0#, 16#00#, 16#FE#, 16#0F#, 16#F0#, 16#7F#, 16#F8#, 16#3F#, 16#F0#, 16#FF#, 16#F0#, 16#FF#, 16#E0#, 16#3F#, 16#E3#, 16#FF#, 16#C0#, 16#3F#, 16#8E#, 16#3F#, 16#80#, 16#7F#, 16#38#, 16#7F#, 16#01#, 16#FE#, 16#60#, 16#FE#, 16#03#, 16#F9#, 16#81#, 16#FC#, 16#07#, 16#F6#, 16#07#, 16#F0#, 16#0F#, 16#E8#, 16#0F#, 16#E0#, 16#3F#, 16#B0#, 16#1F#, 16#C0#, 16#7F#, 16#C0#, 16#7F#, 16#80#, 16#FF#, 16#80#, 16#FF#, 16#03#, 16#FE#, 16#01#, 16#FC#, 16#07#, 16#FC#, 16#07#, 16#F8#, 16#0F#, 16#F0#, 16#0F#, 16#E0#, 16#1F#, 16#E0#, 16#1F#, 16#C0#, 16#7F#, 16#80#, 16#7F#, 16#80#, 16#FF#, 16#00#, 16#FE#, 16#01#, 16#FE#, 16#01#, 16#FC#, 16#07#, 16#F8#, 16#07#, 16#F8#, 16#CF#, 16#F0#, 16#0F#, 16#E3#, 16#1F#, 16#E0#, 16#1F#, 16#C6#, 16#3F#, 16#80#, 16#3F#, 16#98#, 16#FF#, 16#00#, 16#7F#, 16#E1#, 16#FE#, 16#00#, 16#FF#, 16#83#, 16#FC#, 16#00#, 16#FE#, 16#00#, 16#F0#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#03#, 16#FF#, 16#C0#, 16#00#, 16#F8#, 16#7C#, 16#00#, 16#7E#, 16#07#, 16#C0#, 16#1F#, 16#80#, 16#FC#, 16#07#, 16#E0#, 16#1F#, 16#81#, 16#FC#, 16#03#, 16#F8#, 16#7F#, 16#00#, 16#7F#, 16#0F#, 16#E0#, 16#0F#, 16#E3#, 16#F8#, 16#01#, 16#FC#, 16#FF#, 16#00#, 16#7F#, 16#9F#, 16#C0#, 16#0F#, 16#F3#, 16#F8#, 16#01#, 16#FE#, 16#FF#, 16#00#, 16#3F#, 16#DF#, 16#C0#, 16#07#, 16#F3#, 16#F8#, 16#01#, 16#FE#, 16#FF#, 16#00#, 16#3F#, 16#DF#, 16#E0#, 16#07#, 16#FB#, 16#FC#, 16#00#, 16#FE#, 16#7F#, 16#00#, 16#3F#, 16#CF#, 16#E0#, 16#07#, 16#F1#, 16#FC#, 16#01#, 16#FC#, 16#3F#, 16#80#, 16#3F#, 16#87#, 16#F0#, 16#0F#, 16#E0#, 16#7E#, 16#01#, 16#F8#, 16#0F#, 16#C0#, 16#7E#, 16#00#, 16#FC#, 16#1F#, 16#80#, 16#0F#, 16#87#, 16#E0#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#3F#, 16#00#, 16#00#, 16#7F#, 16#8F#, 16#F8#, 16#00#, 16#7F#, 16#F9#, 16#FF#, 16#C0#, 16#07#, 16#FF#, 16#3F#, 16#FE#, 16#00#, 16#0F#, 16#F7#, 16#FF#, 16#E0#, 16#00#, 16#7F#, 16#61#, 16#FF#, 16#00#, 16#0F#, 16#EC#, 16#0F#, 16#F0#, 16#00#, 16#FF#, 16#80#, 16#FF#, 16#00#, 16#0F#, 16#F0#, 16#0F#, 16#F0#, 16#00#, 16#FF#, 16#00#, 16#FF#, 16#00#, 16#0F#, 16#E0#, 16#0F#, 16#F0#, 16#01#, 16#FE#, 16#00#, 16#FF#, 16#00#, 16#1F#, 16#E0#, 16#1F#, 16#F0#, 16#01#, 16#FC#, 16#01#, 16#FE#, 16#00#, 16#1F#, 16#C0#, 16#1F#, 16#E0#, 16#01#, 16#FC#, 16#03#, 16#FE#, 16#00#, 16#3F#, 16#80#, 16#3F#, 16#C0#, 16#03#, 16#F8#, 16#03#, 16#FC#, 16#00#, 16#3F#, 16#80#, 16#7F#, 16#80#, 16#07#, 16#F0#, 16#07#, 16#F8#, 16#00#, 16#7F#, 16#00#, 16#7F#, 16#00#, 16#07#, 16#F0#, 16#0F#, 16#F0#, 16#00#, 16#7F#, 16#00#, 16#FE#, 16#00#, 16#0F#, 16#E0#, 16#1F#, 16#C0#, 16#00#, 16#FE#, 16#03#, 16#F8#, 16#00#, 16#0F#, 16#E0#, 16#3F#, 16#00#, 16#01#, 16#FE#, 16#07#, 16#E0#, 16#00#, 16#1F#, 16#F1#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#1F#, 16#CF#, 16#C0#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#E7#, 16#F0#, 16#03#, 16#FF#, 16#9F#, 16#80#, 16#1F#, 16#E3#, 16#FE#, 16#00#, 16#FE#, 16#07#, 16#F8#, 16#07#, 16#F0#, 16#1F#, 16#E0#, 16#3F#, 16#C0#, 16#7F#, 16#01#, 16#FE#, 16#01#, 16#FC#, 16#07#, 16#F0#, 16#07#, 16#F0#, 16#3F#, 16#C0#, 16#3F#, 16#C1#, 16#FE#, 16#00#, 16#FE#, 16#07#, 16#F8#, 16#03#, 16#F8#, 16#3F#, 16#C0#, 16#0F#, 16#E0#, 16#FF#, 16#00#, 16#7F#, 16#07#, 16#F8#, 16#01#, 16#FC#, 16#1F#, 16#E0#, 16#07#, 16#F0#, 16#7F#, 16#80#, 16#3F#, 16#C3#, 16#FE#, 16#00#, 16#FE#, 16#0F#, 16#F0#, 16#07#, 16#F8#, 16#3F#, 16#C0#, 16#1F#, 16#E0#, 16#FF#, 16#00#, 16#FF#, 16#03#, 16#FC#, 16#07#, 16#FC#, 16#0F#, 16#F0#, 16#1F#, 16#F0#, 16#3F#, 16#C0#, 16#FF#, 16#80#, 16#FF#, 16#8E#, 16#FE#, 16#01#, 16#FF#, 16#F3#, 16#F8#, 16#07#, 16#FF#, 16#DF#, 16#E0#, 16#0F#, 16#FE#, 16#7F#, 16#00#, 16#1F#, 16#E1#, 16#FC#, 16#00#, 16#3F#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#01#, 16#FF#, 16#FF#, 16#00#, 16#07#, 16#FF#, 16#FC#, 16#00#, 16#00#, 16#06#, 16#0F#, 16#00#, 16#FF#, 16#1F#, 16#C7#, 16#FF#, 16#1F#, 16#E3#, 16#FF#, 16#8F#, 16#F0#, 16#3F#, 16#CF#, 16#F8#, 16#1F#, 16#CF#, 16#FC#, 16#0F#, 16#E6#, 16#7E#, 16#07#, 16#F6#, 16#1E#, 16#07#, 16#F6#, 16#00#, 16#03#, 16#FB#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#FD#, 16#80#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#08#, 16#0F#, 16#FF#, 16#C0#, 16#FC#, 16#3E#, 16#0F#, 16#C0#, 16#F0#, 16#7C#, 16#07#, 16#87#, 16#E0#, 16#1C#, 16#3F#, 16#00#, 16#C1#, 16#FC#, 16#02#, 16#0F#, 16#E0#, 16#10#, 16#7F#, 16#80#, 16#83#, 16#FE#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#7F#, 16#E0#, 16#01#, 16#FF#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#FF#, 16#80#, 16#03#, 16#FE#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#7F#, 16#C4#, 16#01#, 16#FE#, 16#20#, 16#07#, 16#F1#, 16#80#, 16#3F#, 16#8C#, 16#00#, 16#FC#, 16#E0#, 16#07#, 16#C7#, 16#80#, 16#3E#, 16#3E#, 16#03#, 16#E1#, 16#F8#, 16#3E#, 16#0F#, 16#FF#, 16#E0#, 16#41#, 16#FC#, 16#00#, 16#00#, 16#03#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#E0#, 16#00#, 16#78#, 16#00#, 16#3E#, 16#00#, 16#1F#, 16#80#, 16#0F#, 16#C0#, 16#07#, 16#F0#, 16#07#, 16#FC#, 16#07#, 16#FF#, 16#F3#, 16#FF#, 16#FC#, 16#FF#, 16#FF#, 16#03#, 16#F8#, 16#01#, 16#FE#, 16#00#, 16#7F#, 16#00#, 16#1F#, 16#C0#, 16#07#, 16#F0#, 16#03#, 16#FC#, 16#00#, 16#FE#, 16#00#, 16#3F#, 16#80#, 16#1F#, 16#E0#, 16#07#, 16#F0#, 16#01#, 16#FC#, 16#00#, 16#7F#, 16#00#, 16#3F#, 16#C0#, 16#0F#, 16#E0#, 16#03#, 16#F8#, 16#01#, 16#FE#, 16#10#, 16#7F#, 16#0C#, 16#1F#, 16#C3#, 16#0F#, 16#F1#, 16#83#, 16#F9#, 16#C0#, 16#FF#, 16#F0#, 16#3F#, 16#F8#, 16#0F#, 16#FC#, 16#01#, 16#FE#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#0F#, 16#F0#, 16#0F#, 16#F7#, 16#FF#, 16#C0#, 16#3F#, 16#9F#, 16#FE#, 16#00#, 16#FE#, 16#0F#, 16#F8#, 16#07#, 16#F8#, 16#3F#, 16#E0#, 16#1F#, 16#C0#, 16#FF#, 16#00#, 16#7F#, 16#03#, 16#FC#, 16#03#, 16#FC#, 16#0F#, 16#F0#, 16#0F#, 16#E0#, 16#3F#, 16#80#, 16#3F#, 16#81#, 16#FE#, 16#01#, 16#FE#, 16#07#, 16#F8#, 16#07#, 16#F8#, 16#1F#, 16#C0#, 16#3F#, 16#C0#, 16#FF#, 16#00#, 16#FF#, 16#03#, 16#F8#, 16#07#, 16#FC#, 16#0F#, 16#E0#, 16#1F#, 16#E0#, 16#3F#, 16#80#, 16#FF#, 16#81#, 16#FC#, 16#03#, 16#FE#, 16#07#, 16#F0#, 16#1F#, 16#F0#, 16#1F#, 16#C0#, 16#FF#, 16#C0#, 16#FE#, 16#07#, 16#7F#, 16#0B#, 16#F8#, 16#39#, 16#F8#, 16#6F#, 16#E1#, 16#EF#, 16#E3#, 16#BF#, 16#8F#, 16#3F#, 16#9C#, 16#FF#, 16#F8#, 16#FF#, 16#E3#, 16#FF#, 16#C3#, 16#FF#, 16#0F#, 16#FE#, 16#0F#, 16#F8#, 16#1F#, 16#F0#, 16#1F#, 16#C0#, 16#3F#, 16#00#, 16#3C#, 16#00#, 16#07#, 16#80#, 16#39#, 16#FF#, 16#00#, 16#FB#, 16#FF#, 16#03#, 16#F9#, 16#FE#, 16#07#, 16#F1#, 16#FC#, 16#0F#, 16#E3#, 16#F8#, 16#0F#, 16#C7#, 16#F0#, 16#0F#, 16#8F#, 16#E0#, 16#1E#, 16#0F#, 16#C0#, 16#1C#, 16#1F#, 16#C0#, 16#38#, 16#3F#, 16#80#, 16#60#, 16#7F#, 16#01#, 16#C0#, 16#FE#, 16#03#, 16#01#, 16#FC#, 16#0C#, 16#03#, 16#F8#, 16#38#, 16#07#, 16#F0#, 16#60#, 16#0F#, 16#E1#, 16#80#, 16#1F#, 16#C7#, 16#00#, 16#3F#, 16#9C#, 16#00#, 16#7F#, 16#70#, 16#00#, 16#FF#, 16#C0#, 16#01#, 16#FF#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#78#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#07#, 16#80#, 16#06#, 16#00#, 16#E7#, 16#FC#, 16#00#, 16#70#, 16#0F#, 16#BF#, 16#E0#, 16#03#, 16#80#, 16#FE#, 16#7F#, 16#80#, 16#3C#, 16#07#, 16#F1#, 16#FC#, 16#03#, 16#E0#, 16#3F#, 16#8F#, 16#E0#, 16#1F#, 16#00#, 16#FC#, 16#7F#, 16#01#, 16#F8#, 16#07#, 16#C3#, 16#F8#, 16#0F#, 16#C0#, 16#1E#, 16#1F#, 16#C0#, 16#FE#, 16#00#, 16#F0#, 16#FF#, 16#0F#, 16#F0#, 16#07#, 16#03#, 16#F8#, 16#7F#, 16#C0#, 16#38#, 16#1F#, 16#C7#, 16#FE#, 16#03#, 16#80#, 16#FE#, 16#37#, 16#F0#, 16#1C#, 16#07#, 16#F3#, 16#BF#, 16#81#, 16#C0#, 16#3F#, 16#99#, 16#FC#, 16#1C#, 16#01#, 16#FD#, 16#8F#, 16#E0#, 16#E0#, 16#0F#, 16#FC#, 16#7F#, 16#0E#, 16#00#, 16#7F#, 16#C3#, 16#F8#, 16#E0#, 16#03#, 16#FE#, 16#1F#, 16#CF#, 16#00#, 16#1F#, 16#E0#, 16#FE#, 16#70#, 16#00#, 16#FF#, 16#07#, 16#F7#, 16#00#, 16#07#, 16#F0#, 16#3F#, 16#F0#, 16#00#, 16#3F#, 16#81#, 16#FF#, 16#00#, 16#01#, 16#F8#, 16#0F#, 16#F0#, 16#00#, 16#0F#, 16#80#, 16#3F#, 16#80#, 16#00#, 16#7C#, 16#01#, 16#F8#, 16#00#, 16#03#, 16#C0#, 16#0F#, 16#80#, 16#00#, 16#1C#, 16#00#, 16#78#, 16#00#, 16#00#, 16#E0#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#1E#, 16#00#, 16#7F#, 16#C0#, 16#3F#, 16#80#, 16#FF#, 16#E0#, 16#3F#, 16#C0#, 16#7F#, 16#F8#, 16#3F#, 16#F0#, 16#03#, 16#FC#, 16#3F#, 16#F0#, 16#00#, 16#FE#, 16#3F#, 16#F8#, 16#00#, 16#7F#, 16#1C#, 16#78#, 16#00#, 16#3F#, 16#DC#, 16#00#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#00#, 16#01#, 16#DF#, 16#E0#, 16#00#, 16#00#, 16#CF#, 16#F0#, 16#60#, 16#78#, 16#E3#, 16#F8#, 16#70#, 16#7F#, 16#E1#, 16#FE#, 16#70#, 16#7F#, 16#F0#, 16#FF#, 16#F0#, 16#3F#, 16#F0#, 16#3F#, 16#F0#, 16#1F#, 16#F0#, 16#1F#, 16#F0#, 16#07#, 16#F0#, 16#07#, 16#F0#, 16#01#, 16#F0#, 16#01#, 16#E0#, 16#00#, 16#00#, 16#01#, 16#80#, 16#38#, 16#00#, 16#7F#, 16#00#, 16#F8#, 16#07#, 16#FE#, 16#03#, 16#F8#, 16#0F#, 16#FE#, 16#07#, 16#F0#, 16#07#, 16#FC#, 16#0F#, 16#E0#, 16#07#, 16#F8#, 16#1F#, 16#C0#, 16#0F#, 16#F8#, 16#3F#, 16#80#, 16#0F#, 16#F0#, 16#3F#, 16#00#, 16#1F#, 16#E0#, 16#3C#, 16#00#, 16#3F#, 16#C0#, 16#38#, 16#00#, 16#3F#, 16#80#, 16#70#, 16#00#, 16#7F#, 16#80#, 16#C0#, 16#00#, 16#FF#, 16#03#, 16#80#, 16#01#, 16#FE#, 16#07#, 16#00#, 16#01#, 16#FC#, 16#0C#, 16#00#, 16#03#, 16#F8#, 16#38#, 16#00#, 16#07#, 16#F8#, 16#60#, 16#00#, 16#0F#, 16#F1#, 16#C0#, 16#00#, 16#0F#, 16#E3#, 16#00#, 16#00#, 16#1F#, 16#CE#, 16#00#, 16#00#, 16#3F#, 16#98#, 16#00#, 16#00#, 16#7F#, 16#70#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#78#, 16#00#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#00#, 16#07#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#01#, 16#E0#, 16#70#, 16#00#, 16#07#, 16#F1#, 16#C0#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#3F#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#FF#, 16#83#, 16#FF#, 16#FF#, 16#C1#, 16#FF#, 16#FF#, 16#C0#, 16#FF#, 16#FF#, 16#C0#, 16#7F#, 16#FF#, 16#C0#, 16#7F#, 16#FF#, 16#C0#, 16#38#, 16#01#, 16#C0#, 16#18#, 16#01#, 16#E0#, 16#1C#, 16#01#, 16#E0#, 16#0C#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#3F#, 16#C0#, 16#00#, 16#3F#, 16#F0#, 16#38#, 16#1F#, 16#FC#, 16#3E#, 16#1F#, 16#FE#, 16#1F#, 16#9F#, 16#FF#, 16#8F#, 16#CE#, 16#1F#, 16#C7#, 16#E0#, 16#07#, 16#F1#, 16#F0#, 16#00#, 16#F8#, 16#F0#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#03#, 16#FF#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#3F#, 16#E0#, 16#00#, 16#1F#, 16#E0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#3F#, 16#80#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#7F#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#E0#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#01#, 16#FF#, 16#F0#, 16#06#, 16#0F#, 16#FF#, 16#F0#, 16#1C#, 16#7F#, 16#FF#, 16#F1#, 16#F9#, 16#FF#, 16#FF#, 16#FF#, 16#E7#, 16#C1#, 16#FF#, 16#FF#, 16#8E#, 16#01#, 16#FF#, 16#FC#, 16#10#, 16#01#, 16#FF#, 16#E0#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#); FreeSerifBoldItalic32pt7bGlyphs : aliased constant Glyph_Array := ( (0, 0, 0, 16, 0, 1), -- 0x20 ' ' (0, 20, 44, 24, 4, -42), -- 0x21 '!' (110, 25, 18, 35, 9, -42), -- 0x22 '"' (167, 36, 44, 31, -2, -43), -- 0x23 '#' (365, 33, 52, 32, -2, -45), -- 0x24 '$' (580, 48, 43, 52, 2, -42), -- 0x25 '%' (838, 44, 44, 49, 0, -42), -- 0x26 '&' (1080, 9, 18, 18, 8, -42), -- 0x27 ''' (1101, 20, 54, 21, 2, -42), -- 0x28 '(' (1236, 20, 54, 21, -3, -42), -- 0x29 ')' (1371, 25, 27, 32, 3, -42), -- 0x2A '*' (1456, 31, 31, 36, 2, -30), -- 0x2B '+' (1577, 12, 20, 16, -3, -8), -- 0x2C ',' (1607, 17, 7, 21, 0, -16), -- 0x2D '-' (1622, 10, 9, 16, -1, -7), -- 0x2E '.' (1634, 25, 44, 21, 0, -42), -- 0x2F '/' (1772, 29, 44, 31, 1, -42), -- 0x30 '0' (1932, 26, 43, 31, 0, -42), -- 0x31 '1' (2072, 29, 43, 32, 1, -42), -- 0x32 '2' (2228, 29, 44, 32, 0, -42), -- 0x33 '3' (2388, 33, 43, 31, 0, -42), -- 0x34 '4' (2566, 31, 43, 31, 1, -41), -- 0x35 '5' (2733, 30, 44, 32, 2, -42), -- 0x36 '6' (2898, 29, 42, 31, 5, -41), -- 0x37 '7' (3051, 30, 44, 31, 1, -42), -- 0x38 '8' (3216, 31, 43, 31, 0, -42), -- 0x39 '9' (3383, 16, 30, 16, 1, -28), -- 0x3A ':' (3443, 18, 41, 16, -1, -28), -- 0x3B ';' (3536, 32, 33, 36, 2, -31), -- 0x3C '<' (3668, 32, 19, 36, 4, -25), -- 0x3D '=' (3744, 32, 33, 36, 4, -31), -- 0x3E '>' (3876, 25, 44, 31, 5, -42), -- 0x3F '?' (4014, 45, 44, 52, 4, -42), -- 0x40 '@' (4262, 42, 43, 44, 0, -42), -- 0x41 'A' (4488, 41, 42, 40, 0, -41), -- 0x42 'B' (4704, 40, 44, 39, 3, -42), -- 0x43 'C' (4924, 47, 42, 46, 0, -41), -- 0x44 'D' (5171, 42, 42, 40, 0, -41), -- 0x45 'E' (5392, 42, 42, 38, 0, -41), -- 0x46 'F' (5613, 43, 44, 44, 3, -42), -- 0x47 'G' (5850, 52, 42, 47, 0, -41), -- 0x48 'H' (6123, 27, 42, 24, 0, -41), -- 0x49 'I' (6265, 36, 48, 31, 0, -41), -- 0x4A 'J' (6481, 46, 42, 42, 0, -41), -- 0x4B 'K' (6723, 38, 42, 38, 0, -41), -- 0x4C 'L' (6923, 60, 43, 55, 0, -41), -- 0x4D 'M' (7246, 49, 43, 44, 0, -41), -- 0x4E 'N' (7510, 42, 44, 43, 2, -42), -- 0x4F 'O' (7741, 41, 42, 38, 0, -41), -- 0x50 'P' (7957, 42, 56, 43, 2, -42), -- 0x51 'Q' (8251, 42, 42, 42, 0, -41), -- 0x52 'R' (8472, 33, 44, 32, 0, -42), -- 0x53 'S' (8654, 36, 42, 37, 6, -41), -- 0x54 'T' (8843, 42, 43, 45, 7, -41), -- 0x55 'U' (9069, 42, 43, 44, 8, -41), -- 0x56 'V' (9295, 55, 43, 58, 8, -41), -- 0x57 'W' (9591, 45, 42, 44, 0, -41), -- 0x58 'X' (9828, 37, 42, 40, 8, -41), -- 0x59 'Y' (10023, 38, 42, 35, 0, -41), -- 0x5A 'Z' (10223, 25, 52, 21, -2, -41), -- 0x5B '[' (10386, 17, 44, 25, 7, -42), -- 0x5C '\' (10480, 26, 52, 21, -4, -41), -- 0x5D ']' (10649, 28, 23, 36, 4, -41), -- 0x5E '^' (10730, 32, 5, 31, 0, 6), -- 0x5F '_' (10750, 13, 11, 21, 5, -43), -- 0x60 '`' (10768, 30, 30, 32, 1, -28), -- 0x61 'a' (10881, 29, 45, 30, 2, -43), -- 0x62 'b' (11045, 24, 30, 27, 2, -28), -- 0x63 'c' (11135, 35, 45, 32, 1, -43), -- 0x64 'd' (11332, 24, 30, 26, 2, -28), -- 0x65 'e' (11422, 38, 57, 31, -6, -43), -- 0x66 'f' (11693, 33, 42, 31, -1, -28), -- 0x67 'g' (11867, 32, 44, 34, 1, -43), -- 0x68 'h' (12043, 15, 43, 18, 3, -42), -- 0x69 'i' (12124, 29, 56, 21, -5, -42), -- 0x6A 'j' (12327, 32, 44, 32, 1, -43), -- 0x6B 'k' (12503, 18, 44, 19, 3, -43), -- 0x6C 'l' (12602, 45, 29, 48, 1, -28), -- 0x6D 'm' (12766, 31, 29, 33, 0, -28), -- 0x6E 'n' (12879, 27, 30, 30, 2, -28), -- 0x6F 'o' (12981, 36, 42, 30, -5, -28), -- 0x70 'p' (13170, 30, 42, 31, 1, -28), -- 0x71 'q' (13328, 25, 29, 25, 1, -28), -- 0x72 'r' (13419, 21, 30, 22, 0, -28), -- 0x73 's' (13498, 18, 37, 18, 2, -36), -- 0x74 't' (13582, 30, 29, 33, 2, -28), -- 0x75 'u' (13691, 23, 30, 28, 4, -28), -- 0x76 'v' (13778, 37, 30, 41, 4, -28), -- 0x77 'w' (13917, 33, 30, 30, -2, -28), -- 0x78 'x' (14041, 31, 42, 27, -4, -28), -- 0x79 'y' (14204, 25, 33, 26, 1, -27), -- 0x7A 'z' (14308, 27, 55, 22, 1, -42), -- 0x7B '{' (14494, 5, 44, 17, 7, -42), -- 0x7C '|' (14522, 26, 55, 22, -8, -42), -- 0x7D '}' (14701, 30, 11, 36, 3, -20)); -- 0x7E '~' Font_D : aliased constant Bitmap_Font := (FreeSerifBoldItalic32pt7bBitmaps'Access, FreeSerifBoldItalic32pt7bGlyphs'Access, 75); Font : constant Giza.Font.Ref_Const := Font_D'Access; end Giza.Bitmap_Fonts.FreeSerifBoldItalic32pt7b;
-- (c) Copyright, Real-Time Innovations, $Date:: 2012-02-16 #$ -- All rights reserved. -- -- No duplications, whole or partial, manual or electronic, may be made -- without express written permission. Any such copies, or -- revisions thereof, must display this notice unaltered. -- This code contains trade secrets of Real-Time Innovations, Inc. with DDS.StatusCondition; with DDS.DomainParticipantListener; with DDS.TopicListener; with DDS.SubscriberListener; with DDS.PublisherListener; with DDS.PublisherSeq; with DDS.Publisher; with DDS.Topic; with DDS.Entity; with DDS.TopicDescription; with DDS.Subscriber; with DDS.SubscriberSeq; with DDS.ContentFilteredTopic; with DDS.MultiTopic; limited with DDS.DomainParticipantFactory; -- limited with DDS.FlowController; with DDS.DataWriter; with DDS.DataWriterListener; with DDS.DataReader; with DDS.DataReaderListener; -- <dref>DomainParticipant</dref> package DDS.DomainParticipant is pragma Elaborate_Body; TOPIC_QOS_DEFAULT : aliased constant TopicQos with Convention => Ada, Import, Link_Name => "DDS__DomainParticipant__TOPIC_QOS_DEFAULT"; -- <dref>TOPIC_QOS_DEFAULT</dref> PUBLISHER_QOS_DEFAULT : aliased constant PublisherQos with Convention => Ada, Import, Link_Name => "DDS__DomainParticipant__PUBLISHER_QOS_DEFAULT"; -- <dref>PUBLISHER_QOS_DEFAULT</dref> SUBSCRIBER_QOS_DEFAULT : aliased constant SubscriberQos with Convention => Ada, Import, Link_Name => "DDS__DomainParticipant__SUBSCRIBER_QOS_DEFAULT"; -- <dref>SUBSCRIBER_QOS_DEFAULT</dref> FLOW_CONTROLLER_PROPERTY_DEFAULT : aliased constant FlowControllerProperty_T with Convention => Ada, Import, Link_Name => "DDS__DomainParticipant__FLOW_CONTROLLER_PROPERTY_DEFAULT"; -- <dref>FLOW_CONTROLLER_PROPERTY_DEFAULT</dref> type Ref is limited interface and DDS.Entity.Ref; type Ref_Access is access all Ref'Class; -- Re-Implement From DDS.DomainEntity procedure Enable (Self : not null access Ref) is abstract; function Get_StatusCondition (Self : not null access Ref) return DDS.StatusCondition.Ref_Access is abstract; function Get_Status_Changes (Self : not null access Ref) return DDS.StatusMask is abstract; function Get_Instance_Handle (Self : not null access Ref) return DDS.InstanceHandle_T is abstract; function Get_Entity_Kind (Self : not null access Ref) return DDS.EntityKind_T is abstract; -- function Create_Publisher (Self : not null access Ref; Qos : in DDS.PublisherQos := PUBLISHER_QOS_DEFAULT; A_Listener : in DDS.PublisherListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Publisher.Ref_Access is abstract; -- <dref>DomainParticipant_create_publisher</dref> function Create_Publisher_With_Profile (Self : not null access Ref; Library_Name : in DDS.String; profile_name : in DDS.String; A_Listener : in DDS.PublisherListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Publisher.Ref_Access is abstract; function Create_Publisher_With_Profile (Self : not null access Ref; Library_Name : in Standard.String; profile_name : in Standard.String; A_Listener : in DDS.PublisherListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Publisher.Ref_Access is abstract; -- <dref>DomainParticipant_create_publisher_with_profile</dref> procedure Delete_Publisher (Self : not null access Ref; Publisher : in out DDS.Publisher.Ref_Access) is abstract; -- <dref>DomainParticipant_delete_publisher</dref> function Create_Subscriber (Self : not null access Ref; Qos : in DDS.SubscriberQos := SUBSCRIBER_QOS_DEFAULT; A_Listener : in DDS.SubscriberListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Subscriber.Ref_Access is abstract; -- <dref>DomainParticipant_create_subscriber</dref> function Create_Subscriber_With_Profile (Self : not null access Ref; Library_Name : in DDS.String; profile_name : in DDS.String; A_Listener : in DDS.SubscriberListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Subscriber.Ref_Access is abstract; function Create_Subscriber_With_Profile (Self : not null access Ref; Library_Name : in Standard.String; profile_name : in Standard.String; A_Listener : in DDS.SubscriberListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Subscriber.Ref_Access is abstract; -- <dref>DomainParticipant_create_subscriber_with_profile</dref> procedure Delete_Subscriber (Self : not null access Ref; S : in out DDS.Subscriber.Ref_Access) is abstract; -- <dref>DomainParticipant_delete_subscriber</dref> function Create_DataWriter (Self : not null access Ref; A_Topic : in DDS.Topic.Ref_Access; Qos : in DDS.DataWriterQos := DDS.Publisher.DATAWRITER_QOS_DEFAULT; A_Listener : in DDS.DataWriterListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.DataWriter.Ref_Access is abstract; -- <dref>DomainParticipant_create_datawriter</dref> function Create_DataWriter_With_Profile (Self : not null access Ref; A_Topic : in DDS.Topic.Ref_Access; Library_Name : in DDS.String; profile_name : in DDS.String; A_Listener : in DDS.DataWriterListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.DataWriter.Ref_Access is abstract; function Create_DataWriter_With_Profile (Self : not null access Ref; A_Topic : in DDS.Topic.Ref_Access; Library_Name : in Standard.String; profile_name : in Standard.String; A_Listener : in DDS.DataWriterListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.DataWriter.Ref_Access is abstract; -- <dref>DomainParticipant_create_datawriter_with_profile</dref> procedure Delete_DataWriter (Self : not null access Ref; A_DataWriter : in out DDS.DataWriter.Ref_Access) is abstract; -- <dref>DomainParticipant_delete_datawriter</dref> function Create_DataReader (Self : not null access Ref; Topic : not null access DDS.TopicDescription.Ref'Class; Qos : in DDS.DataReaderQoS := DDS.Subscriber.DATAREADER_QOS_DEFAULT; A_Listener : in DDS.DataReaderListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.DataReader.Ref_Access is abstract; -- <dref>DomainParticipant_create_datareader</dref> function Create_DataReader_With_Profile (Self : not null access Ref; Topic : not null access DDS.TopicDescription.Ref'Class; Library_Name : in DDS.String; profile_name : in DDS.String; A_Listener : in DDS.DataReaderListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.DataReader.Ref_Access is abstract; -- <dref>DomainParticipant_create_datareader_with_profile</dref> procedure Delete_DataReader (Self : not null access Ref; A_DataReader : in out DDS.DataReader.Ref_Access) is abstract; -- <dref>DomainParticipant_delete_datareader</dref> function Get_Builtin_Subscriber (Self : not null access Ref) return DDS.Subscriber.Ref_Access is abstract; -- <dref>DomainParticipant_get_builtin_subscriber</dref> function Get_Implicit_Publisher (Self : not null access Ref) return DDS.Publisher.Ref_Access is abstract; -- <dref>DomainParticipant_get_implicit_publisher</dref> function Get_Implicit_Subscriber (Self : not null access Ref) return DDS.Subscriber.Ref_Access is abstract; -- <dref>DomainParticipant_get_implicit_subscriber</dref> -- <dref>Shared_implicit_subscriber_mt_safety</dref> function Create_Topic (Self : not null access Ref; Topic_Name : in DDS.String; Type_Name : in DDS.String; Qos : in DDS.TopicQos := TOPIC_QOS_DEFAULT; A_Listener : in DDS.TopicListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Topic.Ref_Access is abstract; -- <dref>DomainParticipant_create_topic</dref> function Create_Topic_With_Profile (Self : not null access Ref; Topic_Name : in DDS.String; Type_Name : in DDS.String; Library_Name : in DDS.String; profile_name : in DDS.String; A_Listener : in DDS.TopicListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Topic.Ref_Access is abstract; function Create_Topic_With_Profile (Self : not null access Ref; Topic_Name : in DDS.String; Type_Name : in DDS.String; Library_Name : in Standard.String; profile_name : in Standard.String; A_Listener : in DDS.TopicListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Topic.Ref_Access is abstract; -- <dref>DomainParticipant_create_topic_with_profile</dref> function Get_Or_Create_Topic (Self : not null access Ref; Topic_Name : in DDS.String; Type_Name : in DDS.String; Qos : in DDS.TopicQos := DDS.DomainParticipant.TOPIC_QOS_DEFAULT; A_Listener : in DDS.TopicListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE)return DDS.Topic.Ref_Access is abstract; function Get_Or_Create_Topic_With_Profile (Self : not null access Ref; Topic_Name : in DDS.String; Type_Name : in DDS.String; Library_Name : in DDS.String; Profile_Name : in DDS.String; A_Listener : in DDS.TopicListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.Topic.Ref_Access is abstract; -- function Create_FlowController -- (Self : not null access Ref; -- name : DDS.String; -- prop : access DDS.FlowControllerProperty_T) -- return access DDS.FlowController.Ref'Class is abstract; procedure Delete_Topic (Self : not null access Ref; A_Topic : in out DDS.Topic.Ref_Access) is abstract; -- <dref>DomainParticipant_delete_topic</dref> function Find_Topic (Self : not null access Ref; Topic_Name : in DDS.String; Timeout : in DDS.Duration_T) return DDS.Topic.Ref_Access is abstract; -- <dref>DomainParticipant_find_topic</dref> function Lookup_Topicdescription (Self : not null access Ref; Name : in DDS.String) return DDS.TopicDescription.Ref_Access is abstract; -- <dref>DomainParticipant_lookup_topicdescription</dref> function Create_Contentfilteredtopic (Self : not null access Ref; Name : in DDS.String; Related_Topic : in DDS.Topic.Ref_Access; Filter_Expression : in DDS.String; Expression_Parameters : access DDS.String_Seq.Sequence) return DDS.ContentFilteredTopic.Ref_Access is abstract; -- <dref>DomainParticipant_create_contentfilteredtopic</dref> procedure Delete_Contentfilteredtopic (Self : not null access Ref; A_Contentfilteredtopic : in out DDS.ContentFilteredTopic.Ref_Access) is abstract; -- <dref>DomainParticipant_delete_contentfilteredtopic</dref> function Create_MultiTopic (Self : not null access Ref; Name : in DDS.String; Type_Name : in DDS.String; Subscription_Expression : in DDS.String; Expression_Parameters : access DDS.String_Seq.Sequence) return DDS.MultiTopic.Ref_Access is abstract; -- <dref>DomainParticipant_create_multitopic</dref> procedure Delete_MultiTopic (Self : not null access Ref; MTopic : in out DDS.MultiTopic.Ref_Access) is abstract; -- <dref>DomainParticipant_delete_multitopic</dref> procedure Delete_Contained_Entities (Self : not null access Ref) is abstract; -- <dref>DomainParticipant_delete_contained_entities</dref> procedure Set_Qos (Self : not null access Ref; Qos : in DDS.DomainParticipantQos) is abstract; -- <dref>DomainParticipant_set_qos</dref> procedure Set_Qos_With_Profile (Self : not null access Ref; library_name : in String; profile_name : in String) is abstract; procedure Set_Qos_With_Profile (Self : not null access Ref; library_name : in Standard.String; profile_name : in Standard.String) is abstract; -- <dref>DomainParticipant_set_qos_with_profile</dref> procedure Get_Qos (Self : not null access Ref; Qos : in out DDS.DomainParticipantQos) is abstract; -- <dref>DomainParticipant_get_qos</dref> procedure Set_Listener (Self : not null access Ref; A_Listener : DDS.DomainParticipantListener.Ref_Access; Mask : in DDS.StatusMask) is abstract; -- <dref>DomainParticipant_set_listener</dref> function Get_Listener (Self : not null access Ref) return DDS.DomainParticipantListener.Ref_Access is abstract; -- <dref>DomainParticipant_get_listener</dref> procedure Ignore_Participant (Self : not null access Ref; Handle : in DDS.InstanceHandle_T) is abstract; -- <dref>DomainParticipant_ignore_participant</dref> -- <dref>Shared_ignore_participant</dref> procedure Ignore_Topic (Self : not null access Ref; Handle : in DDS.InstanceHandle_T) is abstract; -- <dref>DomainParticipant_ignore_topic</dref> procedure Ignore_Publication (Self : not null access Ref; Handle : in DDS.InstanceHandle_T) is abstract; -- <dref>DomainParticipant_ignore_publication</dref> procedure Ignore_Subscription (Self : not null access Ref; Handle : in DDS.InstanceHandle_T) is abstract; -- <dref>DomainParticipant_ignore_subscription</dref> function Get_Domain_Id (Self : not null access Ref) return DDS.DomainId_T is abstract; -- <dref>DomainParticipant_get_domain_id</dref> -- <dref>Shared_domain_id_description</dref> function Get_Factory (Self : not null access Ref) return not null access DDS.DomainParticipantFactory.Ref is abstract; procedure Assert_Liveliness (Self : not null access Ref) is abstract; -- <dref>DomainParticipant_assert_liveliness</dref> -- <dref>Shared_liveliness</dref> procedure Set_Default_DataReader_Qos (Self : not null access Ref; Qos : in DDS.DataReaderQoS) is abstract; -- <dref>DomainParticipant_set_default_datareader_qos</dref> -- <dref>Shared_set_default_datareader_qos</dref> procedure Set_Default_DataReader_Qos_With_Profile (Self : not null access Ref; libName : DDS.String; profName : DDS.String) is abstract; procedure Set_Default_DataReader_Qos_With_Profile (Self : not null access Ref; libName : Standard.String; profName : Standard.String) is abstract; -- <dref>DomainParticipant_set_default_datareader_qos_with_profile</dref> procedure Set_Default_DataWriter_Qos (Self : not null access Ref; Qos : in DDS.DataWriterQoS) is abstract; -- <dref>DomainParticipant_set_default_datawriter_qos</dref> -- <dref>Shared_set_default_datawriter_qos</dref> procedure Set_Default_DataWriter_Qos_With_Profile (Self : not null access Ref; libName : DDS.String; profName : DDS.String) is abstract; procedure Set_Default_DataWriter_Qos_With_Profile (Self : not null access Ref; libName : Standard.String; profName : Standard.String) is abstract; -- <dref>DomainParticipant_set_default_datawriter_qos_with_profile</dref> procedure Set_Default_Publisher_Qos (Self : not null access Ref; Qos : in DDS.PublisherQos) is abstract; -- <dref>DomainParticipant_set_default_publisher_qos</dref> -- <dref>Shared_set_default_publisher_qos</dref> procedure Set_Default_Publisher_Qos_With_Profile (Self : not null access Ref; libName : DDS.String; profName : DDS.String) is abstract; procedure Set_Default_Publisher_Qos_With_Profile (Self : not null access Ref; libName : Standard.String; profName : Standard.String) is abstract; -- <dref>DomainParticipant_set_default_publisher_qos_with_profile</dref> procedure Get_Default_Publisher_Qos (Self : not null access Ref; Qos : in out DDS.PublisherQos) is abstract; -- <dref>DomainParticipant_get_default_publisher_qos</dref> -- <dref>Shared_get_default_publisher_qos_mtsafety</dref> procedure Set_Default_Subscriber_Qos (Self : not null access Ref; Qos : in DDS.SubscriberQos) is abstract; -- <dref>DomainParticipant_set_default_subscriber_qos</dref> procedure Set_Default_Subscriber_Qos_With_Profile (Self : not null access Ref; libraryName : DDS.String; profileName : DDS.String) is abstract; procedure Set_Default_Subscriber_Qos_With_Profile (Self : not null access Ref; libraryName : Standard.String; profileName : Standard.String) is abstract; -- <dref>DomainParticipant_set_default_subscriber_qos_with_profile</dref> procedure Get_Default_Subscriber_Qos (Self : not null access Ref; Qos : in out DDS.SubscriberQos) is abstract; -- <dref>DomainParticipant_get_default_subscriber_qos</dref> procedure Get_Default_DataReader_Qos (Self : not null access Ref; Qos : in out DDS.DataReaderQoS) is abstract; -- <dref>DomainParticipant_get_default_datareader_qos</dref> -- <dref>Shared_get_default_datareader_qos_mtsafety</dref> procedure Get_Default_DataWriter_Qos (Self : not null access Ref; Qos : in out DDS.DataWriterQos) is abstract; -- <dref>DomainParticipant_get_default_datawriter_qos</dref> -- <dref>Shared_get_default_datawriter_qos_mtsafety</dref> procedure Set_Default_Topic_Qos (Self : not null access Ref; Qos : in DDS.TopicQos) is abstract; -- <dref>DomainParticipant_set_default_topic_qos</dref> -- <dref>Shared_set_default_topic_qos</dref> procedure Set_Default_Topic_Qos_With_Profile (Self : not null access Ref; libraryName : DDS.String; profileName : DDS.String) is abstract; procedure Set_Default_Topic_Qos_With_Profile (Self : not null access Ref; libraryName : Standard.String; profileName : Standard.String) is abstract; -- <dref>DomainParticipant_set_default_topic_qos_with_profile</dref> procedure Get_Default_Topic_Qos (Self : not null access Ref; Qos : in out DDS.TopicQos) is abstract; -- <dref>DomainParticipant_get_default_topic_qos</dref> -- <dref>Shared_get_default_topic_qos_mtsafety</dref> procedure Set_Default_Profile (Self : not null access Ref; library_name : DDS.String; profile_name : DDS.String) is abstract; -- <dref>DomainParticipant_set_default_profile</dref> procedure Set_Default_Library (Self : not null access Ref; library_name : DDS.String) is abstract; -- <dref>DomainParticipant_set_default_library</dref> function Get_Default_Library (Self : not null access Ref) return DDS.String is abstract; -- <dref>DomainParticipant_get_default_library</dref> function Get_Default_Profile (Self : not null access Ref) return DDS.String is abstract; -- <dref>DomainParticipant_get_default_profile</dref> function Get_Default_Profile_Library (Self : not null access Ref) return DDS.String is abstract; -- <dref>DomainParticipant_get_default_profile_library</dref> procedure Get_Default_Flowcontroller_Property (Self : not null access Ref; Property : in out DDS.FlowControllerProperty_T) is abstract; -- <dref>DomainParticipant_get_default_flowcontroller_property</dref> procedure Set_Default_Flowcontroller_Property (Self : not null access Ref; Property : in DDS.FlowControllerProperty_T) is abstract; -- <dref>DomainParticipant_set_default_flowcontroller_property</dref> function Get_Discovered_Participants (Self : access Ref) return DDS.InstanceHandle_Seq.Sequence is abstract; -- <dref>DomainParticipant_get_discovered_participants</dref> function Get_Discovered_Participant_Data (Self : not null access Ref; Participant_Handle : in DDS.InstanceHandle_T) return DDS.ParticipantBuiltinTopicData is abstract; -- <dref>DomainParticipant_get_discovered_participant_data</dref> function Get_Discovered_Topics (Self : access Ref) return DDS.InstanceHandle_Seq.Sequence is abstract; -- <dref>DomainParticipant_get_discovered_topics</dref> function Get_Discovered_Topic_Data (Self : not null access Ref; Topic_Handle : in DDS.InstanceHandle_T) return DDS.TopicBuiltinTopicData is abstract; -- <dref>DomainParticipant_get_discovered_topic_data</dref> function Contains_Entity (Self : not null access Ref; A_Handle : in DDS.InstanceHandle_T) return Boolean is abstract; -- <dref>DomainParticipant_contains_entity</dref> function Get_Current_Time (Self : not null access Ref) return DDS.Time_T is abstract; -- <dref>DomainParticipant_get_current_time</dref> procedure Add_Peer (Self : not null access Ref; peer_desc_string : DDS.String) is abstract; -- <dref>DomainParticipant_add_peer</dref> -- <dref>Shared_add_peer</dref> procedure Get_Publishers (Self : not null access Ref; publishers : access DDS.PublisherSeq.Sequence) is abstract; -- <dref>DomainParticipant_get_publishers</dref> procedure Get_Subscribers (Self : not null access Ref; subscribers : access DDS.SubscriberSeq.Sequence) is abstract; -- <dref>DomainParticipant_get_publishers</dref> end DDS.DomainParticipant;
package AdaCar.Motores is procedure Actua_Step(Motor: Tipo_Motor; Valor: Tipo_Step); procedure Actua_Direccion(Motor: Tipo_Motor; Valor: Tipo_Direccion); end AdaCar.Motores;
with Prime_Numbers, Ada.Text_IO; procedure Test_Semiprime is package Integer_Numbers is new Prime_Numbers (Natural, 0, 1, 2); use Integer_Numbers; begin for N in 1 .. 100 loop if Decompose(N)'Length = 2 then -- N is a semiprime; Ada.Text_IO.Put(Integer'Image(Integer(N))); end if; end loop; Ada.Text_IO.New_Line; for N in 1675 .. 1680 loop if Decompose(N)'Length = 2 then -- N is a semiprime; Ada.Text_IO.Put(Integer'Image(Integer(N))); end if; end loop; end Test_Semiprime;
----------------------------------------------------------------------- -- search-filters -- Search engine filters -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Finalization; with Search.Tokenizers; -- == Filters == -- Filters are used to make some text transformation on token strings produced by the lexer. -- They are chained together and the end of the chain gives the token string to the tokenizer. -- A filter can transform the string in lower case, another can compute the stem of the word -- and only return stems, another may filter and ignore some words. -- -- The `Filter_Chain` holds the chain of filters and each filter is added by using the -- `Add_Filter` procedure. package Search.Filters is type Filter_Type is abstract limited new Ada.Finalization.Limited_Controlled and Search.Tokenizers.Consumer_Type with private; type Filter_Type_Access is access all Filter_Type'Class; overriding procedure Push_Token (Chain : in out Filter_Type; Token : in String; Consumer : not null access procedure (Token : in String)); type Filter_Chain is new Filter_Type with private; procedure Add_Filter (Chain : in out Filter_Chain; Filter : in Filter_Type_Access); private type Filter_Type is abstract limited new Ada.Finalization.Limited_Controlled and Search.Tokenizers.Consumer_Type with record Next : Filter_Type_Access; end record; type Filter_Chain is new Filter_Type with null record; end Search.Filters;
With Ada.Streams, Ada.Strings.Less_Case_Insensitive, Ada.Strings.Equal_Case_Insensitive, Ada.Containers.Indefinite_Ordered_Maps; Package INI with Preelaborate, Elaborate_Body is Type Value_Type is ( vt_String, vt_Float, vt_Integer, vt_Boolean ); Type Instance(Convert : Boolean) is private; Function Exists( Object : in Instance; Key : in String; Section: in String:= "" ) return Boolean; -- Return the type of the associated value. Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return Value_Type with Pre => Exists(Object, Key, Section); -- Return the value associated with the key in the indicated section. Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return String with Pre => Exists(Object, Key, Section); Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return Float with Pre => Exists(Object, Key, Section); Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return Integer with Pre => Exists(Object, Key, Section); Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return Boolean with Pre => Exists(Object, Key, Section); -- Associates a value with the given key in the indicated section. Procedure Value( Object : in out Instance; Key : in String; Value : in String; Section: in String:= "" ) with Post => Exists(Object, Key, Section); Procedure Value( Object : in out Instance; Key : in String; Value : in Float; Section: in String:= "" ) with Post => Exists(Object, Key, Section); Procedure Value( Object : in out Instance; Key : in String; Value : in Integer; Section: in String:= "" ) with Post => Exists(Object, Key, Section); Procedure Value( Object : in out Instance; Key : in String; Value : in Boolean; Section: in String:= "" ) with Post => Exists(Object, Key, Section); -- This value sets the Convert discriminant for the object that is generated -- by the 'Input attribute. Default_Conversion : Boolean := False; Empty : Constant Instance; Private Type Value_Object( Kind : Value_Type; Length : Natural ) ; Function "ABS"( Object : Value_Object ) return String; Function "="(Left, Right : Value_Object) return Boolean; Package Object_Package is procedure Value_Output( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in Value_Object ) is null; function Value_Input( Stream : not null access Ada.Streams.Root_Stream_Type'Class ) return Value_Object; End Object_Package; Type Value_Object( Kind : Value_Type; Length : Natural ) is record case Kind is when vt_String => String_Value : String(1..Length):= (Others=>' '); when vt_Float => Float_Value : Float := 0.0; when vt_Integer => Integer_Value: Integer := 0; when vt_Boolean => Boolean_Value: Boolean := False; end case; end record; -- with Input => Object_Package.Value_Input, -- Output => Object_Package.Value_Output; Package KEY_VALUE_MAP is new Ada.Containers.Indefinite_Ordered_Maps( -- "=" => , "<" => Ada.Strings.Less_Case_Insensitive, Key_Type => String, Element_Type => Value_Object ); Function "="(Left, Right : KEY_VALUE_MAP.Map) return Boolean; Package KEY_SECTION_MAP is new Ada.Containers.Indefinite_Ordered_Maps( "=" => "=", "<" => Ada.Strings.Less_Case_Insensitive, Key_Type => String, Element_Type => KEY_VALUE_MAP.Map ); procedure INI_Output( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in Instance ); function INI_Input( Stream : not null access Ada.Streams.Root_Stream_Type'Class ) return Instance; Type Instance(Convert : Boolean) is new KEY_SECTION_MAP.Map with null record with Input => INI_Input, Output => INI_Output; overriding function Copy (Source : Instance) return Instance is ( Source ); Empty : Constant Instance:= (KEY_SECTION_MAP.map with Convert => True, others => <>); End INI;
package body Timeout is procedure Start (Timeout_Time : out Time ; Duration : Time_Span) is begin Timeout_Time := Clock + Duration; end Start; function Timed_Out (Timeout_Time : Time) return Boolean is begin return Clock > Timeout_Time; end Timed_Out; end Timeout;
package ZMQ.Examples is END_MESSAGE : constant String := "<END>"; end ZMQ.Examples;
with AAA.Strings; package Minirest is Rest_Error : exception; type Status_Kinds is (Informative, -- 1xx Success, -- 2xx Redirect, -- 3xx Client_Error, -- 4xx Server_Error); -- 5xx type Parameters is private; -- A collection of arguments of type key + value No_Arguments : constant Parameters; function "and" (L : Parameters; R : Parameters) return Parameters; function "=" (Key, Value : String) return Parameters; type Response (Status : Status_Kinds; Status_Length : Natural) is tagged record Status_Line : String (1 .. Status_Length); Status_Code : Positive range 100 .. 599; Raw_Headers : AAA.Strings.Vector; Headers : AAA.Strings.Map; Content : AAA.Strings.Vector; end record; function Succeeded (This : Response) return Boolean is (This.Status = Success); function Get (URL : String; Arguments : Parameters := No_Arguments; -- these are ?key=val Headers : Parameters := No_Arguments) -- these are Key: Val return Response; -- Use GET to retrieve URL; may raise Rest_Error for unexpected situations. -- Headers are passed via -H switch to curl. private type Parameters is record Data : AAA.Strings.Map; end record; No_Arguments : constant Parameters := (Data => AAA.Strings.Empty_Map); end Minirest;
-- Set up at present to test the compiler's Numerics.Discrete_Random. -- -- Warning: puts large array on stack. You get segmentation fault if stack -- space is insufficient. To get more stack space in bash shell, type: -- ulimit -s 1024M -- ulimit -s unlimited -- at the prompt. Type ulimit -a for summary of limits. -- In c shell type -- limit stacksize 1024M -- limit stacksize unlimited -- -- after 30738012 trials have 50% probability of 2 or more collisions (if -- using 48 bit uniformly distributed rands). with Chi_Gaussian_CDF; -- cumulative distribution functions for getting p_vals with Disorderly.Random; use Disorderly.Random; with Disorderly.Random.Clock_Entropy; with Text_IO; use Text_IO; with Ada.Numerics.Discrete_Random; with Sorted_Array; -- Test bday_tst_1 generates N random numbers (usually N = 2**25 + 2**24), -- and then counts how many of these random numbers occurred more than -- once in the set of N. -- -- Uses package Sorted_Array to sort the N random numbers. The sorted -- data is then inspected to find the number of rands that occurred -- more than once in the sample (collisions). The number of collisions -- should follow a poisson distribution, which is tested with a Chi-square -- goodness-of-fit test. This routine does not count the number of collisions -- in the spacings of the N random numbers (Marsaglia's birthday-spacings-test). -- -- You have a choice of 2 random num generators: -- -- Disorderly.Random or Ada.Numerics.Discrete_Random. -- procedure bday_tst_1 is -- Choose your Random Number Generator: Use_Compilers_Stnd_Generator : constant Boolean := True; -- IF False then use Disorderly.Random -- IF True then use Ada.Numerics.Discrete_Random Bits_per_Random_Word : constant := 48; -- can't change type Real is digits 15; package Chi_CDF is new Chi_Gaussian_CDF (Real); -- prob of no collisions (of an event of probability 2**(-48) = e) in n trials, -- (ie prob of no repeats of any of the 2**48 = 1/e possibilities): -- p(0) = 1*(1-e)*(1-2e)* ... *(1-(n-1)e) -- -- prob of exactly 1 collision: -- p(1) = (n(n+1)/2) * 1*e*(1-e)*(1-2e)* ... *(1-(n-2)e) -- = p(0) * (n(n+1)/2) * e * (1+(n-1)e) -- -- Poissonian p(k) = lambda^k exp(-lambda) / k! -- -- p(0) = exp(-lambda) -- p(1) = exp(-lambda)* lambda = p(0) * lambda -- -- say e = 2**(-48) and n = 2**25 -- -- so by the 1st Poissonian p(0) above: -- lambda = -log (1*(1-e)*(1-2e)* ... *(1-(n-1)e)) = 2.00000001987 -- by the 2nd Poissonian p(1) above: -- lambda = (n(n+1)/2) * e * (1+(n-1)e) = 2.000000298 -- -- Agree to 7 significant figures, so we'll assume poissonian statistics -- with lambda obtained as above. -- Min_Recorded_Cnt : constant := 2; -- counts 0..2 goto 1st bin Max_Recorded_Cnt : constant := 7; -- counts 7..inf goto last bin N : constant Parent_Random_Int := 2**25 + 2**24; -- When N = 2**25 + 2**24, collision counts of 0..2 go into 1st bin, -- and then counts of 7 and higher go into bin 6th bin. Max_Val_of_Random_Ints : constant Parent_Random_Int := 2**Bits_per_Random_Word-1; type Table_Index is mod 2**26; package Sorted_Table is new Sorted_Array (Item => Parent_Random_Int, Max_Size_of_Item => Max_Val_of_Random_Ints, Max_Allowed_No_of_Items => N, Table_Index => Table_Index); subtype Range_of_Recorded_Outcomes is Table_Index range Min_Recorded_Cnt..Max_Recorded_Cnt; type Birthday_Count_Statistics is array (Range_of_Recorded_Outcomes) of Real; Prob_of_k_Collisions : constant Birthday_Count_Statistics := ( 1.73578060853667E-01, 1.68717879896370E-01, 1.89807618654555E-01, 1.70826860183124E-01, 1.28120147682862E-01, 1.68949432729422E-01 ); True_Degrees_of_Freedom : constant := 5.0; -- Prob sums to 1.0. -- The following is stronger, (N=2**26) but requires a larger array. -- --N : constant := 2**26; -- When N = 2**26, collision counts of 0..4 go into 1st bin, -- and then counts of 12 and higher go into bin 9th bin. --Min_Recorded_Cnt : constant := 4; -- counts 0..4 goto 1st bin --Max_Recorded_Cnt : constant := 12; -- counts 12..inf goto last bin -- --Prob_of_k_Collisions : Birthday_Count_Statistics := -- ( -- 9.96323936620416E-02, 9.16036574975765E-02, 1.22138211816770E-01, -- 1.39586529870595E-01, 1.39586531950597E-01, 1.24076919138310E-01, -- 9.92615367897598E-02, 7.21902096500887E-02, 1.11924009624262E-01 -- ); -- --True_Degrees_of_Freedom : constant := 8.0; -- Prob sums to 1.0. Bday_Year_Length : constant := N; Sample_Size : constant := 1600; -- can use 1000 for N=2**26 case above. No_of_Chi_Tests : constant := 2**31-1; -- just keep doing chi tests Cnt : Table_Index; Observed_Count : Birthday_Count_Statistics := (others => 0.0); Expected_Count : Birthday_Count_Statistics := (others => 0.0); p_val : Real; Stream_1 : State; X : Random_Int; -------------------- -- Get_Random_Stnd - -------------------- -- Compiler's built in random number generator. -- GNAT compiler complains if you ask for more than 48 bits. type Unsigned_Stnd is mod 2**Bits_per_Random_Word; package rnd is new Ada.Numerics.Discrete_Random (Unsigned_Stnd); Stream_stnd : rnd.Generator; procedure Get_Random_Stnd(X : out Random_Int; S : in rnd.Generator) is begin X := Random_Int (rnd.Random (S)); end Get_Random_Stnd; pragma Inline (Get_Random_Stnd); begin -- Initialize states of the random number generators. -- Both generators use the clock to choose an initial seed. -- Call Reset only once; then repeat Test many times using Stream_1. rnd.Reset (Stream_stnd); Clock_Entropy.Reset (Stream_1); -- Use Probability to init Expection values: for k in Range_of_Recorded_Outcomes loop Expected_Count(k) := Real (Sample_Size) * Prob_of_k_Collisions(k); end loop; -- get p_val for each repetition of the chi test new_line; if Use_Compilers_Stnd_Generator then put ("Using Ada.Numerics.Discrete_Random to generate random numbers"); else put ("Using Disorderly.Random to generate random numbers"); end if; new_line; put ("Doing a Chi-squared Goodness-of-fit test with sample size ="); put (Integer'Image (Sample_Size)); new_line; put ("Usually takes several hours on a 64-bit PC."); new_line; for Chi_Test_id in 1 .. No_of_Chi_Tests loop Observed_Count := (others => 0.0); Fill_the_Bins: for Trial_id in 1 .. Sample_Size loop Sorted_Table.Initialize_Table_for_Restart; for i in 1 .. Bday_Year_Length loop if Use_Compilers_Stnd_Generator then Get_Random_Stnd (X, Stream_stnd); else Get_Random (X, Stream_1); end if; Sorted_Table.Insert_and_Sort (X mod 2**Bits_per_Random_Word); end loop; -- in i Cnt := Sorted_Table.No_of_Collisions_Detected; put (Table_Index'Image (Cnt)); if Cnt >= Max_Recorded_Cnt then Observed_Count(Max_Recorded_Cnt) := Observed_Count(Max_Recorded_Cnt) + 1.0; elsif Cnt <= Min_Recorded_Cnt then Observed_Count(Min_Recorded_Cnt) := Observed_Count(Min_Recorded_Cnt) + 1.0; else Observed_Count(Cnt) := Observed_Count(Cnt) + 1.0; end if; if not Sorted_Table.Array_Sort_Successful then put_line ("Failure in array sort. Should never happen."); return; end if; end loop Fill_the_Bins; -- Trial_id in 1 .. Sample_Size Get_Chi_p_val: declare chi, e, s, p : Real; begin chi := 0.0; for i in Range_of_Recorded_Outcomes loop e := Expected_Count(i); s := (Observed_Count(i) - e)**2 / e; chi := chi + s; end loop; p := chi_cdf . Chi_Squared_CDF (True_Degrees_of_Freedom, chi); p_val := p; end Get_Chi_p_val; new_line; put ("Chi-squared Goodness-of-fit test, number"); put (Integer'Image (Chi_Test_id)); put (" with sample size "); put (Integer'Image (Sample_Size)); new_line; put ("p-val (should be uniformly distributed in [0, 1) )"); new_line; put (Real'Image (p_val)); new_line; end loop; -- for Chi_Test_id in 1..No_of_Chi_Tests end;
------------------------------------------------------------------------------ -- -- -- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS -- -- -- -- I N T E R F A C E S . C . P O S I X _ E R R O R -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU Library General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. GNARL is distributed in the hope that it will be use- -- -- ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Gen- -- -- eral Library Public License for more details. You should have received -- -- a copy of the GNU Library General Public License along with GNARL; see -- -- file COPYING.LIB. If not, write to the Free Software Foundation, 675 -- -- Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This package contains those parts of the package POSIX defined in P1003.5 -- (Ada binding to POSIX.1) needed to interface to Pthreads. with Interfaces.C.System_Constants; use Interfaces.C.System_Constants; -- Used for, various constants use Interfaces.C; package Interfaces.C.POSIX_Error is type Return_Code is new int; Failure : constant Return_Code := -1; type Error_Code is new int; subtype EC is Error_Code; -- Synonym used only in this package function Get_Error_Code return Error_Code; pragma Import (C, Get_Error_Code, "get_errno"); -- An interface to the error number of the current thread. This is updated -- by Pthreads at each context switch. -- Error number definitions. These definitions are derived from -- /usr/include/errno.h and /usr/include/sys/errno.h. These are SunOS -- errors; they have not yet been checked fsor POSIX complience. -- Error number definitions. Operation_Not_Permitted : constant EC := EPERM; No_Such_File_Or_Directory : constant EC := ENOENT; No_Such_Process : constant EC := ESRCH; Interrupted_Operation : constant EC := EINTR; Input_Output_Error : constant EC := EIO; No_Such_Device_Or_Address : constant EC := ENXIO; Argument_List_Too_Long : constant EC := E2BIG; Exec_Format_Error : constant EC := ENOEXEC; Bad_File_Descriptor : constant EC := EBADF; No_Child_Process : constant EC := ECHILD; Resource_Temporarily_Unavailable : constant EC := EAGAIN; Not_Enough_Space : constant EC := ENOMEM; Permission_Denied : constant EC := EACCES; Resource_Busy : constant EC := EFAULT; File_Exists : constant EC := ENOTBLK; Improper_Link : constant EC := EBUSY; No_Such_Operation_On_Device : constant EC := EEXIST; Not_A_Directory : constant EC := EXDEV; Is_A_Directory : constant EC := ENODEV; Invalid_Argument : constant EC := ENOTDIR; Too_Many_Open_Files_In_System : constant EC := EISDIR; Too_Many_Open_Files : constant EC := EINVAL; Priority_Ceiling_Violation : constant EC := EINVAL; Inappropriate_IO_Control_Operation : constant EC := ENFILE; File_Too_Large : constant EC := EMFILE; No_Space_Left_On_Device : constant EC := ENOTTY; Invalid_Seek : constant EC := ETXTBSY; Read_Only_File_System : constant EC := EFBIG; Too_Many_Links : constant EC := ENOSPC; Broken_Pipe : constant EC := ESPIPE; Operation_Not_Implemented : constant EC := ENOSYS; Operation_Not_Supported : constant EC := ENOTSUP; end Interfaces.C.POSIX_Error;
with gel.Window.setup, gel.Applet.gui_world, gel.Forge, gel.Sprite, gel.World, gel.Camera, Physics, ada.Text_IO, ada.Exceptions; pragma unreferenced (gel.Window.setup); procedure launch_drop_Ball_on_Box -- -- Drops a ball onto a box 'terrain'. -- is use gel.Applet, gel.Applet.gui_world, Ada.Text_IO; the_Applet : gel.Applet.gui_world.view := gel.Forge.new_gui_Applet ("drop Ball on Box", space_Kind => physics.Bullet); function gui_World return gel.World.view is begin return the_Applet.World (gui_world_Id); end gui_World; function gui_Camera return gel.Camera.view is begin return the_Applet.Camera (gui_world_Id, gui_camera_Id); end gui_Camera; the_Ball : constant gel.Sprite.view := gel.Forge.new_ball_Sprite (gui_World); the_Box : constant gel.Sprite.view := gel.Forge.new_box_Sprite (gui_World, Mass => 0.0, Size => (20.0, 1.0, 20.0)); begin new_Line; put_Line ("Use arrow keys and PgUp/PgDn to move the camera."); new_Line; gui_Camera.Site_is ((0.0, 2.0, 20.0)); -- Position the camera. the_Applet.enable_simple_Dolly (in_World => gui_world_Id); -- Enable user camera control via keyboards. the_Ball.Site_is ((0.0, 10.0, 0.0)); gui_World.Gravity_is ((0.0, -9.8, 0.0)); gui_World.add (the_Ball); -- Add ball. gui_World.add (the_Box); -- Add box. while the_Applet.is_open loop the_Applet.freshen; -- Handle any new events and update the screen. end loop; free (the_Applet); exception when E : others => new_Line; put_Line ("Unhandled exception in main task ..."); put_Line (ada.Exceptions.exception_Information (E)); new_Line; end launch_drop_Ball_on_Box;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M -- -- -- -- S p e c -- -- (SUN Solaris Version) -- -- -- -- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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 System is pragma Pure; -- Note that we take advantage of the implementation permission to make -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada -- 2005, this is Pure in any case (AI-362). pragma No_Elaboration_Code_All; -- Allow the use of that restriction in units that WITH this unit type Name is (SYSTEM_NAME_GNAT); System_Name : constant Name := SYSTEM_NAME_GNAT; -- System-Dependent Named Numbers Min_Int : constant := Long_Long_Integer'First; Max_Int : constant := Long_Long_Integer'Last; Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size; Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1; Max_Base_Digits : constant := Long_Long_Float'Digits; Max_Digits : constant := Long_Long_Float'Digits; Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); Tick : constant := 0.01; -- Storage-related Declarations type Address is private; pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; Word_Size : constant := Standard'Word_Size; Memory_Size : constant := 2 ** Word_Size; -- Address comparison function "<" (Left, Right : Address) return Boolean; function "<=" (Left, Right : Address) return Boolean; function ">" (Left, Right : Address) return Boolean; function ">=" (Left, Right : Address) return Boolean; function "=" (Left, Right : Address) return Boolean; pragma Import (Intrinsic, "<"); pragma Import (Intrinsic, "<="); pragma Import (Intrinsic, ">"); pragma Import (Intrinsic, ">="); pragma Import (Intrinsic, "="); -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); Default_Bit_Order : constant Bit_Order := High_Order_First; pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning -- Priority-related Declarations (RM D.1) Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; subtype Any_Priority is Integer range 0 .. 31; subtype Priority is Any_Priority range 0 .. 30; subtype Interrupt_Priority is Any_Priority range 31 .. 31; Default_Priority : constant Priority := 15; private type Address is mod Memory_Size; Null_Address : constant Address := 0; -------------------------------------- -- System Implementation Parameters -- -------------------------------------- -- These parameters provide information about the target that is used -- by the compiler. They are in the private part of System, where they -- can be accessed using the special circuitry in the Targparm unit -- whose source should be consulted for more detailed descriptions -- of the individual switch values. Backend_Divide_Checks : constant Boolean := False; Backend_Overflow_Checks : constant Boolean := True; Command_Line_Args : constant Boolean := True; Configurable_Run_Time : constant Boolean := False; Denorm : constant Boolean := True; Duration_32_Bits : constant Boolean := False; Exit_Status_Supported : constant Boolean := True; Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Machine_Overflows : constant Boolean := False; Machine_Rounds : constant Boolean := True; Preallocated_Stacks : constant Boolean := False; Signed_Zeros : constant Boolean := True; Stack_Check_Default : constant Boolean := False; Stack_Check_Probes : constant Boolean := True; Stack_Check_Limits : constant Boolean := False; Support_Aggregates : constant Boolean := True; Support_Atomic_Primitives : constant Boolean := True; Support_Composite_Assign : constant Boolean := True; Support_Composite_Compare : constant Boolean := True; Support_Long_Shifts : constant Boolean := True; Always_Compatible_Rep : constant Boolean := False; Suppress_Standard_Library : constant Boolean := False; Use_Ada_Main_Program_Name : constant Boolean := False; Frontend_Exceptions : constant Boolean := False; ZCX_By_Default : constant Boolean := True; end System;
with Leds; use Leds; with Interfaces.EFM32; use Interfaces.EFM32; package body Leds is procedure Led_Init is begin CMU_Periph.CTRL.HFPERCLKEN := 1; CMU_Periph.HFBUSCLKEN0.GPIO := 1; GPIO_Periph.PA_MODEH.Arr(12) := PUSHPULL; GPIO_Periph.PA_MODEH.Arr(13) := PUSHPULL; GPIO_Periph.PA_MODEH.Arr(14) := PUSHPULL; GPIO_Periph.PD_MODEL.Arr(6) := PUSHPULL; GPIO_Periph.PF_MODEH.Arr(12) := PUSHPULL; GPIO_Periph.PE_MODEH.Arr(12) := PUSHPULL; Led_Set(LED0, Blue); Led_Set(LED1, Green); end Led_Init; procedure GPIO_Set_Pin(Port : Port_Type; Pin : Pin_Type) is begin case Port is when PA => GPIO_Periph.PA_DOUT.DOUT := GPIO_Periph.PA_DOUT.DOUT or Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PB => GPIO_Periph.PB_DOUT.DOUT := GPIO_Periph.PB_DOUT.DOUT or Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PC => GPIO_Periph.PC_DOUT.DOUT := GPIO_Periph.PC_DOUT.DOUT or Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PD => GPIO_Periph.PD_DOUT.DOUT := GPIO_Periph.PD_DOUT.DOUT or Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PE => GPIO_Periph.PE_DOUT.DOUT := GPIO_Periph.PE_DOUT.DOUT or Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PF => GPIO_Periph.PF_DOUT.DOUT := GPIO_Periph.PF_DOUT.DOUT or Shift_Left(16#0001#, Pin_Type'Pos(Pin)); end case; end GPIO_Set_Pin; procedure GPIO_Clr_Pin(Port : Port_Type; Pin : Pin_Type) is begin case Port is when PA => GPIO_Periph.PA_DOUT.DOUT := GPIO_Periph.PA_DOUT.DOUT and not Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PB => GPIO_Periph.PB_DOUT.DOUT := GPIO_Periph.PB_DOUT.DOUT and not Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PC => GPIO_Periph.PC_DOUT.DOUT := GPIO_Periph.PC_DOUT.DOUT and not Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PD => GPIO_Periph.PD_DOUT.DOUT := GPIO_Periph.PD_DOUT.DOUT and not Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PE => GPIO_Periph.PE_DOUT.DOUT := GPIO_Periph.PE_DOUT.DOUT and not Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PF => GPIO_Periph.PF_DOUT.DOUT := GPIO_Periph.PF_DOUT.DOUT and not Shift_Left(16#0001#, Pin_Type'Pos(Pin)); end case; end GPIO_Clr_Pin; Procedure GPIO_Tgl_Pin(Port : Port_Type; Pin : Pin_Type) is begin case Port is when PA => GPIO_Periph.PA_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PB => GPIO_Periph.PB_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PC => GPIO_Periph.PC_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PD => GPIO_Periph.PD_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PE => GPIO_Periph.PE_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin)); when PF => GPIO_Periph.PF_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin)); end case; end GPIO_Tgl_Pin; procedure Led_Set (LED : Led_No; Led_Color : Color) is begin case Led_Color is when Blue => case LED is when LED0 => GPIO_Set_Pin(PA, P12); GPIO_Set_Pin(PA, P14); GPIO_Clr_Pin(PA, P13); when LED1 => GPIO_Set_Pin(PD, P6); GPIO_Set_Pin(PF, P12); GPIO_Clr_Pin(PE, P12); end case; when Green => case LED is when LED0 => GPIO_Set_Pin(PA, P12); GPIO_Clr_Pin(PA, P14); GPIO_Set_Pin(PA, P13); when LED1 => GPIO_Set_Pin(PD, P6); GPIO_Clr_Pin(PF, P12); GPIO_Set_Pin(PE, P12); end case; when Cyan => case LED is when LED0 => GPIO_Set_Pin(PA, P12); GPIO_Clr_Pin(PA, P14); GPIO_Clr_Pin(PA, P13); when LED1 => GPIO_Set_Pin(PD, P6); GPIO_Clr_Pin(PF, P12); GPIO_Clr_Pin(PE, P12); end case; when Red => case LED is when LED0 => GPIO_Clr_Pin(PA, P12); GPIO_Set_Pin(PA, P14); GPIO_Set_Pin(PA, P13); when LED1 => GPIO_Clr_Pin(PD, P6); GPIO_Set_Pin(PF, P12); GPIO_Set_Pin(PE, P12); end case; when Magenta => case LED is when LED0 => GPIO_Clr_Pin(PA, P12); GPIO_Set_Pin(PA, P14); GPIO_Clr_Pin(PA, P13); when LED1 => GPIO_Clr_Pin(PD, P6); GPIO_Set_Pin(PF, P12); GPIO_Clr_Pin(PE, P12); end case; when Yellow => case LED is when LED0 => GPIO_Clr_Pin(PA, P12); GPIO_Clr_Pin(PA, P14); GPIO_Set_Pin(PA, P13); when LED1 => GPIO_Clr_Pin(PD, P6); GPIO_Clr_Pin(PF, P12); GPIO_Set_Pin(PE, P12); end case; when White => case LED is when LED0 => GPIO_Clr_Pin(PA, P12); GPIO_Clr_Pin(PA, P14); GPIO_Clr_Pin(PA, P13); when LED1 => GPIO_Clr_Pin(PD, P6); GPIO_Clr_Pin(PF, P12); GPIO_Clr_Pin(PE, P12); end case; when Black => case LED is when LED0 => GPIO_Set_Pin(PA, P12); GPIO_Set_Pin(PA, P14); GPIO_Set_Pin(PA, P13); when LED1 => GPIO_Set_Pin(PD, P6); GPIO_Set_Pin(PF, P12); GPIO_Set_Pin(PE, P12); end case; end case; end Led_Set; procedure Blink(LED: Led_No; Led_Color : Color) is Iterator : Integer := 0; begin Led_Set(LED, Led_Color); Iterator := 0; while Iterator < 200000 loop Iterator := Iterator + 1; end loop; Led_Set(LED, Black); Iterator := 0; while Iterator < 100000 loop Iterator := Iterator + 1; end loop; end Blink; end Leds;
with openGL.Context, openGL.Surface, openGL.Geometry, openGL.Model, openGL.Visual, openGL.Impostor, openGL.Texture, openGL.Font, openGL.Light; limited with openGL.Camera; private with ada.Containers.hashed_Maps, ada.unchecked_Conversion; package openGL.Renderer.lean -- -- Provides a rendering engine for the 'lean' GL profile. -- is type Item is limited new Renderer.item with private; type View is access all Item'Class; --------- --- Forge -- procedure define (Self : access Item); procedure destroy (Self : in out Item); procedure free (Self : in out View); -------------- --- Attributes -- function new_Light (Self : in out Item) return Light.item; procedure set (Self : in out Item; the_Light : in Light.item); procedure rid (Self : in out Item; the_Light : in Light.item); function Light (Self : in out Item; Id : in light.Id_t) return openGL.Light.item; function fetch (Self : in out Item) return openGL.Light.items; type context_Setter is access procedure; type Swapper is access procedure; procedure Context_is (Self : in out Item; Now : in Context.view); procedure Context_Setter_is (Self : in out Item; Now : in context_Setter); procedure Swapper_is (Self : in out Item; Now : in Swapper); -------------- -- Operations -- type impostor_Update is record Impostor : openGL.Impostor.view; current_Width_pixels : gl.GLsizei; current_Height_pixels : gl.GLsizei; current_copy_x_Offset : gl.GLsizei; current_copy_y_Offset : gl.GLsizei; current_copy_X : gl.GLsizei; current_copy_Y : gl.GLsizei; current_copy_Width : gl.GLsizei; current_copy_Height : gl.GLsizei; current_Camera_look_at_Rotation : Matrix_3x3; end record; type impostor_Updates is array (Positive range <>) of impostor_Update; procedure queue_Impostor_updates (Self : in out Item; the_Updates : in impostor_Updates; the_Camera : access Camera.item'Class); procedure queue_Visuals (Self : in out Item; the_Visuals : in Visual.views; the_Camera : access Camera.item'Class); procedure start_Engine (Self : in out Item); procedure stop_Engine (Self : in out Item); procedure render (Self : in out Item; to_Surface : in Surface.view := null); procedure add_Font (Self : in out Item; font_Id : in Font.font_Id); procedure Screenshot (Self : in out Item; Filename : in String; with_Alpha : in Boolean := False); function is_Busy (Self : in Item) return Boolean; procedure draw (Self : in out Item; the_Visuals : in Visual.views; camera_world_Transform : in Matrix_4x4; view_Transform : in Matrix_4x4; perspective_Transform : in Matrix_4x4; clear_Frame : in Boolean; to_Surface : in Surface.view := null); -- -- Raises buffer_Overflow if the renderer is unable to cope with the new 'draw'. procedure free (Self : in out Item; the_Model : in Model .view); procedure free (Self : in out Item; the_Impostor : in Impostor.view); buffer_Overflow : exception; Texture_not_found : exception; private type Camera_view is access all openGL.Camera.item'Class; max_Visuals : constant := 20_000; ---------- -- Updates -- type updates_for_Camera is record impostor_Updates : lean.impostor_Updates (1 .. max_Visuals); impostor_updates_Last : Natural := 0; Visuals : Visual.views (1 .. max_Visuals); visuals_Last : Natural := 0; end record; type Updates_for_Camera_view is access Updates_for_Camera; function Hash is new ada.unchecked_Conversion (Camera_view, ada.Containers.Hash_type); package camera_Maps_of_updates is new ada.Containers.Hashed_Maps (Camera_view, updates_for_Camera_view, Hash, "="); type camera_updates_Couple is record Camera : Camera_view; Updates : Updates_for_Camera_view; end record; type camera_updates_Couples is array (Positive range <>) of camera_updates_Couple; protected type safe_camera_Map_of_updates is procedure define; procedure destruct; procedure add (the_Updates : in impostor_Updates; the_Camera : in Camera_view); procedure add (the_Visuals : in Visual.views; the_Camera : in Camera_view); procedure fetch_all_Updates (the_Updates : out camera_updates_Couples; Length : out Natural); private Map_1 : aliased camera_Maps_of_updates.Map; Map_2 : aliased camera_Maps_of_updates.Map; current_Map : access camera_Maps_of_updates.Map; end safe_camera_Map_of_updates; -- visual_geometry_Couple -- type visual_geometry_Couple is record Visual : openGL.Visual .view; Geometry : openGL.Geometry.view; end record; type visual_geometry_Couples is array (math.Index range <>) of visual_geometry_Couple; type visual_geometry_Couples_view is access all visual_geometry_Couples; -- graphics_Models -- type graphics_Models is array (1 .. max_Visuals) of Model.view; protected type safe_Models is procedure add (the_Model : in Model.view); procedure fetch (the_Models : out graphics_Models; Count : out Natural); private my_Models : graphics_Models; my_Count : Natural := 0; end safe_Models; -- Impostors -- type Impostor_Set is array (1 .. max_Visuals) of Impostor.view; protected type safe_Impostors is procedure add (the_Impostor : in Impostor.view); procedure fetch (Impostors : out Impostor_Set; Count : out Natural); private the_Impostors : Impostor_Set; the_Count : Natural := 0; end safe_Impostors; ---------- --- Lights -- function Hash (Id : in openGL.light.Id_t) return ada.Containers.Hash_type; use type openGL.Light.Id_t, openGL.Light.item; package id_Maps_of_light is new ada.Containers.hashed_Maps (Key_type => openGL.light.Id_t, Element_type => openGL.Light.item, Hash => Hash, equivalent_Keys => "="); subtype id_Map_of_light is id_Maps_of_light.Map; protected type safe_Lights is procedure add (Light : in openGL.Light.item); procedure set (Light : in openGL.Light.item); procedure rid (Light : in openGL.Light.item); function get (Id : in openGL.light.Id_t) return openGL.Light.item; function fetch return openGL.Light.items; private the_Lights : id_Map_of_light; end safe_Lights; -- Engine -- task type Engine (Self : access Item'Class) is entry start (Context : in openGL.Context.view); entry Stop; entry render; entry add_Font (font_Id : in Font.font_Id); entry Screenshot (Filename : in String; with_Alpha : in Boolean := False); pragma Storage_Size (100_000_000); end Engine; -- Renderer -- type Item is limited new Renderer.item with record Lights : safe_Lights; prior_Light_Id : openGL.Light.Id_t := 0; Textures : aliased Texture.name_Map_of_texture; Fonts : Font.font_id_Map_of_font; all_opaque_Couples : visual_geometry_Couples_view := new visual_geometry_Couples (1 .. max_Visuals); all_lucid_Couples : visual_geometry_Couples_view := new visual_geometry_Couples (1 .. max_Visuals); obsolete_Models : safe_Models; obsolete_Impostors : safe_Impostors; texture_Pool : aliased Texture.Pool; safe_Camera_updates_Map : aliased safe_camera_Map_of_updates; Engine : lean.Engine (Self => Item'Access); Context : openGL.Context.view; context_Setter : lean.context_Setter; Swapper : lean.Swapper; swap_Required : Boolean; is_Busy : Boolean := False; end record; procedure update_Impostors_and_draw_Visuals (Self : in out Item; all_Updates : in camera_updates_Couples); procedure update_Impostors (Self : in out Item; the_Updates : in impostor_Updates; camera_world_Transform : in Matrix_4x4; view_Transform : in Matrix_4x4; perspective_Transform : in Matrix_4x4); procedure free_old_Models (Self : in out Item); procedure free_old_Impostors (Self : in out Item); end openGL.Renderer.lean;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ V F P T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1997-2005, 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 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. -- -- -- -- 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 Einfo; use Einfo; with Nlists; use Nlists; with Nmake; use Nmake; with Rtsfind; use Rtsfind; with Sem_Res; use Sem_Res; with Sinfo; use Sinfo; with Stand; use Stand; with Tbuild; use Tbuild; with Ttypef; use Ttypef; with Uintp; use Uintp; with Urealp; use Urealp; package body Exp_VFpt is ---------------------- -- Expand_Vax_Arith -- ---------------------- procedure Expand_Vax_Arith (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Base_Type (Etype (N)); Typc : Character; Atyp : Entity_Id; Func : RE_Id; Args : List_Id; begin -- Get arithmetic type, note that we do D stuff in G if Digits_Value (Typ) = VAXFF_Digits then Typc := 'F'; Atyp := RTE (RE_F); else Typc := 'G'; Atyp := RTE (RE_G); end if; case Nkind (N) is when N_Op_Abs => if Typc = 'F' then Func := RE_Abs_F; else Func := RE_Abs_G; end if; when N_Op_Add => if Typc = 'F' then Func := RE_Add_F; else Func := RE_Add_G; end if; when N_Op_Divide => if Typc = 'F' then Func := RE_Div_F; else Func := RE_Div_G; end if; when N_Op_Multiply => if Typc = 'F' then Func := RE_Mul_F; else Func := RE_Mul_G; end if; when N_Op_Minus => if Typc = 'F' then Func := RE_Neg_F; else Func := RE_Neg_G; end if; when N_Op_Subtract => if Typc = 'F' then Func := RE_Sub_F; else Func := RE_Sub_G; end if; when others => Func := RE_Null; raise Program_Error; end case; Args := New_List; if Nkind (N) in N_Binary_Op then Append_To (Args, Convert_To (Atyp, Left_Opnd (N))); end if; Append_To (Args, Convert_To (Atyp, Right_Opnd (N))); Rewrite (N, Convert_To (Typ, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (Func), Loc), Parameter_Associations => Args))); Analyze_And_Resolve (N, Typ, Suppress => All_Checks); end Expand_Vax_Arith; --------------------------- -- Expand_Vax_Comparison -- --------------------------- procedure Expand_Vax_Comparison (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Base_Type (Etype (Left_Opnd (N))); Typc : Character; Func : RE_Id; Atyp : Entity_Id; Revrs : Boolean := False; Args : List_Id; begin -- Get arithmetic type, note that we do D stuff in G if Digits_Value (Typ) = VAXFF_Digits then Typc := 'F'; Atyp := RTE (RE_F); else Typc := 'G'; Atyp := RTE (RE_G); end if; case Nkind (N) is when N_Op_Eq => if Typc = 'F' then Func := RE_Eq_F; else Func := RE_Eq_G; end if; when N_Op_Ge => if Typc = 'F' then Func := RE_Le_F; else Func := RE_Le_G; end if; Revrs := True; when N_Op_Gt => if Typc = 'F' then Func := RE_Lt_F; else Func := RE_Lt_G; end if; Revrs := True; when N_Op_Le => if Typc = 'F' then Func := RE_Le_F; else Func := RE_Le_G; end if; when N_Op_Lt => if Typc = 'F' then Func := RE_Lt_F; else Func := RE_Lt_G; end if; when N_Op_Ne => if Typc = 'F' then Func := RE_Ne_F; else Func := RE_Ne_G; end if; when others => Func := RE_Null; raise Program_Error; end case; if not Revrs then Args := New_List ( Convert_To (Atyp, Left_Opnd (N)), Convert_To (Atyp, Right_Opnd (N))); else Args := New_List ( Convert_To (Atyp, Right_Opnd (N)), Convert_To (Atyp, Left_Opnd (N))); end if; Rewrite (N, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (Func), Loc), Parameter_Associations => Args)); Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks); end Expand_Vax_Comparison; --------------------------- -- Expand_Vax_Conversion -- --------------------------- procedure Expand_Vax_Conversion (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Expr : constant Node_Id := Expression (N); S_Typ : constant Entity_Id := Base_Type (Etype (Expr)); T_Typ : constant Entity_Id := Base_Type (Etype (N)); CallS : RE_Id; CallT : RE_Id; Func : RE_Id; function Call_Type (T : Entity_Id; Otyp : Entity_Id) return RE_Id; -- Given one of the two types T, determines the coresponding call -- type, i.e. the type to be used for the call (or the result of -- the call). The actual operand is converted to (or from) this type. -- Otyp is the other type, which is useful in figuring out the result. -- The result returned is the RE_Id value for the type entity. function Equivalent_Integer_Type (T : Entity_Id) return Entity_Id; -- Find the predefined integer type that has the same size as the -- fixed-point type T, for use in fixed/float conversions. --------------- -- Call_Type -- --------------- function Call_Type (T : Entity_Id; Otyp : Entity_Id) return RE_Id is begin -- Vax float formats if Vax_Float (T) then if Digits_Value (T) = VAXFF_Digits then return RE_F; elsif Digits_Value (T) = VAXGF_Digits then return RE_G; -- For D_Float, leave it as D float if the other operand is -- G_Float, since this is the one conversion that is properly -- supported for D_Float, but otherwise, use G_Float. else pragma Assert (Digits_Value (T) = VAXDF_Digits); if Vax_Float (Otyp) and then Digits_Value (Otyp) = VAXGF_Digits then return RE_D; else return RE_G; end if; end if; -- For all discrete types, use 64-bit integer elsif Is_Discrete_Type (T) then return RE_Q; -- For all real types (other than Vax float format), we use the -- IEEE float-type which corresponds in length to the other type -- (which is Vax Float). else pragma Assert (Is_Real_Type (T)); if Digits_Value (Otyp) = VAXFF_Digits then return RE_S; else return RE_T; end if; end if; end Call_Type; ------------------------------------------------- -- Expand_Multiply_Fixed_By_Fixed_Giving_Fixed -- ------------------------------------------------- function Equivalent_Integer_Type (T : Entity_Id) return Entity_Id is begin if Esize (T) = Esize (Standard_Long_Long_Integer) then return Standard_Long_Long_Integer; elsif Esize (T) = Esize (Standard_Long_Integer) then return Standard_Long_Integer; else return Standard_Integer; end if; end Equivalent_Integer_Type; -- Start of processing for Expand_Vax_Conversion; begin -- If input and output are the same Vax type, we change the -- conversion to be an unchecked conversion and that's it. if Vax_Float (S_Typ) and then Vax_Float (T_Typ) and then Digits_Value (S_Typ) = Digits_Value (T_Typ) then Rewrite (N, Unchecked_Convert_To (T_Typ, Expr)); -- Case of conversion of fixed-point type to Vax_Float type elsif Is_Fixed_Point_Type (S_Typ) then -- If Conversion_OK set, then we introduce an intermediate IEEE -- target type since we are expecting the code generator to handle -- the case of integer to IEEE float. if Conversion_OK (N) then Rewrite (N, Convert_To (T_Typ, OK_Convert_To (Universal_Real, Expr))); -- Otherwise, convert the scaled integer value to the target type, -- and multiply by 'Small of type. else Rewrite (N, Make_Op_Multiply (Loc, Left_Opnd => Make_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (T_Typ, Loc), Expression => Unchecked_Convert_To ( Equivalent_Integer_Type (S_Typ), Expr)), Right_Opnd => Make_Real_Literal (Loc, Realval => Small_Value (S_Typ)))); end if; -- Case of conversion of Vax_Float type to fixed-point type elsif Is_Fixed_Point_Type (T_Typ) then -- If Conversion_OK set, then we introduce an intermediate IEEE -- target type, since we are expecting the code generator to handle -- the case of IEEE float to integer. if Conversion_OK (N) then Rewrite (N, OK_Convert_To (T_Typ, Convert_To (Universal_Real, Expr))); -- Otherwise, multiply value by 'small of type, and convert to the -- corresponding integer type. else Rewrite (N, Unchecked_Convert_To (T_Typ, Make_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (Equivalent_Integer_Type (T_Typ), Loc), Expression => Make_Op_Multiply (Loc, Left_Opnd => Expr, Right_Opnd => Make_Real_Literal (Loc, Realval => Ureal_1 / Small_Value (T_Typ)))))); end if; -- All other cases else -- Compute types for call CallS := Call_Type (S_Typ, T_Typ); CallT := Call_Type (T_Typ, S_Typ); -- Get function and its types if CallS = RE_D and then CallT = RE_G then Func := RE_D_To_G; elsif CallS = RE_G and then CallT = RE_D then Func := RE_G_To_D; elsif CallS = RE_G and then CallT = RE_F then Func := RE_G_To_F; elsif CallS = RE_F and then CallT = RE_G then Func := RE_F_To_G; elsif CallS = RE_F and then CallT = RE_S then Func := RE_F_To_S; elsif CallS = RE_S and then CallT = RE_F then Func := RE_S_To_F; elsif CallS = RE_G and then CallT = RE_T then Func := RE_G_To_T; elsif CallS = RE_T and then CallT = RE_G then Func := RE_T_To_G; elsif CallS = RE_F and then CallT = RE_Q then Func := RE_F_To_Q; elsif CallS = RE_Q and then CallT = RE_F then Func := RE_Q_To_F; elsif CallS = RE_G and then CallT = RE_Q then Func := RE_G_To_Q; else pragma Assert (CallS = RE_Q and then CallT = RE_G); Func := RE_Q_To_G; end if; Rewrite (N, Convert_To (T_Typ, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (Func), Loc), Parameter_Associations => New_List ( Convert_To (RTE (CallS), Expr))))); end if; Analyze_And_Resolve (N, T_Typ, Suppress => All_Checks); end Expand_Vax_Conversion; ----------------------------- -- Expand_Vax_Real_Literal -- ----------------------------- procedure Expand_Vax_Real_Literal (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Btyp : constant Entity_Id := Base_Type (Typ); Stat : constant Boolean := Is_Static_Expression (N); Nod : Node_Id; RE_Source : RE_Id; RE_Target : RE_Id; RE_Fncall : RE_Id; -- Entities for source, target and function call in conversion begin -- We do not know how to convert Vax format real literals, so what -- we do is to convert these to be IEEE literals, and introduce the -- necessary conversion operation. if Vax_Float (Btyp) then -- What we want to construct here is -- x!(y_to_z (1.0E0)) -- where -- x is the base type of the literal (Btyp) -- y_to_z is -- s_to_f for F_Float -- t_to_g for G_Float -- t_to_d for D_Float -- The literal is typed as S (for F_Float) or T otherwise -- We do all our own construction, analysis, and expansion here, -- since things are at too low a level to use Analyze or Expand -- to get this built (we get circularities and other strange -- problems if we try!) if Digits_Value (Btyp) = VAXFF_Digits then RE_Source := RE_S; RE_Target := RE_F; RE_Fncall := RE_S_To_F; elsif Digits_Value (Btyp) = VAXDF_Digits then RE_Source := RE_T; RE_Target := RE_D; RE_Fncall := RE_T_To_D; else pragma Assert (Digits_Value (Btyp) = VAXGF_Digits); RE_Source := RE_T; RE_Target := RE_G; RE_Fncall := RE_T_To_G; end if; Nod := Relocate_Node (N); Set_Etype (Nod, RTE (RE_Source)); Set_Analyzed (Nod, True); Nod := Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Fncall), Loc), Parameter_Associations => New_List (Nod)); Set_Etype (Nod, RTE (RE_Target)); Set_Analyzed (Nod, True); Nod := Make_Unchecked_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (Typ, Loc), Expression => Nod); Set_Etype (Nod, Typ); Set_Analyzed (Nod, True); Rewrite (N, Nod); -- This odd expression is still a static expression. Note that -- the routine Sem_Eval.Expr_Value_R understands this. Set_Is_Static_Expression (N, Stat); end if; end Expand_Vax_Real_Literal; ---------------------- -- Expand_Vax_Valid -- ---------------------- procedure Expand_Vax_Valid (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Pref : constant Node_Id := Prefix (N); Ptyp : constant Entity_Id := Root_Type (Etype (Pref)); Rtyp : constant Entity_Id := Etype (N); Vtyp : RE_Id; Func : RE_Id; begin if Digits_Value (Ptyp) = VAXFF_Digits then Func := RE_Valid_F; Vtyp := RE_F; elsif Digits_Value (Ptyp) = VAXDF_Digits then Func := RE_Valid_D; Vtyp := RE_D; else pragma Assert (Digits_Value (Ptyp) = VAXGF_Digits); Func := RE_Valid_G; Vtyp := RE_G; end if; Rewrite (N, Convert_To (Rtyp, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (Func), Loc), Parameter_Associations => New_List ( Convert_To (RTE (Vtyp), Pref))))); Analyze_And_Resolve (N); end Expand_Vax_Valid; end Exp_VFpt;
-- { dg-do compile } package body prefix2 is procedure Positionne (Objet : in out Instance; X, Y : Coordonnee) is begin Objet.X := X; Objet.Y := Y; end Positionne; function RetourneX (Objet : in Instance) return Coordonnee is begin return Objet.X; end RetourneX; function RetourneY (Objet : in Instance) return Coordonnee is begin return Objet.Y; end RetourneY; procedure Affiche (Objet : in Class; EstVisible : Boolean) is begin if EstVisible then Objet.Allume; else Objet.Eteins; end if; end Affiche; procedure Deplace (Objet : in out Class; DX, DY : Coordonnee) is begin Objet.Affiche (False); -- erreur Objet.Positionne (Objet.X + DX, Objet.Y + DY); Objet.Affiche (True); -- erreur end Deplace; end prefix2;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Assertions; with GNAT.Exception_Actions; with Ada.Exceptions; procedure Fuzzing_Example is Input : Unbounded_String; Fd : File_Type; Filename : aliased String := Ada.Command_Line.Argument(1); procedure Check_Secret (Password : Unbounded_String) is Fuzz : Unbounded_String; Zero : Integer := 0; One : Integer := 1; Answer : Integer := 0; begin Fuzz := To_Unbounded_String("fuzz"); if Fuzz = Input then Put_Line ("Fuzz Found!"); -- raise Ada.Assertions.Assertion_Error; also works. Answer := One / Zero; else Put_Line ("Not Found!"); end if; end Check_Secret; begin Open (File => Fd, Mode => In_File, Name => Filename); Input := To_Unbounded_String(Get_Line (FD)); Check_Secret(Input); exception when Occurence : others => GNAT.Exception_Actions.Core_Dump (Occurence); end Fuzzing_Example;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Elements.Declarations; with Program.Lexical_Elements; with Program.Elements.Defining_Names; with Program.Elements.Parameter_Specifications; with Program.Elements.Expressions; with Program.Elements.Aspect_Specifications; package Program.Elements.Procedure_Renaming_Declarations is pragma Pure (Program.Elements.Procedure_Renaming_Declarations); type Procedure_Renaming_Declaration is limited interface and Program.Elements.Declarations.Declaration; type Procedure_Renaming_Declaration_Access is access all Procedure_Renaming_Declaration'Class with Storage_Size => 0; not overriding function Name (Self : Procedure_Renaming_Declaration) return not null Program.Elements.Defining_Names.Defining_Name_Access is abstract; not overriding function Parameters (Self : Procedure_Renaming_Declaration) return Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access is abstract; not overriding function Renamed_Procedure (Self : Procedure_Renaming_Declaration) return Program.Elements.Expressions.Expression_Access is abstract; not overriding function Aspects (Self : Procedure_Renaming_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access is abstract; not overriding function Has_Not (Self : Procedure_Renaming_Declaration) return Boolean is abstract; not overriding function Has_Overriding (Self : Procedure_Renaming_Declaration) return Boolean is abstract; type Procedure_Renaming_Declaration_Text is limited interface; type Procedure_Renaming_Declaration_Text_Access is access all Procedure_Renaming_Declaration_Text'Class with Storage_Size => 0; not overriding function To_Procedure_Renaming_Declaration_Text (Self : in out Procedure_Renaming_Declaration) return Procedure_Renaming_Declaration_Text_Access is abstract; not overriding function Not_Token (Self : Procedure_Renaming_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Overriding_Token (Self : Procedure_Renaming_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Procedure_Token (Self : Procedure_Renaming_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Left_Bracket_Token (Self : Procedure_Renaming_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Right_Bracket_Token (Self : Procedure_Renaming_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Renames_Token (Self : Procedure_Renaming_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function With_Token (Self : Procedure_Renaming_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Semicolon_Token (Self : Procedure_Renaming_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Procedure_Renaming_Declarations;
with Courbes; use Courbes; package Courbes.Singletons is use Liste_Points; type Singleton is new Courbe with private; -- Crée un singleton function Ctor_Singleton (P : Point2D) return Singleton; overriding procedure Accepter (Self : Singleton; Visiteur : Courbes.Visiteurs.Visiteur_Courbe'Class); -- Obtient un point d'un singleton overriding function Obtenir_Point(Self : Singleton; X : Coordonnee_Normalisee) return Point2D; private type Singleton is new Courbe with null record; end Courbes.Singletons;
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ package body Natools.References.Pools is ------------------------ -- Helper Subprograms -- ------------------------ overriding procedure Finalize (Object : in out Pool_Backend) is begin Unchecked_Free (Object.Refs); end Finalize; procedure Find (Container : in Pool_Backend; First_Available : out Extended_Index; First_Empty : out Extended_Index) is begin First_Available := 0; First_Empty := 0; if Container.Refs = null then return; end if; for I in Container.Refs'Range loop if Container.Refs (I).Is_Empty then if First_Empty = 0 then First_Empty := I; exit when First_Available /= 0; end if; elsif Container.Refs (I).Is_Last then if First_Available = 0 then First_Available := I; exit when First_Empty /= 0; end if; end if; end loop; end Find; not overriding procedure Preallocate (Container : in out Pool_Backend; New_Item_Count : in Pool_Size; Constructor : access function return Held_Data := null) is begin if New_Item_Count = 0 then return; end if; if Container.Refs = null then Container.Refs := new Reference_Array (1 .. New_Item_Count); if Constructor /= null then for I in Container.Refs'Range loop Container.Refs (I) := Create (Constructor); end loop; end if; else declare New_Data : Reference_Array_Access := new Reference_Array (1 .. Container.Refs'Length + New_Item_Count); begin New_Data (1 .. Container.Refs'Length) := Container.Refs.all; if Constructor /= null then for I in Container.Refs'Length + 1 .. New_Data'Last loop New_Data (I) := Create (Constructor); end loop; end if; Unchecked_Free (Container.Refs); Container.Refs := New_Data; exception when others => Unchecked_Free (New_Data); raise; end; end if; end Preallocate; ---------------------------------- -- Public Protected Subprograms -- ---------------------------------- protected body Pool is procedure Get (Ref : out Reference) is First_Available, First_Empty : Extended_Index; begin Backend.Find (First_Available, First_Empty); if First_Available in Reference_Index then Ref := Backend.Refs (First_Available); else raise Constraint_Error with "No non-empty unused reference in pool"; end if; end Get; procedure Get (Constructor : not null access function return Held_Data; Ref : out Reference) is First_Available, First_Empty : Extended_Index; begin Backend.Find (First_Available, First_Empty); if First_Available in Reference_Index then Ref := Backend.Refs (First_Available); elsif First_Empty in Reference_Index then Backend.Refs (First_Empty) := Create (Constructor); Ref := Backend.Refs (First_Empty); else raise Constraint_Error with "No unused reference in pool"; end if; end Get; procedure Create (Constructor : not null access function return Held_Data; Ref : out Reference; Expand_Count : in Pool_Size := 1) is First_Available, First_Empty : Extended_Index; begin Backend.Find (First_Available, First_Empty); if First_Available in Reference_Index then Ref := Backend.Refs (First_Available); elsif First_Empty in Reference_Index then Backend.Refs (First_Empty) := Create (Constructor); Ref := Backend.Refs (First_Empty); else First_Available := Backend.Length + 1; Backend.Preallocate (Expand_Count, Constructor); Ref := Backend.Refs (First_Available); end if; end Create; procedure Preallocate (New_Item_Count : in Pool_Size; Constructor : access function return Held_Data := null) is begin Backend.Preallocate (New_Item_Count, Constructor); end Preallocate; procedure Release_Unused is begin if Backend.Refs = null then return; end if; for I in Backend.Refs'Range loop if not Backend.Refs (I).Is_Empty and then Backend.Refs (I).Is_Last then Backend.Refs (I).Reset; end if; end loop; end Release_Unused; procedure Trim is Index : Extended_Index := 0; New_Count : constant Pool_Size := Initialized_Size; New_Data : Reference_Array_Access := null; begin if New_Count = Backend.Length then return; end if; New_Data := new Reference_Array (1 .. New_Count); for I in Backend.Refs'Range loop if not Backend.Refs (I).Is_Empty then Index := Index + 1; New_Data (Index) := Backend.Refs (I); end if; end loop; pragma Assert (Index = New_Count); Unchecked_Free (Backend.Refs); Backend.Refs := New_Data; exception when others => Unchecked_Free (New_Data); raise; end Trim; procedure Purge is begin Release_Unused; Trim; end Purge; function Capacity return Pool_Size is begin return Backend.Length; end Capacity; function Initialized_Size return Pool_Size is Result : Pool_Size := 0; begin if Backend.Refs /= null then for I in Backend.Refs'Range loop if not Backend.Refs (I).Is_Empty then Result := Result + 1; end if; end loop; end if; return Result; end Initialized_Size; function Active_Size return Pool_Size is Result : Pool_Size := 0; begin if Backend.Refs /= null then for I in Backend.Refs'Range loop if not Backend.Refs (I).Is_Empty and then not Backend.Refs (I).Is_Last then Result := Result + 1; end if; end loop; end if; return Result; end Active_Size; procedure Unchecked_Iterate (Process : not null access procedure (Ref : in Reference)) is begin for I in Backend.Refs'Range loop Process.all (Backend.Refs (I)); end loop; end Unchecked_Iterate; end Pool; end Natools.References.Pools;
package body Ada.Numerics.Float_Random is function Random (Gen : Generator) return Uniformly_Distributed is begin return Float (MT19937.Random_0_To_1 (Gen'Unrestricted_Access.all)); end Random; end Ada.Numerics.Float_Random;
with Lnko; package body Racionalisok is function Szamlalo ( R: Racionalis ) return Integer is begin return R.Szamlalo; end; function Nevezo ( R: Racionalis ) return Positive is begin return R.Nevezo; end; function Normalizalva ( Szamlalo: Integer; Nevezo: Positive ) return Racionalis is begin if Szamlalo = 0 then return (0,1); else declare H: Positive := Lnko( abs Szamlalo, Nevezo ); begin return (Szamlalo/H, Nevezo/H); end; end if; end; function "/" ( Szamlalo: Integer; Nevezo: Positive ) return Racionalis is begin return Normalizalva( Szamlalo, Nevezo ); end; function "/" ( X, Y: Racionalis ) return Racionalis is begin return Normalizalva( X.Szamlalo * Y.Nevezo, X.Nevezo * Y.Szamlalo ); end; function "/" ( X: Racionalis; Y: Positive ) return Racionalis is begin return Normalizalva( X.Szamlalo, X.Nevezo * Y ); end; function "+" ( Szamlalo: Integer; Nevezo: Positive ) return Racionalis is begin return Normalizalva(Szamlalo + Nevezo, 1); end; function "+" ( X, Y: Racionalis ) return Racionalis is begin return Normalizalva(X.Szamlalo * Y.Nevezo + X.Nevezo * Y.Szamlalo, X.Nevezo * Y.Nevezo); end; function "+" ( X: Racionalis; Y: Positive ) return Racionalis is begin return Normalizalva(X.Szamlalo + X.Nevezo * Y, X.Nevezo); end; function "*" ( Szamlalo: Integer; Nevezo: Positive ) return Racionalis is begin return Normalizalva(Szamlalo * Nevezo, 1); end; function "*" ( X, Y: Racionalis ) return Racionalis is begin return Normalizalva(X.Szamlalo * Y.Szamlalo, X.Nevezo * Y.Nevezo); end; function "*" ( X: Racionalis; Y: Positive ) return Racionalis is begin return Normalizalva(X.Szamlalo * Y, X.Nevezo); end; -- function "=" ( X, Y: Racionalis ) return Boolean is -- begin -- return X.Szamlalo * Y.Nevezo = Y.Szamlalo * X.Nevezo; -- end; end Racionalisok;
pragma License (Unrestricted); package Ada.Calendar.Time_Zones is -- Time zone manipulation: type Time_Offset is range -28 * 60 .. 28 * 60; Unknown_Zone_Error : exception; function UTC_Time_Offset (Date : Time := Clock) return Time_Offset; pragma Pure_Function (UTC_Time_Offset); pragma Inline (UTC_Time_Offset); end Ada.Calendar.Time_Zones;
-- protected_refcounted_kvflyweights.ads -- A package for ensuring resources are not duplicated in a manner similar -- to the C++ Boost flyweight classes. This package provides a task-safe -- implementation that uses reference counting to release resources when the -- last reference is released. Resources are associated with a key that can -- be used to create them if they have not already been created. -- Copyright (c) 2016, James Humphry -- -- 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. pragma Profile (No_Implementation_Extensions); with Ada.Containers; with KVFlyweights.Refcounted_Lists; with KVFlyweights.Protected_Hashtables; with KVFlyweights.Refcounted_Ptrs; generic type Key(<>) is private; type Value(<>) is limited private; type Value_Access is access Value; with function Factory (K : in Key) return Value_Access; with function Hash (K : in Key) return Ada.Containers.Hash_Type; Capacity : Ada.Containers.Hash_Type := 256; with function "=" (Left, Right : in Key) return Boolean is <>; package Protected_Refcounted_KVFlyweights is type Key_Access is access Key; package Lists is new KVFlyweights.Refcounted_Lists(Key => Key, Key_Access => Key_Access, Value => Value, Value_Access => Value_Access, Factory => Factory, "=" => "="); package Hashtables is new KVFlyweights.Protected_Hashtables(Key => Key, Key_Access => Key_Access, Value => Value, Value_Access => Value_Access, Hash => Hash, KVLists_Spec => Lists.Lists_Spec, Capacity => Capacity); package Ptrs is new KVFlyweights.Refcounted_Ptrs(Key => Key, Key_Access => Key_Access, Value => Value, Value_Access => Value_Access, KVFlyweight_Hashtables => Hashtables.Hashtables_Spec); subtype KVFlyweight is Hashtables.KVFlyweight; -- This KVFlyweight type is an implementation of the key-value flyweight -- pattern, which helps prevent the resource usage caused by the storage of -- duplicate values. Reference counting is used to release resources when -- they are no longer required. This implementation is protected so it -- is safe to use even if multiple tasks could attempt to add or remove -- resources simultaneously. subtype V_Ref is Ptrs.V_Ref; -- This is a generic generalised reference type which is used to make -- Value_Ptr easier to use and which should not be stored or reused. subtype Value_Ptr is Ptrs.Refcounted_Value_Ptr; -- The Value_Ptr type points to a resource inside a Flyweight. It is -- reference-counted (shared with Value_Ref) so that when the last Value_Ptr -- or Value_Ref pointing to a resource is destroyed, the resource will be -- deallocated as well. The 'Get' function returns an access value to the -- resource. use type Ptrs.Refcounted_Value_Ptr; subtype Value_Ref is Ptrs.Refcounted_Value_Ref; -- The Value_Ref type points to a resource inside a Flyweight. It is -- reference-counted (shared with Value_Ptr) so that when the last Value_Ptr -- or Value_Ref pointing to a resource is destroyed, the resource will be -- deallocated as well. The Value_Ref type can be implicitly derefenced to -- return the resource. use type Ptrs.Refcounted_Value_Ref; function P (P : Ptrs.Refcounted_Value_Ptr) return V_Ref renames Ptrs.P; -- P returns an V_Ref which is a generalised reference to the stored value. -- This is an alternative to calling the Get function and dereferencing the -- access value returned with '.all'. function Get (P : Ptrs.Refcounted_Value_Ptr) return Value_Access renames Ptrs.Get; -- Get returns an access value that points to a resource inside a Flyweight. function Get (P : Ptrs.Refcounted_Value_Ref) return Value_Access renames Ptrs.Get; -- Get returns an access value that points to a resource inside a Flyweight. function Make_Ref (P : Ptrs.Refcounted_Value_Ptr'Class) return Ptrs.Refcounted_Value_Ref renames Ptrs.Make_Ref; -- Make_Ref converts a Refcounted_Value_Ptr into a Refcounted_Value_Ref. function Insert_Ptr (F : aliased in out Hashtables.KVFlyweight; K : in Key) return Ptrs.Refcounted_Value_Ptr renames Ptrs.Insert_Ptr; -- Insert_Ref looks to see if the Key K already exists inside the KVFlyweight -- F. If not, F makes a new value from K using the specified Factory function -- and stores it for future use. A Refcounted_Value_Ptr is returned. function Make_Ptr (R : Ptrs.Refcounted_Value_Ref'Class) return Ptrs.Refcounted_Value_Ptr renames Ptrs.Make_Ptr; -- Make_Ref converts a Refcounted_Value_Ref into a Refcounted_Value_Ptr. function Insert_Ref (F : aliased in out Hashtables.KVFlyweight; K : in Key) return Ptrs.Refcounted_Value_Ref renames Ptrs.Insert_Ref; -- Insert_Ref looks to see if the Key K already exists inside the KVFlyweight -- F. If not, F makes a new value from K using the specified Factory function -- and stores it for future use. A Refcounted_Value_Ref is returned. -- Note - ideally Insert_Ptr and Insert_Ref could both be overloadings of -- Insert. However this seems to cause problems for GNAT GPL 2015 so for now -- the type is suffixed to the name. end Protected_Refcounted_KVFlyweights;