CombinedText
stringlengths
4
3.42M
-- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. -- -- SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from rp2040.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; -- DW_apb_ssi has the following features:\n -- * APB interface – Allows for easy integration into a DesignWare -- Synthesizable Components for AMBA 2 implementation.\n -- * APB3 and APB4 protocol support.\n -- * Scalable APB data bus width – Supports APB data bus widths of -- 8, 16, and 32 bits.\n -- * Serial-master or serial-slave operation – Enables serial -- communication with serial-master or serial-slave peripheral devices.\n -- * Programmable Dual/Quad/Octal SPI support in Master Mode.\n -- * Dual Data Rate (DDR) and Read Data Strobe (RDS) Support - Enables -- the DW_apb_ssi master to perform operations with the device in DDR and RDS -- modes when working in Dual/Quad/Octal mode of operation.\n -- * Data Mask Support - Enables the DW_apb_ssi to selectively update -- the bytes in the device. This feature is applicable only in enhanced SPI -- modes.\n -- * eXecute-In-Place (XIP) support - Enables the DW_apb_ssi master to -- behave as a memory mapped I/O and fetches the data from the device based on -- the APB read request. This feature is applicable only in enhanced SPI -- modes.\n -- * DMA Controller Interface – Enables the DW_apb_ssi to interface -- to a DMA controller over the bus using a handshaking interface for transfer -- requests.\n -- * Independent masking of interrupts – Master collision, transmit -- FIFO overflow, transmit FIFO empty, receive FIFO full, receive FIFO -- underflow, and receive FIFO overflow interrupts can all be masked -- independently.\n -- * Multi-master contention detection – Informs the processor of -- multiple serial-master accesses on the serial bus.\n -- * Bypass of meta-stability flip-flops for synchronous clocks – -- When the APB clock (pclk) and the DW_apb_ssi serial clock (ssi_clk) are -- synchronous, meta-stable flip-flops are not used when transferring control -- signals across these clock domains.\n -- * Programmable delay on the sample time of the received serial data -- bit (rxd); enables programmable control of routing delays resulting in -- higher serial data-bit rates.\n -- * Programmable features:\n -- - Serial interface operation – Choice of Motorola SPI, Texas -- Instruments Synchronous Serial Protocol or National Semiconductor -- Microwire.\n -- - Clock bit-rate – Dynamic control of the serial bit rate of the -- data transfer; used in only serial-master mode of operation.\n -- - Data Item size (4 to 32 bits) – Item size of each data transfer -- under the control of the programmer.\n -- * Configured features:\n -- - FIFO depth – 16 words deep. The FIFO width is fixed at 32 -- bits.\n -- - 1 slave select output.\n -- - Hardware slave-select – Dedicated hardware slave-select line.\n -- - Combined interrupt line - one combined interrupt line from the -- DW_apb_ssi to the interrupt controller.\n -- - Interrupt polarity – active high interrupt lines.\n -- - Serial clock polarity – low serial-clock polarity directly -- after reset.\n -- - Serial clock phase – capture on first edge of serial-clock -- directly after reset. package RP_SVD.XIP_SSI is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CTRLR0_DFS_Field is HAL.UInt4; subtype CTRLR0_FRF_Field is HAL.UInt2; -- Transfer mode type CTRLR0_TMOD_Field is (-- Both transmit and receive Tx_And_Rx, -- Transmit only (not for FRF == 0, standard SPI mode) Tx_Only, -- Receive only (not for FRF == 0, standard SPI mode) Rx_Only, -- EEPROM read mode (TX then RX; RX starts after control data TX'd) Eeprom_Read) with Size => 2; for CTRLR0_TMOD_Field use (Tx_And_Rx => 0, Tx_Only => 1, Rx_Only => 2, Eeprom_Read => 3); subtype CTRLR0_CFS_Field is HAL.UInt4; subtype CTRLR0_DFS_32_Field is HAL.UInt5; -- SPI frame format type CTRLR0_SPI_FRF_Field is (-- Standard 1-bit SPI frame format; 1 bit per SCK, full-duplex Std, -- Dual-SPI frame format; two bits per SCK, half-duplex Dual, -- Quad-SPI frame format; four bits per SCK, half-duplex Quad) with Size => 2; for CTRLR0_SPI_FRF_Field use (Std => 0, Dual => 1, Quad => 2); -- Control register 0 type CTRLR0_Register is record -- Data frame size DFS : CTRLR0_DFS_Field := 16#0#; -- Frame format FRF : CTRLR0_FRF_Field := 16#0#; -- Serial clock phase SCPH : Boolean := False; -- Serial clock polarity SCPOL : Boolean := False; -- Transfer mode TMOD : CTRLR0_TMOD_Field := RP_SVD.XIP_SSI.Tx_And_Rx; -- Slave output enable SLV_OE : Boolean := False; -- Shift register loop (test mode) SRL : Boolean := False; -- Control frame size\n Value of n -> n+1 clocks per frame. CFS : CTRLR0_CFS_Field := 16#0#; -- Data frame size in 32b transfer mode\n Value of n -> n+1 clocks per -- frame. DFS_32 : CTRLR0_DFS_32_Field := 16#0#; -- SPI frame format SPI_FRF : CTRLR0_SPI_FRF_Field := RP_SVD.XIP_SSI.Std; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Slave select toggle enable SSTE : Boolean := False; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CTRLR0_Register use record DFS at 0 range 0 .. 3; FRF at 0 range 4 .. 5; SCPH at 0 range 6 .. 6; SCPOL at 0 range 7 .. 7; TMOD at 0 range 8 .. 9; SLV_OE at 0 range 10 .. 10; SRL at 0 range 11 .. 11; CFS at 0 range 12 .. 15; DFS_32 at 0 range 16 .. 20; SPI_FRF at 0 range 21 .. 22; Reserved_23_23 at 0 range 23 .. 23; SSTE at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype CTRLR1_NDF_Field is HAL.UInt16; -- Master Control register 1 type CTRLR1_Register is record -- Number of data frames NDF : CTRLR1_NDF_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CTRLR1_Register use record NDF at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- SSI Enable type SSIENR_Register is record -- SSI enable SSI_EN : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SSIENR_Register use record SSI_EN at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Microwire Control type MWCR_Register is record -- Microwire transfer mode MWMOD : Boolean := False; -- Microwire control MDD : Boolean := False; -- Microwire handshaking MHS : Boolean := False; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MWCR_Register use record MWMOD at 0 range 0 .. 0; MDD at 0 range 1 .. 1; MHS at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- Slave enable type SER_Register is record -- For each bit:\n 0 -> slave not selected\n 1 -> slave selected SER : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SER_Register use record SER at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; subtype BAUDR_SCKDV_Field is HAL.UInt16; -- Baud rate type BAUDR_Register is record -- SSI clock divider SCKDV : BAUDR_SCKDV_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for BAUDR_Register use record SCKDV at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype TXFTLR_TFT_Field is HAL.UInt8; -- TX FIFO threshold level type TXFTLR_Register is record -- Transmit FIFO threshold TFT : TXFTLR_TFT_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TXFTLR_Register use record TFT at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype RXFTLR_RFT_Field is HAL.UInt8; -- RX FIFO threshold level type RXFTLR_Register is record -- Receive FIFO threshold RFT : RXFTLR_RFT_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RXFTLR_Register use record RFT at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype TXFLR_TFTFL_Field is HAL.UInt8; -- TX FIFO level type TXFLR_Register is record -- Read-only. Transmit FIFO level TFTFL : TXFLR_TFTFL_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TXFLR_Register use record TFTFL at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype RXFLR_RXTFL_Field is HAL.UInt8; -- RX FIFO level type RXFLR_Register is record -- Read-only. Receive FIFO level RXTFL : RXFLR_RXTFL_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RXFLR_Register use record RXTFL at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Status register type SR_Register is record -- Read-only. SSI busy flag BUSY : Boolean; -- Read-only. Transmit FIFO not full TFNF : Boolean; -- Read-only. Transmit FIFO empty TFE : Boolean; -- Read-only. Receive FIFO not empty RFNE : Boolean; -- Read-only. Receive FIFO full RFF : Boolean; -- Read-only. Transmission error TXE : Boolean; -- Read-only. Data collision error DCOL : Boolean; -- unspecified Reserved_7_31 : HAL.UInt25; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record BUSY at 0 range 0 .. 0; TFNF at 0 range 1 .. 1; TFE at 0 range 2 .. 2; RFNE at 0 range 3 .. 3; RFF at 0 range 4 .. 4; TXE at 0 range 5 .. 5; DCOL at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- Interrupt mask type IMR_Register is record -- Transmit FIFO empty interrupt mask TXEIM : Boolean := False; -- Transmit FIFO overflow interrupt mask TXOIM : Boolean := False; -- Receive FIFO underflow interrupt mask RXUIM : Boolean := False; -- Receive FIFO overflow interrupt mask RXOIM : Boolean := False; -- Receive FIFO full interrupt mask RXFIM : Boolean := False; -- Multi-master contention interrupt mask MSTIM : Boolean := False; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IMR_Register use record TXEIM at 0 range 0 .. 0; TXOIM at 0 range 1 .. 1; RXUIM at 0 range 2 .. 2; RXOIM at 0 range 3 .. 3; RXFIM at 0 range 4 .. 4; MSTIM at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; -- Interrupt status type ISR_Register is record -- Read-only. Transmit FIFO empty interrupt status TXEIS : Boolean; -- Read-only. Transmit FIFO overflow interrupt status TXOIS : Boolean; -- Read-only. Receive FIFO underflow interrupt status RXUIS : Boolean; -- Read-only. Receive FIFO overflow interrupt status RXOIS : Boolean; -- Read-only. Receive FIFO full interrupt status RXFIS : Boolean; -- Read-only. Multi-master contention interrupt status MSTIS : Boolean; -- unspecified Reserved_6_31 : HAL.UInt26; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record TXEIS at 0 range 0 .. 0; TXOIS at 0 range 1 .. 1; RXUIS at 0 range 2 .. 2; RXOIS at 0 range 3 .. 3; RXFIS at 0 range 4 .. 4; MSTIS at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; -- Raw interrupt status type RISR_Register is record -- Read-only. Transmit FIFO empty raw interrupt status TXEIR : Boolean; -- Read-only. Transmit FIFO overflow raw interrupt status TXOIR : Boolean; -- Read-only. Receive FIFO underflow raw interrupt status RXUIR : Boolean; -- Read-only. Receive FIFO overflow raw interrupt status RXOIR : Boolean; -- Read-only. Receive FIFO full raw interrupt status RXFIR : Boolean; -- Read-only. Multi-master contention raw interrupt status MSTIR : Boolean; -- unspecified Reserved_6_31 : HAL.UInt26; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RISR_Register use record TXEIR at 0 range 0 .. 0; TXOIR at 0 range 1 .. 1; RXUIR at 0 range 2 .. 2; RXOIR at 0 range 3 .. 3; RXFIR at 0 range 4 .. 4; MSTIR at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; -- TX FIFO overflow interrupt clear type TXOICR_Register is record -- Read-only. Clear-on-read transmit FIFO overflow interrupt TXOICR : Boolean; -- unspecified Reserved_1_31 : HAL.UInt31; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TXOICR_Register use record TXOICR at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- RX FIFO overflow interrupt clear type RXOICR_Register is record -- Read-only. Clear-on-read receive FIFO overflow interrupt RXOICR : Boolean; -- unspecified Reserved_1_31 : HAL.UInt31; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RXOICR_Register use record RXOICR at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- RX FIFO underflow interrupt clear type RXUICR_Register is record -- Read-only. Clear-on-read receive FIFO underflow interrupt RXUICR : Boolean; -- unspecified Reserved_1_31 : HAL.UInt31; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RXUICR_Register use record RXUICR at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Multi-master interrupt clear type MSTICR_Register is record -- Read-only. Clear-on-read multi-master contention interrupt MSTICR : Boolean; -- unspecified Reserved_1_31 : HAL.UInt31; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MSTICR_Register use record MSTICR at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Interrupt clear type ICR_Register is record -- Read-only. Clear-on-read all active interrupts ICR : Boolean; -- unspecified Reserved_1_31 : HAL.UInt31; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICR_Register use record ICR at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- DMA control type DMACR_Register is record -- Receive DMA enable RDMAE : Boolean := False; -- Transmit DMA enable TDMAE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACR_Register use record RDMAE at 0 range 0 .. 0; TDMAE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype DMATDLR_DMATDL_Field is HAL.UInt8; -- DMA TX data level type DMATDLR_Register is record -- Transmit data watermark level DMATDL : DMATDLR_DMATDL_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMATDLR_Register use record DMATDL at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DMARDLR_DMARDL_Field is HAL.UInt8; -- DMA RX data level type DMARDLR_Register is record -- Receive data watermark level (DMARDLR+1) DMARDL : DMARDLR_DMARDL_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMARDLR_Register use record DMARDL at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype RX_SAMPLE_DLY_RSD_Field is HAL.UInt8; -- RX sample delay type RX_SAMPLE_DLY_Register is record -- RXD sample delay (in SCLK cycles) RSD : RX_SAMPLE_DLY_RSD_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RX_SAMPLE_DLY_Register use record RSD at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Address and instruction transfer format type SPI_CTRLR0_TRANS_TYPE_Field is (-- Command and address both in standard SPI frame format Val_1C1A, -- Command in standard SPI format, address in format specified by FRF Val_1C2A, -- Command and address both in format specified by FRF (e.g. Dual-SPI) Val_2C2A) with Size => 2; for SPI_CTRLR0_TRANS_TYPE_Field use (Val_1C1A => 0, Val_1C2A => 1, Val_2C2A => 2); subtype SPI_CTRLR0_ADDR_L_Field is HAL.UInt4; -- Instruction length (0/4/8/16b) type SPI_CTRLR0_INST_L_Field is (-- No instruction None, -- 4-bit instruction Val_4B, -- 8-bit instruction Val_8B, -- 16-bit instruction Val_16B) with Size => 2; for SPI_CTRLR0_INST_L_Field use (None => 0, Val_4B => 1, Val_8B => 2, Val_16B => 3); subtype SPI_CTRLR0_WAIT_CYCLES_Field is HAL.UInt5; subtype SPI_CTRLR0_XIP_CMD_Field is HAL.UInt8; -- SPI control type SPI_CTRLR0_Register is record -- Address and instruction transfer format TRANS_TYPE : SPI_CTRLR0_TRANS_TYPE_Field := RP_SVD.XIP_SSI.Val_1C1A; -- Address length (0b-60b in 4b increments) ADDR_L : SPI_CTRLR0_ADDR_L_Field := 16#0#; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; -- Instruction length (0/4/8/16b) INST_L : SPI_CTRLR0_INST_L_Field := RP_SVD.XIP_SSI.None; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- Wait cycles between control frame transmit and data reception (in -- SCLK cycles) WAIT_CYCLES : SPI_CTRLR0_WAIT_CYCLES_Field := 16#0#; -- SPI DDR transfer enable SPI_DDR_EN : Boolean := False; -- Instruction DDR transfer enable INST_DDR_EN : Boolean := False; -- Read data strobe enable SPI_RXDS_EN : Boolean := False; -- unspecified Reserved_19_23 : HAL.UInt5 := 16#0#; -- SPI Command to send in XIP mode (INST_L = 8-bit) or to append to -- Address (INST_L = 0-bit) XIP_CMD : SPI_CTRLR0_XIP_CMD_Field := 16#3#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SPI_CTRLR0_Register use record TRANS_TYPE at 0 range 0 .. 1; ADDR_L at 0 range 2 .. 5; Reserved_6_7 at 0 range 6 .. 7; INST_L at 0 range 8 .. 9; Reserved_10_10 at 0 range 10 .. 10; WAIT_CYCLES at 0 range 11 .. 15; SPI_DDR_EN at 0 range 16 .. 16; INST_DDR_EN at 0 range 17 .. 17; SPI_RXDS_EN at 0 range 18 .. 18; Reserved_19_23 at 0 range 19 .. 23; XIP_CMD at 0 range 24 .. 31; end record; subtype TXD_DRIVE_EDGE_TDE_Field is HAL.UInt8; -- TX drive edge type TXD_DRIVE_EDGE_Register is record -- TXD drive edge TDE : TXD_DRIVE_EDGE_TDE_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TXD_DRIVE_EDGE_Register use record TDE at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- DW_apb_ssi has the following features:\n * APB interface – Allows for -- easy integration into a DesignWare Synthesizable Components for AMBA 2 -- implementation.\n * APB3 and APB4 protocol support.\n * Scalable APB -- data bus width – Supports APB data bus widths of 8, 16, and 32 bits.\n -- * Serial-master or serial-slave operation – Enables serial -- communication with serial-master or serial-slave peripheral devices.\n * -- Programmable Dual/Quad/Octal SPI support in Master Mode.\n * Dual Data -- Rate (DDR) and Read Data Strobe (RDS) Support - Enables the DW_apb_ssi -- master to perform operations with the device in DDR and RDS modes when -- working in Dual/Quad/Octal mode of operation.\n * Data Mask Support - -- Enables the DW_apb_ssi to selectively update the bytes in the device. -- This feature is applicable only in enhanced SPI modes.\n * -- eXecute-In-Place (XIP) support - Enables the DW_apb_ssi master to behave -- as a memory mapped I/O and fetches the data from the device based on the -- APB read request. This feature is applicable only in enhanced SPI -- modes.\n * DMA Controller Interface – Enables the DW_apb_ssi to -- interface to a DMA controller over the bus using a handshaking interface -- for transfer requests.\n * Independent masking of interrupts – Master -- collision, transmit FIFO overflow, transmit FIFO empty, receive FIFO -- full, receive FIFO underflow, and receive FIFO overflow interrupts can -- all be masked independently.\n * Multi-master contention detection – -- Informs the processor of multiple serial-master accesses on the serial -- bus.\n * Bypass of meta-stability flip-flops for synchronous clocks – -- When the APB clock (pclk) and the DW_apb_ssi serial clock (ssi_clk) are -- synchronous, meta-stable flip-flops are not used when transferring -- control signals across these clock domains.\n * Programmable delay on -- the sample time of the received serial data bit (rxd); enables -- programmable control of routing delays resulting in higher serial -- data-bit rates.\n * Programmable features:\n - Serial interface -- operation – Choice of Motorola SPI, Texas Instruments Synchronous -- Serial Protocol or National Semiconductor Microwire.\n - Clock bit-rate -- – Dynamic control of the serial bit rate of the data transfer; used in -- only serial-master mode of operation.\n - Data Item size (4 to 32 bits) -- – Item size of each data transfer under the control of the -- programmer.\n * Configured features:\n - FIFO depth – 16 words deep. -- The FIFO width is fixed at 32 bits.\n - 1 slave select output.\n - -- Hardware slave-select – Dedicated hardware slave-select line.\n - -- Combined interrupt line - one combined interrupt line from the -- DW_apb_ssi to the interrupt controller.\n - Interrupt polarity – -- active high interrupt lines.\n - Serial clock polarity – low -- serial-clock polarity directly after reset.\n - Serial clock phase – -- capture on first edge of serial-clock directly after reset. type XIP_SSI_Peripheral is record -- Control register 0 CTRLR0 : aliased CTRLR0_Register; -- Master Control register 1 CTRLR1 : aliased CTRLR1_Register; -- SSI Enable SSIENR : aliased SSIENR_Register; -- Microwire Control MWCR : aliased MWCR_Register; -- Slave enable SER : aliased SER_Register; -- Baud rate BAUDR : aliased BAUDR_Register; -- TX FIFO threshold level TXFTLR : aliased TXFTLR_Register; -- RX FIFO threshold level RXFTLR : aliased RXFTLR_Register; -- TX FIFO level TXFLR : aliased TXFLR_Register; -- RX FIFO level RXFLR : aliased RXFLR_Register; -- Status register SR : aliased SR_Register; -- Interrupt mask IMR : aliased IMR_Register; -- Interrupt status ISR : aliased ISR_Register; -- Raw interrupt status RISR : aliased RISR_Register; -- TX FIFO overflow interrupt clear TXOICR : aliased TXOICR_Register; -- RX FIFO overflow interrupt clear RXOICR : aliased RXOICR_Register; -- RX FIFO underflow interrupt clear RXUICR : aliased RXUICR_Register; -- Multi-master interrupt clear MSTICR : aliased MSTICR_Register; -- Interrupt clear ICR : aliased ICR_Register; -- DMA control DMACR : aliased DMACR_Register; -- DMA TX data level DMATDLR : aliased DMATDLR_Register; -- DMA RX data level DMARDLR : aliased DMARDLR_Register; -- Identification register IDR : aliased HAL.UInt32; -- Version ID SSI_VERSION_ID : aliased HAL.UInt32; -- Data Register 0 (of 36) DR0 : aliased HAL.UInt32; -- RX sample delay RX_SAMPLE_DLY : aliased RX_SAMPLE_DLY_Register; -- SPI control SPI_CTRLR0 : aliased SPI_CTRLR0_Register; -- TX drive edge TXD_DRIVE_EDGE : aliased TXD_DRIVE_EDGE_Register; end record with Volatile; for XIP_SSI_Peripheral use record CTRLR0 at 16#0# range 0 .. 31; CTRLR1 at 16#4# range 0 .. 31; SSIENR at 16#8# range 0 .. 31; MWCR at 16#C# range 0 .. 31; SER at 16#10# range 0 .. 31; BAUDR at 16#14# range 0 .. 31; TXFTLR at 16#18# range 0 .. 31; RXFTLR at 16#1C# range 0 .. 31; TXFLR at 16#20# range 0 .. 31; RXFLR at 16#24# range 0 .. 31; SR at 16#28# range 0 .. 31; IMR at 16#2C# range 0 .. 31; ISR at 16#30# range 0 .. 31; RISR at 16#34# range 0 .. 31; TXOICR at 16#38# range 0 .. 31; RXOICR at 16#3C# range 0 .. 31; RXUICR at 16#40# range 0 .. 31; MSTICR at 16#44# range 0 .. 31; ICR at 16#48# range 0 .. 31; DMACR at 16#4C# range 0 .. 31; DMATDLR at 16#50# range 0 .. 31; DMARDLR at 16#54# range 0 .. 31; IDR at 16#58# range 0 .. 31; SSI_VERSION_ID at 16#5C# range 0 .. 31; DR0 at 16#60# range 0 .. 31; RX_SAMPLE_DLY at 16#F0# range 0 .. 31; SPI_CTRLR0 at 16#F4# range 0 .. 31; TXD_DRIVE_EDGE at 16#F8# range 0 .. 31; end record; -- DW_apb_ssi has the following features:\n * APB interface – Allows for -- easy integration into a DesignWare Synthesizable Components for AMBA 2 -- implementation.\n * APB3 and APB4 protocol support.\n * Scalable APB -- data bus width – Supports APB data bus widths of 8, 16, and 32 bits.\n -- * Serial-master or serial-slave operation – Enables serial -- communication with serial-master or serial-slave peripheral devices.\n * -- Programmable Dual/Quad/Octal SPI support in Master Mode.\n * Dual Data -- Rate (DDR) and Read Data Strobe (RDS) Support - Enables the DW_apb_ssi -- master to perform operations with the device in DDR and RDS modes when -- working in Dual/Quad/Octal mode of operation.\n * Data Mask Support - -- Enables the DW_apb_ssi to selectively update the bytes in the device. -- This feature is applicable only in enhanced SPI modes.\n * -- eXecute-In-Place (XIP) support - Enables the DW_apb_ssi master to behave -- as a memory mapped I/O and fetches the data from the device based on the -- APB read request. This feature is applicable only in enhanced SPI -- modes.\n * DMA Controller Interface – Enables the DW_apb_ssi to -- interface to a DMA controller over the bus using a handshaking interface -- for transfer requests.\n * Independent masking of interrupts – Master -- collision, transmit FIFO overflow, transmit FIFO empty, receive FIFO -- full, receive FIFO underflow, and receive FIFO overflow interrupts can -- all be masked independently.\n * Multi-master contention detection – -- Informs the processor of multiple serial-master accesses on the serial -- bus.\n * Bypass of meta-stability flip-flops for synchronous clocks – -- When the APB clock (pclk) and the DW_apb_ssi serial clock (ssi_clk) are -- synchronous, meta-stable flip-flops are not used when transferring -- control signals across these clock domains.\n * Programmable delay on -- the sample time of the received serial data bit (rxd); enables -- programmable control of routing delays resulting in higher serial -- data-bit rates.\n * Programmable features:\n - Serial interface -- operation – Choice of Motorola SPI, Texas Instruments Synchronous -- Serial Protocol or National Semiconductor Microwire.\n - Clock bit-rate -- – Dynamic control of the serial bit rate of the data transfer; used in -- only serial-master mode of operation.\n - Data Item size (4 to 32 bits) -- – Item size of each data transfer under the control of the -- programmer.\n * Configured features:\n - FIFO depth – 16 words deep. -- The FIFO width is fixed at 32 bits.\n - 1 slave select output.\n - -- Hardware slave-select – Dedicated hardware slave-select line.\n - -- Combined interrupt line - one combined interrupt line from the -- DW_apb_ssi to the interrupt controller.\n - Interrupt polarity – -- active high interrupt lines.\n - Serial clock polarity – low -- serial-clock polarity directly after reset.\n - Serial clock phase – -- capture on first edge of serial-clock directly after reset. XIP_SSI_Periph : aliased XIP_SSI_Peripheral with Import, Address => XIP_SSI_Base; end RP_SVD.XIP_SSI;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- U N C H E C K E D _ C O N V E R S I O N -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ generic type Source (<>) is limited private; type Target (<>) is limited private; function Unchecked_Conversion (S : Source) return Target; pragma Import (Intrinsic, Unchecked_Conversion); pragma Pure (Unchecked_Conversion);
----------------------------------------------------------------------- -- asf-applications-views-tests - Unit tests for ASF.Applications.Views -- Copyright (C) 2009, 2010, 2011, 2012, 2014, 2015, 2018, 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.Text_IO; with ASF.Applications.Main; with ASF.Applications.Tests; with ASF.Requests.Mockup; with ASF.Responses.Mockup; with ASF.Servlets.Faces; with ASF.Converters.Dates; with ASF.Server; with Ada.Directories; with Ada.Unchecked_Deallocation; with Util.Files; with Util.Beans.Basic; with Util.Beans.Objects; with Util.Measures; package body ASF.Applications.Views.Tests is use Ada.Strings.Unbounded; overriding procedure Set_Up (T : in out Test) is begin null; end Set_Up; -- Set up performed before each test case -- ------------------------------ -- Test loading of facelet file -- ------------------------------ procedure Test_Load_Facelet (T : in out Test) is procedure Free is new Ada.Unchecked_Deallocation (Object => ASF.Converters.Dates.Date_Converter'Class, Name => ASF.Converters.Dates.Date_Converter_Access); App : aliased Applications.Main.Application; View_Name : constant String := To_String (T.File); Result_File : constant String := To_String (T.Result); Conf : Applications.Config; App_Factory : Applications.Main.Application_Factory; Dir : constant String := "regtests/files"; Path : constant String := Util.Tests.Get_Path (Dir); Faces : aliased ASF.Servlets.Faces.Faces_Servlet; List : Util.Beans.Basic.Readonly_Bean_Access; List_Bean : Util.Beans.Objects.Object; Form : Util.Beans.Basic.Readonly_Bean_Access; Form_Bean : Util.Beans.Objects.Object; C : ASF.Converters.Dates.Date_Converter_Access; Container : ASF.Server.Container; begin List := Applications.Tests.Create_Form_List; List_Bean := Util.Beans.Objects.To_Object (List); Form := Applications.Tests.Create_Form_Bean; Form_Bean := Util.Beans.Objects.To_Object (Form); Conf.Load_Properties ("regtests/view.properties"); Conf.Set ("view.dir", Path); App.Initialize (Conf, App_Factory); App.Register_Application ("/"); App.Add_Servlet ("faces", Faces'Unchecked_Access); App.Add_Mapping ("*.xhtml", "faces"); C := ASF.Converters.Dates.Create_Date_Converter (Date => ASF.Converters.Dates.DEFAULT, Time => ASF.Converters.Dates.DEFAULT, Format => ASF.Converters.Dates.TIME, Locale => "en", Pattern => ""); App.Add_Converter ("date-default-converter", C.all'Access); App.Set_Global ("function", "Test_Load_Facelet"); App.Set_Global ("date", "2011-12-03 03:04:05.23"); Container.Register_Application ("/asfunit", App'Unchecked_Access); Container.Start; for I in 1 .. 2 loop declare S : Util.Measures.Stamp; Req : ASF.Requests.Mockup.Request; Reply : aliased ASF.Responses.Mockup.Response; Content : Unbounded_String; begin Req.Set_Method ("GET"); Req.Set_Request_URI ("/asfunit/" & View_Name); Req.Set_Parameter ("file-name", To_String (T.Name)); Req.Set_Header ("file", To_String (T.Name)); Req.Set_Attribute ("list", List_Bean); Req.Set_Attribute ("form", Form_Bean); Container.Service (Req, Reply); Util.Measures.Report (S, "Pass" & Integer'Image (I) & ": Render view " & View_Name); Reply.Read_Content (Content); Util.Files.Write_File (Result_File, Content); Util.Tests.Assert_Equal_Files (T => T, Expect => To_String (T.Expect), Test => Result_File, Message => "Restore and render view"); end; end loop; Free (C); end Test_Load_Facelet; -- ------------------------------ -- Test case name -- ------------------------------ overriding function Name (T : Test) return Util.Tests.Message_String is begin return Util.Tests.Format ("Test " & To_String (T.Name)); end Name; -- ------------------------------ -- Perform the test. -- ------------------------------ overriding procedure Run_Test (T : in out Test) is begin T.Test_Load_Facelet; end Run_Test; procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is use Ada.Directories; Result_Dir : constant String := "regtests/result/views"; Dir : constant String := "regtests/files/views"; Expect_Dir : constant String := "regtests/expect/views"; Path : constant String := Util.Tests.Get_Path (Dir); Expect_Path : constant String := Util.Tests.Get_Path (Expect_Dir); Result_Path : constant String := Util.Tests.Get_Test_Path (Result_Dir); Search : Search_Type; Filter : constant Filter_Type := (others => True); Ent : Directory_Entry_Type; begin if Kind (Path) /= Directory then Ada.Text_IO.Put_Line ("Cannot read test directory: " & Path); end if; Start_Search (Search, Directory => Path, Pattern => "*.xhtml", Filter => Filter); while More_Entries (Search) loop Get_Next_Entry (Search, Ent); declare Simple : constant String := Simple_Name (Ent); Tst : Test_Case_Access; begin if Simple /= "." and then Simple /= ".." and then Simple /= ".svn" then Tst := new Test; Tst.Name := To_Unbounded_String (Dir & "/" & Simple); Tst.File := To_Unbounded_String ("views/" & Simple); Tst.Expect := To_Unbounded_String (Expect_Path & "/" & Simple); Tst.Result := To_Unbounded_String (Result_Path & "/" & Simple); Suite.Add_Test (Tst.all'Access); end if; end; end loop; end Add_Tests; end ASF.Applications.Views.Tests;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . W I D E _ W I D E _ S U P E R B O U N D E D -- -- -- -- S p e c -- -- -- -- Copyright (C) 2003-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. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This non generic package contains most of the implementation of the -- generic package Ada.Strings.Wide_Wide_Bounded.Generic_Bounded_Length. -- It defines type Super_String as a discriminated record with the maximum -- length as the discriminant. Individual instantiations of the package -- Strings.Wide_Wide_Bounded.Generic_Bounded_Length use this type with -- an appropriate discriminant value set. with Ada.Strings.Wide_Wide_Maps; package Ada.Strings.Wide_Wide_Superbounded is pragma Preelaborate; Wide_Wide_NUL : constant Wide_Wide_Character := Wide_Wide_Character'Val (0); type Super_String (Max_Length : Positive) is record Current_Length : Natural := 0; Data : Wide_Wide_String (1 .. Max_Length) := (others => Wide_Wide_NUL); end record; -- Wide_Wide_Bounded.Generic_Bounded_Length.Wide_Wide_Bounded_String is -- derived from this type, with the constraint of the maximum length. -- The subprograms defined for Super_String are similar to those defined -- for Bounded_Wide_Wide_String, except that they have different names, so -- that they can be renamed in Wide_Wide_Bounded.Generic_Bounded_Length. function Super_Length (Source : Super_String) return Natural; -------------------------------------------------------- -- Conversion, Concatenation, and Selection Functions -- -------------------------------------------------------- function To_Super_String (Source : Wide_Wide_String; Max_Length : Natural; Drop : Truncation := Error) return Super_String; -- Note the additional parameter Max_Length, which specifies the maximum -- length setting of the resulting Super_String value. -- The following procedures have declarations (and semantics) that are -- exactly analogous to those declared in Ada.Strings.Wide_Wide_Bounded. function Super_To_String (Source : Super_String) return Wide_Wide_String; procedure Set_Super_String (Target : out Super_String; Source : Wide_Wide_String; Drop : Truncation := Error); function Super_Append (Left : Super_String; Right : Super_String; Drop : Truncation := Error) return Super_String; function Super_Append (Left : Super_String; Right : Wide_Wide_String; Drop : Truncation := Error) return Super_String; function Super_Append (Left : Wide_Wide_String; Right : Super_String; Drop : Truncation := Error) return Super_String; function Super_Append (Left : Super_String; Right : Wide_Wide_Character; Drop : Truncation := Error) return Super_String; function Super_Append (Left : Wide_Wide_Character; Right : Super_String; Drop : Truncation := Error) return Super_String; procedure Super_Append (Source : in out Super_String; New_Item : Super_String; Drop : Truncation := Error); procedure Super_Append (Source : in out Super_String; New_Item : Wide_Wide_String; Drop : Truncation := Error); procedure Super_Append (Source : in out Super_String; New_Item : Wide_Wide_Character; Drop : Truncation := Error); function Concat (Left : Super_String; Right : Super_String) return Super_String; function Concat (Left : Super_String; Right : Wide_Wide_String) return Super_String; function Concat (Left : Wide_Wide_String; Right : Super_String) return Super_String; function Concat (Left : Super_String; Right : Wide_Wide_Character) return Super_String; function Concat (Left : Wide_Wide_Character; Right : Super_String) return Super_String; function Super_Element (Source : Super_String; Index : Positive) return Wide_Wide_Character; procedure Super_Replace_Element (Source : in out Super_String; Index : Positive; By : Wide_Wide_Character); function Super_Slice (Source : Super_String; Low : Positive; High : Natural) return Wide_Wide_String; function Super_Slice (Source : Super_String; Low : Positive; High : Natural) return Super_String; procedure Super_Slice (Source : Super_String; Target : out Super_String; Low : Positive; High : Natural); function "=" (Left : Super_String; Right : Super_String) return Boolean; function Equal (Left : Super_String; Right : Super_String) return Boolean renames "="; function Equal (Left : Super_String; Right : Wide_Wide_String) return Boolean; function Equal (Left : Wide_Wide_String; Right : Super_String) return Boolean; function Less (Left : Super_String; Right : Super_String) return Boolean; function Less (Left : Super_String; Right : Wide_Wide_String) return Boolean; function Less (Left : Wide_Wide_String; Right : Super_String) return Boolean; function Less_Or_Equal (Left : Super_String; Right : Super_String) return Boolean; function Less_Or_Equal (Left : Super_String; Right : Wide_Wide_String) return Boolean; function Less_Or_Equal (Left : Wide_Wide_String; Right : Super_String) return Boolean; function Greater (Left : Super_String; Right : Super_String) return Boolean; function Greater (Left : Super_String; Right : Wide_Wide_String) return Boolean; function Greater (Left : Wide_Wide_String; Right : Super_String) return Boolean; function Greater_Or_Equal (Left : Super_String; Right : Super_String) return Boolean; function Greater_Or_Equal (Left : Super_String; Right : Wide_Wide_String) return Boolean; function Greater_Or_Equal (Left : Wide_Wide_String; Right : Super_String) return Boolean; ---------------------- -- Search Functions -- ---------------------- function Super_Index (Source : Super_String; Pattern : Wide_Wide_String; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; function Super_Index (Source : Super_String; Pattern : Wide_Wide_String; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; function Super_Index (Source : Super_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; Test : Membership := Inside; Going : Direction := Forward) return Natural; function Super_Index (Source : Super_String; Pattern : Wide_Wide_String; From : Positive; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; function Super_Index (Source : Super_String; Pattern : Wide_Wide_String; From : Positive; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; function Super_Index (Source : Super_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural; function Super_Index_Non_Blank (Source : Super_String; Going : Direction := Forward) return Natural; function Super_Index_Non_Blank (Source : Super_String; From : Positive; Going : Direction := Forward) return Natural; function Super_Count (Source : Super_String; Pattern : Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; function Super_Count (Source : Super_String; Pattern : Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; function Super_Count (Source : Super_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural; procedure Super_Find_Token (Source : Super_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; Test : Membership; First : out Positive; Last : out Natural); ------------------------------------ -- String Translation Subprograms -- ------------------------------------ function Super_Translate (Source : Super_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping) return Super_String; procedure Super_Translate (Source : in out Super_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping); function Super_Translate (Source : Super_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Super_String; procedure Super_Translate (Source : in out Super_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function); --------------------------------------- -- String Transformation Subprograms -- --------------------------------------- function Super_Replace_Slice (Source : Super_String; Low : Positive; High : Natural; By : Wide_Wide_String; Drop : Truncation := Error) return Super_String; procedure Super_Replace_Slice (Source : in out Super_String; Low : Positive; High : Natural; By : Wide_Wide_String; Drop : Truncation := Error); function Super_Insert (Source : Super_String; Before : Positive; New_Item : Wide_Wide_String; Drop : Truncation := Error) return Super_String; procedure Super_Insert (Source : in out Super_String; Before : Positive; New_Item : Wide_Wide_String; Drop : Truncation := Error); function Super_Overwrite (Source : Super_String; Position : Positive; New_Item : Wide_Wide_String; Drop : Truncation := Error) return Super_String; procedure Super_Overwrite (Source : in out Super_String; Position : Positive; New_Item : Wide_Wide_String; Drop : Truncation := Error); function Super_Delete (Source : Super_String; From : Positive; Through : Natural) return Super_String; procedure Super_Delete (Source : in out Super_String; From : Positive; Through : Natural); --------------------------------- -- String Selector Subprograms -- --------------------------------- function Super_Trim (Source : Super_String; Side : Trim_End) return Super_String; procedure Super_Trim (Source : in out Super_String; Side : Trim_End); function Super_Trim (Source : Super_String; Left : Wide_Wide_Maps.Wide_Wide_Character_Set; Right : Wide_Wide_Maps.Wide_Wide_Character_Set) return Super_String; procedure Super_Trim (Source : in out Super_String; Left : Wide_Wide_Maps.Wide_Wide_Character_Set; Right : Wide_Wide_Maps.Wide_Wide_Character_Set); function Super_Head (Source : Super_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space; Drop : Truncation := Error) return Super_String; procedure Super_Head (Source : in out Super_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space; Drop : Truncation := Error); function Super_Tail (Source : Super_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space; Drop : Truncation := Error) return Super_String; procedure Super_Tail (Source : in out Super_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space; Drop : Truncation := Error); ------------------------------------ -- String Constructor Subprograms -- ------------------------------------ -- Note: in some of the following routines, there is an extra parameter -- Max_Length which specifies the value of the maximum length for the -- resulting Super_String value. function Times (Left : Natural; Right : Wide_Wide_Character; Max_Length : Positive) return Super_String; -- Note the additional parameter Max_Length function Times (Left : Natural; Right : Wide_Wide_String; Max_Length : Positive) return Super_String; -- Note the additional parameter Max_Length function Times (Left : Natural; Right : Super_String) return Super_String; function Super_Replicate (Count : Natural; Item : Wide_Wide_Character; Drop : Truncation := Error; Max_Length : Positive) return Super_String; -- Note the additional parameter Max_Length function Super_Replicate (Count : Natural; Item : Wide_Wide_String; Drop : Truncation := Error; Max_Length : Positive) return Super_String; -- Note the additional parameter Max_Length function Super_Replicate (Count : Natural; Item : Super_String; Drop : Truncation := Error) return Super_String; private -- Pragma Inline declarations pragma Inline ("="); pragma Inline (Less); pragma Inline (Less_Or_Equal); pragma Inline (Greater); pragma Inline (Greater_Or_Equal); pragma Inline (Concat); pragma Inline (Super_Count); pragma Inline (Super_Element); pragma Inline (Super_Find_Token); pragma Inline (Super_Index); pragma Inline (Super_Index_Non_Blank); pragma Inline (Super_Length); pragma Inline (Super_Replace_Element); pragma Inline (Super_Slice); pragma Inline (Super_To_String); end Ada.Strings.Wide_Wide_Superbounded;
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Бб., 30 нояб. 2013) $: with Asis.Elements; with Asis.Gela.Errors; with Asis.Gela.Replace; with Asis.Expressions; with Asis.Definitions; with Asis.Declarations; with Asis.Gela.Utils; with Asis.Gela.Resolver; with Asis.Gela.Elements.Assoc; with Asis.Gela.Overloads.Iters; with XASIS.Types; with XASIS.Static; package body Asis.Gela.Overloads.Walk.Down is use Asis.Elements; use Asis.Gela.Classes; package R renames Asis.Gela.Replace; procedure Push_Array_Indexes (Resolver : in out Down_Resolver; Tipe : in Type_Info); procedure Simple_Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element); procedure Access_Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element); procedure Length_Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element); procedure First_Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element); function Array_Dimention (Tipe : Type_Info) return Asis.List_Index; type Component_Info is record Declaration : Asis.Declaration; Association : Asis.Association; Processed : Boolean := False; -- For positional discr only end record; -------------------------------- -- Access_Attribute_Reference -- -------------------------------- procedure Access_Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element) is use Asis.Gela.Errors; use Asis.Expressions; Store : Stored_Set; Stored : Stored_Interpretation; Down : Down_Interpretation; Next : Down_Interpretation; Found : Boolean := False; begin Get (Resolver.Store, Element, Store); D.Pop (Resolver.Stack, Down); if Down.Kind = An_Expression then Set_Expression_Type (Element, Down.Expression_Type); else raise Internal_Error; end if; Get (Store, 1, Stored); if Stored.Down.Kind = A_Declaration and then Is_Subprogram (Stored.Down.Declaration) then for I in 1 .. Length (Store) loop Get (Store, I, Stored); if Conform_Access_Type (Stored.Down.Declaration, Down.Expression_Type) then if Found then Report (Element, Error_Ambiguous_Interprentation); else Next := To_Down_Interpretation (Stored.Down); Found := True; end if; end if; end loop; else Next := To_Down_Interpretation (Stored.Down); Found := True; end if; if not Found then Report (Element, Error_No_Interprentation); Down := (Kind => A_Skip); end if; D.Push (Resolver.Stack, (Kind => A_Skip)); D.Push (Resolver.Stack, Next); Destroy (Store); end Access_Attribute_Reference; --------------- -- Aggregate -- --------------- procedure Aggregate (Resolver : in out Down_Resolver; Element : in out Asis.Element; Extension : in Boolean := False) is use Asis.Gela.Errors; use Asis.Expressions; type Component_Info_List is array (Asis.List_Index range <>) of Component_Info; function Needed_Components (List : Asis.Association_List; Tipe : Type_Info) return Component_Info_List; procedure Resolve_Expression (Element : Asis.Association; Decl : Asis.Declaration); ------------------------ -- Resolve_Expression -- ------------------------ procedure Resolve_Expression (Element : Asis.Association; Decl : Asis.Declaration) is use Asis.Gela.Elements.Assoc; Control : Traverse_Control := Continue; Expr : Asis.Expression := Component_Expression (Element); Info : Type_Info := Type_Of_Declaration (Decl, Element); begin D.Push (Resolver.Stack, Up_Expression (Info)); Iters.Down_Iterator.Walk_Element_And_Free (Expr, Control, Resolver); Set_Component_Expression (Record_Component_Association_Node (Element.all), Expr); Gela.Resolver.Polish_Subexpression (Expr); end Resolve_Expression; ----------------------- -- Needed_Components -- ----------------------- function Needed_Components (List : Asis.Association_List; Tipe : Type_Info) return Component_Info_List is use Asis.Expressions; use Asis.Gela.Errors; type Discriminant_Info is record Decl : Asis.Declaration; Value : XASIS.Static.Value; Processed : Boolean := False; Found : Boolean := False; end record; type Discriminant_Info_List is array (Asis.List_Index range <>) of Discriminant_Info; function Get_Discriminants (Decl : Asis.Declaration) return Discriminant_Info_List; function Count_Component (List : Asis.Association_List) return Natural; procedure Check_Variant (Item : in Asis.Variant; Continue : out Boolean); procedure Find_Companent (Item : in Asis.Declaration; Continue : out Boolean); procedure Find_Other_Companent (Item : in Asis.Declaration; Continue : out Boolean); function Get_Discr_Index (Item : Asis.Variant) return Asis.List_Index; --------------------- -- Count_Component -- --------------------- function Count_Component (List : Asis.Association_List) return Natural is Count : Natural := 0; begin for I in List'Range loop declare Choices : Asis.Element_List := Asis.Expressions.Record_Component_Choices (List (I)); begin if Choices'Length = 0 then Count := Count + 1; elsif Choices'Length = 1 and then Definition_Kind (Choices (1)) = An_Others_Choice then Count := Count + 1; else Count := Count + Choices'Length; end if; end; end loop; return Count; end Count_Component; ----------------------- -- Get_Discriminants -- ----------------------- function Get_Discriminants (Decl : Asis.Declaration) return Discriminant_Info_List is use Asis.Definitions; use Asis.Declarations; Part : Asis.Definition := Discriminant_Part (Decl); begin if not Assigned (Part) or else Definition_Kind (Part) /= A_Known_Discriminant_Part then declare Empty : Discriminant_Info_List (1 .. 0); begin return Empty; end; end if; declare List : Asis.Discriminant_Specification_List := Discriminants (Part); Result : Discriminant_Info_List (List'Range); begin for I in Result'Range loop Result (I).Decl := List (I); end loop; return Result; end; end Get_Discriminants; Index : Asis.List_Index := 1; Ignore : Boolean; First : Asis.List_Index := List'First; Last : constant Asis.ASIS_Natural := Asis.ASIS_Natural (Count_Component (List)); Result : Component_Info_List (1 .. Last); Decl : Asis.Declaration := Get_Type_View (Tipe); Discr : Discriminant_Info_List := Get_Discriminants (Decl); --------------------- -- Get_Discr_Index -- --------------------- function Get_Discr_Index (Item : Asis.Variant) return Asis.List_Index is use Asis.Definitions; Parent : Asis.Element := Enclosing_Element (Item); Name : Asis.Name := Discriminant_Direct_Name (Parent); Decl : Asis.Declaration := Corresponding_Name_Declaration (Name); Found : Asis.List_Index := 1; Expr : Asis.Expression; begin for I in Discr'Range loop if Is_Equal (Discr (I).Decl, Decl) then Found := I; exit; end if; end loop; if not Discr (Found).Processed then for I in 1 .. Index - 1 loop if Is_Equal (Result (I).Declaration, Decl) then ------------------------------------------------- Resolve_Expression (Result (I).Association, Decl); ------------------------------------------------- Result (I).Processed := True; Expr := Component_Expression (Result (I).Association); Discr (Found).Value := XASIS.Static.Evaluate (Expr); end if; end loop; Discr (Found).Processed := True; Discr (Found).Found := False; end if; return Found; end Get_Discr_Index; ------------------- -- Check_Variant -- ------------------- procedure Check_Variant (Item : in Asis.Variant; Continue : out Boolean) is use XASIS.Static; Index : Asis.List_Index := Get_Discr_Index (Item); Value : XASIS.Static.Value; Choises : Asis.Element_List := Asis.Definitions.Variant_Choices (Item); begin Continue := False; if Discr (Index).Found then return; end if; for I in Choises'Range loop if Element_Kind (Choises (I)) = An_Expression then Value := XASIS.Static.Evaluate (Choises (I)); if Discr (Index).Value = Value then Discr (Index).Found := True; Continue := True; end if; elsif Definition_Kind (Choises (I)) = An_Others_Choice then Discr (Index).Found := True; Continue := True; else if In_Range (Discr (Index).Value, Choises (I)) then Discr (Index).Found := True; Continue := True; end if; end if; exit when Continue; end loop; end Check_Variant; -------------------- -- Find_Companent -- -------------------- procedure Find_Companent (Item : in Asis.Declaration; Continue : out Boolean) is begin if Index in List'Range and then Record_Component_Choices (List (Index))'Length = 0 then Continue := True; Result (Index).Declaration := Item; Result (Index).Association := List (Index); Index := Index + 1; else Continue := False; end if; end Find_Companent; -------------------------- -- Find_Other_Companent -- -------------------------- procedure Find_Other_Companent (Item : in Asis.Declaration; Continue : out Boolean) is begin for I in 1 .. Index - 1 loop if Is_Equal (Item, Result (I).Declaration) then Continue := True; return; end if; end loop; Result (Index).Declaration := Item; Continue := False; end Find_Other_Companent; procedure Find_Positional is new Gela.Utils.Walk_Components (Element, Check_Variant, Find_Companent); procedure Find_Other is new Gela.Utils.Walk_Components (Element, Check_Variant, Find_Other_Companent); begin -- Needed_Components Find_Positional (Decl, Ignore); for I in First .. List'Last loop declare Choises : Asis.Element_List := Record_Component_Choices (List (I)); Choice : Asis.Identifier; begin for J in Choises'Range loop Choice := Choises (J); if Is_Nil (Choice) then Report (List (I), Error_Syntax_Misplaced_Association); elsif Definition_Kind (Choice) = An_Others_Choice then Find_Other (Decl, Ignore); elsif Expression_Kind (Choice) = An_Identifier then declare Name : Asis.Program_Text := Asis.Expressions.Name_Image (Choice); begin Result (Index).Association := List (I); Result (Index).Declaration := Find_Component (Tipe, Name); end; else raise Internal_Error; end if; Index := Index + 1; end loop; end; end loop; return Result; end Needed_Components; Store : Stored_Set; Stored : Stored_Interpretation; Down : Down_Interpretation; Tipe : Type_Info; Index : Type_Info; Deep : Asis.List_Index := 1; Dimention : Asis.List_Index; List : Asis.Association_List := Record_Component_Associations (Element); begin D.Pop (Resolver.Stack, Down); if Down.Kind = An_Expression then Set_Expression_Type (Element, Down.Expression_Type); Tipe := Down.Expression_Type; elsif Down.Kind = A_Subaggregate then Tipe := Down.Array_Type; Deep := Down.Deep; else raise Internal_Error; end if; if not Extension and then Is_Array (Tipe) then Dimention := Array_Dimention (Tipe); Index := Get_Array_Index_Type (Tipe, Deep); if Deep = Dimention then Down := Up_Expression (Get_Array_Element_Type (Tipe)); else Down := (A_Subaggregate, Tipe, Deep + 1); end if; for I in reverse List'Range loop D.Push (Resolver.Stack, Down); declare Choises : Asis.Element_List := Record_Component_Choices (List (I)); begin for J in Choises'Range loop if Definition_Kind (Choises (J)) /= An_Others_Choice then D.Push (Resolver.Stack, Up_Expression (Index)); end if; end loop; end; end loop; if Could_Be_Positional_Array_Aggregate (Element) then R.Record_To_Array_Aggregate (Element, True); else R.Record_To_Array_Aggregate (Element, False); end if; else -- is record aggregate declare Fields : Component_Info_List := Needed_Components (List, Tipe); Index : Asis_Natural := Fields'Last; Expr : Type_Info; begin for I in reverse List'Range loop Expr := Type_Of_Declaration (Fields (Index).Declaration, Element); if Fields (Index).Processed then D.Push (Resolver.Stack, (Kind => A_Skip)); else D.Push (Resolver.Stack, Up_Expression (Expr)); end if; declare Choises : Asis.Element_List := Record_Component_Choices (List (I)); Other : Boolean := False; begin for J in reverse Choises'Range loop if Definition_Kind (Choises (J)) /= An_Others_Choice then D.Push (Resolver.Stack, (A_Declaration, Fields (Index).Declaration)); Index := Index - 1; else Other := True; end if; end loop; if Choises'Length = 0 or Other then Index := Index - 1; end if; end; end loop; end; if Extension then Get (Resolver.Store, Element, Store); if Length (Store) /= 1 then raise Internal_Error; end if; Get (Store, 1, Stored); D.Push (Resolver.Stack, To_Down_Interpretation (Stored.Down)); Destroy (Store); end if; end if; end Aggregate; --------------------- -- Array_Dimention -- --------------------- function Array_Dimention (Tipe : Type_Info) return Asis.List_Index is use Asis.Definitions; Def : Asis.Definition := Get_Type_Def (Top_Parent_Type (Tipe)); begin if Definition_Kind (Def) = A_Formal_Type_Definition then case Formal_Type_Kind (Def) is when A_Formal_Unconstrained_Array_Definition => return Index_Subtype_Definitions (Def)'Length; when A_Formal_Constrained_Array_Definition => return Discrete_Subtype_Definitions (Def)'Length; when others => raise Internal_Error; end case; else case Type_Kind (Def) is when An_Unconstrained_Array_Definition => return Index_Subtype_Definitions (Def)'Length; when A_Constrained_Array_Definition => return Discrete_Subtype_Definitions (Def)'Length; when others => raise Internal_Error; end case; end if; end Array_Dimention; ---------------- -- Assignment -- ---------------- procedure Assignment (Resolver : in out Down_Resolver; Element : in out Asis.Element) is Down : Down_Interpretation; begin D.Pop (Resolver.Stack, Down); D.Push (Resolver.Stack, Down); D.Push (Resolver.Stack, Down); end Assignment; ------------------------- -- Attribute_Reference -- ------------------------- procedure Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element) is use Asis.Gela.Errors; use Asis.Expressions; Down : Down_Interpretation; Kind : Attribute_Kinds := Attribute_Kind (Element); begin case Kind is when Not_An_Attribute => raise Internal_Error; when An_Access_Attribute => Access_Attribute_Reference (Resolver, Element); when A_Base_Attribute | A_Class_Attribute => D.Pop (Resolver.Stack, Down); D.Push (Resolver.Stack, (Kind => A_Skip)); D.Push (Resolver.Stack, Down); when A_First_Attribute | A_Last_Attribute | A_Range_Attribute => First_Attribute_Reference (Resolver, Element); when A_Length_Attribute => Length_Attribute_Reference (Resolver, Element); when An_Address_Attribute | An_Adjacent_Attribute | An_Aft_Attribute | An_Alignment_Attribute | A_Bit_Order_Attribute | A_Body_Version_Attribute | A_Callable_Attribute | A_Caller_Attribute | A_Ceiling_Attribute | A_Component_Size_Attribute | A_Compose_Attribute | A_Constrained_Attribute | A_Copy_Sign_Attribute | A_Count_Attribute | A_Definite_Attribute | A_Delta_Attribute | A_Denorm_Attribute | A_Digits_Attribute | An_Exponent_Attribute | An_External_Tag_Attribute | A_First_Bit_Attribute | A_Floor_Attribute | A_Fore_Attribute | A_Fraction_Attribute | An_Identity_Attribute | An_Image_Attribute | An_Input_Attribute | A_Last_Bit_Attribute | A_Leading_Part_Attribute | A_Machine_Attribute | A_Machine_Emax_Attribute | A_Machine_Emin_Attribute | A_Machine_Mantissa_Attribute | A_Machine_Overflows_Attribute | A_Machine_Radix_Attribute | A_Machine_Rounding_Attribute | A_Machine_Rounds_Attribute | A_Max_Attribute | A_Max_Size_In_Storage_Elements_Attribute | A_Min_Attribute | A_Mod_Attribute | A_Model_Attribute | A_Model_Emin_Attribute | A_Model_Epsilon_Attribute | A_Model_Mantissa_Attribute | A_Model_Small_Attribute | A_Modulus_Attribute | A_Partition_ID_Attribute | A_Pos_Attribute | A_Position_Attribute | A_Pred_Attribute | A_Priority_Attribute | A_Read_Attribute | A_Remainder_Attribute | A_Round_Attribute | A_Rounding_Attribute | A_Safe_First_Attribute | A_Safe_Last_Attribute | A_Scale_Attribute | A_Scaling_Attribute | A_Signed_Zeros_Attribute | A_Size_Attribute | A_Small_Attribute | A_Storage_Pool_Attribute | A_Storage_Size_Attribute | A_Stream_Size_Attribute | A_Succ_Attribute | A_Tag_Attribute | A_Terminated_Attribute | A_Truncation_Attribute | An_Unbiased_Rounding_Attribute | An_Unchecked_Access_Attribute | A_Val_Attribute | A_Valid_Attribute | A_Value_Attribute | A_Version_Attribute | A_Wide_Image_Attribute | A_Wide_Value_Attribute | A_Wide_Wide_Image_Attribute | A_Wide_Wide_Value_Attribute | A_Wide_Wide_Width_Attribute | A_Wide_Width_Attribute | A_Width_Attribute | An_Output_Attribute | A_Write_Attribute => Simple_Attribute_Reference (Resolver, Element); when others => raise Internal_Error; end case; end Attribute_Reference; -------------------- -- Check_Implicit -- -------------------- procedure Check_Implicit (Resolver : in out Down_Resolver; Element : in out Asis.Element; Control : in out Traverse_Control) is Down : Down_Interpretation; begin D.Pop (Resolver.Stack, Down); if Down.Kind = An_Expression then Check_Implicit (Resolver.Implicit, Resolver.Store, Element, Down); elsif Down.Kind = A_Skip then Control := Abandon_Children; return; end if; D.Push (Resolver.Stack, Down); end Check_Implicit; -------------------------- -- Explicit_Dereference -- -------------------------- procedure Explicit_Dereference (Resolver : in out Down_Resolver; Element : in Asis.Element) is use Asis.Gela.Errors; Set : Stored_Set; Item : Stored_Interpretation; Down : Down_Interpretation; Next : Down_Interpretation; Found : Boolean := False; begin Get (Resolver.Store, Element, Set); D.Pop (Resolver.Stack, Down); for I in 1 .. Length (Set) loop Get (Set, I, Item); if (Down.Kind = A_Subprogram_Reference and then Item.Kind = A_Subprogram_Reference and then Is_Equal (Item.Result_Type, Down.Access_Type)) or else (Down.Kind = An_Expression and then Item.Kind /= A_Subprogram_Reference and then (Is_Expected_Type (Down.Expression_Type, Item.Result_Type) or Is_Expected_Type (Item.Result_Type, Down.Expression_Type))) then if Found then Report (Element, Error_Ambiguous_Interprentation); else Found := True; Next := To_Down_Interpretation (Item.Down); end if; if Down.Kind = An_Expression then Set_Expression_Type (Element, Down.Expression_Type); end if; elsif Down.Kind /= An_Expression and Down.Kind /= A_Subprogram_Reference then raise Internal_Error; end if; end loop; if not Found then Report (Element, Error_No_Interprentation); end if; D.Push (Resolver.Stack, Next); Destroy (Set); end Explicit_Dereference; ------------------------------- -- First_Attribute_Reference -- ------------------------------- procedure First_Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element) is use Asis.Gela.Errors; use Asis.Expressions; Store : Stored_Set; Stored : Stored_Interpretation; Down : Down_Interpretation; Tipe : Type_Info; List : constant Asis.Element_List := Attribute_Designator_Expressions (Element); begin Get (Resolver.Store, Element, Store); D.Pop (Resolver.Stack, Down); if Down.Kind = An_Expression then Set_Expression_Type (Element, Down.Expression_Type); Tipe := Down.Expression_Type; elsif Down.Kind = A_Range then Tipe := Down.Range_Type; else raise Internal_Error; end if; for I in reverse 1 .. List'Length loop Get (Store, I, Stored); Down := To_Down_Interpretation (Stored.Down); D.Push (Resolver.Stack, Down); end loop; Get (Store, List'Length + 1, Stored); Down := To_Down_Interpretation (Stored.Down); D.Push (Resolver.Stack, (Kind => A_Skip)); D.Push (Resolver.Stack, Down); Destroy (Store); end First_Attribute_Reference; ------------------- -- Function_Call -- ------------------- procedure Function_Call (Resolver : in out Down_Resolver; Element : in out Asis.Element) is use Asis.Gela.Errors; Down : Down_Interpretation; Store : Stored_Set; Stored : Stored_Interpretation; Name : Stored_Interpretation; Result : Type_Info; Found : Natural := 0; Success : Boolean; Formal : List_Index; Params : Asis.Association_List := Get_Call_Parameters (Element); begin -- Down_Function_Call D.Pop (Resolver.Stack, Down); Get (Resolver.Store, Element, Store); if Down.Kind = An_Expression then Result := Down.Expression_Type; Set_Expression_Type (Element, Down.Expression_Type); end if; if Down.Kind = A_Procedure_Call then for I in 1 .. Length (Store) loop Get (Store, I, Stored); if Stored.Kind = A_Procedure_Call then Found := Found + 1; if Found = 1 then Name := Stored; end if; end if; end loop; elsif Down.Kind = A_Family_Member then Name.Kind := A_Family; Found := 1; elsif Down.Kind = An_Expression then declare Names : Up_Interpretation_Set := Create; Next : Up_Interpretation; begin for I in 1 .. Length (Store) loop Get (Store, I, Stored); if Stored.Kind /= A_Procedure_Call and then Is_Expected_Type (Stored.Result_Type, Result) then Add (Names, Up_Expression (Stored.Result_Type)); end if; end loop; Select_Prefered (Names); for J in 1 .. Length (Names) loop Get (Names, J, Next); for I in 1 .. Length (Store) loop Get (Store, I, Stored); if Stored.Kind /= A_Procedure_Call and then Is_Equal (Stored.Result_Type, Next.Expression_Type) then Found := Found + 1; if Found = 1 then Name := Stored; end if; end if; end loop; end loop; Destroy (Names); end; end if; if Found = 0 then Report (Element, Error_No_Interprentation); else if Found > 1 then Report (Element, Error_Ambiguous_Interprentation); end if; case Name.Kind is when An_Array => Push_Array_Indexes (Resolver, Name.Down.Expression_Type); D.Push (Resolver.Stack, Up_Expression (Name.Down.Expression_Type)); R.Function_To_Indexed_Component (Element); when A_Slice => Push_Array_Indexes (Resolver, Name.Down.Expression_Type); D.Push (Resolver.Stack, Up_Expression (Name.Down.Expression_Type)); R.Function_To_Slice (Element); when A_Family => declare use Asis.Declarations; Tipe : Type_Info := Type_From_Discrete_Def (Entry_Family_Definition (Down.Declaration), Element); begin D.Push (Resolver.Stack, Up_Expression (Tipe)); D.Push (Resolver.Stack, (A_Declaration, Down.Declaration)); if Element_Kind (Element) = A_Statement then R.Procedure_To_Indexed_Entry_Call (Element); else R.Function_To_Indexed_Component (Element); end if; end; when A_Function_Call | A_Procedure_Call => declare Tipe : Type_Info; Profile : Asis.Parameter_Specification_List := Get_Profile (Name.Down); begin for Index in reverse Params'Range loop Find_Formal_Index (Params, Index, Profile, Formal, Success); if not Success then raise Internal_Error; end if; if Name.Real_Types = null or else Is_Not_Type (Name.Real_Types (Formal)) then Tipe := Get_Parameter_Type (Name.Down, Profile, Formal, Element); else Tipe := Name.Real_Types (Formal); end if; Down := (An_Expression, Tipe); D.Push (Resolver.Stack, Down); if not Is_Nil (Get_Formal_Parameter (Params, Index)) then Down := (A_Declaration, Profile (Formal)); D.Push (Resolver.Stack, Down); end if; end loop; Down := To_Down_Interpretation (Name.Down); D.Push (Resolver.Stack, Down); if (Down.Kind = A_Declaration or Down.Kind = A_Family_Member) and then Declaration_Kind (Down.Declaration) in An_Entry_Declaration .. An_Entry_Body_Declaration then Replace.Procedure_To_Entry_Call (Element); end if; end; when A_Type_Conversion => Down := To_Down_Interpretation (Name.Down); D.Push (Resolver.Stack, Down); D.Push (Resolver.Stack, (Kind => A_Skip)); R.Function_To_Type_Conversion (Element); when others => raise Internal_Error; end case; Set_Expression_Type (Element, Result); end if; Destroy (Store); end Function_Call; -------------------------------- -- Length_Attribute_Reference -- -------------------------------- procedure Length_Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element) is use Asis.Gela.Errors; use Asis.Expressions; Store : Stored_Set; Stored : Stored_Interpretation; Down : Down_Interpretation; List : constant Asis.Element_List := Attribute_Designator_Expressions (Element); begin Get (Resolver.Store, Element, Store); D.Pop (Resolver.Stack, Down); if Down.Kind /= An_Expression then raise Internal_Error; end if; Set_Expression_Type (Element, XASIS.Types.Universal_Integer); for I in reverse 1 .. List'Length loop Get (Store, I, Stored); Down := To_Down_Interpretation (Stored.Down); D.Push (Resolver.Stack, Down); end loop; Get (Store, List'Length + 1, Stored); Down := To_Down_Interpretation (Stored.Down); D.Push (Resolver.Stack, (Kind => A_Skip)); D.Push (Resolver.Stack, Down); Destroy (Store); end Length_Attribute_Reference; ---------------- -- Membership -- ---------------- procedure Membership (Resolver : in out Down_Resolver; Element : in out Asis.Element) is Store : Stored_Set; Stored : Stored_Interpretation; Down : Down_Interpretation; Kind : Asis.Expression_Kinds := Expression_Kind (Element); begin Get (Resolver.Store, Element, Store); D.Pop (Resolver.Stack, Down); if Length (Store) /= 1 then raise Internal_Error; end if; Get (Store, 1, Stored); if Kind in An_In_Range_Membership_Test .. A_Not_In_Range_Membership_Test then Down := To_Down_Interpretation (Stored.Down); else Down := (Kind => A_Skip); end if; D.Push (Resolver.Stack, Down); Down := Up_Expression (Stored.Result_Type); D.Push (Resolver.Stack, Down); Set_Expression_Type (Element, XASIS.Types.Boolean); Destroy (Store); end Membership; ------------------------ -- Push_Array_Indexes -- ------------------------ procedure Push_Array_Indexes (Resolver : in out Down_Resolver; Tipe : in Type_Info) is Index : Type_Info; begin for I in reverse 1 .. Array_Dimention (Tipe) loop Index := Get_Array_Index_Type (Tipe, I); D.Push (Resolver.Stack, Up_Expression (Index)); end loop; end Push_Array_Indexes; -------------------------- -- Qualified_Expression -- -------------------------- procedure Qualified_Expression (Resolver : in out Down_Resolver; Element : in out Asis.Element) is Down : Down_Interpretation; Store : Stored_Set; Stored : Stored_Interpretation; begin D.Pop (Resolver.Stack, Down); if Down.Kind = An_Expression then Set_Expression_Type (Element, Down.Expression_Type); end if; Get (Resolver.Store, Element, Store); if Length (Store) /= 1 then raise Internal_Error; end if; Get (Store, 1, Stored); if Stored.Kind = An_Array then D.Push (Resolver.Stack, Up_Expression (Stored.Result_Type)); else D.Push (Resolver.Stack, To_Down_Interpretation (Stored.Down)); end if; D.Push (Resolver.Stack, (Kind => A_Skip)); Destroy (Store); end Qualified_Expression; ------------------------ -- Selected_Component -- ------------------------ procedure Selected_Component (Resolver : in out Down_Resolver; Element : in Asis.Element) is use Asis.Gela.Errors; Down : Down_Interpretation; Next : Down_Interpretation; Store : Stored_Set; Stored : Stored_Interpretation; Found : Boolean := False; begin D.Pop (Resolver.Stack, Down); if Is_Expanded_Name (Element) then D.Push (Resolver.Stack, Down); D.Push (Resolver.Stack, (Kind => A_Skip)); return; end if; Get (Resolver.Store, Element, Store); for I in 1 .. Length (Store) loop Get (Store, I, Stored); case Stored.Kind is when A_Component => if Down.Kind = An_Expression and then Is_Expected_Type (Stored.Result_Type, Down.Expression_Type) then if Found then Report (Element, Error_Ambiguous_Interprentation); else Next := (A_Declaration, Stored.Component); D.Push (Resolver.Stack, Next); Next := To_Down_Interpretation (Stored.Down); D.Push (Resolver.Stack, Next); Found := True; Set_Expression_Type (Element, Down.Expression_Type); end if; end if; when A_Function_Call => if Down.Kind = A_Declaration then -- Is_Equal (Stored.Result_Type, Down.Declaration) then if Found then Report (Element, Error_Ambiguous_Interprentation); else D.Push (Resolver.Stack, Down); Next := To_Down_Interpretation (Stored.Down); D.Push (Resolver.Stack, Next); Found := True; end if; end if; when A_Subprogram_Reference => if Down.Kind = A_Prefixed_View and then Is_Equal (Stored.Component, Down.Declaration) then if Found then Report (Element, Error_Ambiguous_Interprentation); else Next := (A_Declaration, Stored.Component); D.Push (Resolver.Stack, Next); Next := To_Down_Interpretation (Stored.Down); D.Push (Resolver.Stack, Next); Found := True; end if; end if; when others => raise Internal_Error; end case; end loop; Destroy (Store); end Selected_Component; ------------------------- -- Set_Expression_Type -- ------------------------- procedure Set_Expression_Type (Element : Asis.Expression; Tipe : Type_Info) is Decl : Asis.Declaration := Get_Declaration (Tipe); begin -- if Is_Declaration (Tipe) and not Is_Anonymous_Access (Tipe) if not Is_Nil (Decl) then Set_Expression_Type (Element, Decl); end if; end Set_Expression_Type; ------------------------- -- Set_Expression_Type -- ------------------------- procedure Set_Expression_Type (Element : Asis.Expression; Tipe : Asis.Element) is use Asis.Elements; use Asis.Gela.Elements; begin case Element_Kind (Tipe) is when A_Declaration => Set_Corresponding_Expression_Type (Expression_Node'Class (Element.all), Tipe); when others => raise Internal_Error; end case; end Set_Expression_Type; -------------------------------- -- Simple_Attribute_Reference -- -------------------------------- procedure Simple_Attribute_Reference (Resolver : in out Down_Resolver; Element : in Asis.Element) is use Asis.Gela.Errors; use Asis.Expressions; Store : Stored_Set; Stored : Stored_Interpretation; Down : Down_Interpretation; begin Get (Resolver.Store, Element, Store); D.Pop (Resolver.Stack, Down); if Down.Kind = An_Expression then Set_Expression_Type (Element, Down.Expression_Type); elsif Down.Kind /= A_Declaration and Down.Kind /= An_Attribute_Function then raise Internal_Error; end if; if Length (Store) = 1 then Get (Store, 1, Stored); Down := To_Down_Interpretation (Stored.Down); else raise Internal_Error; end if; D.Push (Resolver.Stack, (Kind => A_Skip)); D.Push (Resolver.Stack, Down); Destroy (Store); end Simple_Attribute_Reference; end Asis.Gela.Overloads.Walk.Down; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- 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 Maxim Reznik, 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 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. ------------------------------------------------------------------------------
-- This spec has been automatically generated from STM32WL5x_CM0P.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.RCC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_MSIRANGE_Field is HAL.UInt4; -- Clock control register type CR_Register is record -- MSI clock enable MSION : Boolean := True; -- Read-only. MSI clock ready flag (After reset this bit will be read 1 -- once the MSI is ready) MSIRDY : Boolean := False; -- MSI clock PLL enable MSIPLLEN : Boolean := False; -- MSI range control selection MSIRGSEL : Boolean := False; -- MSI clock ranges MSIRANGE : CR_MSIRANGE_Field := 16#6#; -- HSI16 clock enable HSION : Boolean := False; -- HSI16 always enable for peripheral kernel clocks. HSIKERON : Boolean := False; -- Read-only. HSI16 clock ready flag. (After wakeup from Stop this bit -- will be read 1 once the HSI16 is ready) HSIRDY : Boolean := False; -- HSI16 automatic start from Stop HSIASFS : Boolean := False; -- Read-only. HSI16 kernel clock ready flag for peripherals requests. HSIKERDY : Boolean := False; -- unspecified Reserved_13_15 : HAL.UInt3 := 16#0#; -- HSE32 clock enable HSEON : Boolean := False; -- Read-only. HSE32 clock ready flag HSERDY : Boolean := False; -- unspecified Reserved_18_18 : HAL.Bit := 16#0#; -- HSE32 Clock security system enable CSSON : Boolean := False; -- HSE32 sysclk prescaler HSEPRE : Boolean := False; -- Enable HSE32 VDDTCXO output on package pin PB0-VDDTCXO. HSEBYPPWR : Boolean := False; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Main PLL enable PLLON : Boolean := False; -- Read-only. Main PLL clock ready flag PLLRDY : Boolean := False; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record MSION at 0 range 0 .. 0; MSIRDY at 0 range 1 .. 1; MSIPLLEN at 0 range 2 .. 2; MSIRGSEL at 0 range 3 .. 3; MSIRANGE at 0 range 4 .. 7; HSION at 0 range 8 .. 8; HSIKERON at 0 range 9 .. 9; HSIRDY at 0 range 10 .. 10; HSIASFS at 0 range 11 .. 11; HSIKERDY at 0 range 12 .. 12; Reserved_13_15 at 0 range 13 .. 15; HSEON at 0 range 16 .. 16; HSERDY at 0 range 17 .. 17; Reserved_18_18 at 0 range 18 .. 18; CSSON at 0 range 19 .. 19; HSEPRE at 0 range 20 .. 20; HSEBYPPWR at 0 range 21 .. 21; Reserved_22_23 at 0 range 22 .. 23; PLLON at 0 range 24 .. 24; PLLRDY at 0 range 25 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; subtype ICSCR_MSICAL_Field is HAL.UInt8; subtype ICSCR_MSITRIM_Field is HAL.UInt8; subtype ICSCR_HSICAL_Field is HAL.UInt8; subtype ICSCR_HSITRIM_Field is HAL.UInt7; -- Internal clock sources calibration register type ICSCR_Register is record -- Read-only. MSI clock calibration MSICAL : ICSCR_MSICAL_Field := 16#0#; -- MSI clock trimming MSITRIM : ICSCR_MSITRIM_Field := 16#0#; -- Read-only. HSI16 clock calibration HSICAL : ICSCR_HSICAL_Field := 16#0#; -- HSI16 clock trimming HSITRIM : ICSCR_HSITRIM_Field := 16#40#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICSCR_Register use record MSICAL at 0 range 0 .. 7; MSITRIM at 0 range 8 .. 15; HSICAL at 0 range 16 .. 23; HSITRIM at 0 range 24 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype CFGR_SW_Field is HAL.UInt2; subtype CFGR_SWS_Field is HAL.UInt2; subtype CFGR_HPRE_Field is HAL.UInt4; -- CFGR_PPRE array element subtype CFGR_PPRE_Element is HAL.UInt3; -- CFGR_PPRE array type CFGR_PPRE_Field_Array is array (1 .. 2) of CFGR_PPRE_Element with Component_Size => 3, Size => 6; -- Type definition for CFGR_PPRE type CFGR_PPRE_Field (As_Array : Boolean := False) is record case As_Array is when False => -- PPRE as a value Val : HAL.UInt6; when True => -- PPRE as an array Arr : CFGR_PPRE_Field_Array; end case; end record with Unchecked_Union, Size => 6; for CFGR_PPRE_Field use record Val at 0 range 0 .. 5; Arr at 0 range 0 .. 5; end record; subtype CFGR_MCOSEL_Field is HAL.UInt4; subtype CFGR_MCOPRE_Field is HAL.UInt3; -- Clock configuration register type CFGR_Register is record -- System clock switch SW : CFGR_SW_Field := 16#0#; -- Read-only. System clock switch status SWS : CFGR_SWS_Field := 16#0#; -- HCLK1 prescaler (CPU1, AHB1, AHB2, and SRAM1.) HPRE : CFGR_HPRE_Field := 16#0#; -- PCLK1 low-speed prescaler (APB1) PPRE : CFGR_PPRE_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_14_14 : HAL.Bit := 16#0#; -- Wakeup from Stop and CSS backup clock selection STOPWUCK : Boolean := False; -- Read-only. HCLK1 prescaler flag (CPU1, AHB1, AHB2, and SRAM1) HPREF : Boolean := True; -- Read-only. PCLK1 prescaler flag (APB1) PPRE1F : Boolean := True; -- Read-only. PCLK2 prescaler flag (APB2) PPRE2F : Boolean := True; -- unspecified Reserved_19_23 : HAL.UInt5 := 16#0#; -- Microcontroller clock output MCOSEL : CFGR_MCOSEL_Field := 16#0#; -- Microcontroller clock output prescaler MCOPRE : CFGR_MCOPRE_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CFGR_Register use record SW at 0 range 0 .. 1; SWS at 0 range 2 .. 3; HPRE at 0 range 4 .. 7; PPRE at 0 range 8 .. 13; Reserved_14_14 at 0 range 14 .. 14; STOPWUCK at 0 range 15 .. 15; HPREF at 0 range 16 .. 16; PPRE1F at 0 range 17 .. 17; PPRE2F at 0 range 18 .. 18; Reserved_19_23 at 0 range 19 .. 23; MCOSEL at 0 range 24 .. 27; MCOPRE at 0 range 28 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype PLLCFGR_PLLSRC_Field is HAL.UInt2; subtype PLLCFGR_PLLM_Field is HAL.UInt3; subtype PLLCFGR_PLLN_Field is HAL.UInt7; subtype PLLCFGR_PLLP_Field is HAL.UInt5; subtype PLLCFGR_PLLQ_Field is HAL.UInt3; subtype PLLCFGR_PLLR_Field is HAL.UInt3; -- PLL configuration register type PLLCFGR_Register is record -- Main PLL entry clock source PLLSRC : PLLCFGR_PLLSRC_Field := 16#0#; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- Division factor for the main PLL input clock PLLM : PLLCFGR_PLLM_Field := 16#0#; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Main PLL multiplication factor for VCO PLLN : PLLCFGR_PLLN_Field := 16#1#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Main PLL PLLPCLK output enable PLLPEN : Boolean := False; -- Main PLL division factor for PLLPCLK. PLLP : PLLCFGR_PLLP_Field := 16#2#; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Main PLL PLLQCLK output enable PLLQEN : Boolean := False; -- Main PLL division factor for PLLQCLK PLLQ : PLLCFGR_PLLQ_Field := 16#1#; -- Main PLL PLLRCLK output enable PLLREN : Boolean := False; -- Main PLL division factor for PLLRCLK PLLR : PLLCFGR_PLLR_Field := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PLLCFGR_Register use record PLLSRC at 0 range 0 .. 1; Reserved_2_3 at 0 range 2 .. 3; PLLM at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; PLLN at 0 range 8 .. 14; Reserved_15_15 at 0 range 15 .. 15; PLLPEN at 0 range 16 .. 16; PLLP at 0 range 17 .. 21; Reserved_22_23 at 0 range 22 .. 23; PLLQEN at 0 range 24 .. 24; PLLQ at 0 range 25 .. 27; PLLREN at 0 range 28 .. 28; PLLR at 0 range 29 .. 31; end record; -- Clock interrupt enable register type CIER_Register is record -- LSI ready interrupt enable LSIRDYIE : Boolean := False; -- LSE ready interrupt enable LSERDYIE : Boolean := False; -- MSI ready interrupt enable MSIRDYIE : Boolean := False; -- HSI16 ready interrupt enable HSIRDYIE : Boolean := False; -- HSE32 ready interrupt enable HSERDYIE : Boolean := False; -- PLL ready interrupt enable PLLRDYIE : Boolean := False; -- unspecified Reserved_6_8 : HAL.UInt3 := 16#0#; -- LSE clock security system interrupt enable LSECSSIE : Boolean := False; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CIER_Register use record LSIRDYIE at 0 range 0 .. 0; LSERDYIE at 0 range 1 .. 1; MSIRDYIE at 0 range 2 .. 2; HSIRDYIE at 0 range 3 .. 3; HSERDYIE at 0 range 4 .. 4; PLLRDYIE at 0 range 5 .. 5; Reserved_6_8 at 0 range 6 .. 8; LSECSSIE at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- Clock interrupt flag register type CIFR_Register is record -- Read-only. LSI ready interrupt flag LSIRDYF : Boolean; -- Read-only. LSE ready interrupt flag LSERDYF : Boolean; -- Read-only. MSI ready interrupt flag MSIRDYF : Boolean; -- Read-only. HSI16 ready interrupt flag HSIRDYF : Boolean; -- Read-only. HSE32 ready interrupt flag HSERDYF : Boolean; -- Read-only. PLL ready interrupt flag PLLRDYF : Boolean; -- unspecified Reserved_6_7 : HAL.UInt2; -- Read-only. HSE32 Clock security system interrupt flag CSSF : Boolean; -- Read-only. LSE Clock security system interrupt flag LSECSSF : Boolean; -- unspecified Reserved_10_31 : HAL.UInt22; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CIFR_Register use record LSIRDYF at 0 range 0 .. 0; LSERDYF at 0 range 1 .. 1; MSIRDYF at 0 range 2 .. 2; HSIRDYF at 0 range 3 .. 3; HSERDYF at 0 range 4 .. 4; PLLRDYF at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; CSSF at 0 range 8 .. 8; LSECSSF at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- Clock interrupt clear register type CICR_Register is record -- Write-only. LSI ready interrupt clear LSIRDYC : Boolean := False; -- Write-only. LSE ready interrupt clear LSERDYC : Boolean := False; -- Write-only. MSI ready interrupt clear MSIRDYC : Boolean := False; -- Write-only. HSI16 ready interrupt clear HSIRDYC : Boolean := False; -- Write-only. HSE32 ready interrupt clear HSERDYC : Boolean := False; -- Write-only. PLL ready interrupt clear PLLRDYC : Boolean := False; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; -- Write-only. HSE32 Clock security system interrupt clear CSSC : Boolean := False; -- Write-only. LSE Clock security system interrupt clear LSECSSC : Boolean := False; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CICR_Register use record LSIRDYC at 0 range 0 .. 0; LSERDYC at 0 range 1 .. 1; MSIRDYC at 0 range 2 .. 2; HSIRDYC at 0 range 3 .. 3; HSERDYC at 0 range 4 .. 4; PLLRDYC at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; CSSC at 0 range 8 .. 8; LSECSSC at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- AHB1 peripheral reset register type AHB1RSTR_Register is record -- DMA1 reset DMA1RST : Boolean := False; -- DMA2 reset DMA2RST : Boolean := False; -- DMAMUX1 reset DMAMUX1RST : Boolean := False; -- unspecified Reserved_3_11 : HAL.UInt9 := 16#0#; -- CRC reset CRCRST : Boolean := False; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB1RSTR_Register use record DMA1RST at 0 range 0 .. 0; DMA2RST at 0 range 1 .. 1; DMAMUX1RST at 0 range 2 .. 2; Reserved_3_11 at 0 range 3 .. 11; CRCRST at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; -- AHB2 peripheral reset register type AHB2RSTR_Register is record -- IO port A reset GPIOARST : Boolean := False; -- IO port B reset GPIOBRST : Boolean := False; -- IO port C reset GPIOCRST : Boolean := False; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- IO port H reset GPIOHRST : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB2RSTR_Register use record GPIOARST at 0 range 0 .. 0; GPIOBRST at 0 range 1 .. 1; GPIOCRST at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; GPIOHRST at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- AHB3 peripheral reset register type AHB3RSTR_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- PKARST PKARST : Boolean := False; -- AESRST AESRST : Boolean := False; -- RNGRST RNGRST : Boolean := False; -- HSEMRST HSEMRST : Boolean := False; -- IPCCRST IPCCRST : Boolean := False; -- unspecified Reserved_21_24 : HAL.UInt4 := 16#0#; -- Flash interface reset FLASHRST : Boolean := False; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB3RSTR_Register use record Reserved_0_15 at 0 range 0 .. 15; PKARST at 0 range 16 .. 16; AESRST at 0 range 17 .. 17; RNGRST at 0 range 18 .. 18; HSEMRST at 0 range 19 .. 19; IPCCRST at 0 range 20 .. 20; Reserved_21_24 at 0 range 21 .. 24; FLASHRST at 0 range 25 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; -- APB1 peripheral reset register 1 type APB1RSTR1_Register is record -- TIM2 timer reset TIM2RST : Boolean := False; -- unspecified Reserved_1_13 : HAL.UInt13 := 16#0#; -- SPI2S2 reset SPI2S2RST : Boolean := False; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- USART2 reset USART2RST : Boolean := False; -- unspecified Reserved_18_20 : HAL.UInt3 := 16#0#; -- I2C1 reset I2C1RST : Boolean := False; -- I2C2 reset I2C2RST : Boolean := False; -- I2C3 reset I2C3RST : Boolean := False; -- unspecified Reserved_24_28 : HAL.UInt5 := 16#0#; -- DAC1 reset DACRST : Boolean := False; -- unspecified Reserved_30_30 : HAL.Bit := 16#0#; -- Low Power Timer 1 reset LPTIM1RST : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB1RSTR1_Register use record TIM2RST at 0 range 0 .. 0; Reserved_1_13 at 0 range 1 .. 13; SPI2S2RST at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; USART2RST at 0 range 17 .. 17; Reserved_18_20 at 0 range 18 .. 20; I2C1RST at 0 range 21 .. 21; I2C2RST at 0 range 22 .. 22; I2C3RST at 0 range 23 .. 23; Reserved_24_28 at 0 range 24 .. 28; DACRST at 0 range 29 .. 29; Reserved_30_30 at 0 range 30 .. 30; LPTIM1RST at 0 range 31 .. 31; end record; -- APB1 peripheral reset register 2 type APB1RSTR2_Register is record -- Low-power UART 1 reset LPUART1RST : Boolean := False; -- unspecified Reserved_1_4 : HAL.UInt4 := 16#0#; -- Low-power timer 2 reset LPTIM2RST : Boolean := False; -- Low-power timer 3 reset LPTIM3RST : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB1RSTR2_Register use record LPUART1RST at 0 range 0 .. 0; Reserved_1_4 at 0 range 1 .. 4; LPTIM2RST at 0 range 5 .. 5; LPTIM3RST at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- APB2 peripheral reset register type APB2RSTR_Register is record -- unspecified Reserved_0_8 : HAL.UInt9 := 16#0#; -- ADC reset ADCRST : Boolean := False; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- TIM1 timer reset TIM1RST : Boolean := False; -- SPI1 reset SPI1RST : Boolean := False; -- unspecified Reserved_13_13 : HAL.Bit := 16#0#; -- USART1 reset USART1RST : Boolean := False; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- TIM16 timer reset TIM16RST : Boolean := False; -- TIM17 timer reset TIM17RST : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB2RSTR_Register use record Reserved_0_8 at 0 range 0 .. 8; ADCRST at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; TIM1RST at 0 range 11 .. 11; SPI1RST at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; USART1RST at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; TIM16RST at 0 range 17 .. 17; TIM17RST at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- APB3 peripheral reset register type APB3RSTR_Register is record -- Sub-GHz radio SPI reset SUBGHZSPIRST : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB3RSTR_Register use record SUBGHZSPIRST at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AHB1 peripheral clock enable register type AHB1ENR_Register is record -- CPU1 DMA1 clock enable DMA1EN : Boolean := False; -- CPU1 DMA2 clock enable DMA2EN : Boolean := False; -- CPU1 DMAMUX1 clock enable DMAMUX1EN : Boolean := False; -- unspecified Reserved_3_11 : HAL.UInt9 := 16#0#; -- CPU1 CRC clock enable CRCEN : Boolean := False; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB1ENR_Register use record DMA1EN at 0 range 0 .. 0; DMA2EN at 0 range 1 .. 1; DMAMUX1EN at 0 range 2 .. 2; Reserved_3_11 at 0 range 3 .. 11; CRCEN at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; -- AHB2 peripheral clock enable register type AHB2ENR_Register is record -- CPU1 IO port A clock enable GPIOAEN : Boolean := False; -- CPU1 IO port B clock enable GPIOBEN : Boolean := False; -- CPU1 IO port C clock enable GPIOCEN : Boolean := False; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- CPU1 IO port H clock enable GPIOHEN : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB2ENR_Register use record GPIOAEN at 0 range 0 .. 0; GPIOBEN at 0 range 1 .. 1; GPIOCEN at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; GPIOHEN at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- AHB3 peripheral clock enable register type AHB3ENR_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- PKAEN PKAEN : Boolean := False; -- AESEN AESEN : Boolean := False; -- RNGEN RNGEN : Boolean := False; -- HSEMEN HSEMEN : Boolean := True; -- IPCCEN IPCCEN : Boolean := False; -- unspecified Reserved_21_24 : HAL.UInt4 := 16#0#; -- CPU1 Flash interface clock enable FLASHEN : Boolean := True; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB3ENR_Register use record Reserved_0_15 at 0 range 0 .. 15; PKAEN at 0 range 16 .. 16; AESEN at 0 range 17 .. 17; RNGEN at 0 range 18 .. 18; HSEMEN at 0 range 19 .. 19; IPCCEN at 0 range 20 .. 20; Reserved_21_24 at 0 range 21 .. 24; FLASHEN at 0 range 25 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; -- APB1 peripheral clock enable register 1 type APB1ENR1_Register is record -- CPU1 TIM2 timer clock enable TIM2EN : Boolean := False; -- unspecified Reserved_1_9 : HAL.UInt9 := 16#0#; -- CPU1 RTC APB clock enable RTCAPBEN : Boolean := False; -- CPU1 Window watchdog clock enable WWDGEN : Boolean := False; -- unspecified Reserved_12_13 : HAL.UInt2 := 16#0#; -- CPU1 SPI2S2 clock enable SPI2S2EN : Boolean := False; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- CPU1 USART2 clock enable USART2EN : Boolean := False; -- unspecified Reserved_18_20 : HAL.UInt3 := 16#0#; -- CPU1 I2C1 clocks enable I2C1EN : Boolean := False; -- CPU1 I2C2 clocks enable I2C2EN : Boolean := False; -- CPU1 I2C3 clocks enable I2C3EN : Boolean := False; -- unspecified Reserved_24_28 : HAL.UInt5 := 16#0#; -- CPU1 DAC1 clock enable DAC1EN : Boolean := False; -- unspecified Reserved_30_30 : HAL.Bit := 16#0#; -- CPU1 Low power timer 1 clocks enable LPTIM1EN : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB1ENR1_Register use record TIM2EN at 0 range 0 .. 0; Reserved_1_9 at 0 range 1 .. 9; RTCAPBEN at 0 range 10 .. 10; WWDGEN at 0 range 11 .. 11; Reserved_12_13 at 0 range 12 .. 13; SPI2S2EN at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; USART2EN at 0 range 17 .. 17; Reserved_18_20 at 0 range 18 .. 20; I2C1EN at 0 range 21 .. 21; I2C2EN at 0 range 22 .. 22; I2C3EN at 0 range 23 .. 23; Reserved_24_28 at 0 range 24 .. 28; DAC1EN at 0 range 29 .. 29; Reserved_30_30 at 0 range 30 .. 30; LPTIM1EN at 0 range 31 .. 31; end record; -- APB1 peripheral clock enable register 2 type APB1ENR2_Register is record -- CPU1 Low power UART 1 clocks enable LPUART1EN : Boolean := False; -- unspecified Reserved_1_4 : HAL.UInt4 := 16#0#; -- CPU1 Low power timer 2 clocks enable LPTIM2EN : Boolean := False; -- CPU1 Low power timer 3 clocks enable LPTIM3EN : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB1ENR2_Register use record LPUART1EN at 0 range 0 .. 0; Reserved_1_4 at 0 range 1 .. 4; LPTIM2EN at 0 range 5 .. 5; LPTIM3EN at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- APB2 peripheral clock enable register type APB2ENR_Register is record -- unspecified Reserved_0_8 : HAL.UInt9 := 16#0#; -- CPU1 ADC clocks enable ADCEN : Boolean := False; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- CPU1 TIM1 timer clock enable TIM1EN : Boolean := False; -- CPU1 SPI1 clock enable SPI1EN : Boolean := False; -- unspecified Reserved_13_13 : HAL.Bit := 16#0#; -- CPU1 USART1clocks enable USART1EN : Boolean := False; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- CPU1 TIM16 timer clock enable TIM16EN : Boolean := False; -- CPU1 TIM17 timer clock enable TIM17EN : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB2ENR_Register use record Reserved_0_8 at 0 range 0 .. 8; ADCEN at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; TIM1EN at 0 range 11 .. 11; SPI1EN at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; USART1EN at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; TIM16EN at 0 range 17 .. 17; TIM17EN at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- APB3 peripheral clock enable register type APB3ENR_Register is record -- sub-GHz radio SPI clock enable SUBGHZSPIEN : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB3ENR_Register use record SUBGHZSPIEN at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AHB1 peripheral clocks enable in Sleep modes register type AHB1SMENR_Register is record -- DMA1 clock enable during CPU1 CSleep mode. DMA1SMEN : Boolean := True; -- DMA2 clock enable during CPU1 CSleep mode DMA2SMEN : Boolean := True; -- DMAMUX1 clock enable during CPU1 CSleep mode. DMAMUX1SMEN : Boolean := True; -- unspecified Reserved_3_11 : HAL.UInt9 := 16#0#; -- CRC clock enable during CPU1 CSleep mode. CRCSMEN : Boolean := True; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB1SMENR_Register use record DMA1SMEN at 0 range 0 .. 0; DMA2SMEN at 0 range 1 .. 1; DMAMUX1SMEN at 0 range 2 .. 2; Reserved_3_11 at 0 range 3 .. 11; CRCSMEN at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; -- AHB2 peripheral clocks enable in Sleep modes register type AHB2SMENR_Register is record -- IO port A clock enable during CPU1 CSleep mode. GPIOASMEN : Boolean := True; -- IO port B clock enable during CPU1 CSleep mode. GPIOBSMEN : Boolean := True; -- IO port C clock enable during CPU1 CSleep mode. GPIOCSMEN : Boolean := True; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- IO port H clock enable during CPU1 CSleep mode. GPIOHSMEN : Boolean := True; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB2SMENR_Register use record GPIOASMEN at 0 range 0 .. 0; GPIOBSMEN at 0 range 1 .. 1; GPIOCSMEN at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; GPIOHSMEN at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- AHB3 peripheral clocks enable in Sleep and Stop modes register type AHB3SMENR_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- PKA accelerator clock enable during CPU1 CSleep mode. PKASMEN : Boolean := True; -- AES accelerator clock enable during CPU1 CSleep mode. AESSMEN : Boolean := True; -- True RNG clocks enable during CPU1 Csleep and CStop modes RNGSMEN : Boolean := True; -- unspecified Reserved_19_22 : HAL.UInt4 := 16#0#; -- SRAM1 interface clock enable during CPU1 CSleep mode. SRAM1SMEN : Boolean := True; -- SRAM2 memory interface clock enable during CPU1 CSleep mode SRAM2SMEN : Boolean := True; -- Flash interface clock enable during CPU1 CSleep mode. FLASHSMEN : Boolean := True; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AHB3SMENR_Register use record Reserved_0_15 at 0 range 0 .. 15; PKASMEN at 0 range 16 .. 16; AESSMEN at 0 range 17 .. 17; RNGSMEN at 0 range 18 .. 18; Reserved_19_22 at 0 range 19 .. 22; SRAM1SMEN at 0 range 23 .. 23; SRAM2SMEN at 0 range 24 .. 24; FLASHSMEN at 0 range 25 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; -- APB1 peripheral clocks enable in Sleep mode register 1 type APB1SMENR1_Register is record -- TIM2 timer clock enable during CPU1 CSleep mode. TIM2SMEN : Boolean := True; -- unspecified Reserved_1_9 : HAL.UInt9 := 16#0#; -- RTC bus clock enable during CPU1 CSleep mode. RTCAPBSMEN : Boolean := True; -- Window watchdog clocks enable during CPU1 CSleep mode. WWDGSMEN : Boolean := True; -- unspecified Reserved_12_13 : HAL.UInt2 := 16#0#; -- SPI2S2 clock enable during CPU1 CSleep mode. SPI2S2SMEN : Boolean := True; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- USART2 clock enable during CPU1 CSleep mode. USART2SMEN : Boolean := True; -- unspecified Reserved_18_20 : HAL.UInt3 := 16#0#; -- I2C1 clock enable during CPU1 Csleep and CStop modes I2C1SMEN : Boolean := True; -- I2C2 clock enable during CPU1 Csleep and CStop modes I2C2SMEN : Boolean := True; -- I2C3 clock enable during CPU1 Csleep and CStop modes I2C3SMEN : Boolean := True; -- unspecified Reserved_24_28 : HAL.UInt5 := 16#0#; -- DAC1 clock enable during CPU1 CSleep mode. DACSMEN : Boolean := True; -- unspecified Reserved_30_30 : HAL.Bit := 16#0#; -- Low power timer 1 clock enable during CPU1 Csleep and CStop mode LPTIM1SMEN : Boolean := True; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB1SMENR1_Register use record TIM2SMEN at 0 range 0 .. 0; Reserved_1_9 at 0 range 1 .. 9; RTCAPBSMEN at 0 range 10 .. 10; WWDGSMEN at 0 range 11 .. 11; Reserved_12_13 at 0 range 12 .. 13; SPI2S2SMEN at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; USART2SMEN at 0 range 17 .. 17; Reserved_18_20 at 0 range 18 .. 20; I2C1SMEN at 0 range 21 .. 21; I2C2SMEN at 0 range 22 .. 22; I2C3SMEN at 0 range 23 .. 23; Reserved_24_28 at 0 range 24 .. 28; DACSMEN at 0 range 29 .. 29; Reserved_30_30 at 0 range 30 .. 30; LPTIM1SMEN at 0 range 31 .. 31; end record; -- APB1 peripheral clocks enable in Sleep mode register 2 type APB1SMENR2_Register is record -- Low power UART 1 clock enable during CPU1 Csleep and CStop modes. LPUART1SMEN : Boolean := True; -- unspecified Reserved_1_4 : HAL.UInt4 := 16#0#; -- Low power timer 2 clock enable during CPU1 Csleep and CStop modes LPTIM2SMEN : Boolean := True; -- Low power timer 3 clock enable during CPU1 Csleep and CStop modes LPTIM3SMEN : Boolean := True; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB1SMENR2_Register use record LPUART1SMEN at 0 range 0 .. 0; Reserved_1_4 at 0 range 1 .. 4; LPTIM2SMEN at 0 range 5 .. 5; LPTIM3SMEN at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- APB2 peripheral clocks enable in Sleep mode register type APB2SMENR_Register is record -- unspecified Reserved_0_8 : HAL.UInt9 := 16#0#; -- ADC clocks enable during CPU1 Csleep and CStop modes ADCSMEN : Boolean := True; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- TIM1 timer clock enable during CPU1 CSleep mode. TIM1SMEN : Boolean := True; -- SPI1 clock enable during CPU1 CSleep mode. SPI1SMEN : Boolean := True; -- unspecified Reserved_13_13 : HAL.Bit := 16#0#; -- USART1 clock enable during CPU1 Csleep and CStop modes. USART1SMEN : Boolean := True; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- TIM16 timer clock enable during CPU1 CSleep mode. TIM16SMEN : Boolean := True; -- TIM17 timer clock enable during CPU1 CSleep mode. TIM17SMEN : Boolean := True; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB2SMENR_Register use record Reserved_0_8 at 0 range 0 .. 8; ADCSMEN at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; TIM1SMEN at 0 range 11 .. 11; SPI1SMEN at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; USART1SMEN at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; TIM16SMEN at 0 range 17 .. 17; TIM17SMEN at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- APB3 peripheral clock enable in Sleep mode register type APB3SMENR_Register is record -- Sub-GHz radio SPI clock enable during Sleep and Stop modes SUBGHZSPISMEN : Boolean := True; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for APB3SMENR_Register use record SUBGHZSPISMEN at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; subtype CCIPR_USART1SEL_Field is HAL.UInt2; subtype CCIPR_USART2SEL_Field is HAL.UInt2; subtype CCIPR_SPI2S2SEL_Field is HAL.UInt2; subtype CCIPR_LPUART1SEL_Field is HAL.UInt2; subtype CCIPR_I2C1SEL_Field is HAL.UInt2; subtype CCIPR_I2C2SEL_Field is HAL.UInt2; subtype CCIPR_I2C3SEL_Field is HAL.UInt2; subtype CCIPR_LPTIM1SEL_Field is HAL.UInt2; subtype CCIPR_LPTIM2SEL_Field is HAL.UInt2; subtype CCIPR_LPTIM3SEL_Field is HAL.UInt2; subtype CCIPR_ADCSEL_Field is HAL.UInt2; subtype CCIPR_RNGSEL_Field is HAL.UInt2; -- Peripherals independent clock configuration register type CCIPR_Register is record -- USART1 clock source selection USART1SEL : CCIPR_USART1SEL_Field := 16#0#; -- USART2 clock source selection USART2SEL : CCIPR_USART2SEL_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- SPI2S2 I2S clock source selection SPI2S2SEL : CCIPR_SPI2S2SEL_Field := 16#0#; -- LPUART1 clock source selection LPUART1SEL : CCIPR_LPUART1SEL_Field := 16#0#; -- I2C1 clock source selection I2C1SEL : CCIPR_I2C1SEL_Field := 16#0#; -- I2C2 clock source selection I2C2SEL : CCIPR_I2C2SEL_Field := 16#0#; -- I2C3 clock source selection I2C3SEL : CCIPR_I2C3SEL_Field := 16#0#; -- Low power timer 1 clock source selection LPTIM1SEL : CCIPR_LPTIM1SEL_Field := 16#0#; -- Low power timer 2 clock source selection LPTIM2SEL : CCIPR_LPTIM2SEL_Field := 16#0#; -- Low power timer 3 clock source selection LPTIM3SEL : CCIPR_LPTIM3SEL_Field := 16#0#; -- unspecified Reserved_24_27 : HAL.UInt4 := 16#0#; -- ADC clock source selection ADCSEL : CCIPR_ADCSEL_Field := 16#0#; -- RNG clock source selection RNGSEL : CCIPR_RNGSEL_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CCIPR_Register use record USART1SEL at 0 range 0 .. 1; USART2SEL at 0 range 2 .. 3; Reserved_4_7 at 0 range 4 .. 7; SPI2S2SEL at 0 range 8 .. 9; LPUART1SEL at 0 range 10 .. 11; I2C1SEL at 0 range 12 .. 13; I2C2SEL at 0 range 14 .. 15; I2C3SEL at 0 range 16 .. 17; LPTIM1SEL at 0 range 18 .. 19; LPTIM2SEL at 0 range 20 .. 21; LPTIM3SEL at 0 range 22 .. 23; Reserved_24_27 at 0 range 24 .. 27; ADCSEL at 0 range 28 .. 29; RNGSEL at 0 range 30 .. 31; end record; subtype BDCR_LSEDRV_Field is HAL.UInt2; subtype BDCR_RTCSEL_Field is HAL.UInt2; -- Backup domain control register type BDCR_Register is record -- LSE oscillator enable LSEON : Boolean := False; -- Read-only. LSE oscillator ready LSERDY : Boolean := False; -- LSE oscillator bypass LSEBYP : Boolean := False; -- LSE oscillator drive capability LSEDRV : BDCR_LSEDRV_Field := 16#0#; -- CSS on LSE enable LSECSSON : Boolean := False; -- Read-only. CSS on LSE failure Detection LSECSSD : Boolean := False; -- LSE system clock enable LSESYSEN : Boolean := False; -- RTC clock source selection RTCSEL : BDCR_RTCSEL_Field := 16#0#; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- Read-only. LSE system clock ready LSESYSRDY : Boolean := False; -- unspecified Reserved_12_14 : HAL.UInt3 := 16#0#; -- RTC clock enable RTCEN : Boolean := False; -- Backup domain software reset BDRST : Boolean := False; -- unspecified Reserved_17_23 : HAL.UInt7 := 16#0#; -- Low speed clock output enable LSCOEN : Boolean := False; -- Low speed clock output selection LSCOSEL : Boolean := False; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for BDCR_Register use record LSEON at 0 range 0 .. 0; LSERDY at 0 range 1 .. 1; LSEBYP at 0 range 2 .. 2; LSEDRV at 0 range 3 .. 4; LSECSSON at 0 range 5 .. 5; LSECSSD at 0 range 6 .. 6; LSESYSEN at 0 range 7 .. 7; RTCSEL at 0 range 8 .. 9; Reserved_10_10 at 0 range 10 .. 10; LSESYSRDY at 0 range 11 .. 11; Reserved_12_14 at 0 range 12 .. 14; RTCEN at 0 range 15 .. 15; BDRST at 0 range 16 .. 16; Reserved_17_23 at 0 range 17 .. 23; LSCOEN at 0 range 24 .. 24; LSCOSEL at 0 range 25 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; subtype CSR_MSISRANGE_Field is HAL.UInt4; -- Control/status register type CSR_Register is record -- LSI oscillator enable LSION : Boolean := False; -- Read-only. LSI oscillator ready LSIRDY : Boolean := False; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- LSI frequency prescaler LSIPRE : Boolean := False; -- unspecified Reserved_5_7 : HAL.UInt3 := 16#0#; -- MSI clock ranges MSISRANGE : CSR_MSISRANGE_Field := 16#6#; -- unspecified Reserved_12_13 : HAL.UInt2 := 16#0#; -- Read-only. Radio in reset status flag RFRSTF : Boolean := True; -- Radio reset RFRST : Boolean := True; -- unspecified Reserved_16_22 : HAL.UInt7 := 16#1#; -- Remove reset flag RMVF : Boolean := False; -- Read-only. Radio illegal access flag RFILARSTF : Boolean := False; -- Read-only. Option byte loader reset flag OBLRSTF : Boolean := False; -- Read-only. Pin reset flag PINRSTF : Boolean := True; -- Read-only. BOR flag BORRSTF : Boolean := True; -- Read-only. Software reset flag SFTRSTF : Boolean := False; -- Read-only. Independent window watchdog reset flag IWDGRSTF : Boolean := False; -- Read-only. Window watchdog reset flag WWDGRSTF : Boolean := False; -- Read-only. Low-power reset flag LPWRRSTF : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record LSION at 0 range 0 .. 0; LSIRDY at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; LSIPRE at 0 range 4 .. 4; Reserved_5_7 at 0 range 5 .. 7; MSISRANGE at 0 range 8 .. 11; Reserved_12_13 at 0 range 12 .. 13; RFRSTF at 0 range 14 .. 14; RFRST at 0 range 15 .. 15; Reserved_16_22 at 0 range 16 .. 22; RMVF at 0 range 23 .. 23; RFILARSTF at 0 range 24 .. 24; OBLRSTF at 0 range 25 .. 25; PINRSTF at 0 range 26 .. 26; BORRSTF at 0 range 27 .. 27; SFTRSTF at 0 range 28 .. 28; IWDGRSTF at 0 range 29 .. 29; WWDGRSTF at 0 range 30 .. 30; LPWRRSTF at 0 range 31 .. 31; end record; subtype EXTCFGR_SHDHPRE_Field is HAL.UInt4; subtype EXTCFGR_C2HPRE_Field is HAL.UInt4; -- Extended clock recovery register type EXTCFGR_Register is record -- HCLK3 shared prescaler (AHB3, Flash, and SRAM2) SHDHPRE : EXTCFGR_SHDHPRE_Field := 16#0#; -- [dual core device only] HCLK2 prescaler (CPU2) C2HPRE : EXTCFGR_C2HPRE_Field := 16#0#; -- unspecified Reserved_8_15 : HAL.UInt8 := 16#0#; -- Read-only. HCLK3 shared prescaler flag (AHB3, Flash, and SRAM2) SHDHPREF : Boolean := True; -- Read-only. CLK2 prescaler flag (CPU2) C2HPREF : Boolean := True; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for EXTCFGR_Register use record SHDHPRE at 0 range 0 .. 3; C2HPRE at 0 range 4 .. 7; Reserved_8_15 at 0 range 8 .. 15; SHDHPREF at 0 range 16 .. 16; C2HPREF at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- CPU2 AHB1 peripheral clock enable register type C2AHB1ENR_Register is record -- CPU2 DMA1 clock enable DMA1EN : Boolean := False; -- CPU2 DMA2 clock enable DMA2EN : Boolean := False; -- CPU2 DMAMUX1 clock enable DMAMUX1EN : Boolean := False; -- unspecified Reserved_3_11 : HAL.UInt9 := 16#0#; -- CPU2 CRC clock enable CRCEN : Boolean := False; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2AHB1ENR_Register use record DMA1EN at 0 range 0 .. 0; DMA2EN at 0 range 1 .. 1; DMAMUX1EN at 0 range 2 .. 2; Reserved_3_11 at 0 range 3 .. 11; CRCEN at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; -- CPU2 AHB2 peripheral clock enable register type C2AHB2ENR_Register is record -- CPU2 IO port A clock enable GPIOAEN : Boolean := False; -- CPU2 IO port B clock enable GPIOBEN : Boolean := False; -- CPU2 IO port C clock enable GPIOCEN : Boolean := False; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- CPU2 IO port H clock enable GPIOHEN : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2AHB2ENR_Register use record GPIOAEN at 0 range 0 .. 0; GPIOBEN at 0 range 1 .. 1; GPIOCEN at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; GPIOHEN at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- CPU2 AHB3 peripheral clock enable register [dual core device only] type C2AHB3ENR_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- CPU2 PKA accelerator clock enable PKAEN : Boolean := False; -- CPU2 AES accelerator clock enable AESEN : Boolean := False; -- CPU2 True RNG clocks enable RNGEN : Boolean := False; -- CPU2 HSEM clock enable HSEMEN : Boolean := True; -- CPU2 IPCC interface clock enable IPCCEN : Boolean := False; -- unspecified Reserved_21_24 : HAL.UInt4 := 16#0#; -- CPU2 Flash interface clock enable FLASHEN : Boolean := True; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2AHB3ENR_Register use record Reserved_0_15 at 0 range 0 .. 15; PKAEN at 0 range 16 .. 16; AESEN at 0 range 17 .. 17; RNGEN at 0 range 18 .. 18; HSEMEN at 0 range 19 .. 19; IPCCEN at 0 range 20 .. 20; Reserved_21_24 at 0 range 21 .. 24; FLASHEN at 0 range 25 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; -- CPU2 APB1 peripheral clock enable register 1 [dual core device only] type C2APB1ENR1_Register is record -- CPU2 TIM2 timer clock enable TIM2EN : Boolean := False; -- unspecified Reserved_1_9 : HAL.UInt9 := 16#0#; -- CPU2 RTC APB clock enable RTCAPBEN : Boolean := False; -- unspecified Reserved_11_13 : HAL.UInt3 := 16#0#; -- CPU2 SPI2S2 clock enable SPI2S2EN : Boolean := False; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- CPU2 USART2 clock enable USART2EN : Boolean := False; -- unspecified Reserved_18_20 : HAL.UInt3 := 16#0#; -- CPU2 I2C1 clocks enable I2C1EN : Boolean := False; -- CPU2 I2C2 clocks enable I2C2EN : Boolean := False; -- CPU2 I2C3 clocks enable I2C3EN : Boolean := False; -- unspecified Reserved_24_28 : HAL.UInt5 := 16#0#; -- CPU2 DAC1 clock enable DAC1EN : Boolean := False; -- unspecified Reserved_30_30 : HAL.Bit := 16#0#; -- CPU2 Low power timer 1 clocks enable LPTIM1EN : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2APB1ENR1_Register use record TIM2EN at 0 range 0 .. 0; Reserved_1_9 at 0 range 1 .. 9; RTCAPBEN at 0 range 10 .. 10; Reserved_11_13 at 0 range 11 .. 13; SPI2S2EN at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; USART2EN at 0 range 17 .. 17; Reserved_18_20 at 0 range 18 .. 20; I2C1EN at 0 range 21 .. 21; I2C2EN at 0 range 22 .. 22; I2C3EN at 0 range 23 .. 23; Reserved_24_28 at 0 range 24 .. 28; DAC1EN at 0 range 29 .. 29; Reserved_30_30 at 0 range 30 .. 30; LPTIM1EN at 0 range 31 .. 31; end record; -- CPU2 APB1 peripheral clock enable register 2 [dual core device only] type C2APB1ENR2_Register is record -- CPU2 Low power UART 1 clocks enable LPUART1EN : Boolean := False; -- unspecified Reserved_1_4 : HAL.UInt4 := 16#0#; -- CPU2 Low power timer 2 clocks enable LPTIM2EN : Boolean := False; -- CPU2 Low power timer 3 clocks enable LPTIM3EN : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2APB1ENR2_Register use record LPUART1EN at 0 range 0 .. 0; Reserved_1_4 at 0 range 1 .. 4; LPTIM2EN at 0 range 5 .. 5; LPTIM3EN at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- CPU2 APB2 peripheral clock enable register [dual core device only] type C2APB2ENR_Register is record -- unspecified Reserved_0_8 : HAL.UInt9 := 16#0#; -- ADC clocks enable ADCEN : Boolean := False; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- CPU2 TIM1 timer clock enable TIM1EN : Boolean := False; -- CPU2 SPI1 clock enable SPI1EN : Boolean := False; -- unspecified Reserved_13_13 : HAL.Bit := 16#0#; -- CPU2 USART1clocks enable USART1EN : Boolean := False; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- CPU2 TIM16 timer clock enable TIM16EN : Boolean := False; -- CPU2 TIM17 timer clock enable TIM17EN : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2APB2ENR_Register use record Reserved_0_8 at 0 range 0 .. 8; ADCEN at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; TIM1EN at 0 range 11 .. 11; SPI1EN at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; USART1EN at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; TIM16EN at 0 range 17 .. 17; TIM17EN at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- CPU2 APB3 peripheral clock enable register [dual core device only] type C2APB3ENR_Register is record -- CPU2 sub-GHz radio SPI clock enable SUBGHZSPIEN : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2APB3ENR_Register use record SUBGHZSPIEN at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- CPU2 AHB1 peripheral clocks enable in Sleep modes register [dual core -- device only] type C2AHB1SMENR_Register is record -- DMA1 clock enable during CPU2 CSleep mode. DMA1SMEN : Boolean := True; -- DMA2 clock enable during CPU2 CSleep mode. DMA2SMEN : Boolean := True; -- DMAMUX1 clock enable during CPU2 CSleep mode. DMAMUX1SMEN : Boolean := True; -- unspecified Reserved_3_11 : HAL.UInt9 := 16#0#; -- CRC clock enable during CPU2 CSleep mode. CRCSMEN : Boolean := True; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2AHB1SMENR_Register use record DMA1SMEN at 0 range 0 .. 0; DMA2SMEN at 0 range 1 .. 1; DMAMUX1SMEN at 0 range 2 .. 2; Reserved_3_11 at 0 range 3 .. 11; CRCSMEN at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; -- CPU2 AHB2 peripheral clocks enable in Sleep modes register [dual core -- device only] type C2AHB2SMENR_Register is record -- IO port A clock enable during CPU2 CSleep mode. GPIOASMEN : Boolean := True; -- IO port B clock enable during CPU2 CSleep mode. GPIOBSMEN : Boolean := True; -- IO port C clock enable during CPU2 CSleep mode. GPIOCSMEN : Boolean := True; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- IO port H clock enable during CPU2 CSleep mode. GPIOHSMEN : Boolean := True; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2AHB2SMENR_Register use record GPIOASMEN at 0 range 0 .. 0; GPIOBSMEN at 0 range 1 .. 1; GPIOCSMEN at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; GPIOHSMEN at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- CPU2 AHB3 peripheral clocks enable in Sleep mode register [dual core -- device only] type C2AHB3SMENR_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- PKA accelerator clock enable during CPU2 CSleep mode. PKASMEN : Boolean := True; -- AES accelerator clock enable during CPU2 CSleep mode. AESSMEN : Boolean := True; -- True RNG clock enable during CPU2 CSleep and CStop mode. RNGSMEN : Boolean := True; -- unspecified Reserved_19_22 : HAL.UInt4 := 16#0#; -- SRAM1 interface clock enable during CPU2 CSleep mode. SRAM1SMEN : Boolean := True; -- SRAM2 memory interface clock enable during CPU2 CSleep mode. SRAM2SMEN : Boolean := True; -- Flash interface clock enable during CPU2 CSleep mode. FLASHSMEN : Boolean := True; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2AHB3SMENR_Register use record Reserved_0_15 at 0 range 0 .. 15; PKASMEN at 0 range 16 .. 16; AESSMEN at 0 range 17 .. 17; RNGSMEN at 0 range 18 .. 18; Reserved_19_22 at 0 range 19 .. 22; SRAM1SMEN at 0 range 23 .. 23; SRAM2SMEN at 0 range 24 .. 24; FLASHSMEN at 0 range 25 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; -- CPU2 APB1 peripheral clocks enable in Sleep mode register 1 [dual core -- device only] type C2APB1SMENR1_Register is record -- TIM2 timer clock enable during CPU2 CSleep mode. TIM2SMEN : Boolean := True; -- unspecified Reserved_1_9 : HAL.UInt9 := 16#0#; -- RTC bus clock enable during CPU2 CSleep mode. RTCAPBSMEN : Boolean := True; -- unspecified Reserved_11_13 : HAL.UInt3 := 16#0#; -- SPI2S2 clock enable during CPU2 CSleep mode. SPI2S2SMEN : Boolean := True; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- USART2 clock enable during CPU2 CSleep mode. USART2SMEN : Boolean := True; -- unspecified Reserved_18_20 : HAL.UInt3 := 16#0#; -- I2C1 clock enable during CPU2 CSleep and CStop modes I2C1SMEN : Boolean := True; -- I2C2 clock enable during CPU2 CSleep and CStop modes I2C2SMEN : Boolean := True; -- I2C3 clock enable during CPU2 CSleep and CStop modes I2C3SMEN : Boolean := True; -- unspecified Reserved_24_28 : HAL.UInt5 := 16#0#; -- DAC1 clock enable during CPU2 CSleep mode. DAC1SMEN : Boolean := True; -- unspecified Reserved_30_30 : HAL.Bit := 16#0#; -- Low power timer 1 clock enable during CPU2 CSleep and CStop mode LPTIM1SMEN : Boolean := True; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2APB1SMENR1_Register use record TIM2SMEN at 0 range 0 .. 0; Reserved_1_9 at 0 range 1 .. 9; RTCAPBSMEN at 0 range 10 .. 10; Reserved_11_13 at 0 range 11 .. 13; SPI2S2SMEN at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; USART2SMEN at 0 range 17 .. 17; Reserved_18_20 at 0 range 18 .. 20; I2C1SMEN at 0 range 21 .. 21; I2C2SMEN at 0 range 22 .. 22; I2C3SMEN at 0 range 23 .. 23; Reserved_24_28 at 0 range 24 .. 28; DAC1SMEN at 0 range 29 .. 29; Reserved_30_30 at 0 range 30 .. 30; LPTIM1SMEN at 0 range 31 .. 31; end record; -- CPU2 APB1 peripheral clocks enable in Sleep mode register 2 [dual core -- device only] type C2APB1SMENR2_Register is record -- Low power UART 1 clock enable during CPU2 CSleep and CStop mode LPUART1SMEN : Boolean := True; -- unspecified Reserved_1_4 : HAL.UInt4 := 16#0#; -- Low power timer 2 clocks enable during CPU2 CSleep and CStop modes. LPTIM2SMEN : Boolean := True; -- Low power timer 3 clocks enable during CPU2 CSleep and CStop modes. LPTIM3SMEN : Boolean := True; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2APB1SMENR2_Register use record LPUART1SMEN at 0 range 0 .. 0; Reserved_1_4 at 0 range 1 .. 4; LPTIM2SMEN at 0 range 5 .. 5; LPTIM3SMEN at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- CPU2 APB2 peripheral clocks enable in Sleep mode register [dual core -- device only] type C2APB2SMENR_Register is record -- unspecified Reserved_0_8 : HAL.UInt9 := 16#0#; -- ADC clocks enable during CPU2 Csleep and CStop modes ADCSMEN : Boolean := True; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- TIM1 timer clock enable during CPU2 CSleep mode TIM1SMEN : Boolean := True; -- SPI1 clock enable during CPU2 CSleep mode SPI1SMEN : Boolean := True; -- unspecified Reserved_13_13 : HAL.Bit := 16#0#; -- USART1clock enable during CPU2 CSleep and CStop mode USART1SMEN : Boolean := True; -- unspecified Reserved_15_16 : HAL.UInt2 := 16#0#; -- TIM16 timer clock enable during CPU2 CSleep mode TIM16SMEN : Boolean := True; -- TIM17 timer clock enable during CPU2 CSleep mode TIM17SMEN : Boolean := True; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2APB2SMENR_Register use record Reserved_0_8 at 0 range 0 .. 8; ADCSMEN at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; TIM1SMEN at 0 range 11 .. 11; SPI1SMEN at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; USART1SMEN at 0 range 14 .. 14; Reserved_15_16 at 0 range 15 .. 16; TIM16SMEN at 0 range 17 .. 17; TIM17SMEN at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- CPU2 APB3 peripheral clock enable in Sleep mode register [dual core -- device only] type C2APB3SMENR_Register is record -- sub-GHz radio SPI clock enable during CPU2 CSleep and CStop modes SUBGHZSPISMEN : Boolean := True; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2APB3SMENR_Register use record SUBGHZSPISMEN at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Reset and clock control type RCC_Peripheral is record -- Clock control register CR : aliased CR_Register; -- Internal clock sources calibration register ICSCR : aliased ICSCR_Register; -- Clock configuration register CFGR : aliased CFGR_Register; -- PLL configuration register PLLCFGR : aliased PLLCFGR_Register; -- Clock interrupt enable register CIER : aliased CIER_Register; -- Clock interrupt flag register CIFR : aliased CIFR_Register; -- Clock interrupt clear register CICR : aliased CICR_Register; -- AHB1 peripheral reset register AHB1RSTR : aliased AHB1RSTR_Register; -- AHB2 peripheral reset register AHB2RSTR : aliased AHB2RSTR_Register; -- AHB3 peripheral reset register AHB3RSTR : aliased AHB3RSTR_Register; -- APB1 peripheral reset register 1 APB1RSTR1 : aliased APB1RSTR1_Register; -- APB1 peripheral reset register 2 APB1RSTR2 : aliased APB1RSTR2_Register; -- APB2 peripheral reset register APB2RSTR : aliased APB2RSTR_Register; -- APB3 peripheral reset register APB3RSTR : aliased APB3RSTR_Register; -- AHB1 peripheral clock enable register AHB1ENR : aliased AHB1ENR_Register; -- AHB2 peripheral clock enable register AHB2ENR : aliased AHB2ENR_Register; -- AHB3 peripheral clock enable register AHB3ENR : aliased AHB3ENR_Register; -- APB1 peripheral clock enable register 1 APB1ENR1 : aliased APB1ENR1_Register; -- APB1 peripheral clock enable register 2 APB1ENR2 : aliased APB1ENR2_Register; -- APB2 peripheral clock enable register APB2ENR : aliased APB2ENR_Register; -- APB3 peripheral clock enable register APB3ENR : aliased APB3ENR_Register; -- AHB1 peripheral clocks enable in Sleep modes register AHB1SMENR : aliased AHB1SMENR_Register; -- AHB2 peripheral clocks enable in Sleep modes register AHB2SMENR : aliased AHB2SMENR_Register; -- AHB3 peripheral clocks enable in Sleep and Stop modes register AHB3SMENR : aliased AHB3SMENR_Register; -- APB1 peripheral clocks enable in Sleep mode register 1 APB1SMENR1 : aliased APB1SMENR1_Register; -- APB1 peripheral clocks enable in Sleep mode register 2 APB1SMENR2 : aliased APB1SMENR2_Register; -- APB2 peripheral clocks enable in Sleep mode register APB2SMENR : aliased APB2SMENR_Register; -- APB3 peripheral clock enable in Sleep mode register APB3SMENR : aliased APB3SMENR_Register; -- Peripherals independent clock configuration register CCIPR : aliased CCIPR_Register; -- Backup domain control register BDCR : aliased BDCR_Register; -- Control/status register CSR : aliased CSR_Register; -- Extended clock recovery register EXTCFGR : aliased EXTCFGR_Register; -- CPU2 AHB1 peripheral clock enable register C2AHB1ENR : aliased C2AHB1ENR_Register; -- CPU2 AHB2 peripheral clock enable register C2AHB2ENR : aliased C2AHB2ENR_Register; -- CPU2 AHB3 peripheral clock enable register [dual core device only] C2AHB3ENR : aliased C2AHB3ENR_Register; -- CPU2 APB1 peripheral clock enable register 1 [dual core device only] C2APB1ENR1 : aliased C2APB1ENR1_Register; -- CPU2 APB1 peripheral clock enable register 2 [dual core device only] C2APB1ENR2 : aliased C2APB1ENR2_Register; -- CPU2 APB2 peripheral clock enable register [dual core device only] C2APB2ENR : aliased C2APB2ENR_Register; -- CPU2 APB3 peripheral clock enable register [dual core device only] C2APB3ENR : aliased C2APB3ENR_Register; -- CPU2 AHB1 peripheral clocks enable in Sleep modes register [dual core -- device only] C2AHB1SMENR : aliased C2AHB1SMENR_Register; -- CPU2 AHB2 peripheral clocks enable in Sleep modes register [dual core -- device only] C2AHB2SMENR : aliased C2AHB2SMENR_Register; -- CPU2 AHB3 peripheral clocks enable in Sleep mode register [dual core -- device only] C2AHB3SMENR : aliased C2AHB3SMENR_Register; -- CPU2 APB1 peripheral clocks enable in Sleep mode register 1 [dual -- core device only] C2APB1SMENR1 : aliased C2APB1SMENR1_Register; -- CPU2 APB1 peripheral clocks enable in Sleep mode register 2 [dual -- core device only] C2APB1SMENR2 : aliased C2APB1SMENR2_Register; -- CPU2 APB2 peripheral clocks enable in Sleep mode register [dual core -- device only] C2APB2SMENR : aliased C2APB2SMENR_Register; -- CPU2 APB3 peripheral clock enable in Sleep mode register [dual core -- device only] C2APB3SMENR : aliased C2APB3SMENR_Register; end record with Volatile; for RCC_Peripheral use record CR at 16#0# range 0 .. 31; ICSCR at 16#4# range 0 .. 31; CFGR at 16#8# range 0 .. 31; PLLCFGR at 16#C# range 0 .. 31; CIER at 16#18# range 0 .. 31; CIFR at 16#1C# range 0 .. 31; CICR at 16#20# range 0 .. 31; AHB1RSTR at 16#28# range 0 .. 31; AHB2RSTR at 16#2C# range 0 .. 31; AHB3RSTR at 16#30# range 0 .. 31; APB1RSTR1 at 16#38# range 0 .. 31; APB1RSTR2 at 16#3C# range 0 .. 31; APB2RSTR at 16#40# range 0 .. 31; APB3RSTR at 16#44# range 0 .. 31; AHB1ENR at 16#48# range 0 .. 31; AHB2ENR at 16#4C# range 0 .. 31; AHB3ENR at 16#50# range 0 .. 31; APB1ENR1 at 16#58# range 0 .. 31; APB1ENR2 at 16#5C# range 0 .. 31; APB2ENR at 16#60# range 0 .. 31; APB3ENR at 16#64# range 0 .. 31; AHB1SMENR at 16#68# range 0 .. 31; AHB2SMENR at 16#6C# range 0 .. 31; AHB3SMENR at 16#70# range 0 .. 31; APB1SMENR1 at 16#78# range 0 .. 31; APB1SMENR2 at 16#7C# range 0 .. 31; APB2SMENR at 16#80# range 0 .. 31; APB3SMENR at 16#84# range 0 .. 31; CCIPR at 16#88# range 0 .. 31; BDCR at 16#90# range 0 .. 31; CSR at 16#94# range 0 .. 31; EXTCFGR at 16#108# range 0 .. 31; C2AHB1ENR at 16#148# range 0 .. 31; C2AHB2ENR at 16#14C# range 0 .. 31; C2AHB3ENR at 16#150# range 0 .. 31; C2APB1ENR1 at 16#158# range 0 .. 31; C2APB1ENR2 at 16#15C# range 0 .. 31; C2APB2ENR at 16#160# range 0 .. 31; C2APB3ENR at 16#164# range 0 .. 31; C2AHB1SMENR at 16#168# range 0 .. 31; C2AHB2SMENR at 16#16C# range 0 .. 31; C2AHB3SMENR at 16#170# range 0 .. 31; C2APB1SMENR1 at 16#178# range 0 .. 31; C2APB1SMENR2 at 16#17C# range 0 .. 31; C2APB2SMENR at 16#180# range 0 .. 31; C2APB3SMENR at 16#184# range 0 .. 31; end record; -- Reset and clock control RCC_Periph : aliased RCC_Peripheral with Import, Address => RCC_Base; end STM32_SVD.RCC;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P A R . T C H K -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-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. -- -- -- ------------------------------------------------------------------------------ -- Token scan routines -- Error recovery: none of the T_xxx or TF_xxx routines raise Error_Resync separate (Par) package body Tchk is type Position is (SC, BC, AP); -- Specify position of error message (see Error_Msg_SC/BC/AP) ----------------------- -- Local Subprograms -- ----------------------- procedure Check_Token (T : Token_Type; P : Position); pragma Inline (Check_Token); -- Called by T_xx routines to check for reserved keyword token. P is the -- position of the error message if the token is missing (see Wrong_Token) procedure Wrong_Token (T : Token_Type; P : Position); -- Called when scanning a reserved keyword when the keyword is not -- present. T is the token type for the keyword, and P indicates the -- position to be used to place a message relative to the current -- token if the keyword is not located nearby. ----------------- -- Check_Token -- ----------------- procedure Check_Token (T : Token_Type; P : Position) is begin if Token = T then Scan; return; else Wrong_Token (T, P); end if; end Check_Token; ------------- -- T_Abort -- ------------- procedure T_Abort is begin Check_Token (Tok_Abort, SC); end T_Abort; ------------- -- T_Arrow -- ------------- procedure T_Arrow is begin if Token = Tok_Arrow then Scan; -- A little recovery helper, accept then in place of => elsif Token = Tok_Then then Error_Msg_BC ("missing ""='>"""); Scan; -- past THEN used in place of => elsif Token = Tok_Colon_Equal then Error_Msg_SC (""":="" should be ""='>"""); Scan; -- past := used in place of => else Error_Msg_AP ("missing ""='>"""); end if; end T_Arrow; ---------- -- T_At -- ---------- procedure T_At is begin Check_Token (Tok_At, SC); end T_At; ------------ -- T_Body -- ------------ procedure T_Body is begin Check_Token (Tok_Body, BC); end T_Body; ----------- -- T_Box -- ----------- procedure T_Box is begin if Token = Tok_Box then Scan; else Error_Msg_AP ("missing ""'<'>"""); end if; end T_Box; ------------- -- T_Colon -- ------------- procedure T_Colon is begin if Token = Tok_Colon then Scan; else Error_Msg_AP ("missing "":"""); end if; end T_Colon; ------------------- -- T_Colon_Equal -- ------------------- procedure T_Colon_Equal is begin if Token = Tok_Colon_Equal then Scan; elsif Token = Tok_Equal then Error_Msg_SC ("""="" should be "":="""); Scan; elsif Token = Tok_Colon then Error_Msg_SC (""":"" should be "":="""); Scan; elsif Token = Tok_Is then Error_Msg_SC ("IS should be "":="""); Scan; else Error_Msg_AP ("missing "":="""); end if; end T_Colon_Equal; ------------- -- T_Comma -- ------------- procedure T_Comma is begin if Token = Tok_Comma then Scan; else if Token = Tok_Pragma then P_Pragmas_Misplaced; end if; if Token = Tok_Comma then Scan; else Error_Msg_AP ("missing "","""); end if; end if; if Token = Tok_Pragma then P_Pragmas_Misplaced; end if; end T_Comma; --------------- -- T_Dot_Dot -- --------------- procedure T_Dot_Dot is begin if Token = Tok_Dot_Dot then Scan; else Error_Msg_AP ("missing "".."""); end if; end T_Dot_Dot; ----------- -- T_For -- ----------- procedure T_For is begin Check_Token (Tok_For, AP); end T_For; ----------------------- -- T_Greater_Greater -- ----------------------- procedure T_Greater_Greater is begin if Token = Tok_Greater_Greater then Scan; else Error_Msg_AP ("missing ""'>'>"""); end if; end T_Greater_Greater; ------------------ -- T_Identifier -- ------------------ procedure T_Identifier is begin if Token = Tok_Identifier then Scan; elsif Token in Token_Class_Literal then Error_Msg_SC ("identifier expected"); Scan; else Error_Msg_AP ("identifier expected"); end if; end T_Identifier; ---------- -- T_In -- ---------- procedure T_In is begin Check_Token (Tok_In, AP); end T_In; ---------- -- T_Is -- ---------- procedure T_Is is begin if Token = Tok_Is then Scan; Ignore (Tok_Semicolon); -- Allow OF, => or = to substitute for IS with complaint elsif Token = Tok_Arrow or else Token = Tok_Of or else Token = Tok_Equal then Error_Msg_SC ("missing IS"); Scan; -- token used in place of IS else Wrong_Token (Tok_Is, AP); end if; while Token = Tok_Is loop Error_Msg_SC ("extra IS ignored"); Scan; end loop; end T_Is; ------------------ -- T_Left_Paren -- ------------------ procedure T_Left_Paren is begin if Token = Tok_Left_Paren then Scan; else Error_Msg_AP ("missing ""("""); end if; end T_Left_Paren; ------------ -- T_Loop -- ------------ procedure T_Loop is begin if Token = Tok_Do then Error_Msg_SC ("LOOP expected"); Scan; else Check_Token (Tok_Loop, AP); end if; end T_Loop; ----------- -- T_Mod -- ----------- procedure T_Mod is begin Check_Token (Tok_Mod, AP); end T_Mod; ----------- -- T_New -- ----------- procedure T_New is begin Check_Token (Tok_New, AP); end T_New; ---------- -- T_Of -- ---------- procedure T_Of is begin Check_Token (Tok_Of, AP); end T_Of; ---------- -- T_Or -- ---------- procedure T_Or is begin Check_Token (Tok_Or, AP); end T_Or; --------------- -- T_Private -- --------------- procedure T_Private is begin Check_Token (Tok_Private, SC); end T_Private; ------------- -- T_Range -- ------------- procedure T_Range is begin Check_Token (Tok_Range, AP); end T_Range; -------------- -- T_Record -- -------------- procedure T_Record is begin Check_Token (Tok_Record, AP); end T_Record; ------------------- -- T_Right_Paren -- ------------------- procedure T_Right_Paren is begin if Token = Tok_Right_Paren then Scan; else Error_Msg_AP ("missing "")"""); end if; end T_Right_Paren; ----------------- -- T_Semicolon -- ----------------- procedure T_Semicolon is begin if Token = Tok_Semicolon then Scan; if Token = Tok_Semicolon then Error_Msg_SC ("extra "";"" ignored"); Scan; end if; return; elsif Token = Tok_Colon then Error_Msg_SC (""":"" should be "";"""); Scan; return; elsif Token = Tok_Comma then Error_Msg_SC (""","" should be "";"""); Scan; return; elsif Token = Tok_Dot then Error_Msg_SC ("""."" should be "";"""); Scan; return; -- An interesting little kludge here. If the previous token is a -- semicolon, then there is no way that we can legitimately need -- another semicolon. This could only arise in an error situation -- where an error has already been signalled. By simply ignoring -- the request for a semicolon in this case, we avoid some spurious -- missing semicolon messages. elsif Prev_Token = Tok_Semicolon then return; -- If the current token is | then this is a reasonable -- place to suggest the possibility of a "C" confusion :-) elsif Token = Tok_Vertical_Bar then Error_Msg_SC ("unexpected occurrence of ""'|"", did you mean OR'?"); Resync_Past_Semicolon; return; -- Deal with pragma. If pragma is not at start of line, it is -- considered misplaced otherwise we treat it as a normal -- missing semicolong case. elsif Token = Tok_Pragma and then not Token_Is_At_Start_Of_Line then P_Pragmas_Misplaced; if Token = Tok_Semicolon then Scan; return; end if; end if; -- If none of those tests return, we really have a missing semicolon Error_Msg_AP ("|missing "";"""); return; end T_Semicolon; ------------ -- T_Then -- ------------ procedure T_Then is begin Check_Token (Tok_Then, AP); end T_Then; ------------ -- T_Type -- ------------ procedure T_Type is begin Check_Token (Tok_Type, BC); end T_Type; ----------- -- T_Use -- ----------- procedure T_Use is begin Check_Token (Tok_Use, SC); end T_Use; ------------ -- T_When -- ------------ procedure T_When is begin Check_Token (Tok_When, SC); end T_When; ------------ -- T_With -- ------------ procedure T_With is begin Check_Token (Tok_With, BC); end T_With; -------------- -- TF_Arrow -- -------------- procedure TF_Arrow is Scan_State : Saved_Scan_State; begin if Token = Tok_Arrow then Scan; -- skip arrow and we are done elsif Token = Tok_Colon_Equal then T_Arrow; -- Let T_Arrow give the message else T_Arrow; -- give missing arrow message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were! return; end if; Scan; -- continue search! if Token = Tok_Arrow then Scan; -- past arrow return; end if; end loop; end if; end TF_Arrow; ----------- -- TF_Is -- ----------- procedure TF_Is is Scan_State : Saved_Scan_State; begin if Token = Tok_Is then T_Is; -- past IS and we are done -- Allow OF or => or = in place of IS (with error message) elsif Token = Tok_Of or else Token = Tok_Arrow or else Token = Tok_Equal then T_Is; -- give missing IS message and skip bad token else T_Is; -- give missing IS message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were! return; end if; Scan; -- continue search! if Token = Tok_Is or else Token = Tok_Of or else Token = Tok_Arrow then Scan; -- past IS or OF or => return; end if; end loop; end if; end TF_Is; ------------- -- TF_Loop -- ------------- procedure TF_Loop is Scan_State : Saved_Scan_State; begin if Token = Tok_Loop then Scan; -- past LOOP and we are done -- Allow DO or THEN in place of LOOP elsif Token = Tok_Then or else Token = Tok_Do then T_Loop; -- give missing LOOP message else T_Loop; -- give missing LOOP message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were! return; end if; Scan; -- continue search! if Token = Tok_Loop or else Token = Tok_Then then Scan; -- past loop or then (message already generated) return; end if; end loop; end if; end TF_Loop; -------------- -- TF_Return-- -------------- procedure TF_Return is Scan_State : Saved_Scan_State; begin if Token = Tok_Return then Scan; -- skip RETURN and we are done else Error_Msg_SC ("missing RETURN"); Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were! return; end if; Scan; -- continue search! if Token = Tok_Return then Scan; -- past RETURN return; end if; end loop; end if; end TF_Return; ------------------ -- TF_Semicolon -- ------------------ procedure TF_Semicolon is Scan_State : Saved_Scan_State; begin if Token = Tok_Semicolon then T_Semicolon; return; -- An interesting little kludge here. If the previous token is a -- semicolon, then there is no way that we can legitimately need -- another semicolon. This could only arise in an error situation -- where an error has already been signalled. By simply ignoring -- the request for a semicolon in this case, we avoid some spurious -- missing semicolon messages. elsif Prev_Token = Tok_Semicolon then return; else -- Deal with pragma. If pragma is not at start of line, it is -- considered misplaced otherwise we treat it as a normal -- missing semicolong case. if Token = Tok_Pragma and then not Token_Is_At_Start_Of_Line then P_Pragmas_Misplaced; if Token = Tok_Semicolon then T_Semicolon; return; end if; end if; -- Here we definitely have a missing semicolon, so give message T_Semicolon; -- Scan out junk on rest of line Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were return; end if; Scan; -- continue search if Token = Tok_Semicolon then T_Semicolon; return; elsif Token in Token_Class_After_SM then return; end if; end loop; end if; end TF_Semicolon; ------------- -- TF_Then -- ------------- procedure TF_Then is Scan_State : Saved_Scan_State; begin if Token = Tok_Then then Scan; -- past THEN and we are done else T_Then; -- give missing THEN message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were return; end if; Scan; -- continue search! if Token = Tok_Then then Scan; -- past THEN return; end if; end loop; end if; end TF_Then; ------------ -- TF_Use -- ------------ procedure TF_Use is Scan_State : Saved_Scan_State; begin if Token = Tok_Use then Scan; -- past USE and we are done else T_Use; -- give USE expected message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were return; end if; Scan; -- continue search! if Token = Tok_Use then Scan; -- past use return; end if; end loop; end if; end TF_Use; ----------------- -- Wrong_Token -- ----------------- procedure Wrong_Token (T : Token_Type; P : Position) is Missing : constant String := "missing "; Image : constant String := Token_Type'Image (T); Tok_Name : constant String := Image (5 .. Image'Length); M : String (1 .. Missing'Length + Tok_Name'Length); begin -- Set M to Missing & Tok_Name M (1 .. Missing'Length) := Missing; M (Missing'Length + 1 .. M'Last) := Tok_Name; if Token = Tok_Semicolon then Scan; if Token = T then Error_Msg_SP ("extra "";"" ignored"); Scan; else Error_Msg_SP (M); end if; elsif Token = Tok_Comma then Scan; if Token = T then Error_Msg_SP ("extra "","" ignored"); Scan; else Error_Msg_SP (M); end if; else case P is when SC => Error_Msg_SC (M); when BC => Error_Msg_BC (M); when AP => Error_Msg_AP (M); end case; end if; end Wrong_Token; end Tchk;
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Бб., 30 нояб. 2013) $: with Asis.Elements; with Asis.Expressions; with Asis.Gela.Lists; with Asis.Gela.Errors; with Asis.Gela.Classes; with Asis.Gela.Base_Lists; with Asis.Gela.Element_Utils; with Asis.Gela.Elements.Expr; with Asis.Gela.Elements.Assoc; with Asis.Gela.Elements.Decl; with Asis.Gela.Elements.Stmt; with Asis.Gela.Elements.Defs.Rng; with Asis.Gela.Elements.Defs.Const; with Asis.Gela.Elements.Clause.Rep; with Asis.Gela.Elements.Defs.Types; with Asis.Gela.Elements.Defs.Formal; package body Asis.Gela.Replace is procedure Function_To_Index_Constraint (Item : in out Asis.Element); procedure Function_To_Discriminant_Constraint (Item : in out Asis.Element); procedure Set_Enclosing_Element_In_List (List : access Asis.Gela.Base_Lists.Primary_Base_List_Node'Class; Parent : Asis.Element); procedure Set_Enclosing_Element_In_List (List : Asis.Element; Parent : Asis.Element); ----------------------------------------- -- Could_Be_Positional_Array_Aggregate -- ----------------------------------------- function Could_Be_Positional_Array_Aggregate (Item : Asis.Element) return Boolean is use Asis.Elements; use Asis.Expressions; List : Asis.Association_List := Record_Component_Associations (Item); begin if List'Length = 0 then -- null record return False; end if; for I in List'Range loop declare Choises : Asis.Expression_List := Record_Component_Choices (List (I)); begin if List'Length = 1 and then Choises'Length = 0 then return False; end if; if Choises'Length /= 0 then return False; end if; if Element_Kind (Component_Expression (List (I))) /= An_Expression then return False; end if; end; end loop; return True; end Could_Be_Positional_Array_Aggregate; --------------------------------- -- Expression_To_Function_Call -- --------------------------------- procedure Expression_To_Function_Call (Item : in out Asis.Element) is use Asis.Gela.Elements.Expr; Result : Function_Call_Ptr := new Function_Call_Node; begin Element_Utils.Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Prefix (Result.all, Item); Element_Utils.Set_Enclosing_Element (Item, Asis.Element (Result)); Set_Is_Prefix_Call (Result.all, True); Item := Asis.Element (Result); end Expression_To_Function_Call; ---------------------------- -- Function_To_Constraint -- ---------------------------- procedure Function_To_Constraint (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Errors; use Asis.Gela.Classes; Subtipe : Asis.Subtype_Mark := Prefix (Item); Info : Type_Info := Type_From_Subtype_Mark (Subtipe, Item); begin if Is_Not_Type (Info) or else Is_Definition (Info) then return; end if; if Is_Array (Info) then Function_To_Index_Constraint (Item); elsif Is_Composite (Info) then Function_To_Discriminant_Constraint (Item); else Report (Item, Error_Syntax_Bad_Constraints); end if; end Function_To_Constraint; ----------------------------------------- -- Function_To_Discriminant_Constraint -- ----------------------------------------- procedure Function_To_Discriminant_Constraint (Item : in out Asis.Element) is use Asis.Elements; use Asis.Gela.Lists; use Asis.Gela.Errors; use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Elements.Assoc; use Asis.Gela.Element_Utils; use Primary_Association_Lists; use Asis.Gela.Elements.Defs.Const; List : Asis.Association_List := Function_Call_Parameters (Item); List_I : Asis.Element; Result : Discriminant_Constraint_Ptr := new Discriminant_Constraint_Node; Assoc : Discriminant_Association_Ptr; Node : Record_Component_Association_Ptr; Child : Asis.Element; Funct : Function_Call_Node renames Function_Call_Node (Item.all); Aggr : constant Asis.Element := Record_Aggregate (Funct); Assoc_List : Primary_Association_Lists.List := new List_Node; Old_List : Primary_Choise_Lists.List; begin for I in List'Range loop List_I := List (I); Node := Record_Component_Association_Ptr (List_I); Child := Component_Expression (List_I); if Element_Kind (Child) = An_Expression then Assoc := new Discriminant_Association_Node; Copy_Element (List_I, Asis.Element (Assoc)); Set_Discriminant_Expression (Assoc.all, Child); Set_Enclosing_Element (Child, Asis.Element (Assoc)); Child := Record_Component_Choices_List (Node.all); Set_Discriminant_Selector_Names (Assoc.all, Child); Old_List := Primary_Choise_Lists.List (Child); if Assigned (Child) then Set_Enclosing_Element_In_List (Old_List, Asis.Element (Assoc)); end if; Add (Assoc_List.all, Asis.Element (Assoc)); Set_Enclosing_Element (Assoc.all, Asis.Element (Result)); else Report (Child, Error_Syntax_Bad_Constraints); end if; end loop; Copy_Element (Item, Asis.Element (Result)); Set_Discriminant_Associations (Result.all, Asis.Element (Assoc_List)); Set_Start_Position (Result.all, Start_Position (Aggr.all)); Set_End_Position (Result.all, End_Position (Aggr.all)); Item := Asis.Element (Result); end Function_To_Discriminant_Constraint; ----------------------------------- -- Function_To_Indexed_Component -- ----------------------------------- procedure Function_To_Indexed_Component (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; use Lists.Primary_Expression_Lists; Result : Indexed_Component_Ptr := new Indexed_Component_Node; Items : List := new List_Node; List : Asis.Association_List := Function_Call_Parameters (Item); Tmp : Asis.Element; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Tmp := Prefix (Item); Set_Prefix (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); for I in List'Range loop Tmp := Component_Expression (List (I)); Add (Items.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); end loop; Set_Index_Expressions (Result.all, Asis.Element (Items)); Item := Asis.Element (Result); end Function_To_Indexed_Component; ---------------------------------- -- Function_To_Index_Constraint -- ---------------------------------- procedure Function_To_Index_Constraint (Item : in out Asis.Element) is use Asis.Elements; use Asis.Expressions; use Asis.Gela.Errors; use Asis.Gela.Elements.Defs; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; use Asis.Gela.Elements.Defs.Rng; use Asis.Gela.Elements.Defs.Const; use Lists.Primary_Definition_Lists; Result : Index_Constraint_Ptr := new Index_Constraint_Node; Ind : Discrete_Subtype_Indication_Ptr; Ranges : List := new List_Node; Child : Asis.Element; Funct : Function_Call_Node renames Function_Call_Node (Item.all); Aggr : constant Asis.Element := Record_Aggregate (Funct); List : Asis.Association_List := Function_Call_Parameters (Item); begin Copy_Element (Item, Asis.Element (Result)); for I in List'Range loop Child := Component_Expression (List (I)); if Element_Kind (Child) = An_Expression then Ind := new Discrete_Subtype_Indication_Node; Copy_Element (Child, Asis.Element (Ind)); Set_Subtype_Mark (Ind.all, Child); Set_Enclosing_Element (Child, Asis.Element (Ind)); Child := Asis.Element (Ind); end if; if Element_Kind (Child) = A_Definition then Add (Ranges.all, Child); Set_Enclosing_Element (Child, Asis.Element (Result)); else raise Internal_Error; end if; declare Choises : Asis.Expression_List := Record_Component_Choices (List (I)); begin if Choises'Length /= 0 then Report (Child, Error_Syntax_Bad_Constraints); end if; end; end loop; Set_Discrete_Ranges (Result.all, Asis.Element (Ranges)); Set_Start_Position (Result.all, Start_Position (Aggr.all)); Set_End_Position (Result.all, End_Position (Aggr.all)); Item := Asis.Element (Result); end Function_To_Index_Constraint; ----------------------- -- Function_To_Slice -- ----------------------- procedure Function_To_Slice (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; Result : Slice_Ptr := new Slice_Node; List : Asis.Association_List := Function_Call_Parameters (Item); Tmp : Asis.Element; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Tmp := Prefix (Item); Set_Prefix (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Tmp := Component_Expression (List (1)); Set_Slice_Range (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Item := Asis.Element (Result); end Function_To_Slice; --------------------------------- -- Function_To_Type_Conversion -- --------------------------------- procedure Function_To_Type_Conversion (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; Result : Type_Conversion_Ptr := new Type_Conversion_Node; List : Asis.Association_List := Function_Call_Parameters (Item); Tmp : Asis.Element; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Tmp := Prefix (Item); Set_Converted_Or_Qualified_Subtype_Mark (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Tmp := Component_Expression (List (1)); Set_Converted_Or_Qualified_Expression (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Item := Asis.Element (Result); end Function_To_Type_Conversion; --------------------------------------- -- Identifier_To_Enumeration_Literal -- --------------------------------------- procedure Identifier_To_Enumeration_Literal (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; Result : Enumeration_Literal_Ptr := new Enumeration_Literal_Node; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Name_Image (Result.all, Name_Image (Item)); declare List : Element_List := Corresponding_Name_Definition_List (Item); begin for I in List'Range loop Add_Defining_Name (Asis.Element (Result), List (I)); Remove_Defining_Name (Item, List (I)); end loop; end; Set_Corresponding_Name_Declaration (Result.all, Corresponding_Name_Declaration (Item)); Item := Asis.Element (Result); end Identifier_To_Enumeration_Literal; ------------------------- -- Integer_Real_Number -- ------------------------- procedure Integer_Real_Number (Item : in out Asis.Element) is use Asis.Gela.Elements.Decl; Node : Integer_Number_Declaration_Node renames Integer_Number_Declaration_Node (Item.all); begin Set_Declaration_Kind (Node, A_Real_Number_Declaration); end Integer_Real_Number; ----------------------------------- -- Interface_To_Formal_Interface -- ----------------------------------- procedure Interface_To_Formal_Interface (Item : in out Asis.Statement) is use Asis.Gela.Elements.Defs.Types; use Asis.Gela.Elements.Defs.Formal; Node : Interface_Type_Node renames Interface_Type_Node (Item.all); Result : Formal_Interface_Type_Ptr := new Formal_Interface_Type_Node; begin Element_Utils.Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Interface_Kind (Result.all, Interface_Kind (Node)); Set_Progenitor_List (Result.all, Progenitor_List_List (Node)); Item := Asis.Element (Result); end Interface_To_Formal_Interface; --------------------------------------- -- Operator_Symbol_To_String_Literal -- --------------------------------------- procedure Operator_Symbol_To_String_Literal (Item : in out Asis.Element) is use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; Result : String_Literal_Ptr := new String_Literal_Node; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Value_Image (Result.all, Asis.Expressions.Name_Image (Item)); Item := Asis.Element (Result); end Operator_Symbol_To_String_Literal; ----------------------------- -- Procedure_To_Entry_Call -- ----------------------------- procedure Procedure_To_Entry_Call (Item : in out Asis.Element) is use Asis.Gela.Elements.Stmt; use Asis.Gela.Element_Utils; Result : Entry_Call_Statement_Ptr := new Entry_Call_Statement_Node; Node : Procedure_Call_Statement_Node renames Procedure_Call_Statement_Node (Item.all); Tmp : Asis.Element; begin Element_Utils.Copy_Element (Source => Item, Target => Asis.Element (Result)); Tmp := Called_Name (Node); Set_Called_Name (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Tmp := Call_Statement_Parameters_List (Node); Set_Call_Statement_Parameters (Result.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Element (Result)); Tmp := Label_Names_List (Node); Set_Label_Names (Result.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Element (Result)); Item := Asis.Element (Result); end Procedure_To_Entry_Call; ------------------------------------- -- Procedure_To_Indexed_Entry_Call -- ------------------------------------- procedure Procedure_To_Indexed_Entry_Call (Element : in out Asis.Statement) is use Asis.Gela.Elements.Expr; use Asis.Gela.Elements.Stmt; use Asis.Gela.Element_Utils; use Lists.Primary_Expression_Lists; Result : Entry_Call_Statement_Ptr := new Entry_Call_Statement_Node; Index : Indexed_Component_Ptr := new Indexed_Component_Node; Node : Procedure_Call_Statement_Node renames Procedure_Call_Statement_Node (Element.all); Tmp : Asis.Element; Items : List := new List_Node; List : Asis.Association_List := Call_Statement_Parameters (Element.all); begin Element_Utils.Copy_Element (Source => Element, Target => Asis.Element (Index)); Tmp := Called_Name (Node); Set_Prefix (Index.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Index)); Tmp := Component_Expression (List (1).all); Add (Items.all, Tmp); Set_Index_Expressions (Index.all, Asis.Element (Items)); Set_Enclosing_Element (Tmp, Asis.Element (Index)); Element_Utils.Copy_Element (Source => Element, Target => Asis.Element (Result)); Set_Called_Name (Result.all, Asis.Element (Index)); Set_Enclosing_Element (Index.all, Asis.Element (Result)); Tmp := Label_Names_List (Node); Set_Label_Names (Result.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Element (Result)); Element := Asis.Element (Result); end Procedure_To_Indexed_Entry_Call; ------------------------------- -- Record_To_Array_Aggregate -- ------------------------------- type Base_Array_Aggregate_Ptr is access all Asis.Gela.Elements.Expr.Base_Array_Aggregate_Node'Class; procedure Record_To_Array_Aggregate (Item : in out Asis.Element; Positional : in Boolean) is use Asis.Expressions; use Asis.Gela.Lists.Primary_Association_Lists; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; -- Pos & Named ptr used for Storage_Pool works Pos : Positional_Array_Aggregate_Ptr; Named : Named_Array_Aggregate_Ptr; Result : Base_Array_Aggregate_Ptr; Items : List := List (Record_Component_Associations_List (Record_Aggregate_Node (Item.all))); begin if Positional then Pos := new Positional_Array_Aggregate_Node; Result := Base_Array_Aggregate_Ptr (Pos); else Named := new Named_Array_Aggregate_Node; Result := Base_Array_Aggregate_Ptr (Named); end if; Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Array_Component_Associations (Result.all, Asis.Element (Items)); Set_Enclosing_Element_In_List (Items, Asis.Element (Result)); Item := Asis.Element (Result); end Record_To_Array_Aggregate; --------------------------------- -- Record_To_Array_Association -- --------------------------------- procedure Record_To_Array_Association (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Lists.Primary_Choise_Lists; use Asis.Gela.Elements.Assoc; use Asis.Gela.Element_Utils; Result : Array_Component_Association_Ptr := new Array_Component_Association_Node; Items : List := List (Record_Component_Choices_List (Record_Component_Association_Node (Item.all))); begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Array_Component_Choices (Result.all, Asis.Element (Items)); if Items /= null then Set_Enclosing_Element_In_List (Items, Asis.Element (Result)); end if; Set_Component_Expression (Result.all, Component_Expression (Item)); Set_Enclosing_Element (Component_Expression (Item), Asis.Element (Result)); Item := Asis.Element (Result); end Record_To_Array_Association; -------------------------------------- -- Record_To_Parameter_Association -- -------------------------------------- procedure Record_To_Parameter_Association (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Lists.Primary_Choise_Lists; use Asis.Gela.Elements.Assoc; use Asis.Gela.Element_Utils; Result : Parameter_Association_Ptr := new Parameter_Association_Node; Items : List := List (Record_Component_Choices_List (Record_Component_Association_Node (Item.all))); begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Actual_Parameter (Result.all, Component_Expression (Item)); Set_Enclosing_Element (Component_Expression (Item), Asis.Element (Result)); if Items /= null then Set_Formal_Parameter (Result.all, Get_Item (Items, 1)); Set_Enclosing_Element (Get_Item (Items, 1), Asis.Element (Result)); Destroy (Items); end if; Set_Is_Normalized (Result.all, False); Set_Is_Defaulted_Association (Result.all, False); Item := Asis.Element (Result); end Record_To_Parameter_Association; ----------------------------------- -- Set_Enclosing_Element_In_List -- ----------------------------------- procedure Set_Enclosing_Element_In_List (List : access Asis.Gela.Base_Lists.Primary_Base_List_Node'Class; Parent : Asis.Element) is use Asis.Gela.Base_Lists; begin for J in 1 .. Length (List.all) loop Element_Utils.Set_Enclosing_Element (Get_Item (List, J), Parent); end loop; end Set_Enclosing_Element_In_List; ----------------------------------- -- Set_Enclosing_Element_In_List -- ----------------------------------- procedure Set_Enclosing_Element_In_List (List : Asis.Element; Parent : Asis.Element) is begin if Assigned (List) then Set_Enclosing_Element_In_List (Asis.Gela.Base_Lists.Primary_Base_List (List), Parent); end if; end Set_Enclosing_Element_In_List; ------------------------- -- To_Timed_Entry_Call -- ------------------------- procedure To_Timed_Entry_Call (Element : in out Asis.Statement) is use Asis.Gela.Elements.Stmt; use Asis.Gela.Element_Utils; Node : Selective_Accept_Statement_Node renames Selective_Accept_Statement_Node (Element.all); Statement : constant Timed_Entry_Call_Statement_Ptr := new Timed_Entry_Call_Statement_Node; Tmp : Asis.Element; begin Copy_Element (Element, Asis.Element (Statement)); Tmp := Label_Names_List (Node); Set_Label_Names (Statement.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Statement (Statement)); Tmp := Statement_Paths_List (Node); Set_Statement_Paths (Statement.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Statement (Statement)); Element := Asis.Statement (Statement); end To_Timed_Entry_Call; ------------------------------- -- To_Conditional_Entry_Call -- ------------------------------- procedure To_Conditional_Entry_Call (Element : in out Asis.Statement) is use Asis.Gela.Elements.Stmt; use Asis.Gela.Element_Utils; Node : Selective_Accept_Statement_Node renames Selective_Accept_Statement_Node (Element.all); Statement : constant Conditional_Entry_Call_Statement_Ptr := new Conditional_Entry_Call_Statement_Node; Tmp : Asis.Element; begin Copy_Element (Element, Asis.Element (Statement)); Tmp := Label_Names_List (Node); Set_Label_Names (Statement.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Statement (Statement)); Tmp := Statement_Paths_List (Node); Set_Statement_Paths (Statement.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Statement (Statement)); Element := Asis.Statement (Statement); end To_Conditional_Entry_Call; ------------------------------- -- To_Enumeration_Rep_Clause -- ------------------------------- procedure To_Enumeration_Rep_Clause (Element : in out Asis.Statement) is use Asis.Gela.Element_Utils; use Asis.Gela.Elements.Clause.Rep; Result : Enumeration_Representation_Clause_Ptr := new Enumeration_Representation_Clause_Node; Expr : Asis.Element := Representation_Clause_Expression (Element.all); Temp : Asis.Element; Positional : Boolean := Could_Be_Positional_Array_Aggregate (Expr); begin Record_To_Array_Aggregate (Expr, Positional); Copy_Element (Element, Asis.Element (Result)); Set_Representation_Clause_Expression (Result.all, Expr); Set_Enclosing_Element (Expr, Asis.Element (Result)); Temp := Representation_Clause_Name (Element.all); Set_Representation_Clause_Name (Result.all, Temp); Set_Enclosing_Element (Temp, Asis.Element (Result)); Element := Asis.Element (Result); end To_Enumeration_Rep_Clause; end Asis.Gela.Replace; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- 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 Maxim Reznik, 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 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. ------------------------------------------------------------------------------
-- This spec has been automatically generated from STM32F303xE.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.EXTI is pragma Preelaborate; --------------- -- Registers -- --------------- -- IMR1_MR array element subtype IMR1_MR_Element is STM32_SVD.Bit; -- IMR1_MR array type IMR1_MR_Field_Array is array (0 .. 31) of IMR1_MR_Element with Component_Size => 1, Size => 32; -- Interrupt mask register type IMR1_Register (As_Array : Boolean := False) is record case As_Array is when False => -- MR as a value Val : STM32_SVD.UInt32; when True => -- MR as an array Arr : IMR1_MR_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for IMR1_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- EMR1_MR array element subtype EMR1_MR_Element is STM32_SVD.Bit; -- EMR1_MR array type EMR1_MR_Field_Array is array (0 .. 31) of EMR1_MR_Element with Component_Size => 1, Size => 32; -- Event mask register type EMR1_Register (As_Array : Boolean := False) is record case As_Array is when False => -- MR as a value Val : STM32_SVD.UInt32; when True => -- MR as an array Arr : EMR1_MR_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for EMR1_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- RTSR1_TR array element subtype RTSR1_TR_Element is STM32_SVD.Bit; -- RTSR1_TR array type RTSR1_TR_Field_Array is array (0 .. 22) of RTSR1_TR_Element with Component_Size => 1, Size => 23; -- Type definition for RTSR1_TR type RTSR1_TR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- TR as a value Val : STM32_SVD.UInt23; when True => -- TR as an array Arr : RTSR1_TR_Field_Array; end case; end record with Unchecked_Union, Size => 23; for RTSR1_TR_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- RTSR1_TR array type RTSR1_TR_Field_Array_1 is array (29 .. 31) of RTSR1_TR_Element with Component_Size => 1, Size => 3; -- Type definition for RTSR1_TR type RTSR1_TR_Field_1 (As_Array : Boolean := False) is record case As_Array is when False => -- TR as a value Val : STM32_SVD.UInt3; when True => -- TR as an array Arr : RTSR1_TR_Field_Array_1; end case; end record with Unchecked_Union, Size => 3; for RTSR1_TR_Field_1 use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- Rising Trigger selection register type RTSR1_Register is record -- Rising trigger event configuration of line 0 TR : RTSR1_TR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_28 : STM32_SVD.UInt6 := 16#0#; -- Rising trigger event configuration of line 29 TR_1 : RTSR1_TR_Field_1 := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RTSR1_Register use record TR at 0 range 0 .. 22; Reserved_23_28 at 0 range 23 .. 28; TR_1 at 0 range 29 .. 31; end record; -- FTSR1_TR array element subtype FTSR1_TR_Element is STM32_SVD.Bit; -- FTSR1_TR array type FTSR1_TR_Field_Array is array (0 .. 22) of FTSR1_TR_Element with Component_Size => 1, Size => 23; -- Type definition for FTSR1_TR type FTSR1_TR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- TR as a value Val : STM32_SVD.UInt23; when True => -- TR as an array Arr : FTSR1_TR_Field_Array; end case; end record with Unchecked_Union, Size => 23; for FTSR1_TR_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- FTSR1_TR array type FTSR1_TR_Field_Array_1 is array (29 .. 31) of FTSR1_TR_Element with Component_Size => 1, Size => 3; -- Type definition for FTSR1_TR type FTSR1_TR_Field_1 (As_Array : Boolean := False) is record case As_Array is when False => -- TR as a value Val : STM32_SVD.UInt3; when True => -- TR as an array Arr : FTSR1_TR_Field_Array_1; end case; end record with Unchecked_Union, Size => 3; for FTSR1_TR_Field_1 use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- Falling Trigger selection register type FTSR1_Register is record -- Falling trigger event configuration of line 0 TR : FTSR1_TR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_28 : STM32_SVD.UInt6 := 16#0#; -- Falling trigger event configuration of line 29 TR_1 : FTSR1_TR_Field_1 := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FTSR1_Register use record TR at 0 range 0 .. 22; Reserved_23_28 at 0 range 23 .. 28; TR_1 at 0 range 29 .. 31; end record; -- SWIER1_SWIER array element subtype SWIER1_SWIER_Element is STM32_SVD.Bit; -- SWIER1_SWIER array type SWIER1_SWIER_Field_Array is array (0 .. 22) of SWIER1_SWIER_Element with Component_Size => 1, Size => 23; -- Type definition for SWIER1_SWIER type SWIER1_SWIER_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SWIER as a value Val : STM32_SVD.UInt23; when True => -- SWIER as an array Arr : SWIER1_SWIER_Field_Array; end case; end record with Unchecked_Union, Size => 23; for SWIER1_SWIER_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- SWIER1_SWIER array type SWIER1_SWIER_Field_Array_1 is array (29 .. 31) of SWIER1_SWIER_Element with Component_Size => 1, Size => 3; -- Type definition for SWIER1_SWIER type SWIER1_SWIER_Field_1 (As_Array : Boolean := False) is record case As_Array is when False => -- SWIER as a value Val : STM32_SVD.UInt3; when True => -- SWIER as an array Arr : SWIER1_SWIER_Field_Array_1; end case; end record with Unchecked_Union, Size => 3; for SWIER1_SWIER_Field_1 use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- Software interrupt event register type SWIER1_Register is record -- Software Interrupt on line 0 SWIER : SWIER1_SWIER_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_28 : STM32_SVD.UInt6 := 16#0#; -- Software Interrupt on line 29 SWIER_1 : SWIER1_SWIER_Field_1 := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SWIER1_Register use record SWIER at 0 range 0 .. 22; Reserved_23_28 at 0 range 23 .. 28; SWIER_1 at 0 range 29 .. 31; end record; -- PR1_PR array element subtype PR1_PR_Element is STM32_SVD.Bit; -- PR1_PR array type PR1_PR_Field_Array is array (0 .. 22) of PR1_PR_Element with Component_Size => 1, Size => 23; -- Type definition for PR1_PR type PR1_PR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- PR as a value Val : STM32_SVD.UInt23; when True => -- PR as an array Arr : PR1_PR_Field_Array; end case; end record with Unchecked_Union, Size => 23; for PR1_PR_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- PR1_PR array type PR1_PR_Field_Array_1 is array (29 .. 31) of PR1_PR_Element with Component_Size => 1, Size => 3; -- Type definition for PR1_PR type PR1_PR_Field_1 (As_Array : Boolean := False) is record case As_Array is when False => -- PR as a value Val : STM32_SVD.UInt3; when True => -- PR as an array Arr : PR1_PR_Field_Array_1; end case; end record with Unchecked_Union, Size => 3; for PR1_PR_Field_1 use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- Pending register type PR1_Register is record -- Pending bit 0 PR : PR1_PR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_28 : STM32_SVD.UInt6 := 16#0#; -- Pending bit 29 PR_1 : PR1_PR_Field_1 := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PR1_Register use record PR at 0 range 0 .. 22; Reserved_23_28 at 0 range 23 .. 28; PR_1 at 0 range 29 .. 31; end record; -- IMR2_MR array element subtype IMR2_MR_Element is STM32_SVD.Bit; -- IMR2_MR array type IMR2_MR_Field_Array is array (32 .. 35) of IMR2_MR_Element with Component_Size => 1, Size => 4; -- Type definition for IMR2_MR type IMR2_MR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- MR as a value Val : STM32_SVD.UInt4; when True => -- MR as an array Arr : IMR2_MR_Field_Array; end case; end record with Unchecked_Union, Size => 4; for IMR2_MR_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt mask register type IMR2_Register is record -- Interrupt Mask on external/internal line 32 MR : IMR2_MR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_4_31 : STM32_SVD.UInt28 := 16#FFFFFFF#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IMR2_Register use record MR at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- EMR2_MR array element subtype EMR2_MR_Element is STM32_SVD.Bit; -- EMR2_MR array type EMR2_MR_Field_Array is array (32 .. 35) of EMR2_MR_Element with Component_Size => 1, Size => 4; -- Type definition for EMR2_MR type EMR2_MR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- MR as a value Val : STM32_SVD.UInt4; when True => -- MR as an array Arr : EMR2_MR_Field_Array; end case; end record with Unchecked_Union, Size => 4; for EMR2_MR_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Event mask register type EMR2_Register is record -- Event mask on external/internal line 32 MR : EMR2_MR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_4_31 : STM32_SVD.UInt28 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EMR2_Register use record MR at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- RTSR2_TR array element subtype RTSR2_TR_Element is STM32_SVD.Bit; -- RTSR2_TR array type RTSR2_TR_Field_Array is array (32 .. 33) of RTSR2_TR_Element with Component_Size => 1, Size => 2; -- Type definition for RTSR2_TR type RTSR2_TR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- TR as a value Val : STM32_SVD.UInt2; when True => -- TR as an array Arr : RTSR2_TR_Field_Array; end case; end record with Unchecked_Union, Size => 2; for RTSR2_TR_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Rising Trigger selection register type RTSR2_Register is record -- Rising trigger event configuration bit of line 32 TR : RTSR2_TR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_2_31 : STM32_SVD.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RTSR2_Register use record TR at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- FTSR2_TR array element subtype FTSR2_TR_Element is STM32_SVD.Bit; -- FTSR2_TR array type FTSR2_TR_Field_Array is array (32 .. 33) of FTSR2_TR_Element with Component_Size => 1, Size => 2; -- Type definition for FTSR2_TR type FTSR2_TR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- TR as a value Val : STM32_SVD.UInt2; when True => -- TR as an array Arr : FTSR2_TR_Field_Array; end case; end record with Unchecked_Union, Size => 2; for FTSR2_TR_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Falling Trigger selection register type FTSR2_Register is record -- Falling trigger event configuration bit of line 32 TR : FTSR2_TR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_2_31 : STM32_SVD.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FTSR2_Register use record TR at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- SWIER2_SWIER array element subtype SWIER2_SWIER_Element is STM32_SVD.Bit; -- SWIER2_SWIER array type SWIER2_SWIER_Field_Array is array (32 .. 33) of SWIER2_SWIER_Element with Component_Size => 1, Size => 2; -- Type definition for SWIER2_SWIER type SWIER2_SWIER_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SWIER as a value Val : STM32_SVD.UInt2; when True => -- SWIER as an array Arr : SWIER2_SWIER_Field_Array; end case; end record with Unchecked_Union, Size => 2; for SWIER2_SWIER_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Software interrupt event register type SWIER2_Register is record -- Software interrupt on line 32 SWIER : SWIER2_SWIER_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_2_31 : STM32_SVD.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SWIER2_Register use record SWIER at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- PR2_PR array element subtype PR2_PR_Element is STM32_SVD.Bit; -- PR2_PR array type PR2_PR_Field_Array is array (32 .. 33) of PR2_PR_Element with Component_Size => 1, Size => 2; -- Type definition for PR2_PR type PR2_PR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- PR as a value Val : STM32_SVD.UInt2; when True => -- PR as an array Arr : PR2_PR_Field_Array; end case; end record with Unchecked_Union, Size => 2; for PR2_PR_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Pending register type PR2_Register is record -- Pending bit on line 32 PR : PR2_PR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_2_31 : STM32_SVD.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PR2_Register use record PR at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- External interrupt/event controller type EXTI_Peripheral is record -- Interrupt mask register IMR1 : aliased IMR1_Register; -- Event mask register EMR1 : aliased EMR1_Register; -- Rising Trigger selection register RTSR1 : aliased RTSR1_Register; -- Falling Trigger selection register FTSR1 : aliased FTSR1_Register; -- Software interrupt event register SWIER1 : aliased SWIER1_Register; -- Pending register PR1 : aliased PR1_Register; -- Interrupt mask register IMR2 : aliased IMR2_Register; -- Event mask register EMR2 : aliased EMR2_Register; -- Rising Trigger selection register RTSR2 : aliased RTSR2_Register; -- Falling Trigger selection register FTSR2 : aliased FTSR2_Register; -- Software interrupt event register SWIER2 : aliased SWIER2_Register; -- Pending register PR2 : aliased PR2_Register; end record with Volatile; for EXTI_Peripheral use record IMR1 at 16#0# range 0 .. 31; EMR1 at 16#4# range 0 .. 31; RTSR1 at 16#8# range 0 .. 31; FTSR1 at 16#C# range 0 .. 31; SWIER1 at 16#10# range 0 .. 31; PR1 at 16#14# range 0 .. 31; IMR2 at 16#18# range 0 .. 31; EMR2 at 16#1C# range 0 .. 31; RTSR2 at 16#20# range 0 .. 31; FTSR2 at 16#24# range 0 .. 31; SWIER2 at 16#28# range 0 .. 31; PR2 at 16#2C# range 0 .. 31; end record; -- External interrupt/event controller EXTI_Periph : aliased EXTI_Peripheral with Import, Address => System'To_Address (16#40010400#); end STM32_SVD.EXTI;
package body ROSA.Tasks is procedure Create (Task_ID, Priority : in Unsigned_8; t : out Tasking) is begin t.Task_ID := Task_ID; t.Priority := Priority; t.State := Waiting; end Create; function Run (t : in Tasking) return Task_Status is begin if t.State /= Ready then return Not_Ready; end if; -- Fill this in later. return OK; end Run; function Suspend (t : in Tasking) return Task_Status is begin if t.State /= Running then return Not_Running; end if; -- Fill this in later. return OK; end Suspend; end ROSA.Tasks;
package body Test_Operator_Attribute is type Rec is record I : Integer := 0; end record; function Sum(L, R : Rec) return Integer is (R.I + L.I); function "+"(L, R : Rec) return Integer is (R.I + L.I); procedure Test is Foo : access function(L, R : Rec) return Integer := Sum'Access; Bar : access function(L, R : Rec) return Integer := "+"'Access; R, L : Rec; I : Integer; begin Bar := "+"'Access; I := R + L; I := "+"(R, L); end Test; end Test_Operator_Attribute;
pragma License (Unrestricted); -- implementation unit required by compiler package System.Wid_Bool is pragma Pure; -- required for Boolean'Width by compiler (s-widboo.ads) function Width_Boolean (Lo, Hi : Boolean) return Natural; end System.Wid_Bool;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . D E C O D E _ S T R I N G -- -- -- -- S p e c -- -- -- -- Copyright (C) 2007-2014, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides a utility routine for converting from an encoded -- string to a corresponding Wide_String or Wide_Wide_String value. with Interfaces; use Interfaces; with System.WCh_Cnv; use System.WCh_Cnv; with System.WCh_Con; use System.WCh_Con; package body GNAT.Decode_String is ----------------------- -- Local Subprograms -- ----------------------- procedure Bad; pragma No_Return (Bad); -- Raise error for bad encoding procedure Past_End; pragma No_Return (Past_End); -- Raise error for off end of string --------- -- Bad -- --------- procedure Bad is begin raise Constraint_Error with "bad encoding or character out of range"; end Bad; --------------------------- -- Decode_Wide_Character -- --------------------------- procedure Decode_Wide_Character (Input : String; Ptr : in out Natural; Result : out Wide_Character) is Char : Wide_Wide_Character; begin Decode_Wide_Wide_Character (Input, Ptr, Char); if Wide_Wide_Character'Pos (Char) > 16#FFFF# then Bad; else Result := Wide_Character'Val (Wide_Wide_Character'Pos (Char)); end if; end Decode_Wide_Character; ------------------------ -- Decode_Wide_String -- ------------------------ function Decode_Wide_String (S : String) return Wide_String is Result : Wide_String (1 .. S'Length); Length : Natural; begin Decode_Wide_String (S, Result, Length); return Result (1 .. Length); end Decode_Wide_String; procedure Decode_Wide_String (S : String; Result : out Wide_String; Length : out Natural) is Ptr : Natural; begin Ptr := S'First; Length := 0; while Ptr <= S'Last loop if Length >= Result'Last then Past_End; end if; Length := Length + 1; Decode_Wide_Character (S, Ptr, Result (Length)); end loop; end Decode_Wide_String; -------------------------------- -- Decode_Wide_Wide_Character -- -------------------------------- procedure Decode_Wide_Wide_Character (Input : String; Ptr : in out Natural; Result : out Wide_Wide_Character) is C : Character; function In_Char return Character; pragma Inline (In_Char); -- Function to get one input character ------------- -- In_Char -- ------------- function In_Char return Character is begin if Ptr <= Input'Last then Ptr := Ptr + 1; return Input (Ptr - 1); else Past_End; end if; end In_Char; -- Start of processing for Decode_Wide_Wide_Character begin C := In_Char; -- Special fast processing for UTF-8 case if Encoding_Method = WCEM_UTF8 then UTF8 : declare U : Unsigned_32; W : Unsigned_32; procedure Get_UTF_Byte; pragma Inline (Get_UTF_Byte); -- Used to interpret 2#10xxxxxx# continuation byte in UTF-8 mode. -- Reads a byte, and raises CE if the first two bits are not 10. -- Otherwise shifts W 6 bits left and or's in the 6 xxxxxx bits. ------------------ -- Get_UTF_Byte -- ------------------ procedure Get_UTF_Byte is begin U := Unsigned_32 (Character'Pos (In_Char)); if (U and 2#11000000#) /= 2#10_000000# then Bad; end if; W := Shift_Left (W, 6) or (U and 2#00111111#); end Get_UTF_Byte; -- Start of processing for UTF8 case begin -- Note: for details of UTF8 encoding see RFC 3629 U := Unsigned_32 (Character'Pos (C)); -- 16#00_0000#-16#00_007F#: 0xxxxxxx if (U and 2#10000000#) = 2#00000000# then Result := Wide_Wide_Character'Val (Character'Pos (C)); -- 16#00_0080#-16#00_07FF#: 110xxxxx 10xxxxxx elsif (U and 2#11100000#) = 2#110_00000# then W := U and 2#00011111#; Get_UTF_Byte; if W not in 16#00_0080# .. 16#00_07FF# then Bad; end if; Result := Wide_Wide_Character'Val (W); -- 16#00_0800#-16#00_ffff#: 1110xxxx 10xxxxxx 10xxxxxx elsif (U and 2#11110000#) = 2#1110_0000# then W := U and 2#00001111#; Get_UTF_Byte; Get_UTF_Byte; if W not in 16#00_0800# .. 16#00_FFFF# then Bad; end if; Result := Wide_Wide_Character'Val (W); -- 16#01_0000#-16#10_FFFF#: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx elsif (U and 2#11111000#) = 2#11110_000# then W := U and 2#00000111#; for K in 1 .. 3 loop Get_UTF_Byte; end loop; if W not in 16#01_0000# .. 16#10_FFFF# then Bad; end if; Result := Wide_Wide_Character'Val (W); -- 16#0020_0000#-16#03FF_FFFF#: 111110xx 10xxxxxx 10xxxxxx -- 10xxxxxx 10xxxxxx elsif (U and 2#11111100#) = 2#111110_00# then W := U and 2#00000011#; for K in 1 .. 4 loop Get_UTF_Byte; end loop; if W not in 16#0020_0000# .. 16#03FF_FFFF# then Bad; end if; Result := Wide_Wide_Character'Val (W); -- All other cases are invalid, note that this includes: -- 16#0400_0000#-16#7FFF_FFFF#: 1111110x 10xxxxxx 10xxxxxx -- 10xxxxxx 10xxxxxx 10xxxxxx -- since Wide_Wide_Character does not include code values -- greater than 16#03FF_FFFF#. else Bad; end if; end UTF8; -- All encoding functions other than UTF-8 else Non_UTF8 : declare function Char_Sequence_To_UTF is new Char_Sequence_To_UTF_32 (In_Char); begin -- For brackets, must test for specific case of [ not followed by -- quotation, where we must not call Char_Sequence_To_UTF, but -- instead just return the bracket unchanged. if Encoding_Method = WCEM_Brackets and then C = '[' and then (Ptr > Input'Last or else Input (Ptr) /= '"') then Result := '['; -- All other cases including [" with Brackets else Result := Wide_Wide_Character'Val (Char_Sequence_To_UTF (C, Encoding_Method)); end if; end Non_UTF8; end if; end Decode_Wide_Wide_Character; ----------------------------- -- Decode_Wide_Wide_String -- ----------------------------- function Decode_Wide_Wide_String (S : String) return Wide_Wide_String is Result : Wide_Wide_String (1 .. S'Length); Length : Natural; begin Decode_Wide_Wide_String (S, Result, Length); return Result (1 .. Length); end Decode_Wide_Wide_String; procedure Decode_Wide_Wide_String (S : String; Result : out Wide_Wide_String; Length : out Natural) is Ptr : Natural; begin Ptr := S'First; Length := 0; while Ptr <= S'Last loop if Length >= Result'Last then Past_End; end if; Length := Length + 1; Decode_Wide_Wide_Character (S, Ptr, Result (Length)); end loop; end Decode_Wide_Wide_String; ------------------------- -- Next_Wide_Character -- ------------------------- procedure Next_Wide_Character (Input : String; Ptr : in out Natural) is Discard : Wide_Character; begin Decode_Wide_Character (Input, Ptr, Discard); end Next_Wide_Character; ------------------------------ -- Next_Wide_Wide_Character -- ------------------------------ procedure Next_Wide_Wide_Character (Input : String; Ptr : in out Natural) is Discard : Wide_Wide_Character; begin Decode_Wide_Wide_Character (Input, Ptr, Discard); end Next_Wide_Wide_Character; -------------- -- Past_End -- -------------- procedure Past_End is begin raise Constraint_Error with "past end of string"; end Past_End; ------------------------- -- Prev_Wide_Character -- ------------------------- procedure Prev_Wide_Character (Input : String; Ptr : in out Natural) is begin if Ptr > Input'Last + 1 then Past_End; end if; -- Special efficient encoding for UTF-8 case if Encoding_Method = WCEM_UTF8 then UTF8 : declare U : Unsigned_32; procedure Getc; pragma Inline (Getc); -- Gets the character at Input (Ptr - 1) and returns code in U as -- Unsigned_32 value. On return Ptr is decremented by one. procedure Skip_UTF_Byte; pragma Inline (Skip_UTF_Byte); -- Checks that U is 2#10xxxxxx# and then calls Get ---------- -- Getc -- ---------- procedure Getc is begin if Ptr <= Input'First then Past_End; else Ptr := Ptr - 1; U := Unsigned_32 (Character'Pos (Input (Ptr))); end if; end Getc; ------------------- -- Skip_UTF_Byte -- ------------------- procedure Skip_UTF_Byte is begin if (U and 2#11000000#) = 2#10_000000# then Getc; else Bad; end if; end Skip_UTF_Byte; -- Start of processing for UTF-8 case begin -- 16#00_0000#-16#00_007F#: 0xxxxxxx Getc; if (U and 2#10000000#) = 2#00000000# then return; -- 16#00_0080#-16#00_07FF#: 110xxxxx 10xxxxxx else Skip_UTF_Byte; if (U and 2#11100000#) = 2#110_00000# then return; -- 16#00_0800#-16#00_ffff#: 1110xxxx 10xxxxxx 10xxxxxx else Skip_UTF_Byte; if (U and 2#11110000#) = 2#1110_0000# then return; -- Any other code is invalid, note that this includes: -- 16#01_0000#-16#10_FFFF#: 11110xxx 10xxxxxx 10xxxxxx -- 10xxxxxx -- 16#0020_0000#-16#03FF_FFFF#: 111110xx 10xxxxxx -- 10xxxxxx 10xxxxxx -- 10xxxxxx -- 16#0400_0000#-16#7FFF_FFFF#: 1111110x 10xxxxxx -- 10xxxxxx 10xxxxxx -- 10xxxxxx 10xxxxxx -- since Wide_Character does not allow codes > 16#FFFF# else Bad; end if; end if; end if; end UTF8; -- Special efficient encoding for brackets case elsif Encoding_Method = WCEM_Brackets then Brackets : declare P : Natural; S : Natural; begin -- See if we have "] at end positions if Ptr > Input'First + 1 and then Input (Ptr - 1) = ']' and then Input (Ptr - 2) = '"' then P := Ptr - 2; -- Loop back looking for [" at start while P >= Ptr - 10 loop if P <= Input'First + 1 then Bad; elsif Input (P - 1) = '"' and then Input (P - 2) = '[' then -- Found ["..."], scan forward to check it S := P - 2; P := S; Next_Wide_Character (Input, P); -- OK if at original pointer, else error if P = Ptr then Ptr := S; return; else Bad; end if; end if; P := P - 1; end loop; -- Falling through loop means more than 8 chars between the -- enclosing brackets (or simply a missing left bracket) Bad; -- Here if no bracket sequence present else if Ptr = Input'First then Past_End; else Ptr := Ptr - 1; end if; end if; end Brackets; -- Non-UTF-8/Brackets. These are the inefficient cases where we have to -- go to the start of the string and skip forwards till Ptr matches. else Non_UTF_Brackets : declare Discard : Wide_Character; PtrS : Natural; PtrP : Natural; begin PtrS := Input'First; if Ptr <= PtrS then Past_End; end if; loop PtrP := PtrS; Decode_Wide_Character (Input, PtrS, Discard); if PtrS = Ptr then Ptr := PtrP; return; elsif PtrS > Ptr then Bad; end if; end loop; exception when Constraint_Error => Bad; end Non_UTF_Brackets; end if; end Prev_Wide_Character; ------------------------------ -- Prev_Wide_Wide_Character -- ------------------------------ procedure Prev_Wide_Wide_Character (Input : String; Ptr : in out Natural) is begin if Ptr > Input'Last + 1 then Past_End; end if; -- Special efficient encoding for UTF-8 case if Encoding_Method = WCEM_UTF8 then UTF8 : declare U : Unsigned_32; procedure Getc; pragma Inline (Getc); -- Gets the character at Input (Ptr - 1) and returns code in U as -- Unsigned_32 value. On return Ptr is decremented by one. procedure Skip_UTF_Byte; pragma Inline (Skip_UTF_Byte); -- Checks that U is 2#10xxxxxx# and then calls Get ---------- -- Getc -- ---------- procedure Getc is begin if Ptr <= Input'First then Past_End; else Ptr := Ptr - 1; U := Unsigned_32 (Character'Pos (Input (Ptr))); end if; end Getc; ------------------- -- Skip_UTF_Byte -- ------------------- procedure Skip_UTF_Byte is begin if (U and 2#11000000#) = 2#10_000000# then Getc; else Bad; end if; end Skip_UTF_Byte; -- Start of processing for UTF-8 case begin -- 16#00_0000#-16#00_007F#: 0xxxxxxx Getc; if (U and 2#10000000#) = 2#00000000# then return; -- 16#00_0080#-16#00_07FF#: 110xxxxx 10xxxxxx else Skip_UTF_Byte; if (U and 2#11100000#) = 2#110_00000# then return; -- 16#00_0800#-16#00_ffff#: 1110xxxx 10xxxxxx 10xxxxxx else Skip_UTF_Byte; if (U and 2#11110000#) = 2#1110_0000# then return; -- 16#01_0000#-16#10_FFFF#: 11110xxx 10xxxxxx 10xxxxxx -- 10xxxxxx else Skip_UTF_Byte; if (U and 2#11111000#) = 2#11110_000# then return; -- 16#0020_0000#-16#03FF_FFFF#: 111110xx 10xxxxxx -- 10xxxxxx 10xxxxxx -- 10xxxxxx else Skip_UTF_Byte; if (U and 2#11111100#) = 2#111110_00# then return; -- Any other code is invalid, note that this includes: -- 16#0400_0000#-16#7FFF_FFFF#: 1111110x 10xxxxxx -- 10xxxxxx 10xxxxxx -- 10xxxxxx 10xxxxxx -- since Wide_Wide_Character does not allow codes -- greater than 16#03FF_FFFF# else Bad; end if; end if; end if; end if; end if; end UTF8; -- Special efficient encoding for brackets case elsif Encoding_Method = WCEM_Brackets then Brackets : declare P : Natural; S : Natural; begin -- See if we have "] at end positions if Ptr > Input'First + 1 and then Input (Ptr - 1) = ']' and then Input (Ptr - 2) = '"' then P := Ptr - 2; -- Loop back looking for [" at start while P >= Ptr - 10 loop if P <= Input'First + 1 then Bad; elsif Input (P - 1) = '"' and then Input (P - 2) = '[' then -- Found ["..."], scan forward to check it S := P - 2; P := S; Next_Wide_Wide_Character (Input, P); -- OK if at original pointer, else error if P = Ptr then Ptr := S; return; else Bad; end if; end if; P := P - 1; end loop; -- Falling through loop means more than 8 chars between the -- enclosing brackets (or simply a missing left bracket) Bad; -- Here if no bracket sequence present else if Ptr = Input'First then Past_End; else Ptr := Ptr - 1; end if; end if; end Brackets; -- Non-UTF-8/Brackets. These are the inefficient cases where we have to -- go to the start of the string and skip forwards till Ptr matches. else Non_UTF8_Brackets : declare Discard : Wide_Wide_Character; PtrS : Natural; PtrP : Natural; begin PtrS := Input'First; if Ptr <= PtrS then Past_End; end if; loop PtrP := PtrS; Decode_Wide_Wide_Character (Input, PtrS, Discard); if PtrS = Ptr then Ptr := PtrP; return; elsif PtrS > Ptr then Bad; end if; end loop; exception when Constraint_Error => Bad; end Non_UTF8_Brackets; end if; end Prev_Wide_Wide_Character; -------------------------- -- Validate_Wide_String -- -------------------------- function Validate_Wide_String (S : String) return Boolean is Ptr : Natural; begin Ptr := S'First; while Ptr <= S'Last loop Next_Wide_Character (S, Ptr); end loop; return True; exception when Constraint_Error => return False; end Validate_Wide_String; ------------------------------- -- Validate_Wide_Wide_String -- ------------------------------- function Validate_Wide_Wide_String (S : String) return Boolean is Ptr : Natural; begin Ptr := S'First; while Ptr <= S'Last loop Next_Wide_Wide_Character (S, Ptr); end loop; return True; exception when Constraint_Error => return False; end Validate_Wide_Wide_String; end GNAT.Decode_String;
with SPARKNaCl; use SPARKNaCl; with SPARKNaCl.Debug; use SPARKNaCl.Debug; with SPARKNaCl.MAC; use SPARKNaCl.MAC; with Random; with Interfaces; use Interfaces; with Ada.Numerics.Discrete_Random; procedure Onetimeauth7 is package RB is new Ada.Numerics.Discrete_Random (Byte); package RBI16 is new Ada.Numerics.Discrete_Random (Index_16); RBG : RB.Generator; RBI16G : RBI16.Generator; Raw_K : Bytes_32; K : Poly_1305_Key; A : Bytes_16; begin RB.Reset (RBG); RBI16.Reset (RBI16G); -- for I in N32 range 0 .. 9999 loop for I in N32 range 0 .. 99 loop declare subtype C_Index is N32 range 0 .. I; subtype CT is Byte_Seq (C_Index); package RCI is new Ada.Numerics.Discrete_Random (C_Index); RCIG : RCI.Generator; C : CT; R1 : C_Index; R2 : Byte; R3 : Index_16; begin RCI.Reset (RCIG); Random.Random_Bytes (C); Random.Random_Bytes (Raw_K); Construct (K, Raw_K); Onetimeauth (A, C, K); if not Onetimeauth_Verify (A, C, K) then DH ("Fail ", I64 (I)); return; end if; R1 := RCI.Random (RCIG); R2 := RB.Random (RBG) mod 255; C (R1) := C (R1) + 1 + R2; if Onetimeauth_Verify (A, C, K) then DH ("Forgery", I64 (I)); return; end if; R2 := RB.Random (RBG) mod 255; R3 := RBI16.Random (RBI16G); A (R3) := A (R3) + 1 + R2; if Onetimeauth_Verify (A, C, K) then DH ("Forgery", I64 (I)); return; end if; end; end loop; end Onetimeauth7;
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!DOCTYPE boost_serialization> <boost_serialization signature="serialization::archive" version="15"> <syndb class_id="0" tracking_level="0" version="0"> <userIPLatency>-1</userIPLatency> <userIPName></userIPName> <cdfg class_id="1" tracking_level="1" version="0" object_id="_0"> <name>ip2ps_fifo</name> <ret_bitwidth>0</ret_bitwidth> <ports class_id="2" tracking_level="0" version="0"> <count>6</count> <item_version>0</item_version> <item class_id="3" tracking_level="1" version="0" object_id="_1"> <Value class_id="4" tracking_level="0" version="0"> <Obj class_id="5" tracking_level="0" version="0"> <type>1</type> <id>1</id> <name>ip2ps_V_data_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo class_id="6" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>ip2ps.V.data.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>1</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs class_id="7" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_2"> <Value> <Obj> <type>1</type> <id>2</id> <name>ip2ps_V_strb_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>ip2ps.V.strb.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>4</bitwidth> </Value> <direction>1</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_3"> <Value> <Obj> <type>1</type> <id>3</id> <name>ip2ps_V_last_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>ip2ps.V.last.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>1</bitwidth> </Value> <direction>1</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_4"> <Value> <Obj> <type>1</type> <id>4</id> <name>ip2psFifo_V_data_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName>FIFO</coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>3</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_5"> <Value> <Obj> <type>1</type> <id>5</id> <name>ip2psFifo_V_strb_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName>FIFO</coreName> </Obj> <bitwidth>4</bitwidth> </Value> <direction>0</direction> <if_type>3</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_6"> <Value> <Obj> <type>1</type> <id>6</id> <name>ip2psFifo_V_last_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName>FIFO</coreName> </Obj> <bitwidth>1</bitwidth> </Value> <direction>0</direction> <if_type>3</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> </ports> <nodes class_id="8" tracking_level="0" version="0"> <count>9</count> <item_version>0</item_version> <item class_id="9" tracking_level="1" version="0" object_id="_7"> <Value> <Obj> <type>0</type> <id>12</id> <name>tmp</name> <fileName>my_ip_hls/ip2ps_fifo.cpp</fileName> <fileDirectory>C:\Users\CS\Desktop\Vivado-Projects\M3</fileDirectory> <lineNumber>14</lineNumber> <contextFuncName>ip2ps_fifo</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item class_id="10" tracking_level="0" version="0"> <first>C:\Users\CS\Desktop\Vivado-Projects\M3</first> <second class_id="11" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="12" tracking_level="0" version="0"> <first class_id="13" tracking_level="0" version="0"> <first>my_ip_hls/ip2ps_fifo.cpp</first> <second>ip2ps_fifo</second> </first> <second>14</second> </item> </second> </item> </inlineStackInfo> <originalName>tmp</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>1</bitwidth> </Value> <oprand_edges> <count>5</count> <item_version>0</item_version> <item>25</item> <item>26</item> <item>27</item> <item>28</item> <item>30</item> </oprand_edges> <opcode>nbreadreq</opcode> <m_Display>0</m_Display> </item> <item class_id_reference="9" object_id="_8"> <Value> <Obj> <type>0</type> <id>13</id> <name></name> <fileName>my_ip_hls/ip2ps_fifo.cpp</fileName> <fileDirectory>C:\Users\CS\Desktop\Vivado-Projects\M3</fileDirectory> <lineNumber>14</lineNumber> <contextFuncName>ip2ps_fifo</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:\Users\CS\Desktop\Vivado-Projects\M3</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>my_ip_hls/ip2ps_fifo.cpp</first> <second>ip2ps_fifo</second> </first> <second>14</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>0</bitwidth> </Value> <oprand_edges> <count>3</count> <item_version>0</item_version> <item>31</item> <item>32</item> <item>33</item> </oprand_edges> <opcode>br</opcode> <m_Display>0</m_Display> </item> <item class_id_reference="9" object_id="_9"> <Value> <Obj> <type>0</type> <id>15</id> <name>empty</name> <fileName>my_ip_hls/ip2ps_fifo.cpp</fileName> <fileDirectory>C:\Users\CS\Desktop\Vivado-Projects\M3</fileDirectory> <lineNumber>16</lineNumber> <contextFuncName>ip2ps_fifo</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:\Users\CS\Desktop\Vivado-Projects\M3</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>my_ip_hls/ip2ps_fifo.cpp</first> <second>ip2ps_fifo</second> </first> <second>16</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>37</bitwidth> </Value> <oprand_edges> <count>5</count> <item_version>0</item_version> <item>35</item> <item>36</item> <item>37</item> <item>38</item> <item>141</item> </oprand_edges> <opcode>read</opcode> <m_Display>0</m_Display> </item> <item class_id_reference="9" object_id="_10"> <Value> <Obj> <type>0</type> <id>16</id> <name>tmp_data_V</name> <fileName>my_ip_hls/ip2ps_fifo.cpp</fileName> <fileDirectory>C:\Users\CS\Desktop\Vivado-Projects\M3</fileDirectory> <lineNumber>16</lineNumber> <contextFuncName>ip2ps_fifo</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:\Users\CS\Desktop\Vivado-Projects\M3</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>my_ip_hls/ip2ps_fifo.cpp</first> <second>ip2ps_fifo</second> </first> <second>16</second> </item> </second> </item> </inlineStackInfo> <originalName>tmp.data.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <oprand_edges> <count>1</count> <item_version>0</item_version> <item>39</item> </oprand_edges> <opcode>extractvalue</opcode> <m_Display>0</m_Display> </item> <item class_id_reference="9" object_id="_11"> <Value> <Obj> <type>0</type> <id>17</id> <name>tmp_strb_V</name> <fileName>my_ip_hls/ip2ps_fifo.cpp</fileName> <fileDirectory>C:\Users\CS\Desktop\Vivado-Projects\M3</fileDirectory> <lineNumber>16</lineNumber> <contextFuncName>ip2ps_fifo</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:\Users\CS\Desktop\Vivado-Projects\M3</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>my_ip_hls/ip2ps_fifo.cpp</first> <second>ip2ps_fifo</second> </first> <second>16</second> </item> </second> </item> </inlineStackInfo> <originalName>tmp.strb.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>4</bitwidth> </Value> <oprand_edges> <count>1</count> <item_version>0</item_version> <item>40</item> </oprand_edges> <opcode>extractvalue</opcode> <m_Display>0</m_Display> </item> <item class_id_reference="9" object_id="_12"> <Value> <Obj> <type>0</type> <id>18</id> <name>tmp_last_V</name> <fileName>my_ip_hls/ip2ps_fifo.cpp</fileName> <fileDirectory>C:\Users\CS\Desktop\Vivado-Projects\M3</fileDirectory> <lineNumber>16</lineNumber> <contextFuncName>ip2ps_fifo</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:\Users\CS\Desktop\Vivado-Projects\M3</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>my_ip_hls/ip2ps_fifo.cpp</first> <second>ip2ps_fifo</second> </first> <second>16</second> </item> </second> </item> </inlineStackInfo> <originalName>tmp.last.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>1</bitwidth> </Value> <oprand_edges> <count>1</count> <item_version>0</item_version> <item>41</item> </oprand_edges> <opcode>extractvalue</opcode> <m_Display>0</m_Display> </item> <item class_id_reference="9" object_id="_13"> <Value> <Obj> <type>0</type> <id>19</id> <name></name> <fileName>my_ip_hls/ip2ps_fifo.cpp</fileName> <fileDirectory>C:\Users\CS\Desktop\Vivado-Projects\M3</fileDirectory> <lineNumber>17</lineNumber> <contextFuncName>ip2ps_fifo</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:\Users\CS\Desktop\Vivado-Projects\M3</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>my_ip_hls/ip2ps_fifo.cpp</first> <second>ip2ps_fifo</second> </first> <second>17</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>0</bitwidth> </Value> <oprand_edges> <count>7</count> <item_version>0</item_version> <item>43</item> <item>44</item> <item>45</item> <item>46</item> <item>47</item> <item>48</item> <item>49</item> </oprand_edges> <opcode>write</opcode> <m_Display>0</m_Display> </item> <item class_id_reference="9" object_id="_14"> <Value> <Obj> <type>0</type> <id>20</id> <name></name> <fileName>my_ip_hls/ip2ps_fifo.cpp</fileName> <fileDirectory>C:\Users\CS\Desktop\Vivado-Projects\M3</fileDirectory> <lineNumber>18</lineNumber> <contextFuncName>ip2ps_fifo</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:\Users\CS\Desktop\Vivado-Projects\M3</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>my_ip_hls/ip2ps_fifo.cpp</first> <second>ip2ps_fifo</second> </first> <second>18</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>0</bitwidth> </Value> <oprand_edges> <count>1</count> <item_version>0</item_version> <item>50</item> </oprand_edges> <opcode>br</opcode> <m_Display>0</m_Display> </item> <item class_id_reference="9" object_id="_15"> <Value> <Obj> <type>0</type> <id>22</id> <name></name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>0</bitwidth> </Value> <oprand_edges> <count>0</count> <item_version>0</item_version> </oprand_edges> <opcode>ret</opcode> <m_Display>0</m_Display> </item> </nodes> <consts class_id="15" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="16" tracking_level="1" version="0" object_id="_16"> <Value> <Obj> <type>2</type> <id>29</id> <name>empty</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <const_type>0</const_type> <content>1</content> </item> </consts> <blocks class_id="17" tracking_level="0" version="0"> <count>3</count> <item_version>0</item_version> <item class_id="18" tracking_level="1" version="0" object_id="_17"> <Obj> <type>3</type> <id>14</id> <name>entry</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <node_objs> <count>2</count> <item_version>0</item_version> <item>12</item> <item>13</item> </node_objs> </item> <item class_id_reference="18" object_id="_18"> <Obj> <type>3</type> <id>21</id> <name></name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <node_objs> <count>6</count> <item_version>0</item_version> <item>15</item> <item>16</item> <item>17</item> <item>18</item> <item>19</item> <item>20</item> </node_objs> </item> <item class_id_reference="18" object_id="_19"> <Obj> <type>3</type> <id>23</id> <name>ip2ps_fifo.exit</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <node_objs> <count>1</count> <item_version>0</item_version> <item>22</item> </node_objs> </item> </blocks> <edges class_id="19" tracking_level="0" version="0"> <count>24</count> <item_version>0</item_version> <item class_id="20" tracking_level="1" version="0" object_id="_20"> <id>26</id> <edge_type>1</edge_type> <source_obj>4</source_obj> <sink_obj>12</sink_obj> </item> <item class_id_reference="20" object_id="_21"> <id>27</id> <edge_type>1</edge_type> <source_obj>5</source_obj> <sink_obj>12</sink_obj> </item> <item class_id_reference="20" object_id="_22"> <id>28</id> <edge_type>1</edge_type> <source_obj>6</source_obj> <sink_obj>12</sink_obj> </item> <item class_id_reference="20" object_id="_23"> <id>30</id> <edge_type>1</edge_type> <source_obj>29</source_obj> <sink_obj>12</sink_obj> </item> <item class_id_reference="20" object_id="_24"> <id>31</id> <edge_type>1</edge_type> <source_obj>12</source_obj> <sink_obj>13</sink_obj> </item> <item class_id_reference="20" object_id="_25"> <id>32</id> <edge_type>2</edge_type> <source_obj>23</source_obj> <sink_obj>13</sink_obj> </item> <item class_id_reference="20" object_id="_26"> <id>33</id> <edge_type>2</edge_type> <source_obj>21</source_obj> <sink_obj>13</sink_obj> </item> <item class_id_reference="20" object_id="_27"> <id>36</id> <edge_type>1</edge_type> <source_obj>4</source_obj> <sink_obj>15</sink_obj> </item> <item class_id_reference="20" object_id="_28"> <id>37</id> <edge_type>1</edge_type> <source_obj>5</source_obj> <sink_obj>15</sink_obj> </item> <item class_id_reference="20" object_id="_29"> <id>38</id> <edge_type>1</edge_type> <source_obj>6</source_obj> <sink_obj>15</sink_obj> </item> <item class_id_reference="20" object_id="_30"> <id>39</id> <edge_type>1</edge_type> <source_obj>15</source_obj> <sink_obj>16</sink_obj> </item> <item class_id_reference="20" object_id="_31"> <id>40</id> <edge_type>1</edge_type> <source_obj>15</source_obj> <sink_obj>17</sink_obj> </item> <item class_id_reference="20" object_id="_32"> <id>41</id> <edge_type>1</edge_type> <source_obj>15</source_obj> <sink_obj>18</sink_obj> </item> <item class_id_reference="20" object_id="_33"> <id>44</id> <edge_type>1</edge_type> <source_obj>1</source_obj> <sink_obj>19</sink_obj> </item> <item class_id_reference="20" object_id="_34"> <id>45</id> <edge_type>1</edge_type> <source_obj>2</source_obj> <sink_obj>19</sink_obj> </item> <item class_id_reference="20" object_id="_35"> <id>46</id> <edge_type>1</edge_type> <source_obj>3</source_obj> <sink_obj>19</sink_obj> </item> <item class_id_reference="20" object_id="_36"> <id>47</id> <edge_type>1</edge_type> <source_obj>16</source_obj> <sink_obj>19</sink_obj> </item> <item class_id_reference="20" object_id="_37"> <id>48</id> <edge_type>1</edge_type> <source_obj>17</source_obj> <sink_obj>19</sink_obj> </item> <item class_id_reference="20" object_id="_38"> <id>49</id> <edge_type>1</edge_type> <source_obj>18</source_obj> <sink_obj>19</sink_obj> </item> <item class_id_reference="20" object_id="_39"> <id>50</id> <edge_type>2</edge_type> <source_obj>23</source_obj> <sink_obj>20</sink_obj> </item> <item class_id_reference="20" object_id="_40"> <id>138</id> <edge_type>2</edge_type> <source_obj>14</source_obj> <sink_obj>21</sink_obj> </item> <item class_id_reference="20" object_id="_41"> <id>139</id> <edge_type>2</edge_type> <source_obj>14</source_obj> <sink_obj>23</sink_obj> </item> <item class_id_reference="20" object_id="_42"> <id>140</id> <edge_type>2</edge_type> <source_obj>21</source_obj> <sink_obj>23</sink_obj> </item> <item class_id_reference="20" object_id="_43"> <id>141</id> <edge_type>4</edge_type> <source_obj>12</source_obj> <sink_obj>15</sink_obj> </item> </edges> </cdfg> <cdfg_regions class_id="21" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="22" tracking_level="1" version="0" object_id="_44"> <mId>1</mId> <mTag>ip2ps_fifo</mTag> <mType>0</mType> <sub_regions> <count>0</count> <item_version>0</item_version> </sub_regions> <basic_blocks> <count>3</count> <item_version>0</item_version> <item>14</item> <item>21</item> <item>23</item> </basic_blocks> <mII>1</mII> <mDepth>3</mDepth> <mMinTripCount>-1</mMinTripCount> <mMaxTripCount>-1</mMaxTripCount> <mMinLatency>2</mMinLatency> <mMaxLatency>-1</mMaxLatency> <mIsDfPipe>0</mIsDfPipe> <mDfPipe class_id="-1"></mDfPipe> </item> </cdfg_regions> <fsm class_id="24" tracking_level="1" version="0" object_id="_45"> <states class_id="25" tracking_level="0" version="0"> <count>3</count> <item_version>0</item_version> <item class_id="26" tracking_level="1" version="0" object_id="_46"> <id>1</id> <operations class_id="27" tracking_level="0" version="0"> <count>6</count> <item_version>0</item_version> <item class_id="28" tracking_level="1" version="0" object_id="_47"> <id>12</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_48"> <id>13</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_49"> <id>15</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_50"> <id>16</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_51"> <id>17</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_52"> <id>18</id> <stage>1</stage> <latency>1</latency> </item> </operations> </item> <item class_id_reference="26" object_id="_53"> <id>2</id> <operations> <count>1</count> <item_version>0</item_version> <item class_id_reference="28" object_id="_54"> <id>19</id> <stage>2</stage> <latency>2</latency> </item> </operations> </item> <item class_id_reference="26" object_id="_55"> <id>3</id> <operations> <count>8</count> <item_version>0</item_version> <item class_id_reference="28" object_id="_56"> <id>7</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_57"> <id>8</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_58"> <id>9</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_59"> <id>10</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_60"> <id>11</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_61"> <id>19</id> <stage>1</stage> <latency>2</latency> </item> <item class_id_reference="28" object_id="_62"> <id>20</id> <stage>1</stage> <latency>1</latency> </item> <item class_id_reference="28" object_id="_63"> <id>22</id> <stage>1</stage> <latency>1</latency> </item> </operations> </item> </states> <transitions class_id="29" tracking_level="0" version="0"> <count>2</count> <item_version>0</item_version> <item class_id="30" tracking_level="1" version="0" object_id="_64"> <inState>1</inState> <outState>2</outState> <condition class_id="31" tracking_level="0" version="0"> <id>9</id> <sop class_id="32" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="33" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </item> </sop> </condition> </item> <item class_id_reference="30" object_id="_65"> <inState>2</inState> <outState>3</outState> <condition> <id>10</id> <sop> <count>1</count> <item_version>0</item_version> <item> <count>0</count> <item_version>0</item_version> </item> </sop> </condition> </item> </transitions> </fsm> <res class_id="-1"></res> <node_label_latency class_id="35" tracking_level="0" version="0"> <count>9</count> <item_version>0</item_version> <item class_id="36" tracking_level="0" version="0"> <first>12</first> <second class_id="37" tracking_level="0" version="0"> <first>0</first> <second>0</second> </second> </item> <item> <first>13</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>15</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>16</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>17</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>18</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>19</first> <second> <first>1</first> <second>1</second> </second> </item> <item> <first>20</first> <second> <first>2</first> <second>0</second> </second> </item> <item> <first>22</first> <second> <first>2</first> <second>0</second> </second> </item> </node_label_latency> <bblk_ent_exit class_id="38" tracking_level="0" version="0"> <count>3</count> <item_version>0</item_version> <item class_id="39" tracking_level="0" version="0"> <first>14</first> <second class_id="40" tracking_level="0" version="0"> <first>0</first> <second>2</second> </second> </item> <item> <first>21</first> <second> <first>0</first> <second>2</second> </second> </item> <item> <first>23</first> <second> <first>2</first> <second>2</second> </second> </item> </bblk_ent_exit> <regions class_id="41" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="42" tracking_level="1" version="0" object_id="_66"> <region_name>ip2ps_fifo</region_name> <basic_blocks> <count>3</count> <item_version>0</item_version> <item>14</item> <item>21</item> <item>23</item> </basic_blocks> <nodes> <count>0</count> <item_version>0</item_version> </nodes> <anchor_node>-1</anchor_node> <region_type>8</region_type> <interval>1</interval> <pipe_depth>3</pipe_depth> </item> </regions> <dp_fu_nodes class_id="43" tracking_level="0" version="0"> <count>6</count> <item_version>0</item_version> <item class_id="44" tracking_level="0" version="0"> <first>42</first> <second> <count>1</count> <item_version>0</item_version> <item>12</item> </second> </item> <item> <first>54</first> <second> <count>1</count> <item_version>0</item_version> <item>15</item> </second> </item> <item> <first>64</first> <second> <count>2</count> <item_version>0</item_version> <item>19</item> <item>19</item> </second> </item> <item> <first>77</first> <second> <count>1</count> <item_version>0</item_version> <item>16</item> </second> </item> <item> <first>81</first> <second> <count>1</count> <item_version>0</item_version> <item>17</item> </second> </item> <item> <first>85</first> <second> <count>1</count> <item_version>0</item_version> <item>18</item> </second> </item> </dp_fu_nodes> <dp_fu_nodes_expression class_id="46" tracking_level="0" version="0"> <count>3</count> <item_version>0</item_version> <item class_id="47" tracking_level="0" version="0"> <first>tmp_data_V_fu_77</first> <second> <count>1</count> <item_version>0</item_version> <item>16</item> </second> </item> <item> <first>tmp_last_V_fu_85</first> <second> <count>1</count> <item_version>0</item_version> <item>18</item> </second> </item> <item> <first>tmp_strb_V_fu_81</first> <second> <count>1</count> <item_version>0</item_version> <item>17</item> </second> </item> </dp_fu_nodes_expression> <dp_fu_nodes_module> <count>0</count> <item_version>0</item_version> </dp_fu_nodes_module> <dp_fu_nodes_io> <count>3</count> <item_version>0</item_version> <item> <first>empty_read_fu_54</first> <second> <count>1</count> <item_version>0</item_version> <item>15</item> </second> </item> <item> <first>grp_write_fu_64</first> <second> <count>2</count> <item_version>0</item_version> <item>19</item> <item>19</item> </second> </item> <item> <first>tmp_nbreadreq_fu_42</first> <second> <count>1</count> <item_version>0</item_version> <item>12</item> </second> </item> </dp_fu_nodes_io> <return_ports> <count>0</count> <item_version>0</item_version> </return_ports> <dp_mem_port_nodes class_id="48" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </dp_mem_port_nodes> <dp_reg_nodes> <count>4</count> <item_version>0</item_version> <item> <first>89</first> <second> <count>1</count> <item_version>0</item_version> <item>12</item> </second> </item> <item> <first>93</first> <second> <count>1</count> <item_version>0</item_version> <item>16</item> </second> </item> <item> <first>98</first> <second> <count>1</count> <item_version>0</item_version> <item>17</item> </second> </item> <item> <first>103</first> <second> <count>1</count> <item_version>0</item_version> <item>18</item> </second> </item> </dp_reg_nodes> <dp_regname_nodes> <count>4</count> <item_version>0</item_version> <item> <first>tmp_data_V_reg_93</first> <second> <count>1</count> <item_version>0</item_version> <item>16</item> </second> </item> <item> <first>tmp_last_V_reg_103</first> <second> <count>1</count> <item_version>0</item_version> <item>18</item> </second> </item> <item> <first>tmp_reg_89</first> <second> <count>1</count> <item_version>0</item_version> <item>12</item> </second> </item> <item> <first>tmp_strb_V_reg_98</first> <second> <count>1</count> <item_version>0</item_version> <item>17</item> </second> </item> </dp_regname_nodes> <dp_reg_phi> <count>0</count> <item_version>0</item_version> </dp_reg_phi> <dp_regname_phi> <count>0</count> <item_version>0</item_version> </dp_regname_phi> <dp_port_io_nodes class_id="49" tracking_level="0" version="0"> <count>6</count> <item_version>0</item_version> <item class_id="50" tracking_level="0" version="0"> <first>ip2psFifo_V_data_V</first> <second> <count>2</count> <item_version>0</item_version> <item> <first>nbreadreq</first> <second> <count>1</count> <item_version>0</item_version> <item>12</item> </second> </item> <item> <first>read</first> <second> <count>1</count> <item_version>0</item_version> <item>15</item> </second> </item> </second> </item> <item> <first>ip2psFifo_V_last_V</first> <second> <count>2</count> <item_version>0</item_version> <item> <first>nbreadreq</first> <second> <count>1</count> <item_version>0</item_version> <item>12</item> </second> </item> <item> <first>read</first> <second> <count>1</count> <item_version>0</item_version> <item>15</item> </second> </item> </second> </item> <item> <first>ip2psFifo_V_strb_V</first> <second> <count>2</count> <item_version>0</item_version> <item> <first>nbreadreq</first> <second> <count>1</count> <item_version>0</item_version> <item>12</item> </second> </item> <item> <first>read</first> <second> <count>1</count> <item_version>0</item_version> <item>15</item> </second> </item> </second> </item> <item> <first>ip2ps_V_data_V</first> <second> <count>1</count> <item_version>0</item_version> <item> <first>write</first> <second> <count>1</count> <item_version>0</item_version> <item>19</item> </second> </item> </second> </item> <item> <first>ip2ps_V_last_V</first> <second> <count>1</count> <item_version>0</item_version> <item> <first>write</first> <second> <count>1</count> <item_version>0</item_version> <item>19</item> </second> </item> </second> </item> <item> <first>ip2ps_V_strb_V</first> <second> <count>1</count> <item_version>0</item_version> <item> <first>write</first> <second> <count>1</count> <item_version>0</item_version> <item>19</item> </second> </item> </second> </item> </dp_port_io_nodes> <port2core class_id="51" tracking_level="0" version="0"> <count>3</count> <item_version>0</item_version> <item class_id="52" tracking_level="0" version="0"> <first>4</first> <second>FIFO</second> </item> <item> <first>5</first> <second>FIFO</second> </item> <item> <first>6</first> <second>FIFO</second> </item> </port2core> <node2core> <count>0</count> <item_version>0</item_version> </node2core> </syndb> </boost_serialization>
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . T R A C E B A C K _ E N T R I E S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2003-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. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the Alpha/OpenVMS version of this package package System.Traceback_Entries is pragma Preelaborate; type Traceback_Entry is record PC : System.Address; PV : System.Address; end record; pragma Suppress_Initialization (Traceback_Entry); Null_TB_Entry : constant Traceback_Entry := (PC => System.Null_Address, PV => System.Null_Address); function PC_For (TB_Entry : Traceback_Entry) return System.Address; function PV_For (TB_Entry : Traceback_Entry) return System.Address; function TB_Entry_For (PC : System.Address) return Traceback_Entry; end System.Traceback_Entries;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright Β© 2012, 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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.DI.Styles.Hash is new AMF.Elements.Generic_Hash (DI_Style, DI_Style_Access);
-- Generated by Snowball 2.2.0 - https://snowballstem.org/ package body Stemmer.English is pragma Style_Checks ("-mr"); pragma Warnings (Off, "*variable*is never read and never assigned*"); pragma Warnings (Off, "*mode could be*instead of*"); pragma Warnings (Off, "*formal parameter.*is not modified*"); pragma Warnings (Off, "*this line is too long*"); pragma Warnings (Off, "*is not referenced*"); procedure R_Exception2 (Z : in out Context_Type; Result : out Boolean); procedure R_Exception1 (Z : in out Context_Type; Result : out Boolean); procedure R_Step_5 (Z : in out Context_Type; Result : out Boolean); procedure R_Step_4 (Z : in out Context_Type; Result : out Boolean); procedure R_Step_3 (Z : in out Context_Type; Result : out Boolean); procedure R_Step_2 (Z : in out Context_Type; Result : out Boolean); procedure R_Step_1c (Z : in out Context_Type; Result : out Boolean); procedure R_Step_1b (Z : in out Context_Type; Result : out Boolean); procedure R_Step_1a (Z : in out Context_Type; Result : out Boolean); procedure R_R2 (Z : in out Context_Type; Result : out Boolean); procedure R_R1 (Z : in out Context_Type; Result : out Boolean); procedure R_Shortv (Z : in out Context_Type; Result : out Boolean); procedure R_Mark_regions (Z : in out Context_Type; Result : out Boolean); procedure R_Postlude (Z : in out Context_Type; Result : out Boolean); procedure R_Prelude (Z : in out Context_Type; Result : out Boolean); G_V : constant Grouping_Array (0 .. 31) := ( True, False, False, False, True, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, True, False, False, False, False, False, False, False ); G_V_WXY : constant Grouping_Array (0 .. 39) := ( True, False, False, False, False, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, True, True, True, False, False, False, False, False, False, False ); G_Valid_LI : constant Grouping_Array (0 .. 23) := ( True, True, True, False, True, True, False, False, True, False, True, True, False, False, False, True, False, True, False, False, False, False, False, False ); Among_String : constant String := "arsen" & "commun" & "gener" & "'" & "'s'" & "'s" & "ied" & "s" & "ies" & "sses" & "ss" & "us" & "" & "bb" & "dd" & "ff" & "gg" & "bl" & "mm" & "nn" & "pp" & "rr" & "at" & "tt" & "iz" & "ed" & "eed" & "ing" & "edly" & "eedly" & "ingly" & "anci" & "enci" & "ogi" & "li" & "bli" & "abli" & "alli" & "fulli" & "lessli" & "ousli" & "entli" & "aliti" & "biliti" & "iviti" & "tional" & "ational" & "alism" & "ation" & "ization" & "izer" & "ator" & "iveness" & "fulness" & "ousness" & "icate" & "ative" & "alize" & "iciti" & "ical" & "tional" & "ational" & "ful" & "ness" & "ic" & "ance" & "ence" & "able" & "ible" & "ate" & "ive" & "ize" & "iti" & "al" & "ism" & "ion" & "er" & "ous" & "ant" & "ent" & "ment" & "ement" & "e" & "l" & "succeed" & "proceed" & "exceed" & "canning" & "inning" & "earring" & "herring" & "outing" & "andes" & "atlas" & "bias" & "cosmos" & "dying" & "early" & "gently" & "howe" & "idly" & "lying" & "news" & "only" & "singly" & "skies" & "skis" & "sky" & "tying" & "ugly"; A_0 : constant Among_Array_Type (0 .. 2) := ( (1, 5, -1, -1, 0), (6, 11, -1, -1, 0), (12, 16, -1, -1, 0)); A_1 : constant Among_Array_Type (0 .. 2) := ( (17, 17, -1, 1, 0), (18, 20, 0, 1, 0), (21, 22, -1, 1, 0)); A_2 : constant Among_Array_Type (0 .. 5) := ( (23, 25, -1, 2, 0), (26, 26, -1, 3, 0), (27, 29, 1, 2, 0), (30, 33, 1, 1, 0), (34, 35, 1, -1, 0), (36, 37, 1, -1, 0)); A_3 : constant Among_Array_Type (0 .. 12) := ( (38, 37, -1, 3, 0), (38, 39, 0, 2, 0), (40, 41, 0, 2, 0), (42, 43, 0, 2, 0), (44, 45, 0, 2, 0), (46, 47, 0, 1, 0), (48, 49, 0, 2, 0), (50, 51, 0, 2, 0), (52, 53, 0, 2, 0), (54, 55, 0, 2, 0), (56, 57, 0, 1, 0), (58, 59, 0, 2, 0), (60, 61, 0, 1, 0)); A_4 : constant Among_Array_Type (0 .. 5) := ( (62, 63, -1, 2, 0), (64, 66, 0, 1, 0), (67, 69, -1, 2, 0), (70, 73, -1, 2, 0), (74, 78, 3, 1, 0), (79, 83, -1, 2, 0)); A_5 : constant Among_Array_Type (0 .. 23) := ( (84, 87, -1, 3, 0), (88, 91, -1, 2, 0), (92, 94, -1, 13, 0), (95, 96, -1, 15, 0), (97, 99, 3, 12, 0), (100, 103, 4, 4, 0), (104, 107, 3, 8, 0), (108, 112, 3, 9, 0), (113, 118, 3, 14, 0), (119, 123, 3, 10, 0), (124, 128, 3, 5, 0), (129, 133, -1, 8, 0), (134, 139, -1, 12, 0), (140, 144, -1, 11, 0), (145, 150, -1, 1, 0), (151, 157, 14, 7, 0), (158, 162, -1, 8, 0), (163, 167, -1, 7, 0), (168, 174, 17, 6, 0), (175, 178, -1, 6, 0), (179, 182, -1, 7, 0), (183, 189, -1, 11, 0), (190, 196, -1, 9, 0), (197, 203, -1, 10, 0)); A_6 : constant Among_Array_Type (0 .. 8) := ( (204, 208, -1, 4, 0), (209, 213, -1, 6, 0), (214, 218, -1, 3, 0), (219, 223, -1, 4, 0), (224, 227, -1, 4, 0), (228, 233, -1, 1, 0), (234, 240, 5, 2, 0), (241, 243, -1, 5, 0), (244, 247, -1, 5, 0)); A_7 : constant Among_Array_Type (0 .. 17) := ( (248, 249, -1, 1, 0), (250, 253, -1, 1, 0), (254, 257, -1, 1, 0), (258, 261, -1, 1, 0), (262, 265, -1, 1, 0), (266, 268, -1, 1, 0), (269, 271, -1, 1, 0), (272, 274, -1, 1, 0), (275, 277, -1, 1, 0), (278, 279, -1, 1, 0), (280, 282, -1, 1, 0), (283, 285, -1, 2, 0), (286, 287, -1, 1, 0), (288, 290, -1, 1, 0), (291, 293, -1, 1, 0), (294, 296, -1, 1, 0), (297, 300, 15, 1, 0), (301, 305, 16, 1, 0)); A_8 : constant Among_Array_Type (0 .. 1) := ( (306, 306, -1, 1, 0), (307, 307, -1, 2, 0)); A_9 : constant Among_Array_Type (0 .. 7) := ( (308, 314, -1, -1, 0), (315, 321, -1, -1, 0), (322, 327, -1, -1, 0), (328, 334, -1, -1, 0), (335, 340, -1, -1, 0), (341, 347, -1, -1, 0), (348, 354, -1, -1, 0), (355, 360, -1, -1, 0)); A_10 : constant Among_Array_Type (0 .. 17) := ( (361, 365, -1, -1, 0), (366, 370, -1, -1, 0), (371, 374, -1, -1, 0), (375, 380, -1, -1, 0), (381, 385, -1, 3, 0), (386, 390, -1, 9, 0), (391, 396, -1, 7, 0), (397, 400, -1, -1, 0), (401, 404, -1, 6, 0), (405, 409, -1, 4, 0), (410, 413, -1, -1, 0), (414, 417, -1, 10, 0), (418, 423, -1, 11, 0), (424, 428, -1, 2, 0), (429, 432, -1, 1, 0), (433, 435, -1, -1, 0), (436, 440, -1, 5, 0), (441, 444, -1, 8, 0)); procedure R_Prelude (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; v_2 : Char_Index; v_3 : Char_Index; v_4 : Char_Index; v_5 : Char_Index; begin -- (, line 25 -- unset Y_found, line 26 Z.B_Y_found := False; -- do, line 27 v_1 := Z.C; -- (, line 27 Z.Bra := Z.C; -- [, line 27 -- literal, line 27 C := Eq_S (Z, "'"); if C = 0 then goto lab0; end if; Z.C := Z.C + C; Z.Ket := Z.C; -- ], line 27 -- delete, line 27 Slice_Del (Z); <<lab0>> Z.C := v_1; -- do, line 28 v_2 := Z.C; -- (, line 28 Z.Bra := Z.C; -- [, line 28 -- literal, line 28 C := Eq_S (Z, "y"); if C = 0 then goto lab1; end if; Z.C := Z.C + C; Z.Ket := Z.C; -- ], line 28 -- <-, line 28 Slice_From (Z, "Y"); -- set Y_found, line 28 Z.B_Y_found := True; <<lab1>> Z.C := v_2; -- do, line 29 v_3 := Z.C; -- repeat, line 29 <<lab3>> loop v_4 := Z.C; -- (, line 29 -- goto, line 29 loop v_5 := Z.C; -- (, line 29 In_Grouping (Z, G_V, 97, 121, False, C); if C /= 0 then goto lab6; end if; Z.Bra := Z.C; -- [, line 29 -- literal, line 29 C := Eq_S (Z, "y"); if C = 0 then goto lab6; end if; Z.C := Z.C + C; Z.Ket := Z.C; -- ], line 29 Z.C := v_5; exit; <<lab6>> Z.C := v_5; if Z.C >= Z.L then goto lab4; end if; -- goto, line 29 C := Skip_Utf8 (Z); if C < 0 then goto lab4; end if; Z.C := C; end loop; -- <-, line 29 Slice_From (Z, "Y"); -- set Y_found, line 29 Z.B_Y_found := True; goto lab3; <<lab4>> Z.C := v_4; exit; end loop; <<lab2>> Z.C := v_3; Result := True; end R_Prelude; procedure R_Mark_regions (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; v_2 : Char_Index; begin -- (, line 32 Z.I_P1 := Z.L; Z.I_P2 := Z.L; -- do, line 35 v_1 := Z.C; -- (, line 35 -- or, line 41 v_2 := Z.C; -- among, line 36 if Z.C + 4 >= Z.L or else Check_Among (Z, Z.C + 4, 3, 16#244000#) then goto lab2; -- among, line 36 end if; Find_Among (Z, A_0, Among_String, null, A); if A = 0 then goto lab2; end if; goto lab1; <<lab2>> Z.C := v_2; -- (, line 41 -- gopast, line 41 -- grouping v, line 41 Out_Grouping (Z, G_V, 97, 121, True, C); if C < 0 then goto lab0; end if; Z.C := Z.C + C; -- gopast, line 41 -- non v, line 41 In_Grouping (Z, G_V, 97, 121, True, C); if C < 0 then goto lab0; end if; Z.C := Z.C + C; <<lab1>> -- setmark p1, line 42 Z.I_P1 := Z.C; -- gopast, line 43 -- grouping v, line 43 Out_Grouping (Z, G_V, 97, 121, True, C); if C < 0 then goto lab0; end if; Z.C := Z.C + C; -- gopast, line 43 -- non v, line 43 In_Grouping (Z, G_V, 97, 121, True, C); if C < 0 then goto lab0; end if; Z.C := Z.C + C; -- setmark p2, line 43 Z.I_P2 := Z.C; <<lab0>> Z.C := v_1; Result := True; end R_Mark_regions; procedure R_Shortv (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; begin -- or, line 51 v_1 := Z.L - Z.C; -- (, line 50 Out_Grouping_Backward (Z, G_V_WXY, 89, 121, False, C); if C /= 0 then goto lab1; end if; In_Grouping_Backward (Z, G_V, 97, 121, False, C); if C /= 0 then goto lab1; end if; Out_Grouping_Backward (Z, G_V, 97, 121, False, C); if C /= 0 then goto lab1; end if; goto lab0; <<lab1>> Z.C := Z.L - v_1; -- (, line 52 Out_Grouping_Backward (Z, G_V, 97, 121, False, C); if C /= 0 then Result := False; return; end if; In_Grouping_Backward (Z, G_V, 97, 121, False, C); if C /= 0 then Result := False; return; end if; -- atlimit, line 52 if Z.C > Z.Lb then Result := False; return; end if; <<lab0>> Result := True; end R_Shortv; procedure R_R1 (Z : in out Context_Type; Result : out Boolean) is begin Result := (Z.I_P1 <= Z.C); end R_R1; procedure R_R2 (Z : in out Context_Type; Result : out Boolean) is begin Result := (Z.I_P2 <= Z.C); end R_R2; procedure R_Step_1a (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; v_2 : Char_Index; begin -- (, line 58 -- try, line 59 v_1 := Z.L - Z.C; -- (, line 59 Z.Ket := Z.C; -- [, line 60 -- substring, line 60 if Z.C <= Z.Lb or else (Character'Pos (Z.P (Z.C)) /= 39 and then Character'Pos (Z.P (Z.C)) /= 115) then Z.C := Z.L - v_1; goto lab0; -- substring, line 60 end if; Find_Among_Backward (Z, A_1, Among_String, null, A); if A = 0 then Z.C := Z.L - v_1; goto lab0; end if; Z.Bra := Z.C; -- ], line 60 -- (, line 62 -- delete, line 62 Slice_Del (Z); <<lab0>> Z.Ket := Z.C; -- [, line 65 -- substring, line 65 if Z.C <= Z.Lb or else (Character'Pos (Z.P (Z.C)) /= 100 and then Character'Pos (Z.P (Z.C)) /= 115) then Result := False; return; -- substring, line 65 end if; Find_Among_Backward (Z, A_2, Among_String, null, A); if A = 0 then Result := False; return; end if; Z.Bra := Z.C; -- ], line 65 -- among, line 65 case A is when 1 => -- (, line 66 -- <-, line 66 Slice_From (Z, "ss"); when 2 => -- (, line 68 -- or, line 68 v_2 := Z.L - Z.C; -- (, line 68 C := Skip_Utf8_Backward (Z, 2); -- hop, line 68 if C < 0 then goto lab2; end if; Z.C := C; -- <-, line 68 Slice_From (Z, "i"); goto lab1; <<lab2>> Z.C := Z.L - v_2; -- <-, line 68 Slice_From (Z, "ie"); <<lab1>> when 3 => -- (, line 69 -- next, line 69 C := Skip_Utf8_Backward (Z); if C < 0 then Result := False; return; end if; Z.C := C; -- gopast, line 69 -- grouping v, line 69 Out_Grouping_Backward (Z, G_V, 97, 121, True, C); if C < 0 then Result := False; return; end if; Z.C := Z.C - C; -- delete, line 69 Slice_Del (Z); when others => null; end case; Result := True; end R_Step_1a; procedure R_Step_1b (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; v_2 : Char_Index; v_3 : Char_Index; begin -- (, line 74 Z.Ket := Z.C; -- [, line 75 -- substring, line 75 if Z.C - 1 <= Z.Lb or else Check_Among (Z, Z.C - 1, 3, 16#2000090#) then Result := False; return; -- substring, line 75 end if; Find_Among_Backward (Z, A_4, Among_String, null, A); if A = 0 then Result := False; return; end if; Z.Bra := Z.C; -- ], line 75 -- among, line 75 case A is when 1 => -- (, line 77 -- call R1, line 77 R_R1 (Z, Result); if not Result then Result := False; return; end if; -- <-, line 77 Slice_From (Z, "ee"); when 2 => -- (, line 79 -- test, line 80 v_1 := Z.L - Z.C; -- gopast, line 80 -- grouping v, line 80 Out_Grouping_Backward (Z, G_V, 97, 121, True, C); if C < 0 then Result := False; return; end if; Z.C := Z.C - C; Z.C := Z.L - v_1; -- delete, line 80 Slice_Del (Z); -- test, line 81 v_2 := Z.L - Z.C; -- substring, line 81 if Z.C - 1 <= Z.Lb or else Check_Among (Z, Z.C - 1, 3, 16#41570d4#) then A := 3; else -- substring, line 81 Find_Among_Backward (Z, A_3, Among_String, null, A); if A = 0 then Result := False; return; end if; end if; Z.C := Z.L - v_2; -- among, line 81 case A is when 1 => -- (, line 83 -- <+, line 83 C := Z.C; Insert (Z, Z.C, Z.C, "e"); Z.C := C; when 2 => -- (, line 86 Z.Ket := Z.C; -- [, line 86 -- next, line 86 C := Skip_Utf8_Backward (Z); if C < 0 then Result := False; return; end if; Z.C := C; Z.Bra := Z.C; -- ], line 86 -- delete, line 86 Slice_Del (Z); when 3 => -- (, line 87 -- atmark, line 87 if Z.C /= Z.I_P1 then Result := False; return; end if; -- test, line 87 v_3 := Z.L - Z.C; -- call shortv, line 87 R_Shortv (Z, Result); if not Result then Result := False; return; end if; Z.C := Z.L - v_3; -- <+, line 87 C := Z.C; Insert (Z, Z.C, Z.C, "e"); Z.C := C; when others => null; end case; when others => null; end case; Result := True; end R_Step_1b; procedure R_Step_1c (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; begin -- (, line 93 Z.Ket := Z.C; -- [, line 94 -- or, line 94 v_1 := Z.L - Z.C; -- literal, line 94 C := Eq_S_Backward (Z, "y"); if C = 0 then goto lab1; end if; Z.C := Z.C - C; goto lab0; <<lab1>> Z.C := Z.L - v_1; -- literal, line 94 C := Eq_S_Backward (Z, "Y"); if C = 0 then Result := False; return; end if; Z.C := Z.C - C; <<lab0>> Z.Bra := Z.C; -- ], line 94 Out_Grouping_Backward (Z, G_V, 97, 121, False, C); if C /= 0 then Result := False; return; end if; -- not, line 95 -- atlimit, line 95 if Z.C > Z.Lb then goto lab2; end if; Result := False; return; <<lab2>> -- <-, line 96 Slice_From (Z, "i"); Result := True; end R_Step_1c; procedure R_Step_2 (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; begin -- (, line 99 Z.Ket := Z.C; -- [, line 100 -- substring, line 100 if Z.C - 1 <= Z.Lb or else Check_Among (Z, Z.C - 1, 3, 16#c7200#) then Result := False; return; -- substring, line 100 end if; Find_Among_Backward (Z, A_5, Among_String, null, A); if A = 0 then Result := False; return; end if; Z.Bra := Z.C; -- ], line 100 -- call R1, line 100 R_R1 (Z, Result); if not Result then Result := False; return; end if; -- among, line 100 case A is when 1 => -- (, line 101 -- <-, line 101 Slice_From (Z, "tion"); when 2 => -- (, line 102 -- <-, line 102 Slice_From (Z, "ence"); when 3 => -- (, line 103 -- <-, line 103 Slice_From (Z, "ance"); when 4 => -- (, line 104 -- <-, line 104 Slice_From (Z, "able"); when 5 => -- (, line 105 -- <-, line 105 Slice_From (Z, "ent"); when 6 => -- (, line 107 -- <-, line 107 Slice_From (Z, "ize"); when 7 => -- (, line 109 -- <-, line 109 Slice_From (Z, "ate"); when 8 => -- (, line 111 -- <-, line 111 Slice_From (Z, "al"); when 9 => -- (, line 112 -- <-, line 112 Slice_From (Z, "ful"); when 10 => -- (, line 114 -- <-, line 114 Slice_From (Z, "ous"); when 11 => -- (, line 116 -- <-, line 116 Slice_From (Z, "ive"); when 12 => -- (, line 118 -- <-, line 118 Slice_From (Z, "ble"); when 13 => -- (, line 119 -- literal, line 119 C := Eq_S_Backward (Z, "l"); if C = 0 then Result := False; return; end if; Z.C := Z.C - C; -- <-, line 119 Slice_From (Z, "og"); when 14 => -- (, line 121 -- <-, line 121 Slice_From (Z, "less"); when 15 => -- (, line 122 In_Grouping_Backward (Z, G_Valid_LI, 99, 116, False, C); if C /= 0 then Result := False; return; end if; -- delete, line 122 Slice_Del (Z); when others => null; end case; Result := True; end R_Step_2; procedure R_Step_3 (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; begin -- (, line 126 Z.Ket := Z.C; -- [, line 127 -- substring, line 127 if Z.C - 2 <= Z.Lb or else Check_Among (Z, Z.C - 1, 3, 16#81220#) then Result := False; return; -- substring, line 127 end if; Find_Among_Backward (Z, A_6, Among_String, null, A); if A = 0 then Result := False; return; end if; Z.Bra := Z.C; -- ], line 127 -- call R1, line 127 R_R1 (Z, Result); if not Result then Result := False; return; end if; -- among, line 127 case A is when 1 => -- (, line 128 -- <-, line 128 Slice_From (Z, "tion"); when 2 => -- (, line 129 -- <-, line 129 Slice_From (Z, "ate"); when 3 => -- (, line 130 -- <-, line 130 Slice_From (Z, "al"); when 4 => -- (, line 132 -- <-, line 132 Slice_From (Z, "ic"); when 5 => -- (, line 134 -- delete, line 134 Slice_Del (Z); when 6 => -- (, line 136 -- call R2, line 136 R_R2 (Z, Result); if not Result then Result := False; return; end if; -- delete, line 136 Slice_Del (Z); when others => null; end case; Result := True; end R_Step_3; procedure R_Step_4 (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; begin -- (, line 140 Z.Ket := Z.C; -- [, line 141 -- substring, line 141 if Z.C - 1 <= Z.Lb or else Check_Among (Z, Z.C - 1, 3, 16#1c7228#) then Result := False; return; -- substring, line 141 end if; Find_Among_Backward (Z, A_7, Among_String, null, A); if A = 0 then Result := False; return; end if; Z.Bra := Z.C; -- ], line 141 -- call R2, line 141 R_R2 (Z, Result); if not Result then Result := False; return; end if; -- among, line 141 case A is when 1 => -- (, line 144 -- delete, line 144 Slice_Del (Z); when 2 => -- (, line 145 -- or, line 145 v_1 := Z.L - Z.C; -- literal, line 145 C := Eq_S_Backward (Z, "s"); if C = 0 then goto lab1; end if; Z.C := Z.C - C; goto lab0; <<lab1>> Z.C := Z.L - v_1; -- literal, line 145 C := Eq_S_Backward (Z, "t"); if C = 0 then Result := False; return; end if; Z.C := Z.C - C; <<lab0>> -- delete, line 145 Slice_Del (Z); when others => null; end case; Result := True; end R_Step_4; procedure R_Step_5 (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; v_2 : Char_Index; begin -- (, line 149 Z.Ket := Z.C; -- [, line 150 -- substring, line 150 if Z.C <= Z.Lb or else (Character'Pos (Z.P (Z.C)) /= 101 and then Character'Pos (Z.P (Z.C)) /= 108) then Result := False; return; -- substring, line 150 end if; Find_Among_Backward (Z, A_8, Among_String, null, A); if A = 0 then Result := False; return; end if; Z.Bra := Z.C; -- ], line 150 -- among, line 150 case A is when 1 => -- (, line 151 -- or, line 151 v_1 := Z.L - Z.C; -- call R2, line 151 R_R2 (Z, Result); if not Result then goto lab1; end if; goto lab0; <<lab1>> Z.C := Z.L - v_1; -- (, line 151 -- call R1, line 151 R_R1 (Z, Result); if not Result then Result := False; return; end if; -- not, line 151 v_2 := Z.L - Z.C; -- call shortv, line 151 R_Shortv (Z, Result); if not Result then goto lab2; end if; Result := False; return; <<lab2>> Z.C := Z.L - v_2; <<lab0>> -- delete, line 151 Slice_Del (Z); when 2 => -- (, line 152 -- call R2, line 152 R_R2 (Z, Result); if not Result then Result := False; return; end if; -- literal, line 152 C := Eq_S_Backward (Z, "l"); if C = 0 then Result := False; return; end if; Z.C := Z.C - C; -- delete, line 152 Slice_Del (Z); when others => null; end case; Result := True; end R_Step_5; procedure R_Exception2 (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; begin -- (, line 156 Z.Ket := Z.C; -- [, line 158 -- substring, line 158 if Z.C - 5 <= Z.Lb or else (Character'Pos (Z.P (Z.C)) /= 100 and then Character'Pos (Z.P (Z.C)) /= 103) then Result := False; return; -- substring, line 158 end if; Find_Among_Backward (Z, A_9, Among_String, null, A); if A = 0 then Result := False; return; end if; Z.Bra := Z.C; -- ], line 158 -- atlimit, line 158 if Z.C > Z.Lb then Result := False; return; end if; Result := True; end R_Exception2; procedure R_Exception1 (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; begin -- (, line 168 Z.Bra := Z.C; -- [, line 170 -- substring, line 170 if Z.C + 2 >= Z.L or else Check_Among (Z, Z.C + 2, 3, 16#28c5212#) then Result := False; return; -- substring, line 170 end if; Find_Among (Z, A_10, Among_String, null, A); if A = 0 then Result := False; return; end if; Z.Ket := Z.C; -- ], line 170 -- atlimit, line 170 if Z.C < Z.L then Result := False; return; end if; -- among, line 170 case A is when 1 => -- (, line 174 -- <-, line 174 Slice_From (Z, "ski"); when 2 => -- (, line 175 -- <-, line 175 Slice_From (Z, "sky"); when 3 => -- (, line 176 -- <-, line 176 Slice_From (Z, "die"); when 4 => -- (, line 177 -- <-, line 177 Slice_From (Z, "lie"); when 5 => -- (, line 178 -- <-, line 178 Slice_From (Z, "tie"); when 6 => -- (, line 182 -- <-, line 182 Slice_From (Z, "idl"); when 7 => -- (, line 183 -- <-, line 183 Slice_From (Z, "gentl"); when 8 => -- (, line 184 -- <-, line 184 Slice_From (Z, "ugli"); when 9 => -- (, line 185 -- <-, line 185 Slice_From (Z, "earli"); when 10 => -- (, line 186 -- <-, line 186 Slice_From (Z, "onli"); when 11 => -- (, line 187 -- <-, line 187 Slice_From (Z, "singl"); when others => null; end case; Result := True; end R_Exception1; procedure R_Postlude (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; v_2 : Char_Index; begin -- (, line 203 -- Boolean test Y_found, line 203 if not Z.B_Y_found then Result := False; return; end if; -- repeat, line 203 <<lab0>> loop v_1 := Z.C; -- (, line 203 -- goto, line 203 loop v_2 := Z.C; -- (, line 203 Z.Bra := Z.C; -- [, line 203 -- literal, line 203 C := Eq_S (Z, "Y"); if C = 0 then goto lab3; end if; Z.C := Z.C + C; Z.Ket := Z.C; -- ], line 203 Z.C := v_2; exit; <<lab3>> Z.C := v_2; if Z.C >= Z.L then goto lab1; end if; -- goto, line 203 C := Skip_Utf8 (Z); if C < 0 then goto lab1; end if; Z.C := C; end loop; -- <-, line 203 Slice_From (Z, "y"); goto lab0; <<lab1>> Z.C := v_1; exit; end loop; Result := True; end R_Postlude; procedure Stem (Z : in out Context_Type; Result : out Boolean) is C : Result_Index; A : Integer; v_1 : Char_Index; v_2 : Char_Index; v_5 : Char_Index; v_6 : Char_Index; v_7 : Char_Index; v_8 : Char_Index; v_9 : Char_Index; v_10 : Char_Index; v_11 : Char_Index; v_12 : Char_Index; v_13 : Char_Index; begin -- or, line 207 v_1 := Z.C; -- call exception1, line 207 R_Exception1 (Z, Result); if not Result then goto lab1; end if; goto lab0; <<lab1>> Z.C := v_1; -- not, line 208 v_2 := Z.C; C := Skip_Utf8 (Z, 3); -- hop, line 208 if C < 0 then goto lab3; end if; Z.C := C; goto lab2; <<lab3>> Z.C := v_2; goto lab0; <<lab2>> Z.C := v_1; -- (, line 208 -- do, line 209 -- call prelude, line 209 R_Prelude (Z, Result); -- do, line 210 -- call mark_regions, line 210 R_Mark_regions (Z, Result); Z.Lb := Z.C; Z.C := Z.L; -- backwards, line 211 -- (, line 211 -- do, line 213 v_5 := Z.L - Z.C; -- call Step_1a, line 213 R_Step_1a (Z, Result); Z.C := Z.L - v_5; -- or, line 215 v_6 := Z.L - Z.C; -- call exception2, line 215 R_Exception2 (Z, Result); if not Result then goto lab5; end if; goto lab4; <<lab5>> Z.C := Z.L - v_6; -- (, line 215 -- do, line 217 v_7 := Z.L - Z.C; -- call Step_1b, line 217 R_Step_1b (Z, Result); Z.C := Z.L - v_7; -- do, line 218 v_8 := Z.L - Z.C; -- call Step_1c, line 218 R_Step_1c (Z, Result); Z.C := Z.L - v_8; -- do, line 220 v_9 := Z.L - Z.C; -- call Step_2, line 220 R_Step_2 (Z, Result); Z.C := Z.L - v_9; -- do, line 221 v_10 := Z.L - Z.C; -- call Step_3, line 221 R_Step_3 (Z, Result); Z.C := Z.L - v_10; -- do, line 222 v_11 := Z.L - Z.C; -- call Step_4, line 222 R_Step_4 (Z, Result); Z.C := Z.L - v_11; -- do, line 224 v_12 := Z.L - Z.C; -- call Step_5, line 224 R_Step_5 (Z, Result); Z.C := Z.L - v_12; <<lab4>> Z.C := Z.Lb; -- do, line 227 v_13 := Z.C; -- call postlude, line 227 R_Postlude (Z, Result); Z.C := v_13; <<lab0>> Result := True; end Stem; end Stemmer.English;
------------------------------------------------------------------------------- -- -- FIXED TYPES -- -- Fixed_Short & Fixed_Sat_Short definitions -- -- The MIT License (MIT) -- -- Copyright (c) 2015 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. ------------------------------------------------------------------------------- with Ada.Unchecked_Conversion; package Fixed_Types.Short is Fixed_Depth : constant Positive := 16; type Fixed_Short is delta 1.0 / 2.0 ** (Fixed_Depth - 1) range -1.0 .. 1.0 with Size => Fixed_Depth; type Fixed_Sat_Short is new Fixed_Short; pragma Suppress (Overflow_Check, on => Fixed_Short); pragma Suppress (Range_Check, on => Fixed_Short); -- pragma Suppress (All_checks, on => Fixed_Short); type Fixed_Integer_Short is range -2**(Fixed_Depth - 1) .. 2**(Fixed_Depth - 1) - 1 with Size => Fixed_Depth; type Modular_Short is mod 2 ** Fixed_Depth with Size => Fixed_Depth; function To_Fixed_Integer_Short is new Ada.Unchecked_Conversion (Fixed_Short, Fixed_Integer_Short); function To_Fixed_Integer_Short is new Ada.Unchecked_Conversion (Fixed_Sat_Short, Fixed_Integer_Short); function To_Fixed_Short is new Ada.Unchecked_Conversion (Fixed_Integer_Short, Fixed_Short); function To_Fixed_Sat_Short is new Ada.Unchecked_Conversion (Fixed_Integer_Short, Fixed_Sat_Short); function Fixed_Short_To_Mod_Short is new Ada.Unchecked_Conversion (Fixed_Short, Modular_Short); function Fixed_Sat_Short_To_Mod_Short is new Ada.Unchecked_Conversion (Fixed_Sat_Short, Modular_Short); overriding function "abs" (A : Fixed_Sat_Short) return Fixed_Sat_Short; overriding function "+" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short; overriding function "-" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short; overriding function "-" (A : Fixed_Sat_Short) return Fixed_Sat_Short; not overriding function "*" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short; overriding function "*" (A : Fixed_Sat_Short; B : Integer) return Fixed_Sat_Short; end Fixed_Types.Short;
-- This spec has been automatically generated from STM32F7x9.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.DMA is pragma Preelaborate; --------------- -- Registers -- --------------- -- low interrupt status register type LISR_Register is record -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF0 : Boolean; -- unspecified Reserved_1_1 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF0 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF0 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF0 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF0 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF1 : Boolean; -- unspecified Reserved_7_7 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF1 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF1 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF1 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF1 : Boolean; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF2 : Boolean; -- unspecified Reserved_17_17 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF2 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF2 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF2 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF2 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF3 : Boolean; -- unspecified Reserved_23_23 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF3 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF3 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF3 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF3 : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LISR_Register use record FEIF0 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; DMEIF0 at 0 range 2 .. 2; TEIF0 at 0 range 3 .. 3; HTIF0 at 0 range 4 .. 4; TCIF0 at 0 range 5 .. 5; FEIF1 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; DMEIF1 at 0 range 8 .. 8; TEIF1 at 0 range 9 .. 9; HTIF1 at 0 range 10 .. 10; TCIF1 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; FEIF2 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; DMEIF2 at 0 range 18 .. 18; TEIF2 at 0 range 19 .. 19; HTIF2 at 0 range 20 .. 20; TCIF2 at 0 range 21 .. 21; FEIF3 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; DMEIF3 at 0 range 24 .. 24; TEIF3 at 0 range 25 .. 25; HTIF3 at 0 range 26 .. 26; TCIF3 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- high interrupt status register type HISR_Register is record -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF4 : Boolean; -- unspecified Reserved_1_1 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF4 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF4 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF4 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF4 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF5 : Boolean; -- unspecified Reserved_7_7 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF5 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF5 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF5 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF5 : Boolean; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF6 : Boolean; -- unspecified Reserved_17_17 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF6 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF6 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF6 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF6 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF7 : Boolean; -- unspecified Reserved_23_23 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF7 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF7 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF7 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF7 : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HISR_Register use record FEIF4 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; DMEIF4 at 0 range 2 .. 2; TEIF4 at 0 range 3 .. 3; HTIF4 at 0 range 4 .. 4; TCIF4 at 0 range 5 .. 5; FEIF5 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; DMEIF5 at 0 range 8 .. 8; TEIF5 at 0 range 9 .. 9; HTIF5 at 0 range 10 .. 10; TCIF5 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; FEIF6 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; DMEIF6 at 0 range 18 .. 18; TEIF6 at 0 range 19 .. 19; HTIF6 at 0 range 20 .. 20; TCIF6 at 0 range 21 .. 21; FEIF7 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; DMEIF7 at 0 range 24 .. 24; TEIF7 at 0 range 25 .. 25; HTIF7 at 0 range 26 .. 26; TCIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- low interrupt flag clear register type LIFCR_Register is record -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF0 : Boolean := False; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF0 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF0 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF0 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF0 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF1 : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF1 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF1 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF1 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF1 : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF2 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF2 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF2 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF2 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF2 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF3 : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF3 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF3 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF3 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF3 : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LIFCR_Register use record CFEIF0 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; CDMEIF0 at 0 range 2 .. 2; CTEIF0 at 0 range 3 .. 3; CHTIF0 at 0 range 4 .. 4; CTCIF0 at 0 range 5 .. 5; CFEIF1 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; CDMEIF1 at 0 range 8 .. 8; CTEIF1 at 0 range 9 .. 9; CHTIF1 at 0 range 10 .. 10; CTCIF1 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CFEIF2 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; CDMEIF2 at 0 range 18 .. 18; CTEIF2 at 0 range 19 .. 19; CHTIF2 at 0 range 20 .. 20; CTCIF2 at 0 range 21 .. 21; CFEIF3 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; CDMEIF3 at 0 range 24 .. 24; CTEIF3 at 0 range 25 .. 25; CHTIF3 at 0 range 26 .. 26; CTCIF3 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- high interrupt flag clear register type HIFCR_Register is record -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF4 : Boolean := False; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF4 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF4 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF4 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF4 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF5 : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF5 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF5 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF5 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF5 : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF6 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF6 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF6 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF6 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF6 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF7 : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF7 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF7 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF7 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF7 : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HIFCR_Register use record CFEIF4 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; CDMEIF4 at 0 range 2 .. 2; CTEIF4 at 0 range 3 .. 3; CHTIF4 at 0 range 4 .. 4; CTCIF4 at 0 range 5 .. 5; CFEIF5 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; CDMEIF5 at 0 range 8 .. 8; CTEIF5 at 0 range 9 .. 9; CHTIF5 at 0 range 10 .. 10; CTCIF5 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CFEIF6 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; CDMEIF6 at 0 range 18 .. 18; CTEIF6 at 0 range 19 .. 19; CHTIF6 at 0 range 20 .. 20; CTCIF6 at 0 range 21 .. 21; CFEIF7 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; CDMEIF7 at 0 range 24 .. 24; CTEIF7 at 0 range 25 .. 25; CHTIF7 at 0 range 26 .. 26; CTCIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -------------------------------- -- Stream cluster's Registers -- -------------------------------- subtype SxCR_Stream_DIR_Field is HAL.UInt2; subtype SxCR_Stream_PSIZE_Field is HAL.UInt2; subtype SxCR_Stream_MSIZE_Field is HAL.UInt2; subtype SxCR_Stream_PL_Field is HAL.UInt2; subtype SxCR_Stream_PBURST_Field is HAL.UInt2; subtype SxCR_Stream_MBURST_Field is HAL.UInt2; subtype SxCR_Stream_CHSEL_Field is HAL.UInt4; -- stream x configuration register type SxCR_Stream_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : SxCR_Stream_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : SxCR_Stream_PSIZE_Field := 16#0#; -- Memory data size MSIZE : SxCR_Stream_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : SxCR_Stream_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Peripheral burst transfer configuration PBURST : SxCR_Stream_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : SxCR_Stream_MBURST_Field := 16#0#; -- Channel selection CHSEL : SxCR_Stream_CHSEL_Field := 16#0#; -- unspecified Reserved_29_31 : HAL.UInt3 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SxCR_Stream_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; Reserved_20_20 at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 28; Reserved_29_31 at 0 range 29 .. 31; end record; subtype SxNDTR_Stream_NDT_Field is HAL.UInt16; -- stream x number of data register type SxNDTR_Stream_Register is record -- Number of data items to transfer NDT : SxNDTR_Stream_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SxNDTR_Stream_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SxFCR_Stream_FTH_Field is HAL.UInt2; subtype SxFCR_Stream_FS_Field is HAL.UInt3; -- stream x FIFO control register type SxFCR_Stream_Register is record -- FIFO threshold selection FTH : SxFCR_Stream_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : SxFCR_Stream_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SxFCR_Stream_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Stream registers type Stream_Cluster is record -- stream x configuration register SxCR : aliased SxCR_Stream_Register; -- stream x number of data register SxNDTR : aliased SxNDTR_Stream_Register; -- stream x peripheral address register SxPAR : aliased HAL.UInt32; -- stream x memory 0 address register SxM0AR : aliased HAL.UInt32; -- stream x memory 1 address register SxM1AR : aliased HAL.UInt32; -- stream x FIFO control register SxFCR : aliased SxFCR_Stream_Register; end record with Volatile, Size => 192; for Stream_Cluster use record SxCR at 16#0# range 0 .. 31; SxNDTR at 16#4# range 0 .. 31; SxPAR at 16#8# range 0 .. 31; SxM0AR at 16#C# range 0 .. 31; SxM1AR at 16#10# range 0 .. 31; SxFCR at 16#14# range 0 .. 31; end record; -- Stream registers type Stream_Clusters is array (0 .. 7) of Stream_Cluster; -------------------------------- -- Stream cluster's Registers -- -------------------------------- ----------------- -- Peripherals -- ----------------- -- DMA controller type DMA_Peripheral is record -- low interrupt status register LISR : aliased LISR_Register; -- high interrupt status register HISR : aliased HISR_Register; -- low interrupt flag clear register LIFCR : aliased LIFCR_Register; -- high interrupt flag clear register HIFCR : aliased HIFCR_Register; -- Stream registers Stream : aliased Stream_Clusters; end record with Volatile; for DMA_Peripheral use record LISR at 16#0# range 0 .. 31; HISR at 16#4# range 0 .. 31; LIFCR at 16#8# range 0 .. 31; HIFCR at 16#C# range 0 .. 31; Stream at 16#10# range 0 .. 1535; end record; -- DMA controller DMA1_Periph : aliased DMA_Peripheral with Import, Address => System'To_Address (16#40026000#); -- DMA controller DMA2_Periph : aliased DMA_Peripheral with Import, Address => System'To_Address (16#40026400#); end STM32_SVD.DMA;
-- Copyright 2008-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program 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 program. If not, see <http://www.gnu.org/licenses/>. procedure Comp_Bug is type Number_T (Exists : Boolean := False) is record case Exists is when True => Value : Natural range 0 .. 255; when False => null; end case; end record; pragma Pack (Number_T); X : Number_T; -- brobecker/2007-09-06: At the time when this issue (G904-017) was -- reported, the problem only reproduced if the variable was declared -- inside a function (in other words, stored on stack). Although -- the issue probably still existed when I tried moving this variable -- to a package spec, the symptoms inside GDB disappeared. begin X := (Exists => True, Value => 10); if X.Exists then -- STOP X.Value := X.Value + 1; end if; end Comp_Bug;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body SSD1306 is procedure Write_Command (This : SSD1306_Screen; Cmd : UInt8); procedure Write_Data (This : SSD1306_Screen; Data : UInt8_Array); ------------------- -- Write_Command -- ------------------- procedure Write_Command (This : SSD1306_Screen; Cmd : UInt8) is Status : I2C_Status; begin This.Port.Master_Transmit (Addr => SSD1306_I2C_Addr, Data => (1 => 0, 2 => (Cmd)), Status => Status); if Status /= Ok then -- No error handling... raise Program_Error; end if; end Write_Command; ---------------- -- Write_Data -- ---------------- procedure Write_Data (This : SSD1306_Screen; Data : UInt8_Array) is Status : I2C_Status; begin This.Port.Master_Transmit (Addr => SSD1306_I2C_Addr, Data => Data, Status => Status); if Status /= Ok then -- No error handling... raise Program_Error; end if; end Write_Data; ---------------- -- Initialize -- ---------------- procedure Initialize (This : in out SSD1306_Screen; External_VCC : Boolean) is begin if This.Width * This.Height /= (This.Buffer_Size_In_Byte * 8) then raise Program_Error with "Invalid screen parameters"; end if; This.RST.Clear; This.Time.Delay_Milliseconds (100); This.RST.Set; This.Time.Delay_Milliseconds (100); Write_Command (This, DISPLAY_OFF); Write_Command (This, SET_DISPLAY_CLOCK_DIV); Write_Command (This, 16#80#); Write_Command (This, SET_MULTIPLEX); Write_Command (This, UInt8 (This.Height - 1)); Write_Command (This, SET_DISPLAY_OFFSET); Write_Command (This, 16#00#); Write_Command (This, SET_START_LINE or 0); Write_Command (This, CHARGE_PUMP); Write_Command (This, (if External_VCC then 16#10# else 16#14#)); Write_Command (This, MEMORY_MODE); Write_Command (This, 16#00#); Write_Command (This, SEGREMAP or 1); Write_Command (This, COM_SCAN_DEC); Write_Command (This, SET_COMPINS); if This.Height > 32 then Write_Command (This, 16#12#); else Write_Command (This, 16#02#); end if; Write_Command (This, SET_CONTRAST); Write_Command (This, 16#AF#); Write_Command (This, SET_PRECHARGE); Write_Command (This, (if External_VCC then 16#22# else 16#F1#)); Write_Command (This, SET_VCOM_DETECT); Write_Command (This, 16#40#); Write_Command (This, DISPLAY_ALL_ON_RESUME); Write_Command (This, NORMAL_DISPLAY); Write_Command (This, DEACTIVATE_SCROLL); This.Device_Initialized := True; end Initialize; ----------------- -- Initialized -- ----------------- overriding function Initialized (This : SSD1306_Screen) return Boolean is (This.Device_Initialized); ------------- -- Turn_On -- ------------- procedure Turn_On (This : SSD1306_Screen) is begin Write_Command (This, DISPLAY_ON); end Turn_On; -------------- -- Turn_Off -- -------------- procedure Turn_Off (This : SSD1306_Screen) is begin Write_Command (This, DISPLAY_OFF); end Turn_Off; -------------------------- -- Display_Inversion_On -- -------------------------- procedure Display_Inversion_On (This : SSD1306_Screen) is begin Write_Command (This, INVERT_DISPLAY); end Display_Inversion_On; --------------------------- -- Display_Inversion_Off -- --------------------------- procedure Display_Inversion_Off (This : SSD1306_Screen) is begin Write_Command (This, NORMAL_DISPLAY); end Display_Inversion_Off; ---------------------- -- Write_Raw_Pixels -- ---------------------- procedure Write_Raw_Pixels (This : SSD1306_Screen; Data : HAL.UInt8_Array) is begin Write_Command (This, COLUMN_ADDR); Write_Command (This, 0); -- from Write_Command (This, UInt8 (This.Width - 1)); -- to Write_Command (This, PAGE_ADDR); Write_Command (This, 0); -- from Write_Command (This, UInt8 (This.Height / 8) - 1); -- to Write_Data (This, (1 => 16#40#) & Data); end Write_Raw_Pixels; -------------------- -- Get_Max_Layers -- -------------------- overriding function Max_Layers (This : SSD1306_Screen) return Positive is (1); ------------------ -- Is_Supported -- ------------------ overriding function Supported (This : SSD1306_Screen; Mode : FB_Color_Mode) return Boolean is (Mode = HAL.Bitmap.RGB_565); --------------------- -- Set_Orientation -- --------------------- overriding procedure Set_Orientation (This : in out SSD1306_Screen; Orientation : Display_Orientation) is begin null; end Set_Orientation; -------------- -- Set_Mode -- -------------- overriding procedure Set_Mode (This : in out SSD1306_Screen; Mode : Wait_Mode) is begin null; end Set_Mode; --------------- -- Get_Width -- --------------- overriding function Width (This : SSD1306_Screen) return Positive is (This.Width); ---------------- -- Get_Height -- ---------------- overriding function Height (This : SSD1306_Screen) return Positive is (This.Height); ---------------- -- Is_Swapped -- ---------------- overriding function Swapped (This : SSD1306_Screen) return Boolean is (False); -------------------- -- Set_Background -- -------------------- overriding procedure Set_Background (This : SSD1306_Screen; R, G, B : UInt8) is begin -- Does it make sense when there's no alpha channel... raise Program_Error; end Set_Background; ---------------------- -- Initialize_Layer -- ---------------------- overriding procedure Initialize_Layer (This : in out SSD1306_Screen; Layer : Positive; Mode : FB_Color_Mode; X : Natural := 0; Y : Natural := 0; Width : Positive := Positive'Last; Height : Positive := Positive'Last) is pragma Unreferenced (X, Y, Width, Height); begin if Layer /= 1 or else Mode /= M_1 then raise Program_Error; end if; This.Memory_Layer.Actual_Width := This.Width; This.Memory_Layer.Actual_Height := This.Height; This.Memory_Layer.Addr := This.Memory_Layer.Data'Address; This.Memory_Layer.Actual_Color_Mode := Mode; This.Layer_Initialized := True; end Initialize_Layer; ----------------- -- Initialized -- ----------------- overriding function Initialized (This : SSD1306_Screen; Layer : Positive) return Boolean is begin return Layer = 1 and then This.Layer_Initialized; end Initialized; ------------------ -- Update_Layer -- ------------------ overriding procedure Update_Layer (This : in out SSD1306_Screen; Layer : Positive; Copy_Back : Boolean := False) is pragma Unreferenced (Copy_Back); begin if Layer /= 1 then raise Program_Error; end if; This.Write_Raw_Pixels (This.Memory_Layer.Data); end Update_Layer; ------------------- -- Update_Layers -- ------------------- overriding procedure Update_Layers (This : in out SSD1306_Screen) is begin This.Update_Layer (1); end Update_Layers; -------------------- -- Get_Color_Mode -- -------------------- overriding function Color_Mode (This : SSD1306_Screen; Layer : Positive) return FB_Color_Mode is pragma Unreferenced (This); begin if Layer /= 1 then raise Program_Error; end if; return M_1; end Color_Mode; ----------------------- -- Get_Hidden_Buffer -- ----------------------- overriding function Hidden_Buffer (This : in out SSD1306_Screen; Layer : Positive) return not null HAL.Bitmap.Any_Bitmap_Buffer is begin if Layer /= 1 then raise Program_Error; end if; return This.Memory_Layer'Unchecked_Access; end Hidden_Buffer; -------------------- -- Get_Pixel_Size -- -------------------- overriding function Pixel_Size (This : SSD1306_Screen; Layer : Positive) return Positive is (1); --------------- -- Set_Pixel -- --------------- overriding procedure Set_Pixel (Buffer : in out SSD1306_Bitmap_Buffer; Pt : Point) is X : constant Natural := Buffer.Width - 1 - Pt.X; Y : constant Natural := Buffer.Height - 1 - Pt.Y; Index : constant Natural := X + (Y / 8) * Buffer.Actual_Width; Byte : UInt8 renames Buffer.Data (Buffer.Data'First + Index); begin if Buffer.Native_Source = 0 then Byte := Byte and not (Shift_Left (1, Y mod 8)); else Byte := Byte or Shift_Left (1, Y mod 8); end if; end Set_Pixel; --------------- -- Set_Pixel -- --------------- overriding procedure Set_Pixel (Buffer : in out SSD1306_Bitmap_Buffer; Pt : Point; Color : Bitmap_Color) is begin Buffer.Set_Pixel (Pt, (if Color = Black then 0 else 1)); end Set_Pixel; --------------- -- Set_Pixel -- --------------- overriding procedure Set_Pixel (Buffer : in out SSD1306_Bitmap_Buffer; Pt : Point; Raw : UInt32) is begin Buffer.Native_Source := Raw; Buffer.Set_Pixel (Pt); end Set_Pixel; ----------- -- Pixel -- ----------- overriding function Pixel (Buffer : SSD1306_Bitmap_Buffer; Pt : Point) return Bitmap_Color is begin return (if Buffer.Pixel (Pt) = 0 then Black else White); end Pixel; ----------- -- Pixel -- ----------- overriding function Pixel (Buffer : SSD1306_Bitmap_Buffer; Pt : Point) return UInt32 is X : constant Natural := Buffer.Width - 1 - Pt.X; Y : constant Natural := Buffer.Height - 1 - Pt.Y; Index : constant Natural := X + (Y / 8) * Buffer.Actual_Width; Byte : UInt8 renames Buffer.Data (Buffer.Data'First + Index); begin if (Byte and (Shift_Left (1, Y mod 8))) /= 0 then return 1; else return 0; end if; end Pixel; ---------- -- Fill -- ---------- overriding procedure Fill (Buffer : in out SSD1306_Bitmap_Buffer) is Val : constant UInt8 := (if Buffer.Native_Source /= 0 then 16#FF# else 0); begin Buffer.Data := (others => Val); end Fill; end SSD1306;
with Ada.Text_IO; with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A056 is use Ada.Text_IO; use Ada.Integer_Text_IO; Str : constant String (1 .. 12) := "Hello World "; Num : constant Integer := 2021; begin Put (Str); Put (Num, Width => 0); end A056;
------------------------------------------------------------------------------ -- 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. -- ------------------------------------------------------------------------------ procedure Natools.S_Expressions.Templates.Generic_Discrete_Render (Output : in out Ada.Streams.Root_Stream_Type'Class; Template : in out Lockable.Descriptor'Class; Value : in T) is Current_Value : T := T'First; Event : Events.Event := Template.Current_Event; begin loop case Event is when Events.Add_Atom => if Current_Value = Value then Output.Write (Template.Current_Atom); return; end if; when Events.Open_List => loop Template.Next (Event); case Event is when Events.Add_Atom => Output.Write (Template.Current_Atom); when others => return; end case; end loop; when Events.Close_List | Events.End_Of_Input | Events.Error => exit; end case; Template.Next (Event); Current_Value := T'Succ (Current_Value); end loop; Output.Write (To_Atom (Default_Image (Value))); end Natools.S_Expressions.Templates.Generic_Discrete_Render;
-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010 -- Lumen would not be possible without the support and contributions of a cast -- of thousands, including and primarily Rod Kay. -- This code is covered by the ISC License: -- -- Copyright Β© 2010, NiEstu -- -- 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. package Lumen.Events is -- Translated keysym type and value type Key_Category is (Key_Control, Key_Graphic, Key_Modifier, Key_Function, Key_Special, Key_Unknown, Key_Not_Translated); subtype Key_Symbol is Long_Integer; -- Keystroke and pointer modifiers type Modifier is (Mod_Shift, Mod_Lock, Mod_Control, Mod_1, Mod_2, Mod_3, Mod_4, Mod_5, Mod_Button_1, Mod_Button_2, Mod_Button_3, Mod_Button_4, Mod_Button_5); type Modifier_Set is array (Modifier) of Boolean; No_Modifiers : Modifier_Set := (others => False); Not_Character : exception; -- key symbol is not a Latin-1 character --------------------------------------------------------------------------- -- Key translation helpers -- Convert a Key_Symbol into a Latin-1 character; raises Not_Character if -- it's not possible. Character'Val is simpler. function To_Character (Symbol : in Key_Symbol) return Character; -- Convert a Key_Symbol into a UTF-8 encoded string; raises Not_Character -- if it's not possible. Really only useful for Latin-1 hibit chars, but -- works for all Latin-1 chars. function To_UTF_8 (Symbol : in Key_Symbol) return String; -- Convert a normal Latin-1 character to a Key_Symbol function To_Symbol (Char : in Character) return Key_Symbol; end Lumen.Events;
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h; with glib; with glib.Values; with System; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h; -- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h; -- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h; with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h; with glib; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstmessage_h; -- with GStreamer.GST_Low_Level.glib_2_0_glib_gquark_h; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h is -- unsupported macro: GST_TYPE_ELEMENT (gst_element_get_type ()) -- arg-macro: function GST_IS_ELEMENT (obj) -- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ELEMENT); -- arg-macro: function GST_IS_ELEMENT_CLASS (klass) -- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ELEMENT); -- arg-macro: function GST_ELEMENT_GET_CLASS (obj) -- return G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ELEMENT, GstElementClass); -- arg-macro: function GST_ELEMENT (obj) -- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ELEMENT, GstElement); -- arg-macro: function GST_ELEMENT_CLASS (klass) -- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_ELEMENT, GstElementClass); -- arg-macro: function GST_ELEMENT_CAST (obj) -- return (GstElement*)(obj); -- arg-macro: function GST_STATE (elem) -- return GST_ELEMENT_CAST(elem).current_state; -- arg-macro: function GST_STATE_NEXT (elem) -- return GST_ELEMENT_CAST(elem).next_state; -- arg-macro: function GST_STATE_PENDING (elem) -- return GST_ELEMENT_CAST(elem).pending_state; -- arg-macro: function GST_STATE_TARGET (elem) -- return GST_ELEMENT_CAST(elem).abidata.ABI.target_state; -- arg-macro: function GST_STATE_RETURN (elem) -- return GST_ELEMENT_CAST(elem).last_return; -- arg-macro: function GST_STATE_GET_NEXT (cur, pending) -- return (GstState)((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur))); -- arg-macro: function GST_STATE_TRANSITION (cur, next) -- return (GstStateChange)(((cur)<<3)or(next)); -- arg-macro: function GST_STATE_TRANSITION_CURRENT (trans) -- return (GstState)((trans)>>3); -- arg-macro: function GST_STATE_TRANSITION_NEXT (trans) -- return (GstState)((trans)and16#7#); -- arg-macro: function GST_ELEMENT_IS_LOCKED_STATE (elem) -- return GST_OBJECT_FLAG_IS_SET(elem,GST_ELEMENT_LOCKED_STATE); -- arg-macro: function GST_ELEMENT_NAME (elem) -- return GST_OBJECT_NAME(elem); -- arg-macro: function GST_ELEMENT_PARENT (elem) -- return GST_ELEMENT_CAST(GST_OBJECT_PARENT(elem)); -- arg-macro: function GST_ELEMENT_BUS (elem) -- return GST_ELEMENT_CAST(elem).bus; -- arg-macro: function GST_ELEMENT_CLOCK (elem) -- return GST_ELEMENT_CAST(elem).clock; -- arg-macro: function GST_ELEMENT_PADS (elem) -- return GST_ELEMENT_CAST(elem).pads; -- arg-macro: function GST_ELEMENT_START_TIME (elem) -- return GST_ELEMENT_CAST(elem).abidata.ABI.start_time; -- unsupported macro: GST_ELEMENT_ERROR(el,domain,code,text,debug) G_STMT_START { gchar *__txt = _gst_element_error_printf text; gchar *__dbg = _gst_element_error_printf debug; if (__txt) GST_WARNING_OBJECT (el, "error: %s", __txt); if (__dbg) GST_WARNING_OBJECT (el, "error: %s", __dbg); gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR, GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); } G_STMT_END -- unsupported macro: GST_ELEMENT_WARNING(el,domain,code,text,debug) G_STMT_START { gchar *__txt = _gst_element_error_printf text; gchar *__dbg = _gst_element_error_printf debug; if (__txt) GST_WARNING_OBJECT (el, "warning: %s", __txt); if (__dbg) GST_WARNING_OBJECT (el, "warning: %s", __dbg); gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING, GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); } G_STMT_END -- unsupported macro: GST_ELEMENT_INFO(el,domain,code,text,debug) G_STMT_START { gchar *__txt = _gst_element_error_printf text; gchar *__dbg = _gst_element_error_printf debug; if (__txt) GST_INFO_OBJECT (el, "info: %s", __txt); if (__dbg) GST_INFO_OBJECT (el, "info: %s", __dbg); gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_INFO, GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); } G_STMT_END -- arg-macro: function GST_STATE_GET_LOCK (elem) -- return GST_ELEMENT_CAST(elem).state_lock; -- arg-macro: function GST_STATE_GET_COND (elem) -- return GST_ELEMENT_CAST(elem).state_cond; -- arg-macro: procedure GST_STATE_LOCK (elem) -- g_static_rec_mutex_lock(GST_STATE_GET_LOCK(elem)) -- arg-macro: procedure GST_STATE_TRYLOCK (elem) -- g_static_rec_mutex_trylock(GST_STATE_GET_LOCK(elem)) -- arg-macro: procedure GST_STATE_UNLOCK (elem) -- g_static_rec_mutex_unlock(GST_STATE_GET_LOCK(elem)) -- arg-macro: procedure GST_STATE_UNLOCK_FULL (elem) -- g_static_rec_mutex_unlock_full(GST_STATE_GET_LOCK(elem)) -- arg-macro: procedure GST_STATE_LOCK_FULL (elem, t) -- g_static_rec_mutex_lock_full(GST_STATE_GET_LOCK(elem), t) -- arg-macro: procedure GST_STATE_WAIT (elem) -- g_cond_wait (GST_STATE_GET_COND (elem), GST_OBJECT_GET_LOCK (elem)) -- arg-macro: procedure GST_STATE_TIMED_WAIT (elem, timeval) -- g_cond_timed_wait (GST_STATE_GET_COND (elem), GST_OBJECT_GET_LOCK (elem), timeval) -- arg-macro: procedure GST_STATE_SIGNAL (elem) -- g_cond_signal (GST_STATE_GET_COND (elem)); -- arg-macro: procedure GST_STATE_BROADCAST (elem) -- g_cond_broadcast (GST_STATE_GET_COND (elem)); -- arg-macro: procedure gst_element_get_name (elem) -- gst_object_get_name(GST_OBJECT_CAST(elem)) -- arg-macro: procedure gst_element_set_name (elem, name) -- gst_object_set_name(GST_OBJECT_CAST(elem),name) -- arg-macro: procedure gst_element_get_parent (elem) -- gst_object_get_parent(GST_OBJECT_CAST(elem)) -- arg-macro: procedure gst_element_set_parent (elem, parent) -- gst_object_set_parent(GST_OBJECT_CAST(elem),parent) -- GStreamer -- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> -- * 2000,2004 Wim Taymans <wim@fluendo.com> -- * -- * gstelement.h: Header for GstElement -- * -- * 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. -- -- gstelement.h and gstelementfactory.h include eachother type GstElement; type GstState is (GST_STATE_VOID_PENDING, GST_STATE_NULL, GST_STATE_READY, GST_STATE_PAUSED, GST_STATE_PLAYING); pragma Convention (C, GstState); -- gst/gstelement.h:52 type anon_232; type anon_233 is record target_state : aliased GstState; -- gst/gstelement.h:575 start_time : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/gstelement.h:577 end record; pragma Convention (C_Pass_By_Copy, anon_233); type u_GstElement_u_gst_reserved_array is array (0 .. 3) of System.Address; type anon_232 (discr : unsigned := 0) is record case discr is when 0 => ABI : aliased anon_233; -- gst/gstelement.h:578 when others => u_gst_reserved : u_GstElement_u_gst_reserved_array; -- gst/gstelement.h:580 end case; end record; pragma Convention (C_Pass_By_Copy, anon_232); pragma Unchecked_Union (anon_232);--subtype GstElement is u_GstElement; -- gst/gstelement.h:28 type GstElementClass; type u_GstElementClass_u_gst_reserved_array is array (0 .. 0) of System.Address; --subtype GstElementClass is u_GstElementClass; -- gst/gstelement.h:29 -- gstmessage.h needs State --* -- * GstState: -- * @GST_STATE_VOID_PENDING: no pending state. -- * @GST_STATE_NULL : the NULL state or initial state of an element. -- * @GST_STATE_READY : the element is ready to go to PAUSED. -- * @GST_STATE_PAUSED : the element is PAUSED, it is ready to accept and -- * process data. Sink elements however only accept one -- * buffer and then block. -- * @GST_STATE_PLAYING : the element is PLAYING, the #GstClock is running and -- * the data is flowing. -- * -- * The possible states an element can be in. States can be changed using -- * gst_element_set_state() and checked using gst_element_get_state(). -- --* -- * GstStateChangeReturn: -- * @GST_STATE_CHANGE_FAILURE : the state change failed -- * @GST_STATE_CHANGE_SUCCESS : the state change succeeded -- * @GST_STATE_CHANGE_ASYNC : the state change will happen asynchronously -- * @GST_STATE_CHANGE_NO_PREROLL: the state change succeeded but the element -- * cannot produce data in %GST_STATE_PAUSED. -- * This typically happens with live sources. -- * -- * The possible return values from a state change function such as -- * gst_element_set_state(). Only @GST_STATE_CHANGE_FAILURE is a real failure. -- type GstStateChangeReturn is (GST_STATE_CHANGE_FAILURE, GST_STATE_CHANGE_SUCCESS, GST_STATE_CHANGE_ASYNC, GST_STATE_CHANGE_NO_PREROLL); pragma Convention (C, GstStateChangeReturn); -- gst/gstelement.h:96 -- NOTE: this probably should be done with an #ifdef to decide -- * whether to safe-cast or to just do the non-checking cast. -- --* -- * GST_STATE: -- * @elem: a #GstElement to return state for. -- * -- * This macro returns the current #GstState of the element. -- --* -- * GST_STATE_NEXT: -- * @elem: a #GstElement to return the next state for. -- * -- * This macro returns the next #GstState of the element. -- --* -- * GST_STATE_PENDING: -- * @elem: a #GstElement to return the pending state for. -- * -- * This macro returns the currently pending #GstState of the element. -- --* -- * GST_STATE_TARGET: -- * @elem: a #GstElement to return the target state for. -- * -- * This macro returns the target #GstState of the element. -- * -- * Since: 0.10.13 -- --* -- * GST_STATE_RETURN: -- * @elem: a #GstElement to return the last state result for. -- * -- * This macro returns the last #GstStateChangeReturn value. -- --* -- * GST_STATE_GET_NEXT: -- * @cur: A starting #GstState -- * @pending: A target #GstState -- * -- * Given a current state @cur and a target state @pending, calculate the next (intermediate) -- * #GstState. -- --* -- * GST_STATE_TRANSITION: -- * @cur: A current state -- * @next: A next state -- * -- * Given a current state @cur and a next state @next, calculate the associated -- * #GstStateChange transition. -- --* -- * GST_STATE_TRANSITION_CURRENT: -- * @trans: A #GstStateChange -- * -- * Given a state transition @trans, extract the current #GstState. -- --* -- * GST_STATE_TRANSITION_NEXT: -- * @trans: A #GstStateChange -- * -- * Given a state transition @trans, extract the next #GstState. -- --* -- * GstStateChange: -- * @GST_STATE_CHANGE_NULL_TO_READY : state change from NULL to READY. -- * <itemizedlist> -- * <listitem><para> -- * The element must check if the resources it needs are available. Device -- * sinks and -sources typically try to probe the device to constrain their -- * caps. -- * </para></listitem> -- * <listitem><para> -- * The element opens the device (in case feature need to be probed). -- * </para></listitem> -- * </itemizedlist> -- * @GST_STATE_CHANGE_READY_TO_PAUSED : state change from READY to PAUSED. -- * <itemizedlist> -- * <listitem><para> -- * The element pads are activated in order to receive data in PAUSED. -- * Streaming threads are started. -- * </para></listitem> -- * <listitem><para> -- * Some elements might need to return %GST_STATE_CHANGE_ASYNC and complete -- * the state change when they have enough information. It is a requirement -- * for sinks to return %GST_STATE_CHANGE_ASYNC and complete the state change -- * when they receive the first buffer or %GST_EVENT_EOS (preroll). -- * Sinks also block the dataflow when in PAUSED. -- * </para></listitem> -- * <listitem><para> -- * A pipeline resets the running_time to 0. -- * </para></listitem> -- * <listitem><para> -- * Live sources return %GST_STATE_CHANGE_NO_PREROLL and don't generate data. -- * </para></listitem> -- * </itemizedlist> -- * @GST_STATE_CHANGE_PAUSED_TO_PLAYING: state change from PAUSED to PLAYING. -- * <itemizedlist> -- * <listitem><para> -- * Most elements ignore this state change. -- * </para></listitem> -- * <listitem><para> -- * The pipeline selects a #GstClock and distributes this to all the children -- * before setting them to PLAYING. This means that it is only alowed to -- * synchronize on the #GstClock in the PLAYING state. -- * </para></listitem> -- * <listitem><para> -- * The pipeline uses the #GstClock and the running_time to calculate the -- * base_time. The base_time is distributed to all children when performing -- * the state change. -- * </para></listitem> -- * <listitem><para> -- * Sink elements stop blocking on the preroll buffer or event and start -- * rendering the data. -- * </para></listitem> -- * <listitem><para> -- * Sinks can post %GST_MESSAGE_EOS in the PLAYING state. It is not allowed -- * to post %GST_MESSAGE_EOS when not in the PLAYING state. -- * </para></listitem> -- * <listitem><para> -- * While streaming in PAUSED or PLAYING elements can create and remove -- * sometimes pads. -- * </para></listitem> -- * <listitem><para> -- * Live sources start generating data and return %GST_STATE_CHANGE_SUCCESS. -- * </para></listitem> -- * </itemizedlist> -- * @GST_STATE_CHANGE_PLAYING_TO_PAUSED: state change from PLAYING to PAUSED. -- * <itemizedlist> -- * <listitem><para> -- * Most elements ignore this state change. -- * </para></listitem> -- * <listitem><para> -- * The pipeline calculates the running_time based on the last selected -- * #GstClock and the base_time. It stores this information to continue -- * playback when going back to the PLAYING state. -- * </para></listitem> -- * <listitem><para> -- * Sinks unblock any #GstClock wait calls. -- * </para></listitem> -- * <listitem><para> -- * When a sink does not have a pending buffer to play, it returns -- * %GST_STATE_CHANGE_ASYNC from this state change and completes the state -- * change when it receives a new buffer or an %GST_EVENT_EOS. -- * </para></listitem> -- * <listitem><para> -- * Any queued %GST_MESSAGE_EOS items are removed since they will be reposted -- * when going back to the PLAYING state. The EOS messages are queued in -- * #GstBin containers. -- * </para></listitem> -- * <listitem><para> -- * Live sources stop generating data and return %GST_STATE_CHANGE_NO_PREROLL. -- * </para></listitem> -- * </itemizedlist> -- * @GST_STATE_CHANGE_PAUSED_TO_READY : state change from PAUSED to READY. -- * <itemizedlist> -- * <listitem><para> -- * Sinks unblock any waits in the preroll. -- * </para></listitem> -- * <listitem><para> -- * Elements unblock any waits on devices -- * </para></listitem> -- * <listitem><para> -- * Chain or get_range functions return %GST_FLOW_WRONG_STATE. -- * </para></listitem> -- * <listitem><para> -- * The element pads are deactivated so that streaming becomes impossible and -- * all streaming threads are stopped. -- * </para></listitem> -- * <listitem><para> -- * The sink forgets all negotiated formats -- * </para></listitem> -- * <listitem><para> -- * Elements remove all sometimes pads -- * </para></listitem> -- * </itemizedlist> -- * @GST_STATE_CHANGE_READY_TO_NULL : state change from READY to NULL. -- * <itemizedlist> -- * <listitem><para> -- * Elements close devices -- * </para></listitem> -- * <listitem><para> -- * Elements reset any internal state. -- * </para></listitem> -- * </itemizedlist> -- * -- * These are the different state changes an element goes through. -- * %GST_STATE_NULL &rArr; %GST_STATE_PLAYING is called an upwards state change -- * and %GST_STATE_PLAYING &rArr; %GST_STATE_NULL a downwards state change. -- --< flags=0 > subtype GstStateChange is unsigned; GST_STATE_CHANGE_NULL_TO_READY : constant GstStateChange := 10; GST_STATE_CHANGE_READY_TO_PAUSED : constant GstStateChange := 19; GST_STATE_CHANGE_PAUSED_TO_PLAYING : constant GstStateChange := 28; GST_STATE_CHANGE_PLAYING_TO_PAUSED : constant GstStateChange := 35; GST_STATE_CHANGE_PAUSED_TO_READY : constant GstStateChange := 26; GST_STATE_CHANGE_READY_TO_NULL : constant GstStateChange := 17; -- gst/gstelement.h:313 --* -- * GstElementFlags: -- * @GST_ELEMENT_LOCKED_STATE: ignore state changes from parent -- * @GST_ELEMENT_IS_SINK: the element is a sink -- * @GST_ELEMENT_UNPARENTING: Child is being removed from the parent bin. -- * gst_bin_remove() on a child already being removed immediately returns FALSE -- * @GST_ELEMENT_IS_SOURCE: the element is a source. Since 0.10.31 -- * @GST_ELEMENT_FLAG_LAST: offset to define more flags -- * -- * The standard flags that an element may have. -- -- padding subtype GstElementFlags is unsigned; GST_ELEMENT_LOCKED_STATE : constant GstElementFlags := 16; GST_ELEMENT_IS_SINK : constant GstElementFlags := 32; GST_ELEMENT_UNPARENTING : constant GstElementFlags := 64; GST_ELEMENT_IS_SOURCE : constant GstElementFlags := 128; GST_ELEMENT_FLAG_LAST : constant GstElementFlags := 1048576; -- gst/gstelement.h:334 --* -- * GST_ELEMENT_IS_LOCKED_STATE: -- * @elem: A #GstElement to query -- * -- * Check if the element is in the locked state and therefore will ignore state -- * changes from its parent object. -- --* -- * GST_ELEMENT_NAME: -- * @elem: A #GstElement to query -- * -- * Gets the name of this element. Use only in core as this is not -- * ABI-compatible. Others use gst_element_get_name() -- --* -- * GST_ELEMENT_PARENT: -- * @elem: A #GstElement to query -- * -- * Get the parent object of this element. -- --* -- * GST_ELEMENT_BUS: -- * @elem: A #GstElement to query -- * -- * Get the message bus of this element. -- --* -- * GST_ELEMENT_CLOCK: -- * @elem: A #GstElement to query -- * -- * Get the clock of this element -- --* -- * GST_ELEMENT_PADS: -- * @elem: A #GstElement to query -- * -- * Get the pads of this elements. -- --* -- * GST_ELEMENT_START_TIME: -- * @elem: a #GstElement to return the start time for. -- * -- * This macro returns the start_time of the @elem. The start_time is the -- * running_time of the pipeline when the element went to PAUSED. -- * -- * Since: 0.10.24 -- --* -- * GST_ELEMENT_ERROR: -- * @el: the element that generates the error -- * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError) -- * @code: error code defined for that domain (see #gstreamer-GstGError) -- * @text: the message to display (format string and args enclosed in -- parentheses) -- * @debug: debugging information for the message (format string and args -- enclosed in parentheses) -- * -- * Utility function that elements can use in case they encountered a fatal -- * data processing error. The pipeline will post an error message and the -- * application will be requested to stop further media processing. -- --* -- * GST_ELEMENT_WARNING: -- * @el: the element that generates the warning -- * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError) -- * @code: error code defined for that domain (see #gstreamer-GstGError) -- * @text: the message to display (format string and args enclosed in -- parentheses) -- * @debug: debugging information for the message (format string and args -- enclosed in parentheses) -- * -- * Utility function that elements can use in case they encountered a non-fatal -- * data processing problem. The pipeline will post a warning message and the -- * application will be informed. -- --* -- * GST_ELEMENT_INFO: -- * @el: the element that generates the information -- * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError) -- * @code: error code defined for that domain (see #gstreamer-GstGError) -- * @text: the message to display (format string and args enclosed in -- parentheses) -- * @debug: debugging information for the message (format string and args -- enclosed in parentheses) -- * -- * Utility function that elements can use in case they want to inform -- * the application of something noteworthy that is not an error. -- * The pipeline will post a info message and the -- * application will be informed. -- * -- * Since: 0.10.12 -- -- the state change mutexes and conds --* -- * GST_STATE_GET_LOCK: -- * @elem: a #GstElement -- * -- * Get a reference to the state lock of @elem. -- * This lock is used by the core. It is taken while getting or setting -- * the state, during state changes, and while finalizing. -- --* -- * GST_STATE_GET_COND: -- * @elem: a #GstElement -- * -- * Get the conditional used to signal the completion of a state change. -- --* -- * GstElement: -- * @state_lock: Used to serialize execution of gst_element_set_state() -- * @state_cond: Used to signal completion of a state change -- * @state_cookie: Used to detect concurrent execution of -- * gst_element_set_state() and gst_element_get_state() -- * @current_state: the current state of an element -- * @next_state: the next state of an element, can be #GST_STATE_VOID_PENDING if -- * the element is in the correct state. -- * @pending_state: the final state the element should go to, can be -- * #GST_STATE_VOID_PENDING if the element is in the correct state -- * @last_return: the last return value of an element state change -- * @bus: the bus of the element. This bus is provided to the element by the -- * parent element or the application. A #GstPipeline has a bus of its own. -- * @clock: the clock of the element. This clock is usually provided to the -- * element by the toplevel #GstPipeline. -- * @base_time: the time of the clock right before the element is set to -- * PLAYING. Subtracting @base_time from the current clock time in the PLAYING -- * state will yield the running_time against the clock. -- * @numpads: number of pads of the element, includes both source and sink pads. -- * @pads: list of pads -- * @numsrcpads: number of source pads of the element. -- * @srcpads: list of source pads -- * @numsinkpads: number of sink pads of the element. -- * @sinkpads: list of sink pads -- * @pads_cookie: updated whenever the a pad is added or removed -- * -- * GStreamer element abstract base class. -- type GstElement is record object : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject; -- gst/gstelement.h:542 state_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h.GStaticRecMutex; -- gst/gstelement.h:545 state_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstelement.h:548 state_cookie : aliased GLIB.guint32; -- gst/gstelement.h:549 current_state : aliased GstState; -- gst/gstelement.h:550 next_state : aliased GstState; -- gst/gstelement.h:551 pending_state : aliased GstState; -- gst/gstelement.h:552 last_return : aliased GstStateChangeReturn; -- gst/gstelement.h:553 bus : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h.GstBus; -- gst/gstelement.h:555 clock : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock; -- gst/gstelement.h:558 base_time : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTimeDiff; -- gst/gstelement.h:559 numpads : aliased GLIB.guint16; -- gst/gstelement.h:563 pads : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:564 numsrcpads : aliased GLIB.guint16; -- gst/gstelement.h:565 srcpads : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:566 numsinkpads : aliased GLIB.guint16; -- gst/gstelement.h:567 sinkpads : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:568 pads_cookie : aliased GLIB.guint32; -- gst/gstelement.h:569 abidata : aliased anon_232; -- gst/gstelement.h:581 end record; pragma Convention (C_Pass_By_Copy, GstElement); -- gst/gstelement.h:540 --< public > -- with LOCK -- element state -- allocated clock -- NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock -- element pads, these lists can only be iterated while holding -- * the LOCK or checking the cookie after each LOCK. --< private > -- state set by application -- running time of the last PAUSED state -- adding + 0 to mark ABI change to be undone later --* -- * GstElementClass: -- * @parent_class: the parent class structure -- * @details: #GstElementDetails for elements of this class -- * @elementfactory: the #GstElementFactory that creates these elements -- * @padtemplates: a #GList of #GstPadTemplate -- * @numpadtemplates: the number of padtemplates -- * @pad_templ_cookie: changed whenever the padtemplates change -- * @request_new_pad: called when a new pad is requested -- * @release_pad: called when a request pad is to be released -- * @get_state: get the state of the element -- * @set_state: set a new state on the element -- * @change_state: called by @set_state to perform an incremental state change -- * @set_bus: set a #GstBus on the element -- * @provide_clock: gets the #GstClock provided by the element -- * @set_clock: set the #GstClock on the element -- * @get_index: set a #GstIndex on the element -- * @set_index: get the #GstIndex of an element -- * @send_event: send a #GstEvent to the element -- * @get_query_types: get the supported #GstQueryType of this element -- * @query: perform a #GstQuery on the element -- * @request_new_pad_full: called when a new pad is requested. Since: 0.10.32. -- * @state_changed: called immediately after a new state was set. Since: 0.10.36. -- * -- * GStreamer element class. Override the vmethods to implement the element -- * functionality. -- type GstElementClass is record parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObjectClass; -- gst/gstelement.h:613 details : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h.GstElementDetails; -- gst/gstelement.h:618 elementfactory : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h.GstElementFactory; -- gst/gstelement.h:621 padtemplates : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:624 numpadtemplates : aliased GLIB.gint; -- gst/gstelement.h:625 pad_templ_cookie : aliased GLIB.guint32; -- gst/gstelement.h:626 pad_added : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad); -- gst/gstelement.h:630 pad_removed : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad); -- gst/gstelement.h:631 no_more_pads : access procedure (arg1 : access GstElement); -- gst/gstelement.h:632 request_new_pad : access function (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; arg3 : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:638 release_pad : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad); -- gst/gstelement.h:639 get_state : access function (arg1 : access GstElement; arg2 : access GstState; arg3 : access GstState; arg4 : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return GstStateChangeReturn; -- gst/gstelement.h:643 set_state : access function (arg1 : access GstElement; arg2 : GstState) return GstStateChangeReturn; -- gst/gstelement.h:644 change_state : access function (arg1 : access GstElement; arg2 : GstStateChange) return GstStateChangeReturn; -- gst/gstelement.h:645 set_bus : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h.GstBus); -- gst/gstelement.h:648 provide_clock : access function (arg1 : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock; -- gst/gstelement.h:651 set_clock : access function (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock) return GLIB.gboolean; -- gst/gstelement.h:652 get_index : access function (arg1 : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h.GstIndex; -- gst/gstelement.h:655 set_index : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h.GstIndex); -- gst/gstelement.h:656 send_event : access function (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstelement.h:659 get_query_types : access function (arg1 : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstelement.h:661 query : access function (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstelement.h:662 meta_data : System.Address; -- gst/gstelement.h:666 request_new_pad_full : access function (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; arg3 : access GLIB.gchar; arg4 : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:672 state_changed : access procedure (arg1 : access GstElement; arg2 : GstState; arg3 : GstState; arg4 : GstState); -- gst/gstelement.h:675 u_gst_reserved : u_GstElementClass_u_gst_reserved_array; -- gst/gstelement.h:678 end record; pragma Convention (C_Pass_By_Copy, GstElementClass); -- gst/gstelement.h:611 --< public > -- the element details -- FIXME-0.11: deprecate this in favour of meta_data -- factory that the element was created from -- templates for our pads --< private > -- signal callbacks --< public > -- virtual methods for subclasses -- request/release pads -- state changes -- bus -- set/get clocks -- index -- query functions --< private > -- FIXME-0.11: move up and replace details --< public > -- Virtual method for subclasses (additions) -- FIXME-0.11 Make this the default behaviour --< private > -- element class pad templates procedure gst_element_class_add_pad_template (klass : access GstElementClass; templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate); -- gst/gstelement.h:682 pragma Import (C, gst_element_class_add_pad_template, "gst_element_class_add_pad_template"); procedure gst_element_class_add_static_pad_template (klass : access GstElementClass; templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstStaticPadTemplate); -- gst/gstelement.h:683 pragma Import (C, gst_element_class_add_static_pad_template, "gst_element_class_add_static_pad_template"); function gst_element_class_get_pad_template (element_class : access GstElementClass; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstelement.h:684 pragma Import (C, gst_element_class_get_pad_template, "gst_element_class_get_pad_template"); function gst_element_class_get_pad_template_list (element_class : access GstElementClass) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:685 pragma Import (C, gst_element_class_get_pad_template_list, "gst_element_class_get_pad_template_list"); -- element class meta data procedure gst_element_class_set_documentation_uri (klass : access GstElementClass; uri : access GLIB.gchar); -- gst/gstelement.h:688 pragma Import (C, gst_element_class_set_documentation_uri, "gst_element_class_set_documentation_uri"); procedure gst_element_class_set_icon_name (klass : access GstElementClass; name : access GLIB.gchar); -- gst/gstelement.h:689 pragma Import (C, gst_element_class_set_icon_name, "gst_element_class_set_icon_name"); procedure gst_element_class_set_details (klass : access GstElementClass; details : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h.GstElementDetails); -- gst/gstelement.h:691 pragma Import (C, gst_element_class_set_details, "gst_element_class_set_details"); procedure gst_element_class_set_details_simple (klass : access GstElementClass; longname : access GLIB.gchar; classification : access GLIB.gchar; description : access GLIB.gchar; author : access GLIB.gchar); -- gst/gstelement.h:693 pragma Import (C, gst_element_class_set_details_simple, "gst_element_class_set_details_simple"); -- element instance function gst_element_get_type return GLIB.GType; -- gst/gstelement.h:700 pragma Import (C, gst_element_get_type, "gst_element_get_type"); -- basic name and parentage stuff from GstObject --* -- * gst_element_get_name: -- * @elem: a #GstElement to get the name of @elem. -- * -- * Returns a copy of the name of @elem. -- * Caller should g_free() the return value after usage. -- * For a nameless element, this returns NULL, which you can safely g_free() -- * as well. -- * -- * Returns: (transfer full): the name of @elem. g_free() after usage. MT safe. -- * -- --* -- * gst_element_set_name: -- * @elem: a #GstElement to set the name of. -- * @name: the new name -- * -- * Sets the name of the element, getting rid of the old name if there was one. -- --* -- * gst_element_get_parent: -- * @elem: a #GstElement to get the parent of. -- * -- * Get the parent of an element. -- * -- * Returns: (transfer full): the parent of an element. -- --* -- * gst_element_set_parent: -- * @elem: a #GstElement to set the parent of. -- * @parent: the new parent #GstObject of the element. -- * -- * Sets the parent of an element. -- -- clocking function gst_element_requires_clock (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:747 pragma Import (C, gst_element_requires_clock, "gst_element_requires_clock"); function gst_element_provides_clock (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:748 pragma Import (C, gst_element_provides_clock, "gst_element_provides_clock"); function gst_element_provide_clock (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock; -- gst/gstelement.h:749 pragma Import (C, gst_element_provide_clock, "gst_element_provide_clock"); function gst_element_get_clock (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock; -- gst/gstelement.h:750 pragma Import (C, gst_element_get_clock, "gst_element_get_clock"); function gst_element_set_clock (element : access GstElement; clock : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock) return GLIB.gboolean; -- gst/gstelement.h:751 pragma Import (C, gst_element_set_clock, "gst_element_set_clock"); procedure gst_element_set_base_time (element : access GstElement; time : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime); -- gst/gstelement.h:752 pragma Import (C, gst_element_set_base_time, "gst_element_set_base_time"); function gst_element_get_base_time (element : access GstElement) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/gstelement.h:753 pragma Import (C, gst_element_get_base_time, "gst_element_get_base_time"); procedure gst_element_set_start_time (element : access GstElement; time : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime); -- gst/gstelement.h:754 pragma Import (C, gst_element_set_start_time, "gst_element_set_start_time"); function gst_element_get_start_time (element : access GstElement) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/gstelement.h:755 pragma Import (C, gst_element_get_start_time, "gst_element_get_start_time"); -- indexes function gst_element_is_indexable (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:758 pragma Import (C, gst_element_is_indexable, "gst_element_is_indexable"); procedure gst_element_set_index (element : access GstElement; index : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h.GstIndex); -- gst/gstelement.h:759 pragma Import (C, gst_element_set_index, "gst_element_set_index"); function gst_element_get_index (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h.GstIndex; -- gst/gstelement.h:760 pragma Import (C, gst_element_get_index, "gst_element_get_index"); -- bus procedure gst_element_set_bus (element : access GstElement; bus : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h.GstBus); -- gst/gstelement.h:763 pragma Import (C, gst_element_set_bus, "gst_element_set_bus"); function gst_element_get_bus (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h.GstBus; -- gst/gstelement.h:764 pragma Import (C, gst_element_get_bus, "gst_element_get_bus"); -- pad management function gst_element_add_pad (element : access GstElement; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad) return GLIB.gboolean; -- gst/gstelement.h:767 pragma Import (C, gst_element_add_pad, "gst_element_add_pad"); function gst_element_remove_pad (element : access GstElement; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad) return GLIB.gboolean; -- gst/gstelement.h:768 pragma Import (C, gst_element_remove_pad, "gst_element_remove_pad"); procedure gst_element_no_more_pads (element : access GstElement); -- gst/gstelement.h:769 pragma Import (C, gst_element_no_more_pads, "gst_element_no_more_pads"); function gst_element_get_pad (element : access GstElement; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:772 pragma Import (C, gst_element_get_pad, "gst_element_get_pad"); function gst_element_get_static_pad (element : access GstElement; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:774 pragma Import (C, gst_element_get_static_pad, "gst_element_get_static_pad"); function gst_element_get_request_pad (element : access GstElement; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:775 pragma Import (C, gst_element_get_request_pad, "gst_element_get_request_pad"); function gst_element_request_pad (element : access GstElement; templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; name : access GLIB.gchar; caps : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:776 pragma Import (C, gst_element_request_pad, "gst_element_request_pad"); procedure gst_element_release_request_pad (element : access GstElement; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad); -- gst/gstelement.h:779 pragma Import (C, gst_element_release_request_pad, "gst_element_release_request_pad"); function gst_element_iterate_pads (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstelement.h:781 pragma Import (C, gst_element_iterate_pads, "gst_element_iterate_pads"); function gst_element_iterate_src_pads (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstelement.h:782 pragma Import (C, gst_element_iterate_src_pads, "gst_element_iterate_src_pads"); function gst_element_iterate_sink_pads (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstelement.h:783 pragma Import (C, gst_element_iterate_sink_pads, "gst_element_iterate_sink_pads"); -- event/query/format stuff function gst_element_send_event (element : access GstElement; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstelement.h:786 pragma Import (C, gst_element_send_event, "gst_element_send_event"); function gst_element_seek (element : access GstElement; rate : GLIB.gdouble; format : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat; flags : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstSeekFlags; cur_type : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstSeekType; cur : GLIB.gint64; stop_type : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstSeekType; stop : GLIB.gint64) return GLIB.gboolean; -- gst/gstelement.h:787 pragma Import (C, gst_element_seek, "gst_element_seek"); function gst_element_get_query_types (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstelement.h:791 pragma Import (C, gst_element_get_query_types, "gst_element_get_query_types"); function gst_element_query (element : access GstElement; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstelement.h:792 pragma Import (C, gst_element_query, "gst_element_query"); -- messages function gst_element_post_message (element : access GstElement; message : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstmessage_h.GstMessage) return GLIB.gboolean; -- gst/gstelement.h:795 pragma Import (C, gst_element_post_message, "gst_element_post_message"); -- error handling -- gcc versions < 3.3 warn about NULL being passed as format to printf -- skipped func _gst_element_error_printf procedure gst_element_message_full (element : access GstElement; c_type : int; domain : Glib.GQuark; code : GLIB.gint; text : access GLIB.gchar; debug : access GLIB.gchar; file : access GLIB.gchar; c_function : access GLIB.gchar; line : GLIB.gint); -- gst/gstelement.h:804 pragma Import (C, gst_element_message_full, "gst_element_message_full"); -- state management function gst_element_is_locked_state (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:810 pragma Import (C, gst_element_is_locked_state, "gst_element_is_locked_state"); function gst_element_set_locked_state (element : access GstElement; locked_state : GLIB.gboolean) return GLIB.gboolean; -- gst/gstelement.h:811 pragma Import (C, gst_element_set_locked_state, "gst_element_set_locked_state"); function gst_element_sync_state_with_parent (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:812 pragma Import (C, gst_element_sync_state_with_parent, "gst_element_sync_state_with_parent"); function gst_element_get_state (element : access GstElement; state : access GstState; pending : access GstState; timeout : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return GstStateChangeReturn; -- gst/gstelement.h:814 pragma Import (C, gst_element_get_state, "gst_element_get_state"); function gst_element_set_state (element : access GstElement; state : GstState) return GstStateChangeReturn; -- gst/gstelement.h:818 pragma Import (C, gst_element_set_state, "gst_element_set_state"); procedure gst_element_abort_state (element : access GstElement); -- gst/gstelement.h:820 pragma Import (C, gst_element_abort_state, "gst_element_abort_state"); function gst_element_change_state (element : access GstElement; transition : GstStateChange) return GstStateChangeReturn; -- gst/gstelement.h:821 pragma Import (C, gst_element_change_state, "gst_element_change_state"); function gst_element_continue_state (element : access GstElement; ret : GstStateChangeReturn) return GstStateChangeReturn; -- gst/gstelement.h:823 pragma Import (C, gst_element_continue_state, "gst_element_continue_state"); procedure gst_element_lost_state (element : access GstElement); -- gst/gstelement.h:825 pragma Import (C, gst_element_lost_state, "gst_element_lost_state"); procedure gst_element_lost_state_full (element : access GstElement; new_base_time : GLIB.gboolean); -- gst/gstelement.h:826 pragma Import (C, gst_element_lost_state_full, "gst_element_lost_state_full"); -- factory management function gst_element_get_factory (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h.GstElementFactory; -- gst/gstelement.h:829 pragma Import (C, gst_element_get_factory, "gst_element_get_factory"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h;
with STM32_SVD; use STM32_SVD; with Interfaces; use Interfaces; generic type Buffer_Size_Type is range <>; type Buffer_Type is array (Buffer_Size_Type) of Byte; type Tag_Type is (<>); package TLV is -- type Data_Types is (False, True, Byte, Short, Long, Float, Double, -- String, Timestamp, Duration, Sequence); procedure Encode (Tag : Tag_Type; Value : Integer; Buffer : in out Buffer_Type; Position : in out Buffer_Size_Type); procedure Encode (Tag : Tag_Type; Value : Short_Float; Buffer : in out Buffer_Type; Position : in out Buffer_Size_Type); procedure Encode (Tag : Tag_Type; Value : String; Buffer : in out Buffer_Type; Position : in out Buffer_Size_Type); procedure Start_Sequence (Tag : Tag_Type; Buffer : in out Buffer_Type; Length_Position : out Buffer_Size_Type; Position : in out Buffer_Size_Type); procedure End_Sequence (Buffer : in out Buffer_Type; Length_Position : in Buffer_Size_Type; Position : in out Buffer_Size_Type); end TLV;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with 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 STM32.DMA2D; use STM32.DMA2D; with STM32.DMA2D_Bitmap; use STM32.DMA2D_Bitmap; with HAL; use HAL; with HAL.Bitmap; use HAL.Bitmap; procedure Dma2d is function Bitmap_Buffer return not null Any_Bitmap_Buffer; function Buffer return DMA2D_Buffer; ------------------- -- Bitmap_Buffer -- ------------------- function Bitmap_Buffer return not null Any_Bitmap_Buffer is begin if Display.Hidden_Buffer (1).all not in DMA2D_Bitmap_Buffer then raise Program_Error with "We expect a DM2D buffer here"; end if; return Display.Hidden_Buffer (1); end Bitmap_Buffer; ------------ -- Buffer -- ------------ function Buffer return DMA2D_Buffer is begin return To_DMA2D_Buffer (Display.Hidden_Buffer (1).all); end Buffer; Width : Natural; Height : Natural; X, Y : Natural; L4_CLUT : array (UInt4) of DMA2D_Color; L8_CLUT : array (UInt8) of DMA2D_Color; type L4_Bitmap is array (UInt4) of UInt4 with Pack; type L8_Bitmap is array (UInt8) of UInt8 with Pack; L4_Data : L4_Bitmap with Size => 16 * 4; L8_Data : L8_Bitmap with Size => 256 * 8; L4_Buffer : constant DMA2D_Buffer := (Color_Mode => L4, Addr => L4_Data (0)'Address, Width => 4, Height => 4, CLUT_Color_Mode => ARGB8888, CLUT_Addr => L4_CLUT (0)'Address); L8_Buffer : constant DMA2D_Buffer := (Color_Mode => L8, Addr => L8_Data (0)'Address, Width => 16, Height => 16, CLUT_Color_Mode => ARGB8888, CLUT_Addr => L8_CLUT (0)'Address); begin -- Initialize LCD Display.Initialize; Display.Initialize_Layer (1, HAL.Bitmap.ARGB_8888); Width := Display.Hidden_Buffer (1).Width; Height := Display.Hidden_Buffer (1).Height; loop Bitmap_Buffer.Set_Source (HAL.Bitmap.Dark_Green); Bitmap_Buffer.Fill; -- Draw blue filled rectangle in the upper left corner Bitmap_Buffer.Set_Source (HAL.Bitmap.Blue); Bitmap_Buffer.Fill_Rect ((Position => (0, 0), Width => Width / 2, Height => Height / 2)); -- Drawn yellow rectangle outline in the lower left corner Bitmap_Buffer.Set_Source (HAL.Bitmap.Yellow); Bitmap_Buffer.Draw_Rect ((Position => (0, Height / 2), Width => Width / 2, Height => Height / 2)); -- Draw 10 red lines in the blue rectangle X := 0; Y := 0; while X < Width / 2 and then Y < ((Height / 2) - 10) loop for Cnt in 0 .. 10 loop Bitmap_Buffer.Set_Pixel ((X, Y + Cnt), HAL.Bitmap.Red); end loop; X := X + 1; Y := Y + 1; end loop; -- Draw 10 red blended lines in the yellow rectangle X := 0; Y := Height / 2; while X < Width / 2 and then Y < Height - 10 loop for Cnt in 0 .. 10 loop Bitmap_Buffer.Set_Source ((100, 255, 0, 0)); Bitmap_Buffer.Set_Pixel_Blend ((X, Y + Cnt)); end loop; X := X + 1; Y := Y + 1; end loop; -- Copy half of the screen to the other half Copy_Rect (Src_Buffer => Bitmap_Buffer.all, Src_Pt => (0, 0), Dst_Buffer => Bitmap_Buffer.all, Dst_Pt => (Width / 2, 0), Bg_Buffer => STM32.DMA2D_Bitmap.Null_Buffer, Bg_Pt => (0, 0), Width => Width / 2, Height => Height, Synchronous => True); -- Fill L4 CLUT for Index in UInt4 loop L4_CLUT (Index) := (255, 0, 0, UInt8 (Index) * 16); end loop; -- Fill L4 bitmap for Index in L4_Data'Range loop L4_Data (Index) := Index; end loop; -- Fill L8 CLUT for Index in UInt8 loop L8_CLUT (Index) := (255, 0, Index, 0); end loop; -- Fill L8 bitmap for Index in L8_Data'Range loop L8_Data (Index) := Index; end loop; for X in 0 .. 4 loop for Y in 0 .. 4 loop STM32.DMA2D.DMA2D_Copy_Rect (Src_Buffer => L4_Buffer, X_Src => 0, Y_Src => 0, Dst_Buffer => Buffer, X_Dst => L4_Buffer.Width * X, Y_Dst => (L4_Buffer.Height * Y), Bg_Buffer => STM32.DMA2D.Null_Buffer, X_Bg => 0, Y_Bg => 0, Width => L4_Buffer.Width, Height => L4_Buffer.Height, Synchronous => True); STM32.DMA2D.DMA2D_Copy_Rect (Src_Buffer => L8_Buffer, X_Src => 0, Y_Src => 0, Dst_Buffer => Buffer, X_Dst => L8_Buffer.Width * X, Y_Dst => (L8_Buffer.Height * Y) + Height / 2, Bg_Buffer => STM32.DMA2D.Null_Buffer, X_Bg => 0, Y_Bg => 0, Width => L8_Buffer.Width, Height => L8_Buffer.Height, Synchronous => True); end loop; end loop; Display.Update_Layers; end loop; end Dma2d;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . O S _ L I B -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2010, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- This package does not require a body, since it is a package renaming. We -- provide a dummy file containing a No_Body pragma so that previous versions -- of the body (which did exist) will not interfere. pragma No_Body;
----------------------------------------------------------------------- -- awa -- Ada Web Application -- Copyright (C) 2009, 2010, 2011, 2012, 2013 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. ----------------------------------------------------------------------- package AWA is pragma Pure; -- Library SVN identification SVN_URL : constant String := "$HeadURL: file:///opt/repository/svn/ada/awa/trunk/src/awa.ads $"; -- Revision used (must run 'make version' to update) SVN_REV : constant String := "$Rev: 318 $"; end AWA;
----------------------------------------------------------------------- -- awa-wikis-tests -- Unit tests for wikis module -- Copyright (C) 2018, 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 Util.Test_Caller; with Util.Strings; with Servlet.Streams; with ASF.Requests.Mockup; with ASF.Responses.Mockup; with ASF.Tests; with AWA.Tests.Helpers.Users; package body AWA.Wikis.Tests is use Ada.Strings.Unbounded; use AWA.Tests; package Caller is new Util.Test_Caller (Test, "Wikis.Beans"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Wikis.Beans.Load_List (Anonymous)", Test_Anonymous_Access'Access); Caller.Add_Test (Suite, "Test AWA.Wikis.Beans.Save", Test_Create_Wiki'Access); Caller.Add_Test (Suite, "Test AWA.Wikis.Beans.Load (missing)", Test_Missing_Page'Access); end Add_Tests; -- ------------------------------ -- Get some access on the wiki as anonymous users. -- ------------------------------ procedure Verify_Anonymous (T : in out Test; Page : in String; Title : in String) is pragma Unreferenced (Title); function Get_Link (Title : in String) return String; Wiki : constant String := To_String (T.Wiki_Ident); Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; function Get_Link (Title : in String) return String is Stream : Servlet.Streams.Print_Stream := Reply.Get_Output_Stream; Content : Ada.Strings.Unbounded.Unbounded_String; begin Reply.Read_Content (Content); Stream.Write (Content); return AWA.Tests.Helpers.Extract_Link (To_String (Content), Title); end Get_Link; begin ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/recent", "wiki-list-recent.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki list recent page is invalid"); ASF.Tests.Do_Get (Request, Reply, "/wikis/tags/" & Wiki, "wiki-list-tagged.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki tag page is invalid"); if Page'Length > 0 then ASF.Tests.Do_Get (Request, Reply, "/wikis/view/" & Wiki & "/" & Page, "wiki-page-" & Page & ".html"); ASF.Tests.Assert_Contains (T, "The wiki page content", Reply, "Wiki page " & Page & " is invalid"); declare Info : constant String := Get_Link ("Info"); History : constant String := Get_Link ("History"); begin Util.Tests.Assert_Matches (T, "/asfunit/wikis/info/[0-9]+/[0-9]+$", Info, "Invalid wiki info link in the response"); Util.Tests.Assert_Matches (T, "/asfunit/wikis/history/[0-9]+/[0-9]+$", History, "Invalid wiki history link in the response"); -- Get the information page. ASF.Tests.Do_Get (Request, Reply, Info (Info'First + 8 .. Info'Last), "wiki-info-" & Page & ".html"); ASF.Tests.Assert_Contains (T, "wiki-word-list", Reply, "Wiki info page " & Page & " is invalid"); -- Get the history page. ASF.Tests.Do_Get (Request, Reply, History (History'First + 8 .. History'Last), "wiki-history-" & Page & ".html"); ASF.Tests.Assert_Contains (T, "wiki-page-version", Reply, "Wiki history page " & Page & " is invalid"); end; end if; end Verify_Anonymous; -- ------------------------------ -- Verify that the wiki lists contain the given page. -- ------------------------------ procedure Verify_List_Contains (T : in out Test; Page : in String) is Wiki : constant String := To_String (T.Wiki_Ident); Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/recent", "wiki-list-recent.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki list recent page is invalid"); ASF.Tests.Assert_Contains (T, "/wikis/view/" & To_String (T.Wiki_Ident) & "/" & Page, Reply, "Wiki list recent page does not reference the page"); ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/popular", "wiki-list-popular.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki list popular page is invalid"); ASF.Tests.Assert_Contains (T, "/wikis/view/" & To_String (T.Wiki_Ident) & "/" & Page, Reply, "Wiki list popular page does not reference the page"); ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/name", "wiki-list-name.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki list name page is invalid"); ASF.Tests.Assert_Contains (T, "/wikis/view/" & To_String (T.Wiki_Ident) & "/" & Page, Reply, "Wiki list name page does not reference the page"); ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/name/grid", "wiki-list-name-grid.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki list name/grid page is invalid"); ASF.Tests.Assert_Contains (T, "/wikis/view/" & To_String (T.Wiki_Ident) & "/" & Page, Reply, "Wiki list name/grid page does not reference the page"); end Verify_List_Contains; -- ------------------------------ -- Test access to the blog as anonymous user. -- ------------------------------ procedure Test_Anonymous_Access (T : in out Test) is begin T.Verify_Anonymous ("", ""); end Test_Anonymous_Access; -- ------------------------------ -- Test creation of blog by simulating web requests. -- ------------------------------ procedure Test_Create_Wiki (T : in out Test) is procedure Create_Page (Name : in String; Title : in String); Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; procedure Create_Page (Name : in String; Title : in String) is begin Request.Set_Parameter ("page-wiki-id", To_String (T.Wiki_Ident)); Request.Set_Parameter ("post", "1"); Request.Set_Parameter ("page-title", Title); Request.Set_Parameter ("text", "# Main title" & ASCII.LF & "* The wiki page content." & ASCII.LF & "* Second item." & ASCII.LF); Request.Set_Parameter ("name", Name); Request.Set_Parameter ("comment", "Created wiki page " & Name); Request.Set_Parameter ("save", "1"); Request.Set_Parameter ("page-is-public", "1"); Request.Set_Parameter ("wiki-format", "FORMAT_MARKDOWN"); ASF.Tests.Do_Post (Request, Reply, "/wikis/create.html", "create-wiki.html"); T.Page_Ident := Helpers.Extract_Redirect (Reply, "/asfunit/wikis/view/" & To_String (T.Wiki_Ident) & "/"); Util.Tests.Assert_Equals (T, Name, To_String (T.Page_Ident), "Invalid redirect after wiki page creation"); -- Remove the 'wikiPage' bean from the request so that we get a new instance -- for the next call. Request.Remove_Attribute ("wikiPage"); end Create_Page; begin AWA.Tests.Helpers.Users.Login ("test-wiki@test.com", Request); Request.Set_Parameter ("title", "The Wiki Space Title"); Request.Set_Parameter ("post", "1"); Request.Set_Parameter ("create", "1"); ASF.Tests.Do_Post (Request, Reply, "/wikis/setup.html", "setup-wiki.html"); T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY, "Invalid response after wiki space creation"); declare Ident : constant String := Helpers.Extract_Redirect (Reply, "/asfunit/wikis/list/"); Pos : constant Natural := Util.Strings.Index (Ident, '/'); begin Util.Tests.Assert_Matches (T, "^[0-9]+/recent/grid$", Ident, "Invalid wiki space identifier in the response"); T.Wiki_Ident := To_Unbounded_String (Ident (Ident'First .. Pos - 1)); end; Create_Page ("WikiPageTestName", "Wiki page title1"); T.Verify_List_Contains (To_String (T.Page_Ident)); Create_Page ("WikiSecondPageName", "Wiki page title2"); T.Verify_List_Contains (To_String (T.Page_Ident)); Create_Page ("WikiThirdPageName", "Wiki page title3"); T.Verify_Anonymous ("WikiPageTestName", "Wiki page title1"); T.Verify_Anonymous ("WikiSecondPageName", "Wiki page title2"); T.Verify_Anonymous ("WikiThirdPageName", "Wiki page title3"); end Test_Create_Wiki; -- ------------------------------ -- Test getting a wiki page which does not exist. -- ------------------------------ procedure Test_Missing_Page (T : in out Test) is Wiki : constant String := To_String (T.Wiki_Ident); Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/wikis/view/" & Wiki & "/MissingPage", "wiki-page-missing.html"); ASF.Tests.Assert_Matches (T, ".title.Wiki page does not exist./title.", Reply, "Wiki page 'MissingPage' is invalid", ASF.Responses.SC_NOT_FOUND); ASF.Tests.Assert_Matches (T, ".h2.MissingPage./h2.", Reply, "Wiki page 'MissingPage' header is invalid", ASF.Responses.SC_NOT_FOUND); end Test_Missing_Page; end AWA.Wikis.Tests;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . I N T E R R U P T _ M A N A G E M E N T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- -- -- -- 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 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the NT version of this package with System.OS_Interface; use System.OS_Interface; package body System.Interrupt_Management is ---------------- -- Initialize -- ---------------- procedure Initialize is begin -- "Reserve" all the interrupts, except those that are explicitly -- defined. for J in Interrupt_ID'Range loop Reserve (J) := True; end loop; Reserve (SIGINT) := False; Reserve (SIGILL) := False; Reserve (SIGABRT) := False; Reserve (SIGFPE) := False; Reserve (SIGSEGV) := False; Reserve (SIGTERM) := False; end Initialize; end System.Interrupt_Management;
package ShipModules.Test_Data.Tests.BaseModules_Container is end ShipModules.Test_Data.Tests.BaseModules_Container;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright Β© 2011-2012, 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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Duration_Observations.Collections is pragma Preelaborate; package UML_Duration_Observation_Collections is new AMF.Generic_Collections (UML_Duration_Observation, UML_Duration_Observation_Access); type Set_Of_UML_Duration_Observation is new UML_Duration_Observation_Collections.Set with null record; Empty_Set_Of_UML_Duration_Observation : constant Set_Of_UML_Duration_Observation; type Ordered_Set_Of_UML_Duration_Observation is new UML_Duration_Observation_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Duration_Observation : constant Ordered_Set_Of_UML_Duration_Observation; type Bag_Of_UML_Duration_Observation is new UML_Duration_Observation_Collections.Bag with null record; Empty_Bag_Of_UML_Duration_Observation : constant Bag_Of_UML_Duration_Observation; type Sequence_Of_UML_Duration_Observation is new UML_Duration_Observation_Collections.Sequence with null record; Empty_Sequence_Of_UML_Duration_Observation : constant Sequence_Of_UML_Duration_Observation; private Empty_Set_Of_UML_Duration_Observation : constant Set_Of_UML_Duration_Observation := (UML_Duration_Observation_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Duration_Observation : constant Ordered_Set_Of_UML_Duration_Observation := (UML_Duration_Observation_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Duration_Observation : constant Bag_Of_UML_Duration_Observation := (UML_Duration_Observation_Collections.Bag with null record); Empty_Sequence_Of_UML_Duration_Observation : constant Sequence_Of_UML_Duration_Observation := (UML_Duration_Observation_Collections.Sequence with null record); end AMF.UML.Duration_Observations.Collections;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M A K E -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-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. -- -- -- ------------------------------------------------------------------------------ -- The following package implements the facilities to recursively -- compile (a la make), bind and/or link a set of sources. This package -- gives the individual routines for performing such tasks as well as -- the routine gnatmake below that puts it all together. with Table; with Types; use Types; with GNAT.OS_Lib; use GNAT.OS_Lib; package Make is -- The 3 following packages are used to store gcc, gnatbind and gnatbl -- switches passed on the gnatmake or gnatdist command line. -- Note that the lower bounds definitely need to be 1 to match the -- requirement that the argument array prepared for Spawn must have -- a lower bound of 1. package Gcc_Switches is new Table.Table ( Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Gcc_Switches"); package Binder_Switches is new Table.Table ( Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Binder_Switches"); package Linker_Switches is new Table.Table ( Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Linker_Switches"); procedure Display_Commands (Display : Boolean := True); -- The default behavior of Make commands (Compile_Sources, Bind, Link) -- is to display them on stderr. This behavior can be changed repeatedly -- by invoking this procedure. -- If a compilation, bind or link failed one of the following 3 exceptions -- is raised. These need to be handled by the calling routines. Compilation_Failed : exception; -- Raised by Compile_Sources if a compilation failed Bind_Failed : exception; -- Raised by Bind below if the bind failed Link_Failed : exception; -- Raised by Link below if the link failed procedure Bind (ALI_File : File_Name_Type; Args : Argument_List); -- Binds ALI_File. Args are the arguments to pass to the binder. -- Args must have a lower bound of 1. procedure Link (ALI_File : File_Name_Type; Args : Argument_List); -- Links ALI_File. Args are the arguments to pass to the linker. -- Args must have a lower bound of 1. procedure Initialize; -- Performs default and package initialization. Therefore, -- Compile_Sources can be called by an external unit. procedure Scan_Make_Arg (Argv : String; And_Save : Boolean); -- Scan make arguments. Argv is a single argument to be processed procedure Extract_Failure (File : out File_Name_Type; Unit : out Unit_Name_Type; Found : out Boolean); -- Extracts the first failure report from Bad_Compilation table procedure Compile_Sources (Main_Source : File_Name_Type; Args : Argument_List; First_Compiled_File : out Name_Id; Most_Recent_Obj_File : out Name_Id; Most_Recent_Obj_Stamp : out Time_Stamp_Type; Main_Unit : out Boolean; Compilation_Failures : out Natural; Main_Index : Int := 0; Check_Readonly_Files : Boolean := False; Do_Not_Execute : Boolean := False; Force_Compilations : Boolean := False; Keep_Going : Boolean := False; In_Place_Mode : Boolean := False; Initialize_ALI_Data : Boolean := True; Max_Process : Positive := 1); -- Compile_Sources will recursively compile all the sources needed by -- Main_Source. Before calling this routine make sure Namet has been -- initialized. This routine can be called repeatedly with different -- Main_Source file as long as all the source (-I flags), library -- (-B flags) and ada library (-A flags) search paths between calls are -- *exactly* the same. The default directory must also be the same. -- -- Args contains the arguments to use during the compilations. -- The lower bound of Args must be 1. -- -- First_Compiled_File is set to the name of the first file that is -- compiled or that needs to be compiled. This is set to No_Name if no -- compilations were needed. -- -- Most_Recent_Obj_File is set to the full name of the most recent -- object file found when no compilations are needed, that is when -- First_Compiled_File is set to No_Name. When First_Compiled_File -- is set then Most_Recent_Obj_File is set to No_Name. -- -- Most_Recent_Obj_Stamp is the time stamp of Most_Recent_Obj_File. -- -- Main_Unit is set to True if Main_Source can be a main unit. -- If Do_Not_Execute is False and First_Compiled_File /= No_Name -- the value of Main_Unit is always False. -- Is this used any more??? It is certainly not used by gnatmake??? -- -- Compilation_Failures is a count of compilation failures. This count -- is used to extract compilation failure reports with Extract_Failure. -- -- Main_Index, when not zero, is the index of the main unit in source -- file Main_Source which is a multi-unit source. -- Zero indicates that Main_Source is a single unit source file. -- -- Check_Readonly_Files set it to True to compile source files -- which library files are read-only. When compiling GNAT predefined -- files the "-gnatg" flag is used. -- -- Do_Not_Execute set it to True to find out the first source that -- needs to be recompiled, but without recompiling it. This file is -- saved in First_Compiled_File. -- -- Force_Compilations forces all compilations no matter what but -- recompiles read-only files only if Check_Readonly_Files -- is set. -- -- Keep_Going when True keep compiling even in the presence of -- compilation errors. -- -- In_Place_Mode when True save library/object files in their object -- directory if they already exist; otherwise, in the source directory. -- -- Initialize_ALI_Data set it to True when you want to initialize ALI -- data-structures. This is what you should do most of the time. -- (especially the first time around when you call this routine). -- This parameter is set to False to preserve previously recorded -- ALI file data. -- -- Max_Process is the maximum number of processes that should be spawned -- to carry out compilations. -- -- Flags in Package Opt Affecting Compile_Sources -- ----------------------------------------------- -- -- Check_Object_Consistency set it to False to omit all consistency -- checks between an .ali file and its corresponding object file. -- When this flag is set to true, every time an .ali is read, -- package Osint checks that the corresponding object file -- exists and is more recent than the .ali. -- -- Use of Name Table Info -- ---------------------- -- -- All file names manipulated by Compile_Sources are entered into the -- Names table. The Byte field of a source file is used to mark it. -- -- Calling Compile_Sources Several Times -- ------------------------------------- -- -- Upon return from Compile_Sources all the ALI data structures are left -- intact for further browsing. HOWEVER upon entry to this routine ALI -- data structures are re-initialized if parameter Initialize_ALI_Data -- above is set to true. Typically this is what you want the first time -- you call Compile_Sources. You should not load an ali file, call this -- routine with flag Initialize_ALI_Data set to True and then expect -- that ALI information to be around after the call. Note that the first -- time you call Compile_Sources you better set Initialize_ALI_Data to -- True unless you have called Initialize_ALI yourself. -- -- Compile_Sources ALGORITHM : Compile_Sources (Main_Source) -- ------------------------- -- -- 1. Insert Main_Source in a Queue (Q) and mark it. -- -- 2. Let unit.adb be the file at the head of the Q. If unit.adb is -- missing but its corresponding ali file is in an Ada library directory -- (see below) then, remove unit.adb from the Q and goto step 4. -- Otherwise, look at the files under the D (dependency) section of -- unit.ali. If unit.ali does not exist or some of the time stamps do -- not match, (re)compile unit.adb. -- -- An Ada library directory is a directory containing Ada specs, ali -- and object files but no source files for the bodies. An Ada library -- directory is communicated to gnatmake by means of some switch so that -- gnatmake can skip the sources whole ali are in that directory. -- There are two reasons for skipping the sources in this case. Firstly, -- Ada libraries typically come without full sources but binding and -- linking against those libraries is still possible. Secondly, it would -- be very wasteful for gnatmake to systematically check the consistency -- of every external Ada library used in a program. The binder is -- already in charge of catching any potential inconsistencies. -- -- 3. Look into the W section of unit.ali and insert into the Q all -- unmarked source files. Mark all files newly inserted in the Q. -- Specifically, assuming that the W section looks like -- -- W types%s types.adb types.ali -- W unchecked_deallocation%s -- W xref_tab%s xref_tab.adb xref_tab.ali -- -- Then xref_tab.adb and types.adb are inserted in the Q if they are not -- already marked. -- Note that there is no file listed under W unchecked_deallocation%s -- so no generic body should ever be explicitly compiled (unless the -- Main_Source at the start was a generic body). -- -- 4. Repeat steps 2 and 3 above until the Q is empty -- -- Note that the above algorithm works because the units withed in -- subunits are transitively included in the W section (with section) of -- the main unit. Likewise the withed units in a generic body needed -- during a compilation are also transitively included in the W section -- of the originally compiled file. procedure Gnatmake; -- The driver of gnatmake. This routine puts it all together. -- This utility can be used to automatically (re)compile (using -- Compile_Sources), bind (using Bind) and link (using Link) a set of -- ada sources. For more information on gnatmake and its precise usage -- please refer to the gnat documentation. -- -- Flags in Package Opt Affecting Gnatmake -- --------------------------------------- -- -- Check_Readonly_Files: True when -a present in command line -- Check_Object_Consistency: Set to True by Gnatmake -- Compile_Only: True when -c present in command line -- Force_Compilations: True when -f present in command line -- Maximum_Processes: Number of processes given by -jnum -- Keep_Going: True when -k present in command line -- List_Dependencies: True when -l present in command line -- Do_Not_Execute True when -n present in command line -- Quiet_Output: True when -q present in command line -- Minimal_Recompilation: True when -m present in command line -- Verbose_Mode: True when -v present in command line end Make;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- -- -- -- 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 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a NT (native) version of this package -- This package contains all the GNULL primitives that interface directly with -- the underlying OS. 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. with Interfaces.C; with Interfaces.C.Strings; with System.Float_Control; with System.Interrupt_Management; with System.Multiprocessors; with System.OS_Primitives; with System.Task_Info; with System.Tasking.Debug; with System.Win32.Ext; with System.Soft_Links; -- We use System.Soft_Links instead of System.Tasking.Initialization because -- the later is a higher level package that we shouldn't depend on. For -- example when using the restricted run time, it is replaced by -- System.Tasking.Restricted.Stages. package body System.Task_Primitives.Operations is package SSL renames System.Soft_Links; use Interfaces.C; use Interfaces.C.Strings; use System.OS_Interface; use System.OS_Primitives; use System.Parameters; use System.Task_Info; use System.Tasking; use System.Tasking.Debug; use System.Win32; use System.Win32.Ext; pragma Link_With ("-Xlinker --stack=0x200000,0x1000"); -- Change the default stack size (2 MB) for tasking programs on Windows. -- This allows about 1000 tasks running at the same time. Note that -- we set the stack size for non tasking programs on System unit. -- Also note that under Windows XP, we use a Windows XP extension to -- specify the stack size on a per task basis, as done under other OSes. --------------------- -- Local Functions -- --------------------- procedure InitializeCriticalSection (pCriticalSection : access RTS_Lock); procedure InitializeCriticalSection (pCriticalSection : access CRITICAL_SECTION); pragma Import (Stdcall, InitializeCriticalSection, "InitializeCriticalSection"); procedure EnterCriticalSection (pCriticalSection : access RTS_Lock); procedure EnterCriticalSection (pCriticalSection : access CRITICAL_SECTION); pragma Import (Stdcall, EnterCriticalSection, "EnterCriticalSection"); procedure LeaveCriticalSection (pCriticalSection : access RTS_Lock); procedure LeaveCriticalSection (pCriticalSection : access CRITICAL_SECTION); pragma Import (Stdcall, LeaveCriticalSection, "LeaveCriticalSection"); procedure DeleteCriticalSection (pCriticalSection : access RTS_Lock); procedure DeleteCriticalSection (pCriticalSection : access CRITICAL_SECTION); pragma Import (Stdcall, DeleteCriticalSection, "DeleteCriticalSection"); ---------------- -- Local Data -- ---------------- Environment_Task_Id : Task_Id; -- A variable to hold Task_Id for the environment task Single_RTS_Lock : aliased RTS_Lock; -- This is a lock to allow only one thread of control in the RTS at -- a time; it is used to execute in mutual exclusion from all other tasks. -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Time_Slice_Val : Integer; pragma Import (C, Time_Slice_Val, "__gl_time_slice_val"); Dispatching_Policy : Character; pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); function Get_Policy (Prio : System.Any_Priority) return Character; pragma Import (C, Get_Policy, "__gnat_get_specific_dispatching"); -- Get priority specific dispatching policy Foreign_Task_Elaborated : aliased Boolean := True; -- Used to identified fake tasks (i.e., non-Ada Threads) Null_Thread_Id : constant Thread_Id := 0; -- Constant to indicate that the thread identifier has not yet been -- initialized. ------------------------------------ -- The thread local storage index -- ------------------------------------ TlsIndex : DWORD; pragma Export (Ada, TlsIndex); -- To ensure that this variable won't be local to this package, since -- in some cases, inlining forces this variable to be global anyway. -------------------- -- Local Packages -- -------------------- package Specific is function Is_Valid_Task return Boolean; pragma Inline (Is_Valid_Task); -- Does executing thread have a TCB? procedure Set (Self_Id : Task_Id); pragma Inline (Set); -- Set the self id for the current task end Specific; package body Specific is ------------------- -- Is_Valid_Task -- ------------------- function Is_Valid_Task return Boolean is begin return TlsGetValue (TlsIndex) /= System.Null_Address; end Is_Valid_Task; --------- -- Set -- --------- procedure Set (Self_Id : Task_Id) is Succeeded : BOOL; begin Succeeded := TlsSetValue (TlsIndex, To_Address (Self_Id)); pragma Assert (Succeeded = Win32.TRUE); end Set; end Specific; ---------------------------------- -- ATCB allocation/deallocation -- ---------------------------------- package body ATCB_Allocation is separate; -- The body of this package is shared across several targets --------------------------------- -- Support for foreign threads -- --------------------------------- function Register_Foreign_Thread (Thread : Thread_Id) return Task_Id; -- Allocate and Initialize a new ATCB for the current Thread function Register_Foreign_Thread (Thread : Thread_Id) return Task_Id is separate; ---------------------------------- -- Condition Variable Functions -- ---------------------------------- procedure Initialize_Cond (Cond : not null access Condition_Variable); -- Initialize given condition variable Cond procedure Finalize_Cond (Cond : not null access Condition_Variable); -- Finalize given condition variable Cond procedure Cond_Signal (Cond : not null access Condition_Variable); -- Signal condition variable Cond procedure Cond_Wait (Cond : not null access Condition_Variable; L : not null access RTS_Lock); -- Wait on conditional variable Cond, using lock L procedure Cond_Timed_Wait (Cond : not null access Condition_Variable; L : not null access RTS_Lock; Rel_Time : Duration; Timed_Out : out Boolean; Status : out Integer); -- Do timed wait on condition variable Cond using lock L. The duration -- of the timed wait is given by Rel_Time. When the condition is -- signalled, Timed_Out shows whether or not a time out occurred. -- Status is only valid if Timed_Out is False, in which case it -- shows whether Cond_Timed_Wait completed successfully. --------------------- -- Initialize_Cond -- --------------------- procedure Initialize_Cond (Cond : not null access Condition_Variable) is hEvent : HANDLE; begin hEvent := CreateEvent (null, Win32.TRUE, Win32.FALSE, Null_Ptr); pragma Assert (hEvent /= 0); Cond.all := Condition_Variable (hEvent); end Initialize_Cond; ------------------- -- Finalize_Cond -- ------------------- -- No such problem here, DosCloseEventSem has been derived. -- What does such refer to in above comment??? procedure Finalize_Cond (Cond : not null access Condition_Variable) is Result : BOOL; begin Result := CloseHandle (HANDLE (Cond.all)); pragma Assert (Result = Win32.TRUE); end Finalize_Cond; ----------------- -- Cond_Signal -- ----------------- procedure Cond_Signal (Cond : not null access Condition_Variable) is Result : BOOL; begin Result := SetEvent (HANDLE (Cond.all)); pragma Assert (Result = Win32.TRUE); end Cond_Signal; --------------- -- Cond_Wait -- --------------- -- Pre-condition: Cond is posted -- L is locked. -- Post-condition: Cond is posted -- L is locked. procedure Cond_Wait (Cond : not null access Condition_Variable; L : not null access RTS_Lock) is Result : DWORD; Result_Bool : BOOL; begin -- Must reset Cond BEFORE L is unlocked Result_Bool := ResetEvent (HANDLE (Cond.all)); pragma Assert (Result_Bool = Win32.TRUE); Unlock (L, Global_Lock => True); -- No problem if we are interrupted here: if the condition is signaled, -- WaitForSingleObject will simply not block Result := WaitForSingleObject (HANDLE (Cond.all), Wait_Infinite); pragma Assert (Result = 0); Write_Lock (L, Global_Lock => True); end Cond_Wait; --------------------- -- Cond_Timed_Wait -- --------------------- -- Pre-condition: Cond is posted -- L is locked. -- Post-condition: Cond is posted -- L is locked. procedure Cond_Timed_Wait (Cond : not null access Condition_Variable; L : not null access RTS_Lock; Rel_Time : Duration; Timed_Out : out Boolean; Status : out Integer) is Time_Out_Max : constant DWORD := 16#FFFF0000#; -- NT 4 can't handle excessive timeout values (e.g. DWORD'Last - 1) Time_Out : DWORD; Result : BOOL; Wait_Result : DWORD; begin -- Must reset Cond BEFORE L is unlocked Result := ResetEvent (HANDLE (Cond.all)); pragma Assert (Result = Win32.TRUE); Unlock (L, Global_Lock => True); -- No problem if we are interrupted here: if the condition is signaled, -- WaitForSingleObject will simply not block. if Rel_Time <= 0.0 then Timed_Out := True; Wait_Result := 0; else Time_Out := (if Rel_Time >= Duration (Time_Out_Max) / 1000 then Time_Out_Max else DWORD (Rel_Time * 1000)); Wait_Result := WaitForSingleObject (HANDLE (Cond.all), Time_Out); if Wait_Result = WAIT_TIMEOUT then Timed_Out := True; Wait_Result := 0; else Timed_Out := False; end if; end if; Write_Lock (L, Global_Lock => True); -- Ensure post-condition if Timed_Out then Result := SetEvent (HANDLE (Cond.all)); pragma Assert (Result = Win32.TRUE); end if; Status := Integer (Wait_Result); end Cond_Timed_Wait; ------------------ -- Stack_Guard -- ------------------ -- The underlying thread system sets a guard page at the bottom of a thread -- stack, so nothing is needed. -- ??? Check the comment above procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is pragma Unreferenced (T, On); begin null; end Stack_Guard; -------------------- -- Get_Thread_Id -- -------------------- function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is begin return T.Common.LL.Thread; end Get_Thread_Id; ---------- -- Self -- ---------- function Self return Task_Id is Self_Id : constant Task_Id := To_Task_Id (TlsGetValue (TlsIndex)); begin if Self_Id = null then return Register_Foreign_Thread (GetCurrentThread); else return Self_Id; end if; end Self; --------------------- -- Initialize_Lock -- --------------------- -- Note: mutexes and cond_variables needed per-task basis are initialized -- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such -- as RTS_Lock, Memory_Lock...) used in the RTS is initialized before any -- status change of RTS. Therefore raising Storage_Error in the following -- routines should be able to be handled safely. procedure Initialize_Lock (Prio : System.Any_Priority; L : not null access Lock) is begin InitializeCriticalSection (L.Mutex'Access); L.Owner_Priority := 0; L.Priority := Prio; end Initialize_Lock; procedure Initialize_Lock (L : not null access RTS_Lock; Level : Lock_Level) is pragma Unreferenced (Level); begin InitializeCriticalSection (L); end Initialize_Lock; ------------------- -- Finalize_Lock -- ------------------- procedure Finalize_Lock (L : not null access Lock) is begin DeleteCriticalSection (L.Mutex'Access); end Finalize_Lock; procedure Finalize_Lock (L : not null access RTS_Lock) is begin DeleteCriticalSection (L); end Finalize_Lock; ---------------- -- Write_Lock -- ---------------- procedure Write_Lock (L : not null access Lock; Ceiling_Violation : out Boolean) is begin L.Owner_Priority := Get_Priority (Self); if L.Priority < L.Owner_Priority then Ceiling_Violation := True; return; end if; EnterCriticalSection (L.Mutex'Access); Ceiling_Violation := False; end Write_Lock; procedure Write_Lock (L : not null access RTS_Lock; Global_Lock : Boolean := False) is begin if not Single_Lock or else Global_Lock then EnterCriticalSection (L); end if; end Write_Lock; procedure Write_Lock (T : Task_Id) is begin if not Single_Lock then EnterCriticalSection (T.Common.LL.L'Access); end if; end Write_Lock; --------------- -- Read_Lock -- --------------- procedure Read_Lock (L : not null access Lock; Ceiling_Violation : out Boolean) is begin Write_Lock (L, Ceiling_Violation); end Read_Lock; ------------ -- Unlock -- ------------ procedure Unlock (L : not null access Lock) is begin LeaveCriticalSection (L.Mutex'Access); end Unlock; procedure Unlock (L : not null access RTS_Lock; Global_Lock : Boolean := False) is begin if not Single_Lock or else Global_Lock then LeaveCriticalSection (L); end if; end Unlock; procedure Unlock (T : Task_Id) is begin if not Single_Lock then LeaveCriticalSection (T.Common.LL.L'Access); end if; end Unlock; ----------------- -- Set_Ceiling -- ----------------- -- Dynamic priority ceilings are not supported by the underlying system procedure Set_Ceiling (L : not null access Lock; Prio : System.Any_Priority) is pragma Unreferenced (L, Prio); begin null; end Set_Ceiling; ----------- -- Sleep -- ----------- procedure Sleep (Self_ID : Task_Id; Reason : System.Tasking.Task_States) is pragma Unreferenced (Reason); begin pragma Assert (Self_ID = Self); if Single_Lock then Cond_Wait (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); else Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); end if; if Self_ID.Deferral_Level = 0 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then Unlock (Self_ID); raise Standard'Abort_Signal; end if; end Sleep; ----------------- -- Timed_Sleep -- ----------------- -- This is for use within the run-time system, so abort is assumed to be -- already deferred, and the caller should be holding its own ATCB lock. procedure Timed_Sleep (Self_ID : Task_Id; Time : Duration; Mode : ST.Delay_Modes; Reason : System.Tasking.Task_States; Timedout : out Boolean; Yielded : out Boolean) is pragma Unreferenced (Reason); Check_Time : Duration := Monotonic_Clock; Rel_Time : Duration; Abs_Time : Duration; Result : Integer; pragma Unreferenced (Result); Local_Timedout : Boolean; begin Timedout := True; Yielded := False; if Mode = Relative then Rel_Time := Time; Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time; else Rel_Time := Time - Check_Time; Abs_Time := Time; end if; if Rel_Time > 0.0 then loop exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; if Single_Lock then Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, Rel_Time, Local_Timedout, Result); else Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, Rel_Time, Local_Timedout, Result); end if; Check_Time := Monotonic_Clock; exit when Abs_Time <= Check_Time; if not Local_Timedout then -- Somebody may have called Wakeup for us Timedout := False; exit; end if; Rel_Time := Abs_Time - Check_Time; end loop; end if; end Timed_Sleep; ----------------- -- Timed_Delay -- ----------------- procedure Timed_Delay (Self_ID : Task_Id; Time : Duration; Mode : ST.Delay_Modes) is Check_Time : Duration := Monotonic_Clock; Rel_Time : Duration; Abs_Time : Duration; Timedout : Boolean; Result : Integer; pragma Unreferenced (Timedout, Result); begin if Single_Lock then Lock_RTS; end if; Write_Lock (Self_ID); if Mode = Relative then Rel_Time := Time; Abs_Time := Time + Check_Time; else Rel_Time := Time - Check_Time; Abs_Time := Time; end if; if Rel_Time > 0.0 then Self_ID.Common.State := Delay_Sleep; loop exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; if Single_Lock then Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, Rel_Time, Timedout, Result); else Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, Rel_Time, Timedout, Result); end if; Check_Time := Monotonic_Clock; exit when Abs_Time <= Check_Time; Rel_Time := Abs_Time - Check_Time; end loop; Self_ID.Common.State := Runnable; end if; Unlock (Self_ID); if Single_Lock then Unlock_RTS; end if; Yield; end Timed_Delay; ------------ -- Wakeup -- ------------ procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is pragma Unreferenced (Reason); begin Cond_Signal (T.Common.LL.CV'Access); end Wakeup; ----------- -- Yield -- ----------- procedure Yield (Do_Yield : Boolean := True) is begin -- Note: in a previous implementation if Do_Yield was False, then we -- introduced a delay of 1 millisecond in an attempt to get closer to -- annex D semantics, and in particular to make ACATS CXD8002 pass. But -- this change introduced a huge performance regression evaluating the -- Count attribute. So we decided to remove this processing. -- Moreover, CXD8002 appears to pass on Windows (although we do not -- guarantee full Annex D compliance on Windows in any case). if Do_Yield then SwitchToThread; end if; end Yield; ------------------ -- Set_Priority -- ------------------ procedure Set_Priority (T : Task_Id; Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is Res : BOOL; pragma Unreferenced (Loss_Of_Inheritance); begin Res := SetThreadPriority (T.Common.LL.Thread, Interfaces.C.int (Underlying_Priorities (Prio))); pragma Assert (Res = Win32.TRUE); -- Note: Annex D (RM D.2.3(5/2)) requires the task to be placed at the -- head of its priority queue when decreasing its priority as a result -- of a loss of inherited priority. This is not the case, but we -- consider it an acceptable variation (RM 1.1.3(6)), given this is -- the built-in behavior offered by the Windows operating system. -- In older versions we attempted to better approximate the Annex D -- required behavior, but this simulation was not entirely accurate, -- and it seems better to live with the standard Windows semantics. T.Common.Current_Priority := Prio; end Set_Priority; ------------------ -- Get_Priority -- ------------------ function Get_Priority (T : Task_Id) return System.Any_Priority is begin return T.Common.Current_Priority; end Get_Priority; ---------------- -- Enter_Task -- ---------------- -- There were two paths were we needed to call Enter_Task : -- 1) from System.Task_Primitives.Operations.Initialize -- 2) from System.Tasking.Stages.Task_Wrapper -- The pseudo handle (LL.Thread) need not be closed when it is no -- longer needed. Calling the CloseHandle function with this handle -- has no effect. procedure Enter_Task (Self_ID : Task_Id) is procedure Get_Stack_Bounds (Base : Address; Limit : Address); pragma Import (C, Get_Stack_Bounds, "__gnat_get_stack_bounds"); -- Get stack boundaries begin Specific.Set (Self_ID); -- Properly initializes the FPU for x86 systems System.Float_Control.Reset; if Self_ID.Common.Task_Info /= null and then Self_ID.Common.Task_Info.CPU >= CPU_Number (Number_Of_Processors) then raise Invalid_CPU_Number; end if; Self_ID.Common.LL.Thread := GetCurrentThread; Self_ID.Common.LL.Thread_Id := GetCurrentThreadId; Get_Stack_Bounds (Self_ID.Common.Compiler_Data.Pri_Stack_Info.Base'Address, Self_ID.Common.Compiler_Data.Pri_Stack_Info.Limit'Address); end Enter_Task; ------------------- -- Is_Valid_Task -- ------------------- function Is_Valid_Task return Boolean renames Specific.Is_Valid_Task; ----------------------------- -- Register_Foreign_Thread -- ----------------------------- function Register_Foreign_Thread return Task_Id is begin if Is_Valid_Task then return Self; else return Register_Foreign_Thread (GetCurrentThread); end if; end Register_Foreign_Thread; -------------------- -- Initialize_TCB -- -------------------- procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is begin -- Initialize thread ID to 0, this is needed to detect threads that -- are not yet activated. Self_ID.Common.LL.Thread := Null_Thread_Id; Initialize_Cond (Self_ID.Common.LL.CV'Access); if not Single_Lock then Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level); end if; Succeeded := True; end Initialize_TCB; ----------------- -- Create_Task -- ----------------- procedure Create_Task (T : Task_Id; Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; Priority : System.Any_Priority; Succeeded : out Boolean) is Initial_Stack_Size : constant := 1024; -- We set the initial stack size to 1024. On Windows version prior to XP -- there is no way to fix a task stack size. Only the initial stack size -- can be set, the operating system will raise the task stack size if -- needed. function Is_Windows_XP return Integer; pragma Import (C, Is_Windows_XP, "__gnat_is_windows_xp"); -- Returns 1 if running on Windows XP hTask : HANDLE; TaskId : aliased DWORD; pTaskParameter : Win32.PVOID; Result : DWORD; Entry_Point : PTHREAD_START_ROUTINE; use type System.Multiprocessors.CPU_Range; begin -- Check whether both Dispatching_Domain and CPU are specified for the -- task, and the CPU value is not contained within the range of -- processors for the domain. if T.Common.Domain /= null and then T.Common.Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU and then (T.Common.Base_CPU not in T.Common.Domain'Range or else not T.Common.Domain (T.Common.Base_CPU)) then Succeeded := False; return; end if; pTaskParameter := To_Address (T); Entry_Point := To_PTHREAD_START_ROUTINE (Wrapper); if Is_Windows_XP = 1 then hTask := CreateThread (null, DWORD (Stack_Size), Entry_Point, pTaskParameter, DWORD (Create_Suspended) or DWORD (Stack_Size_Param_Is_A_Reservation), TaskId'Unchecked_Access); else hTask := CreateThread (null, Initial_Stack_Size, Entry_Point, pTaskParameter, DWORD (Create_Suspended), TaskId'Unchecked_Access); end if; -- Step 1: Create the thread in blocked mode if hTask = 0 then Succeeded := False; return; end if; -- Step 2: set its TCB T.Common.LL.Thread := hTask; -- Note: it would be useful to initialize Thread_Id right away to avoid -- a race condition in gdb where Thread_ID may not have the right value -- yet, but GetThreadId is a Vista specific API, not available under XP: -- T.Common.LL.Thread_Id := GetThreadId (hTask); so instead we set the -- field to 0 to avoid having a random value. Thread_Id is initialized -- in Enter_Task anyway. T.Common.LL.Thread_Id := 0; -- Step 3: set its priority (child has inherited priority from parent) Set_Priority (T, Priority); if Time_Slice_Val = 0 or else Dispatching_Policy = 'F' or else Get_Policy (Priority) = 'F' then -- Here we need Annex D semantics so we disable the NT priority -- boost. A priority boost is temporarily given by the system to -- a thread when it is taken out of a wait state. SetThreadPriorityBoost (hTask, DisablePriorityBoost => Win32.TRUE); end if; -- Step 4: Handle pragma CPU and Task_Info Set_Task_Affinity (T); -- Step 5: Now, start it for good Result := ResumeThread (hTask); pragma Assert (Result = 1); Succeeded := Result = 1; end Create_Task; ------------------ -- Finalize_TCB -- ------------------ procedure Finalize_TCB (T : Task_Id) is Succeeded : BOOL; begin if not Single_Lock then Finalize_Lock (T.Common.LL.L'Access); end if; Finalize_Cond (T.Common.LL.CV'Access); if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; if T.Common.LL.Thread /= 0 then -- This task has been activated. Close the thread handle. This -- is needed to release system resources. Succeeded := CloseHandle (T.Common.LL.Thread); pragma Assert (Succeeded = Win32.TRUE); end if; ATCB_Allocation.Free_ATCB (T); end Finalize_TCB; --------------- -- Exit_Task -- --------------- procedure Exit_Task is begin Specific.Set (null); end Exit_Task; ---------------- -- Abort_Task -- ---------------- procedure Abort_Task (T : Task_Id) is pragma Unreferenced (T); begin null; end Abort_Task; ---------------------- -- Environment_Task -- ---------------------- function Environment_Task return Task_Id is begin return Environment_Task_Id; end Environment_Task; -------------- -- Lock_RTS -- -------------- procedure Lock_RTS is begin Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); end Lock_RTS; ---------------- -- Unlock_RTS -- ---------------- procedure Unlock_RTS is begin Unlock (Single_RTS_Lock'Access, Global_Lock => True); end Unlock_RTS; ---------------- -- Initialize -- ---------------- procedure Initialize (Environment_Task : Task_Id) is Discard : BOOL; begin Environment_Task_Id := Environment_Task; OS_Primitives.Initialize; Interrupt_Management.Initialize; if Time_Slice_Val = 0 or else Dispatching_Policy = 'F' then -- Here we need Annex D semantics, switch the current process to the -- Realtime_Priority_Class. Discard := OS_Interface.SetPriorityClass (GetCurrentProcess, Realtime_Priority_Class); end if; TlsIndex := TlsAlloc; -- Initialize the lock used to synchronize chain of all ATCBs Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Environment_Task.Common.LL.Thread := GetCurrentThread; -- Make environment task known here because it doesn't go through -- Activate_Tasks, which does it for all other tasks. Known_Tasks (Known_Tasks'First) := Environment_Task; Environment_Task.Known_Tasks_Index := Known_Tasks'First; Enter_Task (Environment_Task); -- pragma CPU and dispatching domains for the environment task Set_Task_Affinity (Environment_Task); end Initialize; --------------------- -- Monotonic_Clock -- --------------------- function Monotonic_Clock return Duration is function Internal_Clock return Duration; pragma Import (Ada, Internal_Clock, "__gnat_monotonic_clock"); begin return Internal_Clock; end Monotonic_Clock; ------------------- -- RT_Resolution -- ------------------- function RT_Resolution return Duration is Ticks_Per_Second : aliased LARGE_INTEGER; begin QueryPerformanceFrequency (Ticks_Per_Second'Access); return Duration (1.0 / Ticks_Per_Second); end RT_Resolution; ---------------- -- Initialize -- ---------------- procedure Initialize (S : in out Suspension_Object) is begin -- Initialize internal state. It is always initialized to False (ARM -- D.10 par. 6). S.State := False; S.Waiting := False; -- Initialize internal mutex InitializeCriticalSection (S.L'Access); -- Initialize internal condition variable S.CV := CreateEvent (null, Win32.TRUE, Win32.FALSE, Null_Ptr); pragma Assert (S.CV /= 0); end Initialize; -------------- -- Finalize -- -------------- procedure Finalize (S : in out Suspension_Object) is Result : BOOL; begin -- Destroy internal mutex DeleteCriticalSection (S.L'Access); -- Destroy internal condition variable Result := CloseHandle (S.CV); pragma Assert (Result = Win32.TRUE); end Finalize; ------------------- -- Current_State -- ------------------- function Current_State (S : Suspension_Object) return Boolean is begin -- We do not want to use lock on this read operation. State is marked -- as Atomic so that we ensure that the value retrieved is correct. return S.State; end Current_State; --------------- -- Set_False -- --------------- procedure Set_False (S : in out Suspension_Object) is begin SSL.Abort_Defer.all; EnterCriticalSection (S.L'Access); S.State := False; LeaveCriticalSection (S.L'Access); SSL.Abort_Undefer.all; end Set_False; -------------- -- Set_True -- -------------- procedure Set_True (S : in out Suspension_Object) is Result : BOOL; begin SSL.Abort_Defer.all; EnterCriticalSection (S.L'Access); -- If there is already a task waiting on this suspension object then -- we resume it, leaving the state of the suspension object to False, -- as it is specified in ARM D.10 par. 9. Otherwise, it just leaves -- the state to True. if S.Waiting then S.Waiting := False; S.State := False; Result := SetEvent (S.CV); pragma Assert (Result = Win32.TRUE); else S.State := True; end if; LeaveCriticalSection (S.L'Access); SSL.Abort_Undefer.all; end Set_True; ------------------------ -- Suspend_Until_True -- ------------------------ procedure Suspend_Until_True (S : in out Suspension_Object) is Result : DWORD; Result_Bool : BOOL; begin SSL.Abort_Defer.all; EnterCriticalSection (S.L'Access); if S.Waiting then -- Program_Error must be raised upon calling Suspend_Until_True -- if another task is already waiting on that suspension object -- (ARM D.10 par. 10). LeaveCriticalSection (S.L'Access); SSL.Abort_Undefer.all; raise Program_Error; else -- Suspend the task if the state is False. Otherwise, the task -- continues its execution, and the state of the suspension object -- is set to False (ARM D.10 par. 9). if S.State then S.State := False; LeaveCriticalSection (S.L'Access); SSL.Abort_Undefer.all; else S.Waiting := True; -- Must reset CV BEFORE L is unlocked Result_Bool := ResetEvent (S.CV); pragma Assert (Result_Bool = Win32.TRUE); LeaveCriticalSection (S.L'Access); SSL.Abort_Undefer.all; Result := WaitForSingleObject (S.CV, Wait_Infinite); pragma Assert (Result = 0); end if; end if; end Suspend_Until_True; ---------------- -- Check_Exit -- ---------------- -- Dummy versions, currently this only works for solaris (native) function Check_Exit (Self_ID : ST.Task_Id) return Boolean is pragma Unreferenced (Self_ID); begin return True; end Check_Exit; -------------------- -- Check_No_Locks -- -------------------- function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is pragma Unreferenced (Self_ID); begin return True; end Check_No_Locks; ------------------ -- Suspend_Task -- ------------------ function Suspend_Task (T : ST.Task_Id; Thread_Self : Thread_Id) return Boolean is begin if T.Common.LL.Thread /= Thread_Self then return SuspendThread (T.Common.LL.Thread) = NO_ERROR; else return True; end if; end Suspend_Task; ----------------- -- Resume_Task -- ----------------- function Resume_Task (T : ST.Task_Id; Thread_Self : Thread_Id) return Boolean is begin if T.Common.LL.Thread /= Thread_Self then return ResumeThread (T.Common.LL.Thread) = NO_ERROR; else return True; end if; end Resume_Task; -------------------- -- Stop_All_Tasks -- -------------------- procedure Stop_All_Tasks is begin null; end Stop_All_Tasks; --------------- -- Stop_Task -- --------------- function Stop_Task (T : ST.Task_Id) return Boolean is pragma Unreferenced (T); begin return False; end Stop_Task; ------------------- -- Continue_Task -- ------------------- function Continue_Task (T : ST.Task_Id) return Boolean is pragma Unreferenced (T); begin return False; end Continue_Task; ----------------------- -- Set_Task_Affinity -- ----------------------- procedure Set_Task_Affinity (T : ST.Task_Id) is Result : DWORD; use type System.Multiprocessors.CPU_Range; begin -- Do nothing if the underlying thread has not yet been created. If the -- thread has not yet been created then the proper affinity will be set -- during its creation. if T.Common.LL.Thread = Null_Thread_Id then null; -- pragma CPU elsif T.Common.Base_CPU /= Multiprocessors.Not_A_Specific_CPU then -- The CPU numbering in pragma CPU starts at 1 while the subprogram -- to set the affinity starts at 0, therefore we must substract 1. Result := SetThreadIdealProcessor (T.Common.LL.Thread, ProcessorId (T.Common.Base_CPU) - 1); pragma Assert (Result = 1); -- Task_Info elsif T.Common.Task_Info /= null then if T.Common.Task_Info.CPU /= Task_Info.Any_CPU then Result := SetThreadIdealProcessor (T.Common.LL.Thread, T.Common.Task_Info.CPU); pragma Assert (Result = 1); end if; -- Dispatching domains elsif T.Common.Domain /= null and then (T.Common.Domain /= ST.System_Domain or else T.Common.Domain.all /= (Multiprocessors.CPU'First .. Multiprocessors.Number_Of_CPUs => True)) then declare CPU_Set : DWORD := 0; begin for Proc in T.Common.Domain'Range loop if T.Common.Domain (Proc) then -- The thread affinity mask is a bit vector in which each -- bit represents a logical processor. CPU_Set := CPU_Set + 2 ** (Integer (Proc) - 1); end if; end loop; Result := SetThreadAffinityMask (T.Common.LL.Thread, CPU_Set); pragma Assert (Result = 1); end; end if; end Set_Task_Affinity; end System.Task_Primitives.Operations;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . R E A L _ T I M E . T I M I N G _ E V E N T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2005-2019, 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. -- -- -- ------------------------------------------------------------------------------ with Ada.Finalization; package Ada.Real_Time.Timing_Events is type Timing_Event is tagged limited private; type Timing_Event_Handler is access protected procedure (Event : in out Timing_Event); procedure Set_Handler (Event : in out Timing_Event; At_Time : Time; Handler : Timing_Event_Handler); procedure Set_Handler (Event : in out Timing_Event; In_Time : Time_Span; Handler : Timing_Event_Handler); function Current_Handler (Event : Timing_Event) return Timing_Event_Handler; procedure Cancel_Handler (Event : in out Timing_Event; Cancelled : out Boolean); function Time_Of_Event (Event : Timing_Event) return Time; private type Timing_Event is new Ada.Finalization.Limited_Controlled with record Timeout : Time := Time_First; -- The time at which the user's handler should be invoked when the -- event is "set" (i.e., when Handler is not null). Handler : Timing_Event_Handler; -- An access value designating the protected procedure to be invoked -- at the Timeout time in the future. When this value is null the event -- is said to be "cleared" and no timeout is processed. end record; overriding procedure Finalize (This : in out Timing_Event); -- Finalization procedure is required to satisfy (RM D.15 (19/2)), which -- says that the object must be cleared on finalization. end Ada.Real_Time.Timing_Events;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . S T R I N G S . F I X E D . H A S H -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Containers, Ada.Strings.Hash; function Ada.Strings.Fixed.Hash (Key : String) return Containers.Hash_Type renames Ada.Strings.Hash; pragma Pure (Ada.Strings.Fixed.Hash);
-------------------------------------------------------- -- E n c o d i n g s -- -- -- -- Tools for convertion strings between Unicode and -- -- national/vendor character sets. -- -- - - - - - - - - - -- -- Read copyright and license at the end of this file -- -------------------------------------------------------- package Encodings.Maps.UTF_8 is procedure Encode (Text : in Wide_String; Text_Last : out Natural; Result : out Raw_String; Result_Last : out Natural; Map : in Encoding := Encodings.UTF_8); procedure Decode (Text : in Raw_String; Text_Last : out Natural; Result : out Wide_String; Result_Last : out Natural; Map : in Encoding := Encodings.UTF_8); end Encodings.Maps.UTF_8; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- 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 Maxim Reznik, 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 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. ------------------------------------------------------------------------------
-- Copyright 2016,2017 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. generic type Element_T is private; package Linted.Channels is pragma Pure; protected type Channel is private -- Overwrites old values procedure Push (Element : Element_T) with Global => null, Depends => (Channel =>+ Element); entry Pop_Impl (Element : out Element_T) with Global => null, Depends => (Element => Channel, Channel =>+ null); procedure Poll (Element : out Element_T; Success : out Boolean) with Global => null, Depends => (Element => Channel, Channel =>+ null, Success => Channel); Current : Element_T; Full : Boolean := False; end Channel; procedure Push (This : in out Channel; Element : Element_T) with Global => null, Depends => (This =>+ Element); procedure Pop (This : in out Channel; Element : out Element_T) with Global => null, Depends => (Element => This, This =>+ null); procedure Poll (This : in out Channel; Element : out Element_T; Success : out Boolean) with Global => null, Depends => ((Element, Success) => This, This =>+ null); private end Linted.Channels;
------------------------------------------------------------------------------ -- A d a r u n - t i m e s p e c i f i c a t i o n -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of ada.ads file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Бб., 30 нояб. 2013) $ package Ada.Decimal is pragma Pure (Decimal); Max_Scale : constant := implementation-defined; Min_Scale : constant := implementation-defined; Min_Delta : constant := 10.0**(-Max_Scale); Max_Delta : constant := 10.0**(-Min_Scale); Max_Decimal_Digits : constant := implementation-defined; generic type Dividend_Type is delta <> digits <>; type Divisor_Type is delta <> digits <>; type Quotient_Type is delta <> digits <>; type Remainder_Type is delta <> digits <>; procedure Divide (Dividend : in Dividend_Type; Divisor : in Divisor_Type; Quotient : out Quotient_Type; Remainder : out Remainder_Type); pragma Convention (Intrinsic, Divide); end Ada.Decimal;
--------------------------------------------------------------------------------- -- Copyright 2004-2005 Β© Luke A. Guest -- -- This code is to be used for tutorial purposes only. -- You may not redistribute this code in any form without my express permission. --------------------------------------------------------------------------------- with Interfaces.C; use Interfaces.C; --with Interfaces.C.Strings; use Interfaces.C.Strings; with Text_Io; use Text_Io; with SDL.Types; use SDL.Types; with SDL.Keyboard; with SDL.Keysym; with SDL.Video; with SDL.Events; with SDL.Timer; with SDL.Active; use type SDL.Init_Flags; use type SDL.Active.Active_State; use type SDL.Video.Surface_Flags; use type SDL.Video.Surface_Ptr; use type SDL.Video.VideoInfo_ConstPtr; with Example; with GL; with GLU; use type GL.GLdouble; -- A simple example of a cube drawn with a display list. procedure Multipass is pragma Link_With("-lSDL"); VideoFlags : SDL.Video.Surface_Flags := SDL.Video.OPENGL or SDL.Video.HWPALETTE or SDL.Video.RESIZABLE; Result : Boolean := False; TickCount : Integer := 0; procedure ReshapeGL(Width, Height : in GL.GLint) is AspectRatio : constant GL.GLdouble := GL.GLdouble(Width) / GL.GLdouble(Height); begin GL.glViewport(0, 0, GL.GLsizei(Width), GL.GLsizei(Height)); -- The Current Viewport. GL.glMatrixMode(GL.GL_PROJECTION); -- The Projection Matrix. GL.glLoadIdentity; -- The Projection Matrix. GLU.gluPerspective(45.0, AspectRatio, 1.0, 100.0); -- Calculate The Aspect Ratio Of The Window. GL.glMatrixMode(GL.GL_MODELVIEW); -- The Modelview Matrix. GL.glLoadIdentity; -- Reset The Modelview Matrix. end ReshapeGL; procedure CreateWindowGL(Result : out Boolean) is VideoInfo : SDL.Video.VideoInfo_ConstPtr; begin if SDL.Init(SDL.INIT_VIDEO or SDL.INIT_TIMER) = -1 then Put_Line("Error Initialising SDL"); Result := False; else VideoInfo := SDL.Video.GetVideoInfo; if VideoInfo = null then Put_Line("Error Retrieving video information"); Result := False; else if VideoInfo.hw_available = 1 then VideoFlags := VideoFlags or SDL.Video.HWSURFACE; else VideoFlags := VideoFlags or SDL.Video.SWSURFACE; end if; if VideoInfo.blit_hw = 1 then VideoFlags := VideoFlags or SDL.Video.HWACCEL; end if; SDL.Video.GL_SetAttribute(SDL.Video.GL_RED_SIZE, 5); SDL.Video.GL_SetAttribute(SDL.Video.GL_GREEN_SIZE, 5); SDL.Video.GL_SetAttribute(SDL.Video.GL_BLUE_SIZE, 5); SDL.Video.GL_SetAttribute(SDL.Video.GL_DEPTH_SIZE, 16); SDL.Video.GL_SetAttribute(SDL.Video.GL_DOUBLEBUFFER, 1); Example.SetSurface(SDL.Video.SetVideoMode(C.int(Example.GetWidth), C.int(Example.GetHeight), C.int(Example.GetBitsPerPixel), VideoFlags)); if Example.GetSurface = null then Put_Line("Error setting video mode"); Result := False; else SDL.Video.WM_Set_Caption_Title(Example.GetTitle); ReshapeGL(GL.GLint(Example.GetWidth), GL.GLint(Example.GetHeight)); end if; end if; end if; Result := True; end CreateWindowGL; procedure DestroyWindowGL is begin SDL.SDL_Quit; end DestroyWindowGL; procedure PollEvents is Event : aliased SDL.Events.Event; begin while SDL.Events.PollEvent(Event'Unchecked_Access) /= 0 loop case Event.the_type is when SDL.Events.QUIT => Put_Line("Quitting..."); Example.SetQuit(True); when SDL.Events.KEYDOWN => Example.SetKey(Event.Key.Keysym.sym, True); when SDL.Events.KEYUP => Example.SetKey(Event.Key.Keysym.sym, False); when SDL.Events.VIDEORESIZE => Example.SetSurface(SDL.Video.SetVideoMode(Event.Resize.w, Event.Resize.h, C.int(Example.GetBitsPerPixel), VideoFlags)); ReshapeGL(GL.GLint(Event.Resize.w), GL.GLint(Event.Resize.h)); when SDL.Events.ISACTIVEEVENT => if Event.Active.Gain = 0 then Example.SetActive(False); else Example.SetActive(True); end if; when others => null; end case; end loop; end PollEvents; package Float_InOut is new Text_IO.Float_IO(Float); use Float_InOut; begin CreateWindowGL(Result); Example.PrintGLInfo; Example.PrintUsage; if Result = True then if Example.Initialise = True then while Example.Quit = False loop PollEvents; if Example.IsActive = True then --TickCount := Integer(SDL.Timer.GetTicks); Example.Update;--(TickCount); --Example.SetLastTickCount(TickCount); Example.Draw; Example.CalculateFPS; SDL.Video.GL_SwapBuffers; end if; end loop; Example.Uninitialise; end if; DestroyWindowGL; end if; end Multipass;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright Β© 2015, 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.String_Vectors; with Asis.Declarations; with Asis.Definitions; with Asis.Elements; with Asis.Expressions; with Properties.Tools; with Properties.Expressions.Identifiers; package body Properties.Expressions.Record_Aggregate is ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is use type League.Strings.Universal_String; use type Asis.Declaration_List; procedure Append (Names : League.Strings.Universal_String; Code : League.Strings.Universal_String); procedure Mark_Done (Name : League.Strings.Universal_String); function Get_Name (Index : Positive) return League.Strings.Universal_String; function Get_Type_Name return League.Strings.Universal_String; Tipe : constant Asis.Element := Asis.Expressions.Corresponding_Expression_Type_Definition (Element); Parts : constant Asis.Declaration_List := Tools.Corresponding_Type_Discriminants (Tipe) & Tools.Corresponding_Type_Components (Tipe); Done : array (Parts'Range) of Boolean := (others => False); Last : Natural := 0; Result : League.Strings.Universal_String; ------------ -- Append -- ------------ procedure Append (Names : League.Strings.Universal_String; Code : League.Strings.Universal_String) is Text : League.Strings.Universal_String; List : constant League.String_Vectors.Universal_String_Vector := Names.Split (','); begin if List.Length = 0 then -- positional association Last := Last + 1; Done (Last) := True; Text := Get_Name (Last); Result.Append (Text); Result.Append (":"); Result.Append (Code); else for J in 1 .. List.Length loop Mark_Done (List.Element (J)); Result.Append (List.Element (J)); Result.Append (":"); Result.Append (Code); end loop; end if; end Append; -------------- -- Get_Name -- -------------- function Get_Name (Index : Positive) return League.Strings.Universal_String is Names : constant Asis.Defining_Name_List := Asis.Declarations.Names (Parts (Index)); begin pragma Assert (Names'Length = 1); return Engine.Text.Get_Property (Names (Names'First), Code.Name); end Get_Name; ------------------- -- Get_Type_Name -- ------------------- function Get_Type_Name return League.Strings.Universal_String is use type Asis.Definition_Kinds; use type Asis.Expression_Kinds; Result : League.Strings.Universal_String; Name : League.Strings.Universal_String; X : Asis.Element := Tipe; Decl : Asis.Declaration; begin -- Unwind all subtype declarations while Asis.Elements.Definition_Kind (X) = Asis.A_Subtype_Indication loop X := Asis.Definitions.Subtype_Mark (X); if Asis.Elements.Expression_Kind (X) = Asis.A_Selected_Component then X := Asis.Expressions.Selector (X); end if; X := Asis.Expressions.Corresponding_Name_Declaration (X); X := Asis.Declarations.Type_Declaration_View (X); end loop; if Asis.Elements.Definition_Kind (X) = Asis.A_Type_Definition then Decl := Asis.Elements.Enclosing_Element (X); Result := Properties.Expressions.Identifiers.Name_Prefix (Engine => Engine, Name => Element, Decl => Asis.Elements.Enclosing_Element (X)); Name := Engine.Text.Get_Property (Asis.Declarations.Names (Decl) (1), Code.Name); Result.Append (Name); end if; return Result; end Get_Type_Name; --------------- -- Mark_Done -- --------------- procedure Mark_Done (Name : League.Strings.Universal_String) is Text : League.Strings.Universal_String; begin for J in Parts'Range loop if not Done (J) then Text := Get_Name (J); if Text = Name then Done (J) := True; return; end if; end if; end loop; end Mark_Done; Names : League.Strings.Universal_String; Text : League.Strings.Universal_String; List : constant Asis.Association_List := Asis.Expressions.Record_Component_Associations (Element); Tipe_Name : constant League.Strings.Universal_String := Get_Type_Name; begin if not Tipe_Name.Is_Empty then Result.Append (Tipe_Name); Result.Append ("._cast("); end if; Result.Append ("{"); for J in List'Range loop Names := Engine.Text.Get_Property (List (J), Engines.Associations); if Names /= League.Strings.To_Universal_String ("others") then Text := Engine.Text.Get_Property (List (J), Name); if not Text.Is_Empty then -- Box <> expression returns empty Code. We ignore such assoc. if J /= List'First then Result.Append (","); end if; Append (Names, Text); end if; end if; end loop; for J in Parts'Range loop if not Done (J) then Text := Get_Name (J); Result.Append (","); Result.Append (Text); Result.Append (":"); Text := Engine.Text.Get_Property (Parts (J), Engines.Initialize); Result.Append (Text); end if; end loop; Result.Append ("}"); if not Tipe_Name.Is_Empty then Result.Append (")"); end if; return Result; end Code; ---------------------------- -- Typed_Array_Initialize -- ---------------------------- function Typed_Array_Initialize (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is Result : League.Strings.Universal_String; Down : League.Strings.Universal_String; Item : Asis.Expression; List : constant Asis.Association_List := Asis.Expressions.Record_Component_Associations (Element); begin Result.Append ("_result._TA_allign(4);"); for J in List'Range loop pragma Assert (Asis.Expressions.Record_Component_Choices (List (J))'Length = 0, "Named associations in Typed_Array aggregate" & " are not supported"); Item := Asis.Expressions.Component_Expression (List (J)); Down := Engine.Text.Get_Property (Item, Name); Result.Append (Down); end loop; return Result; end Typed_Array_Initialize; end Properties.Expressions.Record_Aggregate;
package Problem_10 is procedure Solve; end Problem_10;
-- Lambda Calculus interpreter -- --------------------------- -- Parses and reduces Lamdba Calculus statements. -- -- What is the strategy for reducing an expression? -- - Strict evaluation is bottom up (C, Fortran, Java, Ada, etc) -- - Lazy evaluation is top down - left to right (Haskel, Lambda Calculus) -- -- Start with lazy evaluation. Come back and do strict evaluation as an enhancement. -- -- In what order do we perform alpha substitution, beta reduction, eta reduction -- - beta and eta reduction can be performed in any order - result is the same -- - alpha substitution renames bound variables so that they do not overlap with free variables being substituted -- (Barendregt Variable Convention). Need to check this prior to performing a beta substitution. -- -- Reduction is iterative. What is the stopping condition? -- - A Normal form cannot be further reduced. Next form = last form, ie Alpha-Equivalence. -- - Is beta normal if cannot be beta reduced -- - Is eta normal if cannot be eta reduced -- - can end up in an infinite loop -- - there may be more than one normal form -- -- Simplest stopping condition is if the expression is just Beta Normal. -- More complex stopping condition is if the expression is both Beta Normal & Eta Normal. Could this lead to loops? Is this useful? -- -- Musings: -- Reduction rules are the functions of a calculi. For example, the reduction rules of arithmetic are the tables of addition and multiplication of numerals. -- If the reduction rules for the Lambda calculus were encoded in configuration then this interpreter could easily be extended with additional functions, -- enabling it to be used for more complex types of calculus. (eg. could you turn this into a Lisp interpreter?) -- with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Containers; use Ada.Containers; with Ada.Containers.Multiway_Trees; with Ada.Strings.Unbounded; -- package Instructions is new Ada.Containers.Multiway_Trees -- (Element_Type => Element_Record); -- use Instructions; with Lambda; use Lambda; Package Lambda_Reducer is function reduce( I: Instructions.Tree ) return Instructions.Tree; private -- Alpha-renaming to preserve the meaning of a function -- function rename( I: Instructions.Tree ) return Instructions.Tree; -- Beta-reduction, Eta-reduction. -- Variable substitution, eg (?x.x)[y:=y] = ?x.(x[y:=y]) = ?x.x -- function substitution( I: Instructions.Tree ) return Instructions.Tree; -- -- Test for alpha-equivalence. Can we use this to detect when we are in a recursion loop? -- -- -- Expression Optimiser -- - ((X)) => (X) -- - X() => X procedure Optimise( I: in out Instructions.Tree ; Curs : Instructions.Cursor ); end Lambda_Reducer;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Case_Expression_Paths; with Program.Elements.Case_Expressions; with Program.Element_Visitors; package Program.Nodes.Case_Expressions is pragma Preelaborate; type Case_Expression is new Program.Nodes.Node and Program.Elements.Case_Expressions.Case_Expression and Program.Elements.Case_Expressions.Case_Expression_Text with private; function Create (Case_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Selecting_Expression : not null Program.Elements.Expressions .Expression_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Paths : not null Program.Elements.Case_Expression_Paths .Case_Expression_Path_Vector_Access) return Case_Expression; type Implicit_Case_Expression is new Program.Nodes.Node and Program.Elements.Case_Expressions.Case_Expression with private; function Create (Selecting_Expression : not null Program.Elements.Expressions .Expression_Access; Paths : not null Program.Elements.Case_Expression_Paths .Case_Expression_Path_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Case_Expression with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Case_Expression is abstract new Program.Nodes.Node and Program.Elements.Case_Expressions.Case_Expression with record Selecting_Expression : not null Program.Elements.Expressions .Expression_Access; Paths : not null Program.Elements.Case_Expression_Paths .Case_Expression_Path_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Case_Expression'Class); overriding procedure Visit (Self : not null access Base_Case_Expression; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Selecting_Expression (Self : Base_Case_Expression) return not null Program.Elements.Expressions.Expression_Access; overriding function Paths (Self : Base_Case_Expression) return not null Program.Elements.Case_Expression_Paths .Case_Expression_Path_Vector_Access; overriding function Is_Case_Expression_Element (Self : Base_Case_Expression) return Boolean; overriding function Is_Expression_Element (Self : Base_Case_Expression) return Boolean; type Case_Expression is new Base_Case_Expression and Program.Elements.Case_Expressions.Case_Expression_Text with record Case_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Is_Token : not null Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Case_Expression_Text (Self : aliased in out Case_Expression) return Program.Elements.Case_Expressions.Case_Expression_Text_Access; overriding function Case_Token (Self : Case_Expression) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Is_Token (Self : Case_Expression) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Case_Expression is new Base_Case_Expression with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Case_Expression_Text (Self : aliased in out Implicit_Case_Expression) return Program.Elements.Case_Expressions.Case_Expression_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Case_Expression) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Case_Expression) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Case_Expression) return Boolean; end Program.Nodes.Case_Expressions;
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C; use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C; procedure prologin_template_charmatrix is type stringptr is access all char_array; procedure PString(s : stringptr) is begin String'Write (Text_Streams.Stream (Current_Output), To_Ada(s.all)); end; procedure PChar(c : in Character) is begin Character'Write (Text_Streams.Stream (Current_Output), c); end; procedure PInt(i : in Integer) is begin String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left)); end; procedure SkipSpaces is C : Character; Eol : Boolean; begin loop Look_Ahead(C, Eol); exit when Eol or C /= ' '; Get(C); end loop; end; type e is Array (Integer range <>) of Character; type e_PTR is access e; type f is Array (Integer range <>) of e_PTR; type f_PTR is access f; function programme_candidat(tableau : in f_PTR; taille_x : in Integer; taille_y : in Integer) return Integer is out0 : Integer; begin out0 := 0; for i in integer range 0..taille_y - 1 loop for j in integer range 0..taille_x - 1 loop out0 := out0 + Character'Pos(tableau(i)(j)) * (i + j * 2); PChar(tableau(i)(j)); end loop; PString(new char_array'( To_C("--" & Character'Val(10)))); end loop; return out0; end; taille_y : Integer; taille_x : Integer; tableau : f_PTR; c : e_PTR; a : f_PTR; begin Get(taille_x); SkipSpaces; Get(taille_y); SkipSpaces; a := new f (0..taille_y - 1); for b in integer range 0..taille_y - 1 loop c := new e (0..taille_x - 1); for d in integer range 0..taille_x - 1 loop Get(c(d)); end loop; SkipSpaces; a(b) := c; end loop; tableau := a; PInt(programme_candidat(tableau, taille_x, taille_y)); PString(new char_array'( To_C("" & Character'Val(10)))); end;
-- Copyright 2016-2021 Bartek thindil Jasicki -- -- This file is part of Steam Sky. -- -- Steam Sky is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- Steam Sky is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with Steam Sky. If not, see <http://www.gnu.org/licenses/>. with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with DOM.Core; use DOM.Core; with DOM.Core.Documents; with DOM.Core.Nodes; use DOM.Core.Nodes; with DOM.Core.Elements; use DOM.Core.Elements; with Log; use Log; with Game; use Game; with Items; use Items; package body Help is procedure LoadHelp(Reader: Tree_Reader) is use Short_String; use Tiny_String; TmpHelp: Help_Data; NodesList: Node_List; HelpData: Document; Action: Data_Action; HelpIndex, HelpTitle: Unbounded_String; HelpNode: Node; begin HelpData := Get_Tree(Reader); NodesList := DOM.Core.Documents.Get_Elements_By_Tag_Name(HelpData, "entry"); Load_Help_Data : for I in 0 .. Length(NodesList) - 1 loop TmpHelp := (Index => Null_Unbounded_String, Text => Null_Unbounded_String); HelpNode := Item(NodesList, I); Action := (if Get_Attribute(HelpNode, "action")'Length > 0 then Data_Action'Value(Get_Attribute(HelpNode, "action")) else ADD); HelpIndex := To_Unbounded_String(Get_Attribute(HelpNode, "index")); HelpTitle := To_Unbounded_String(Get_Attribute(HelpNode, "title")); if Action in UPDATE | REMOVE then if not Help_Container.Contains(Help_List, HelpTitle) then raise Data_Loading_Error with "Can't " & To_Lower(Data_Action'Image(Action)) & " help '" & To_String(HelpTitle) & "', there no help with that title."; end if; elsif Help_Container.Contains(Help_List, HelpTitle) then raise Data_Loading_Error with "Can't add help '" & To_String(HelpTitle) & "', there is one with that title."; end if; if Action /= REMOVE then TmpHelp.Index := HelpIndex; if Action = UPDATE then TmpHelp := Help_List(HelpTitle); end if; if Has_Child_Nodes(HelpNode) then TmpHelp.Text := To_Unbounded_String(Node_Value(First_Child(HelpNode))); end if; if Action /= UPDATE then Help_Container.Include(Help_List, HelpTitle, TmpHelp); Log_Message("Help added: " & To_String(HelpTitle), EVERYTHING); else Help_List(HelpTitle) := TmpHelp; end if; else Help_Container.Exclude(Help_List, HelpTitle); Log_Message("Help removed: " & To_String(HelpTitle), EVERYTHING); end if; end loop Load_Help_Data; TmpHelp.Index := To_Unbounded_String("stats"); HelpTitle := To_Unbounded_String (Trim(Positive'Image(Positive(Help_List.Length) + 1), Left) & ". Attributes and skills"); TmpHelp.Text := To_Unbounded_String ("Here you will find information about all available attributes and skills in the game" & LF & LF & "{u}Attributes{/u}" & LF); for I in 1 .. Attributes_Amount loop declare Attribute: constant Attribute_Record := AttributesData_Container.Element (Container => Attributes_List, Index => I); begin Append (TmpHelp.Text, "{b}" & To_String(Attribute.Name) & "{/b}" & LF & " " & To_String(Attribute.Description) & LF & LF); end; end loop; Append(TmpHelp.Text, LF & "{u}Skills{/u}" & LF); for I in 1 .. Skills_Amount loop declare Skill: constant Skill_Record := SkillsData_Container.Element(Skills_List, I); begin Append (TmpHelp.Text, "{b}" & To_String(Skill.Name) & "{/b}" & LF & " {i}Related attribute:{/i} " & To_String (AttributesData_Container.Element (Attributes_List, Skill.Attribute) .Name) & LF); for Item of Items_List loop if Item.IType = To_Unbounded_String(To_String(Skill.Tool)) then Append (TmpHelp.Text, " {i}Training tool:{/i} " & (if Item.ShowType = Null_Unbounded_String then Item.IType else Item.ShowType) & LF); exit; end if; end loop; Append (TmpHelp.Text, " " & To_String(Skill.Description) & LF & LF); end; end loop; Help_List.Include(HelpTitle, TmpHelp); Log_Message("Help added: " & To_String(HelpTitle), EVERYTHING); end LoadHelp; end Help;
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Video.Surfaces -- -- Render surface abstraction. -------------------------------------------------------------------------------------------------------------------- with Ada.Finalization; with Interfaces.C; with System; private with SDL.C_Pointers; with SDL.RWops; with SDL.Video; with SDL.Video.Palettes; with SDL.Video.Pixel_Formats; with SDL.Video.Rectangles; package SDL.Video.Surfaces is package C renames Interfaces.C; Surface_Error : exception; -- Pixel depths. type Pixel_Depths is new Positive with Convention => C, Static_Predicate => Pixel_Depths in 1 | 2 | 4 | 8 | 12 | 15 | 16 | 24 | 32; -- For defining RGBA colour masks. type Colour_Masks is mod 2 ** 32 with Convention => C; type Internal_Surface is private; type Internal_Surface_Pointer is access Internal_Surface with Convention => C; type Surface is new Ada.Finalization.Controlled with private; Null_Surface : constant Surface; -- Operations to get hold of the various fields in the internal record. function Pixel_Format (Self : in Surface) return Pixel_Formats.Pixel_Format_Access with Inline => True; -- Get the dimensions of this surface. function Size (Self : in Surface) return SDL.Sizes with Inline => True; -- Get the pitch of this surface. function Pitch (Self : in Surface) return C.int with Inline => True; -- TODO: Make generic so that we can get access to specific arrays which are mapped onto the Pixels address. function Pixels (Self : in Surface) return System.Address with Inline => True; generic type Data is private; type Data_Pointer is access all Data; package User_Data is function Get (Self : in Surface) return Data_Pointer; procedure Set (Self : in out Surface; Data : in Data_Pointer); end User_Data; -- Other operations. -- Blit Source Surface onto Self Surface. procedure Blit (Self : in out Surface; Source : in Surface); procedure Blit (Self : in out Surface; Self_Area : in out Rectangles.Rectangle; Source : in Surface; Source_Area : in out Rectangles.Rectangle); -- Blit Source Surface onto Self Surface with scaling. procedure Blit_Scaled (Self : in out Surface; Source : in Surface); -- As above, but takes in rectangles to define the areas of blitting. Updates the Self_Area with the final area -- used to blit into. procedure Blit_Scaled (Self : in out Surface; Self_Area : in out Rectangles.Rectangle; Source : in Surface; Source_Area : in Rectangles.Rectangle := Rectangles.Null_Rectangle); -- The next two functions require that the rectangles already be clipped, if they're not, use the above. procedure Lower_Blit (Self : in out Surface; Self_Area : in Rectangles.Rectangle; Source : in Surface; Source_Area : in Rectangles.Rectangle); procedure Lower_Blit_Scaled (Self : in out Surface; Self_Area : in Rectangles.Rectangle; Source : in Surface; Source_Area : in Rectangles.Rectangle); -- TODO: SDL_ConvertPixels procedure Fill (Self : in out Surface; Area : in Rectangles.Rectangle; Colour : in Interfaces.Unsigned_32); procedure Fill (Self : in out Surface; Areas : in Rectangles.Rectangle_Arrays; Colour : in Interfaces.Unsigned_32); function Clip_Rectangle (Self : in Surface) return Rectangles.Rectangle with Inline => True; procedure Set_Clip_Rectangle (Self : in out Surface; Now : in Rectangles.Rectangle) with Inline => True; function Colour_Key (Self : in Surface) return Palettes.Colour with Inline => True; procedure Set_Colour_Key (Self : in out Surface; Now : in Palettes.Colour; Enable : in Boolean := True) with Inline => True; function Alpha_Blend (Self : in Surface) return Palettes.Colour_Component with Inline => True; procedure Set_Alpha_Blend (Self : in out Surface; Now : in Palettes.Colour_Component) with Inline => True; function Blend_Mode (Self : in Surface) return Blend_Modes with Inline => True; procedure Set_Blend_Mode (Self : in out Surface; Now : in Blend_Modes) with Inline => True; function Colour (Self : in Surface) return Palettes.RGB_Colour with Inline => True; procedure Set_Colour (Self : in out Surface; Now : in Palettes.RGB_Colour) with Inline => True; -- TODO: SDL_LoadBMP_RW -- TODO: SDL_SaveBMP -- TODO: SDL_SaveBMP_RW procedure Save_BMP (Self : in out Surface; To : in SDL.RWops.RWops; Free : in Boolean); procedure Save_BMP (Self : in out Surface; File : in String); procedure Save_PNG (Self : in out Surface; To : in SDL.RWops.RWops; Free : in Boolean); procedure Lock (Self : in out Surface) with Inline => True; procedure Unlock (Self : in out Surface) with Inline => True; function Must_Lock (Self : in Surface) return Boolean with Inline => True; -- TODO: SDL_SetSurfacePalette procedure Set_RLE (Self : in out Surface; Enabled : in Boolean) with Inline => True; overriding procedure Initialize (Self : in out Surface) renames Adjust; overriding procedure Adjust (Self : in out Surface); overriding procedure Finalize (Self : in out Surface); private type Surface_Flags is mod 2 ** 32 with Convention => C; SW_Surface : constant Surface_Flags := Surface_Flags'First; Preallocated : constant Surface_Flags := 16#0000_0001#; RLE_Encoded : constant Surface_Flags := 16#0000_0002#; Dont_Free : constant Surface_Flags := 16#0000_0004#; type Test_Address is access all C.int with Convention => C; type User_Data_Pointer is access all C.int with Convention => C; -- Internal_Surfaces are allowed to be manipulated by the user, but this is protected behind the following inlines. type Internal_Surface is record Flags : Surface_Flags; -- Internal, don't touch. Pixel_Format : Pixel_Formats.Pixel_Format_Access; Width : SDL.Dimension; Height : SDL.Dimension; Pitch : C.int; Pixels : System.Address; -- Pixel data. User_Data : User_Data_Pointer; Locked : C.int; -- Internal, don't touch. Lock_Data : System.Address; -- Internal, don't touch. Clip_Rectangle : Rectangles.Rectangle; Blit_Map : System.Address; -- Internal, don't touch. Reference_Count : C.int; end record with Convention => C; Null_Internal_Surface : constant Internal_Surface := (others => <>); -- If the Dont_Free flag is set on the Internal_Surface, then calling SDL_FreeSurface won't decrease the reference -- count. This is set when getting a window's surface. type Surface is new Ada.Finalization.Controlled with record Internal : Internal_Surface_Pointer := null; Owns : Boolean := True; -- Only if created by Surface.Makers. end record; Null_Surface : constant Surface := (Ada.Finalization.Controlled with Internal => null, Owns => True); end SDL.Video.Surfaces;
with AdaM.Context, gtk.Widget; private with gtk.Label, gtk.Frame, gtk.Box; package aIDE.Editor.of_context is type Item is new Editor.item with private; type View is access all Item'Class; package Forge is function to_context_Editor (the_Context : in AdaM.Context.view) return View; end Forge; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; overriding procedure freshen (Self : in out Item); procedure Context_is (Self : in out Item; Now : in AdaM.Context.view); private use gtk.Widget, gtk.Box, gtk.Label, gtk.Frame; type Item is new Editor.item with record Context : AdaM.Context.view; Top : Gtk_Frame; context_Label : Gtk_Label; context_lines_Box : Gtk_Box; end record; end aIDE.Editor.of_context;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.CONTAINERS.BOUNDED_SYNCHRONIZED_QUEUES -- -- -- -- B o d y -- -- -- -- Copyright (C) 2011-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ package body Ada.Containers.Bounded_Synchronized_Queues with SPARK_Mode => Off is package body Implementation is ------------- -- Dequeue -- ------------- procedure Dequeue (List : in out List_Type; Element : out Queue_Interfaces.Element_Type) is EE : Element_Array renames List.Elements; begin Element := EE (List.First); List.Length := List.Length - 1; if List.Length = 0 then List.First := 0; List.Last := 0; elsif List.First <= List.Last then List.First := List.First + 1; else List.First := List.First + 1; if List.First > List.Capacity then List.First := 1; end if; end if; end Dequeue; ------------- -- Enqueue -- ------------- procedure Enqueue (List : in out List_Type; New_Item : Queue_Interfaces.Element_Type) is begin if List.Length >= List.Capacity then raise Capacity_Error with "No capacity for insertion"; end if; if List.Length = 0 then List.Elements (1) := New_Item; List.First := 1; List.Last := 1; elsif List.First <= List.Last then if List.Last < List.Capacity then List.Elements (List.Last + 1) := New_Item; List.Last := List.Last + 1; else List.Elements (1) := New_Item; List.Last := 1; end if; else List.Elements (List.Last + 1) := New_Item; List.Last := List.Last + 1; end if; List.Length := List.Length + 1; if List.Length > List.Max_Length then List.Max_Length := List.Length; end if; end Enqueue; ------------ -- Length -- ------------ function Length (List : List_Type) return Count_Type is begin return List.Length; end Length; ---------------- -- Max_Length -- ---------------- function Max_Length (List : List_Type) return Count_Type is begin return List.Max_Length; end Max_Length; end Implementation; protected body Queue is ----------------- -- Current_Use -- ----------------- function Current_Use return Count_Type is begin return List.Length; end Current_Use; ------------- -- Dequeue -- ------------- entry Dequeue (Element : out Queue_Interfaces.Element_Type) when List.Length > 0 is begin List.Dequeue (Element); end Dequeue; ------------- -- Enqueue -- ------------- entry Enqueue (New_Item : Queue_Interfaces.Element_Type) when List.Length < Capacity is begin List.Enqueue (New_Item); end Enqueue; -------------- -- Peak_Use -- -------------- function Peak_Use return Count_Type is begin return List.Max_Length; end Peak_Use; end Queue; end Ada.Containers.Bounded_Synchronized_Queues;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- C A S I N G -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2000 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, 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. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Types; use Types; package Casing is -- This package contains data and subprograms to support the feature that -- recognizes the letter case styles used in the source program being -- compiled, and uses this information for error message formatting, and -- for recognizing reserved words that are misused as identifiers. ------------------------------- -- Case Control Declarations -- ------------------------------- -- Declaration of type for describing casing convention type Casing_Type is ( All_Upper_Case, -- All letters are upper case All_Lower_Case, -- All letters are lower case Mixed_Case, -- The initial letter, and any letters after underlines are upper case. -- All other letters are lower case Unknown -- Used if an identifier does not distinguish between the above cases, -- (e.g. X, Y_3, M4, A_B, or if it is inconsistent ABC_def). ); ------------------------------ -- Case Control Subprograms -- ------------------------------ procedure Set_Casing (C : Casing_Type; D : Casing_Type := Mixed_Case); -- Takes the name stored in the first Name_Len positions of Name_Buffer -- and modifies it to be consistent with the casing given by C, or if -- C = Unknown, then with the casing given by D. The name is basically -- treated as an identifier, except that special separator characters -- other than underline are permitted and treated like underlines (this -- handles cases like minus and period in unit names, apostrophes in error -- messages, angle brackets in names like <any_type>, etc). procedure Set_All_Upper_Case; pragma Inline (Set_All_Upper_Case); -- This procedure is called with an identifier name stored in Name_Buffer. -- On return, the identifier is converted to all upper case. The call is -- equivalent to Set_Casing (All_Upper_Case). function Determine_Casing (Ident : Text_Buffer) return Casing_Type; -- Determines the casing of the identifier/keyword string Ident end Casing;
-- CD2D13A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT A SMALL CLAUSE CAN BE GIVEN IN THE VISIBLE -- OR PRIVATE PART OF A PACKAGE FOR A FIXED POINT TYPE DECLARED -- IN THE VISIBLE PART. -- HISTORY: -- BCB 09/01/87 CREATED ORIGINAL TEST. -- PWB 05/11/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA'. WITH SYSTEM; WITH TEXT_IO; WITH REPORT; USE REPORT; PROCEDURE CD2D13A IS SPECIFIED_SMALL : CONSTANT := 2.0 ** (-4); PACKAGE P IS TYPE FIXED_IN_P IS DELTA 1.0 RANGE -4.0 .. 4.0; FOR FIXED_IN_P'SMALL USE SPECIFIED_SMALL; TYPE ALT_FIXED_IN_P IS DELTA 1.0 RANGE -4.0 .. 4.0; PRIVATE FOR ALT_FIXED_IN_P'SMALL USE SPECIFIED_SMALL; END P; USE P; BEGIN TEST("CD2D13A", "A SMALL CLAUSE CAN BE GIVEN IN THE VISIBLE " & "OR PRIVATE PART OF A PACKAGE FOR A FIXED " & "POINT TYPE DECLARED IN THE VISIBLE PART"); IF FIXED_IN_P'SMALL /= SPECIFIED_SMALL THEN FAILED ("INCORRECT VALUE FOR FIXED_IN_P'SMALL"); END IF; IF ALT_FIXED_IN_P'SMALL /= SPECIFIED_SMALL THEN FAILED ("INCORRECT VALUE FOR ALT_FIXED_IN_P'SMALL"); END IF; RESULT; END CD2D13A;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Ada.Calendar.Conversions; use Ada.Calendar.Conversions; procedure ShowEpoch is etime : Time := To_Ada_Time (0); begin Put_Line (Image (Date => etime)); end ShowEpoch;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . D W A R F _ L I N E S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2009-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Ada.Characters.Handling; with Ada.Exceptions.Traceback; use Ada.Exceptions.Traceback; with Ada.Unchecked_Deallocation; with Ada.Containers.Generic_Array_Sort; with Interfaces; use Interfaces; with System; use System; with System.Storage_Elements; use System.Storage_Elements; with System.Address_Image; with System.IO; use System.IO; with System.Object_Reader; use System.Object_Reader; with System.Traceback_Entries; use System.Traceback_Entries; with System.Mmap; use System.Mmap; with System.Bounded_Strings; use System.Bounded_Strings; package body System.Dwarf_Lines is SSU : constant := System.Storage_Unit; function String_Length (Str : Str_Access) return Natural; -- Return the length of the C string Str --------------------------------- -- DWARF Parser Implementation -- --------------------------------- procedure Read_Initial_Length (S : in out Mapped_Stream; Len : out Offset; Is64 : out Boolean); -- Read initial length as specified by Dwarf-4 7.2.2 procedure Read_Section_Offset (S : in out Mapped_Stream; Len : out Offset; Is64 : Boolean); -- Read a section offset, as specified by Dwarf-4 7.4 procedure Read_Aranges_Entry (C : in out Dwarf_Context; Start : out Storage_Offset; Len : out Storage_Count); -- Read a single .debug_aranges pair procedure Read_Aranges_Header (C : in out Dwarf_Context; Info_Offset : out Offset; Success : out Boolean); -- Read .debug_aranges header procedure Aranges_Lookup (C : in out Dwarf_Context; Addr : Storage_Offset; Info_Offset : out Offset; Success : out Boolean); -- Search for Addr in .debug_aranges and return offset Info_Offset in -- .debug_info. procedure Skip_Form (S : in out Mapped_Stream; Form : uint32; Is64 : Boolean; Ptr_Sz : uint8); -- Advance offset in S for Form. procedure Seek_Abbrev (C : in out Dwarf_Context; Abbrev_Offset : Offset; Abbrev_Num : uint32); -- Seek to abbrev Abbrev_Num (starting from Abbrev_Offset) procedure Debug_Info_Lookup (C : in out Dwarf_Context; Info_Offset : Offset; Line_Offset : out Offset; Success : out Boolean); -- Search for stmt_list tag in Info_Offset and set Line_Offset to the -- offset in .debug_lines. Only look at the first DIE, which should be -- a compilation unit. procedure Initialize_Pass (C : in out Dwarf_Context); -- Seek to the first byte of the first prologue and prepare to make a pass -- over the line number entries. procedure Initialize_State_Machine (C : in out Dwarf_Context); -- Set all state machine registers to their specified initial values procedure Parse_Prologue (C : in out Dwarf_Context); -- Decode a DWARF statement program prologue procedure Read_And_Execute_Isn (C : in out Dwarf_Context; Done : out Boolean); -- Read an execute a statement program instruction function To_File_Name (C : in out Dwarf_Context; Code : uint32) return String; -- Extract a file name from the prologue type Callback is access procedure (C : in out Dwarf_Context); procedure For_Each_Row (C : in out Dwarf_Context; F : Callback); -- Traverse each .debug_line entry with a callback procedure Dump_Row (C : in out Dwarf_Context); -- Dump a single row function "<" (Left, Right : Search_Entry) return Boolean; -- For sorting Search_Entry procedure Sort_Search_Array is new Ada.Containers.Generic_Array_Sort (Index_Type => Natural, Element_Type => Search_Entry, Array_Type => Search_Array); procedure Symbolic_Address (C : in out Dwarf_Context; Addr : Storage_Offset; Dir_Name : out Str_Access; File_Name : out Str_Access; Subprg_Name : out String_Ptr_Len; Line_Num : out Natural); -- Symbolize one address ----------------------- -- DWARF constants -- ----------------------- -- 6.2.5.2 Standard Opcodes DW_LNS_copy : constant := 1; DW_LNS_advance_pc : constant := 2; DW_LNS_advance_line : constant := 3; DW_LNS_set_file : constant := 4; DW_LNS_set_column : constant := 5; DW_LNS_negate_stmt : constant := 6; DW_LNS_set_basic_block : constant := 7; DW_LNS_const_add_pc : constant := 8; DW_LNS_fixed_advance_pc : constant := 9; DW_LNS_set_prologue_end : constant := 10; DW_LNS_set_epilogue_begin : constant := 11; DW_LNS_set_isa : constant := 12; -- 6.2.5.3 Extended Opcodes DW_LNE_end_sequence : constant := 1; DW_LNE_set_address : constant := 2; DW_LNE_define_file : constant := 3; -- From the DWARF version 4 public review draft DW_LNE_set_discriminator : constant := 4; -- Attribute encodings DW_TAG_Compile_Unit : constant := 16#11#; DW_AT_Stmt_List : constant := 16#10#; DW_FORM_addr : constant := 16#01#; DW_FORM_block2 : constant := 16#03#; DW_FORM_block4 : constant := 16#04#; DW_FORM_data2 : constant := 16#05#; DW_FORM_data4 : constant := 16#06#; DW_FORM_data8 : constant := 16#07#; DW_FORM_string : constant := 16#08#; DW_FORM_block : constant := 16#09#; DW_FORM_block1 : constant := 16#0a#; DW_FORM_data1 : constant := 16#0b#; DW_FORM_flag : constant := 16#0c#; DW_FORM_sdata : constant := 16#0d#; DW_FORM_strp : constant := 16#0e#; DW_FORM_udata : constant := 16#0f#; DW_FORM_ref_addr : constant := 16#10#; DW_FORM_ref1 : constant := 16#11#; DW_FORM_ref2 : constant := 16#12#; DW_FORM_ref4 : constant := 16#13#; DW_FORM_ref8 : constant := 16#14#; DW_FORM_ref_udata : constant := 16#15#; DW_FORM_indirect : constant := 16#16#; DW_FORM_sec_offset : constant := 16#17#; DW_FORM_exprloc : constant := 16#18#; DW_FORM_flag_present : constant := 16#19#; DW_FORM_ref_sig8 : constant := 16#20#; --------- -- "<" -- --------- function "<" (Left, Right : Search_Entry) return Boolean is begin return Left.First < Right.First; end "<"; ----------- -- Close -- ----------- procedure Close (C : in out Dwarf_Context) is procedure Unchecked_Deallocation is new Ada.Unchecked_Deallocation (Object_File, Object_File_Access); procedure Unchecked_Deallocation is new Ada.Unchecked_Deallocation (Search_Array, Search_Array_Access); begin if C.Has_Debug then Close (C.Lines); Close (C.Abbrev); Close (C.Info); Close (C.Aranges); end if; Close (C.Obj.all); Unchecked_Deallocation (C.Obj); Unchecked_Deallocation (C.Cache); end Close; ---------- -- Dump -- ---------- procedure Dump (C : in out Dwarf_Context) is begin For_Each_Row (C, Dump_Row'Access); end Dump; -------------- -- Dump_Row -- -------------- procedure Dump_Row (C : in out Dwarf_Context) is PC : constant Integer_Address := Integer_Address (C.Registers.Address); Off : Offset; begin Tell (C.Lines, Off); Put (System.Address_Image (To_Address (PC))); Put (" "); Put (To_File_Name (C, C.Registers.File)); Put (":"); declare Image : constant String := uint32'Image (C.Registers.Line); begin Put_Line (Image (2 .. Image'Last)); end; Seek (C.Lines, Off); end Dump_Row; procedure Dump_Cache (C : Dwarf_Context) is Cache : constant Search_Array_Access := C.Cache; S : Object_Symbol; Name : String_Ptr_Len; begin if Cache = null then Put_Line ("No cache"); return; end if; for I in Cache'Range loop declare E : Search_Entry renames Cache (I); Base_Address : constant System.Address := To_Address (Integer_Address (C.Low + Storage_Count (E.First))); begin Put (System.Address_Image (Base_Address)); Put (" - "); Put (System.Address_Image (Base_Address + Storage_Count (E.Size))); Put (" l@"); Put (System.Address_Image (To_Address (Integer_Address (E.Line)))); Put (": "); S := Read_Symbol (C.Obj.all, Offset (E.Sym)); Name := Object_Reader.Name (C.Obj.all, S); Put (String (Name.Ptr (1 .. Name.Len))); New_Line; end; end loop; end Dump_Cache; ------------------ -- For_Each_Row -- ------------------ procedure For_Each_Row (C : in out Dwarf_Context; F : Callback) is Done : Boolean; begin Initialize_Pass (C); loop Read_And_Execute_Isn (C, Done); if C.Registers.Is_Row then F.all (C); end if; exit when Done; end loop; end For_Each_Row; --------------------- -- Initialize_Pass -- --------------------- procedure Initialize_Pass (C : in out Dwarf_Context) is begin Seek (C.Lines, 0); C.Next_Prologue := 0; Initialize_State_Machine (C); end Initialize_Pass; ------------------------------ -- Initialize_State_Machine -- ------------------------------ procedure Initialize_State_Machine (C : in out Dwarf_Context) is begin C.Registers := (Address => 0, File => 1, Line => 1, Column => 0, Is_Stmt => C.Prologue.Default_Is_Stmt = 0, Basic_Block => False, End_Sequence => False, Prologue_End => False, Epilogue_Begin => False, ISA => 0, Is_Row => False); end Initialize_State_Machine; --------------- -- Is_Inside -- --------------- function Is_Inside (C : Dwarf_Context; Addr : Address) return Boolean is begin return (Addr >= C.Low + C.Load_Address and then Addr <= C.High + C.Load_Address); end Is_Inside; ----------------- -- Low_Address -- ----------------- function Low_Address (C : Dwarf_Context) return System.Address is begin return C.Load_Address + C.Low; end Low_Address; ---------- -- Open -- ---------- procedure Open (File_Name : String; C : out Dwarf_Context; Success : out Boolean) is Line_Sec, Info_Sec, Abbrev_Sec, Aranges_Sec : Object_Section; Hi, Lo : uint64; begin -- Not a success by default Success := False; -- Open file C.Obj := Open (File_Name, C.In_Exception); if C.Obj = null then return; end if; Success := True; -- Get memory bounds for executable code. Note that such code -- might come from multiple sections. Get_Xcode_Bounds (C.Obj.all, Lo, Hi); C.Low := Storage_Offset (Lo); C.High := Storage_Offset (Hi); -- Create a stream for debug sections if Format (C.Obj.all) = XCOFF32 then Line_Sec := Get_Section (C.Obj.all, ".dwline"); Abbrev_Sec := Get_Section (C.Obj.all, ".dwabrev"); Info_Sec := Get_Section (C.Obj.all, ".dwinfo"); Aranges_Sec := Get_Section (C.Obj.all, ".dwarnge"); else Line_Sec := Get_Section (C.Obj.all, ".debug_line"); Abbrev_Sec := Get_Section (C.Obj.all, ".debug_abbrev"); Info_Sec := Get_Section (C.Obj.all, ".debug_info"); Aranges_Sec := Get_Section (C.Obj.all, ".debug_aranges"); end if; if Line_Sec = Null_Section or else Abbrev_Sec = Null_Section or else Info_Sec = Null_Section or else Aranges_Sec = Null_Section then pragma Annotate (CodePeer, False_Positive, "test always true", "codepeer got confused"); C.Has_Debug := False; return; end if; C.Lines := Create_Stream (C.Obj.all, Line_Sec); C.Abbrev := Create_Stream (C.Obj.all, Abbrev_Sec); C.Info := Create_Stream (C.Obj.all, Info_Sec); C.Aranges := Create_Stream (C.Obj.all, Aranges_Sec); -- All operations are successful, context is valid C.Has_Debug := True; end Open; -------------------- -- Parse_Prologue -- -------------------- procedure Parse_Prologue (C : in out Dwarf_Context) is Char : uint8; Prev : uint8; -- The most recently read character and the one preceding it Dummy : uint32; -- Destination for reads we don't care about Buf : Buffer; Off : Offset; First_Byte_Of_Prologue : Offset; Last_Byte_Of_Prologue : Offset; Max_Op_Per_Insn : uint8; pragma Unreferenced (Max_Op_Per_Insn); Prologue : Line_Info_Prologue renames C.Prologue; begin Tell (C.Lines, First_Byte_Of_Prologue); Prologue.Unit_Length := Read (C.Lines); Tell (C.Lines, Off); C.Next_Prologue := Off + Offset (Prologue.Unit_Length); Prologue.Version := Read (C.Lines); Prologue.Prologue_Length := Read (C.Lines); Tell (C.Lines, Last_Byte_Of_Prologue); Last_Byte_Of_Prologue := Last_Byte_Of_Prologue + Offset (Prologue.Prologue_Length) - 1; Prologue.Min_Isn_Length := Read (C.Lines); if Prologue.Version >= 4 then Max_Op_Per_Insn := Read (C.Lines); end if; Prologue.Default_Is_Stmt := Read (C.Lines); Prologue.Line_Base := Read (C.Lines); Prologue.Line_Range := Read (C.Lines); Prologue.Opcode_Base := Read (C.Lines); -- Opcode_Lengths is an array of Opcode_Base bytes specifying the number -- of LEB128 operands for each of the standard opcodes. for J in 1 .. uint32 (Prologue.Opcode_Base - 1) loop Prologue.Opcode_Lengths (J) := Read (C.Lines); end loop; -- The include directories table follows. This is a list of null -- terminated strings terminated by a double null. We only store -- its offset for later decoding. Tell (C.Lines, Prologue.Includes_Offset); Char := Read (C.Lines); if Char /= 0 then loop Prev := Char; Char := Read (C.Lines); exit when Char = 0 and Prev = 0; end loop; end if; -- The file_names table is next. Each record is a null terminated string -- for the file name, an unsigned LEB128 directory index, an unsigned -- LEB128 modification time, and an LEB128 file length. The table is -- terminated by a null byte. Tell (C.Lines, Prologue.File_Names_Offset); loop -- Read the filename Read_C_String (C.Lines, Buf); exit when Buf (0) = 0; Dummy := Read_LEB128 (C.Lines); -- Skip the directory index. Dummy := Read_LEB128 (C.Lines); -- Skip the modification time. Dummy := Read_LEB128 (C.Lines); -- Skip the file length. end loop; -- Check we're where we think we are. This sanity check ensures we think -- the prologue ends where the prologue says it does. It we aren't then -- we've probably gotten out of sync somewhere. Tell (C.Lines, Off); if Prologue.Unit_Length /= 0 and then Off /= Last_Byte_Of_Prologue + 1 then raise Dwarf_Error with "Parse error reading DWARF information"; end if; end Parse_Prologue; -------------------------- -- Read_And_Execute_Isn -- -------------------------- procedure Read_And_Execute_Isn (C : in out Dwarf_Context; Done : out Boolean) is Opcode : uint8; Extended_Opcode : uint8; uint32_Operand : uint32; int32_Operand : int32; uint16_Operand : uint16; Off : Offset; Extended_Length : uint32; pragma Unreferenced (Extended_Length); Obj : Object_File renames C.Obj.all; Registers : Line_Info_Registers renames C.Registers; Prologue : Line_Info_Prologue renames C.Prologue; begin Done := False; Registers.Is_Row := False; if Registers.End_Sequence then Initialize_State_Machine (C); end if; -- If we have reached the next prologue, read it. Beware of possibly -- empty blocks. -- When testing for the end of section, beware of possible zero padding -- at the end. Bail out as soon as there's not even room for at least a -- DW_LNE_end_sequence, 3 bytes from Off to Off+2. This resolves to -- Off+2 > Last_Offset_Within_Section, that is Off+2 > Section_Length-1, -- or Off+3 > Section_Length. Tell (C.Lines, Off); while Off = C.Next_Prologue loop Initialize_State_Machine (C); Parse_Prologue (C); Tell (C.Lines, Off); exit when Off + 3 > Length (C.Lines); end loop; -- Test whether we're done Tell (C.Lines, Off); -- We are finished when we either reach the end of the section, or we -- have reached zero padding at the end of the section. if Prologue.Unit_Length = 0 or else Off + 3 > Length (C.Lines) then Done := True; return; end if; -- Read and interpret an instruction Opcode := Read (C.Lines); -- Extended opcodes if Opcode = 0 then Extended_Length := Read_LEB128 (C.Lines); Extended_Opcode := Read (C.Lines); case Extended_Opcode is when DW_LNE_end_sequence => -- Mark the end of a sequence of source locations Registers.End_Sequence := True; Registers.Is_Row := True; when DW_LNE_set_address => -- Set the program counter to a word Registers.Address := Read_Address (Obj, C.Lines); when DW_LNE_define_file => -- Not implemented raise Dwarf_Error with "DWARF operator not implemented"; when DW_LNE_set_discriminator => -- Ignored int32_Operand := Read_LEB128 (C.Lines); when others => -- Fail on an unrecognized opcode raise Dwarf_Error with "DWARF operator not implemented"; end case; -- Standard opcodes elsif Opcode < Prologue.Opcode_Base then case Opcode is -- Append a row to the line info matrix when DW_LNS_copy => Registers.Basic_Block := False; Registers.Is_Row := True; -- Add an unsigned word to the program counter when DW_LNS_advance_pc => uint32_Operand := Read_LEB128 (C.Lines); Registers.Address := Registers.Address + uint64 (uint32_Operand * uint32 (Prologue.Min_Isn_Length)); -- Add a signed word to the current source line when DW_LNS_advance_line => int32_Operand := Read_LEB128 (C.Lines); Registers.Line := uint32 (int32 (Registers.Line) + int32_Operand); -- Set the current source file when DW_LNS_set_file => uint32_Operand := Read_LEB128 (C.Lines); Registers.File := uint32_Operand; -- Set the current source column when DW_LNS_set_column => uint32_Operand := Read_LEB128 (C.Lines); Registers.Column := uint32_Operand; -- Toggle the "is statement" flag. GCC doesn't seem to set this??? when DW_LNS_negate_stmt => Registers.Is_Stmt := not Registers.Is_Stmt; -- Mark the beginning of a basic block when DW_LNS_set_basic_block => Registers.Basic_Block := True; -- Advance the program counter as by the special opcode 255 when DW_LNS_const_add_pc => Registers.Address := Registers.Address + uint64 (((255 - Prologue.Opcode_Base) / Prologue.Line_Range) * Prologue.Min_Isn_Length); -- Advance the program counter by a constant when DW_LNS_fixed_advance_pc => uint16_Operand := Read (C.Lines); Registers.Address := Registers.Address + uint64 (uint16_Operand); -- The following are not implemented and ignored when DW_LNS_set_prologue_end => null; when DW_LNS_set_epilogue_begin => null; when DW_LNS_set_isa => null; -- Anything else is an error when others => raise Dwarf_Error with "DWARF operator not implemented"; end case; -- Decode a special opcode. This is a line and address increment encoded -- in a single byte 'special opcode' as described in 6.2.5.1. else declare Address_Increment : int32; Line_Increment : int32; begin Opcode := Opcode - Prologue.Opcode_Base; -- The adjusted opcode is a uint8 encoding an address increment -- and a signed line increment. The upperbound is allowed to be -- greater than int8'last so we decode using int32 directly to -- prevent overflows. Address_Increment := int32 (Opcode / Prologue.Line_Range) * int32 (Prologue.Min_Isn_Length); Line_Increment := int32 (Prologue.Line_Base) + int32 (Opcode mod Prologue.Line_Range); Registers.Address := Registers.Address + uint64 (Address_Increment); Registers.Line := uint32 (int32 (Registers.Line) + Line_Increment); Registers.Basic_Block := False; Registers.Prologue_End := False; Registers.Epilogue_Begin := False; Registers.Is_Row := True; end; end if; exception when Dwarf_Error => -- In case of errors during parse, just stop reading Registers.Is_Row := False; Done := True; end Read_And_Execute_Isn; ---------------------- -- Set_Load_Address -- ---------------------- procedure Set_Load_Address (C : in out Dwarf_Context; Addr : Address) is begin C.Load_Address := Addr; end Set_Load_Address; ------------------ -- To_File_Name -- ------------------ function To_File_Name (C : in out Dwarf_Context; Code : uint32) return String is Buf : Buffer; J : uint32; Dir_Idx : uint32; pragma Unreferenced (Dir_Idx); Mod_Time : uint32; pragma Unreferenced (Mod_Time); Length : uint32; pragma Unreferenced (Length); begin Seek (C.Lines, C.Prologue.File_Names_Offset); -- Find the entry J := 0; loop J := J + 1; Read_C_String (C.Lines, Buf); if Buf (Buf'First) = 0 then return "???"; end if; Dir_Idx := Read_LEB128 (C.Lines); Mod_Time := Read_LEB128 (C.Lines); Length := Read_LEB128 (C.Lines); exit when J = Code; end loop; return To_String (Buf); end To_File_Name; ------------------------- -- Read_Initial_Length -- ------------------------- procedure Read_Initial_Length (S : in out Mapped_Stream; Len : out Offset; Is64 : out Boolean) is Len32 : uint32; Len64 : uint64; begin Len32 := Read (S); if Len32 < 16#ffff_fff0# then Is64 := False; Len := Offset (Len32); elsif Len32 < 16#ffff_ffff# then -- Invalid length raise Constraint_Error; else Is64 := True; Len64 := Read (S); Len := Offset (Len64); end if; end Read_Initial_Length; ------------------------- -- Read_Section_Offset -- ------------------------- procedure Read_Section_Offset (S : in out Mapped_Stream; Len : out Offset; Is64 : Boolean) is begin if Is64 then Len := Offset (uint64'(Read (S))); else Len := Offset (uint32'(Read (S))); end if; end Read_Section_Offset; -------------------- -- Aranges_Lookup -- -------------------- procedure Aranges_Lookup (C : in out Dwarf_Context; Addr : Storage_Offset; Info_Offset : out Offset; Success : out Boolean) is begin Info_Offset := 0; Seek (C.Aranges, 0); while Tell (C.Aranges) < Length (C.Aranges) loop Read_Aranges_Header (C, Info_Offset, Success); exit when not Success; loop declare Start : Storage_Offset; Len : Storage_Count; begin Read_Aranges_Entry (C, Start, Len); exit when Start = 0 and Len = 0; if Addr >= Start and then Addr < Start + Len then Success := True; return; end if; end; end loop; end loop; Success := False; end Aranges_Lookup; --------------- -- Skip_Form -- --------------- procedure Skip_Form (S : in out Mapped_Stream; Form : uint32; Is64 : Boolean; Ptr_Sz : uint8) is Skip : Offset; begin case Form is when DW_FORM_addr => Skip := Offset (Ptr_Sz); when DW_FORM_block2 => Skip := Offset (uint16'(Read (S))); when DW_FORM_block4 => Skip := Offset (uint32'(Read (S))); when DW_FORM_data2 | DW_FORM_ref2 => Skip := 2; when DW_FORM_data4 | DW_FORM_ref4 => Skip := 4; when DW_FORM_data8 | DW_FORM_ref8 | DW_FORM_ref_sig8 => Skip := 8; when DW_FORM_string => while uint8'(Read (S)) /= 0 loop null; end loop; return; when DW_FORM_block | DW_FORM_exprloc => Skip := Offset (uint32'(Read_LEB128 (S))); when DW_FORM_block1 | DW_FORM_ref1 => Skip := Offset (uint8'(Read (S))); when DW_FORM_data1 | DW_FORM_flag => Skip := 1; when DW_FORM_sdata => declare Val : constant int32 := Read_LEB128 (S); pragma Unreferenced (Val); begin return; end; when DW_FORM_strp | DW_FORM_ref_addr | DW_FORM_sec_offset => Skip := (if Is64 then 8 else 4); when DW_FORM_udata | DW_FORM_ref_udata => declare Val : constant uint32 := Read_LEB128 (S); pragma Unreferenced (Val); begin return; end; when DW_FORM_flag_present => return; when DW_FORM_indirect => raise Constraint_Error; when others => raise Constraint_Error; end case; Seek (S, Tell (S) + Skip); end Skip_Form; ----------------- -- Seek_Abbrev -- ----------------- procedure Seek_Abbrev (C : in out Dwarf_Context; Abbrev_Offset : Offset; Abbrev_Num : uint32) is Num : uint32; Abbrev : uint32; Tag : uint32; Has_Child : uint8; pragma Unreferenced (Abbrev, Tag, Has_Child); begin Seek (C.Abbrev, Abbrev_Offset); Num := 1; loop exit when Num = Abbrev_Num; Abbrev := Read_LEB128 (C.Abbrev); Tag := Read_LEB128 (C.Abbrev); Has_Child := Read (C.Abbrev); loop declare Name : constant uint32 := Read_LEB128 (C.Abbrev); Form : constant uint32 := Read_LEB128 (C.Abbrev); begin exit when Name = 0 and Form = 0; end; end loop; Num := Num + 1; end loop; end Seek_Abbrev; ----------------------- -- Debug_Info_Lookup -- ----------------------- procedure Debug_Info_Lookup (C : in out Dwarf_Context; Info_Offset : Offset; Line_Offset : out Offset; Success : out Boolean) is Unit_Length : Offset; Is64 : Boolean; Version : uint16; Abbrev_Offset : Offset; Addr_Sz : uint8; Abbrev : uint32; Has_Child : uint8; pragma Unreferenced (Has_Child); begin Line_Offset := 0; Success := False; Seek (C.Info, Info_Offset); Read_Initial_Length (C.Info, Unit_Length, Is64); Version := Read (C.Info); if Version not in 2 .. 4 then return; end if; Read_Section_Offset (C.Info, Abbrev_Offset, Is64); Addr_Sz := Read (C.Info); if Addr_Sz /= (Address'Size / SSU) then return; end if; -- Read DIEs loop Abbrev := Read_LEB128 (C.Info); exit when Abbrev /= 0; end loop; -- Read abbrev table Seek_Abbrev (C, Abbrev_Offset, Abbrev); -- First ULEB128 is the abbrev code if Read_LEB128 (C.Abbrev) /= Abbrev then -- Ill formed abbrev table return; end if; -- Then the tag if Read_LEB128 (C.Abbrev) /= uint32'(DW_TAG_Compile_Unit) then -- Expect compile unit return; end if; -- Then the has child flag Has_Child := Read (C.Abbrev); loop declare Name : constant uint32 := Read_LEB128 (C.Abbrev); Form : constant uint32 := Read_LEB128 (C.Abbrev); begin exit when Name = 0 and Form = 0; if Name = DW_AT_Stmt_List then case Form is when DW_FORM_sec_offset => Read_Section_Offset (C.Info, Line_Offset, Is64); when DW_FORM_data4 => Line_Offset := Offset (uint32'(Read (C.Info))); when DW_FORM_data8 => Line_Offset := Offset (uint64'(Read (C.Info))); when others => -- Unhandled form return; end case; Success := True; return; else Skip_Form (C.Info, Form, Is64, Addr_Sz); end if; end; end loop; return; end Debug_Info_Lookup; ------------------------- -- Read_Aranges_Header -- ------------------------- procedure Read_Aranges_Header (C : in out Dwarf_Context; Info_Offset : out Offset; Success : out Boolean) is Unit_Length : Offset; Is64 : Boolean; Version : uint16; Sz : uint8; begin Success := False; Info_Offset := 0; Read_Initial_Length (C.Aranges, Unit_Length, Is64); Version := Read (C.Aranges); if Version /= 2 then return; end if; Read_Section_Offset (C.Aranges, Info_Offset, Is64); -- Read address_size (ubyte) Sz := Read (C.Aranges); if Sz /= (Address'Size / SSU) then return; end if; -- Read segment_size (ubyte) Sz := Read (C.Aranges); if Sz /= 0 then return; end if; -- Handle alignment on twice the address size declare Cur_Off : constant Offset := Tell (C.Aranges); Align : constant Offset := 2 * Address'Size / SSU; Space : constant Offset := Cur_Off mod Align; begin if Space /= 0 then Seek (C.Aranges, Cur_Off + Align - Space); end if; end; Success := True; end Read_Aranges_Header; ------------------------ -- Read_Aranges_Entry -- ------------------------ procedure Read_Aranges_Entry (C : in out Dwarf_Context; Start : out Storage_Offset; Len : out Storage_Count) is begin -- Read table if Address'Size = 32 then declare S, L : uint32; begin S := Read (C.Aranges); L := Read (C.Aranges); Start := Storage_Offset (S); Len := Storage_Count (L); end; elsif Address'Size = 64 then declare S, L : uint64; begin S := Read (C.Aranges); L := Read (C.Aranges); Start := Storage_Offset (S); Len := Storage_Count (L); end; else raise Constraint_Error; end if; end Read_Aranges_Entry; ------------------ -- Enable_Cache -- ------------------ procedure Enable_Cache (C : in out Dwarf_Context) is Cache : Search_Array_Access; begin -- Phase 1: count number of symbols. Phase 2: fill the cache. declare S : Object_Symbol; Val : uint64; Xcode_Low : constant uint64 := uint64 (C.Low); Xcode_High : constant uint64 := uint64 (C.High); Sz : uint32; Addr, Prev_Addr : uint32; Nbr_Symbols : Natural; begin for Phase in 1 .. 2 loop Nbr_Symbols := 0; S := First_Symbol (C.Obj.all); Prev_Addr := uint32'Last; while S /= Null_Symbol loop -- Discard symbols of length 0 or located outside of the -- execution code section outer boundaries. Sz := uint32 (Size (S)); Val := Value (S); if Sz > 0 and then Val >= Xcode_Low and then Val <= Xcode_High then Addr := uint32 (Val - Xcode_Low); -- Try to filter symbols at the same address. This is a best -- effort as they might not be consecutive. if Addr /= Prev_Addr then Nbr_Symbols := Nbr_Symbols + 1; Prev_Addr := Addr; if Phase = 2 then C.Cache (Nbr_Symbols) := (First => Addr, Size => Sz, Sym => uint32 (Off (S)), Line => 0); end if; end if; end if; S := Next_Symbol (C.Obj.all, S); end loop; if Phase = 1 then -- Allocate the cache Cache := new Search_Array (1 .. Nbr_Symbols); C.Cache := Cache; end if; end loop; pragma Assert (Nbr_Symbols = C.Cache'Last); end; -- Sort the cache. Sort_Search_Array (C.Cache.all); -- Set line offsets if not C.Has_Debug then return; end if; declare Info_Offset : Offset; Line_Offset : Offset; Success : Boolean; Ar_Start : Storage_Offset; Ar_Len : Storage_Count; Start, Len : uint32; First, Last : Natural; Mid : Natural; begin Seek (C.Aranges, 0); while Tell (C.Aranges) < Length (C.Aranges) loop Read_Aranges_Header (C, Info_Offset, Success); exit when not Success; Debug_Info_Lookup (C, Info_Offset, Line_Offset, Success); exit when not Success; -- Read table loop Read_Aranges_Entry (C, Ar_Start, Ar_Len); exit when Ar_Start = 0 and Ar_Len = 0; Len := uint32 (Ar_Len); Start := uint32 (Ar_Start - C.Low); -- Search START in the array First := Cache'First; Last := Cache'Last; Mid := First; -- In case of array with one element while First < Last loop Mid := First + (Last - First) / 2; if Start < Cache (Mid).First then Last := Mid - 1; elsif Start >= Cache (Mid).First + Cache (Mid).Size then First := Mid + 1; else exit; end if; end loop; -- Fill info. -- There can be overlapping symbols while Mid > Cache'First and then Cache (Mid - 1).First <= Start and then Cache (Mid - 1).First + Cache (Mid - 1).Size > Start loop Mid := Mid - 1; end loop; while Mid <= Cache'Last loop if Start < Cache (Mid).First + Cache (Mid).Size and then Start + Len > Cache (Mid).First then -- MID is within the bounds Cache (Mid).Line := uint32 (Line_Offset); elsif Start + Len <= Cache (Mid).First then -- Over exit; end if; Mid := Mid + 1; end loop; end loop; end loop; end; end Enable_Cache; ---------------------- -- Symbolic_Address -- ---------------------- procedure Symbolic_Address (C : in out Dwarf_Context; Addr : Storage_Offset; Dir_Name : out Str_Access; File_Name : out Str_Access; Subprg_Name : out String_Ptr_Len; Line_Num : out Natural) is procedure Set_Result (Match : Line_Info_Registers); -- Set results using match procedure Set_Result (Match : Line_Info_Registers) is Dir_Idx : uint32; J : uint32; Mod_Time : uint32; pragma Unreferenced (Mod_Time); Length : uint32; pragma Unreferenced (Length); begin Seek (C.Lines, C.Prologue.File_Names_Offset); -- Find the entry J := 0; loop J := J + 1; File_Name := Read_C_String (C.Lines); if File_Name (File_Name'First) = ASCII.NUL then -- End of file list, so incorrect entry return; end if; Dir_Idx := Read_LEB128 (C.Lines); Mod_Time := Read_LEB128 (C.Lines); Length := Read_LEB128 (C.Lines); exit when J = Match.File; end loop; if Dir_Idx = 0 then -- No directory Dir_Name := null; else Seek (C.Lines, C.Prologue.Includes_Offset); J := 0; loop J := J + 1; Dir_Name := Read_C_String (C.Lines); if Dir_Name (Dir_Name'First) = ASCII.NUL then -- End of directory list, so ill-formed table return; end if; exit when J = Dir_Idx; end loop; end if; Line_Num := Natural (Match.Line); end Set_Result; Addr_Int : constant uint64 := uint64 (Addr); Previous_Row : Line_Info_Registers; Info_Offset : Offset; Line_Offset : Offset; Success : Boolean; Done : Boolean; S : Object_Symbol; begin -- Initialize result Dir_Name := null; File_Name := null; Subprg_Name := (null, 0); Line_Num := 0; if C.Cache /= null then -- Look in the cache declare Addr_Off : constant uint32 := uint32 (Addr - C.Low); First, Last, Mid : Natural; begin First := C.Cache'First; Last := C.Cache'Last; Mid := First; while First <= Last loop Mid := First + (Last - First) / 2; if Addr_Off < C.Cache (Mid).First then Last := Mid - 1; elsif Addr_Off >= C.Cache (Mid).First + C.Cache (Mid).Size then First := Mid + 1; else exit; end if; end loop; if Addr_Off >= C.Cache (Mid).First and then Addr_Off < C.Cache (Mid).First + C.Cache (Mid).Size then Line_Offset := Offset (C.Cache (Mid).Line); S := Read_Symbol (C.Obj.all, Offset (C.Cache (Mid).Sym)); Subprg_Name := Object_Reader.Name (C.Obj.all, S); else -- Not found return; end if; end; else -- Search symbol S := First_Symbol (C.Obj.all); while S /= Null_Symbol loop if Spans (S, Addr_Int) then Subprg_Name := Object_Reader.Name (C.Obj.all, S); exit; end if; S := Next_Symbol (C.Obj.all, S); end loop; -- Search address in aranges table Aranges_Lookup (C, Addr, Info_Offset, Success); if not Success then return; end if; -- Search stmt_list in info table Debug_Info_Lookup (C, Info_Offset, Line_Offset, Success); if not Success then return; end if; end if; Seek (C.Lines, Line_Offset); C.Next_Prologue := 0; Initialize_State_Machine (C); Parse_Prologue (C); Previous_Row.Line := 0; -- Advance to the first entry loop Read_And_Execute_Isn (C, Done); if C.Registers.Is_Row then Previous_Row := C.Registers; exit; end if; exit when Done; end loop; -- Read the rest of the entries while Tell (C.Lines) < C.Next_Prologue loop Read_And_Execute_Isn (C, Done); if C.Registers.Is_Row then if not Previous_Row.End_Sequence and then Addr_Int >= Previous_Row.Address and then Addr_Int < C.Registers.Address then Set_Result (Previous_Row); return; elsif Addr_Int = C.Registers.Address then Set_Result (C.Registers); return; end if; Previous_Row := C.Registers; end if; exit when Done; end loop; end Symbolic_Address; ------------------- -- String_Length -- ------------------- function String_Length (Str : Str_Access) return Natural is begin for I in Str'Range loop if Str (I) = ASCII.NUL then return I - Str'First; end if; end loop; return Str'Last; end String_Length; ------------------------ -- Symbolic_Traceback -- ------------------------ procedure Symbolic_Traceback (Cin : Dwarf_Context; Traceback : AET.Tracebacks_Array; Suppress_Hex : Boolean; Symbol_Found : out Boolean; Res : in out System.Bounded_Strings.Bounded_String) is use Ada.Characters.Handling; C : Dwarf_Context := Cin; Addr_In_Traceback : Address; Offset_To_Lookup : Storage_Offset; Dir_Name : Str_Access; File_Name : Str_Access; Subprg_Name : String_Ptr_Len; Line_Num : Natural; Off : Natural; begin if not C.Has_Debug then Symbol_Found := False; return; else Symbol_Found := True; end if; for J in Traceback'Range loop -- If the buffer is full, no need to do any useless work exit when Is_Full (Res); Addr_In_Traceback := PC_For (Traceback (J)); Offset_To_Lookup := Addr_In_Traceback - C.Load_Address; Symbolic_Address (C, Offset_To_Lookup, Dir_Name, File_Name, Subprg_Name, Line_Num); if File_Name /= null then declare Last : constant Natural := String_Length (File_Name); Is_Ada : constant Boolean := Last > 3 and then To_Upper (String (File_Name (Last - 3 .. Last - 1))) = ".AD"; -- True if this is an Ada file. This doesn't take into account -- nonstandard file-naming conventions, but that's OK; this is -- purely cosmetic. It covers at least .ads, .adb, and .ada. Line_Image : constant String := Natural'Image (Line_Num); begin if Subprg_Name.Len /= 0 then -- For Ada code, Symbol_Image is in all lower case; we don't -- have the case from the original source code. But the best -- guess is Mixed_Case, so convert to that. if Is_Ada then declare Symbol_Image : String := Object_Reader.Decoded_Ada_Name (C.Obj.all, Subprg_Name); begin for K in Symbol_Image'Range loop if K = Symbol_Image'First or else not (Is_Letter (Symbol_Image (K - 1)) or else Is_Digit (Symbol_Image (K - 1))) then Symbol_Image (K) := To_Upper (Symbol_Image (K)); end if; end loop; Append (Res, Symbol_Image); end; else Off := Strip_Leading_Char (C.Obj.all, Subprg_Name); Append (Res, String (Subprg_Name.Ptr (Off .. Subprg_Name.Len))); end if; Append (Res, ' '); end if; Append (Res, "at "); Append (Res, String (File_Name (1 .. Last))); Append (Res, ':'); Append (Res, Line_Image (2 .. Line_Image'Last)); end; else if Suppress_Hex then Append (Res, "..."); else Append_Address (Res, Addr_In_Traceback); end if; if Subprg_Name.Len > 0 then Off := Strip_Leading_Char (C.Obj.all, Subprg_Name); Append (Res, ' '); Append (Res, String (Subprg_Name.Ptr (Off .. Subprg_Name.Len))); end if; Append (Res, " at ???"); end if; Append (Res, ASCII.LF); end loop; end Symbolic_Traceback; end System.Dwarf_Lines;
with FLTK.Images; package FLTK.Devices.Graphics is type Graphics_Driver is new Device with private; type Graphics_Driver_Reference (Data : not null access Graphics_Driver'Class) is limited null record with Implicit_Dereference => Data; function Get_Color (This : in Graphics_Driver) return Color; function Get_Text_Descent (This : in Graphics_Driver) return Integer; function Get_Line_Height (This : in Graphics_Driver) return Integer; function Get_Width (This : in Graphics_Driver; Char : in Character) return Long_Float; function Get_Width (This : in Graphics_Driver; Str : in String) return Long_Float; function Get_Font_Kind (This : in Graphics_Driver) return Font_Kind; function Get_Font_Size (This : in Graphics_Driver) return Font_Size; procedure Set_Font (This : in Graphics_Driver; Face : in Font_Kind; Size : in Font_Size); procedure Draw_Scaled_Image (This : in Graphics_Driver; Img : in FLTK.Images.Image'Class; X, Y, W, H : in Integer); private type Graphics_Driver is new Device with null record; pragma Inline (Get_Color); pragma Inline (Get_Text_Descent); pragma Inline (Get_Line_Height); pragma Inline (Get_Width); pragma Inline (Get_Font_Kind); pragma Inline (Get_Font_Size); pragma Inline (Set_Font); pragma Inline (Draw_Scaled_Image); end FLTK.Devices.Graphics;
with Ada.Unchecked_Deallocation; package body UxAS.Comms.Transport.ZeroMQ_Fabric is procedure Free is new Ada.Unchecked_Deallocation (ZMQ_Fabric, ZMQ_Fabric_Reference); -------------- -- Instance -- -------------- function Instance return not null ZMQ_Fabric_Reference is begin if The_Instance = null then The_Instance := new ZMQ_Fabric; end if; return The_Instance; end Instance; ------------- -- Destroy -- ------------- procedure Destroy is begin Free (The_Instance); end Destroy; ------------------- -- Create_Socket -- ------------------- procedure Create_Socket (This : ZMQ_Fabric_Reference; Config : ZeroMq_Socket_Configuration; Result : out Socket) is begin This.zmQContext.Set_Number_Of_IO_Threads (Config.Number_of_IO_Threads); -- std::unique_ptr<zmq::socket_t> zmqSocket = uxas::stduxas::make_unique<zmq::socket_t>(*m_zmqContext, socketConfiguration.m_zmqSocketType); ZMQ.Sockets.Initialize (Result, This.zmQContext, Config.Zmq_Socket_Type); if Config.Is_Server_Bind then Result.Bind (Address => Value (Config.Socket_Address)); else Result.Connect (Address => Value (Config.Socket_Address)); end if; -- zmqSocket->setsockopt(ZMQ_RCVHWM, &socketConfiguration.m_receiveHighWaterMark, sizeof (socketConfiguration.m_receiveHighWaterMark)); Result.Set_High_Water_Mark_For_Inbound_Messages (Integer (Config.Receive_High_Water_Mark)); -- zmqSocket->setsockopt(ZMQ_SNDHWM, &socketConfiguration.m_sendHighWaterMark, sizeof (socketConfiguration.m_sendHighWaterMark)); Result.Set_High_Water_Mark_For_Outbound_Messages (Integer (Config.Send_High_Water_Mark)); end Create_Socket; end UxAS.Comms.Transport.ZeroMQ_Fabric;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Nodes.Generic_Vectors; with Program.Elements.Aspect_Specifications; package Program.Nodes.Aspect_Specification_Vectors is new Program.Nodes.Generic_Vectors (Program.Elements.Aspect_Specifications .Aspect_Specification_Vector); pragma Preelaborate (Program.Nodes.Aspect_Specification_Vectors);
with Ada; with Interfaces.C.Char_Pointers; with Interfaces.C.Pointers; with Interfaces.C.Strings; with Interfaces.C.Wide_WStrings; procedure intf is begin -- Import declare type Unsigned_Long_Long is mod 2 ** Long_Long_Integer'Size; type P is access all Character; function strtoll (str : String; endptr : access P; base : Integer) return Long_Long_Integer with Import, Convention => C; function strtoull (str : String; endptr : access P; base : Integer) return Unsigned_Long_Long with Import, Convention => C; N : aliased Long_Long_Integer := -1; U : aliased Unsigned_Long_Long := -1; begin N := strtoll ("100" & ASCII.NUL, null, 10); pragma Assert (N = 100); U := strtoull ("100" & ASCII.NUL, null, 10); pragma Assert (U = 100); end; -- Interfaces.C declare use type Interfaces.C.size_t; use type Interfaces.C.char_array; use type Interfaces.C.wchar_array; use type Interfaces.C.char16_array; use type Interfaces.C.char32_array; begin pragma Assert (Interfaces.C.To_C (String'("")) = Interfaces.C.char_array'(0 => Interfaces.C.nul)); pragma Assert (Interfaces.C.To_Ada (Interfaces.C.char_array'(0 => Interfaces.C.nul)) = String'("")); pragma Assert (Interfaces.C.To_C (Wide_String'("")) = Interfaces.C.wchar_array'(0 => Interfaces.C.wide_nul)); pragma Assert (Interfaces.C.To_Ada (Interfaces.C.wchar_array'(0 => Interfaces.C.wide_nul)) = Wide_String'("")); pragma Assert (Interfaces.C.To_C (Wide_String'("")) = Interfaces.C.char16_array'(0 => Interfaces.C.char16_nul)); pragma Assert (Interfaces.C.To_Ada (Interfaces.C.char16_array'(0 => Interfaces.C.char16_nul)) = Wide_String'("")); pragma Assert (Interfaces.C.To_C (Wide_Wide_String'("")) = Interfaces.C.char32_array'(0 => Interfaces.C.char32_nul)); pragma Assert (Interfaces.C.To_Ada (Interfaces.C.char32_array'(0 => Interfaces.C.char32_nul)) = Wide_Wide_String'("")); -- contains nul pragma Assert (Interfaces.C.To_Ada (Interfaces.C.char_array'(0 => Interfaces.C.nul), Trim_Nul => False) = String'(1 => Character'Val (0))); -- substitute if Interfaces.C.wchar_t'Size /= Wide_Character'Size then pragma Assert (Interfaces.C.To_Wide_String (Interfaces.C.wchar_array'(16#d800#, Interfaces.C.wide_nul), Substitute => "ILSEQ") = "ILSEQ"); null; else pragma Assert (Interfaces.C.To_Wide_Wide_String (Interfaces.C.wchar_array'(16#d800#, Interfaces.C.wide_nul), Substitute => "ILSEQ") = "ILSEQ"); null; end if; end; -- Interfaces.C.Pointers declare use type Interfaces.C.ptrdiff_t; use type Interfaces.C.size_t; type A is array (Positive range <>) of aliased Integer; package Ps is new Interfaces.C.Pointers ( Positive, Integer, A, Default_Terminator => 0); AO : aliased A (1 .. 10); E1 : not null Ps.Pointer := AO (3)'Access; E2 : not null Ps.Pointer := AO (7)'Access; ZSTR : aliased Interfaces.C.char_array (0 .. 0) := (0 => Interfaces.C.nul); Empty_ZSTR : constant Interfaces.C.char_array := Interfaces.C.Char_Pointers.Value (ZSTR (0)'Access, 0); begin pragma Assert (Ps."-" (E2, E1) = 4); pragma Assert (Empty_ZSTR'First = 1 and then Empty_ZSTR'Last = 0); null; end; -- Interfaces.C.Strings declare use type Interfaces.C.char_array; C_Str : aliased Interfaces.C.char_array (1 .. 5) := "12345"; C_Sub_Str : Interfaces.C.char_array renames C_Str (3 .. 5); p : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String ("ABC"); begin pragma Assert (Interfaces.C.Strings.Value (p) = String'("ABC")); Interfaces.C.Strings.Update (p, 1, Interfaces.C.char_array'("Z")); pragma Assert (Interfaces.C.Strings.Value (p) = String'("AZC")); pragma Assert (Interfaces.C.Strings.Value (p, 1, Append_Nul => True) = ('A', Interfaces.C.nul)); Interfaces.C.Strings.Free (p); pragma Assert (Interfaces.C.Strings.Value (Interfaces.C.Strings.To_Const_Chars_Ptr (C_Sub_Str'Unrestricted_Access), 3) = String'("345")); end; -- Interfaces.C.Wide_WStrings declare use type Interfaces.C.wchar_array; C_Str : aliased Interfaces.C.wchar_array (1 .. 5) := Interfaces.C.To_C ("12345", Append_Nul => False); C_Sub_Str : Interfaces.C.wchar_array renames C_Str (3 .. 5); p : Interfaces.C.Wide_WStrings.chars_ptr := Interfaces.C.Wide_WStrings.New_String ("ABC"); begin pragma Assert (Interfaces.C.Wide_WStrings.Value (p) = Wide_String'("ABC")); Interfaces.C.Wide_WStrings.Update (p, 1, Interfaces.C.wchar_array'(0 => Interfaces.C.wchar_t'Val (Character'Pos ('Z')))); pragma Assert (Interfaces.C.Wide_WStrings.Value (p) = Wide_String'("AZC")); pragma Assert (Interfaces.C.Wide_WStrings.Value (p, 1, Append_Nul => True) = (Interfaces.C.wchar_t'Val (Character'Pos ('A')), Interfaces.C.wide_nul)); Interfaces.C.Wide_WStrings.Free (p); pragma Assert (Interfaces.C.Wide_WStrings.Value (Interfaces.C.Wide_WStrings.To_Const_Chars_Ptr (C_Sub_Str'Unrestricted_Access), 3) = Wide_String'("345")); p := Interfaces.C.Wide_WStrings.New_Strcat ( Interfaces.C.Wide_WStrings.const_chars_ptr_With_Length_array'( (C_Str (1)'Unchecked_Access, 2), (C_Str (4)'Unchecked_Access, 2))); pragma Assert (Interfaces.C.Wide_WStrings.Value (p) = "1245"); Interfaces.C.Wide_WStrings.Free (p); end; pragma Debug (Ada.Debug.Put ("OK")); end intf;
-- { dg-do run } with Init8; use Init8; with Text_IO; use Text_IO; with Dump; procedure S8 is A1 : R1 := My_R1; A2 : R2 := My_R2; N1 : Nested1; N2 : Nested2; C1 : Integer; C2 : Integer; C3 : Integer; begin Put ("A1 :"); Dump (A1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "A1 : 78 56 34 12 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } Put ("A2 :"); Dump (A2'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "A2 : 12 34 56 78 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } N1 := A1.N; C1 := N1.C1; C2 := N1.C2; C3 := N1.C3; Put_Line("C1 :" & C1'Img); -- { dg-output "C1 : 11206674.*\n" } Put_Line("C2 :" & C2'Img); -- { dg-output "C2 : 13434932.*\n" } Put_Line("C3 :" & C3'Img); -- { dg-output "C3 : 15663190.*\n" } N1.C1 := C1; N1.C2 := C2; N1.C3 := C3; A1.N := N1; N2 := A2.N; C1 := N2.C1; C2 := N2.C2; C3 := N2.C3; Put_Line("C1 :" & C1'Img); -- { dg-output "C1 : 11206674.*\n" } Put_Line("C2 :" & C2'Img); -- { dg-output "C2 : 13434932.*\n" } Put_Line("C3 :" & C3'Img); -- { dg-output "C3 : 15663190.*\n" } N2.C1 := C1; N2.C2 := C2; N2.C3 := C3; A2.N := N2; Put ("A1 :"); Dump (A1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "A1 : 78 56 34 12 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } Put ("A2 :"); Dump (A2'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "A2 : 12 34 56 78 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } end;
with STM32_SVD; use STM32_SVD; with HAL; generic with package Chip_Select is new HAL.Pin (<>); with package IRQ is new HAL.Pin (<>); with package SPI is new HAL.SPI (<>); package Drivers.CC1101 is type Raw_Register_Array is array (0 .. 16#3D#) of Byte; type Packet_Type is array (Positive range <>) of Byte; procedure Init; procedure TX_Mode; procedure RX_Mode; procedure Set_Sync_Word (Word : Unsigned_16); function Get_Sync_Word return Unsigned_16; procedure TX (Packet: Packet_Type); function Wait_For_RX return Boolean; procedure RX (Packet : out Packet_Type; Length : out Natural); function RX_Available return Boolean; procedure Clear_IRQ; procedure Power_Down; procedure Cancel; procedure Read_Registers (Registers : out Raw_Register_Array); generic with procedure Put_Line (Line: in string); procedure Print_Registers; end Drivers.CC1101;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . G L O B A L _ L O C K S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2019, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This implementation is specific to NT with System.OS_Interface; with System.Task_Lock; with System.Win32; with Interfaces.C.Strings; package body System.Global_Locks is package TSL renames System.Task_Lock; package OSI renames System.OS_Interface; package ICS renames Interfaces.C.Strings; subtype Lock_File_Entry is Win32.HANDLE; Last_Lock : Lock_Type := Null_Lock; Lock_Table : array (Lock_Type range 1 .. 15) of Lock_File_Entry; ----------------- -- Create_Lock -- ----------------- procedure Create_Lock (Lock : out Lock_Type; Name : String) is L : Lock_Type; begin TSL.Lock; Last_Lock := Last_Lock + 1; L := Last_Lock; TSL.Unlock; if L > Lock_Table'Last then raise Lock_Error; end if; Lock_Table (L) := OSI.CreateMutex (null, Win32.FALSE, ICS.New_String (Name)); Lock := L; end Create_Lock; ------------------ -- Acquire_Lock -- ------------------ procedure Acquire_Lock (Lock : in out Lock_Type) is use type Win32.DWORD; Res : Win32.DWORD; begin Res := OSI.WaitForSingleObject (Lock_Table (Lock), OSI.Wait_Infinite); if Res = OSI.WAIT_FAILED then raise Lock_Error; end if; end Acquire_Lock; ------------------ -- Release_Lock -- ------------------ procedure Release_Lock (Lock : in out Lock_Type) is use type Win32.BOOL; Res : Win32.BOOL; begin Res := OSI.ReleaseMutex (Lock_Table (Lock)); if Res = Win32.FALSE then raise Lock_Error; end if; end Release_Lock; end System.Global_Locks;
-- This spec has been automatically generated from STM32F303xE.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.CRC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype IDR_IDR_Field is STM32_SVD.Byte; -- Independent data register type IDR_Register is record -- General-purpose 8-bit data register bits IDR : IDR_IDR_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IDR_Register use record IDR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype CR_RESET_Field is STM32_SVD.Bit; subtype CR_POLYSIZE_Field is STM32_SVD.UInt2; subtype CR_REV_IN_Field is STM32_SVD.UInt2; subtype CR_REV_OUT_Field is STM32_SVD.Bit; -- Control register type CR_Register is record -- reset bit RESET : CR_RESET_Field := 16#0#; -- unspecified Reserved_1_2 : STM32_SVD.UInt2 := 16#0#; -- Polynomial size POLYSIZE : CR_POLYSIZE_Field := 16#0#; -- Reverse input data REV_IN : CR_REV_IN_Field := 16#0#; -- Reverse output data REV_OUT : CR_REV_OUT_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record RESET at 0 range 0 .. 0; Reserved_1_2 at 0 range 1 .. 2; POLYSIZE at 0 range 3 .. 4; REV_IN at 0 range 5 .. 6; REV_OUT at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- cyclic redundancy check calculation unit type CRC_Peripheral is record -- Data register DR : aliased STM32_SVD.UInt32; -- Independent data register IDR : aliased IDR_Register; -- Control register CR : aliased CR_Register; -- Initial CRC value INIT : aliased STM32_SVD.UInt32; -- CRC polynomial POL : aliased STM32_SVD.UInt32; end record with Volatile; for CRC_Peripheral use record DR at 16#0# range 0 .. 31; IDR at 16#4# range 0 .. 31; CR at 16#8# range 0 .. 31; INIT at 16#10# range 0 .. 31; POL at 16#14# range 0 .. 31; end record; -- cyclic redundancy check calculation unit CRC_Periph : aliased CRC_Peripheral with Import, Address => System'To_Address (16#40023000#); end STM32_SVD.CRC;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . C O M P L E X _ T E X T _ I O -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- Ada 2005 AI-328 with Ada.Text_IO.Complex_IO; with Ada.Numerics.Complex_Types; pragma Elaborate_All (Ada.Text_IO.Complex_IO); package Ada.Complex_Text_IO is new Ada.Text_IO.Complex_IO (Ada.Numerics.Complex_Types);
with agar.core.event; with agar.core.types; with agar.gui.widget.label; with agar.gui.widget.slider; with agar.gui.widget; with agar.gui.window; package slider_callbacks is package gui_event renames agar.core.event; package gui_label renames agar.gui.widget.label; package gui_slider renames agar.gui.widget.slider; package gui_widget renames agar.gui.widget; package gui_window renames agar.gui.window; type slider_t is record slider : gui_slider.slider_access_t; label : gui_label.label_access_t; value : aliased agar.core.types.integer_t; minimum : aliased agar.core.types.integer_t; maximum : aliased agar.core.types.integer_t; changed : gui_event.event_access_t; end record; sliders : array (1 .. 8) of slider_t; procedure init (window : gui_window.window_access_t); procedure quit (event : gui_event.event_access_t); procedure changed (event : gui_event.event_access_t); pragma convention (c, changed); pragma convention (c, quit); end slider_callbacks;
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with swig; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_is_direct_reply_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; length : aliased Interfaces.Unsigned_32; is_direct : aliased Interfaces.Unsigned_8; pad1 : aliased swig.int8_t_Array (0 .. 22); end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_is_direct_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_is_direct_reply_t.Item, Element_Array => xcb.xcb_glx_is_direct_reply_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_is_direct_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_is_direct_reply_t.Pointer, Element_Array => xcb.xcb_glx_is_direct_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_is_direct_reply_t;
-- -- Copyright (C) 2016 secunet Security Networks AG -- -- This program 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 program 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. -- package HW.GFX.EDID is use type Word8; use type Word16; subtype Raw_EDID_Index is Natural range 0 .. 127; subtype Raw_EDID_Data is Buffer (Raw_EDID_Index); function Valid (Raw_EDID : Raw_EDID_Data) return Boolean; procedure Sanitize (Raw_EDID : in out Raw_EDID_Data; Success : out Boolean) with Post => (if Success then Valid (Raw_EDID)); DESCRIPTOR_1 : constant := 54; function Read_LE16 (Raw_EDID : Raw_EDID_Data; Offset : Raw_EDID_Index) return Word16 with Pre => Offset < Raw_EDID_Index'Last; function Compatible_Display (Raw_EDID : Raw_EDID_Data; Display : Display_Type) return Boolean with Pre => Valid (Raw_EDID); function Has_Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Boolean with Pre => Valid (Raw_EDID), Post => (Has_Preferred_Mode'Result = (Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000 in Frequency_Type and ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0))); function Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Mode_Type with Pre => Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000 in Frequency_Type and ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0); end HW.GFX.EDID;
------------------------------------------------------------------------------ -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ package body Pathname_Manipulation is -------------- -- Root_Dir -- -------------- procedure Root_Dir (Path : Pathname; Start, Stop : out Integer) is begin Start := Path'First; Stop := Start; if Path'Length = 0 then return; end if; while Start <= Path'Last and then Path (Start) = '/' loop Start := Start + 1; end loop; Stop := Start; while Stop + 1 <= Path'Last and then Path (Stop + 1) /= '/' loop Stop := Stop + 1; end loop; end Root_Dir; -------------- -- Root_Dir -- -------------- function Root_Dir (Path : Pathname) return Pathname is Start, Stop : Integer; begin Root_Dir (Path, Start, Stop); if Start not in Path'Range or else Stop not in Path'Range then return ""; else return Path (Start .. Stop); end if; end Root_Dir; end Pathname_Manipulation;
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr> -- MIT license. Please refer to the LICENSE file. -- "With" the shared output sink instance access point package. with Apsepp.Output; package body Apsepp_Demo_OSASI_Instance_Client is ---------------------------------------------------------------------------- B_Count : Natural := 0; function B return String is N : constant Natural := B_Count + 1; Ret : String := Natural'Image (N) & " "; begin Ret (Ret'First) := 'B'; B_Count := N; return Ret; end B; ---------------------------------------------------------------------------- procedure Output_Sink_Client is use Apsepp.Output; -- Makes function Apsepp.Output.Output visible (access -- to the shared output sink instance). begin -- Call primitive operation of output sink instance. Output.Put_Line (B & "Hello!"); -- Displayed if current shared output sink instance is of type -- Apsepp.Output_Class.Standard.Output_Standard but not if -- it is of type Apsepp.Output_Class.Quiet.Output_Quiet. end Output_Sink_Client; ---------------------------------------------------------------------------- end Apsepp_Demo_OSASI_Instance_Client;
package Natools.Static_Maps.Web.List_Templates.Commands is pragma Pure; function Hash (S : String) return Natural; end Natools.Static_Maps.Web.List_Templates.Commands;
------------------------------------------------------------------------------ -- -- -- GNAT RUNTIME COMPONENTS -- -- -- -- S Y S T E M . W C H _ J I S -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved -- -- -- -- The GNAT library 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. The GNAT 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 -- -- the GNAT library; see the file COPYING.LIB. If not, write to the Free -- -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This package contains routines used for converting between internal -- JIS codes and the two external forms we support (EUC and Shift-JIS) package System.WCh_JIS is pragma Pure (WCh_JIS); function EUC_To_JIS (EUC1, EUC2 : Character) return Wide_Character; -- Given the two bytes of a EUC representation, return the -- corresponding JIS code wide character. Raises Constraint_Error -- if the two characters are not a valid EUC encoding. procedure JIS_To_EUC (J : in Wide_Character; EUC1 : out Character; EUC2 : out Character); -- Given a wide character in JIS form, produce the corresponding -- two bytes of the EUC representation of this character. This is -- only used if J is not in the normal ASCII range, i.e. on entry -- we know that Wide_Character'Pos (J) >= 16#0080# and that we -- thus require a two byte EUC representation (ASCII codes appear -- unchanged as a single byte in EUC). No error checking is performed, -- the input code is assumed to be in an appropriate range. procedure JIS_To_Shift_JIS (J : in Wide_Character; SJ1 : out Character; SJ2 : out Character); -- Given a wide character code in JIS form, produce the corresponding -- two bytes of the Shift-JIS representation of this character. This -- is only used if J is not in the normal ASCII range, i.e. on entry -- we know that Wide_Character'Pos (J) >= 16#0080# and that we -- thus require a two byte EUC representation (ASCII codes appear -- unchanged as a single byte in EUC). No error checking is performed, -- the input code is assumed to be in an appropriate range (note in -- particular that input codes in the range 16#0080#-16#00FF#, i.e. -- Hankaku Kana, do not appear, since Shift JIS has no representation -- for such codes. function Shift_JIS_To_JIS (SJ1, SJ2 : Character) return Wide_Character; -- Given the two bytes of a Shift-JIS representation, return the -- corresponding JIS code wide character. Raises Constraint_Error if -- the two characters are not a valid shift-JIS encoding. end System.WCh_JIS;
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Text_IO.Aux -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1996 -- Version Control: -- $Revision: 1.7 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ package body Terminal_Interface.Curses.Text_IO.Aux is procedure Put_Buf (Win : in Window; Buf : in String; Width : in Field; Signal : in Boolean := True; Ljust : in Boolean := False) is L : Field; Len : Field; W : Field := Width; LC : Line_Count; CC : Column_Count; Y : Line_Position; X : Column_Position; procedure Output (From, To : Field); procedure Output (From, To : Field) is begin if Len > 0 then if W = 0 then W := Len; end if; if Len > W then -- LRM A10.6 (7) says this W := Len; end if; pragma Assert (Len <= W); Get_Size (Win, LC, CC); if Column_Count (Len) > CC then if Signal then raise Layout_Error; else return; end if; else if Len < W and then not Ljust then declare Filler : constant String (1 .. (W - Len)) := (others => ' '); begin Put (Win, Filler); end; end if; Get_Cursor_Position (Win, Y, X); if (X + Column_Position (Len)) > CC then New_Line (Win); end if; Put (Win, Buf (From .. To)); if Len < W and then Ljust then declare Filler : constant String (1 .. (W - Len)) := (others => ' '); begin Put (Win, Filler); end; end if; end if; end if; end Output; begin pragma Assert (Win /= Null_Window); if Ljust then L := 1; for I in 1 .. Buf'Length loop exit when Buf (L) = ' '; L := L + 1; end loop; Len := L - 1; Output (1, Len); else -- input buffer is not left justified L := Buf'Length; for I in 1 .. Buf'Length loop exit when Buf (L) = ' '; L := L - 1; end loop; Len := Buf'Length - L; Output (L + 1, Buf'Length); end if; end Put_Buf; end Terminal_Interface.Curses.Text_IO.Aux;
-- This package is intended to set up and tear down the test environment. -- Once created by GNATtest, this package will never be overwritten -- automatically. Contents of this package can be modified in any way -- except for sections surrounded by a 'read only' marker. package body Bases.Test_Data.Tests.Recruit_Container.Test_Data is procedure Set_Up(Gnattest_T: in out Test) is pragma Unreferenced(Gnattest_T); begin null; end Set_Up; procedure Tear_Down(Gnattest_T: in out Test) is pragma Unreferenced(Gnattest_T); begin null; end Tear_Down; procedure User_Set_Up(Gnattest_T: in out New_Test) is pragma Unreferenced(Gnattest_T); begin null; end User_Set_Up; procedure User_Tear_Down(Gnattest_T: in out New_Test) is pragma Unreferenced(Gnattest_T); begin null; end User_Tear_Down; end Bases.Test_Data.Tests.Recruit_Container.Test_Data;
----------------------------------------------------------------------- -- hyperion -- Hyperion Monitoring Server -- Copyright (C) 2017 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. ----------------------------------------------------------------------- package Hyperion is end Hyperion;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 1 1 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Exp_Ch7; use Exp_Ch7; with Exp_Intr; use Exp_Intr; with Exp_Util; use Exp_Util; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Restrict; use Restrict; with Rident; use Rident; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Ch8; use Sem_Ch8; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Sinput; use Sinput; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; with Targparm; use Targparm; with Tbuild; use Tbuild; with Uintp; use Uintp; package body Exp_Ch11 is ----------------------- -- Local Subprograms -- ----------------------- procedure Warn_No_Exception_Propagation_Active (N : Node_Id); -- Generates warning that pragma Restrictions (No_Exception_Propagation) -- is in effect. Caller then generates appropriate continuation message. -- N is the node on which the warning is placed. procedure Warn_If_No_Propagation (N : Node_Id); -- Called for an exception raise that is not a local raise (and thus cannot -- be optimized to a goto). Issues warning if No_Exception_Propagation -- restriction is set. N is the node for the raise or equivalent call. --------------------------- -- Expand_At_End_Handler -- --------------------------- -- For a handled statement sequence that has a cleanup (At_End_Proc -- field set), an exception handler of the following form is required: -- exception -- when all others => -- cleanup call -- raise; -- Note: this exception handler is treated rather specially by -- subsequent expansion in two respects: -- The normal call to Undefer_Abort is omitted -- The raise call does not do Defer_Abort -- This is because the current tasking code seems to assume that -- the call to the cleanup routine that is made from an exception -- handler for the abort signal is called with aborts deferred. -- This expansion is only done if we have front end exception handling. -- If we have back end exception handling, then the AT END handler is -- left alone, and cleanups (including the exceptional case) are handled -- by the back end. -- In the front end case, the exception handler described above handles -- the exceptional case. The AT END handler is left in the generated tree -- and the code generator (e.g. gigi) must still handle proper generation -- of cleanup calls for the non-exceptional case. procedure Expand_At_End_Handler (HSS : Node_Id; Blk_Id : Entity_Id) is Clean : constant Entity_Id := Entity (At_End_Proc (HSS)); Ohandle : Node_Id; Stmnts : List_Id; Loc : constant Source_Ptr := No_Location; -- Location used for expansion. We quite deliberately do not set a -- specific source location for the expanded handler. This makes -- sense since really the handler is not associated with specific -- source. We used to set this to Sloc (Clean), but that caused -- useless and annoying bouncing around of line numbers in the -- debugger in some circumstances. begin pragma Assert (Present (Clean)); pragma Assert (No (Exception_Handlers (HSS))); -- Back end exception schemes don't need explicit handlers to -- trigger AT-END actions on exceptional paths. if Back_End_Exceptions then return; end if; -- Don't expand an At End handler if we have already had configurable -- run-time violations, since likely this will just be a matter of -- generating useless cascaded messages if Configurable_Run_Time_Violations > 0 then return; end if; -- Don't expand an At End handler if we are not allowing exceptions -- or if exceptions are transformed into local gotos, and never -- propagated (No_Exception_Propagation). if No_Exception_Handlers_Set then return; end if; if Present (Blk_Id) then Push_Scope (Blk_Id); end if; Ohandle := Make_Others_Choice (Loc); Set_All_Others (Ohandle); Stmnts := New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Clean, Loc))); -- Generate reraise statement as last statement of AT-END handler, -- unless we are under control of No_Exception_Propagation, in which -- case no exception propagation is possible anyway, so we do not need -- a reraise (the AT END handler in this case is only for normal exits -- not for exceptional exits). Also, we flag the Reraise statement as -- being part of an AT END handler to prevent signalling this reraise -- as a violation of the restriction when it is not set. if not Restriction_Active (No_Exception_Propagation) then declare Rstm : constant Node_Id := Make_Raise_Statement (Loc); begin Set_From_At_End (Rstm); Append_To (Stmnts, Rstm); end; end if; Set_Exception_Handlers (HSS, New_List ( Make_Implicit_Exception_Handler (Loc, Exception_Choices => New_List (Ohandle), Statements => Stmnts))); Analyze_List (Stmnts, Suppress => All_Checks); Expand_Exception_Handlers (HSS); if Present (Blk_Id) then Pop_Scope; end if; end Expand_At_End_Handler; ------------------------------- -- Expand_Exception_Handlers -- ------------------------------- procedure Expand_Exception_Handlers (HSS : Node_Id) is Handlrs : constant List_Id := Exception_Handlers (HSS); Loc : constant Source_Ptr := Sloc (HSS); Handler : Node_Id; Others_Choice : Boolean; Obj_Decl : Node_Id; Next_Handler : Node_Id; procedure Expand_Local_Exception_Handlers; -- This procedure handles the expansion of exception handlers for the -- optimization of local raise statements into goto statements. procedure Prepend_Call_To_Handler (Proc : RE_Id; Args : List_Id := No_List); -- Routine to prepend a call to the procedure referenced by Proc at -- the start of the handler code for the current Handler. procedure Replace_Raise_By_Goto (Raise_S : Node_Id; Goto_L1 : Node_Id); -- Raise_S is a raise statement (possibly expanded, and possibly of the -- form of a Raise_xxx_Error node with a condition. This procedure is -- called to replace the raise action with the (already analyzed) goto -- statement passed as Goto_L1. This procedure also takes care of the -- requirement of inserting a Local_Raise call where possible. ------------------------------------- -- Expand_Local_Exception_Handlers -- ------------------------------------- -- There are two cases for this transformation. First the case of -- explicit raise statements. For this case, the transformation we do -- looks like this. Right now we have for example (where L1, L2 are -- exception labels) -- begin -- ... -- raise_exception (excep1'identity); -- was raise excep1 -- ... -- raise_exception (excep2'identity); -- was raise excep2 -- ... -- exception -- when excep1 => -- estmts1 -- when excep2 => -- estmts2 -- end; -- This gets transformed into: -- begin -- L1 : label; -- marked Exception_Junk -- L2 : label; -- marked Exception_Junk -- L3 : label; -- marked Exception_Junk -- begin -- marked Exception_Junk -- ... -- local_raise (excep1'address); -- was raise excep1 -- goto L1; -- ... -- local_raise (excep2'address); -- was raise excep2 -- goto L2; -- ... -- exception -- when excep1 => -- goto L1; -- when excep2 => -- goto L2; -- end; -- goto L3; -- skip handler if no raise, marked Exception_Junk -- <<L1>> -- local excep target label, marked Exception_Junk -- begin -- marked Exception_Junk -- estmts1 -- end; -- goto L3; -- marked Exception_Junk -- <<L2>> -- marked Exception_Junk -- begin -- marked Exception_Junk -- estmts2 -- end; -- goto L3; -- marked Exception_Junk -- <<L3>> -- marked Exception_Junk -- end; -- Note: the reason we wrap the original statement sequence in an -- inner block is that there may be raise statements within the -- sequence of statements in the handlers, and we must ensure that -- these are properly handled, and in particular, such raise statements -- must not reenter the same exception handlers. -- If the restriction No_Exception_Propagation is in effect, then we -- can omit the exception handlers. -- begin -- L1 : label; -- marked Exception_Junk -- L2 : label; -- marked Exception_Junk -- L3 : label; -- marked Exception_Junk -- begin -- marked Exception_Junk -- ... -- local_raise (excep1'address); -- was raise excep1 -- goto L1; -- ... -- local_raise (excep2'address); -- was raise excep2 -- goto L2; -- ... -- end; -- goto L3; -- skip handler if no raise, marked Exception_Junk -- <<L1>> -- local excep target label, marked Exception_Junk -- begin -- marked Exception_Junk -- estmts1 -- end; -- goto L3; -- marked Exception_Junk -- <<L2>> -- marked Exception_Junk -- begin -- marked Exception_Junk -- estmts2 -- end; -- <<L3>> -- marked Exception_Junk -- end; -- The second case is for exceptions generated by the back end in one -- of three situations: -- 1. Front end generates N_Raise_xxx_Error node -- 2. Front end sets Do_xxx_Check flag in subexpression node -- 3. Back end detects a situation where an exception is appropriate -- In all these cases, the current processing in gigi is to generate a -- call to the appropriate Rcheck_xx routine (where xx encodes both the -- exception message and the exception to be raised, Constraint_Error, -- Program_Error, or Storage_Error. -- We could handle some subcases of 1 using the same front end expansion -- into gotos, but even for case 1, we can't handle all cases, since -- generating gotos in the middle of expressions is not possible (it's -- possible at the gigi/gcc level, but not at the level of the GNAT -- tree). -- In any case, it seems easier to have a scheme which handles all three -- cases in a uniform manner. So here is how we proceed in this case. -- This procedure detects all handlers for these three exceptions, -- Constraint_Error, Program_Error and Storage_Error (including WHEN -- OTHERS handlers that cover one or more of these cases). -- If the handler meets the requirements for being the target of a local -- raise, then the front end does the expansion described previously, -- creating a label to be used as a goto target to raise the exception. -- However, no attempt is made in the front end to convert any related -- raise statements into gotos, e.g. all N_Raise_xxx_Error nodes are -- left unchanged and passed to the back end. -- Instead, the front end generates three nodes -- N_Push_Constraint_Error_Label -- N_Push_Program_Error_Label -- N_Push_Storage_Error_Label -- The Push node is generated at the start of the statements -- covered by the handler, and has as a parameter the label to be -- used as the raise target. -- N_Pop_Constraint_Error_Label -- N_Pop_Program_Error_Label -- N_Pop_Storage_Error_Label -- The Pop node is generated at the end of the covered statements -- and undoes the effect of the preceding corresponding Push node. -- In the case where the handler does NOT meet the requirements, the -- front end will still generate the Push and Pop nodes, but the label -- field in the Push node will be empty signifying that for this region -- of code, no optimization is possible. -- These Push/Pop nodes are inhibited if No_Exception_Handlers is set -- since they are useless in this case, and in CodePeer mode, where -- they serve no purpose and can intefere with the analysis. -- The back end must maintain three stacks, one for each exception case, -- the Push node pushes an entry onto the corresponding stack, and Pop -- node pops off the entry. Then instead of calling Rcheck_nn, if the -- corresponding top stack entry has an non-empty label, a goto is -- generated. This goto should be preceded by a call to Local_Raise as -- described above. -- An example of this transformation is as follows, given: -- declare -- A : Integer range 1 .. 10; -- begin -- A := B + C; -- exception -- when Constraint_Error => -- estmts -- end; -- gets transformed to: -- declare -- A : Integer range 1 .. 10; -- begin -- L1 : label; -- L2 : label; -- begin -- %push_constraint_error_label (L1) -- R1b : constant long_long_integer := long_long_integer?(b) + -- long_long_integer?(c); -- [constraint_error when -- not (R1b in -16#8000_0000# .. 16#7FFF_FFFF#) -- "overflow check failed"] -- a := integer?(R1b); -- %pop_constraint_error_Label -- exception -- ... -- when constraint_error => -- goto L1; -- end; -- goto L2; -- skip handler when exception not raised -- <<L1>> -- target label for local exception -- estmts -- <<L2>> -- end; -- Note: the generated labels and goto statements all have the flag -- Exception_Junk set True, so that Sem_Ch6.Check_Returns will ignore -- this generated exception stuff when checking for missing return -- statements (see circuitry in Check_Statement_Sequence). -- Note: All of the processing described above occurs only if -- restriction No_Exception_Propagation applies or debug flag .g is -- enabled. CE_Locally_Handled : Boolean := False; SE_Locally_Handled : Boolean := False; PE_Locally_Handled : Boolean := False; -- These three flags indicate whether a handler for the corresponding -- exception (CE=Constraint_Error, SE=Storage_Error, PE=Program_Error) -- is present. If so the switch is set to True, the Exception_Label -- field of the corresponding handler is set, and appropriate Push -- and Pop nodes are inserted into the code. Local_Expansion_Required : Boolean := False; -- Set True if we have at least one handler requiring local raise -- expansion as described above. procedure Expand_Local_Exception_Handlers is procedure Add_Exception_Label (H : Node_Id); -- H is an exception handler. First check for an Exception_Label -- already allocated for H. If none, allocate one, set the field in -- the handler node, add the label declaration, and set the flag -- Local_Expansion_Required. Note: if Local_Raise_Not_OK is set -- the call has no effect and Exception_Label is left empty. procedure Add_Label_Declaration (L : Entity_Id); -- Add an implicit declaration of the given label to the declaration -- list in the parent of the current sequence of handled statements. generic Exc_Locally_Handled : in out Boolean; -- Flag indicating whether a local handler for this exception -- has already been generated. with function Make_Push_Label (Loc : Source_Ptr) return Node_Id; -- Function to create a Push_xxx_Label node with function Make_Pop_Label (Loc : Source_Ptr) return Node_Id; -- Function to create a Pop_xxx_Label node procedure Generate_Push_Pop (H : Node_Id); -- Common code for Generate_Push_Pop_xxx below, used to generate an -- exception label and Push/Pop nodes for Constraint_Error, -- Program_Error, or Storage_Error. ------------------------- -- Add_Exception_Label -- ------------------------- procedure Add_Exception_Label (H : Node_Id) is begin if No (Exception_Label (H)) and then not Local_Raise_Not_OK (H) and then not Special_Exception_Package_Used then Local_Expansion_Required := True; declare L : constant Entity_Id := Make_Temporary (Sloc (H), 'L'); begin Set_Exception_Label (H, L); Add_Label_Declaration (L); end; end if; end Add_Exception_Label; --------------------------- -- Add_Label_Declaration -- --------------------------- procedure Add_Label_Declaration (L : Entity_Id) is P : constant Node_Id := Parent (HSS); Decl_L : constant Node_Id := Make_Implicit_Label_Declaration (Loc, Defining_Identifier => L); begin if Declarations (P) = No_List then Set_Declarations (P, Empty_List); end if; Append (Decl_L, Declarations (P)); Analyze (Decl_L); end Add_Label_Declaration; ----------------------- -- Generate_Push_Pop -- ----------------------- procedure Generate_Push_Pop (H : Node_Id) is begin if Restriction_Active (No_Exception_Handlers) or else CodePeer_Mode then return; end if; if Exc_Locally_Handled then return; else Exc_Locally_Handled := True; end if; Add_Exception_Label (H); declare F : constant Node_Id := First (Statements (HSS)); L : constant Node_Id := Last (Statements (HSS)); Push : constant Node_Id := Make_Push_Label (Sloc (F)); Pop : constant Node_Id := Make_Pop_Label (Sloc (L)); begin -- We make sure that a call to Get_Local_Raise_Call_Entity is -- made during front end processing, so that when we need it -- in the back end, it will already be available and loaded. Discard_Node (Get_Local_Raise_Call_Entity); -- Prepare and insert Push and Pop nodes Set_Exception_Label (Push, Exception_Label (H)); Insert_Before (F, Push); Set_Analyzed (Push); Insert_After (L, Pop); Set_Analyzed (Pop); end; end Generate_Push_Pop; -- Local declarations Loc : constant Source_Ptr := Sloc (HSS); Stmts : List_Id := No_List; Choice : Node_Id; Excep : Entity_Id; procedure Generate_Push_Pop_For_Constraint_Error is new Generate_Push_Pop (Exc_Locally_Handled => CE_Locally_Handled, Make_Push_Label => Make_Push_Constraint_Error_Label, Make_Pop_Label => Make_Pop_Constraint_Error_Label); -- If no Push/Pop has been generated for CE yet, then set the flag -- CE_Locally_Handled, allocate an Exception_Label for handler H (if -- not already done), and generate Push/Pop nodes for the exception -- label at the start and end of the statements of HSS. procedure Generate_Push_Pop_For_Program_Error is new Generate_Push_Pop (Exc_Locally_Handled => PE_Locally_Handled, Make_Push_Label => Make_Push_Program_Error_Label, Make_Pop_Label => Make_Pop_Program_Error_Label); -- If no Push/Pop has been generated for PE yet, then set the flag -- PE_Locally_Handled, allocate an Exception_Label for handler H (if -- not already done), and generate Push/Pop nodes for the exception -- label at the start and end of the statements of HSS. procedure Generate_Push_Pop_For_Storage_Error is new Generate_Push_Pop (Exc_Locally_Handled => SE_Locally_Handled, Make_Push_Label => Make_Push_Storage_Error_Label, Make_Pop_Label => Make_Pop_Storage_Error_Label); -- If no Push/Pop has been generated for SE yet, then set the flag -- SE_Locally_Handled, allocate an Exception_Label for handler H (if -- not already done), and generate Push/Pop nodes for the exception -- label at the start and end of the statements of HSS. -- Start of processing for Expand_Local_Exception_Handlers begin -- No processing if all exception handlers will get removed if Debug_Flag_Dot_X then return; end if; -- See for each handler if we have any local raises to expand Handler := First_Non_Pragma (Handlrs); while Present (Handler) loop -- Note, we do not test Local_Raise_Not_OK here, because in the -- case of Push/Pop generation we want to generate push with a -- null label. The Add_Exception_Label routine has no effect if -- Local_Raise_Not_OK is set, so this works as required. if Present (Local_Raise_Statements (Handler)) then Add_Exception_Label (Handler); end if; -- If we are doing local raise to goto optimization (restriction -- No_Exception_Propagation set or debug flag .g set), then check -- to see if handler handles CE, PE, SE and if so generate the -- appropriate push/pop sequence for the back end. if (Debug_Flag_Dot_G or else Restriction_Active (No_Exception_Propagation)) and then Has_Local_Raise (Handler) then Choice := First (Exception_Choices (Handler)); while Present (Choice) loop if Nkind (Choice) = N_Others_Choice and then not All_Others (Choice) then Generate_Push_Pop_For_Constraint_Error (Handler); Generate_Push_Pop_For_Program_Error (Handler); Generate_Push_Pop_For_Storage_Error (Handler); elsif Is_Entity_Name (Choice) then Excep := Get_Renamed_Entity (Entity (Choice)); if Excep = Standard_Constraint_Error then Generate_Push_Pop_For_Constraint_Error (Handler); elsif Excep = Standard_Program_Error then Generate_Push_Pop_For_Program_Error (Handler); elsif Excep = Standard_Storage_Error then Generate_Push_Pop_For_Storage_Error (Handler); end if; end if; Next (Choice); end loop; end if; Next_Non_Pragma (Handler); end loop; -- Nothing to do if no handlers requiring the goto transformation if not (Local_Expansion_Required) then return; end if; -- Prepare to do the transformation declare -- L3 is the label to exit the HSS L3_Dent : constant Entity_Id := Make_Temporary (Loc, 'L'); Labl_L3 : constant Node_Id := Make_Label (Loc, Identifier => New_Occurrence_Of (L3_Dent, Loc)); Blk_Stm : Node_Id; Relmt : Elmt_Id; begin Set_Exception_Junk (Labl_L3); Add_Label_Declaration (L3_Dent); -- Wrap existing statements and handlers in an inner block Blk_Stm := Make_Block_Statement (Loc, Handled_Statement_Sequence => Relocate_Node (HSS)); Set_Exception_Junk (Blk_Stm); Rewrite (HSS, Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Blk_Stm), End_Label => Relocate_Node (End_Label (HSS)))); -- Set block statement as analyzed, we don't want to actually call -- Analyze on this block, it would cause a recursion in exception -- handler processing which would mess things up. Set_Analyzed (Blk_Stm); -- Now loop through the exception handlers to deal with those that -- are targets of local raise statements. Handler := First_Non_Pragma (Handlrs); while Present (Handler) loop if Present (Exception_Label (Handler)) then -- This handler needs the goto expansion declare Loc : constant Source_Ptr := Sloc (Handler); -- L1 is the start label for this handler L1_Dent : constant Entity_Id := Exception_Label (Handler); Labl_L1 : constant Node_Id := Make_Label (Loc, Identifier => New_Occurrence_Of (L1_Dent, Loc)); -- Jump to L1 to be used as replacement for the original -- handler (used in the case where exception propagation -- may still occur). Name_L1 : constant Node_Id := New_Occurrence_Of (L1_Dent, Loc); Goto_L1 : constant Node_Id := Make_Goto_Statement (Loc, Name => Name_L1); -- Jump to L3 to be used at the end of handler Name_L3 : constant Node_Id := New_Occurrence_Of (L3_Dent, Loc); Goto_L3 : constant Node_Id := Make_Goto_Statement (Loc, Name => Name_L3); H_Stmts : constant List_Id := Statements (Handler); begin Set_Exception_Junk (Labl_L1); Set_Exception_Junk (Goto_L3); -- Note: we do NOT set Exception_Junk in Goto_L1, since -- this is a real transfer of control that we want the -- Sem_Ch6.Check_Returns procedure to recognize properly. -- Replace handler by a goto L1. We can mark this as -- analyzed since it is fully formed, and we don't -- want it going through any further checks. We save -- the last statement location in the goto L1 node for -- the benefit of Sem_Ch6.Check_Returns. Set_Statements (Handler, New_List (Goto_L1)); Set_Analyzed (Goto_L1); Set_Etype (Name_L1, Standard_Void_Type); -- Now replace all the raise statements by goto L1 if Present (Local_Raise_Statements (Handler)) then Relmt := First_Elmt (Local_Raise_Statements (Handler)); while Present (Relmt) loop declare Raise_S : constant Node_Id := Node (Relmt); RLoc : constant Source_Ptr := Sloc (Raise_S); Name_L1 : constant Node_Id := New_Occurrence_Of (L1_Dent, Loc); Goto_L1 : constant Node_Id := Make_Goto_Statement (RLoc, Name => Name_L1); begin -- Replace raise by goto L1 Set_Analyzed (Goto_L1); Set_Etype (Name_L1, Standard_Void_Type); Replace_Raise_By_Goto (Raise_S, Goto_L1); end; Next_Elmt (Relmt); end loop; end if; -- Add a goto L3 at end of statement list in block. The -- first time, this is what skips over the exception -- handlers in the normal case. Subsequent times, it -- terminates the execution of the previous handler code, -- and skips subsequent handlers. Stmts := Statements (HSS); Insert_After (Last (Stmts), Goto_L3); Set_Analyzed (Goto_L3); Set_Etype (Name_L3, Standard_Void_Type); -- Now we drop the label that marks the handler start, -- followed by the statements of the handler. Set_Etype (Identifier (Labl_L1), Standard_Void_Type); Insert_After_And_Analyze (Last (Stmts), Labl_L1); declare Loc : constant Source_Ptr := Sloc (First (H_Stmts)); Blk : constant Node_Id := Make_Block_Statement (Loc, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => H_Stmts)); begin Set_Exception_Junk (Blk); Insert_After_And_Analyze (Last (Stmts), Blk); end; end; -- Here if we have local raise statements but the handler is -- not suitable for processing with a local raise. In this -- case we have to generate possible diagnostics. elsif Has_Local_Raise (Handler) and then Local_Raise_Statements (Handler) /= No_Elist then Relmt := First_Elmt (Local_Raise_Statements (Handler)); while Present (Relmt) loop Warn_If_No_Propagation (Node (Relmt)); Next_Elmt (Relmt); end loop; end if; Next (Handler); end loop; -- Only remaining step is to drop the L3 label and we are done Set_Etype (Identifier (Labl_L3), Standard_Void_Type); -- If we had at least one handler, then we drop the label after -- the last statement of that handler. if Stmts /= No_List then Insert_After_And_Analyze (Last (Stmts), Labl_L3); -- Otherwise we have removed all the handlers (this results from -- use of pragma Restrictions (No_Exception_Propagation), and we -- drop the label at the end of the statements of the HSS. else Insert_After_And_Analyze (Last (Statements (HSS)), Labl_L3); end if; return; end; end Expand_Local_Exception_Handlers; ----------------------------- -- Prepend_Call_To_Handler -- ----------------------------- procedure Prepend_Call_To_Handler (Proc : RE_Id; Args : List_Id := No_List) is Ent : constant Entity_Id := RTE (Proc); begin -- If we have no Entity, then we are probably in no run time mode or -- some weird error has occurred. In either case do nothing. Note use -- of No_Location to hide this code from the debugger, so single -- stepping doesn't jump back and forth. if Present (Ent) then declare Call : constant Node_Id := Make_Procedure_Call_Statement (No_Location, Name => New_Occurrence_Of (RTE (Proc), No_Location), Parameter_Associations => Args); begin Prepend_To (Statements (Handler), Call); Analyze (Call, Suppress => All_Checks); end; end if; end Prepend_Call_To_Handler; --------------------------- -- Replace_Raise_By_Goto -- --------------------------- procedure Replace_Raise_By_Goto (Raise_S : Node_Id; Goto_L1 : Node_Id) is Loc : constant Source_Ptr := Sloc (Raise_S); Excep : Entity_Id; LR : Node_Id; Cond : Node_Id; Orig : Node_Id; begin -- If we have a null statement, it means that there is no replacement -- needed (typically this results from a suppressed check). if Nkind (Raise_S) = N_Null_Statement then return; -- Test for Raise_xxx_Error elsif Nkind (Raise_S) = N_Raise_Constraint_Error then Excep := Standard_Constraint_Error; Cond := Condition (Raise_S); elsif Nkind (Raise_S) = N_Raise_Storage_Error then Excep := Standard_Storage_Error; Cond := Condition (Raise_S); elsif Nkind (Raise_S) = N_Raise_Program_Error then Excep := Standard_Program_Error; Cond := Condition (Raise_S); -- The only other possibility is a node that is or used to be a -- simple raise statement. Note that the string expression in the -- original Raise statement is ignored. else Orig := Original_Node (Raise_S); pragma Assert (Nkind (Orig) = N_Raise_Statement and then Present (Name (Orig))); Excep := Entity (Name (Orig)); Cond := Empty; end if; -- Here Excep is the exception to raise, and Cond is the condition -- First prepare the call to Local_Raise (excep'address). if RTE_Available (RE_Local_Raise) then LR := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Local_Raise), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_Address), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Excep, Loc), Attribute_Name => Name_Identity)))); -- Use null statement if Local_Raise not available else LR := Make_Null_Statement (Loc); end if; -- If there is no condition, we rewrite as -- begin -- Local_Raise (excep'Identity); -- goto L1; -- end; if No (Cond) then Rewrite (Raise_S, Make_Block_Statement (Loc, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (LR, Goto_L1)))); Set_Exception_Junk (Raise_S); -- If there is a condition, we rewrite as -- if condition then -- Local_Raise (excep'Identity); -- goto L1; -- end if; else Rewrite (Raise_S, Make_If_Statement (Loc, Condition => Cond, Then_Statements => New_List (LR, Goto_L1))); end if; Analyze (Raise_S); end Replace_Raise_By_Goto; -- Start of processing for Expand_Exception_Handlers begin Expand_Local_Exception_Handlers; -- Loop through handlers Handler := First_Non_Pragma (Handlrs); Handler_Loop : while Present (Handler) loop Process_Statements_For_Controlled_Objects (Handler); Next_Handler := Next_Non_Pragma (Handler); -- Remove source handler if gnat debug flag .x is set if Debug_Flag_Dot_X and then Comes_From_Source (Handler) then Remove (Handler); -- Remove handler if no exception propagation, generating a warning -- if a source generated handler was not the target of a local raise. else if not Has_Local_Raise (Handler) and then Comes_From_Source (Handler) then Warn_If_No_Local_Raise (Handler); end if; if No_Exception_Propagation_Active then Remove (Handler); -- Exception handler is active and retained and must be processed else -- If an exception occurrence is present, then we must declare -- it and initialize it from the value stored in the TSD -- declare -- name : Exception_Occurrence; -- begin -- Save_Occurrence (name, Get_Current_Excep.all) -- ... -- end; -- This expansion is only performed when using front-end -- exceptions. Gigi will insert a call to initialize the -- choice parameter. if Present (Choice_Parameter (Handler)) and then (Front_End_Exceptions or else CodePeer_Mode) then declare Cparm : constant Entity_Id := Choice_Parameter (Handler); Cloc : constant Source_Ptr := Sloc (Cparm); Hloc : constant Source_Ptr := Sloc (Handler); Save : Node_Id; begin -- Note: No_Location used to hide code from the debugger, -- so single stepping doesn't jump back and forth. Save := Make_Procedure_Call_Statement (No_Location, Name => New_Occurrence_Of (RTE (RE_Save_Occurrence), No_Location), Parameter_Associations => New_List ( New_Occurrence_Of (Cparm, No_Location), Make_Explicit_Dereference (No_Location, Prefix => Make_Function_Call (No_Location, Name => Make_Explicit_Dereference (No_Location, Prefix => New_Occurrence_Of (RTE (RE_Get_Current_Excep), No_Location)))))); Mark_Rewrite_Insertion (Save); Prepend (Save, Statements (Handler)); Obj_Decl := Make_Object_Declaration (Cloc, Defining_Identifier => Cparm, Object_Definition => New_Occurrence_Of (RTE (RE_Exception_Occurrence), Cloc)); Set_No_Initialization (Obj_Decl, True); Rewrite (Handler, Make_Exception_Handler (Hloc, Choice_Parameter => Empty, Exception_Choices => Exception_Choices (Handler), Statements => New_List ( Make_Block_Statement (Hloc, Declarations => New_List (Obj_Decl), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Hloc, Statements => Statements (Handler)))))); -- Local raise statements can't occur, since exception -- handlers with choice parameters are not allowed when -- No_Exception_Propagation applies, so set attributes -- accordingly. Set_Local_Raise_Statements (Handler, No_Elist); Set_Local_Raise_Not_OK (Handler); Analyze_List (Statements (Handler), Suppress => All_Checks); end; end if; -- For the normal case, we have to worry about the state of -- abort deferral. Generally, we defer abort during runtime -- handling of exceptions. When control is passed to the -- handler, then in the normal case we undefer aborts. In -- any case this entire handling is relevant only if aborts -- are allowed. if Abort_Allowed and then not ZCX_Exceptions then -- There are some special cases in which we do not do the -- undefer. In particular a finalization (AT END) handler -- wants to operate with aborts still deferred. -- We also suppress the call if this is the special handler -- for Abort_Signal, since if we are aborting, we want to -- keep aborts deferred (one abort is enough). -- If abort really needs to be deferred the expander must -- add this call explicitly, see -- Expand_N_Asynchronous_Select. Others_Choice := Nkind (First (Exception_Choices (Handler))) = N_Others_Choice; if (Others_Choice or else Entity (First (Exception_Choices (Handler))) /= Stand.Abort_Signal) and then not (Others_Choice and then All_Others (First (Exception_Choices (Handler)))) then Prepend_Call_To_Handler (RE_Abort_Undefer); end if; end if; end if; end if; Handler := Next_Handler; end loop Handler_Loop; -- If all handlers got removed, then remove the list. Note we cannot -- reference HSS here, since expanding local handlers may have buried -- the handlers in an inner block. if Is_Empty_List (Handlrs) then Set_Exception_Handlers (Parent (Handlrs), No_List); end if; end Expand_Exception_Handlers; ------------------------------------ -- Expand_N_Exception_Declaration -- ------------------------------------ -- Generates: -- exceptE : constant String := "A.B.EXCEP"; -- static data -- except : exception_data := -- (Handled_By_Other => False, -- Lang => 'A', -- Name_Length => exceptE'Length, -- Full_Name => exceptE'Address, -- HTable_Ptr => null, -- Foreign_Data => null, -- Raise_Hook => null); -- (protecting test only needed if not at library level) -- exceptF : Boolean := True -- static data -- if exceptF then -- exceptF := False; -- Register_Exception (except'Unchecked_Access); -- end if; procedure Expand_N_Exception_Declaration (N : Node_Id) is Id : constant Entity_Id := Defining_Identifier (N); Loc : constant Source_Ptr := Sloc (N); procedure Force_Static_Allocation_Of_Referenced_Objects (Aggregate : Node_Id); -- A specialized solution to one particular case of an ugly problem -- -- The given aggregate includes an Unchecked_Conversion as one of the -- component values. The call to Analyze_And_Resolve below ends up -- calling Exp_Ch4.Expand_N_Unchecked_Type_Conversion, which may decide -- to introduce a (constant) temporary and then obtain the component -- value by evaluating the temporary. -- -- In the case of an exception declared within a subprogram (or any -- other dynamic scope), this is a bad transformation. The exception -- object is marked as being Statically_Allocated but the temporary is -- not. If the initial value of a Statically_Allocated declaration -- references a dynamically allocated object, this prevents static -- initialization of the object. -- -- We cope with this here by marking the temporary Statically_Allocated. -- It might seem cleaner to generalize this utility and then use it to -- enforce a rule that the entities referenced in the declaration of any -- "hoisted" (i.e., Is_Statically_Allocated and not Is_Library_Level) -- entity must also be either Library_Level or hoisted. It turns out -- that this would be incompatible with the current treatment of an -- object which is local to a subprogram, subject to an Export pragma, -- not subject to an address clause, and whose declaration contains -- references to other local (non-hoisted) objects (e.g., in the initial -- value expression). function Null_String return String_Id; -- Build a null-terminated empty string --------------------------------------------------- -- Force_Static_Allocation_Of_Referenced_Objects -- --------------------------------------------------- procedure Force_Static_Allocation_Of_Referenced_Objects (Aggregate : Node_Id) is function Fixup_Node (N : Node_Id) return Traverse_Result; -- If the given node references a dynamically allocated object, then -- correct the declaration of the object. ---------------- -- Fixup_Node -- ---------------- function Fixup_Node (N : Node_Id) return Traverse_Result is begin if Nkind (N) in N_Has_Entity and then Present (Entity (N)) and then not Is_Library_Level_Entity (Entity (N)) -- Note: the following test is not needed but it seems cleaner -- to do this test (this would be more important if procedure -- Force_Static_Allocation_Of_Referenced_Objects recursively -- traversed the declaration of an entity after marking it as -- statically allocated). and then not Is_Statically_Allocated (Entity (N)) then Set_Is_Statically_Allocated (Entity (N)); end if; return OK; end Fixup_Node; procedure Fixup_Tree is new Traverse_Proc (Fixup_Node); -- Start of processing for Force_Static_Allocation_Of_Referenced_Objects begin Fixup_Tree (Aggregate); end Force_Static_Allocation_Of_Referenced_Objects; ----------------- -- Null_String -- ----------------- function Null_String return String_Id is begin Start_String; Store_String_Char (Get_Char_Code (ASCII.NUL)); return End_String; end Null_String; -- Local variables Ex_Id : Entity_Id; Ex_Val : String_Id; Flag_Id : Entity_Id; L : List_Id; -- Start of processing for Expand_N_Exception_Declaration begin -- Nothing to do when generating C code if Modify_Tree_For_C then return; end if; -- Definition of the external name: nam : constant String := "A.B.NAME"; Ex_Id := Make_Defining_Identifier (Loc, New_External_Name (Chars (Id), 'E')); -- Do not generate an external name if the exception declaration is -- subject to pragma Discard_Names. Use a null-terminated empty name -- to ensure that Ada.Exceptions.Exception_Name functions properly. if Global_Discard_Names or else Discard_Names (Ex_Id) then Ex_Val := Null_String; -- Otherwise generate the fully qualified name of the exception else Ex_Val := Fully_Qualified_Name_String (Id); end if; Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Ex_Id, Constant_Present => True, Object_Definition => New_Occurrence_Of (Standard_String, Loc), Expression => Make_String_Literal (Loc, Ex_Val))); Set_Is_Statically_Allocated (Ex_Id); -- Create the aggregate list for type Standard.Exception_Type: -- Handled_By_Other component: False L := Empty_List; Append_To (L, New_Occurrence_Of (Standard_False, Loc)); -- Lang component: 'A' Append_To (L, Make_Character_Literal (Loc, Chars => Name_uA, Char_Literal_Value => UI_From_Int (Character'Pos ('A')))); -- Name_Length component: Nam'Length Append_To (L, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Ex_Id, Loc), Attribute_Name => Name_Length)); -- Full_Name component: Standard.A_Char!(Nam'Address) -- The unchecked conversion causes capacity issues for CodePeer in some -- cases and is never useful, so we set the Full_Name component to null -- instead for CodePeer. if CodePeer_Mode then Append_To (L, Make_Null (Loc)); else Append_To (L, Unchecked_Convert_To (Standard_A_Char, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Ex_Id, Loc), Attribute_Name => Name_Address))); end if; -- HTable_Ptr component: null Append_To (L, Make_Null (Loc)); -- Foreign_Data component: null Append_To (L, Make_Null (Loc)); -- Raise_Hook component: null Append_To (L, Make_Null (Loc)); Set_Expression (N, Make_Aggregate (Loc, Expressions => L)); Analyze_And_Resolve (Expression (N), Etype (Id)); Force_Static_Allocation_Of_Referenced_Objects (Expression (N)); -- Register_Exception (except'Unchecked_Access); if not No_Exception_Handlers_Set and then not Restriction_Active (No_Exception_Registration) then L := New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Register_Exception), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_Exception_Data_Ptr), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Id, Loc), Attribute_Name => Name_Unrestricted_Access))))); Set_Register_Exception_Call (Id, First (L)); if not Is_Library_Level_Entity (Id) then Flag_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Id), 'F')); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Flag_Id, Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc), Expression => New_Occurrence_Of (Standard_True, Loc))); Set_Is_Statically_Allocated (Flag_Id); Append_To (L, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Flag_Id, Loc), Expression => New_Occurrence_Of (Standard_False, Loc))); Insert_After_And_Analyze (N, Make_Implicit_If_Statement (N, Condition => New_Occurrence_Of (Flag_Id, Loc), Then_Statements => L)); else Insert_List_After_And_Analyze (N, L); end if; end if; end Expand_N_Exception_Declaration; --------------------------------------------- -- Expand_N_Handled_Sequence_Of_Statements -- --------------------------------------------- procedure Expand_N_Handled_Sequence_Of_Statements (N : Node_Id) is begin -- Expand exception handlers if Present (Exception_Handlers (N)) and then not Restriction_Active (No_Exception_Handlers) then Expand_Exception_Handlers (N); end if; -- If local exceptions are being expanded, the previous call will -- have rewritten the construct as a block and reanalyzed it. No -- further expansion is needed. if Analyzed (N) then return; end if; -- Add cleanup actions if required. No cleanup actions are needed in -- thunks associated with interfaces, because they only displace the -- pointer to the object. For extended return statements, we need -- cleanup actions if the Handled_Statement_Sequence contains generated -- objects of controlled types, for example. We do not want to clean up -- the return object. if Nkind (Parent (N)) not in N_Accept_Statement | N_Extended_Return_Statement | N_Package_Body and then not Delay_Cleanups (Current_Scope) and then not Is_Thunk (Current_Scope) then Expand_Cleanup_Actions (Parent (N)); elsif Nkind (Parent (N)) = N_Extended_Return_Statement and then Handled_Statement_Sequence (Parent (N)) = N and then not Delay_Cleanups (Current_Scope) then pragma Assert (not Is_Thunk (Current_Scope)); Expand_Cleanup_Actions (Parent (N)); else Set_First_Real_Statement (N, First (Statements (N))); end if; end Expand_N_Handled_Sequence_Of_Statements; ------------------------------------- -- Expand_N_Raise_Constraint_Error -- ------------------------------------- procedure Expand_N_Raise_Constraint_Error (N : Node_Id) is begin -- We adjust the condition to deal with the C/Fortran boolean case. This -- may well not be necessary, as all such conditions are generated by -- the expander and probably are all standard boolean, but who knows -- what strange optimization in future may require this adjustment. Adjust_Condition (Condition (N)); -- Now deal with possible local raise handling Possible_Local_Raise (N, Standard_Constraint_Error); end Expand_N_Raise_Constraint_Error; ------------------------------- -- Expand_N_Raise_Expression -- ------------------------------- procedure Expand_N_Raise_Expression (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); RCE : Node_Id; begin Possible_Local_Raise (N, Entity (Name (N))); -- Later we must teach the back end/gigi how to deal with this, but -- for now we will assume the type is Standard_Boolean and transform -- the node to: -- do -- raise X [with string] -- in -- raise Constraint_Error; -- unless the flag Convert_To_Return_False is set, in which case -- the transformation is to: -- do -- return False; -- in -- raise Constraint_Error; -- The raise constraint error can never be executed. It is just a dummy -- node that can be labeled with an arbitrary type. RCE := Make_Raise_Constraint_Error (Loc, Reason => CE_Explicit_Raise); Set_Etype (RCE, Typ); if Convert_To_Return_False (N) then Rewrite (N, Make_Expression_With_Actions (Loc, Actions => New_List ( Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_False, Loc))), Expression => RCE)); else Rewrite (N, Make_Expression_With_Actions (Loc, Actions => New_List ( Make_Raise_Statement (Loc, Name => Name (N), Expression => Expression (N))), Expression => RCE)); end if; Analyze_And_Resolve (N, Typ); end Expand_N_Raise_Expression; ---------------------------------- -- Expand_N_Raise_Program_Error -- ---------------------------------- procedure Expand_N_Raise_Program_Error (N : Node_Id) is begin -- We adjust the condition to deal with the C/Fortran boolean case. This -- may well not be necessary, as all such conditions are generated by -- the expander and probably are all standard boolean, but who knows -- what strange optimization in future may require this adjustment. Adjust_Condition (Condition (N)); -- Now deal with possible local raise handling Possible_Local_Raise (N, Standard_Program_Error); end Expand_N_Raise_Program_Error; ------------------------------ -- Expand_N_Raise_Statement -- ------------------------------ procedure Expand_N_Raise_Statement (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ehand : Node_Id; E : Entity_Id; Str : String_Id; H : Node_Id; Src : Boolean; begin -- Processing for locally handled exception (exclude reraise case) if Present (Name (N)) and then Nkind (Name (N)) = N_Identifier then if Debug_Flag_Dot_G or else Restriction_Active (No_Exception_Propagation) then -- If we have a local handler, then note that this is potentially -- able to be transformed into a goto statement. H := Find_Local_Handler (Entity (Name (N)), N); if Present (H) then if Local_Raise_Statements (H) = No_Elist then Set_Local_Raise_Statements (H, New_Elmt_List); end if; -- Append the new entry if it is not there already. Sometimes -- we have situations where due to reexpansion, the same node -- is analyzed twice and would otherwise be added twice. Append_Unique_Elmt (N, Local_Raise_Statements (H)); Set_Has_Local_Raise (H); -- If no local handler, then generate no propagation warning else Warn_If_No_Propagation (N); end if; end if; end if; -- If a string expression is present, then the raise statement is -- converted to a call: -- Raise_Exception (exception-name'Identity, string); -- and there is nothing else to do. if Present (Expression (N)) then -- Adjust message to deal with Prefix_Exception_Messages. We only -- add the prefix to string literals, if the message is being -- constructed, we assume it already deals with uniqueness. if Prefix_Exception_Messages and then Nkind (Expression (N)) = N_String_Literal then declare Buf : Bounded_String; begin Add_Source_Info (Buf, Loc, Name_Enclosing_Entity); Append (Buf, ": "); Append (Buf, Strval (Expression (N))); Rewrite (Expression (N), Make_String_Literal (Loc, +Buf)); Analyze_And_Resolve (Expression (N), Standard_String); end; end if; -- Avoid passing exception-name'identity in runtimes in which this -- argument is not used. This avoids generating undefined references -- to these exceptions when compiling with no optimization if Configurable_Run_Time_On_Target and then (Restriction_Active (No_Exception_Handlers) or else Restriction_Active (No_Exception_Propagation)) then Rewrite (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Raise_Exception), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (RTE (RE_Null_Id), Loc), Expression (N)))); else Rewrite (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Raise_Exception), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, Prefix => Name (N), Attribute_Name => Name_Identity), Expression (N)))); end if; Analyze (N); return; end if; -- Remaining processing is for the case where no string expression is -- present. -- Don't expand a raise statement that does not come from source if we -- have already had configurable run-time violations, since most likely -- it will be junk cascaded nonsense. if Configurable_Run_Time_Violations > 0 and then not Comes_From_Source (N) then return; end if; -- Convert explicit raise of Program_Error, Constraint_Error, and -- Storage_Error into the corresponding raise (in High_Integrity_Mode -- all other raises will get normal expansion and be disallowed, -- but this is also faster in all modes). Propagate Comes_From_Source -- flag to the new node. if Present (Name (N)) and then Nkind (Name (N)) = N_Identifier then Src := Comes_From_Source (N); if Entity (Name (N)) = Standard_Constraint_Error then Rewrite (N, Make_Raise_Constraint_Error (Loc, Reason => CE_Explicit_Raise)); Set_Comes_From_Source (N, Src); Analyze (N); return; elsif Entity (Name (N)) = Standard_Program_Error then Rewrite (N, Make_Raise_Program_Error (Loc, Reason => PE_Explicit_Raise)); Set_Comes_From_Source (N, Src); Analyze (N); return; elsif Entity (Name (N)) = Standard_Storage_Error then Rewrite (N, Make_Raise_Storage_Error (Loc, Reason => SE_Explicit_Raise)); Set_Comes_From_Source (N, Src); Analyze (N); return; end if; end if; -- Case of name present, in this case we expand raise name to -- Raise_Exception (name'Identity, location_string); -- where location_string identifies the file/line of the raise if Present (Name (N)) then declare Id : Entity_Id := Entity (Name (N)); Buf : Bounded_String; begin Build_Location_String (Buf, Loc); -- If the exception is a renaming, use the exception that it -- renames (which might be a predefined exception, e.g.). if Present (Renamed_Object (Id)) then Id := Renamed_Object (Id); end if; -- Build a C-compatible string in case of no exception handlers, -- since this is what the last chance handler is expecting. if No_Exception_Handlers_Set then -- Generate an empty message if configuration pragma -- Suppress_Exception_Locations is set for this unit. if Opt.Exception_Locations_Suppressed then Buf.Length := 0; end if; Append (Buf, ASCII.NUL); end if; if Opt.Exception_Locations_Suppressed then Buf.Length := 0; end if; Str := String_From_Name_Buffer (Buf); -- Convert raise to call to the Raise_Exception routine Rewrite (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Raise_Exception), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, Prefix => Name (N), Attribute_Name => Name_Identity), Make_String_Literal (Loc, Strval => Str)))); end; -- Case of no name present (reraise). We rewrite the raise to: -- Reraise_Occurrence_Always (EO); -- where EO is the current exception occurrence. If the current handler -- does not have a choice parameter specification, then we provide one. else -- Bypass expansion to a run-time call when back-end exception -- handling is active, unless the target is CodePeer or GNATprove. -- In CodePeer, raising an exception is treated as an error, while in -- GNATprove all code with exceptions falls outside the subset of -- code which can be formally analyzed. if not CodePeer_Mode and then Back_End_Exceptions then return; end if; -- Find innermost enclosing exception handler (there must be one, -- since the semantics has already verified that this raise statement -- is valid, and a raise with no arguments is only permitted in the -- context of an exception handler. Ehand := Parent (N); while Nkind (Ehand) /= N_Exception_Handler loop Ehand := Parent (Ehand); end loop; -- Make exception choice parameter if none present. Note that we do -- not need to put the entity on the entity chain, since no one will -- be referencing this entity by normal visibility methods. if No (Choice_Parameter (Ehand)) then E := Make_Temporary (Loc, 'E'); Set_Choice_Parameter (Ehand, E); Set_Ekind (E, E_Variable); Set_Etype (E, RTE (RE_Exception_Occurrence)); Set_Scope (E, Current_Scope); end if; -- Now rewrite the raise as a call to Reraise. A special case arises -- if this raise statement occurs in the context of a handler for -- all others (i.e. an at end handler). in this case we avoid -- the call to defer abort, cleanup routines are expected to be -- called in this case with aborts deferred. declare Ech : constant Node_Id := First (Exception_Choices (Ehand)); Ent : Entity_Id; begin if Nkind (Ech) = N_Others_Choice and then All_Others (Ech) then Ent := RTE (RE_Reraise_Occurrence_No_Defer); else Ent := RTE (RE_Reraise_Occurrence_Always); end if; Rewrite (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Ent, Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Choice_Parameter (Ehand), Loc)))); end; end if; Analyze (N); end Expand_N_Raise_Statement; ---------------------------------- -- Expand_N_Raise_Storage_Error -- ---------------------------------- procedure Expand_N_Raise_Storage_Error (N : Node_Id) is begin -- We adjust the condition to deal with the C/Fortran boolean case. This -- may well not be necessary, as all such conditions are generated by -- the expander and probably are all standard boolean, but who knows -- what strange optimization in future may require this adjustment. Adjust_Condition (Condition (N)); -- Now deal with possible local raise handling Possible_Local_Raise (N, Standard_Storage_Error); end Expand_N_Raise_Storage_Error; -------------------------- -- Possible_Local_Raise -- -------------------------- procedure Possible_Local_Raise (N : Node_Id; E : Entity_Id) is begin -- Nothing to do if local raise optimization not active if not Debug_Flag_Dot_G and then not Restriction_Active (No_Exception_Propagation) then return; end if; -- Nothing to do if original node was an explicit raise, because in -- that case, we already generated the required warning for the raise. if Nkind (Original_Node (N)) = N_Raise_Statement then return; end if; -- Otherwise see if we have a local handler for the exception declare H : constant Node_Id := Find_Local_Handler (E, N); begin -- If so, mark that it has a local raise if Present (H) then Set_Has_Local_Raise (H, True); -- Otherwise, if the No_Exception_Propagation restriction is active -- and the warning is enabled, generate the appropriate warnings. -- ??? Do not do it for the Call_Marker nodes inserted by the ABE -- mechanism because this generates too many false positives, or -- for generic instantiations for the same reason. elsif Warn_On_Non_Local_Exception and then Restriction_Active (No_Exception_Propagation) and then Nkind (N) /= N_Call_Marker and then Nkind (N) not in N_Generic_Instantiation then Warn_No_Exception_Propagation_Active (N); if Configurable_Run_Time_Mode then Error_Msg_NE ("\?X?& may call Last_Chance_Handler", N, E); else Error_Msg_NE ("\?X?& may result in unhandled exception", N, E); end if; end if; end; end Possible_Local_Raise; ------------------------ -- Find_Local_Handler -- ------------------------ function Find_Local_Handler (Ename : Entity_Id; Nod : Node_Id) return Node_Id is N : Node_Id; P : Node_Id; H : Node_Id; C : Node_Id; SSE : Scope_Stack_Entry renames Scope_Stack.Table (Scope_Stack.Last); -- This is used to test for wrapped actions below ERaise : Entity_Id; EHandle : Entity_Id; -- The entity Id's for the exception we are raising and handling, using -- the renamed exception if a Renamed_Entity is present. begin -- Never any local handler if all handlers removed if Debug_Flag_Dot_X then return Empty; end if; -- Get the exception we are raising, allowing for renaming ERaise := Get_Renamed_Entity (Ename); -- We need to check if the node we are looking at is contained in -- -- Loop to search up the tree N := Nod; loop P := Parent (N); -- If we get to the top of the tree, or to a subprogram, task, entry, -- protected body, or accept statement without having found a -- matching handler, then there is no local handler. if No (P) or else Nkind (P) = N_Subprogram_Body or else Nkind (P) = N_Task_Body or else Nkind (P) = N_Protected_Body or else Nkind (P) = N_Entry_Body or else Nkind (P) = N_Accept_Statement then return Empty; -- Test for handled sequence of statements with at least one -- exception handler which might be the one we are looking for. elsif Nkind (P) = N_Handled_Sequence_Of_Statements and then Present (Exception_Handlers (P)) then -- Before we proceed we need to check if the node N is covered -- by the statement part of P rather than one of its exception -- handlers (an exception handler obviously does not cover its -- own statements). -- This test is more delicate than might be thought. It is not -- just a matter of checking the Statements (P), because the node -- might be waiting to be wrapped in a transient scope, in which -- case it will end up in the block statements, even though it -- is not there now. if Is_List_Member (N) then declare LCN : constant List_Id := List_Containing (N); begin if LCN = Statements (P) or else LCN = SSE.Actions_To_Be_Wrapped (Before) or else LCN = SSE.Actions_To_Be_Wrapped (After) or else LCN = SSE.Actions_To_Be_Wrapped (Cleanup) then -- Loop through exception handlers H := First (Exception_Handlers (P)); while Present (H) loop -- Guard against other constructs appearing in the -- list of exception handlers. if Nkind (H) = N_Exception_Handler then -- Loop through choices in one handler C := First (Exception_Choices (H)); while Present (C) loop -- Deal with others case if Nkind (C) = N_Others_Choice then -- Matching others handler, but we need -- to ensure there is no choice parameter. -- If there is, then we don't have a local -- handler after all (since we do not allow -- choice parameters for local handlers). if No (Choice_Parameter (H)) then return H; else return Empty; end if; -- If not others must be entity name elsif Nkind (C) /= N_Others_Choice then pragma Assert (Is_Entity_Name (C)); pragma Assert (Present (Entity (C))); -- Get exception being handled, dealing with -- renaming. EHandle := Get_Renamed_Entity (Entity (C)); -- If match, then check choice parameter if ERaise = EHandle then if No (Choice_Parameter (H)) then return H; else return Empty; end if; end if; end if; Next (C); end loop; end if; Next (H); end loop; end if; end; end if; end if; N := P; end loop; end Find_Local_Handler; --------------------------------- -- Get_Local_Raise_Call_Entity -- --------------------------------- -- Note: this is primarily provided for use by the back end in generating -- calls to Local_Raise. But it would be too late in the back end to call -- RTE if this actually caused a load/analyze of the unit. So what we do -- is to ensure there is a dummy call to this function during front end -- processing so that the unit gets loaded then, and not later. Local_Raise_Call_Entity : Entity_Id; Local_Raise_Call_Entity_Set : Boolean := False; function Get_Local_Raise_Call_Entity return Entity_Id is begin if not Local_Raise_Call_Entity_Set then Local_Raise_Call_Entity_Set := True; if RTE_Available (RE_Local_Raise) then Local_Raise_Call_Entity := RTE (RE_Local_Raise); else Local_Raise_Call_Entity := Empty; end if; end if; return Local_Raise_Call_Entity; end Get_Local_Raise_Call_Entity; ----------------------------- -- Get_RT_Exception_Entity -- ----------------------------- function Get_RT_Exception_Entity (R : RT_Exception_Code) return Entity_Id is begin case Rkind (R) is when CE_Reason => return Standard_Constraint_Error; when PE_Reason => return Standard_Program_Error; when SE_Reason => return Standard_Storage_Error; end case; end Get_RT_Exception_Entity; --------------------------- -- Get_RT_Exception_Name -- --------------------------- procedure Get_RT_Exception_Name (Code : RT_Exception_Code) is begin case Code is when CE_Access_Check_Failed => Add_Str_To_Name_Buffer ("CE_Access_Check"); when CE_Access_Parameter_Is_Null => Add_Str_To_Name_Buffer ("CE_Null_Access_Parameter"); when CE_Discriminant_Check_Failed => Add_Str_To_Name_Buffer ("CE_Discriminant_Check"); when CE_Divide_By_Zero => Add_Str_To_Name_Buffer ("CE_Divide_By_Zero"); when CE_Explicit_Raise => Add_Str_To_Name_Buffer ("CE_Explicit_Raise"); when CE_Index_Check_Failed => Add_Str_To_Name_Buffer ("CE_Index_Check"); when CE_Invalid_Data => Add_Str_To_Name_Buffer ("CE_Invalid_Data"); when CE_Length_Check_Failed => Add_Str_To_Name_Buffer ("CE_Length_Check"); when CE_Null_Exception_Id => Add_Str_To_Name_Buffer ("CE_Null_Exception_Id"); when CE_Null_Not_Allowed => Add_Str_To_Name_Buffer ("CE_Null_Not_Allowed"); when CE_Overflow_Check_Failed => Add_Str_To_Name_Buffer ("CE_Overflow_Check"); when CE_Partition_Check_Failed => Add_Str_To_Name_Buffer ("CE_Partition_Check"); when CE_Range_Check_Failed => Add_Str_To_Name_Buffer ("CE_Range_Check"); when CE_Tag_Check_Failed => Add_Str_To_Name_Buffer ("CE_Tag_Check"); when PE_Access_Before_Elaboration => Add_Str_To_Name_Buffer ("PE_Access_Before_Elaboration"); when PE_Accessibility_Check_Failed => Add_Str_To_Name_Buffer ("PE_Accessibility_Check"); when PE_Address_Of_Intrinsic => Add_Str_To_Name_Buffer ("PE_Address_Of_Intrinsic"); when PE_Aliased_Parameters => Add_Str_To_Name_Buffer ("PE_Aliased_Parameters"); when PE_All_Guards_Closed => Add_Str_To_Name_Buffer ("PE_All_Guards_Closed"); when PE_Bad_Predicated_Generic_Type => Add_Str_To_Name_Buffer ("PE_Bad_Predicated_Generic_Type"); when PE_Build_In_Place_Mismatch => Add_Str_To_Name_Buffer ("PE_Build_In_Place_Mismatch"); when PE_Current_Task_In_Entry_Body => Add_Str_To_Name_Buffer ("PE_Current_Task_In_Entry_Body"); when PE_Duplicated_Entry_Address => Add_Str_To_Name_Buffer ("PE_Duplicated_Entry_Address"); when PE_Explicit_Raise => Add_Str_To_Name_Buffer ("PE_Explicit_Raise"); when PE_Finalize_Raised_Exception => Add_Str_To_Name_Buffer ("PE_Finalize_Raised_Exception"); when PE_Implicit_Return => Add_Str_To_Name_Buffer ("PE_Implicit_Return"); when PE_Misaligned_Address_Value => Add_Str_To_Name_Buffer ("PE_Misaligned_Address_Value"); when PE_Missing_Return => Add_Str_To_Name_Buffer ("PE_Missing_Return"); when PE_Non_Transportable_Actual => Add_Str_To_Name_Buffer ("PE_Non_Transportable_Actual"); when PE_Overlaid_Controlled_Object => Add_Str_To_Name_Buffer ("PE_Overlaid_Controlled_Object"); when PE_Potentially_Blocking_Operation => Add_Str_To_Name_Buffer ("PE_Potentially_Blocking_Operation"); when PE_Stream_Operation_Not_Allowed => Add_Str_To_Name_Buffer ("PE_Stream_Operation_Not_Allowed"); when PE_Stubbed_Subprogram_Called => Add_Str_To_Name_Buffer ("PE_Stubbed_Subprogram_Called"); when PE_Unchecked_Union_Restriction => Add_Str_To_Name_Buffer ("PE_Unchecked_Union_Restriction"); when SE_Empty_Storage_Pool => Add_Str_To_Name_Buffer ("SE_Empty_Storage_Pool"); when SE_Explicit_Raise => Add_Str_To_Name_Buffer ("SE_Explicit_Raise"); when SE_Infinite_Recursion => Add_Str_To_Name_Buffer ("SE_Infinite_Recursion"); when SE_Object_Too_Large => Add_Str_To_Name_Buffer ("SE_Object_Too_Large"); end case; end Get_RT_Exception_Name; ---------------------------- -- Warn_If_No_Local_Raise -- ---------------------------- procedure Warn_If_No_Local_Raise (N : Node_Id) is begin if Restriction_Active (No_Exception_Propagation) and then Warn_On_Non_Local_Exception then Warn_No_Exception_Propagation_Active (N); Error_Msg_N ("\?X?this handler can never be entered, and has been removed", N); end if; end Warn_If_No_Local_Raise; ---------------------------- -- Warn_If_No_Propagation -- ---------------------------- procedure Warn_If_No_Propagation (N : Node_Id) is begin if Restriction_Check_Required (No_Exception_Propagation) and then Warn_On_Non_Local_Exception then Warn_No_Exception_Propagation_Active (N); if Configurable_Run_Time_Mode then Error_Msg_N ("\?X?Last_Chance_Handler will be called on exception", N); else Error_Msg_N ("\?X?execution may raise unhandled exception", N); end if; end if; end Warn_If_No_Propagation; ------------------------------------------ -- Warn_No_Exception_Propagation_Active -- ------------------------------------------ procedure Warn_No_Exception_Propagation_Active (N : Node_Id) is begin Error_Msg_N ("?X?pragma Restrictions (No_Exception_Propagation) in effect", N); end Warn_No_Exception_Propagation_Active; end Exp_Ch11;
with CLIC.Subcommand; with Commands; with Ada.Text_IO; with CLIC.TTY; with Version; with Ada.Exceptions; use Ada.Exceptions; procedure Glad is begin Ada.Text_IO.New_Line; Commands.Execute; exception when E : others => Ada.Text_IO.Put_Line(Exception_Message (E)); end Glad;
package Signed_Integer_Type_Definition is type Type_1 is range 0..10; end Signed_Integer_Type_Definition;
-- Abstract : -- -- See spec. -- -- Copyright (C) 2018 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, 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 MERCHAN- -- TABILITY 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. pragma License (Modified_GPL); with Ada.Containers; with Ada.Text_IO; with SAL.Generic_Decimal_Image; package body WisiToken.Syntax_Trees is -- Body specs, alphabetical, as needed function Image (Tree : in Syntax_Trees.Tree; N : in Syntax_Trees.Node; Descriptor : in WisiToken.Descriptor; Include_Children : in Boolean; Include_RHS_Index : in Boolean := False) return String; function Min (Item : in Valid_Node_Index_Array) return Valid_Node_Index; procedure Move_Branch_Point (Tree : in out Syntax_Trees.Tree; Required_Node : in Valid_Node_Index); type Visit_Parent_Mode is (Before, After); function Process_Tree (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Visit_Parent : in Visit_Parent_Mode; Process_Node : access function (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean) return Boolean; -- Call Process_Node on nodes in tree rooted at Node. Return when -- Process_Node returns False (Process_Tree returns False), or when -- all nodes have been processed (Process_Tree returns True). procedure Set_Children (Nodes : in out Node_Arrays.Vector; Parent : in Valid_Node_Index; Children : in Valid_Node_Index_Array); ---------- -- Public and body operations, alphabetical function Action (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Semantic_Action is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Action else Tree.Branched_Nodes (Node).Action); end Action; procedure Add_Child (Tree : in out Syntax_Trees.Tree; Parent : in Valid_Node_Index; Child : in Valid_Node_Index) is Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Parent); begin Node.Children.Append (Child); -- We don't update Min/Max_terminal_index; they are no longer needed. end Add_Child; function Add_Identifier (Tree : in out Syntax_Trees.Tree; ID : in Token_ID; Identifier : in Identifier_Index; Byte_Region : in WisiToken.Buffer_Region) return Valid_Node_Index is begin Tree.Shared_Tree.Nodes.Append ((Label => Virtual_Identifier, Byte_Region => Byte_Region, ID => ID, Identifier => Identifier, others => <>)); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; return Tree.Last_Shared_Node; end Add_Identifier; function Add_Nonterm (Tree : in out Syntax_Trees.Tree; Production : in WisiToken.Production_ID; Children : in Valid_Node_Index_Array; Action : in Semantic_Action := null; Default_Virtual : in Boolean := False) return Valid_Node_Index is Nonterm_Node : Valid_Node_Index; begin if Tree.Flush then Tree.Shared_Tree.Nodes.Append ((Label => Syntax_Trees.Nonterm, ID => Production.LHS, Action => Action, RHS_Index => Production.RHS, Virtual => (if Children'Length = 0 then Default_Virtual else False), others => <>)); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; Nonterm_Node := Tree.Last_Shared_Node; else Tree.Branched_Nodes.Append ((Label => Syntax_Trees.Nonterm, ID => Production.LHS, Action => Action, RHS_Index => Production.RHS, Virtual => (if Children'Length = 0 then Default_Virtual else False), others => <>)); Nonterm_Node := Tree.Branched_Nodes.Last_Index; end if; if Children'Length = 0 then return Nonterm_Node; end if; if Tree.Flush then Set_Children (Tree.Shared_Tree.Nodes, Nonterm_Node, Children); else declare Min_Child_Node : constant Valid_Node_Index := Min (Children); begin if Min_Child_Node <= Tree.Last_Shared_Node then Move_Branch_Point (Tree, Min_Child_Node); end if; end; Set_Children (Tree.Branched_Nodes, Nonterm_Node, Children); end if; return Nonterm_Node; end Add_Nonterm; function Add_Terminal (Tree : in out Syntax_Trees.Tree; Terminal : in Token_Index; Terminals : in Base_Token_Arrays.Vector) return Valid_Node_Index is begin if Tree.Flush then Tree.Shared_Tree.Nodes.Append ((Label => Shared_Terminal, ID => Terminals (Terminal).ID, Byte_Region => Terminals (Terminal).Byte_Region, Terminal => Terminal, others => <>)); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; return Tree.Last_Shared_Node; else Tree.Branched_Nodes.Append ((Label => Shared_Terminal, ID => Terminals (Terminal).ID, Byte_Region => Terminals (Terminal).Byte_Region, Terminal => Terminal, others => <>)); return Tree.Branched_Nodes.Last_Index; end if; end Add_Terminal; function Add_Terminal (Tree : in out Syntax_Trees.Tree; Terminal : in Token_ID) return Valid_Node_Index is begin if Tree.Flush then Tree.Shared_Tree.Nodes.Append ((Label => Virtual_Terminal, ID => Terminal, others => <>)); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; return Tree.Last_Shared_Node; else Tree.Branched_Nodes.Append ((Label => Virtual_Terminal, ID => Terminal, others => <>)); return Tree.Branched_Nodes.Last_Index; end if; end Add_Terminal; function Augmented (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Class_Access is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Augmented; else return Tree.Branched_Nodes (Node).Augmented; end if; end Augmented; function Byte_Region (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return WisiToken.Buffer_Region is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Byte_Region else Tree.Branched_Nodes (Node).Byte_Region); end Byte_Region; function Child (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Child_Index : in Positive_Index_Type) return Node_Index is function Compute (N : in Syntax_Trees.Node) return Node_Index is begin if N.Label /= Nonterm then return Invalid_Node_Index; elsif Child_Index in N.Children.First_Index .. N.Children.Last_Index then return N.Children (Child_Index); else return Invalid_Node_Index; end if; end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Child; function Children (N : in Syntax_Trees.Node) return Valid_Node_Index_Array is begin if N.Children.Length = 0 then return (1 .. 0 => <>); else return Result : Valid_Node_Index_Array (N.Children.First_Index .. N.Children.Last_Index) do for I in Result'Range loop Result (I) := N.Children (I); end loop; end return; end if; end Children; function Children (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Valid_Node_Index_Array is begin if Node <= Tree.Last_Shared_Node then return Children (Tree.Shared_Tree.Nodes (Node)); else return Children (Tree.Branched_Nodes (Node)); end if; end Children; procedure Clear (Tree : in out Syntax_Trees.Base_Tree) is begin Tree.Finalize; end Clear; procedure Clear (Tree : in out Syntax_Trees.Tree) is begin if Tree.Shared_Tree.Augmented_Present then for Node of Tree.Branched_Nodes loop if Node.Label = Nonterm then Free (Node.Augmented); end if; end loop; end if; Tree.Shared_Tree.Finalize; Tree.Last_Shared_Node := Invalid_Node_Index; Tree.Branched_Nodes.Clear; end Clear; function Copy_Subtree (Tree : in out Syntax_Trees.Tree; Root : in Valid_Node_Index; Last : in Valid_Node_Index) return Valid_Node_Index is function Copy_Node (Tree : in out Syntax_Trees.Tree; Index : in Valid_Node_Index; Parent : in Node_Index) return Valid_Node_Index is begin case Tree.Shared_Tree.Nodes (Index).Label is when Shared_Terminal => declare Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Index); begin Tree.Shared_Tree.Nodes.Append ((Label => Shared_Terminal, ID => Node.ID, Byte_Region => Node.Byte_Region, Parent => Parent, State => Unknown_State, Terminal => Node.Terminal)); end; when Virtual_Terminal => declare Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Index); begin Tree.Shared_Tree.Nodes.Append ((Label => Virtual_Terminal, ID => Node.ID, Byte_Region => Node.Byte_Region, Parent => Parent, State => Unknown_State)); end; when Virtual_Identifier => declare Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Index); begin Tree.Shared_Tree.Nodes.Append ((Label => Virtual_Identifier, ID => Node.ID, Byte_Region => Node.Byte_Region, Parent => Parent, State => Unknown_State, Identifier => Node.Identifier)); end; when Nonterm => declare Children : constant Valid_Node_Index_Array := Tree.Children (Index); Parent : Node_Index := Invalid_Node_Index; New_Children : Valid_Node_Index_Arrays.Vector; begin if Children'Length > 0 then declare use all type SAL.Base_Peek_Type; Last_Index : SAL.Base_Peek_Type := SAL.Base_Peek_Type'Last; begin for I in Children'Range loop if Children (I) = Last then Last_Index := I; end if; end loop; if Last_Index = SAL.Base_Peek_Type'Last then New_Children.Set_First_Last (Children'First, Children'Last); for I in Children'Range loop New_Children (I) := Copy_Node (Tree, Children (I), Parent); end loop; else for I in Last_Index .. Children'Last loop New_Children.Append (Copy_Node (Tree, Children (I), Parent)); end loop; end if; end; end if; declare Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Index); begin Tree.Shared_Tree.Nodes.Append ((Label => Nonterm, ID => Node.ID, Byte_Region => Node.Byte_Region, Parent => Parent, State => Unknown_State, Virtual => Node.Virtual, RHS_Index => Node.RHS_Index, Action => Node.Action, Name => Node.Name, Children => New_Children, Min_Terminal_Index => Node.Min_Terminal_Index, Max_Terminal_Index => Node.Max_Terminal_Index, Augmented => Node.Augmented)); end; Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; Parent := Tree.Last_Shared_Node; for I in New_Children.First_Index .. New_Children.Last_Index loop Tree.Shared_Tree.Nodes (New_Children (I)).Parent := Parent; end loop; return Parent; end; end case; Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; return Tree.Last_Shared_Node; end Copy_Node; begin return Copy_Node (Tree, Root, Invalid_Node_Index); end Copy_Subtree; function Count_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return SAL.Base_Peek_Type is function Compute (N : in Syntax_Trees.Node) return SAL.Base_Peek_Type is use all type SAL.Base_Peek_Type; begin return Result : SAL.Base_Peek_Type := 0 do if N.ID = ID then Result := 1; end if; case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => null; when Nonterm => for I of N.Children loop Result := Result + Count_IDs (Tree, I, ID); end loop; end case; end return; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Count_IDs; function Count_Terminals (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Integer -- Count_Terminals must return Integer for Get_Terminals, -- Positive_Index_Type for Get_Terminal_IDs. is function Compute (N : in Syntax_Trees.Node) return Integer is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return 1; when Nonterm => return Result : Integer := 0 do for I of N.Children loop Result := Result + Count_Terminals (Tree, I); end loop; end return; end case; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Count_Terminals; overriding procedure Finalize (Tree : in out Base_Tree) is begin Tree.Traversing := False; if Tree.Augmented_Present then for Node of Tree.Nodes loop if Node.Label = Nonterm then Free (Node.Augmented); end if; end loop; Tree.Augmented_Present := False; end if; Tree.Nodes.Finalize; end Finalize; overriding procedure Finalize (Tree : in out Syntax_Trees.Tree) is begin if Tree.Last_Shared_Node /= Invalid_Node_Index then if Tree.Shared_Tree.Augmented_Present then for Node of Tree.Branched_Nodes loop Free (Node.Augmented); end loop; -- We don't clear Tree.Shared_Tree.Augmented_Present here; other -- branched trees may need to be finalized. end if; Tree.Branched_Nodes.Finalize; Tree.Last_Shared_Node := Invalid_Node_Index; Tree.Shared_Tree := null; end if; end Finalize; function Find_Ancestor (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Node_Index is N : Node_Index := Node; begin loop N := (if N <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (N).Parent else Tree.Branched_Nodes (N).Parent); exit when N = Invalid_Node_Index; exit when ID = (if N <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (N).ID else Tree.Branched_Nodes (N).ID); end loop; return N; end Find_Ancestor; function Find_Ancestor (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; IDs : in Token_ID_Array) return Node_Index is N : Node_Index := Node; begin loop N := (if N <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (N).Parent else Tree.Branched_Nodes (N).Parent); exit when N = Invalid_Node_Index; exit when (for some ID of IDs => ID = (if N <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (N).ID else Tree.Branched_Nodes (N).ID)); end loop; return N; end Find_Ancestor; function Find_Child (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Node_Index is function Compute (N : in Syntax_Trees.Node) return Node_Index is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Invalid_Node_Index; when Nonterm => for C of N.Children loop if ID = (if C <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (C).ID else Tree.Branched_Nodes (C).ID) then return C; end if; end loop; return Invalid_Node_Index; end case; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Find_Child; function Find_Descendant (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Node_Index is Found : Node_Index := Invalid_Node_Index; function Process (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is Node_ID : constant Token_ID := (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).ID else Tree.Branched_Nodes (Node).ID); begin if Node_ID = ID then Found := Node; return False; else return True; end if; end Process; Junk : constant Boolean := Process_Tree (Tree, Node, Before, Process'Access); pragma Unreferenced (Junk); begin return Found; end Find_Descendant; function Find_Descendant (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Predicate : access function (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean) return Node_Index is Found : Node_Index := Invalid_Node_Index; function Process (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Predicate (Tree, Node) then Found := Node; return False; else return True; end if; end Process; Junk : constant Boolean := Process_Tree (Tree, Node, Before, Process'Access); pragma Unreferenced (Junk); begin return Found; end Find_Descendant; function Find_Min_Terminal_Index (Tree : in Syntax_Trees.Tree; Index : in Token_Index) return Node_Index is Found : Node_Index := Invalid_Node_Index; function Process (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is function Compute (N : in Syntax_Trees.Node) return Boolean is begin if N.Label /= Nonterm then return True; elsif Index = N.Min_Terminal_Index then Found := Node; return False; else return True; end if; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Process; Junk : constant Boolean := Process_Tree (Tree, Tree.Root, Before, Process'Access); pragma Unreferenced (Junk); begin return Found; end Find_Min_Terminal_Index; function Find_Max_Terminal_Index (Tree : in Syntax_Trees.Tree; Index : in Token_Index) return Node_Index is Found : Node_Index := Invalid_Node_Index; function Process (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is function Compute (N : in Syntax_Trees.Node) return Boolean is begin if N.Label /= Nonterm then return True; elsif Index = N.Max_Terminal_Index then Found := Node; return False; else return True; end if; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Process; Junk : constant Boolean := Process_Tree (Tree, Tree.Root, Before, Process'Access); pragma Unreferenced (Junk); begin return Found; end Find_Max_Terminal_Index; function Find_Sibling (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Node_Index is function Compute_2 (N : in Syntax_Trees.Node) return Node_Index is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Invalid_Node_Index; when Nonterm => for C of N.Children loop if ID = (if C <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (C).ID else Tree.Branched_Nodes (C).ID) then return C; end if; end loop; return Invalid_Node_Index; end case; end Compute_2; function Compute_1 (Parent : in Node_Index) return Node_Index is begin if Parent = Invalid_Node_Index then return Invalid_Node_Index; else return Compute_2 ((if Parent <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Parent) else Tree.Branched_Nodes (Parent))); end if; end Compute_1; begin return Compute_1 ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Parent else Tree.Branched_Nodes (Node).Parent)); end Find_Sibling; function First_Index (Tree : in Syntax_Trees.Tree) return Node_Index is begin return Tree.Shared_Tree.Nodes.First_Index; end First_Index; procedure Flush (Tree : in out Syntax_Trees.Tree) is begin -- This is the opposite of Move_Branch_Point Tree.Shared_Tree.Nodes.Merge (Tree.Branched_Nodes); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; Tree.Flush := True; end Flush; function Flushed (Tree : in Syntax_Trees.Tree) return Boolean is begin return Tree.Flush; end Flushed; procedure Get_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID; Result : in out Valid_Node_Index_Array; Last : in out SAL.Base_Peek_Type) is use all type SAL.Base_Peek_Type; procedure Compute (N : in Syntax_Trees.Node) is begin if N.ID = ID then Last := Last + 1; Result (Last) := Node; end if; case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => null; when Nonterm => for I of N.Children loop Get_IDs (Tree, I, ID, Result, Last); end loop; end case; end Compute; begin Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Get_IDs; function Get_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Valid_Node_Index_Array is Last : SAL.Base_Peek_Type := 0; begin Tree.Shared_Tree.Traversing := True; return Result : Valid_Node_Index_Array (1 .. Count_IDs (Tree, Node, ID)) do Get_IDs (Tree, Node, ID, Result, Last); Tree.Shared_Tree.Traversing := False; end return; end Get_IDs; procedure Get_Terminals (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Result : in out Valid_Node_Index_Array; Last : in out SAL.Base_Peek_Type) is use all type SAL.Base_Peek_Type; procedure Compute (N : in Syntax_Trees.Node) is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => Last := Last + 1; Result (Last) := Node; when Nonterm => for I of N.Children loop Get_Terminals (Tree, I, Result, Last); end loop; end case; end Compute; begin Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Get_Terminals; function Get_Terminals (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Valid_Node_Index_Array is Last : SAL.Base_Peek_Type := 0; begin Tree.Shared_Tree.Traversing := True; return Result : Valid_Node_Index_Array (1 .. SAL.Base_Peek_Type (Count_Terminals (Tree, Node))) do Get_Terminals (Tree, Node, Result, Last); Tree.Shared_Tree.Traversing := False; end return; end Get_Terminals; procedure Get_Terminal_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Result : in out Token_ID_Array; Last : in out SAL.Base_Peek_Type) is procedure Compute (N : in Syntax_Trees.Node) is use all type SAL.Base_Peek_Type; begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => Last := Last + 1; Result (Integer (Last)) := N.ID; when Nonterm => for I of N.Children loop Get_Terminal_IDs (Tree, I, Result, Last); end loop; end case; end Compute; begin Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Get_Terminal_IDs; function Get_Terminal_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Token_ID_Array is Last : SAL.Base_Peek_Type := 0; begin Tree.Shared_Tree.Traversing := True; return Result : Token_ID_Array (1 .. Count_Terminals (Tree, Node)) do Get_Terminal_IDs (Tree, Node, Result, Last); Tree.Shared_Tree.Traversing := False; end return; end Get_Terminal_IDs; function First_Terminal_ID (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Token_ID is function Compute (N : in Syntax_Trees.Node) return Token_ID is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return N.ID; when Nonterm => return First_Terminal_ID (Tree, N.Children (1)); end case; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end First_Terminal_ID; function Has_Branched_Nodes (Tree : in Syntax_Trees.Tree) return Boolean is begin return Tree.Branched_Nodes.Length > 0; end Has_Branched_Nodes; function Has_Children (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Children.Length > 0; else return Tree.Branched_Nodes (Node).Children.Length > 0; end if; end Has_Children; function Has_Parent (Tree : in Syntax_Trees.Tree; Child : in Valid_Node_Index) return Boolean is begin return (if Child <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Child).Parent /= Invalid_Node_Index else Tree.Branched_Nodes (Child).Parent /= Invalid_Node_Index); end Has_Parent; function Has_Parent (Tree : in Syntax_Trees.Tree; Children : in Valid_Node_Index_Array) return Boolean is begin return (for some Child of Children => (if Child <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Child).Parent /= Invalid_Node_Index else Tree.Branched_Nodes (Child).Parent /= Invalid_Node_Index)); end Has_Parent; function ID (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Token_ID is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).ID else Tree.Branched_Nodes (Node).ID); end ID; function Identifier (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Identifier_Index is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Identifier else Tree.Branched_Nodes (Node).Identifier); end Identifier; function Image (Tree : in Syntax_Trees.Tree; Children : in Valid_Node_Index_Arrays.Vector; Descriptor : in WisiToken.Descriptor) return String is use Ada.Strings.Unbounded; Result : Unbounded_String := +"("; Need_Comma : Boolean := False; begin for I of Children loop Result := Result & (if Need_Comma then ", " else "") & Tree.Image (I, Descriptor, Include_Children => False); Need_Comma := True; end loop; Result := Result & ")"; return -Result; end Image; function Image (Tree : in Syntax_Trees.Tree; N : in Syntax_Trees.Node; Descriptor : in WisiToken.Descriptor; Include_Children : in Boolean; Include_RHS_Index : in Boolean := False) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; begin if Include_Children and N.Label = Nonterm then Result := +Image (N.ID, Descriptor) & '_' & Trimmed_Image (N.RHS_Index) & ": "; end if; case N.Label is when Shared_Terminal => Result := Result & (+Token_Index'Image (N.Terminal)) & ":"; when Virtual_Identifier => Result := Result & (+Identifier_Index'Image (N.Identifier)) & ";"; when others => null; end case; Result := Result & "(" & Image (N.ID, Descriptor) & (if Include_RHS_Index and N.Label = Nonterm then "_" & Trimmed_Image (N.RHS_Index) else "") & (if N.Byte_Region = Null_Buffer_Region then "" else ", " & Image (N.Byte_Region)) & ")"; if Include_Children and N.Label = Nonterm then Result := Result & " <= " & Image (Tree, N.Children, Descriptor); end if; return -Result; end Image; function Image (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Descriptor : in WisiToken.Descriptor; Include_Children : in Boolean := False) return String is begin return Tree.Image ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node)), Descriptor, Include_Children); end Image; function Image (Tree : in Syntax_Trees.Tree; Nodes : in Valid_Node_Index_Array; Descriptor : in WisiToken.Descriptor) return String is use Ada.Strings.Unbounded; Result : Unbounded_String := +"("; Need_Comma : Boolean := False; begin for I in Nodes'Range loop Result := Result & (if Need_Comma then ", " else "") & Tree.Image (Nodes (I), Descriptor, Include_Children => False); Need_Comma := True; end loop; Result := Result & ")"; return -Result; end Image; function Image (Item : in Node_Sets.Vector; Inverted : in Boolean := False) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; begin for I in Item.First_Index .. Item.Last_Index loop if (if Inverted then not Item (I) else Item (I)) then Result := Result & Node_Index'Image (I); end if; end loop; return -Result; end Image; procedure Initialize (Branched_Tree : in out Syntax_Trees.Tree; Shared_Tree : in Base_Tree_Access; Flush : in Boolean) is begin Branched_Tree := (Ada.Finalization.Controlled with Shared_Tree => Shared_Tree, Last_Shared_Node => Shared_Tree.Nodes.Last_Index, Branched_Nodes => <>, Flush => Flush, Root => <>); end Initialize; function Is_Empty (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Byte_Region = Null_Buffer_Region; else return Tree.Branched_Nodes (Node).Byte_Region = Null_Buffer_Region; end if; end Is_Empty; function Is_Nonterm (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Label = Nonterm; else return Tree.Branched_Nodes (Node).Label = Nonterm; end if; end Is_Nonterm; function Is_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Label = Shared_Terminal; else return Tree.Branched_Nodes (Node).Label = Shared_Terminal; end if; end Is_Terminal; function Is_Virtual (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is function Compute (N : in Syntax_Trees.Node) return Boolean is begin return N.Label = Virtual_Terminal or (N.Label = Nonterm and then N.Virtual); end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Is_Virtual; function Is_Virtual_Identifier (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Label = Virtual_Identifier else Tree.Branched_Nodes (Node).Label = Virtual_Identifier); end Is_Virtual_Identifier; function Label (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Node_Label is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Label; else return Tree.Branched_Nodes (Node).Label; end if; end Label; function Last_Index (Tree : in Syntax_Trees.Tree) return Node_Index is begin return (if Tree.Flush then Tree.Shared_Tree.Nodes.Last_Index else Tree.Branched_Nodes.Last_Index); end Last_Index; function Min (Item : in Valid_Node_Index_Array) return Valid_Node_Index is Result : Node_Index := Item (Item'First); begin for I in Item'Range loop if Item (I) < Result then Result := Item (I); end if; end loop; return Result; end Min; function Min_Descendant (Nodes : in Node_Arrays.Vector; Node : in Valid_Node_Index) return Valid_Node_Index is N : Syntax_Trees.Node renames Nodes (Node); begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Node; when Nonterm => declare Min : Node_Index := Node; begin for C of N.Children loop Min := Node_Index'Min (Min, Min_Descendant (Nodes, C)); end loop; return Min; end; end case; end Min_Descendant; function Min_Terminal_Index (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Index is function Compute (N : in Syntax_Trees.Node) return Base_Token_Index is begin return (case N.Label is when Shared_Terminal => N.Terminal, when Virtual_Terminal | Virtual_Identifier => Invalid_Token_Index, when Nonterm => N.Min_Terminal_Index); end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Min_Terminal_Index; function Max_Terminal_Index (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Index is function Compute (N : in Syntax_Trees.Node) return Base_Token_Index is begin return (case N.Label is when Shared_Terminal => N.Terminal, when Virtual_Terminal | Virtual_Identifier => Invalid_Token_Index, when Nonterm => N.Max_Terminal_Index); end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Max_Terminal_Index; procedure Move_Branch_Point (Tree : in out Syntax_Trees.Tree; Required_Node : in Valid_Node_Index) is begin -- Note that this preserves all stored indices in Branched_Nodes. Tree.Branched_Nodes.Prepend (Tree.Shared_Tree.Nodes, Required_Node, Tree.Last_Shared_Node); Tree.Last_Shared_Node := Required_Node - 1; end Move_Branch_Point; function Parent (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Count : in Positive := 1) return Node_Index is Result : Node_Index := Node; N : Natural := 0; begin loop if Result <= Tree.Last_Shared_Node then Result := Tree.Shared_Tree.Nodes (Result).Parent; else Result := Tree.Branched_Nodes (Result).Parent; end if; N := N + 1; exit when N = Count or Result = Invalid_Node_Index; end loop; return Result; end Parent; procedure Print_Tree (Tree : in Syntax_Trees.Tree; Descriptor : in WisiToken.Descriptor; Root : in Node_Index := Invalid_Node_Index) is use Ada.Text_IO; Node_Printed : Node_Sets.Vector; procedure Print_Node (Node : in Valid_Node_Index; Level : in Integer) is function Image is new SAL.Generic_Decimal_Image (Node_Index); N : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Node); begin if Node_Printed (Node) then -- This does not catch all possible tree edit errors, but it does -- catch circles. raise SAL.Programmer_Error with "Print_Tree: invalid tree" & Node_Index'Image (Node); else Node_Printed (Node) := True; end if; Put (Image (Node, Width => 4) & ": "); for I in 1 .. Level loop Put ("| "); end loop; Put_Line (Image (Tree, N, Descriptor, Include_Children => False, Include_RHS_Index => True)); if N.Label = Nonterm then for Child of N.Children loop Print_Node (Child, Level + 1); end loop; end if; end Print_Node; begin Node_Printed.Set_First_Last (Tree.First_Index, Tree.Last_Index); Print_Node ((if Root = Invalid_Node_Index then Tree.Root else Root), 0); end Print_Tree; function Process_Tree (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Visit_Parent : in Visit_Parent_Mode; Process_Node : access function (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean) return Boolean is function Compute (N : in Syntax_Trees.Node) return Boolean is begin if Visit_Parent = Before then if not Process_Node (Tree, Node) then return False; end if; end if; if N.Label = Nonterm then for Child of N.Children loop if not Process_Tree (Tree, Child, Visit_Parent, Process_Node) then return False; end if; end loop; end if; if Visit_Parent = After then return Process_Node (Tree, Node); else return True; end if; end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Process_Tree; procedure Process_Tree (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; Process_Node : access procedure (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index)) is procedure Compute (N : in Syntax_Trees.Node) is begin if N.Label = Nonterm then for Child of N.Children loop Process_Tree (Tree, Child, Process_Node); end loop; end if; Process_Node (Tree, Node); end Compute; begin if Node <= Tree.Last_Shared_Node then Compute (Tree.Shared_Tree.Nodes (Node)); else Compute (Tree.Branched_Nodes (Node)); end if; end Process_Tree; procedure Process_Tree (Tree : in out Syntax_Trees.Tree; Process_Node : access procedure (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index); Root : in Node_Index := Invalid_Node_Index) is begin if Root = Invalid_Node_Index and Tree.Root = Invalid_Node_Index then raise SAL.Programmer_Error with "Tree.Root not set"; end if; Tree.Shared_Tree.Traversing := True; Process_Tree (Tree, (if Root = Invalid_Node_Index then Tree.Root else Root), Process_Node); Tree.Shared_Tree.Traversing := False; exception when others => Tree.Shared_Tree.Traversing := False; raise; end Process_Tree; function Production_ID (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return WisiToken.Production_ID is begin return (if Node <= Tree.Last_Shared_Node then (Tree.Shared_Tree.Nodes (Node).ID, Tree.Shared_Tree.Nodes (Node).RHS_Index) else (Tree.Branched_Nodes (Node).ID, Tree.Branched_Nodes (Node).RHS_Index)); end Production_ID; function RHS_Index (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Natural is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).RHS_Index else Tree.Branched_Nodes (Node).RHS_Index); end RHS_Index; procedure Set_Node_Identifier (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID; Identifier : in Identifier_Index) is Current : constant Syntax_Trees.Node := Tree.Shared_Tree.Nodes (Node); begin Tree.Shared_Tree.Nodes.Replace_Element (Node, (Label => Virtual_Identifier, ID => ID, Identifier => Identifier, Byte_Region => Current.Byte_Region, Parent => Current.Parent, State => Unknown_State)); end Set_Node_Identifier; procedure Set_Root (Tree : in out Syntax_Trees.Tree; Root : in Valid_Node_Index) is begin Tree.Root := Root; end Set_Root; function Root (Tree : in Syntax_Trees.Tree) return Node_Index is begin if Tree.Root /= Invalid_Node_Index then return Tree.Root; else if Tree.Flush then return Tree.Shared_Tree.Nodes.Last_Index; else return Tree.Branched_Nodes.Last_Index; end if; end if; end Root; function Same_Token (Tree_1 : in Syntax_Trees.Tree'Class; Index_1 : in Valid_Node_Index; Tree_2 : in Syntax_Trees.Tree'Class; Index_2 : in Valid_Node_Index) return Boolean is function Compute (N_1, N_2 : in Syntax_Trees.Node) return Boolean is begin return N_1.Label = N_2.Label and N_1.ID = N_2.ID and N_1.Byte_Region = N_2.Byte_Region; end Compute; begin return Compute ((if Index_1 <= Tree_1.Last_Shared_Node then Tree_1.Shared_Tree.Nodes (Index_1) else Tree_1.Branched_Nodes (Index_1)), (if Index_2 <= Tree_2.Last_Shared_Node then Tree_2.Shared_Tree.Nodes (Index_2) else Tree_2.Branched_Nodes (Index_2))); end Same_Token; procedure Set_Augmented (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; Value : in Base_Token_Class_Access) is begin if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Augmented := Value; else Tree.Branched_Nodes (Node).Augmented := Value; end if; Tree.Shared_Tree.Augmented_Present := True; end Set_Augmented; procedure Set_Children (Nodes : in out Node_Arrays.Vector; Parent : in Valid_Node_Index; Children : in Valid_Node_Index_Array) is use all type SAL.Base_Peek_Type; N : Nonterm_Node renames Nodes (Parent); J : Positive_Index_Type := Positive_Index_Type'First; Min_Terminal_Index_Set : Boolean := False; begin N.Children.Set_First_Last (Children'First, Children'Last); for I in Children'Range loop N.Children (J) := Children (I); declare K : Node renames Nodes (Children (I)); begin K.Parent := Parent; N.Virtual := N.Virtual or (case K.Label is when Shared_Terminal => False, when Virtual_Terminal | Virtual_Identifier => True, when Nonterm => K.Virtual); if N.Byte_Region.First > K.Byte_Region.First then N.Byte_Region.First := K.Byte_Region.First; end if; if N.Byte_Region.Last < K.Byte_Region.Last then N.Byte_Region.Last := K.Byte_Region.Last; end if; if not Min_Terminal_Index_Set then case K.Label is when Shared_Terminal => Min_Terminal_Index_Set := True; N.Min_Terminal_Index := K.Terminal; when Virtual_Terminal | Virtual_Identifier => null; when Nonterm => if K.Min_Terminal_Index /= Invalid_Token_Index then -- not an empty nonterm Min_Terminal_Index_Set := True; N.Min_Terminal_Index := K.Min_Terminal_Index; end if; end case; end if; case K.Label is when Shared_Terminal => if N.Max_Terminal_Index < K.Terminal then N.Max_Terminal_Index := K.Terminal; end if; when Virtual_Terminal | Virtual_Identifier => null; when Nonterm => if K.Max_Terminal_Index /= Invalid_Token_Index and then -- not an empty nonterm N.Max_Terminal_Index < K.Max_Terminal_Index then N.Max_Terminal_Index := K.Max_Terminal_Index; end if; end case; end; J := J + 1; end loop; end Set_Children; procedure Set_Children (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; New_ID : in WisiToken.Production_ID; Children : in Valid_Node_Index_Array) is use all type SAL.Base_Peek_Type; Parent_Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Node); J : Positive_Index_Type := Positive_Index_Type'First; begin Parent_Node.ID := New_ID.LHS; Parent_Node.RHS_Index := New_ID.RHS; Parent_Node.Action := null; Parent_Node.Children.Set_First_Last (Children'First, Children'Last); for I in Children'Range loop -- We don't update Min/Max_terminal_index; we assume Set_Children is -- only called after parsing is done, so they are no longer needed. Parent_Node.Children (J) := Children (I); Tree.Shared_Tree.Nodes (Children (I)).Parent := Node; J := J + 1; end loop; end Set_Children; procedure Set_State (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; State : in State_Index) is begin if Tree.Flush then Tree.Shared_Tree.Nodes (Node).State := State; else if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).State := State; else Tree.Branched_Nodes (Node).State := State; end if; end if; end Set_State; procedure Set_Flush_False (Tree : in out Syntax_Trees.Tree) is begin if Tree.Flush then Tree.Flush := False; Tree.Branched_Nodes.Set_First_Last (Tree.Last_Shared_Node + 1, Tree.Last_Shared_Node); end if; end Set_Flush_False; procedure Set_Name_Region (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; Region : in Buffer_Region) is begin if Tree.Flush then Tree.Shared_Tree.Nodes (Node).Name := Region; else if Node <= Tree.Last_Shared_Node then Move_Branch_Point (Tree, Node); end if; Tree.Branched_Nodes (Node).Name := Region; end if; end Set_Name_Region; function Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Index is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Terminal; else return Tree.Branched_Nodes (Node).Terminal; end if; end Terminal; function Traversing (Tree : in Syntax_Trees.Tree) return Boolean is begin return Tree.Shared_Tree.Traversing; end Traversing; function Recover_Token (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return WisiToken.Recover_Token is function Compute (N : Syntax_Trees.Node) return WisiToken.Recover_Token is begin case N.Label is when Shared_Terminal => return (ID => N.ID, Byte_Region => N.Byte_Region, Min_Terminal_Index => N.Terminal, Name => Null_Buffer_Region, Virtual => False); when Virtual_Terminal | Virtual_Identifier => return (ID => N.ID, Byte_Region => Null_Buffer_Region, Min_Terminal_Index => Invalid_Token_Index, Name => Null_Buffer_Region, Virtual => True); when Nonterm => return (ID => N.ID, Byte_Region => N.Byte_Region, Min_Terminal_Index => N.Min_Terminal_Index, Name => N.Name, Virtual => N.Virtual); end case; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Recover_Token; function Recover_Token_Array (Tree : in Syntax_Trees.Tree; Nodes : in Valid_Node_Index_Array) return WisiToken.Recover_Token_Array is begin return Result : WisiToken.Recover_Token_Array (Nodes'First .. Nodes'Last) do for I in Result'Range loop Result (I) := Tree.Recover_Token (Nodes (I)); end loop; end return; end Recover_Token_Array; function State (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Unknown_State_Index is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).State; else return Tree.Branched_Nodes (Node).State; end if; end State; end WisiToken.Syntax_Trees;
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <Heziode@protonmail.com> -- -- 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. ------------------------------------------------------------------------------- package body LSE.Model.L_System.Error.Missing_Angle is function Initialize return Instance is begin return Instance '(Error => Error_Type.Missing_Angle); end Initialize; function Get_Error (This : Instance) return String is pragma Unreferenced (This); begin return "Angle not found"; end Get_Error; end LSE.Model.L_System.Error.Missing_Angle;
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_poly_point_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; coordinate_mode : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; drawable : aliased xcb.xcb_drawable_t; gc : aliased xcb.xcb_gcontext_t; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_poly_point_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_poly_point_request_t.Item, Element_Array => xcb.xcb_poly_point_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_poly_point_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_poly_point_request_t.Pointer, Element_Array => xcb.xcb_poly_point_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_poly_point_request_t;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . I M G _ I N T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routines for supporting the Image attribute for -- signed integer types up to Size Integer'Size, and also for conversion -- operations required in Text_IO.Integer_IO for such types. package System.Img_Int is pragma Pure; procedure Image_Integer (V : Integer; S : in out String; P : out Natural); -- Computes Integer'Image (V) and stores the result in S (1 .. P) -- setting the resulting value of P. The caller guarantees that S -- is long enough to hold the result, and that S'First is 1. procedure Set_Image_Integer (V : Integer; S : in out String; P : in out Natural); -- Stores the image of V in S starting at S (P + 1), P is updated to point -- to the last character stored. The value stored is identical to the value -- of Integer'Image (V) except that no leading space is stored when V is -- non-negative. The caller guarantees that S is long enough to hold the -- result. S need not have a lower bound of 1. end System.Img_Int;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Formal_Type_Definitions; with Program.Lexical_Elements; package Program.Elements.Formal_Discrete_Type_Definitions is pragma Pure (Program.Elements.Formal_Discrete_Type_Definitions); type Formal_Discrete_Type_Definition is limited interface and Program.Elements.Formal_Type_Definitions.Formal_Type_Definition; type Formal_Discrete_Type_Definition_Access is access all Formal_Discrete_Type_Definition'Class with Storage_Size => 0; type Formal_Discrete_Type_Definition_Text is limited interface; type Formal_Discrete_Type_Definition_Text_Access is access all Formal_Discrete_Type_Definition_Text'Class with Storage_Size => 0; not overriding function To_Formal_Discrete_Type_Definition_Text (Self : aliased in out Formal_Discrete_Type_Definition) return Formal_Discrete_Type_Definition_Text_Access is abstract; not overriding function Left_Bracket_Token (Self : Formal_Discrete_Type_Definition_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Box_Token (Self : Formal_Discrete_Type_Definition_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Right_Bracket_Token (Self : Formal_Discrete_Type_Definition_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Formal_Discrete_Type_Definitions;
with Ada.Numerics, Ada.Numerics.Elementary_Functions; package body PolyPaver.Floats is function Eps_Abs return Float is begin return 0.5**126; end Eps_Abs; function Eps_Rel return Float is begin return 0.5**22; end Eps_Rel; function Pi return Float is begin return Ada.Numerics.Pi; end Pi; function Add (X,Y : Float) return Float is begin return X+Y; end Add; function Subtract (X,Y : Float) return Float is begin return X-Y; end Subtract; function Multiply (X,Y : Float) return Float is begin return X*Y; end Multiply; function Divide (X,Y : Float) return Float is begin return X/Y; end Divide; function Square (X : Float) return Float is begin return X*X; end Square; function Sqrt (X : Float) return Float is begin return Ada.Numerics.Elementary_Functions.Sqrt(X); end Sqrt; function Exp (X : Float) return Float is begin return Ada.Numerics.Elementary_Functions.Exp(X); end Exp; function Sin (X : Float) return Float is begin return Ada.Numerics.Elementary_Functions.Sin(X); end Sin; function Cos (X : Float) return Float is begin return Ada.Numerics.Elementary_Functions.Cos(X); end Cos; end PolyPaver.Floats;
-- Initially based on stm32f7xx_hal_sd.h -- V1.0.4 -- 09-December-2015 -- -- SDCard driver. Controls the SDMMC peripheral. with System; with STM32_SVD.SDMMC; use STM32_SVD.SDMMC; with STM32.DMA; package STM32.SDMMC is type SDMMC_Controller is private; function As_Controller (Periph : access STM32_SVD.SDMMC.SDMMC1_Peripheral) return SDMMC_Controller; type SD_Error is (OK, Error, Timeout_Error, Unsupported_Card, Rx_Overrun, Tx_Underrun, Startbit_Not_Detected, Request_Not_Applicable, CRC_Check_Fail, Illegal_Cmd, Address_Out_Of_Range, Address_Missaligned, Block_Length_Error, Erase_Seq_Error, Bad_Erase_Parameter, Write_Protection_Violation, Lock_Unlock_Failed, Card_ECC_Failed, Card_ECC_Disabled, CC_Error, General_Unknown_Error, Stream_Read_Underrun, Stream_Write_Underrun, CID_CSD_Overwrite, WP_Erase_Skip, Erase_Reset, AKE_SEQ_Error, Invalid_Voltage_Range, DMA_Alignment_Error); type Supported_SD_Memory_Cards is (STD_Capacity_SD_Card_V1_1, STD_Capacity_SD_Card_v2_0, High_Capacity_SD_Card, Multimedia_Card, Secure_Digital_IO_Card, High_Speed_Multimedia_Card, Secure_Digital_IO_Combo_Card, High_Capacity_MMC_Card); type Card_Specific_Data_Register is record CSD_Structure : Byte; System_Specification_Version : Byte; Reserved : Byte; Data_Read_Access_Time_1 : Byte; Data_Read_Access_Time_2 : Byte; -- In CLK Cycles Max_Bus_Clock_Frequency : Byte; Card_Command_Class : Short; Max_Read_Data_Block_Length : Byte; Partial_Block_For_Read_Allowed : Boolean; Write_Block_Missalignment : Boolean; Read_Block_Missalignment : Boolean; DSR_Implemented : Boolean; Reserved_2 : Byte; Device_Size : Word; Max_Read_Current_At_VDD_Min : Byte; Max_Read_Current_At_VDD_Max : Byte; Max_Write_Current_At_VDD_Min : Byte; Max_Write_Current_At_VDD_Max : Byte; Device_Size_Multiplier : Byte; Erase_Group_Size : Byte; Erase_Group_Size_Multiplier : Byte; Write_Protect_Group_Size : Byte; Write_Protect_Group_Enable : Boolean; Manufacturer_Default_ECC : Byte; Write_Speed_Factor : Byte; Max_Write_Data_Block_Length : Byte; Partial_Blocks_For_Write_Allowed : Boolean; Reserved_3 : Byte; Content_Protection_Application : Boolean; File_Format_Group : Boolean; Copy_Flag : Boolean; Permanent_Write_Protection : Boolean; Temporary_Write_Protection : Boolean; File_Format : Byte; ECC_Code : Byte; CSD_CRC : Byte; Reserved_4 : Byte; -- Always 1 end record; type Card_Revision is record Major : UInt4; Minor : UInt4; end record with Pack; type Manufacturing_Year is range 2000 .. 2255; type Manufacturing_Month is (January, February, March, April, May, June, July, August, September, October, November, December) with Size => 4; type Manufacturing_Date_Type is record Year : Manufacturing_Year; Month : Manufacturing_Month; end record; type Card_Identification_Data_Register is record Manufacturer_ID : Byte; OEM_Application_ID : String (1 .. 2); Product_Name : String (1 .. 5); Product_Revision : Card_Revision; Product_Serial_Number : Word; Reserved_1 : Byte; Manufacturing_Date : Manufacturing_Date_Type; CID_CRC : Byte; Reserved_2 : Byte; -- Always 1 end record; type Card_Information is record SD_CSD : Card_Specific_Data_Register; SD_CID : Card_Identification_Data_Register; Card_Capacity : Unsigned_64; Card_Block_Size : Unsigned_32; RCA : Short; -- SD relative card address Card_Type : Supported_SD_Memory_Cards := STD_Capacity_SD_Card_V1_1; end record; -- Wide bus mode type Wide_Bus_Mode is ( -- Default bus mode: SDMMC_D0 is used. Wide_Bus_1B, -- 4-wide bus mode: SDMMC_D[3:0] used. Wide_Bus_4B, -- 8-wide bus mode: SDMMC_D[7:0] used. Wide_Bus_8B) with Size => 2; for Wide_Bus_Mode use (Wide_Bus_1B => 0, Wide_Bus_4B => 1, Wide_Bus_8B => 2); function Initialize (Controller : in out SDMMC_Controller; Info : out Card_Information) return SD_Error; function Initialized (Controller : SDMMC_Controller) return Boolean; function Get_Card_Type (Controller : SDMMC_Controller) return Supported_SD_Memory_Cards with Pre => Initialized (Controller); function Configure_Wide_Bus_Mode (Controller : in out SDMMC_Controller; Wide_Mode : Wide_Bus_Mode) return SD_Error; type SD_Data is array (Unsigned_32 range <>) of Byte with Pack; function Read_Blocks (Controller : in out SDMMC_Controller; Addr : Unsigned_64; Data : out SD_Data) return SD_Error with Pre => Data'Length mod 512 = 0; function Read_Blocks_DMA (Controller : in out SDMMC_Controller; Addr : Unsigned_64; DMA : STM32.DMA.DMA_Controller; Stream : STM32.DMA.DMA_Stream_Selector; Data : out SD_Data) return SD_Error with Pre => Data'Length <= 65535; function Write_Blocks_DMA (Controller : in out SDMMC_Controller; Addr : Unsigned_64; DMA : STM32.DMA.DMA_Controller; Stream : STM32.DMA.DMA_Stream_Selector; Data : SD_Data) return SD_Error with Pre => Data'Length <= 65535; function Stop_Transfer (Controller : in out SDMMC_Controller) return SD_Error; function Get_FIFO_Address (Controller : SDMMC_Controller) return System.Address; function Get_Transfer_Status (Controller : in out SDMMC_Controller) return SD_Error; type SDMMC_Flags is (Data_End, Data_CRC_Fail, Data_Timeout, RX_Overrun, TX_Underrun, RX_Active, TX_Active); subtype SDMMC_Clearable_Flags is SDMMC_Flags range Data_End .. TX_Underrun; function Get_Flag (Controller : SDMMC_Controller; Flag : SDMMC_Flags) return Boolean; procedure Clear_Flag (Controller : in out SDMMC_Controller; Flag : SDMMC_Clearable_Flags); procedure Clear_Static_Flags (Controller : in out SDMMC_Controller); type SDMMC_Interrupts is (Data_End_Interrupt, Data_CRC_Fail_Interrupt, Data_Timeout_Interrupt, TX_FIFO_Empty_Interrupt, RX_FIFO_Full_Interrupt, TX_Underrun_Interrupt, RX_Overrun_Interrupt); procedure Enable_Interrupt (Controller : in out SDMMC_Controller; Interrupt : SDMMC_Interrupts); procedure Disable_Interrupt (Controller : in out SDMMC_Controller; Interrupt : SDMMC_Interrupts); type SDMMC_Operation is (No_Operation, Read_Single_Block_Operation, Read_Multiple_Blocks_Operation, Write_Single_Block_Operation, Write_Multiple_Blocks_Operation); function Last_Operation (Controller : SDMMC_Controller) return SDMMC_Operation; private type SDMMC_Command is new Byte; -- Resets the SD memory card Go_Idle_State : constant SDMMC_Command := 0; -- Sends host capacity support information and activates the card's -- initialization process Send_Op_Cond : constant SDMMC_Command := 1; -- Asks any card connected to the host to send the CID numbers on the -- CMD line. All_Send_CID : constant SDMMC_Command := 2; -- Asks the card to publish a new relative address (RCA). Set_Rel_Addr : constant SDMMC_Command := 3; -- Programs the DSR of all cards. Set_DSR : constant SDMMC_Command := 4; -- Sends host capacity support information (HCS) and asks the accessed -- card to send its operating condition register (OCR) content in the -- response on the CMD line. SDMMC_Send_Op_Cond : constant SDMMC_Command := 5; -- Checks switchable function (mode 0) and switch card function (mode -- 1). HS_Switch : constant SDMMC_Command := 6; -- Selects the card by its own relative address and gets deselected by -- any other address Sel_Desel_Card : constant SDMMC_Command := 7; -- Sends SD Memory Card interface condition HS_Send_Ext_CSD : constant SDMMC_Command := 8; -- Addressed card sends its card specific data Send_CSD : constant SDMMC_Command := 9; -- Addressed card sends its card identification (CID) on the CMD line. Send_CID : constant SDMMC_Command := 10; Read_Dat_Until_Stop : constant SDMMC_Command := 11; Stop_Transmission : constant SDMMC_Command := 12; Send_Status : constant SDMMC_Command := 13; HS_Bustest_Read : constant SDMMC_Command := 14; Go_Inactive_State : constant SDMMC_Command := 15; Set_Blocklen : constant SDMMC_Command := 16; Read_Single_Block : constant SDMMC_Command := 17; Read_Multi_Block : constant SDMMC_Command := 18; HS_Bustest_Write : constant SDMMC_Command := 19; Write_Dat_Until_Stop : constant SDMMC_Command := 20; Set_Block_Count : constant SDMMC_Command := 23; -- Only for MMC Write_Single_Block : constant SDMMC_Command := 24; Write_Multi_Block : constant SDMMC_Command := 25; Prog_CID : constant SDMMC_Command := 26; Prog_CSD : constant SDMMC_Command := 27; Set_Write_Prot : constant SDMMC_Command := 28; Clr_Write_Prot : constant SDMMC_Command := 29; Send_Write_Prot : constant SDMMC_Command := 30; SD_Erase_Grp_Start : constant SDMMC_Command := 32; SD_Erase_Grp_End : constant SDMMC_Command := 33; Erase_Grp_Start : constant SDMMC_Command := 35; Erase_Grp_End : constant SDMMC_Command := 36; Erase : constant SDMMC_Command := 38; Fast_IO : constant SDMMC_Command := 39; Go_IRQ_State : constant SDMMC_Command := 40; Lock_Unlock : constant SDMMC_Command := 42; App_Cmd : constant SDMMC_Command := 55; Gen_Cmd : constant SDMMC_Command := 56; No_Cmd : constant SDMMC_Command := 64; -- SD-Card speciric commands -- App_Cmd should be sent before sending these commands subtype SD_Specific_Command is SDMMC_Command; SD_App_Set_Buswidth : constant SD_Specific_Command := 6; SD_App_Status : constant SD_Specific_Command := 13; SD_App_Secure_Read_Multi_Block : constant SD_Specific_Command := 18; SD_App_Send_Num_Write_Blocks : constant SD_Specific_Command := 22; SD_App_Set_Write_Block_Erase_Count : constant SD_Specific_Command := 23; SD_App_Secure_Write_Multi_Block : constant SD_Specific_Command := 25; SD_App_Secure_Erase : constant SD_Specific_Command := 38; SD_App_Op_Cond : constant SD_Specific_Command := 41; SD_App_Get_MKB : constant SD_Specific_Command := 43; SD_App_Get_MID : constant SD_Specific_Command := 44; SD_App_Set_CER_RN1 : constant SD_Specific_Command := 45; SD_App_Get_CER_RN2 : constant SD_Specific_Command := 46; SD_App_Set_CER_RES2 : constant SD_Specific_Command := 47; SD_App_Get_CER_RES1 : constant SD_Specific_Command := 48; SD_App_Change_Secure_Area : constant SD_Specific_Command := 49; SD_App_Send_SCR : constant SD_Specific_Command := 51; type Card_Data_Table is array (0 .. 3) of Word; type SDMMC_Controller is record Periph : access STM32_SVD.SDMMC.SDMMC1_Peripheral; CID : Card_Data_Table; CSD : Card_Data_Table; Card_Type : Supported_SD_Memory_Cards := STD_Capacity_SD_Card_V1_1; RCA : Word; Operation : SDMMC_Operation := No_Operation; end record; function As_Controller (Periph : access STM32_SVD.SDMMC.SDMMC1_Peripheral) return SDMMC_Controller is (Periph, CID => (others => 0), CSD => (others => 0), others => <>); function Initialized (Controller : SDMMC_Controller) return Boolean is (Controller.CID /= (0, 0, 0, 0)); function Get_Card_Type (Controller : SDMMC_Controller) return Supported_SD_Memory_Cards is (Controller.Card_Type); type Data_Direction is (Read, Write); function Get_FIFO_Address (Controller : SDMMC_Controller) return System.Address is (Controller.Periph.FIFO'Address); function Get_Flag (Controller : SDMMC_Controller; Flag : SDMMC_Flags) return Boolean is (case Flag is when Data_End => Controller.Periph.STA.DATAEND, when Data_CRC_Fail => Controller.Periph.STA.DCRCFAIL, when Data_Timeout => Controller.Periph.STA.DTIMEOUT, when RX_Overrun => Controller.Periph.STA.RXOVERR, when TX_Underrun => Controller.Periph.STA.TXUNDERR, when RX_Active => Controller.Periph.STA.RXACT, when TX_Active => Controller.Periph.STA.TXACT); function Last_Operation (Controller : SDMMC_Controller) return SDMMC_Operation is (Controller.Operation); end STM32.SDMMC;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of 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 Cortex_M.Debug; with System.Machine_Code; use System.Machine_Code; with HAL; use HAL; with Ada.Unchecked_Conversion; with Interfaces.C; use Interfaces.C; package body Semihosting is type SH_u32_Array is array (Integer range <>) of SH_Word with Pack, Convention => C, Volatile_Components; function To_SH_u32 is new Ada.Unchecked_Conversion (Source => System.Address, Target => SH_Word); function To_SH_u32 is new Ada.Unchecked_Conversion (Source => Integer, Target => SH_Word); subtype Syscall is SH_Word; SYS_OPEN : constant Syscall := 16#01#; SYS_CLOSE : constant Syscall := 16#02#; SYS_WRITEC : constant Syscall := 16#03#; SYS_WRITE0 : constant Syscall := 16#04#; SYS_WRITE : constant Syscall := 16#05#; SYS_READ : constant Syscall := 16#06#; -- SYS_READC : constant Syscall := 16#07#; -- SYS_ISERROR : constant Syscall := 16#08#; -- SYS_ISTTY : constant Syscall := 16#09#; SYS_SEEK : constant Syscall := 16#0A#; -- SYS_FLEN : constant Syscall := 16#0C#; -- SYS_TMPNAM : constant Syscall := 16#0D#; SYS_REMOVE : constant Syscall := 16#0E#; -- SYS_RENAME : constant Syscall := 16#0E#; -- SYS_CLOCK : constant Syscall := 16#10#; -- SYS_TIME : constant Syscall := 16#11#; SYS_ERRNO : constant Syscall := 16#13#; -- SYS_GET_CMD : constant Syscall := 16#15#; -- SYS_HEAPINFO : constant Syscall := 16#16#; -- SYS_ELAPSED : constant Syscall := 16#30#; -- SYS_TICKFREQ : constant Syscall := 16#31#; function Semihosting_Enabled return Boolean is (Cortex_M.Debug.Halting_Debug_Enabled); function Generic_SH_Call (R0, R1 : SH_Word) return SH_Word; function Generic_SH_Call (R0 : SH_Word; R1 : System.Address) return SH_Word; --------------------- -- Generic_SH_Call -- --------------------- function Generic_SH_Call (R0, R1 : SH_Word) return SH_Word is Ret : SH_Word; begin Asm ("mov r0, %1" & ASCII.LF & ASCII.HT & "mov r1, %2" & ASCII.LF & ASCII.HT & "bkpt #0xAB" & ASCII.LF & ASCII.HT & "mov %0, r0", Outputs => (SH_Word'Asm_Output ("=r", Ret)), Inputs => (SH_Word'Asm_Input ("r", R0), SH_Word'Asm_Input ("r", R1)), Volatile => True, Clobber => ("r1, r0")); return Ret; end Generic_SH_Call; --------------------- -- Generic_SH_Call -- --------------------- function Generic_SH_Call (R0 : SH_Word; R1 : System.Address) return SH_Word is begin return Generic_SH_Call (R0, To_SH_u32 (R1)); end Generic_SH_Call; ----------- -- Close -- ----------- function Close (File_Handle : SH_Word) return SH_Word is Block : SH_u32_Array (0 .. 0); begin if not Semihosting_Enabled then -- No debugger attached return SH_Word'Last; end if; Block (0) := File_Handle; return Generic_SH_Call (SYS_CLOSE, Block'Address); end Close; ---------- -- Open -- ---------- function Open (Filename : String; Mode : Flag) return SH_Word is Block : SH_u32_Array (0 .. 2); C_Name : char_array (0 .. Filename'Length) with Volatile; begin if not Semihosting_Enabled then -- No debugger attached return SH_Word'Last; end if; for J in Filename'Range loop C_Name (size_t (J - Filename'First)) := char'Val (Character'Pos (Filename (J))); end loop; C_Name (C_Name'Last) := nul; Block (0) := To_SH_u32 (C_Name'Address); Block (1) := Mode; Block (2) := Filename'Length; return Generic_SH_Call (SYS_OPEN, Block'Address); end Open; ---------- -- Read -- ---------- function Read (File_Handle : SH_Word; Buffer_Address : System.Address; Buffer_Size : SH_Word) return SH_Word is Block : SH_u32_Array (0 .. 2); begin if not Semihosting_Enabled then -- No debugger attached return Buffer_Size; end if; Block (0) := File_Handle; Block (1) := To_SH_u32 (Buffer_Address); Block (2) := Buffer_Size; return Generic_SH_Call (SYS_READ, Block'Address); end Read; ----------- -- Write -- ----------- function Write (File_Handle : SH_Word; Buffer_Address : System.Address; Buffer_Size : SH_Word) return SH_Word is Block : SH_u32_Array (0 .. 3); begin if not Semihosting_Enabled then -- No debugger attached return Buffer_Size; end if; Block (0) := File_Handle; Block (1) := To_SH_u32 (Buffer_Address); Block (2) := Buffer_Size; return Generic_SH_Call (SYS_WRITE, Block'Address); end Write; ------------ -- Remove -- ------------ function Remove (Filename : String) return SH_Word is Block : SH_u32_Array (0 .. 1); C_Name : char_array (0 .. Filename'Length) with Volatile; begin if not Semihosting_Enabled then -- No debugger attached return SH_Word'Last; end if; for J in Filename'Range loop C_Name (size_t (J - Filename'First)) := char'Val (Character'Pos (Filename (J))); end loop; C_Name (C_Name'Last) := nul; Block (0) := To_SH_u32 (C_Name'Address); Block (1) := To_SH_u32 (Filename'Length); return Generic_SH_Call (SYS_REMOVE, Block'Address); end Remove; ---------- -- Seek -- ---------- function Seek (File_Handle : SH_Word; Absolute_Position : SH_Word) return SH_Word is Block : SH_u32_Array (0 .. 1); begin if not Semihosting_Enabled then -- No debugger attached return SH_Word'Last; end if; Block (0) := File_Handle; Block (1) := Absolute_Position; return Generic_SH_Call (SYS_SEEK, Block'Address); end Seek; ----------- -- Errno -- ----------- function Errno return SH_Word is begin return Generic_SH_Call (SYS_ERRNO, 0); end Errno; ------------- -- Write_C -- ------------- procedure Write_C (C : Character) is Ret : SH_Word with Unreferenced; begin if not Semihosting_Enabled then -- No debugger attached return; end if; Ret := Generic_SH_Call (SYS_WRITEC, C'Address); end Write_C; ------------- -- Write_0 -- ------------- procedure Write_0 (Str : String) is Data : UInt8_Array (Str'First .. Str'Last + 1); Ret : SH_Word with Unreferenced; begin if not Semihosting_Enabled then -- No debugger attached return; end if; for Index in Str'Range loop Data (Index) := Character'Pos (Str (Index)); end loop; -- Add trailing zero Data (Str'Last + 1) := 0; Ret := Generic_SH_Call (SYS_WRITE0, Data'Address); end Write_0; -------------- -- Log_Line -- -------------- procedure Log_Line (Str : String) is begin Log (Str); Log_New_Line; end Log_Line; ------------------ -- Log_New_Line -- ------------------ procedure Log_New_Line is begin Write_C (ASCII.LF); end Log_New_Line; end Semihosting;
-- Copyright 2014-2017 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program 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 program. If not, see <http://www.gnu.org/licenses/>. with System; package Pck is type Element is abstract tagged null record; type GADataType is interface; type Data_Type is new Element and GADataType with record I : Integer := 42; end record; procedure Do_Nothing (A : System.Address); end Pck;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 0 3 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2021, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Storage_Elements; with System.Unsigned_Types; package body System.Pack_03 is subtype Bit_Order is System.Bit_Order; Reverse_Bit_Order : constant Bit_Order := Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order)); subtype Ofs is System.Storage_Elements.Storage_Offset; subtype Uns is System.Unsigned_Types.Unsigned; subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7; use type System.Storage_Elements.Storage_Offset; use type System.Unsigned_Types.Unsigned; type Cluster is record E0, E1, E2, E3, E4, E5, E6, E7 : Bits_03; end record; for Cluster use record E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1; E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1; E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1; E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1; E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1; E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1; E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1; E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1; end record; for Cluster'Size use Bits * 8; for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment, 1 + 1 * Boolean'Pos (Bits mod 2 = 0) + 2 * Boolean'Pos (Bits mod 4 = 0)); -- Use maximum possible alignment, given the bit field size, since this -- will result in the most efficient code possible for the field. type Cluster_Ref is access Cluster; type Rev_Cluster is new Cluster with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_Cluster_Ref is access Rev_Cluster; ------------ -- Get_03 -- ------------ function Get_03 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_03 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end Get_03; ------------ -- Set_03 -- ------------ procedure Set_03 (Arr : System.Address; N : Natural; E : Bits_03; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end Set_03; end System.Pack_03;
-- -- 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. -- -- with ada.unchecked_conversion; with ewok.tasks; use ewok.tasks; with ewok.tasks.debug; with ewok.tasks_shared; use ewok.tasks_shared; with ewok.devices_shared; use ewok.devices_shared; with ewok.sched; with soc.interrupts; with ewok.debug; package body ewok.mpu.handler with spark_mode => off is function memory_fault_handler (frame_a : t_stack_frame_access) return t_stack_frame_access is #if CONFIG_KERNEL_PANIC_FAULT new_frame_a : t_stack_frame_access; #end if; begin pragma DEBUG (ewok.tasks.debug.crashdump (frame_a)); ewok.tasks.debug.crashdump (frame_a); -- On memory fault, the task is not scheduled anymore ewok.tasks.set_state (ewok.sched.current_task_id, TASK_MODE_MAINTHREAD, ewok.tasks.TASK_STATE_FAULT); #if CONFIG_KERNEL_PANIC_FAULT if (ewok.tasks.is_real_user(ewok.sched.current_task_id)) then new_frame_a := ewok.sched.do_schedule (frame_a); return new_frame_a; else -- panic happen in a kernel task (softirq...) debug.panic ("Memory fault!"); return frame_a; end if; #else -- leave the panic function handling the other panic actions debug.panic ("Memory fault!"); return frame_a; #end if; end memory_fault_handler; procedure init is ok : boolean; begin ewok.interrupts.set_task_switching_handler (soc.interrupts.INT_MEMMANAGE, memory_fault_handler'access, ID_KERNEL, ID_DEV_UNUSED, ok); if not ok then raise program_error; end if; end init; end ewok.mpu.handler;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Entry_Declarations is function Create (Not_Token : Program.Lexical_Elements.Lexical_Element_Access; Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access; Entry_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Entry_Family_Definition : Program.Elements.Discrete_Ranges .Discrete_Range_Access; Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Left_Bracket_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Right_Bracket_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Entry_Declaration is begin return Result : Entry_Declaration := (Not_Token => Not_Token, Overriding_Token => Overriding_Token, Entry_Token => Entry_Token, Name => Name, Left_Bracket_Token => Left_Bracket_Token, Entry_Family_Definition => Entry_Family_Definition, Right_Bracket_Token => Right_Bracket_Token, Left_Bracket_Token_2 => Left_Bracket_Token_2, Parameters => Parameters, Right_Bracket_Token_2 => Right_Bracket_Token_2, With_Token => With_Token, Aspects => Aspects, Semicolon_Token => Semicolon_Token, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Entry_Family_Definition : Program.Elements.Discrete_Ranges .Discrete_Range_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Not : Boolean := False; Has_Overriding : Boolean := False) return Implicit_Entry_Declaration is begin return Result : Implicit_Entry_Declaration := (Name => Name, Entry_Family_Definition => Entry_Family_Definition, Parameters => Parameters, Aspects => Aspects, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Has_Not => Has_Not, Has_Overriding => Has_Overriding, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Name (Self : Base_Entry_Declaration) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is begin return Self.Name; end Name; overriding function Entry_Family_Definition (Self : Base_Entry_Declaration) return Program.Elements.Discrete_Ranges.Discrete_Range_Access is begin return Self.Entry_Family_Definition; end Entry_Family_Definition; overriding function Parameters (Self : Base_Entry_Declaration) return Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access is begin return Self.Parameters; end Parameters; overriding function Aspects (Self : Base_Entry_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access is begin return Self.Aspects; end Aspects; overriding function Not_Token (Self : Entry_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Not_Token; end Not_Token; overriding function Overriding_Token (Self : Entry_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Overriding_Token; end Overriding_Token; overriding function Entry_Token (Self : Entry_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Entry_Token; end Entry_Token; overriding function Left_Bracket_Token (Self : Entry_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Left_Bracket_Token; end Left_Bracket_Token; overriding function Right_Bracket_Token (Self : Entry_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Right_Bracket_Token; end Right_Bracket_Token; overriding function Left_Bracket_Token_2 (Self : Entry_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Left_Bracket_Token_2; end Left_Bracket_Token_2; overriding function Right_Bracket_Token_2 (Self : Entry_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Right_Bracket_Token_2; end Right_Bracket_Token_2; overriding function With_Token (Self : Entry_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.With_Token; end With_Token; overriding function Semicolon_Token (Self : Entry_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Semicolon_Token; end Semicolon_Token; overriding function Has_Not (Self : Entry_Declaration) return Boolean is begin return Self.Not_Token.Assigned; end Has_Not; overriding function Has_Overriding (Self : Entry_Declaration) return Boolean is begin return Self.Overriding_Token.Assigned; end Has_Overriding; overriding function Is_Part_Of_Implicit (Self : Implicit_Entry_Declaration) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Entry_Declaration) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Entry_Declaration) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; overriding function Has_Not (Self : Implicit_Entry_Declaration) return Boolean is begin return Self.Has_Not; end Has_Not; overriding function Has_Overriding (Self : Implicit_Entry_Declaration) return Boolean is begin return Self.Has_Overriding; end Has_Overriding; procedure Initialize (Self : aliased in out Base_Entry_Declaration'Class) is begin Set_Enclosing_Element (Self.Name, Self'Unchecked_Access); if Self.Entry_Family_Definition.Assigned then Set_Enclosing_Element (Self.Entry_Family_Definition, Self'Unchecked_Access); end if; for Item in Self.Parameters.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; for Item in Self.Aspects.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; null; end Initialize; overriding function Is_Entry_Declaration_Element (Self : Base_Entry_Declaration) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Entry_Declaration_Element; overriding function Is_Declaration_Element (Self : Base_Entry_Declaration) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Declaration_Element; overriding procedure Visit (Self : not null access Base_Entry_Declaration; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Entry_Declaration (Self); end Visit; overriding function To_Entry_Declaration_Text (Self : aliased in out Entry_Declaration) return Program.Elements.Entry_Declarations .Entry_Declaration_Text_Access is begin return Self'Unchecked_Access; end To_Entry_Declaration_Text; overriding function To_Entry_Declaration_Text (Self : aliased in out Implicit_Entry_Declaration) return Program.Elements.Entry_Declarations .Entry_Declaration_Text_Access is pragma Unreferenced (Self); begin return null; end To_Entry_Declaration_Text; end Program.Nodes.Entry_Declarations;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 9 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Table; with Types; use Types; package Sem_Ch9 is procedure Analyze_Abort_Statement (N : Node_Id); procedure Analyze_Accept_Alternative (N : Node_Id); procedure Analyze_Accept_Statement (N : Node_Id); procedure Analyze_Asynchronous_Select (N : Node_Id); procedure Analyze_Conditional_Entry_Call (N : Node_Id); procedure Analyze_Delay_Alternative (N : Node_Id); procedure Analyze_Delay_Relative (N : Node_Id); procedure Analyze_Delay_Until (N : Node_Id); procedure Analyze_Entry_Body (N : Node_Id); procedure Analyze_Entry_Body_Formal_Part (N : Node_Id); procedure Analyze_Entry_Call_Alternative (N : Node_Id); procedure Analyze_Entry_Declaration (N : Node_Id); procedure Analyze_Entry_Index_Specification (N : Node_Id); procedure Analyze_Protected_Body (N : Node_Id); procedure Analyze_Protected_Definition (N : Node_Id); procedure Analyze_Protected_Type_Declaration (N : Node_Id); procedure Analyze_Requeue (N : Node_Id); procedure Analyze_Selective_Accept (N : Node_Id); procedure Analyze_Single_Protected_Declaration (N : Node_Id); procedure Analyze_Single_Task_Declaration (N : Node_Id); procedure Analyze_Task_Body (N : Node_Id); procedure Analyze_Task_Definition (N : Node_Id); procedure Analyze_Task_Type_Declaration (N : Node_Id); procedure Analyze_Terminate_Alternative (N : Node_Id); procedure Analyze_Timed_Entry_Call (N : Node_Id); procedure Analyze_Triggering_Alternative (N : Node_Id); procedure Install_Declarations (Spec : Entity_Id); -- Make visible in corresponding body the entities defined in a task, -- protected type declaration, or entry declaration. ------------------------------ -- Lock Free Data Structure -- ------------------------------ -- A lock-free subprogram is a protected routine which references a unique -- protected scalar component and does not contain statements that cause -- side effects. Due to this restricted behavior, all references to shared -- data from within the subprogram can be synchronized through the use of -- atomic operations rather than relying on locks. type Lock_Free_Subprogram is record Sub_Body : Node_Id; -- Reference to the body of a protected subprogram which meets the lock- -- free requirements. Comp_Id : Entity_Id; -- Reference to the scalar component referenced from within Sub_Body end record; -- This table establishes a relation between a protected subprogram body -- and a unique component it references. The table is used when building -- the lock-free versions of a protected subprogram body. package Lock_Free_Subprogram_Table is new Table.Table ( Table_Component_Type => Lock_Free_Subprogram, Table_Index_Type => Nat, Table_Low_Bound => 1, Table_Initial => 5, Table_Increment => 5, Table_Name => "Lock_Free_Subprogram_Table"); end Sem_Ch9;
with Interfaces.C.Strings; with a_nodes_h; package tool_2_wrapper_h is function tool_2_wrapper (target_file_in : in Interfaces.C.Strings.chars_ptr; gnat_home : in Interfaces.C.Strings.chars_ptr; output_dir : in Interfaces.C.Strings.chars_ptr) return a_nodes_h.Nodes_Struct; pragma Export (C, tool_2_wrapper); end tool_2_wrapper_h;
with Ada.Containers; use Ada.Containers; with Ada.Text_IO; use Ada.Text_IO; with AUnit.Assertions; use AUnit.Assertions; with GNAT.Source_Info; use GNAT.Source_Info; with Langkit_Support.Text; use Langkit_Support.Text; with Libadalang.Analysis; use Libadalang.Analysis; with Libadalang.Common; use Libadalang.Common; with Rejuvenation; use Rejuvenation; with Rejuvenation.Finder; use Rejuvenation.Finder; with Rejuvenation.Match_Patterns; use Rejuvenation.Match_Patterns; with Rejuvenation.Patterns; use Rejuvenation.Patterns; with Rejuvenation.Simple_Factory; use Rejuvenation.Simple_Factory; with Shared; use Shared; package body Test_Exercises_Match is procedure Test_Rejuvenation_Finder_Public_Subp_Definition_With_3_Parameters (T : in out Test_Case'Class); procedure Test_Rejuvenation_Finder_Public_Subp_Definition_With_3_Parameters (T : in out Test_Case'Class) is pragma Unreferenced (T); function Valid_Node (Node : Ada_Node'Class) return Boolean; function Valid_Node (Node : Ada_Node'Class) return Boolean is begin if Node.Kind = Ada_Subp_Spec then declare SS : constant Subp_Spec := Node.As_Subp_Spec; begin return not Inside_Private_Part (SS) and then Is_Part_Of_Subp_Def (SS) and then Nr_Of_Parameters (SS) = 3; end; else return False; end if; end Valid_Node; Unit : constant Analysis_Unit := Analyze_File ("src/count_subprogram.ads"); Found_Nodes : constant Node_List.Vector := Find (Unit.Root, Valid_Node'Access); begin Put_Line ("Begin - " & Enclosing_Entity); for Found_Node of Found_Nodes loop declare SS : constant Subp_Spec := Found_Node.As_Subp_Spec; begin Put_Line ("Found " & Image (SS.F_Subp_Name.Text)); end; end loop; Put_Line ("Done - " & Enclosing_Entity); end Test_Rejuvenation_Finder_Public_Subp_Definition_With_3_Parameters; procedure Test_Rejuvenation_Find_Assign_Condition_In_If_Statement (T : in out Test_Case'Class); procedure Test_Rejuvenation_Find_Assign_Condition_In_If_Statement (T : in out Test_Case'Class) is pragma Unreferenced (T); Unit : constant Analysis_Unit := Analyze_File ("src/assignmentbyifexamples.adb"); Pattern_Assign_Condition_In_If_Statement : constant Pattern := Make_Pattern ("if $S_Condition then $S_Variable := True; " & "else $S_Variable := False; end if;", If_Stmt_Rule); Found_Matches : constant Match_Pattern_List.Vector := Find_Full (Unit.Root, Pattern_Assign_Condition_In_If_Statement); begin Put_Line ("Begin - " & Enclosing_Entity); Assert (Found_Matches.Length = 2, "Two instances in unit expected, got " & Found_Matches.Length'Image); for Found_Match of Found_Matches loop declare Condition : constant String := Found_Match.Get_Single_As_Raw_Signature ("$S_Condition"); Variable : constant String := Found_Match.Get_Single_As_Raw_Signature ("$S_Variable"); begin Put_Line (Image (Found_Match.Get_Nodes.First_Element.Full_Sloc_Image) & Variable & " := " & Condition & ";"); end; end loop; Put_Line ("End - " & Enclosing_Entity); end Test_Rejuvenation_Find_Assign_Condition_In_If_Statement; procedure Test_Rejuvenation_Find_Windows_New_Line (T : in out Test_Case'Class); procedure Test_Rejuvenation_Find_Windows_New_Line (T : in out Test_Case'Class) is pragma Unreferenced (T); procedure Handle_Matches (Matches : Match_Pattern_List.Vector); procedure Handle_Matches (Matches : Match_Pattern_List.Vector) is begin for Match of Matches loop declare Node : constant Ada_Node := Match.Get_Nodes.First_Element; begin Put_Line (Image (Node.Full_Sloc_Image) & " Found New_Line"); end; end loop; end Handle_Matches; Unit : constant Analysis_Unit := Analyze_File ("src/newlineexamples.adb"); Pattern1_New_Line : constant Pattern := Make_Pattern ("ASCII.CR & ASCII.LF", Expr_Rule); Found1_Matches : constant Match_Pattern_List.Vector := Find_Full (Unit.Root, Pattern1_New_Line); Pattern2_New_Line : constant Pattern := Make_Pattern ("(1 => ASCII.CR, 2 => ASCII.LF)", Expr_Rule); Found2_Matches : constant Match_Pattern_List.Vector := Find_Full (Unit.Root, Pattern2_New_Line); PrefixKey : constant String := "$S_prefix"; Pattern3_New_Line : constant Pattern := Make_Pattern (PrefixKey & " & ASCII.CR & ASCII.LF", Expr_Rule); Found3_Matches : constant Match_Pattern_List.Vector := Find_Full (Unit.Root, Pattern3_New_Line); begin Put_Line ("Begin - " & Enclosing_Entity); Put_Line ("Pattern 1"); Handle_Matches (Found1_Matches); Put_Line ("Pattern 2"); Handle_Matches (Found2_Matches); Put_Line ("Pattern 3"); Handle_Matches (Found3_Matches); Put_Line ("Done - " & Enclosing_Entity); end Test_Rejuvenation_Find_Windows_New_Line; -- TODO: Add real world example usable in open source -- procedure Test_Rejuvenation_Find_Modify_Item -- (T : in out Test_Case'Class); -- Test plumbing overriding function Name (T : Exercise_Match_Test_Case) return AUnit.Message_String is pragma Unreferenced (T); begin return AUnit.Format ("Exercises Match Pattern"); end Name; overriding procedure Register_Tests (T : in out Exercise_Match_Test_Case) is begin Registration.Register_Routine (T, Test_Rejuvenation_Finder_Public_Subp_Definition_With_3_Parameters' Access, "Use Rejuvenation Finder to find Subp_Specs with 3 Parameters"); Registration.Register_Routine (T, Test_Rejuvenation_Find_Assign_Condition_In_If_Statement'Access, "Use Rejuvenation to find assign condition in if statements"); Registration.Register_Routine (T, Test_Rejuvenation_Find_Windows_New_Line'Access, "Use Rejuvenation to find Windows New Line"); end Register_Tests; end Test_Exercises_Match;
with ada.unchecked_Conversion; with impact.d3.Shape.convex, impact.d3.Shape.convex.internal.polyhedral.triangle, impact.d3.Shape.convex.internal.sphere, impact.d3.Shape.convex.internal.cylinder, impact.d3.Shape.convex.internal.polyhedral.hull; -- btCapsuleShape, -- obsolete with impact.d3.Transform, impact.d3.collision.Proxy, impact.d3.Shape.convex.internal.polyhedral.box, impact.d3.Shape.convex.internal.polyhedral.triangle, -- impact.d3.Shape.convex.internal.cylinder, -- impact.d3.convex_HullShape, impact.d3.Vector, impact.d3.Matrix, interfaces.c.Pointers; with impact.d3.Scalar; with impact.d3.Shape.convex.internal.polyhedral; package body impact.d3.Shape.convex -- -- -- is type Vector_3s is array (Positive range <>) of aliased Vector_3; package vector_Pointers is new interfaces.c.Pointers (Positive, Vector_3, Vector_3s, (0.0, 0.0, 0.0)); function convexHullSupport (localDirOrg : in Vector_3; points : access Vector_3; numPoints : in Integer; localScaling : in Vector_3) return Vector_3 is use Interfaces, vector_Pointers, impact.d3.Vector; the_Points : Vector_3s renames Value (points.all'Access, c.ptrdiff_t (numPoints)); vec : constant Vector_3 := Scaled (localDirOrg, by => localScaling); newDot : Real; maxDot : Real := Real'First; ptIndex : Integer := -1; supVec : Vector_3; begin for i in 1 .. numPoints loop newDot := dot (vec, the_Points (i)); if newDot > maxDot then maxDot := newDot; ptIndex := i; end if; end loop; pragma Assert (ptIndex >= 1); supVec := Scaled (the_Points (ptIndex), by => localScaling); return supVec; end convexHullSupport; type Box_view is access all impact.d3.Shape.convex.internal.polyhedral.box.Item'Class; type Triangle_view is access all impact.d3.Shape.convex.internal.polyhedral.triangle.Item'Class; function localGetSupportVertexWithoutMarginNonVirtual (Self : in Item'Class; localDir : in Vector_3) return Vector_3 is use impact.d3.collision.Proxy; begin case Self.getShapeType is when SPHERE_SHAPE_PROXYTYPE => return (0.0, 0.0, 0.0); when BOX_SHAPE_PROXYTYPE => declare use Standard.impact.d3.Scalar; convexShape : constant impact.d3.Shape.convex.internal.polyhedral.box.item'Class := impact.d3.Shape.convex.internal.polyhedral.box.item'Class (Self); halfExtents : constant Vector_3 := convexShape.getImplicitShapeDimensions; begin return (btFsels (localDir (1), halfExtents (1), -halfExtents (1)), btFsels (localDir (2), halfExtents (2), -halfExtents (2)), btFsels (localDir (3), halfExtents (3), -halfExtents (3))); end; when TRIANGLE_SHAPE_PROXYTYPE => declare use impact.d3.Vector; triangleShape : impact.d3.Shape.convex.internal.polyhedral.triangle.item'Class := impact.d3.Shape.convex.internal.polyhedral.triangle.item'Class (Self); dir : constant Vector_3 := (localDir (1), localDir (2), localDir (3)); vertices : constant array (1 .. 3) of access Vector_3 := (triangleShape.m_vertices1 (1)'Access, triangleShape.m_vertices1 (2)'Access, triangleShape.m_vertices1 (3)'Access); dots : constant Vector_3 := (dot (dir, vertices (1).all), dot (dir, vertices (2).all), dot (dir, vertices (3).all)); sup : constant Vector_3 := vertices (maxAxis (dots)).all; begin return sup; end; when CYLINDER_SHAPE_PROXYTYPE => declare cylShape : constant impact.d3.Shape.convex.internal.cylinder.item'Class := impact.d3.Shape.convex.internal.cylinder.item'Class (Self); -- mapping of halfextents/dimension onto radius/height depends on how cylinder local orientation is (upAxis) halfExtents : Vector_3 := cylShape.getImplicitShapeDimensions; v : Vector_3 := (localDir (1), localDir (2), localDir (3)); cylinderUpAxis : constant Integer := cylShape.getUpAxis; XX : Integer := 2; YY : Integer := 1; ZZ : Integer := 3; begin case cylinderUpAxis is when 1 => XX := 2; YY := 1; ZZ := 3; when 2 => XX := 1; YY := 2; ZZ := 3; when 3 => XX := 1; YY := 3; ZZ := 2; when others => pragma Assert (False); raise Program_Error; end case; declare use math.Functions; radius : constant Real := halfExtents (XX); halfHeight : constant Real := halfExtents (cylinderUpAxis); tmp : Vector_3; d : Real; s : constant Real := sqRt (v (XX) * v (XX) + v (ZZ) * v (ZZ)); begin if s /= 0.0 then d := radius / s; tmp (XX) := v (XX) * d; if v (YY) < 0.0 then tmp (YY) := -halfHeight; else tmp (YY) := halfHeight; end if; tmp (ZZ) := v (ZZ) * d; return tmp; else tmp (XX) := radius; if v (YY) < 0.0 then tmp (YY) := -halfHeight; else tmp (YY) := halfHeight; end if; tmp (ZZ) := 0.0; return tmp; end if; end; end; -- when CAPSULE_SHAPE_PROXYTYPE => -- nb: capsules are provided by multi-sphere, so this is probably obsolete ? -- declare -- capsuleShape : access btCapsuleShape.item := btCapsuleShape.view (Self); -- -- vec0 : Vector_3 := localDir; -- halfHeight : Scalar := capsuleShape.getHalfHeight; -- capsuleUpAxis : Integer := capsuleShape.getUpAxis; -- -- radius : Scalar := capsuleShape.getRadius; -- supVec : Vector_3 := (0.0, 0.0, 0.0); -- -- maxDot : Scalar := -BT_LARGE_FLOAT; -- -- vec : Vector_3 := vec0; -- lenSqr : Scalar := length2 (vec); -- -- pos, -- vtx : Vector_3; -- -- newDot, -- rlen : Scalar; -- begin -- if lenSqr < 0.0001 then -- vec := (1.0, 0.0, 0.0); -- else -- rlen := 1.0 / sqRt (lenSqr); -- vec := vec * rlen; -- end if; -- -- pos := (0.0, 0.0, 0.0); -- pos (capsuleUpAxis) := halfHeight; -- -- -- vtx = pos +vec*(radius); -- vtx := pos + vec * capsuleShape.getLocalScalingNV * radius - vec * capsuleShape.getMarginNV; -- newDot := dot (vec, vtx); -- -- if newDot > maxDot then -- maxDot := newDot; -- supVec := vtx; -- end if; -- -- pos := (0.0, 0.0, 0.0); -- pos (capsuleUpAxis) := -halfHeight; -- -- -- vtx = pos +vec*(radius); -- vtx := pos + vec * capsuleShape.getLocalScalingNV * radius - vec * capsuleShape.getMarginNV; -- newDot := dot (vec, vtx); -- -- if newDot > maxDot then -- maxDot := newDot; -- supVec := vtx; -- end if; -- -- return supVec; -- end; -- -- when CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE => -- declare -- convexPointCloudShape : access impact.d3.Shape.convex.internal.polyhedral.point_cloud.item := impact.d3.Shape.convex.internal.polyhedral.point_cloud.view (Self); -- points : access impact.d3.Vector := convexPointCloudShape.getUnscaledPoints; -- numPoints : Integer := convexPointCloudShape.getNumPoints; -- begin -- return convexHullSupport (localDir, points, numPoints, convexPointCloudShape.getLocalScalingNV); -- end; -- when CONVEX_HULL_SHAPE_PROXYTYPE => declare package hull_Shape renames impact.d3.Shape.convex.internal.polyhedral.hull; type Vector_3_view is access all math.Vector_3; type c_Vector_3_view is access all c_Vector_3; function to_Vector_3_view is new ada.unchecked_Conversion (c_Vector_3_view, Vector_3_view); -- tbd: Remove/improve this. convexHullShape : constant hull_Shape.item'Class := hull_Shape.item'Class (Self); points : constant Vector_3_view := to_Vector_3_view (convexHullShape.getUnscaledPoints); numPoints : constant Integer := convexHullShape.getNumPoints; begin return convexHullSupport (localDir, points, numPoints, convexHullShape.getLocalScalingNV); end; when others => -- null; return Self.localGetSupportingVertexWithoutMargin (localDir); end case; pragma Assert (False); -- Should never reach here. return (0.0, 0.0, 0.0); end localGetSupportVertexWithoutMarginNonVirtual; function localGetSupportVertexNonVirtual (Self : in Item'Class; vec : in Vector_3) return Vector_3 is use impact.d3.Vector, math.Vectors; localDir : math.Vector_3 renames vec; localDirNorm : math.Vector_3 := localDir; begin if length2 (localDirNorm) < impact.d3.Scalar.SIMD_EPSILON * impact.d3.Scalar.SIMD_EPSILON then localDirNorm := (-1.0, -1.0, -1.0); end if; normalize (localDirNorm); return Self.localGetSupportVertexWithoutMarginNonVirtual (localDirNorm) + Self.getMarginNonVirtual * localDirNorm; end localGetSupportVertexNonVirtual; -- TODO: This should be bumped up to impact.d3.Shape () -- function getMarginNonVirtual (Self : in Item'Class) return Real is begin case Self.getShapeType is when impact.d3.collision.Proxy.SPHERE_SHAPE_PROXYTYPE => declare sphereShape : constant impact.d3.Shape.convex.internal.sphere.item'Class := impact.d3.Shape.convex.internal.sphere.item'Class (Self); begin return sphereShape.getRadius; end; when impact.d3.collision.Proxy.BOX_SHAPE_PROXYTYPE => declare convexShape : constant impact.d3.Shape.convex.internal.polyhedral.box.item'Class := impact.d3.Shape.convex.internal.polyhedral.box.item'Class (Self); begin return convexShape.getMarginNV; end; when impact.d3.collision.Proxy.TRIANGLE_SHAPE_PROXYTYPE => declare triangleShape : constant impact.d3.Shape.convex.internal.polyhedral.triangle.item'Class := impact.d3.Shape.convex.internal.polyhedral.triangle.item'Class (Self); begin return triangleShape.getMarginNV; end; when impact.d3.collision.Proxy.CYLINDER_SHAPE_PROXYTYPE => raise Program_Error with "TBD"; -- declare -- cylShape : impact.d3.Shape.convex.internal.cylinder.item'Class := impact.d3.Shape.convex.internal.cylinder.item'Class (Self); -- begin -- return cylShape.getMarginNV; -- end; when impact.d3.collision.Proxy.CAPSULE_SHAPE_PROXYTYPE => raise Program_Error with "TBD"; -- declare -- capsuleShape : btCapsuleShape.item'Class := btCapsuleShape.item'Class (Self); -- begin -- return capsuleShape.getMarginNV; -- end; when impact.d3.collision.Proxy.CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE | impact.d3.collision.Proxy.CONVEX_HULL_SHAPE_PROXYTYPE => raise Program_Error with "TBD"; -- declare -- convexHullShape : impact.d3.Shape.convex.internal.polyhedral.item'Class := impact.d3.Shape.convex.internal.polyhedral.item'Class (Self); -- begin -- return convexHullShape.getMarginNV; -- end; when others => return Self.getMargin; end case; -- should never reach here pragma Assert (False); return 0.0; end getMarginNonVirtual; procedure getAabbNonVirtual (Self : in Item'Class; t : in Transform_3d; aabbMin, aabbMax : out Vector_3) is use impact.d3.Transform, impact.d3.Vector, impact.d3.Matrix, math.Vectors; begin case Self.getShapeType is when impact.d3.collision.Proxy.SPHERE_SHAPE_PROXYTYPE => declare sphereShape : constant impact.d3.Shape.convex.internal.sphere.item'Class := impact.d3.Shape.convex.internal.sphere.Item'Class (Self); radius : constant math.Real := sphereShape.getImplicitShapeDimensions (1); -- * convexShape->getLocalScaling().getX(); margin : constant math.Real := radius + sphereShape.getMarginNonVirtual; center : constant math.Vector_3 := getOrigin (t); extent : constant math.Vector_3 := (margin, margin, margin); begin aabbMin := center - extent; aabbMax := center + extent; end; when impact.d3.collision.Proxy.CYLINDER_SHAPE_PROXYTYPE | impact.d3.collision.Proxy.BOX_SHAPE_PROXYTYPE => declare convexShape : constant impact.d3.Shape.convex.internal.polyhedral.box.item'Class := impact.d3.Shape.convex.internal.polyhedral.box.item'Class (Self); margin : math.Real := convexShape.getMarginNonVirtual; halfExtents : constant math.Vector_3 := convexShape.getImplicitShapeDimensions + (margin, margin, margin); abs_b : constant math.Matrix_3x3 := absolute (getBasis (t)); center : constant math.Vector_3 := getOrigin (t); extent : constant math.Vector_3 := (dot (getRow (abs_b, 1), halfExtents), dot (getRow (abs_b, 2), halfExtents), dot (getRow (abs_b, 3), halfExtents)); begin aabbMin := center - extent; aabbMax := center + extent; end; when impact.d3.collision.Proxy.TRIANGLE_SHAPE_PROXYTYPE => declare use linear_Algebra_3d; triangleShape : constant impact.d3.Shape.convex.internal.polyhedral.triangle.item'Class := impact.d3.Shape.convex.internal.polyhedral.triangle.item'Class (Self); margin : math.Real := triangleShape.getMarginNonVirtual; vec, sv, tmp : math.Vector_3; begin for i in 1 .. 3 loop vec := (0.0, 0.0, 0.0); vec (i) := 1.0; sv := Self.localGetSupportVertexWithoutMarginNonVirtual (vec * getBasis (t)); tmp := t * sv; aabbMax (i) := tmp (i) + margin; vec (i) := -1.0; tmp := t * Self.localGetSupportVertexWithoutMarginNonVirtual (vec * getBasis (t)); aabbMin (i) := tmp (i) - margin; end loop; end; when impact.d3.collision.Proxy.CAPSULE_SHAPE_PROXYTYPE => raise Program_Error with "TBD"; -- declare -- btCapsuleShape* capsuleShape := (btCapsuleShape*)this; -- impact.d3.Vector halfExtents(capsuleShape->getRadius(),capsuleShape->getRadius(),capsuleShape->getRadius()); -- int m_upAxis := capsuleShape->getUpAxis(); -- halfExtents[m_upAxis] := capsuleShape->getRadius() + capsuleShape->getHalfHeight(); -- halfExtents += impact.d3.Vector(capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual()); -- impact.d3.Matrix abs_b := t.getBasis().absolute(); -- impact.d3.Vector center := t.getOrigin(); -- impact.d3.Vector extent := impact.d3.Vector(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents)); -- begin -- aabbMin := center - extent; -- aabbMax := center + extent; -- end; when impact.d3.collision.Proxy.CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE | impact.d3.collision.Proxy.CONVEX_HULL_SHAPE_PROXYTYPE => raise Program_Error with "TBD32"; -- declare -- convexHullShape : btPolyhedralConvexAabbCachingShape.item'Class := btPolyhedralConvexAabbCachingShape.item'Class (Self); -- margin : math.Real := convexHullShape.getMarginNonVirtual; -- begin -- convexHullShape.getNonvirtualAabb (t, aabbMin, aabbMax, margin); -- end; when others => Self.getAabb (t, aabbMin, aabbMax); end case; -- should never reach here pragma Assert (False); end getAabbNonVirtual; procedure project (Self : in Item; t : in Transform_3d; dir : in Vector_3; min, max : out Real) is use linear_Algebra_3d, impact.d3.Transform, impact.d3.Vector, Math.Vectors; localAxis : constant Vector_3 := dir * getBasis (t); vtx1 : constant Vector_3 := t * Item'Class (Self).localGetSupportingVertex (localAxis); vtx2 : constant Vector_3 := t * Item'Class (Self).localGetSupportingVertex (-localAxis); tmp : Real; begin min := dot (vtx1, dir); max := dot (vtx2, dir); if min > max then tmp := min; min := max; max := tmp; end if; end project; end impact.d3.Shape.convex; --------------------------------------------------------------- --- below is left for reference (it has been ported above) ... -- -- impact.d3.Vector impact.d3.Shape.convex::localGetSupportVertexWithoutMarginNonVirtual (const impact.d3.Vector& localDir) const -- { -- switch (m_shapeType) -- { -- case SPHERE_SHAPE_PROXYTYPE: -- { -- return impact.d3.Vector(0,0,0); -- } -- case BOX_SHAPE_PROXYTYPE: -- { -- impact.d3.Shape.convex.internal.polyhedral.box* convexShape = (impact.d3.Shape.convex.internal.polyhedral.box*)this; -- const impact.d3.Vector& halfExtents = convexShape->getImplicitShapeDimensions(); -- -- return impact.d3.Vector(btFsels(localDir.x(), halfExtents.x(), -halfExtents.x()), -- btFsels(localDir.y(), halfExtents.y(), -halfExtents.y()), -- btFsels(localDir.z(), halfExtents.z(), -halfExtents.z())); -- } -- case TRIANGLE_SHAPE_PROXYTYPE: -- { -- impact.d3.Shape.convex.internal.polyhedral.triangle* triangleShape = (impact.d3.Shape.convex.internal.polyhedral.triangle*)this; -- impact.d3.Vector dir(localDir.getX(),localDir.getY(),localDir.getZ()); -- impact.d3.Vector* vertices = &triangleShape->m_vertices1[0]; -- impact.d3.Vector dots(dir.dot(vertices[0]), dir.dot(vertices[1]), dir.dot(vertices[2])); -- impact.d3.Vector sup = vertices[dots.maxAxis()]; -- return impact.d3.Vector(sup.getX(),sup.getY(),sup.getZ()); -- } -- case CYLINDER_SHAPE_PROXYTYPE: -- { -- impact.d3.Shape.convex.internal.cylinder* cylShape = (impact.d3.Shape.convex.internal.cylinder*)this; -- //mapping of halfextents/dimension onto radius/height depends on how cylinder local orientation is (upAxis) -- -- impact.d3.Vector halfExtents = cylShape->getImplicitShapeDimensions(); -- impact.d3.Vector v(localDir.getX(),localDir.getY(),localDir.getZ()); -- int cylinderUpAxis = cylShape->getUpAxis(); -- int XX(1),YY(0),ZZ(2); -- -- switch (cylinderUpAxis) -- { -- case 0: -- { -- XX = 1; -- YY = 0; -- ZZ = 2; -- } -- break; -- case 1: -- { -- XX = 0; -- YY = 1; -- ZZ = 2; -- } -- break; -- case 2: -- { -- XX = 0; -- YY = 2; -- ZZ = 1; -- -- } -- break; -- default: -- btAssert(0); -- break; -- }; -- -- impact.d3.Scalar radius = halfExtents[XX]; -- impact.d3.Scalar halfHeight = halfExtents[cylinderUpAxis]; -- -- impact.d3.Vector tmp; -- impact.d3.Scalar d ; -- -- impact.d3.Scalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); -- if (s != impact.d3.Scalar(0.0)) -- { -- d = radius / s; -- tmp[XX] = v[XX] * d; -- tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; -- tmp[ZZ] = v[ZZ] * d; -- return impact.d3.Vector(tmp.getX(),tmp.getY(),tmp.getZ()); -- } else { -- tmp[XX] = radius; -- tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; -- tmp[ZZ] = impact.d3.Scalar(0.0); -- return impact.d3.Vector(tmp.getX(),tmp.getY(),tmp.getZ()); -- } -- } -- case CAPSULE_SHAPE_PROXYTYPE: -- { -- impact.d3.Vector vec0(localDir.getX(),localDir.getY(),localDir.getZ()); -- -- btCapsuleShape* capsuleShape = (btCapsuleShape*)this; -- impact.d3.Scalar halfHeight = capsuleShape->getHalfHeight(); -- int capsuleUpAxis = capsuleShape->getUpAxis(); -- -- impact.d3.Scalar radius = capsuleShape->getRadius(); -- impact.d3.Vector supVec(0,0,0); -- -- impact.d3.Scalar maxDot(impact.d3.Scalar(-BT_LARGE_FLOAT)); -- -- impact.d3.Vector vec = vec0; -- impact.d3.Scalar lenSqr = vec.length2(); -- if (lenSqr < impact.d3.Scalar(0.0001)) -- { -- vec.setValue(1,0,0); -- } else -- { -- impact.d3.Scalar rlen = impact.d3.Scalar(1.) / btSqrt(lenSqr ); -- vec *= rlen; -- } -- impact.d3.Vector vtx; -- impact.d3.Scalar newDot; -- { -- impact.d3.Vector pos(0,0,0); -- pos[capsuleUpAxis] = halfHeight; -- -- //vtx = pos +vec*(radius); -- vtx = pos +vec*capsuleShape->getLocalScalingNV()*(radius) - vec * capsuleShape->getMarginNV(); -- newDot = vec.dot(vtx); -- -- -- if (newDot > maxDot) -- { -- maxDot = newDot; -- supVec = vtx; -- } -- } -- { -- impact.d3.Vector pos(0,0,0); -- pos[capsuleUpAxis] = -halfHeight; -- -- //vtx = pos +vec*(radius); -- vtx = pos +vec*capsuleShape->getLocalScalingNV()*(radius) - vec * capsuleShape->getMarginNV(); -- newDot = vec.dot(vtx); -- if (newDot > maxDot) -- { -- maxDot = newDot; -- supVec = vtx; -- } -- } -- return impact.d3.Vector(supVec.getX(),supVec.getY(),supVec.getZ()); -- } -- case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE: -- { -- impact.d3.Shape.convex.internal.polyhedral.point_cloud* convexPointCloudShape = (impact.d3.Shape.convex.internal.polyhedral.point_cloud*)this; -- impact.d3.Vector* points = convexPointCloudShape->getUnscaledPoints (); -- int numPoints = convexPointCloudShape->getNumPoints (); -- return convexHullSupport (localDir, points, numPoints,convexPointCloudShape->getLocalScalingNV()); -- } -- case CONVEX_HULL_SHAPE_PROXYTYPE: -- { -- impact.d3.convex_HullShape* convexHullShape = (impact.d3.convex_HullShape*)this; -- impact.d3.Vector* points = convexHullShape->getUnscaledPoints(); -- int numPoints = convexHullShape->getNumPoints (); -- return convexHullSupport (localDir, points, numPoints,convexHullShape->getLocalScalingNV()); -- } -- default: -- #ifndef __SPU__ -- return this->localGetSupportingVertexWithoutMargin (localDir); -- #else -- btAssert (0); -- #endif -- } -- -- // should never reach here -- btAssert (0); -- return impact.d3.Vector (impact.d3.Scalar(0.0f), impact.d3.Scalar(0.0f), impact.d3.Scalar(0.0f)); -- }
-- Abstract : -- -- Config parsing subprograms. -- -- Copyright (C) 2018 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, 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 MERCHAN- -- TABILITY 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. pragma License (Modified_GPL); with SAL.Gen_Bounded_Definite_Vectors.Gen_Refs; with WisiToken.Parse.LR.McKenzie_Recover.Base; private package WisiToken.Parse.LR.McKenzie_Recover.Parse is function Reduce_Stack (Shared : not null access Base.Shared; Stack : in out Recover_Stacks.Stack; Action : in Reduce_Action_Rec; Nonterm : out Recover_Token; Default_Virtual : in Boolean) return Semantic_Checks.Check_Status; -- Reduce Stack according to Action, setting Nonterm. If -- Action.Token_Count = 0, set Nonterm.Virtual := Default_Virtual. type Parse_Item is record Config : Configuration; Action : Parse_Action_Node_Ptr; Parsed : Boolean; Shift_Count : Natural := 0; -- On return from Parse, if Parsed = False, this item was queued by a -- conflict, but not parsed; it should be ignored. -- -- Otherwise, if Config.Error_Token.ID = Invalid_Token_ID and -- Config.Check_Status.Label = Ok, Config was parsed successfully to -- the goal. -- -- Otherwise, the parser failed a semantic check, or encountered an -- Error action. Action gives the last action processed. Shift_Count -- gives the number of shifts performed. If Check_Status.Label is -- Error, Action.Item.Verb must be Reduce, and Config is in the -- pre-reduce state. end record; package Parse_Item_Arrays is new SAL.Gen_Bounded_Definite_Vectors (Positive, Parse_Item, Capacity => 10); -- Parse_Item_Arrays.Capacity sets maximum conflicts in one call to Parse package Parse_Item_Array_Refs is new Parse_Item_Arrays.Gen_Refs; function Parse (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Parse_Items : aliased out Parse_Item_Arrays.Vector; Config : in Configuration; Shared_Token_Goal : in Base_Token_Index; All_Conflicts : in Boolean; Trace_Prefix : in String) return Boolean; -- Attempt to parse Config and any conflict configs. If not -- All_Conflicts, return when Config.Insert_Delete is all processed, -- and either Shared_Token_Goal = Invalid_Token_Index or -- Shared_Token_Goal is shifted. If All_Conflicts, return when all -- conflict configs have been parsed. -- -- Parsed configs are in Parse_Items; there is more than one if a -- conflict is encountered. Parse returns True if at least one -- Parse_Item parsed successfully to the goal. In that case, the -- other items are either not parsed or failed. See comment in -- Parse_Item for more detail. -- -- Raises Bad_Config if parse encounters Unknown_State. end WisiToken.Parse.LR.McKenzie_Recover.Parse;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright Β© 2011-2012, 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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Relationships.Collections is pragma Preelaborate; package UML_Relationship_Collections is new AMF.Generic_Collections (UML_Relationship, UML_Relationship_Access); type Set_Of_UML_Relationship is new UML_Relationship_Collections.Set with null record; Empty_Set_Of_UML_Relationship : constant Set_Of_UML_Relationship; type Ordered_Set_Of_UML_Relationship is new UML_Relationship_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Relationship : constant Ordered_Set_Of_UML_Relationship; type Bag_Of_UML_Relationship is new UML_Relationship_Collections.Bag with null record; Empty_Bag_Of_UML_Relationship : constant Bag_Of_UML_Relationship; type Sequence_Of_UML_Relationship is new UML_Relationship_Collections.Sequence with null record; Empty_Sequence_Of_UML_Relationship : constant Sequence_Of_UML_Relationship; private Empty_Set_Of_UML_Relationship : constant Set_Of_UML_Relationship := (UML_Relationship_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Relationship : constant Ordered_Set_Of_UML_Relationship := (UML_Relationship_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Relationship : constant Bag_Of_UML_Relationship := (UML_Relationship_Collections.Bag with null record); Empty_Sequence_Of_UML_Relationship : constant Sequence_Of_UML_Relationship := (UML_Relationship_Collections.Sequence with null record); end AMF.UML.Relationships.Collections;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Upg1 is procedure Print(A, B: in Integer) is Spaces: Integer; begin if A < B then Spaces := (B - A) * 4; for I in 1..Spaces loop Put(' '); end loop; end if; for X in 1..A loop Put(B,1); Put(' '); if A = X then Put("= "); Put(A * B, 1); else Put("+ "); end if; end loop; New_Line; end; A, B : Integer; begin Put("Mata in tvΓ₯ positiva siffror: "); Get(A); Get(B); Skip_Line; New_Line; Print(A, B); Print(B, A); Put("Tryck ENTER fΓΆr at fortsΓ€tta..."); Skip_Line; Put("Multiplikation Γ€r KUL!"); end;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 4 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2014, 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. -- -- -- ------------------------------------------------------------------------------ -- Expand routines for chapter 4 constructs with Types; use Types; package Exp_Ch4 is procedure Expand_N_Allocator (N : Node_Id); procedure Expand_N_And_Then (N : Node_Id); procedure Expand_N_Case_Expression (N : Node_Id); procedure Expand_N_Explicit_Dereference (N : Node_Id); procedure Expand_N_Expression_With_Actions (N : Node_Id); procedure Expand_N_If_Expression (N : Node_Id); procedure Expand_N_In (N : Node_Id); procedure Expand_N_Indexed_Component (N : Node_Id); procedure Expand_N_Not_In (N : Node_Id); procedure Expand_N_Null (N : Node_Id); procedure Expand_N_Op_Abs (N : Node_Id); procedure Expand_N_Op_Add (N : Node_Id); procedure Expand_N_Op_And (N : Node_Id); procedure Expand_N_Op_Concat (N : Node_Id); procedure Expand_N_Op_Divide (N : Node_Id); procedure Expand_N_Op_Expon (N : Node_Id); procedure Expand_N_Op_Eq (N : Node_Id); procedure Expand_N_Op_Ge (N : Node_Id); procedure Expand_N_Op_Gt (N : Node_Id); procedure Expand_N_Op_Le (N : Node_Id); procedure Expand_N_Op_Lt (N : Node_Id); procedure Expand_N_Op_Minus (N : Node_Id); procedure Expand_N_Op_Mod (N : Node_Id); procedure Expand_N_Op_Multiply (N : Node_Id); procedure Expand_N_Op_Ne (N : Node_Id); procedure Expand_N_Op_Not (N : Node_Id); procedure Expand_N_Op_Or (N : Node_Id); procedure Expand_N_Op_Plus (N : Node_Id); procedure Expand_N_Op_Rem (N : Node_Id); procedure Expand_N_Op_Rotate_Left (N : Node_Id); procedure Expand_N_Op_Rotate_Right (N : Node_Id); procedure Expand_N_Op_Shift_Left (N : Node_Id); procedure Expand_N_Op_Shift_Right (N : Node_Id); procedure Expand_N_Op_Shift_Right_Arithmetic (N : Node_Id); procedure Expand_N_Op_Subtract (N : Node_Id); procedure Expand_N_Op_Xor (N : Node_Id); procedure Expand_N_Or_Else (N : Node_Id); procedure Expand_N_Qualified_Expression (N : Node_Id); procedure Expand_N_Quantified_Expression (N : Node_Id); procedure Expand_N_Selected_Component (N : Node_Id); procedure Expand_N_Slice (N : Node_Id); procedure Expand_N_Type_Conversion (N : Node_Id); procedure Expand_N_Unchecked_Expression (N : Node_Id); procedure Expand_N_Unchecked_Type_Conversion (N : Node_Id); function Expand_Record_Equality (Nod : Node_Id; Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id; -- Expand a record equality into an expression that compares the fields -- individually to yield the required Boolean result. Loc is the -- location for the generated nodes. Typ is the type of the record, and -- Lhs, Rhs are the record expressions to be compared, these -- expressions need not to be analyzed but have to be side-effect free. -- Bodies is a list on which to attach bodies of local functions that -- are created in the process. This is the responsibility of the caller -- to insert those bodies at the right place. Nod provides the Sloc -- value for generated code. procedure Expand_Set_Membership (N : Node_Id); -- For each choice of a set membership, we create a simple equality or -- membership test. The whole membership is rewritten connecting these -- with OR ELSE. function Integer_Promotion_Possible (N : Node_Id) return Boolean; -- Returns true if the node is a type conversion whose operand is an -- arithmetic operation on signed integers, and the base type of the -- signed integer type is smaller than Standard.Integer. In such case we -- have special circuitry in Expand_N_Type_Conversion to promote both of -- the operands to type Integer. end Exp_Ch4;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M E M R O O T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1997-2005, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package offers basic types that deal with gdb backtraces related -- to memory allocation. A memory root (root_id) is a backtrace -- referencing the actual point of allocation along with counters -- recording various information concerning allocation at this root. -- A back trace is composed of Frames (Frame_Id) which themselves are -- nothing else than a subprogram call at a source location which can be -- represented by three strings: subprogram name, file name and line -- number. All the needed strings are entered in a table and referenced -- through a Name_Id in order to avoid duplication. with System.Storage_Elements; use System.Storage_Elements; package Memroot is -- Simple abstract type for names. A name is a sequence of letters type Name_Id is new Natural; No_Name_Id : constant Name_Id := 0; function Enter_Name (S : String) return Name_Id; function Image (N : Name_Id) return String; -- Simple abstract type for a backtrace frame. A frame is composed by -- a subprogram name, a file name and a line reference. type Frame_Id is new Natural; No_Frame_Id : constant Frame_Id := 0; function Enter_Frame (Addr : System.Address; Name : Name_Id; File : Name_Id; Line : Name_Id) return Frame_Id; type Frame_Array is array (Natural range <>) of Frame_Id; -- Simple abstract type for an allocation root. It is composed by a set -- of frames, the number of allocation, the total size of allocated -- memory, and the high water mark. An iterator is also provided to -- iterate over all the entered allocation roots. type Root_Id is new Natural; No_Root_Id : constant Root_Id := 0; function Read_BT (BT_Depth : Integer) return Root_Id; -- Reads a backtrace whose maximum frame number is given by -- BT_Depth and returns the corresponding Allocation root. function Enter_Root (Fr : Frame_Array) return Root_Id; -- Create an allocation root from the frames that compose it function Frames_Of (B : Root_Id) return Frame_Array; -- Retreives the Frames of the root's backtrace procedure Print_BT (B : Root_Id; Short : Boolean := False); -- Prints on standard out the backtrace associated with the root B -- When Short is set to True, only the filename & line info is printed. -- When it is set to false, the subprogram name is also printed. function Get_First return Root_Id; function Get_Next return Root_Id; -- Iterator to iterate over roots procedure Set_Nb_Alloc (B : Root_Id; V : Integer); function Nb_Alloc (B : Root_Id) return Integer; -- Access and modify the number of allocation counter associated with -- this allocation root. If the value is negative, it means that this is -- not an allocation root but a deallocation root (this can only happen -- in erroneous situations where there are more frees than allocations). procedure Set_Alloc_Size (B : Root_Id; V : Storage_Count); function Alloc_Size (B : Root_Id) return Storage_Count; -- Access and modify the total allocated memory counter associated with -- this allocation root. procedure Set_High_Water_Mark (B : Root_Id; V : Storage_Count); function High_Water_Mark (B : Root_Id) return Storage_Count; -- Access and modify the high water mark associated with this -- allocation root. The high water mark is the maximum value, over -- time, of the Alloc_Size. end Memroot;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M -- -- -- -- S p e c -- -- (GNU-Linux/x86 Version) -- -- -- -- Copyright (C) 1992-2003 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, 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. -- -- -- -- 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 (System); -- Note that we take advantage of the implementation permission to -- make this unit Pure instead of Preelaborable, see RM 13.7(36) 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 := Integer'Last; 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.000_001; -- Storage-related Declarations type Address is private; Null_Address : constant Address; Storage_Unit : constant := 8; Word_Size : constant := 32; Memory_Size : constant := 2 ** 32; -- 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 := Low_Order_First; -- 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. AAMP : constant Boolean := False; Backend_Divide_Checks : constant Boolean := False; Backend_Overflow_Checks : constant Boolean := False; 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; Functions_Return_By_DSP : constant Boolean := False; Machine_Overflows : constant Boolean := False; Machine_Rounds : constant Boolean := True; OpenVMS : constant Boolean := False; Signed_Zeros : constant Boolean := True; Stack_Check_Default : constant Boolean := False; Stack_Check_Probes : constant Boolean := False; Support_64_Bit_Divides : constant Boolean := True; Support_Aggregates : constant Boolean := True; Support_Composite_Assign : constant Boolean := True; Support_Composite_Compare : constant Boolean := True; Support_Long_Shifts : constant Boolean := True; Suppress_Standard_Library : constant Boolean := False; Use_Ada_Main_Program_Name : constant Boolean := False; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; Front_End_ZCX_Support : constant Boolean := False; -- Obsolete entries, to be removed eventually (bootstrap issues!) High_Integrity_Mode : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; end System;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with League.Strings; with League.String_Vectors; package Meta.Classes is type Capacity_Kind is (Just_One, Zero_Or_One, Zero_Or_More, One_Or_More); type Property is record Name : League.Strings.Universal_String; Type_Name : League.Strings.Universal_String; Capacity : Capacity_Kind := Just_One; end record; type Property_Array is array (Positive range <>) of Property; type Class is tagged private; not overriding function Name (Self : Class) return League.Strings.Universal_String; not overriding function Is_Abstract (Self : Class) return Boolean; not overriding function Parents (Self : Class) return League.String_Vectors.Universal_String_Vector; not overriding function Properties (Self : Class) return Property_Array; not overriding procedure Initialize (Self : in out Class; Name : League.Strings.Universal_String; Is_Abstract : Boolean := False); not overriding procedure Add_Parent (Self : in out Class; Name : League.Strings.Universal_String); not overriding procedure Add_Property (Self : in out Class; Value : Property); generic with function Pass (Value : Property) return Boolean; function Generic_Filter (List : Property_Array) return Property_Array; private type Class is tagged record Name : League.Strings.Universal_String; Is_Abstract : Boolean; Parents : League.String_Vectors.Universal_String_Vector; Properties : Property_Array (1 .. 30); Last_Prop : Natural := 0; end record; end Meta.Classes;