max_stars_repo_path stringlengths 4 261 | max_stars_repo_name stringlengths 6 106 | max_stars_count int64 0 38.8k | id stringlengths 1 6 | text stringlengths 7 1.05M |
|---|---|---|---|---|
Web/asm/examples/Add 16-bit.asm | visrealm/vrcpu | 102 | 14673 | <filename>Web/asm/examples/Add 16-bit.asm
; Add two 16 bit numbers.
; Place result high byte in Rc, low byte in Rb
; Carry flag will be set if result is > 16 bits
FIRST = 0x00
SECOND = FIRST + 0x02
NUMBER1 = 12345
NUMBER2 = 12122
.setup:
clra
data SP, 0xff
; first number
data Ra, NUMBER1 >> 8 ; high byte
data Rd, NUMBER1 ; low byte
sto Rd, FIRST
sto Ra, FIRST + 0x01
; second number
data Ra, NUMBER2 >> 8 ; high byte
data Rd, NUMBER2 ; low byte
sto Rd, SECOND
sto Ra, SECOND + 0x01
data Ra, FIRST
data Rd, SECOND
call .add16
lod Rd, FIRST
lod Rc, FIRST + 0x01
data Rb, 0xff
add Ra ; ensure the carry flag is set if we overflowed
mov Rb, Rd
hlt
; adds 16-bit numbers in memory.
; Number 1 address in Ra
; Number 2 address in Rd
.add16:
lod Rb, Ra ; load first low byte into Rb
lod Rc, Rd ; load second low byte into Rc
add Rc ; sum to Rc
sto Ra, Rc ; write back to first address
jnc .addHigh
.addCarry:
inc Ra
lod Rb, Ra
inc Rb
sto Ra, Rb
dec Ra
.addHigh:
inc Ra ; go to high byte
inc Rd ; go to high byte
lod Rb, Ra ; load first low byte into Rb
lod Rc, Rd ; load second low byte into Rc
add Rc ; sum to Rc
sto Ra, Rc ; write back to first address
data Ra, 0
jnc .done
inc Ra ; overflow
.done:
ret |
src/util-properties-json.adb | Letractively/ada-util | 0 | 15015 | <reponame>Letractively/ada-util<gh_stars>0
-----------------------------------------------------------------------
-- util-properties-json -- read json files into properties
-- Copyright (C) 2013 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Serialize.IO.JSON;
with Util.Stacks;
with Util.Beans.Objects;
package body Util.Properties.JSON is
type Natural_Access is access all Natural;
package Length_Stack is new Util.Stacks (Element_Type => Natural,
Element_Type_Access => Natural_Access);
type Parser is new Util.Serialize.IO.JSON.Parser with record
Base_Name : Ada.Strings.Unbounded.Unbounded_String;
Lengths : Length_Stack.Stack;
Separator : Ada.Strings.Unbounded.Unbounded_String;
Separator_Length : Natural;
end record;
-- Start a new object associated with the given name. This is called when
-- the '{' is reached. The reader must be updated so that the next
-- <b>Set_Member</b> procedure will associate the name/value pair on the
-- new object.
overriding
procedure Start_Object (Handler : in out Parser;
Name : in String);
-- Finish an object associated with the given name. The reader must be
-- updated to be associated with the previous object.
overriding
procedure Finish_Object (Handler : in out Parser;
Name : in String);
-- -----------------------
-- Start a new object associated with the given name. This is called when
-- the '{' is reached. The reader must be updated so that the next
-- <b>Set_Member</b> procedure will associate the name/value pair on the
-- new object.
-- -----------------------
overriding
procedure Start_Object (Handler : in out Parser;
Name : in String) is
begin
if Name'Length > 0 then
Ada.Strings.Unbounded.Append (Handler.Base_Name, Name);
Ada.Strings.Unbounded.Append (Handler.Base_Name, Handler.Separator);
Length_Stack.Push (Handler.Lengths);
Length_Stack.Current (Handler.Lengths).all := Name'Length + Handler.Separator_Length;
end if;
end Start_Object;
-- -----------------------
-- Finish an object associated with the given name. The reader must be
-- updated to be associated with the previous object.
-- -----------------------
overriding
procedure Finish_Object (Handler : in out Parser;
Name : in String) is
Len : constant Natural := Ada.Strings.Unbounded.Length (Handler.Base_Name);
begin
if Name'Length > 0 then
Ada.Strings.Unbounded.Delete (Handler.Base_Name,
Len - Name'Length - Handler.Separator_Length + 1, Len);
end if;
end Finish_Object;
-- -----------------------
-- Parse the JSON content and put the flattened content in the property manager.
-- -----------------------
procedure Parse_JSON (Manager : in out Util.Properties.Manager'Class;
Content : in String;
Flatten_Separator : in String := ".") is
type Local_Parser is new Parser with record
Manager : access Util.Properties.Manager'Class;
end record;
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
overriding
procedure Set_Member (Handler : in out Local_Parser;
Name : in String;
Value : in Util.Beans.Objects.Object;
Attribute : in Boolean := False);
-- -----------------------
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
-- -----------------------
overriding
procedure Set_Member (Handler : in out Local_Parser;
Name : in String;
Value : in Util.Beans.Objects.Object;
Attribute : in Boolean := False) is
pragma Unreferenced (Attribute);
begin
Handler.Manager.Set (Ada.Strings.Unbounded.To_String (Handler.Base_Name) & Name,
Util.Beans.Objects.To_String (Value));
end Set_Member;
P : Local_Parser;
begin
P.Separator := Ada.Strings.Unbounded.To_Unbounded_String (Flatten_Separator);
P.Separator_Length := Flatten_Separator'Length;
P.Manager := Manager'Access;
P.Parse_String (Content);
if P.Has_Error then
raise Util.Serialize.IO.Parse_Error;
end if;
end Parse_JSON;
-- -----------------------
-- Read the JSON file into the property manager.
-- The JSON content is flatten into Flatten the JSON content and add the properties.
-- -----------------------
procedure Read_JSON (Manager : in out Util.Properties.Manager'Class;
Path : in String;
Flatten_Separator : in String := ".") is
type Local_Parser is new Parser with record
Manager : access Util.Properties.Manager'Class;
end record;
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
overriding
procedure Set_Member (Handler : in out Local_Parser;
Name : in String;
Value : in Util.Beans.Objects.Object;
Attribute : in Boolean := False);
-- -----------------------
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
-- -----------------------
overriding
procedure Set_Member (Handler : in out Local_Parser;
Name : in String;
Value : in Util.Beans.Objects.Object;
Attribute : in Boolean := False) is
pragma Unreferenced (Attribute);
begin
Handler.Manager.Set (Ada.Strings.Unbounded.To_String (Handler.Base_Name) & Name,
Util.Beans.Objects.To_String (Value));
end Set_Member;
P : Local_Parser;
begin
P.Manager := Manager'Access;
P.Separator := Ada.Strings.Unbounded.To_Unbounded_String (Flatten_Separator);
P.Separator_Length := Flatten_Separator'Length;
P.Parse (Path);
if P.Has_Error then
raise Util.Serialize.IO.Parse_Error;
end if;
end Read_JSON;
end Util.Properties.JSON;
|
src/Categories/Minus2-Category.agda | Trebor-Huang/agda-categories | 279 | 4373 | <reponame>Trebor-Huang/agda-categories
{-# OPTIONS --without-K --safe #-}
-- 'Traditionally', meaning in nLab and in
-- "Lectures on n-Categories and Cohomology" by <NAME> Shulman
-- https://arxiv.org/abs/math/0608420
-- (-2)-Categories are defined to be just a single value, with trivial Hom
-- But that's hardly a definition of a class of things, it's a definition of
-- a single structure! What we want is the definition of a class which turns
-- out to be (essentially) unique. Rather like the reals are (essentially) the
-- only ordered complete archimedean field.
-- So we will take a -2-Category to be a full-fledge Category, but where
-- 1. |Obj| is (Categorically) contractible
-- 2. |Hom| is connected (all arrows are equal)
-- Note that we don't need to say anything at all about ≈
module Categories.Minus2-Category where
open import Level
open import Categories.Category
open import Data.Product using (Σ)
import Categories.Morphism as M
private
variable
o ℓ e : Level
record -2-Category : Set (suc (o ⊔ ℓ ⊔ e)) where
field
cat : Category o ℓ e
open Category cat public
open M cat using (_≅_)
field
Obj-Contr : Σ Obj (λ x → (y : Obj) → x ≅ y)
Hom-Conn : {x y : Obj} {f g : x ⇒ y} → f ≈ g
|
s2/music-original/8C - EHZ 2P.asm | Cancer52/flamedriver | 9 | 13771 | <reponame>Cancer52/flamedriver
EHZ_2p_Header:
smpsHeaderStartSong 2
smpsHeaderVoice EHZ_2p_Voices
smpsHeaderChan $06, $03
smpsHeaderTempo $01, $5B
smpsHeaderDAC EHZ_2p_DAC
smpsHeaderFM EHZ_2p_FM1, $F4, $0A
smpsHeaderFM EHZ_2p_FM2, $F4, $0F
smpsHeaderFM EHZ_2p_FM3, $F4, $0A
smpsHeaderFM EHZ_2p_FM4, $F4, $10
smpsHeaderFM EHZ_2p_FM5, $E8, $10
smpsHeaderPSG EHZ_2p_PSG1, $D0, $06, $00, $00
smpsHeaderPSG EHZ_2p_PSG2, $D0, $06, $00, $00
smpsHeaderPSG EHZ_2p_PSG3, $00, $05, $00, $00
; FM1 Data
EHZ_2p_FM1:
smpsSetvoice $04
smpsAlterNote $01
dc.b nG6, $06, nE6, nF6, nD6, nE6, nC6, nC6, nA5
EHZ_2p_Jump01:
smpsCall EHZ_2p_Call02
smpsSetvoice $03
smpsAlterVol $06
dc.b nG4, $06
smpsNoteFill $06
dc.b nA4, $03, nC5, nC5, nA4
smpsSetvoice $04
smpsAlterVol $FA
smpsNoteFill $00
smpsCall EHZ_2p_Call02
dc.b nRst, $12, nC6, $18, nA5, $0C, nC6, nBb5, nC6, $06, nD6, $0C
dc.b nC6, $06, nBb5, $0C, nC6, $18, nA5, $0C, nC6, nBb5, $06
smpsSetvoice $02
smpsAlterVol $06
dc.b nEb5, $06, nF5, nEb5, nRst, nEb5, nF5, nEb5
smpsSetvoice $04
smpsAlterVol $FA
dc.b nC6, $18, nA5, $0C, nC6, nBb5, nC6, $06, nD6, $0C, nC6, $06
dc.b nBb5, $0C, nA5, $18, nF5, $0C, nA5
smpsSetvoice $02
smpsAlterVol $06
dc.b nG5, $03, nRst, nG5, $06, nA5, $03, nG5, nA5, $06, nG5, $03
dc.b nRst, $15
smpsSetvoice $04
smpsAlterVol $FA
smpsJump EHZ_2p_Jump01
EHZ_2p_Call02:
smpsSetvoice $03
smpsAlterVol $06
dc.b nE5, $06
smpsNoteFill $06
dc.b nC5, $03, nA4, nC5, $06, nRst, nRst
smpsSetvoice $04
smpsAlterVol $FA
smpsNoteFill $00
dc.b nB4, $06, $09, $03
smpsSetvoice $03
smpsAlterVol $06
smpsNoteFill $06
dc.b nF5, $03, nF5, nRst, nF5, nRst, nF5
smpsNoteFill $00
dc.b nFs5, $06, nG5, nRst
smpsNoteFill $06
dc.b nG5, $03, $03, nA5, nG5
smpsNoteFill $00
dc.b nE5, $06
smpsNoteFill $06
dc.b nC5, $03, nA4, nC5, $06, nRst, nRst
smpsNoteFill $00
smpsSetvoice $04
smpsAlterVol $FA
dc.b nE5, nG5, nE5
smpsSetvoice $02
smpsAlterVol $06
smpsNoteFill $06
dc.b nF5, $03, nF5, nRst, nF5, nRst, nF5
smpsNoteFill $00
dc.b nFs5, $06, nG5, $03, nRst
smpsSetvoice $04
smpsAlterVol $FA
smpsReturn
; FM4 Data
EHZ_2p_FM4:
smpsSetvoice $04
smpsAlterVol $FA
dc.b nRst, $03, nF6, $06, nD6, nE6, nC6, nD6, nB5, nB5, nG5, $03
smpsAlterVol $06
EHZ_2p_Loop05:
smpsSetvoice $01
smpsPan panRight, $00
smpsAlterPitch $F4
smpsNoteFill $06
dc.b nRst, $06, nE5, $03, $09, $0C, nG5, $03, $09, $06
smpsSetvoice $04
smpsPan panCenter, $00
smpsAlterVol $FA
smpsNoteFill $00
dc.b nA5
smpsNoteFill $06
smpsAlterVol $06
smpsSetvoice $01
smpsPan panRight, $00
dc.b nF5, $03, $09, $0C, nG5, $03, $09, $0C, nE5, $03, $09, $0C
dc.b nG5, $03, $09, $06
smpsSetvoice $02
smpsPan panCenter, $00
smpsAlterPitch $0C
dc.b nA5, $03, nA5, nRst, nA5, nRst, nA5
smpsNoteFill $00
dc.b nBb5, $06, nB5, $03
smpsSetvoice $01
smpsPan panRight, $00
smpsAlterPitch $F4
smpsNoteFill $06
dc.b nRst, nG5, $03, $09, $06
smpsSetvoice $02
smpsPan panCenter, $00
smpsAlterPitch $0C
smpsNoteFill $00
smpsLoop $00, $02, EHZ_2p_Loop05
smpsSetvoice $01
smpsPan panRight, $00
smpsAlterPitch $F4
smpsNoteFill $06
dc.b nRst, $06, nA5, $03, $09, $03, $09, $03, $09, $03, $03, nRst
dc.b $06, nG5, $03, $09, $03, $09, $03, $09, $03, $03, nRst, $06
dc.b nA5, $03, $09, $03, $09, $03, $09, $03, $03
smpsSetvoice $02
smpsPan panCenter, $00
smpsAlterPitch $0C
smpsNoteFill $00
dc.b nRst, $06, nG5, nA5, nG5, nRst, nG5, nA5, nG5
smpsSetvoice $01
smpsPan panRight, $00
smpsAlterPitch $F4
smpsNoteFill $06
dc.b nRst, $06, nA5, $03, $09, $03, $09, $03, $09, $03, $03, nRst
dc.b $06, nG5, $03, $09, $03, $09, $03, $09, $03, $03, nRst, $06
dc.b nF5, $03, $09, $03, $09, $03, $09, $03, $03
smpsSetvoice $02
smpsPan panCenter, $00
smpsAlterPitch $0C
smpsNoteFill $00
dc.b nB5, $03, nRst, nB5, $06, nC6, $03, nB5, nC6, $06, nB5, $03
dc.b nRst, $15
smpsJump EHZ_2p_Loop05
; FM3 Data
EHZ_2p_FM3:
smpsSetvoice $03
smpsNoteFill $06
dc.b nRst, $1E, nG5, $03, $03, nA5, nC6, nC6, nA5
EHZ_2p_Jump00:
smpsCall EHZ_2p_Call00
smpsSetvoice $01
smpsPan panRight, $00
smpsAlterPitch $F4
smpsNoteFill $06
smpsAlterVol $06
dc.b nRst, $06, nF5, $03, $09, $06
smpsSetvoice $03
smpsPan panCenter, $00
smpsAlterPitch $0C
smpsNoteFill $00
smpsAlterVol $FA
dc.b nRst, nG5
smpsNoteFill $06
dc.b nA5, $03, nC6, nC6, nA5
smpsCall EHZ_2p_Call00
smpsSetvoice $01
smpsPan panRight, $00
smpsAlterPitch $F4
smpsNoteFill $06
smpsAlterVol $06
dc.b nRst, $06, nF5, $03, $09, $06, nRst, nG5, $03, $09, $06
smpsSetvoice $03
smpsPan panCenter, $00
smpsAlterPitch $0C
smpsNoteFill $00
smpsAlterVol $FA
smpsCall EHZ_2p_Call01
dc.b nRst, $30
smpsCall EHZ_2p_Call01
smpsSetvoice $01
smpsPan panRight, $00
smpsAlterPitch $F4
smpsNoteFill $06
smpsAlterVol $06
dc.b nRst, $06, nG5, $03, $09, $03, $09, $03, $09, $03, $03
smpsSetvoice $03
smpsPan panCenter, $00
smpsAlterPitch $0C
smpsNoteFill $00
smpsAlterVol $FA
smpsCall EHZ_2p_Call01
dc.b nRst, $30, nD6, $0C, nE6, nF6, nFs6, nG6, $06
smpsSetvoice $01
smpsPan panRight, $00
smpsAlterPitch $F4
smpsNoteFill $06
smpsAlterVol $06
dc.b nB5, $03, $09, $03, $03
smpsSetvoice $03
smpsPan panCenter, $00
smpsAlterPitch $0C
smpsNoteFill $00
smpsAlterVol $FA
smpsNoteFill $00
dc.b nRst, $06, nG5
smpsNoteFill $06
dc.b nA5, $03, nC6, nC6, nA5
smpsJump EHZ_2p_Jump00
EHZ_2p_Call01:
smpsNoteFill $06
dc.b nRst, $06, nA5, nF5, $03, nC5, $06, $03, nF5, $06, nA5, nBb5
dc.b $03
smpsNoteFill $00
dc.b nA5, $09
smpsReturn
EHZ_2p_Call00:
smpsNoteFill $00
dc.b nE6, $06
smpsNoteFill $06
dc.b nC6, $03, nA5, nC6, $06, nRst, nRst, $09
smpsSetvoice $04
smpsNoteFill $00
dc.b nC5, nA4, $06
smpsNoteFill $06
smpsSetvoice $03
dc.b nF6, $03, nF6, nRst, nF6, nRst, nF6
smpsNoteFill $00
dc.b nFs6, $06, nG6, nRst
smpsNoteFill $06
dc.b nG6, $03, $03, nA6, nG6
smpsNoteFill $00
dc.b nE6, $06
smpsNoteFill $06
dc.b nC6, $03, nA5, nC6, $06
smpsNoteFill $00
smpsSetvoice $04
dc.b nRst, $0F, nF5, $06, nF5, nC5, $03
smpsReturn
; FM5 Data
EHZ_2p_FM5:
smpsPan panLeft, $01
smpsSetvoice $01
dc.b nRst, $30
EHZ_2p_Loop03:
smpsNoteFill $06
dc.b nRst, $06, nG5, $03, $09, $0C, nB5, $03, $09, $06, nRst, nA5
dc.b $03, $09, $0C, nB5, $03, $09, $06
smpsLoop $00, $04, EHZ_2p_Loop03
EHZ_2p_Loop04:
dc.b nRst, $06, nC6, $03, $09, $03, $09, $03, $09, $03, $03, nRst
dc.b $06, nBb5, $03, $09, $03, $09, $03, $09, $03, $03
smpsLoop $00, $03, EHZ_2p_Loop04
dc.b nRst, $06, nA5, $03, $09, $03, $09, $03, $09, $03, $03, nRst
dc.b $06, nD6, $03, $09, $03, $1B
smpsJump EHZ_2p_Loop03
; FM2 Data
EHZ_2p_FM2:
smpsSetvoice $03
smpsNoteFill $06
dc.b nRst, $1E, nG4, $03, $03, nA4, nC5, nC5, nA4
smpsSetvoice $00
smpsAlterVol $FA
EHZ_2p_Loop01:
smpsNoteFill $00
dc.b nRst, $06, nC4, nA3, $03, $03, nG3, $06, nRst, nB3, nA3, $03
dc.b $03, nG3, $06, nRst, nA3, nG3, $03, $03, nF3, $06, nRst, nG3
dc.b $06, $03, $03, nA3, nG3, nRst, $06, nC4, nA3, $03, $03, nG3
dc.b $06, nRst, nB3, nA3, $03, $03, nG3, $06
smpsSetvoice $04
dc.b nC5
smpsSetvoice $00
dc.b nA3, nG3, $03, $03, nF3, $06, nRst, nG3, $06, $03, $03, nA3
dc.b nG3
smpsLoop $00, $02, EHZ_2p_Loop01
EHZ_2p_Loop02:
dc.b nRst, $06, nF4, $03, $03, nD4, nD4, nC4, nC4, nRst, $06, nF4
dc.b $03, $03, nD4, nD4, nC4, nC4, nRst, $06, nEb4, $03, $03, nC4
dc.b nC4, nBb3, nBb3, nRst, $06, nEb4, $03, $03, nC4, nC4, nBb3, nBb3
smpsLoop $00, $03, EHZ_2p_Loop02
dc.b nRst, $06, nD4, $03, $03, nC4, nC4, nA3, nA3, nRst, $06, nD4
dc.b $03, $03, nC4, nC4, nA3, nA3, nG3, $06, $06, nA3, $03, nG3
dc.b nA3, $06, nG3, $18
smpsJump EHZ_2p_Loop01
; DAC Data
EHZ_2p_DAC:
dc.b dMidTom, $03, dMidTom, dMidTom, $06, dLowTom, $03, dLowTom, dLowTom, $06, dFloorTom, $03
dc.b dFloorTom, dFloorTom, $06, dLowTom, dFloorTom
EHZ_2p_Loop00:
dc.b dKick, dKick, dFloorTom, nRst, dKick, dKick, dFloorTom, nRst
smpsLoop $00, $0F, EHZ_2p_Loop00
dc.b dKick, dKick, dFloorTom, nRst, dMidTom, $03, dMidTom, dMidTom, $06, dLowTom, dFloorTom
smpsJump EHZ_2p_Loop00
; PSG1 Data
EHZ_2p_PSG1:
dc.b nRst, $02
smpsPSGvoice fTone_08
smpsAlterVol $04
dc.b nG6, $03, nF6, nE6, nD6, nF6, nE6, nD6, nC6, nE6, nD6, nC6
dc.b nB5, nC6, nB5, nA5, nG5, $01
smpsAlterVol $FC
smpsAlterPitch $04
smpsJump EHZ_2p_Loop06
; PSG2 Data
EHZ_2p_PSG2:
dc.b nRst, $30
EHZ_2p_Loop06:
smpsNoteFill $06
dc.b nRst, $06, nC5, $03, $09, $0C, nG5, $03, $09, $06, nRst, nF5
dc.b $03, $09, $0C, nG5, $03, $09, $06
smpsLoop $00, $04, EHZ_2p_Loop06
smpsNoteFill $00
smpsPSGvoice fTone_0B
dc.b nF5, $18, nF5, $0C, nF5, nEb5, nF5, $06, nEb5, $0C, nF5, $06
dc.b nEb5, $0C, nF5, $18, nF5, $0C, nF5, nEb5, $30, nF5, $18, nF5
dc.b $0C, nF5, nEb5, nF5, $06, nEb5, $0C, nF5, $06, nEb5, $0C, nF5
dc.b $18, nF5, $0C, nF5, nG5, $06, nRst, $2A
smpsJump EHZ_2p_Loop06
; PSG3 Data
EHZ_2p_PSG3:
dc.b nRst, $30
EHZ_2p_Jump02:
smpsPSGvoice fTone_04
smpsPSGform $E7
smpsModSet $00, $01, $01, $01
dc.b nMaxPSG, $03, nMaxPSG, nMaxPSG, $06
smpsJump EHZ_2p_Jump02
EHZ_2p_Voices:
; Voice $00
; $20
; $66, $65, $60, $60, $DF, $DF, $9F, $1F, $00, $06, $09, $0C
; $07, $06, $06, $08, $2F, $1F, $1F, $FF, $1C, $3A, $16, $80
smpsVcAlgorithm $00
smpsVcFeedback $04
smpsVcUnusedBits $00
smpsVcDetune $06, $06, $06, $06
smpsVcCoarseFreq $00, $00, $05, $06
smpsVcRateScale $00, $02, $03, $03
smpsVcAttackRate $1F, $1F, $1F, $1F
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $0C, $09, $06, $00
smpsVcDecayRate2 $08, $06, $06, $07
smpsVcDecayLevel $0F, $01, $01, $02
smpsVcReleaseRate $0F, $0F, $0F, $0F
smpsVcTotalLevel $00, $16, $3A, $1C
; Voice $01
; $0D
; $32, $08, $06, $01, $1F, $19, $19, $19, $0A, $05, $05, $05
; $00, $02, $02, $02, $3F, $2F, $2F, $2F, $28, $80, $86, $8D
smpsVcAlgorithm $05
smpsVcFeedback $01
smpsVcUnusedBits $00
smpsVcDetune $00, $00, $00, $03
smpsVcCoarseFreq $01, $06, $08, $02
smpsVcRateScale $00, $00, $00, $00
smpsVcAttackRate $19, $19, $19, $1F
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $05, $05, $05, $0A
smpsVcDecayRate2 $02, $02, $02, $00
smpsVcDecayLevel $02, $02, $02, $03
smpsVcReleaseRate $0F, $0F, $0F, $0F
smpsVcTotalLevel $0D, $06, $00, $28
; Voice $02
; $3A
; $61, $08, $51, $02, $5D, $5D, $5D, $50, $04, $0F, $1F, $1F
; $00, $00, $00, $00, $1F, $5F, $0F, $0F, $22, $1E, $22, $80
smpsVcAlgorithm $02
smpsVcFeedback $07
smpsVcUnusedBits $00
smpsVcDetune $00, $05, $00, $06
smpsVcCoarseFreq $02, $01, $08, $01
smpsVcRateScale $01, $01, $01, $01
smpsVcAttackRate $10, $1D, $1D, $1D
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $1F, $1F, $0F, $04
smpsVcDecayRate2 $00, $00, $00, $00
smpsVcDecayLevel $00, $00, $05, $01
smpsVcReleaseRate $0F, $0F, $0F, $0F
smpsVcTotalLevel $00, $22, $1E, $22
; Voice $03
; $02
; $01, $55, $02, $04, $92, $8D, $8E, $54, $0D, $0C, $00, $03
; $00, $00, $00, $00, $FF, $2F, $0F, $5F, $16, $2A, $1D, $80
smpsVcAlgorithm $02
smpsVcFeedback $00
smpsVcUnusedBits $00
smpsVcDetune $00, $00, $05, $00
smpsVcCoarseFreq $04, $02, $05, $01
smpsVcRateScale $01, $02, $02, $02
smpsVcAttackRate $14, $0E, $0D, $12
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $03, $00, $0C, $0D
smpsVcDecayRate2 $00, $00, $00, $00
smpsVcDecayLevel $05, $00, $02, $0F
smpsVcReleaseRate $0F, $0F, $0F, $0F
smpsVcTotalLevel $00, $1D, $2A, $16
; Voice $04
; $02
; $75, $71, $73, $31, $1F, $58, $96, $9F, $01, $1B, $03, $08
; $01, $04, $01, $05, $FF, $2F, $3F, $2F, $24, $29, $30, $80
smpsVcAlgorithm $02
smpsVcFeedback $00
smpsVcUnusedBits $00
smpsVcDetune $03, $07, $07, $07
smpsVcCoarseFreq $01, $03, $01, $05
smpsVcRateScale $02, $02, $01, $00
smpsVcAttackRate $1F, $16, $18, $1F
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $08, $03, $1B, $01
smpsVcDecayRate2 $05, $01, $04, $01
smpsVcDecayLevel $02, $03, $02, $0F
smpsVcReleaseRate $0F, $0F, $0F, $0F
smpsVcTotalLevel $00, $30, $29, $24
|
experiments/test-suite/mutation-based/10/1/fullTree.als | kaiyuanw/AlloyFLCore | 1 | 2002 | <filename>experiments/test-suite/mutation-based/10/1/fullTree.als
pred test15 {
some disj Node0, Node1: Node {
Node = Node0 + Node1
no left
right = Node0->Node1 + Node1->Node0
Acyclic[]
}
}
run test15 for 3 expect 0
pred test32 {
some disj Node0, Node1: Node {
Node = Node0 + Node1
no left
right = Node1->Node0
FullTree[]
}
}
run test32 for 3 expect 0
pred test43 {
some disj Node0, Node1: Node {
Node = Node0 + Node1
left = Node1->Node1
right = Node0->Node1 + Node1->Node1
}
}
run test43 for 3 expect 1
pred test31 {
some disj Node0: Node {
Node = Node0
left = Node0->Node0
no right
FullTree[]
}
}
run test31 for 3 expect 0
|
projects/07/StackArithmetic/StackTest/StackTest.asm | RobertCurry0216/nand2tetris | 0 | 6343 | <filename>projects/07/StackArithmetic/StackTest/StackTest.asm
// push constant 17
@17
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 17
@17
D=A
@SP
A=M
M=D
@SP
M=M+1
// eq
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-eq-9
D;JEQ
@end-9
D=0;JMP
(is-eq-9)
D=-1
(end-9)
@SP
A=M-1
M=D
// push constant 17
@17
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 16
@16
D=A
@SP
A=M
M=D
@SP
M=M+1
// eq
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-eq-12
D;JEQ
@end-12
D=0;JMP
(is-eq-12)
D=-1
(end-12)
@SP
A=M-1
M=D
// push constant 16
@16
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 17
@17
D=A
@SP
A=M
M=D
@SP
M=M+1
// eq
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-eq-15
D;JEQ
@end-15
D=0;JMP
(is-eq-15)
D=-1
(end-15)
@SP
A=M-1
M=D
// push constant 892
@892
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 891
@891
D=A
@SP
A=M
M=D
@SP
M=M+1
// lt
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-lt-18
D;JLT
@end-18
D=0;JMP
(is-lt-18)
D=-1
(end-18)
@SP
A=M-1
M=D
// push constant 891
@891
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 892
@892
D=A
@SP
A=M
M=D
@SP
M=M+1
// lt
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-lt-21
D;JLT
@end-21
D=0;JMP
(is-lt-21)
D=-1
(end-21)
@SP
A=M-1
M=D
// push constant 891
@891
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 891
@891
D=A
@SP
A=M
M=D
@SP
M=M+1
// lt
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-lt-24
D;JLT
@end-24
D=0;JMP
(is-lt-24)
D=-1
(end-24)
@SP
A=M-1
M=D
// push constant 32767
@32767
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 32766
@32766
D=A
@SP
A=M
M=D
@SP
M=M+1
// gt
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-gt-27
D;JGT
@end-27
D=0;JMP
(is-gt-27)
D=-1
(end-27)
@SP
A=M-1
M=D
// push constant 32766
@32766
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 32767
@32767
D=A
@SP
A=M
M=D
@SP
M=M+1
// gt
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-gt-30
D;JGT
@end-30
D=0;JMP
(is-gt-30)
D=-1
(end-30)
@SP
A=M-1
M=D
// push constant 32766
@32766
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 32766
@32766
D=A
@SP
A=M
M=D
@SP
M=M+1
// gt
@SP
AM=M-1
D=M
A=A-1
D=M-D
@is-gt-33
D;JGT
@end-33
D=0;JMP
(is-gt-33)
D=-1
(end-33)
@SP
A=M-1
M=D
// push constant 57
@57
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 31
@31
D=A
@SP
A=M
M=D
@SP
M=M+1
// push constant 53
@53
D=A
@SP
A=M
M=D
@SP
M=M+1
// add
@SP
AM=M-1
D=M
A=A-1
M=D+M
// push constant 112
@112
D=A
@SP
A=M
M=D
@SP
M=M+1
// sub
@SP
AM=M-1
D=M
A=A-1
M=M-D
// neg
@SP
A=M-1
M=-M
// and
@SP
AM=M-1
D=M
A=A-1
M=D&M
// push constant 82
@82
D=A
@SP
A=M
M=D
@SP
M=M+1
// or
@SP
AM=M-1
D=M
A=A-1
M=D|M
// not
@SP
A=M-1
M=!M
|
dialect/mysql/MySqlLexer.g4 | golangee/sql | 0 | 823 | /*
MySQL (Positive Technologies) grammar
The MIT License (MIT).
Copyright (c) 2015-2017, <NAME> (<EMAIL>), Positive Technologies.
Copyright (c) 2017, <NAME> (<EMAIL>)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
lexer grammar MySqlLexer;
channels { MYSQLCOMMENT, ERRORCHANNEL }
// SKIP
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
SPEC_MYSQL_COMMENT: '/*!' .+? '*/' -> channel(MYSQLCOMMENT);
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
LINE_COMMENT: (
('--' [ \t]? | '#') ~[\r\n]* ('\r'? '\n' | EOF)
| '--' ('\r'? '\n' | EOF)
) -> channel(HIDDEN);
// Keywords
// Common Keywords
ADD: 'ADD';
ALL: 'ALL';
ALTER: 'ALTER';
ALWAYS: 'ALWAYS';
ANALYZE: 'ANALYZE';
AND: 'AND';
AS: 'AS';
ASC: 'ASC';
BEFORE: 'BEFORE';
BETWEEN: 'BETWEEN';
BOTH: 'BOTH';
BY: 'BY';
CALL: 'CALL';
CASCADE: 'CASCADE';
CASE: 'CASE';
CAST: 'CAST';
CHANGE: 'CHANGE';
CHARACTER: 'CHARACTER';
CHECK: 'CHECK';
COLLATE: 'COLLATE';
COLUMN: 'COLUMN';
CONDITION: 'CONDITION';
CONSTRAINT: 'CONSTRAINT';
CONTINUE: 'CONTINUE';
CONVERT: 'CONVERT';
CREATE: 'CREATE';
CROSS: 'CROSS';
CURRENT: 'CURRENT';
CURRENT_USER: 'CURRENT_USER';
CURSOR: 'CURSOR';
DATABASE: 'DATABASE';
DATABASES: 'DATABASES';
DECLARE: 'DECLARE';
DEFAULT: 'DEFAULT';
DELAYED: 'DELAYED';
DELETE: 'DELETE';
DESC: 'DESC';
DESCRIBE: 'DESCRIBE';
DETERMINISTIC: 'DETERMINISTIC';
DIAGNOSTICS: 'DIAGNOSTICS';
DISTINCT: 'DISTINCT';
DISTINCTROW: 'DISTINCTROW';
DROP: 'DROP';
EACH: 'EACH';
ELSE: 'ELSE';
ELSEIF: 'ELSEIF';
ENCLOSED: 'ENCLOSED';
ESCAPED: 'ESCAPED';
EXISTS: 'EXISTS';
EXIT: 'EXIT';
EXPLAIN: 'EXPLAIN';
FALSE: 'FALSE';
FETCH: 'FETCH';
FOR: 'FOR';
FORCE: 'FORCE';
FOREIGN: 'FOREIGN';
FROM: 'FROM';
FULLTEXT: 'FULLTEXT';
GENERATED: 'GENERATED';
GET: 'GET';
GRANT: 'GRANT';
GROUP: 'GROUP';
HAVING: 'HAVING';
HIGH_PRIORITY: 'HIGH_PRIORITY';
IF: 'IF';
IGNORE: 'IGNORE';
IN: 'IN';
INDEX: 'INDEX';
INFILE: 'INFILE';
INNER: 'INNER';
INOUT: 'INOUT';
INSERT: 'INSERT';
INTERVAL: 'INTERVAL';
INTO: 'INTO';
IS: 'IS';
ITERATE: 'ITERATE';
JOIN: 'JOIN';
KEY: 'KEY';
KEYS: 'KEYS';
KILL: 'KILL';
LEADING: 'LEADING';
LEAVE: 'LEAVE';
LEFT: 'LEFT';
LIKE: 'LIKE';
LIMIT: 'LIMIT';
LINEAR: 'LINEAR';
LINES: 'LINES';
LOAD: 'LOAD';
LOCK: 'LOCK';
LOOP: 'LOOP';
LOW_PRIORITY: 'LOW_PRIORITY';
MASTER_BIND: 'MASTER_BIND';
MASTER_SSL_VERIFY_SERVER_CERT: 'MASTER_SSL_VERIFY_SERVER_CERT';
MATCH: 'MATCH';
MAXVALUE: 'MAXVALUE';
MODIFIES: 'MODIFIES';
NATURAL: 'NATURAL';
NOT: 'NOT';
NO_WRITE_TO_BINLOG: 'NO_WRITE_TO_BINLOG';
NULL_LITERAL: 'NULL';
NUMBER: 'NUMBER';
ON: 'ON';
OPTIMIZE: 'OPTIMIZE';
OPTION: 'OPTION';
OPTIONALLY: 'OPTIONALLY';
OR: 'OR';
ORDER: 'ORDER';
OUT: 'OUT';
OUTER: 'OUTER';
OUTFILE: 'OUTFILE';
PARTITION: 'PARTITION';
PRIMARY: 'PRIMARY';
PROCEDURE: 'PROCEDURE';
PURGE: 'PURGE';
RANGE: 'RANGE';
READ: 'READ';
READS: 'READS';
REFERENCES: 'REFERENCES';
REGEXP: 'REGEXP';
RELEASE: 'RELEASE';
RENAME: 'RENAME';
REPEAT: 'REPEAT';
REPLACE: 'REPLACE';
REQUIRE: 'REQUIRE';
RESIGNAL: 'RESIGNAL';
RESTRICT: 'RESTRICT';
RETURN: 'RETURN';
REVOKE: 'REVOKE';
RIGHT: 'RIGHT';
RLIKE: 'RLIKE';
SCHEMA: 'SCHEMA';
SCHEMAS: 'SCHEMAS';
SELECT: 'SELECT';
SET: 'SET';
SEPARATOR: 'SEPARATOR';
SHOW: 'SHOW';
SIGNAL: 'SIGNAL';
SPATIAL: 'SPATIAL';
SQL: 'SQL';
SQLEXCEPTION: 'SQLEXCEPTION';
SQLSTATE: 'SQLSTATE';
SQLWARNING: 'SQLWARNING';
SQL_BIG_RESULT: 'SQL_BIG_RESULT';
SQL_CALC_FOUND_ROWS: 'SQL_CALC_FOUND_ROWS';
SQL_SMALL_RESULT: 'SQL_SMALL_RESULT';
SSL: 'SSL';
STACKED: 'STACKED';
STARTING: 'STARTING';
STRAIGHT_JOIN: 'STRAIGHT_JOIN';
TABLE: 'TABLE';
TERMINATED: 'TERMINATED';
THEN: 'THEN';
TO: 'TO';
TRAILING: 'TRAILING';
TRIGGER: 'TRIGGER';
TRUE: 'TRUE';
UNDO: 'UNDO';
UNION: 'UNION';
UNIQUE: 'UNIQUE';
UNLOCK: 'UNLOCK';
UNSIGNED: 'UNSIGNED';
UPDATE: 'UPDATE';
USAGE: 'USAGE';
USE: 'USE';
USING: 'USING';
VALUES: 'VALUES';
WHEN: 'WHEN';
WHERE: 'WHERE';
WHILE: 'WHILE';
WITH: 'WITH';
WRITE: 'WRITE';
XOR: 'XOR';
ZEROFILL: 'ZEROFILL';
// DATA TYPE Keywords
TINYINT: 'TINYINT';
SMALLINT: 'SMALLINT';
MEDIUMINT: 'MEDIUMINT';
MIDDLEINT: 'MIDDLEINT';
INT: 'INT';
INT1: 'INT1';
INT2: 'INT2';
INT3: 'INT3';
INT4: 'INT4';
INT8: 'INT8';
INTEGER: 'INTEGER';
BIGINT: 'BIGINT';
REAL: 'REAL';
DOUBLE: 'DOUBLE';
PRECISION: 'PRECISION';
FLOAT: 'FLOAT';
FLOAT4: 'FLOAT4';
FLOAT8: 'FLOAT8';
DECIMAL: 'DECIMAL';
DEC: 'DEC';
NUMERIC: 'NUMERIC';
DATE: 'DATE';
TIME: 'TIME';
TIMESTAMP: 'TIMESTAMP';
DATETIME: 'DATETIME';
YEAR: 'YEAR';
CHAR: 'CHAR';
VARCHAR: 'VARCHAR';
NVARCHAR: 'NVARCHAR';
NATIONAL: 'NATIONAL';
BINARY: 'BINARY';
VARBINARY: 'VARBINARY';
TINYBLOB: 'TINYBLOB';
BLOB: 'BLOB';
MEDIUMBLOB: 'MEDIUMBLOB';
LONG: 'LONG';
LONGBLOB: 'LONGBLOB';
TINYTEXT: 'TINYTEXT';
TEXT: 'TEXT';
MEDIUMTEXT: 'MEDIUMTEXT';
LONGTEXT: 'LONGTEXT';
ENUM: 'ENUM';
VARYING: 'VARYING';
SERIAL: 'SERIAL';
// Interval type Keywords
YEAR_MONTH: 'YEAR_MONTH';
DAY_HOUR: 'DAY_HOUR';
DAY_MINUTE: 'DAY_MINUTE';
DAY_SECOND: 'DAY_SECOND';
HOUR_MINUTE: 'HOUR_MINUTE';
HOUR_SECOND: 'HOUR_SECOND';
MINUTE_SECOND: 'MINUTE_SECOND';
SECOND_MICROSECOND: 'SECOND_MICROSECOND';
MINUTE_MICROSECOND: 'MINUTE_MICROSECOND';
HOUR_MICROSECOND: 'HOUR_MICROSECOND';
DAY_MICROSECOND: 'DAY_MICROSECOND';
// JSON keywords
JSON_VALID: 'JSON_VALID';
JSON_SCHEMA_VALID: 'JSON_SCHEMA_VALID';
// Group function Keywords
AVG: 'AVG';
BIT_AND: 'BIT_AND';
BIT_OR: 'BIT_OR';
BIT_XOR: 'BIT_XOR';
COUNT: 'COUNT';
GROUP_CONCAT: 'GROUP_CONCAT';
MAX: 'MAX';
MIN: 'MIN';
STD: 'STD';
STDDEV: 'STDDEV';
STDDEV_POP: 'STDDEV_POP';
STDDEV_SAMP: 'STDDEV_SAMP';
SUM: 'SUM';
VAR_POP: 'VAR_POP';
VAR_SAMP: 'VAR_SAMP';
VARIANCE: 'VARIANCE';
// Common function Keywords
CURRENT_DATE: 'CURRENT_DATE';
CURRENT_TIME: 'CURRENT_TIME';
CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
LOCALTIME: 'LOCALTIME';
CURDATE: 'CURDATE';
CURTIME: 'CURTIME';
DATE_ADD: 'DATE_ADD';
DATE_SUB: 'DATE_SUB';
EXTRACT: 'EXTRACT';
LOCALTIMESTAMP: 'LOCALTIMESTAMP';
NOW: 'NOW';
POSITION: 'POSITION';
SUBSTR: 'SUBSTR';
SUBSTRING: 'SUBSTRING';
SYSDATE: 'SYSDATE';
TRIM: 'TRIM';
UTC_DATE: 'UTC_DATE';
UTC_TIME: 'UTC_TIME';
UTC_TIMESTAMP: 'UTC_TIMESTAMP';
// Keywords, but can be ID
// Common Keywords, but can be ID
ACCOUNT: 'ACCOUNT';
ACTION: 'ACTION';
AFTER: 'AFTER';
AGGREGATE: 'AGGREGATE';
ALGORITHM: 'ALGORITHM';
ANY: 'ANY';
AT: 'AT';
AUTHORS: 'AUTHORS';
AUTOCOMMIT: 'AUTOCOMMIT';
AUTOEXTEND_SIZE: 'AUTOEXTEND_SIZE';
AUTO_INCREMENT: 'AUTO_INCREMENT';
AVG_ROW_LENGTH: 'AVG_ROW_LENGTH';
BEGIN: 'BEGIN';
BINLOG: 'BINLOG';
BIT: 'BIT';
BLOCK: 'BLOCK';
BOOL: 'BOOL';
BOOLEAN: 'BOOLEAN';
BTREE: 'BTREE';
CACHE: 'CACHE';
CASCADED: 'CASCADED';
CHAIN: 'CHAIN';
CHANGED: 'CHANGED';
CHANNEL: 'CHANNEL';
CHECKSUM: 'CHECKSUM';
PAGE_CHECKSUM: 'PAGE_CHECKSUM';
CIPHER: 'CIPHER';
CLASS_ORIGIN: 'CLASS_ORIGIN';
CLIENT: 'CLIENT';
CLOSE: 'CLOSE';
COALESCE: 'COALESCE';
CODE: 'CODE';
COLUMNS: 'COLUMNS';
COLUMN_FORMAT: 'COLUMN_FORMAT';
COLUMN_NAME: 'COLUMN_NAME';
COMMENT: 'COMMENT';
COMMIT: 'COMMIT';
COMPACT: 'COMPACT';
COMPLETION: 'COMPLETION';
COMPRESSED: 'COMPRESSED';
COMPRESSION: 'COMPRESSION';
CONCURRENT: 'CONCURRENT';
CONNECTION: 'CONNECTION';
CONSISTENT: 'CONSISTENT';
CONSTRAINT_CATALOG: 'CONSTRAINT_CATALOG';
CONSTRAINT_SCHEMA: 'CONSTRAINT_SCHEMA';
CONSTRAINT_NAME: 'CONSTRAINT_NAME';
CONTAINS: 'CONTAINS';
CONTEXT: 'CONTEXT';
CONTRIBUTORS: 'CONTRIBUTORS';
COPY: 'COPY';
CPU: 'CPU';
CURSOR_NAME: 'CURSOR_NAME';
DATA: 'DATA';
DATAFILE: 'DATAFILE';
DEALLOCATE: 'DEALLOCATE';
DEFAULT_AUTH: 'DEFAULT_AUTH';
DEFINER: 'DEFINER';
DELAY_KEY_WRITE: 'DELAY_KEY_WRITE';
DES_KEY_FILE: 'DES_KEY_FILE';
DIRECTORY: 'DIRECTORY';
DISABLE: 'DISABLE';
DISCARD: 'DISCARD';
DISK: 'DISK';
DO: 'DO';
DUMPFILE: 'DUMPFILE';
DUPLICATE: 'DUPLICATE';
DYNAMIC: 'DYNAMIC';
ENABLE: 'ENABLE';
ENCRYPTION: 'ENCRYPTION';
END: 'END';
ENDS: 'ENDS';
ENGINE: 'ENGINE';
ENGINES: 'ENGINES';
ERROR: 'ERROR';
ERRORS: 'ERRORS';
ESCAPE: 'ESCAPE';
EVEN: 'EVEN';
EVENT: 'EVENT';
EVENTS: 'EVENTS';
EVERY: 'EVERY';
EXCHANGE: 'EXCHANGE';
EXCLUSIVE: 'EXCLUSIVE';
EXPIRE: 'EXPIRE';
EXPORT: 'EXPORT';
EXTENDED: 'EXTENDED';
EXTENT_SIZE: 'EXTENT_SIZE';
FAST: 'FAST';
FAULTS: 'FAULTS';
FIELDS: 'FIELDS';
FILE_BLOCK_SIZE: 'FILE_BLOCK_SIZE';
FILTER: 'FILTER';
FIRST: 'FIRST';
FIXED: 'FIXED';
FLUSH: 'FLUSH';
FOLLOWS: 'FOLLOWS';
FOUND: 'FOUND';
FULL: 'FULL';
FUNCTION: 'FUNCTION';
GENERAL: 'GENERAL';
GLOBAL: 'GLOBAL';
GRANTS: 'GRANTS';
GROUP_REPLICATION: 'GROUP_REPLICATION';
HANDLER: 'HANDLER';
HASH: 'HASH';
HELP: 'HELP';
HOST: 'HOST';
HOSTS: 'HOSTS';
IDENTIFIED: 'IDENTIFIED';
IGNORE_SERVER_IDS: 'IGNORE_SERVER_IDS';
IMPORT: 'IMPORT';
INDEXES: 'INDEXES';
INITIAL_SIZE: 'INITIAL_SIZE';
INPLACE: 'INPLACE';
INSERT_METHOD: 'INSERT_METHOD';
INSTALL: 'INSTALL';
INSTANCE: 'INSTANCE';
INVISIBLE: 'INVISIBLE';
INVOKER: 'INVOKER';
IO: 'IO';
IO_THREAD: 'IO_THREAD';
IPC: 'IPC';
ISOLATION: 'ISOLATION';
ISSUER: 'ISSUER';
JSON: 'JSON';
KEY_BLOCK_SIZE: 'KEY_BLOCK_SIZE';
LANGUAGE: 'LANGUAGE';
LAST: 'LAST';
LEAVES: 'LEAVES';
LESS: 'LESS';
LEVEL: 'LEVEL';
LIST: 'LIST';
LOCAL: 'LOCAL';
LOGFILE: 'LOGFILE';
LOGS: 'LOGS';
MASTER: 'MASTER';
MASTER_AUTO_POSITION: 'MASTER_AUTO_POSITION';
MASTER_CONNECT_RETRY: 'MASTER_CONNECT_RETRY';
MASTER_DELAY: 'MASTER_DELAY';
MASTER_HEARTBEAT_PERIOD: 'MASTER_HEARTBEAT_PERIOD';
MASTER_HOST: 'MASTER_HOST';
MASTER_LOG_FILE: 'MASTER_LOG_FILE';
MASTER_LOG_POS: 'MASTER_LOG_POS';
MASTER_PASSWORD: '<PASSWORD>';
MASTER_PORT: 'MASTER_PORT';
MASTER_RETRY_COUNT: 'MASTER_RETRY_COUNT';
MASTER_SSL: 'MASTER_SSL';
MASTER_SSL_CA: 'MASTER_SSL_CA';
MASTER_SSL_CAPATH: 'MASTER_SSL_CAPATH';
MASTER_SSL_CERT: 'MASTER_SSL_CERT';
MASTER_SSL_CIPHER: 'MASTER_SSL_CIPHER';
MASTER_SSL_CRL: 'MASTER_SSL_CRL';
MASTER_SSL_CRLPATH: 'MASTER_SSL_CRLPATH';
MASTER_SSL_KEY: 'MASTER_SSL_KEY';
MASTER_TLS_VERSION: 'MASTER_TLS_VERSION';
MASTER_USER: 'MASTER_USER';
MAX_CONNECTIONS_PER_HOUR: 'MAX_CONNECTIONS_PER_HOUR';
MAX_QUERIES_PER_HOUR: 'MAX_QUERIES_PER_HOUR';
MAX_ROWS: 'MAX_ROWS';
MAX_SIZE: 'MAX_SIZE';
MAX_UPDATES_PER_HOUR: 'MAX_UPDATES_PER_HOUR';
MAX_USER_CONNECTIONS: 'MAX_USER_CONNECTIONS';
MEDIUM: 'MEDIUM';
MEMBER: 'MEMBER';
MERGE: 'MERGE';
MESSAGE_TEXT: 'MESSAGE_TEXT';
MID: 'MID';
MIGRATE: 'MIGRATE';
MIN_ROWS: 'MIN_ROWS';
MODE: 'MODE';
MODIFY: 'MODIFY';
MUTEX: 'MUTEX';
MYSQL: 'MYSQL';
MYSQL_ERRNO: 'MYSQL_ERRNO';
NAME: 'NAME';
NAMES: 'NAMES';
NCHAR: 'NCHAR';
NEVER: 'NEVER';
NEXT: 'NEXT';
NO: 'NO';
NODEGROUP: 'NODEGROUP';
NONE: 'NONE';
OFFLINE: 'OFFLINE';
OFFSET: 'OFFSET';
OF: 'OF';
OJ: 'OJ';
OLD_PASSWORD: '<PASSWORD>';
ONE: 'ONE';
ONLINE: 'ONLINE';
ONLY: 'ONLY';
OPEN: 'OPEN';
OPTIMIZER_COSTS: 'OPTIMIZER_COSTS';
OPTIONS: 'OPTIONS';
OWNER: 'OWNER';
PACK_KEYS: 'PACK_KEYS';
PAGE: 'PAGE';
PARSER: 'PARSER';
PARTIAL: 'PARTIAL';
PARTITIONING: 'PARTITIONING';
PARTITIONS: 'PARTITIONS';
PASSWORD: 'PASSWORD';
PHASE: 'PHASE';
PLUGIN: 'PLUGIN';
PLUGIN_DIR: 'PLUGIN_DIR';
PLUGINS: 'PLUGINS';
PORT: 'PORT';
PRECEDES: 'PRECEDES';
PREPARE: 'PREPARE';
PRESERVE: 'PRESERVE';
PREV: 'PREV';
PROCESSLIST: 'PROCESSLIST';
PROFILE: 'PROFILE';
PROFILES: 'PROFILES';
PROXY: 'PROXY';
QUERY: 'QUERY';
QUICK: 'QUICK';
REBUILD: 'REBUILD';
RECOVER: 'RECOVER';
REDO_BUFFER_SIZE: 'REDO_BUFFER_SIZE';
REDUNDANT: 'REDUNDANT';
RELAY: 'RELAY';
RELAY_LOG_FILE: 'RELAY_LOG_FILE';
RELAY_LOG_POS: 'RELAY_LOG_POS';
RELAYLOG: 'RELAYLOG';
REMOVE: 'REMOVE';
REORGANIZE: 'REORGANIZE';
REPAIR: 'REPAIR';
REPLICATE_DO_DB: 'REPLICATE_DO_DB';
REPLICATE_DO_TABLE: 'REPLICATE_DO_TABLE';
REPLICATE_IGNORE_DB: 'REPLICATE_IGNORE_DB';
REPLICATE_IGNORE_TABLE: 'REPLICATE_IGNORE_TABLE';
REPLICATE_REWRITE_DB: 'REPLICATE_REWRITE_DB';
REPLICATE_WILD_DO_TABLE: 'REPLICATE_WILD_DO_TABLE';
REPLICATE_WILD_IGNORE_TABLE: 'REPLICATE_WILD_IGNORE_TABLE';
REPLICATION: 'REPLICATION';
RESET: 'RESET';
RESUME: 'RESUME';
RETURNED_SQLSTATE: 'RETURNED_SQLSTATE';
RETURNS: 'RETURNS';
ROLE: 'ROLE';
ROLLBACK: 'ROLLBACK';
ROLLUP: 'ROLLUP';
ROTATE: 'ROTATE';
ROW: 'ROW';
ROWS: 'ROWS';
ROW_FORMAT: 'ROW_FORMAT';
SAVEPOINT: 'SAVEPOINT';
SCHEDULE: 'SCHEDULE';
SECURITY: 'SECURITY';
SERVER: 'SERVER';
SESSION: 'SESSION';
SHARE: 'SHARE';
SHARED: 'SHARED';
SIGNED: 'SIGNED';
SIMPLE: 'SIMPLE';
SLAVE: 'SLAVE';
SLOW: 'SLOW';
SNAPSHOT: 'SNAPSHOT';
SOCKET: 'SOCKET';
SOME: 'SOME';
SONAME: 'SONAME';
SOUNDS: 'SOUNDS';
SOURCE: 'SOURCE';
SQL_AFTER_GTIDS: 'SQL_AFTER_GTIDS';
SQL_AFTER_MTS_GAPS: 'SQL_AFTER_MTS_GAPS';
SQL_BEFORE_GTIDS: 'SQL_BEFORE_GTIDS';
SQL_BUFFER_RESULT: 'SQL_BUFFER_RESULT';
SQL_CACHE: 'SQL_CACHE';
SQL_NO_CACHE: 'SQL_NO_CACHE';
SQL_THREAD: 'SQL_THREAD';
START: 'START';
STARTS: 'STARTS';
STATS_AUTO_RECALC: 'STATS_AUTO_RECALC';
STATS_PERSISTENT: 'STATS_PERSISTENT';
STATS_SAMPLE_PAGES: 'STATS_SAMPLE_PAGES';
STATUS: 'STATUS';
STOP: 'STOP';
STORAGE: 'STORAGE';
STORED: 'STORED';
STRING: 'STRING';
SUBCLASS_ORIGIN: 'SUBCLASS_ORIGIN';
SUBJECT: 'SUBJECT';
SUBPARTITION: 'SUBPARTITION';
SUBPARTITIONS: 'SUBPARTITIONS';
SUSPEND: 'SUSPEND';
SWAPS: 'SWAPS';
SWITCHES: 'SWITCHES';
TABLE_NAME: 'TABLE_NAME';
TABLESPACE: 'TABLESPACE';
TEMPORARY: 'TEMPORARY';
TEMPTABLE: 'TEMPTABLE';
THAN: 'THAN';
TRADITIONAL: 'TRADITIONAL';
TRANSACTION: 'TRANSACTION';
TRANSACTIONAL: 'TRANSACTIONAL';
TRIGGERS: 'TRIGGERS';
TRUNCATE: 'TRUNCATE';
UNDEFINED: 'UNDEFINED';
UNDOFILE: 'UNDOFILE';
UNDO_BUFFER_SIZE: 'UNDO_BUFFER_SIZE';
UNINSTALL: 'UNINSTALL';
UNKNOWN: 'UNKNOWN';
UNTIL: 'UNTIL';
UPGRADE: 'UPGRADE';
USER: 'USER';
USE_FRM: 'USE_FRM';
USER_RESOURCES: 'USER_RESOURCES';
VALIDATION: 'VALIDATION';
VALUE: 'VALUE';
VARIABLES: 'VARIABLES';
VIEW: 'VIEW';
VIRTUAL: 'VIRTUAL';
VISIBLE: 'VISIBLE';
WAIT: 'WAIT';
WARNINGS: 'WARNINGS';
WITHOUT: 'WITHOUT';
WORK: 'WORK';
WRAPPER: 'WRAPPER';
X509: 'X509';
XA: 'XA';
XML: 'XML';
// Date format Keywords
EUR: 'EUR';
USA: 'USA';
JIS: 'JIS';
ISO: 'ISO';
INTERNAL: 'INTERNAL';
// Interval type Keywords
QUARTER: 'QUARTER';
MONTH: 'MONTH';
DAY: 'DAY';
HOUR: 'HOUR';
MINUTE: 'MINUTE';
WEEK: 'WEEK';
SECOND: 'SECOND';
MICROSECOND: 'MICROSECOND';
// PRIVILEGES
TABLES: 'TABLES';
ROUTINE: 'ROUTINE';
EXECUTE: 'EXECUTE';
FILE: 'FILE';
PROCESS: 'PROCESS';
RELOAD: 'RELOAD';
SHUTDOWN: 'SHUTDOWN';
SUPER: 'SUPER';
PRIVILEGES: 'PRIVILEGES';
APPLICATION_PASSWORD_ADMIN: 'APPLICATION_PASSWORD_ADMIN';
AUDIT_ADMIN: 'AUDIT_ADMIN';
BACKUP_ADMIN: 'BACKUP_ADMIN';
BINLOG_ADMIN: 'BINLOG_ADMIN';
BINLOG_ENCRYPTION_ADMIN: 'BINLOG_ENCRYPTION_ADMIN';
CLONE_ADMIN: 'CLONE_ADMIN';
CONNECTION_ADMIN: 'CONNECTION_ADMIN';
ENCRYPTION_KEY_ADMIN: 'ENCRYPTION_KEY_ADMIN';
FIREWALL_ADMIN: 'FIREWALL_ADMIN';
FIREWALL_USER: 'FIREWALL_USER';
GROUP_REPLICATION_ADMIN: 'GROUP_REPLICATION_ADMIN';
INNODB_REDO_LOG_ARCHIVE: 'INNODB_REDO_LOG_ARCHIVE';
NDB_STORED_USER: 'NDB_STORED_USER';
PERSIST_RO_VARIABLES_ADMIN: 'PERSIST_RO_VARIABLES_ADMIN';
REPLICATION_APPLIER: 'REPLICATION_APPLIER';
REPLICATION_SLAVE_ADMIN: 'REPLICATION_SLAVE_ADMIN';
RESOURCE_GROUP_ADMIN: 'RESOURCE_GROUP_ADMIN';
RESOURCE_GROUP_USER: 'RESOURCE_GROUP_USER';
ROLE_ADMIN: 'ROLE_ADMIN';
SESSION_VARIABLES_ADMIN: QUOTE_SYMB? 'SESSION_VARIABLES_ADMIN' QUOTE_SYMB?;
SET_USER_ID: 'SET_USER_ID';
SHOW_ROUTINE: 'SHOW_ROUTINE';
SYSTEM_VARIABLES_ADMIN: 'SYSTEM_VARIABLES_ADMIN';
TABLE_ENCRYPTION_ADMIN: 'TABLE_ENCRYPTION_ADMIN';
VERSION_TOKEN_ADMIN: 'VERSION_TOKEN_ADMIN';
XA_RECOVER_ADMIN: 'XA_RECOVER_ADMIN';
// Charsets
ARMSCII8: 'ARMSCII8';
ASCII: 'ASCII';
BIG5: 'BIG5';
CP1250: 'CP1250';
CP1251: 'CP1251';
CP1256: 'CP1256';
CP1257: 'CP1257';
CP850: 'CP850';
CP852: 'CP852';
CP866: 'CP866';
CP932: 'CP932';
DEC8: 'DEC8';
EUCJPMS: 'EUCJPMS';
EUCKR: 'EUCKR';
GB2312: 'GB2312';
GBK: 'GBK';
GEOSTD8: 'GEOSTD8';
GREEK: 'GREEK';
HEBREW: 'HEBREW';
HP8: 'HP8';
KEYBCS2: 'KEYBCS2';
KOI8R: 'KOI8R';
KOI8U: 'KOI8U';
LATIN1: 'LATIN1';
LATIN2: 'LATIN2';
LATIN5: 'LATIN5';
LATIN7: 'LATIN7';
MACCE: 'MACCE';
MACROMAN: 'MACROMAN';
SJIS: 'SJIS';
SWE7: 'SWE7';
TIS620: 'TIS620';
UCS2: 'UCS2';
UJIS: 'UJIS';
UTF16: 'UTF16';
UTF16LE: 'UTF16LE';
UTF32: 'UTF32';
UTF8: 'UTF8';
UTF8MB3: 'UTF8MB3';
UTF8MB4: 'UTF8MB4';
// DB Engines
ARCHIVE: 'ARCHIVE';
BLACKHOLE: 'BLACKHOLE';
CSV: 'CSV';
FEDERATED: 'FEDERATED';
INNODB: 'INNODB';
MEMORY: 'MEMORY';
MRG_MYISAM: 'MRG_MYISAM';
MYISAM: 'MYISAM';
NDB: 'NDB';
NDBCLUSTER: 'NDBCLUSTER';
PERFORMANCE_SCHEMA: 'PERFORMANCE_SCHEMA';
TOKUDB: 'TOKUDB';
// Transaction Levels
REPEATABLE: 'REPEATABLE';
COMMITTED: 'COMMITTED';
UNCOMMITTED: 'UNCOMMITTED';
SERIALIZABLE: 'SERIALIZABLE';
// Spatial data types
GEOMETRYCOLLECTION: 'GEOMETRYCOLLECTION';
GEOMCOLLECTION: 'GEOMCOLLECTION';
GEOMETRY: 'GEOMETRY';
LINESTRING: 'LINESTRING';
MULTILINESTRING: 'MULTILINESTRING';
MULTIPOINT: 'MULTIPOINT';
MULTIPOLYGON: 'MULTIPOLYGON';
POINT: 'POINT';
POLYGON: 'POLYGON';
// Common function names
ABS: 'ABS';
ACOS: 'ACOS';
ADDDATE: 'ADDDATE';
ADDTIME: 'ADDTIME';
AES_DECRYPT: 'AES_DECRYPT';
AES_ENCRYPT: 'AES_ENCRYPT';
AREA: 'AREA';
ASBINARY: 'ASBINARY';
ASIN: 'ASIN';
ASTEXT: 'ASTEXT';
ASWKB: 'ASWKB';
ASWKT: 'ASWKT';
ASYMMETRIC_DECRYPT: 'ASYMMETRIC_DECRYPT';
ASYMMETRIC_DERIVE: 'ASYMMETRIC_DERIVE';
ASYMMETRIC_ENCRYPT: 'ASYMMETRIC_ENCRYPT';
ASYMMETRIC_SIGN: 'ASYMMETRIC_SIGN';
ASYMMETRIC_VERIFY: 'ASYMMETRIC_VERIFY';
ATAN: 'ATAN';
ATAN2: 'ATAN2';
BENCHMARK: 'BENCHMARK';
BIN: 'BIN';
BIT_COUNT: 'BIT_COUNT';
BIT_LENGTH: 'BIT_LENGTH';
BUFFER: 'BUFFER';
CATALOG_NAME: 'CATALOG_NAME';
CEIL: 'CEIL';
CEILING: 'CEILING';
CENTROID: 'CENTROID';
CHARACTER_LENGTH: 'CHARACTER_LENGTH';
CHARSET: 'CHARSET';
CHAR_LENGTH: 'CHAR_LENGTH';
COERCIBILITY: 'COERCIBILITY';
COLLATION: 'COLLATION';
COMPRESS: 'COMPRESS';
CONCAT: 'CONCAT';
CONCAT_WS: 'CONCAT_WS';
CONNECTION_ID: 'CONNECTION_ID';
CONV: 'CONV';
CONVERT_TZ: 'CONVERT_TZ';
COS: 'COS';
COT: 'COT';
CRC32: 'CRC32';
CREATE_ASYMMETRIC_PRIV_KEY: 'CREATE_ASYMMETRIC_PRIV_KEY';
CREATE_ASYMMETRIC_PUB_KEY: 'CREATE_ASYMMETRIC_PUB_KEY';
CREATE_DH_PARAMETERS: 'CREATE_DH_PARAMETERS';
CREATE_DIGEST: 'CREATE_DIGEST';
CROSSES: 'CROSSES';
DATEDIFF: 'DATEDIFF';
DATE_FORMAT: 'DATE_FORMAT';
DAYNAME: 'DAYNAME';
DAYOFMONTH: 'DAYOFMONTH';
DAYOFWEEK: 'DAYOFWEEK';
DAYOFYEAR: 'DAYOFYEAR';
DECODE: 'DECODE';
DEGREES: 'DEGREES';
DES_DECRYPT: 'DES_DECRYPT';
DES_ENCRYPT: 'DES_ENCRYPT';
DIMENSION: 'DIMENSION';
DISJOINT: 'DISJOINT';
ELT: 'ELT';
ENCODE: 'ENCODE';
ENCRYPT: 'ENCRYPT';
ENDPOINT: 'ENDPOINT';
ENVELOPE: 'ENVELOPE';
EQUALS: 'EQUALS';
EXP: 'EXP';
EXPORT_SET: 'EXPORT_SET';
EXTERIORRING: 'EXTERIORRING';
EXTRACTVALUE: 'EXTRACTVALUE';
FIELD: 'FIELD';
FIND_IN_SET: 'FIND_IN_SET';
FLOOR: 'FLOOR';
FORMAT: 'FORMAT';
FOUND_ROWS: 'FOUND_ROWS';
FROM_BASE64: 'FROM_BASE64';
FROM_DAYS: 'FROM_DAYS';
FROM_UNIXTIME: 'FROM_UNIXTIME';
GEOMCOLLFROMTEXT: 'GEOMCOLLFROMTEXT';
GEOMCOLLFROMWKB: 'GEOMCOLLFROMWKB';
GEOMETRYCOLLECTIONFROMTEXT: 'GEOMETRYCOLLECTIONFROMTEXT';
GEOMETRYCOLLECTIONFROMWKB: 'GEOMETRYCOLLECTIONFROMWKB';
GEOMETRYFROMTEXT: 'GEOMETRYFROMTEXT';
GEOMETRYFROMWKB: 'GEOMETRYFROMWKB';
GEOMETRYN: 'GEOMETRYN';
GEOMETRYTYPE: 'GEOMETRYTYPE';
GEOMFROMTEXT: 'GEOMFROMTEXT';
GEOMFROMWKB: 'GEOMFROMWKB';
GET_FORMAT: 'GET_FORMAT';
GET_LOCK: 'GET_LOCK';
GLENGTH: 'GLENGTH';
GREATEST: 'GREATEST';
GTID_SUBSET: 'GTID_SUBSET';
GTID_SUBTRACT: 'GTID_SUBTRACT';
HEX: 'HEX';
IFNULL: 'IFNULL';
INET6_ATON: 'INET6_ATON';
INET6_NTOA: 'INET6_NTOA';
INET_ATON: 'INET_ATON';
INET_NTOA: 'INET_NTOA';
INSTR: 'INSTR';
INTERIORRINGN: 'INTERIORRINGN';
INTERSECTS: 'INTERSECTS';
ISCLOSED: 'ISCLOSED';
ISEMPTY: 'ISEMPTY';
ISNULL: 'ISNULL';
ISSIMPLE: 'ISSIMPLE';
IS_FREE_LOCK: 'IS_FREE_LOCK';
IS_IPV4: 'IS_IPV4';
IS_IPV4_COMPAT: 'IS_IPV4_COMPAT';
IS_IPV4_MAPPED: 'IS_IPV4_MAPPED';
IS_IPV6: 'IS_IPV6';
IS_USED_LOCK: 'IS_USED_LOCK';
LAST_INSERT_ID: 'LAST_INSERT_ID';
LCASE: 'LCASE';
LEAST: 'LEAST';
LENGTH: 'LENGTH';
LINEFROMTEXT: 'LINEFROMTEXT';
LINEFROMWKB: 'LINEFROMWKB';
LINESTRINGFROMTEXT: 'LINESTRINGFROMTEXT';
LINESTRINGFROMWKB: 'LINESTRINGFROMWKB';
LN: 'LN';
LOAD_FILE: 'LOAD_FILE';
LOCATE: 'LOCATE';
LOG: 'LOG';
LOG10: 'LOG10';
LOG2: 'LOG2';
LOWER: 'LOWER';
LPAD: 'LPAD';
LTRIM: 'LTRIM';
MAKEDATE: 'MAKEDATE';
MAKETIME: 'MAKETIME';
MAKE_SET: 'MAKE_SET';
MASTER_POS_WAIT: 'MASTER_POS_WAIT';
MBRCONTAINS: 'MBRCONTAINS';
MBRDISJOINT: 'MBRDISJOINT';
MBREQUAL: 'MBREQUAL';
MBRINTERSECTS: 'MBRINTERSECTS';
MBROVERLAPS: 'MBROVERLAPS';
MBRTOUCHES: 'MBRTOUCHES';
MBRWITHIN: 'MBRWITHIN';
MD5: 'MD5';
MLINEFROMTEXT: 'MLINEFROMTEXT';
MLINEFROMWKB: 'MLINEFROMWKB';
MONTHNAME: 'MONTHNAME';
MPOINTFROMTEXT: 'MPOINTFROMTEXT';
MPOINTFROMWKB: 'MPOINTFROMWKB';
MPOLYFROMTEXT: 'MPOLYFROMTEXT';
MPOLYFROMWKB: 'MPOLYFROMWKB';
MULTILINESTRINGFROMTEXT: 'MULTILINESTRINGFROMTEXT';
MULTILINESTRINGFROMWKB: 'MULTILINESTRINGFROMWKB';
MULTIPOINTFROMTEXT: 'MULTIPOINTFROMTEXT';
MULTIPOINTFROMWKB: 'MULTIPOINTFROMWKB';
MULTIPOLYGONFROMTEXT: 'MULTIPOLYGONFROMTEXT';
MULTIPOLYGONFROMWKB: 'MULTIPOLYGONFROMWKB';
NAME_CONST: 'NAME_CONST';
NULLIF: 'NULLIF';
NUMGEOMETRIES: 'NUMGEOMETRIES';
NUMINTERIORRINGS: 'NUMINTERIORRINGS';
NUMPOINTS: 'NUMPOINTS';
OCT: 'OCT';
OCTET_LENGTH: 'OCTET_LENGTH';
ORD: 'ORD';
OVERLAPS: 'OVERLAPS';
PERIOD_ADD: 'PERIOD_ADD';
PERIOD_DIFF: 'PERIOD_DIFF';
PI: 'PI';
POINTFROMTEXT: 'POINTFROMTEXT';
POINTFROMWKB: 'POINTFROMWKB';
POINTN: 'POINTN';
POLYFROMTEXT: 'POLYFROMTEXT';
POLYFROMWKB: 'POLYFROMWKB';
POLYGONFROMTEXT: 'POLYGONFROMTEXT';
POLYGONFROMWKB: 'POLYGONFROMWKB';
POW: 'POW';
POWER: 'POWER';
QUOTE: 'QUOTE';
RADIANS: 'RADIANS';
RAND: 'RAND';
RANDOM_BYTES: 'RANDOM_BYTES';
RELEASE_LOCK: 'RELEASE_LOCK';
REVERSE: 'REVERSE';
ROUND: 'ROUND';
ROW_COUNT: 'ROW_COUNT';
RPAD: 'RPAD';
RTRIM: 'RTRIM';
SEC_TO_TIME: 'SEC_TO_TIME';
SESSION_USER: 'SESSION_USER';
SHA: 'SHA';
SHA1: 'SHA1';
SHA2: 'SHA2';
SCHEMA_NAME: 'SCHEMA_NAME';
SIGN: 'SIGN';
SIN: 'SIN';
SLEEP: 'SLEEP';
SOUNDEX: 'SOUNDEX';
SQL_THREAD_WAIT_AFTER_GTIDS: 'SQL_THREAD_WAIT_AFTER_GTIDS';
SQRT: 'SQRT';
SRID: 'SRID';
STARTPOINT: 'STARTPOINT';
STRCMP: 'STRCMP';
STR_TO_DATE: 'STR_TO_DATE';
ST_AREA: 'ST_AREA';
ST_ASBINARY: 'ST_ASBINARY';
ST_ASTEXT: 'ST_ASTEXT';
ST_ASWKB: 'ST_ASWKB';
ST_ASWKT: 'ST_ASWKT';
ST_BUFFER: 'ST_BUFFER';
ST_CENTROID: 'ST_CENTROID';
ST_CONTAINS: 'ST_CONTAINS';
ST_CROSSES: 'ST_CROSSES';
ST_DIFFERENCE: 'ST_DIFFERENCE';
ST_DIMENSION: 'ST_DIMENSION';
ST_DISJOINT: 'ST_DISJOINT';
ST_DISTANCE: 'ST_DISTANCE';
ST_ENDPOINT: 'ST_ENDPOINT';
ST_ENVELOPE: 'ST_ENVELOPE';
ST_EQUALS: 'ST_EQUALS';
ST_EXTERIORRING: 'ST_EXTERIORRING';
ST_GEOMCOLLFROMTEXT: 'ST_GEOMCOLLFROMTEXT';
ST_GEOMCOLLFROMTXT: 'ST_GEOMCOLLFROMTXT';
ST_GEOMCOLLFROMWKB: 'ST_GEOMCOLLFROMWKB';
ST_GEOMETRYCOLLECTIONFROMTEXT: 'ST_GEOMETRYCOLLECTIONFROMTEXT';
ST_GEOMETRYCOLLECTIONFROMWKB: 'ST_GEOMETRYCOLLECTIONFROMWKB';
ST_GEOMETRYFROMTEXT: 'ST_GEOMETRYFROMTEXT';
ST_GEOMETRYFROMWKB: 'ST_GEOMETRYFROMWKB';
ST_GEOMETRYN: 'ST_GEOMETRYN';
ST_GEOMETRYTYPE: 'ST_GEOMETRYTYPE';
ST_GEOMFROMTEXT: 'ST_GEOMFROMTEXT';
ST_GEOMFROMWKB: 'ST_GEOMFROMWKB';
ST_INTERIORRINGN: 'ST_INTERIORRINGN';
ST_INTERSECTION: 'ST_INTERSECTION';
ST_INTERSECTS: 'ST_INTERSECTS';
ST_ISCLOSED: 'ST_ISCLOSED';
ST_ISEMPTY: 'ST_ISEMPTY';
ST_ISSIMPLE: 'ST_ISSIMPLE';
ST_LINEFROMTEXT: 'ST_LINEFROMTEXT';
ST_LINEFROMWKB: 'ST_LINEFROMWKB';
ST_LINESTRINGFROMTEXT: 'ST_LINESTRINGFROMTEXT';
ST_LINESTRINGFROMWKB: 'ST_LINESTRINGFROMWKB';
ST_NUMGEOMETRIES: 'ST_NUMGEOMETRIES';
ST_NUMINTERIORRING: 'ST_NUMINTERIORRING';
ST_NUMINTERIORRINGS: 'ST_NUMINTERIORRINGS';
ST_NUMPOINTS: 'ST_NUMPOINTS';
ST_OVERLAPS: 'ST_OVERLAPS';
ST_POINTFROMTEXT: 'ST_POINTFROMTEXT';
ST_POINTFROMWKB: 'ST_POINTFROMWKB';
ST_POINTN: 'ST_POINTN';
ST_POLYFROMTEXT: 'ST_POLYFROMTEXT';
ST_POLYFROMWKB: 'ST_POLYFROMWKB';
ST_POLYGONFROMTEXT: 'ST_POLYGONFROMTEXT';
ST_POLYGONFROMWKB: 'ST_POLYGONFROMWKB';
ST_SRID: 'ST_SRID';
ST_STARTPOINT: 'ST_STARTPOINT';
ST_SYMDIFFERENCE: 'ST_SYMDIFFERENCE';
ST_TOUCHES: 'ST_TOUCHES';
ST_UNION: 'ST_UNION';
ST_WITHIN: 'ST_WITHIN';
ST_X: 'ST_X';
ST_Y: 'ST_Y';
SUBDATE: 'SUBDATE';
SUBSTRING_INDEX: 'SUBSTRING_INDEX';
SUBTIME: 'SUBTIME';
SYSTEM_USER: 'SYSTEM_USER';
TAN: 'TAN';
TIMEDIFF: 'TIMEDIFF';
TIMESTAMPADD: 'TIMESTAMPADD';
TIMESTAMPDIFF: 'TIMESTAMPDIFF';
TIME_FORMAT: 'TIME_FORMAT';
TIME_TO_SEC: 'TIME_TO_SEC';
TOUCHES: 'TOUCHES';
TO_BASE64: 'TO_BASE64';
TO_DAYS: 'TO_DAYS';
TO_SECONDS: 'TO_SECONDS';
UCASE: 'UCASE';
UNCOMPRESS: 'UNCOMPRESS';
UNCOMPRESSED_LENGTH: 'UNCOMPRESSED_LENGTH';
UNHEX: 'UNHEX';
UNIX_TIMESTAMP: 'UNIX_TIMESTAMP';
UPDATEXML: 'UPDATEXML';
UPPER: 'UPPER';
UUID: 'UUID';
UUID_SHORT: 'UUID_SHORT';
VALIDATE_PASSWORD_STRENGTH: 'VALIDATE_PASSWORD_STRENGTH';
VERSION: 'VERSION';
WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS: 'WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS';
WEEKDAY: 'WEEKDAY';
WEEKOFYEAR: 'WEEKOFYEAR';
WEIGHT_STRING: 'WEIGHT_STRING';
WITHIN: 'WITHIN';
YEARWEEK: 'YEARWEEK';
Y_FUNCTION: 'Y';
X_FUNCTION: 'X';
// Operators
// Operators. Assigns
VAR_ASSIGN: ':=';
PLUS_ASSIGN: '+=';
MINUS_ASSIGN: '-=';
MULT_ASSIGN: '*=';
DIV_ASSIGN: '/=';
MOD_ASSIGN: '%=';
AND_ASSIGN: '&=';
XOR_ASSIGN: '^=';
OR_ASSIGN: '|=';
// Operators. Arithmetics
STAR: '*';
DIVIDE: '/';
MODULE: '%';
PLUS: '+';
MINUSMINUS: '--';
MINUS: '-';
DIV: 'DIV';
MOD: 'MOD';
// Operators. Comparation
EQUAL_SYMBOL: '=';
GREATER_SYMBOL: '>';
LESS_SYMBOL: '<';
EXCLAMATION_SYMBOL: '!';
// Operators. Bit
BIT_NOT_OP: '~';
BIT_OR_OP: '|';
BIT_AND_OP: '&';
BIT_XOR_OP: '^';
// Constructors symbols
DOT: '.';
LR_BRACKET: '(';
RR_BRACKET: ')';
COMMA: ',';
SEMI: ';';
AT_SIGN: '@';
ZERO_DECIMAL: '0';
ONE_DECIMAL: '1';
TWO_DECIMAL: '2';
SINGLE_QUOTE_SYMB: '\'';
DOUBLE_QUOTE_SYMB: '"';
REVERSE_QUOTE_SYMB: '`';
COLON_SYMB: ':';
fragment QUOTE_SYMB
: SINGLE_QUOTE_SYMB | DOUBLE_QUOTE_SYMB | REVERSE_QUOTE_SYMB
;
// Charsets
CHARSET_REVERSE_QOUTE_STRING: '`' CHARSET_NAME '`';
// File's sizes
FILESIZE_LITERAL: DEC_DIGIT+ ('K'|'M'|'G'|'T');
// Literal Primitives
START_NATIONAL_STRING_LITERAL: 'N' SQUOTA_STRING;
STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING;
DECIMAL_LITERAL: DEC_DIGIT+;
HEXADECIMAL_LITERAL: 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\''
| '0X' HEX_DIGIT+;
REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
| DEC_DIGIT+ '.' EXPONENT_NUM_PART
| (DEC_DIGIT+)? '.' (DEC_DIGIT+ EXPONENT_NUM_PART)
| DEC_DIGIT+ EXPONENT_NUM_PART;
NULL_SPEC_LITERAL: '\\' 'N';
BIT_STRING: BIT_STRING_L;
STRING_CHARSET_NAME: '_' CHARSET_NAME;
// Hack for dotID
// Prevent recognize string: .123somelatin AS ((.123), FLOAT_LITERAL), ((somelatin), ID)
// it must recoginze: .123somelatin AS ((.), DOT), (123somelatin, ID)
DOT_ID: '.' ID_LITERAL;
// Identifiers
ID: ID_LITERAL;
// DOUBLE_QUOTE_ID: '"' ~'"'+ '"';
REVERSE_QUOTE_ID: '`' ~'`'+ '`';
STRING_USER_NAME: (
SQUOTA_STRING | DQUOTA_STRING
| BQUOTA_STRING | ID_LITERAL
) '@'
(
SQUOTA_STRING | DQUOTA_STRING
| BQUOTA_STRING | ID_LITERAL
| IP_ADDRESS
);
IP_ADDRESS: (
[0-9]+ '.' [0-9.]+
| [0-9A-F:]+ ':' [0-9A-F:]+
);
LOCAL_ID: '@'
(
[A-Z0-9._$]+
| SQUOTA_STRING
| DQUOTA_STRING
| BQUOTA_STRING
);
GLOBAL_ID: '@' '@'
(
[A-Z0-9._$]+
| BQUOTA_STRING
);
// Fragments for Literal primitives
fragment CHARSET_NAME: ARMSCII8 | ASCII | BIG5 | BINARY | CP1250
| CP1251 | CP1256 | CP1257 | CP850
| CP852 | CP866 | CP932 | DEC8 | EUCJPMS
| EUCKR | GB2312 | GBK | GEOSTD8 | GREEK
| HEBREW | HP8 | KEYBCS2 | KOI8R | KOI8U
| LATIN1 | LATIN2 | LATIN5 | LATIN7
| MACCE | MACROMAN | SJIS | SWE7 | TIS620
| UCS2 | UJIS | UTF16 | UTF16LE | UTF32
| UTF8 | UTF8MB3 | UTF8MB4;
fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+;
fragment ID_LITERAL: [A-Za-z_$0-9]+;
fragment DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';
fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\'';
fragment BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';
fragment HEX_DIGIT: [0-9A-F];
fragment DEC_DIGIT: [0-9];
fragment BIT_STRING_L: 'B' '\'' [01]+ '\'';
// Last tokens must generate Errors
ERROR_RECONGNIGION: . -> channel(ERRORCHANNEL);
|
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/fib.adb | ouankou/rose | 488 | 30829 | <filename>tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/fib.adb
function Fib(x: in Integer) return Integer is
Result : Integer;
begin
if x = 0 then
Result := 0;
elsif x = 1 then
Result := 1;
else
Result := Fib(x-2) + Fib(x-1);
end if;
return Result;
end Fib;
|
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0xca_notsx.log_21829_1909.asm | ljhsiun2/medusa | 9 | 14232 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r15
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0xf33c, %r15
nop
nop
nop
nop
sub %r11, %r11
movups (%r15), %xmm5
vpextrq $1, %xmm5, %rbp
nop
cmp $60187, %rbp
lea addresses_UC_ht+0x956c, %rax
and $13289, %rcx
mov $0x6162636465666768, %rdx
movq %rdx, %xmm7
vmovups %ymm7, (%rax)
nop
nop
and $37564, %rax
lea addresses_WC_ht+0x6992, %rsi
lea addresses_WT_ht+0x45ec, %rdi
clflush (%rsi)
nop
nop
inc %rbp
mov $50, %rcx
rep movsq
nop
nop
add %rax, %rax
lea addresses_WT_ht+0x184ec, %r11
nop
dec %rsi
movb (%r11), %al
nop
sub %r15, %r15
lea addresses_D_ht+0x2cb4, %rax
and %rsi, %rsi
movb $0x61, (%rax)
nop
nop
nop
nop
nop
inc %rdi
lea addresses_D_ht+0xa1ec, %rsi
lea addresses_WC_ht+0x151d2, %rdi
nop
nop
nop
nop
cmp $55577, %r15
mov $15, %rcx
rep movsq
nop
nop
nop
nop
add $54031, %rsi
lea addresses_WT_ht+0x1bc6c, %rdx
nop
nop
nop
nop
nop
sub %rax, %rax
mov (%rdx), %si
nop
nop
inc %rdi
lea addresses_UC_ht+0x4cfc, %rsi
lea addresses_A_ht+0x169c, %rdi
nop
nop
nop
add $4512, %r15
mov $23, %rcx
rep movsq
inc %rbp
lea addresses_normal_ht+0x4aec, %r15
nop
nop
nop
nop
nop
inc %rax
vmovups (%r15), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %rbp
nop
nop
nop
inc %rbp
lea addresses_normal_ht+0xbe6c, %rsi
lea addresses_normal_ht+0x13e6c, %rdi
nop
nop
nop
nop
nop
add %r15, %r15
mov $69, %rcx
rep movsb
nop
nop
nop
and $31545, %r15
lea addresses_normal_ht+0xdb98, %rax
nop
nop
nop
xor %rsi, %rsi
movb $0x61, (%rax)
nop
nop
nop
cmp $38571, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r15
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r15
push %rax
push %rbp
push %rdx
push %rsi
// Store
mov $0xfec, %rsi
add $61268, %rax
movw $0x5152, (%rsi)
nop
nop
add $5834, %rax
// Store
lea addresses_D+0x20ec, %rsi
nop
nop
nop
and $8179, %r13
movb $0x51, (%rsi)
nop
nop
nop
inc %r15
// Faulty Load
lea addresses_A+0x92ec, %r15
cmp %r10, %r10
mov (%r15), %rdx
lea oracles, %rax
and $0xff, %rdx
shlq $12, %rdx
mov (%rax,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rbp
pop %rax
pop %r15
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_A'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 8, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_A'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'src': {'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 8, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 4, 'same': True, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
programs/oeis/122/A122638.asm | neoneye/loda | 22 | 95275 | <filename>programs/oeis/122/A122638.asm
; A122638: {n+1}_n.
; 2,3,4,5,6,7,8,9,9,11,13,15,17,19,21,23,25,27,38,41,44,47,50,53,56,59,62,65,87,91,95,99,103,107,111,115,119,123,156,161,166,171,176,181,186,191,196,201,245,251,257,263,269,275,281,287,293,299,354,361,368,375,382,389
mov $3,$0
sub $0,7
mov $2,6
add $2,$0
add $2,1
add $3,2
lpb $0
sub $0,1
trn $0,9
add $3,$2
sub $3,9
lpe
add $1,$3
mov $0,$1
|
programs/oeis/030/A030441.asm | neoneye/loda | 22 | 166678 | <reponame>neoneye/loda
; A030441: Values of Newton-Gregory forward interpolating polynomial (1/3)*(2*n - 3)*(2*n^2 - 3*n + 4).
; -4,-1,2,13,40,91,174,297,468,695,986,1349,1792,2323,2950,3681,4524,5487,6578,7805,9176,10699,12382,14233,16260,18471,20874,23477,26288,29315,32566,36049,39772,43743,47970,52461,57224,62267,67598,73225,79156,85399
mul $0,2
mov $2,2
sub $2,$0
sub $0,1
bin $0,3
add $2,1
sub $0,$2
|
programs/oeis/173/A173773.asm | karttu/loda | 1 | 163635 | <filename>programs/oeis/173/A173773.asm
; A173773: a(3*n) = 8*n+2, a(3*n+1) = 2*n+1, a(3*n+2) = 8*n+6.
; 2,1,6,10,3,14,18,5,22,26,7,30,34,9,38,42,11,46,50,13,54,58,15,62,66,17,70,74,19,78,82,21,86,90,23,94,98,25,102,106,27,110,114,29,118,122,31,126,130,33,134,138,35,142,146,37,150,154,39,158
mov $2,$0
add $2,$0
mov $0,$2
cal $0,122918 ; Expansion of (1+x)^2/(1+x+x^2)^2.
add $1,$0
add $1,12
add $2,3
add $1,$2
sub $1,14
|
test/Succeed/Issue81.agda | cruhland/agda | 1,989 | 11459 | <filename>test/Succeed/Issue81.agda
-- {-# OPTIONS -v tc.lhs.unify:50 #-}
module Issue81 where
data ⊥ : Set where
data D : Set where
d : D
c : D
data E : Set where
e : E
⌜_⌝ : E -> D
⌜ e ⌝ = c
data R : D -> E -> Set where
Val : (v : E) -> R ⌜ v ⌝ v
foo : R d e -> ⊥
foo ()
|
prototyping/Luau/Syntax.agda | TheGreatSageEqualToHeaven/luau | 1 | 17255 | <reponame>TheGreatSageEqualToHeaven/luau
module Luau.Syntax where
open import Agda.Builtin.Equality using (_≡_)
open import Agda.Builtin.Bool using (Bool; true; false)
open import Agda.Builtin.Float using (Float)
open import Agda.Builtin.String using (String)
open import Luau.Var using (Var)
open import Luau.Addr using (Addr)
open import Luau.Type using (Type)
open import FFI.Data.Maybe using (Maybe; just; nothing)
infixr 5 _∙_
data Annotated : Set where
maybe : Annotated
yes : Annotated
data VarDec : Annotated → Set where
var : Var → VarDec maybe
var_∈_ : ∀ {a} → Var → Type → VarDec a
name : ∀ {a} → VarDec a → Var
name (var x) = x
name (var x ∈ T) = x
data FunDec : Annotated → Set where
_⟨_⟩∈_ : ∀ {a} → Var → VarDec a → Type → FunDec a
_⟨_⟩ : Var → VarDec maybe → FunDec maybe
fun : ∀ {a} → FunDec a → VarDec a
fun (f ⟨ x ⟩∈ T) = (var f ∈ T)
fun (f ⟨ x ⟩) = (var f)
arg : ∀ {a} → FunDec a → VarDec a
arg (f ⟨ x ⟩∈ T) = x
arg (f ⟨ x ⟩) = x
data BinaryOperator : Set where
+ : BinaryOperator
- : BinaryOperator
* : BinaryOperator
/ : BinaryOperator
< : BinaryOperator
> : BinaryOperator
== : BinaryOperator
~= : BinaryOperator
<= : BinaryOperator
>= : BinaryOperator
·· : BinaryOperator
data Value : Set where
nil : Value
addr : Addr → Value
number : Float → Value
bool : Bool → Value
string : String → Value
data Block (a : Annotated) : Set
data Stat (a : Annotated) : Set
data Expr (a : Annotated) : Set
data Block a where
_∙_ : Stat a → Block a → Block a
done : Block a
data Stat a where
function_is_end : FunDec a → Block a → Stat a
local_←_ : VarDec a → Expr a → Stat a
return : Expr a → Stat a
data Expr a where
var : Var → Expr a
val : Value → Expr a
_$_ : Expr a → Expr a → Expr a
function_is_end : FunDec a → Block a → Expr a
block_is_end : VarDec a → Block a → Expr a
binexp : Expr a → BinaryOperator → Expr a → Expr a
isAnnotatedᴱ : ∀ {a} → Expr a → Maybe (Expr yes)
isAnnotatedᴮ : ∀ {a} → Block a → Maybe (Block yes)
isAnnotatedᴱ (var x) = just (var x)
isAnnotatedᴱ (val v) = just (val v)
isAnnotatedᴱ (M $ N) with isAnnotatedᴱ M | isAnnotatedᴱ N
isAnnotatedᴱ (M $ N) | just M′ | just N′ = just (M′ $ N′)
isAnnotatedᴱ (M $ N) | _ | _ = nothing
isAnnotatedᴱ (function f ⟨ var x ∈ T ⟩∈ U is B end) with isAnnotatedᴮ B
isAnnotatedᴱ (function f ⟨ var x ∈ T ⟩∈ U is B end) | just B′ = just (function f ⟨ var x ∈ T ⟩∈ U is B′ end)
isAnnotatedᴱ (function f ⟨ var x ∈ T ⟩∈ U is B end) | _ = nothing
isAnnotatedᴱ (function _ is B end) = nothing
isAnnotatedᴱ (block var b ∈ T is B end) with isAnnotatedᴮ B
isAnnotatedᴱ (block var b ∈ T is B end) | just B′ = just (block var b ∈ T is B′ end)
isAnnotatedᴱ (block var b ∈ T is B end) | _ = nothing
isAnnotatedᴱ (block _ is B end) = nothing
isAnnotatedᴱ (binexp M op N) with isAnnotatedᴱ M | isAnnotatedᴱ N
isAnnotatedᴱ (binexp M op N) | just M′ | just N′ = just (binexp M′ op N′)
isAnnotatedᴱ (binexp M op N) | _ | _ = nothing
isAnnotatedᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) with isAnnotatedᴮ B | isAnnotatedᴮ C
isAnnotatedᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) | just B′ | just C′ = just (function f ⟨ var x ∈ T ⟩∈ U is C′ end ∙ B′)
isAnnotatedᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) | _ | _ = nothing
isAnnotatedᴮ (function _ is C end ∙ B) = nothing
isAnnotatedᴮ (local var x ∈ T ← M ∙ B) with isAnnotatedᴱ M | isAnnotatedᴮ B
isAnnotatedᴮ (local var x ∈ T ← M ∙ B) | just M′ | just B′ = just (local var x ∈ T ← M′ ∙ B′)
isAnnotatedᴮ (local var x ∈ T ← M ∙ B) | _ | _ = nothing
isAnnotatedᴮ (local _ ← M ∙ B) = nothing
isAnnotatedᴮ (return M ∙ B) with isAnnotatedᴱ M | isAnnotatedᴮ B
isAnnotatedᴮ (return M ∙ B) | just M′ | just B′ = just (return M′ ∙ B′)
isAnnotatedᴮ (return M ∙ B) | _ | _ = nothing
isAnnotatedᴮ done = just done
|
oeis/037/A037736.asm | neoneye/loda-programs | 11 | 172867 | ; A037736: Decimal expansion of a(n) is given by the first n terms of the periodic sequence with initial period 2,1,0,3.
; Submitted by <NAME>
; 2,21,210,2103,21032,210321,2103210,21032103,210321032,2103210321,21032103210,210321032103,2103210321032,21032103210321,210321032103210,2103210321032103
mov $2,2
lpb $0
sub $0,1
add $1,$2
mul $1,10
add $2,11
mod $2,4
lpe
add $1,$2
mov $0,$1
|
server/src/antlr/grammer/siParser.g4 | SI-Gen/jportal2-vscode-extension | 0 | 3128 | parser grammar siParser;
options { tokenVocab=siLexer; }
// Parser starting point
jInput : DATABASE jIdent
( FLAGS ( jString )+ )*
( PACKAGE jPackageIdent )?
( ( OUTPUT jIdentOrString | IMPORT jIdentOrString ) )*
jConnect
( jTables )+
( jView )*
EOF;
// This is only used for table generation code.
jConnect : SERVER
jIdentOrString
( SCHEMA jIdentOrString )?
( USERID jIdent PASSWORD jIdent )?;
// A package can contain dotted notation
jPackageIdent : jIdent ( POINT jIdent )*;
// The server may be a standard variable or a string
jIdentOrString : jIdent | STRING;
// Identifiers may be DEF keywords if they are escaped using L'x'
jIdent : IDENTIFIER | LIDENTIFIER;
jTables : ( jTable ( jExtras )* | jTableImport )
( jProc )*
( PARM jParm )*;
jTableImport : IMPORT jIdentOrString
( LEFTBRACK ( jIdent )+ RIGHTBRACK )?
( jAlias )?;
jTable : TABLE jIdent ( jAlias )?
( CHECK STRING )?
( jComment )*
( OPTIONS ( jString )+ )*
( jField )*;
jPackageField : jPackageIdent
( jAlias )?
jDatatype
( DEFAULTV STRING | ( NOT )? NULL | CALC | CHECK STRING )*
( jComment )*;
jField : jIdent
( jAlias )?
jDatatype
( DEFAULTV STRING | ( NOT )? NULL | CALC | CHECK STRING )*
( jComment )*;
jAlias : LEFTPAREN jIdent RIGHTPAREN;
jDatatype : BLOB ( jCharsize )?
| BOOLEAN
| BYTE ( jEnumValue | jCharList )?
| CHAR ( jCharsize )? ( jCharList )?
| ANSICHAR ( jEnumChar )?
| WCHAR ( jCharsize )? ( jCharList )?
| WANSICHAR ( jEnumChar )?
| UTF8 ( jCharsize )? ( jCharList )?
| SHORT ( jEnumValue | jCharList )?
| INT ( jEnumValue | jCharList )?
| LONG
| UID
| DATE
| DATETIME
| TIME
| TIMESTAMP
| AUTOTIMESTAMP
| TLOB ( jCharsize )?
| XML ( jCharsize )?
| BIGXML ( jCharsize )?
| USERSTAMP
| SEQUENCE
| BIGSEQUENCE
| IDENTITY
| BIGIDENTITY
| ( DOUBLE | FLOAT ) ( jFloatsize )?
| MONEY
| jLookup;
jLookup : EQUALS ( LEFTPAREN jIdent RIGHTPAREN )?;
jEnumValue : LEFTPAREN
( ( LINK jIdent )? ( jIdent EQUALS jNumber ( COMMA )? )+ )
RIGHTPAREN;
jFloatsize : LEFTBRACK jNumber COMMA jNumber RIGHTBRACK
| LEFTPAREN jNumber COMMA jNumber RIGHTPAREN;
jEnumChar : ( LEFTBRACK jNumber RIGHTBRACK )
| ( LEFTPAREN
( jNumber | ( LINK jIdent )?
( jIdent EQUALS jAsciiChar ( COMMA )? )+ )
RIGHTPAREN
)
| jNumber;
jCharsize : ( LEFTBRACK jNumber RIGHTBRACK )
| ( LEFTPAREN jNumber RIGHTPAREN )
| jNumber;
jCharList : LEFTBRACE
( jIdent ( COMMA )? )+
RIGHTBRACE;
jNumber : NUMBER;
jParm : ( jString )?
(
PARMSHOWS ( jIdent )+
| PARMVIEWONLY
| PARMSUPPLIED ( jIdent )+
| PARMCACHE ( jIdent | SELECTALL ) ( jIdent )*
| PARMREADER ( jIdent | SELECTALL )
| PARMINSERT ( jIdent | INSERT )
| PARMUPDATE ( jIdent | UPDATE )
| PARMDELETE ( jIdent | DELETEONE )
)*;
jExtras : jGrant
| jKey
| jLink
| jView
| jConst;
jConst : CONST jIdent
( jIdent EQUALS jString ( COMMA )? )+;
jGrant : GRANT ( jPermission )+ TO ( jUser )+;
jPermission : ALL
| DELETE
| INSERT
| SELECT
| UPDATE
| EXECUTE;
jUser : jIdent;
jKey : KEY jIdent ( OPTIONS ( jString )+ )* ( jModifier )* ( jColumn )+;
jModifier : UNIQUE
| PRIMARY;
jColumn : jIdent;
jLink : LINK jPackageIdent
( LEFTPAREN ( jIdent )+ RIGHTPAREN )?
( DELETE ( CASCADE )? )?
( UPDATE ( CASCADE )? )?
( OPTIONS ( jString )+ )*
( jLinkColumn )+;
jLinkColumn : jIdent;
jView : VIEW jIdent
( TO ( jUser )+ )?
( OUTPUT ( jViewAlias )+ )?
( jOldViewCode | jNewViewCode );
jViewAlias : jIdent;
jLine : STRING;
jString : STRING;
jAsciiChar : jString;
jProc : ( PROC | SPROC )
( jStdProc | ( jNewProc | jUserProc ) )
| ( jOldData | jNewData | jIdlCode );
jStdProc : (
INSERT ( RETURNING )?
| UPDATE
| BULKINSERT ( jRowCount )?
| MAXTMSTAMP
| BULKUPDATE ( jRowCount )?
| DELETEONE ( LEFTPAREN STANDARD RIGHTPAREN )?
| DELETEALL
| SELECTONE ( ( FOR )? ( UPDATE | READONLY ) )?
| SELECTONEBY ( jProcColumn )+
( ( IN )? ORDER )?
( ( FOR )? ( UPDATE | READONLY ) )?
( AS jIdent )?
| SELECTBY ( jProcColumn )+
( ( IN )? ORDER )?
( ( FOR )? ( UPDATE | READONLY ) )?
( AS jIdent )?
( OUTPUT ( jOutputType )?
( jField )* )?
| SELECTALL
( ( IN )? ORDER ( jOrderColumn )* ( DESC )? )?
( ( FOR )? ( UPDATE | READONLY ) )?
| COUNT
| EXISTS
| MERGE
)
( OPTIONS ( jString )+ )*;
jNewProc : jIdent
(
SELECT ( LEFTPAREN STANDARD RIGHTPAREN )?
( INPUT ( jInputType )? ( jField )+ )?
( OUTPUT ( jOutputType )? ( jPackageField )* )?
( jOldCode | jNewCode )
| SELECTONEBY ( jProcColumn )+
( ( FOR )? ( UPDATE | READONLY ) )?
| SELECTBY ( jProcColumn )+
( ( IN )? ORDER ( jOrderColumn )* ( DESC )? )?
( ( FOR )? ( UPDATE | READONLY ) )?
( OUTPUT ( jOutputType )? ( jField )* )?
| DELETEBY ( jProcColumn )+
| UPDATEFOR ( jProcColumn )+
| UPDATEBY ( ( jProcUpdateByColumn )+ ( FOR ( jProcColumn )+ )? )
);
jProcColumn : jIdent;
jOrderColumn : jIdent;
jProcUpdateByColumn : jIdent;
jComment : COMMENT;
jRowCount : LEFTPAREN jNumber RIGHTPAREN;
jUserProc : jIdent ( LEFTPAREN STANDARD RIGHTPAREN )?
( jComment )*
( OPTIONS ( jString )+ )*
( INPUT ( jInputType )? ( jField )* )?
( INOUT ( jOutputType )? ( jField )* )?
( OUTPUT ( jOutputType )? ( jField )* )?
( jOldCode | jNewCode );
jOptSize : ( LEFTPAREN jNumber RIGHTPAREN )?;
jInputType : LEFTPAREN MULTIPLE RIGHTPAREN
| LEFTPAREN jNumber RIGHTPAREN
| LEFTPAREN STANDARD RIGHTPAREN;
jOutputType : LEFTPAREN SINGLE ( STANDARD )? RIGHTPAREN
| LEFTPAREN SINGLE ( UPDATE )? RIGHTPAREN
| LEFTPAREN jNumber RIGHTPAREN
| LEFTPAREN STANDARD ( SINGLE )? RIGHTPAREN;
jOldData : DATA
( jLine )*
ENDDATA;
jNewData : SQLDATA ( CODELINE )+ ENDDATA;
jIdlCode : IDLCODE ( CODELINE )+ ENDCODE;
jOldCode : ( SQL )? CODE
( jLine | jIdent jOptSize )*
ENDCODE;
jOldViewCode : CODE
( jLine )*
ENDCODE;
jNewCode : SQLCODE
(CODELINE)+
ENDCODE;
jNewViewCode : SQLCODE
(CODELINE)+
ENDCODE;
|
.build/ada/asis-gela-elements-helpers.ads | faelys/gela-asis | 4 | 13953 | <gh_stars>1-10
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the <NAME>, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
with Asis.Gela.Lists; use Asis.Gela.Lists;
with Asis.Gela.Compilations;
package Asis.Gela.Elements.Helpers is
-----------------------
-- Fake_Element_Node --
-----------------------
type Fake_Element_Node is abstract
new Element_Node with private;
type Fake_Element_Ptr is
access all Fake_Element_Node;
for Fake_Element_Ptr'Storage_Pool use Lists.Pool;
function Start_Position
(Element : Fake_Element_Node) return Asis.Text_Position;
procedure Set_Start_Position
(Element : in out Fake_Element_Node;
Value : in Asis.Text_Position);
----------------
-- Token_Node --
----------------
type Token_Node is
new Fake_Element_Node with private;
type Token_Ptr is
access all Token_Node;
for Token_Ptr'Storage_Pool use Lists.Pool;
function New_Token_Node
(The_Context : ASIS.Context)
return Token_Ptr;
function End_Position
(Element : Token_Node) return Asis.Text_Position;
procedure Set_End_Position
(Element : in out Token_Node;
Value : in Asis.Text_Position);
function Raw_Image
(Element : Token_Node) return Gela_String;
procedure Set_Raw_Image
(Element : in out Token_Node;
Value : in Gela_String);
function Clone
(Element : Token_Node;
Parent : Asis.Element)
return Asis.Element;
----------------------------
-- Private_Indicator_Node --
----------------------------
type Private_Indicator_Node is
new Fake_Element_Node with private;
type Private_Indicator_Ptr is
access all Private_Indicator_Node;
for Private_Indicator_Ptr'Storage_Pool use Lists.Pool;
function New_Private_Indicator_Node
(The_Context : ASIS.Context)
return Private_Indicator_Ptr;
function Next_Element
(Element : Private_Indicator_Node) return Asis.Element;
procedure Set_Next_Element
(Element : in out Private_Indicator_Node;
Value : in Asis.Element);
function End_Position
(Element : Private_Indicator_Node) return Asis.Text_Position;
procedure Set_End_Position
(Element : in out Private_Indicator_Node;
Value : in Asis.Text_Position);
function Clone
(Element : Private_Indicator_Node;
Parent : Asis.Element)
return Asis.Element;
-----------------------------
-- Handled_Statements_Node --
-----------------------------
type Handled_Statements_Node is
new Fake_Element_Node with private;
type Handled_Statements_Ptr is
access all Handled_Statements_Node;
for Handled_Statements_Ptr'Storage_Pool use Lists.Pool;
function New_Handled_Statements_Node
(The_Context : ASIS.Context)
return Handled_Statements_Ptr;
function Statements
(Element : Handled_Statements_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Statements
(Element : in out Handled_Statements_Node;
Value : in Asis.Element);
function Statements_List
(Element : Handled_Statements_Node) return Asis.Element;
function Exception_Handlers
(Element : Handled_Statements_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Exception_Handlers
(Element : in out Handled_Statements_Node;
Value : in Asis.Element);
function Exception_Handlers_List
(Element : Handled_Statements_Node) return Asis.Element;
function Get_Identifier
(Element : Handled_Statements_Node) return Asis.Element;
procedure Set_Identifier
(Element : in out Handled_Statements_Node;
Value : in Asis.Element);
function End_Position
(Element : Handled_Statements_Node) return Asis.Text_Position;
procedure Set_End_Position
(Element : in out Handled_Statements_Node;
Value : in Asis.Text_Position);
function Clone
(Element : Handled_Statements_Node;
Parent : Asis.Element)
return Asis.Element;
---------------------------
-- Function_Profile_Node --
---------------------------
type Function_Profile_Node is
new Fake_Element_Node with private;
type Function_Profile_Ptr is
access all Function_Profile_Node;
for Function_Profile_Ptr'Storage_Pool use Lists.Pool;
function New_Function_Profile_Node
(The_Context : ASIS.Context)
return Function_Profile_Ptr;
function Parameter_Profile
(Element : Function_Profile_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Parameter_Profile
(Element : in out Function_Profile_Node;
Value : in Asis.Element);
function Parameter_Profile_List
(Element : Function_Profile_Node) return Asis.Element;
function Result_Profile
(Element : Function_Profile_Node) return Asis.Expression;
procedure Set_Result_Profile
(Element : in out Function_Profile_Node;
Value : in Asis.Expression);
function End_Position
(Element : Function_Profile_Node) return Asis.Text_Position;
procedure Set_End_Position
(Element : in out Function_Profile_Node;
Value : in Asis.Text_Position);
function Clone
(Element : Function_Profile_Node;
Parent : Asis.Element)
return Asis.Element;
----------------------------------
-- Procedure_Specification_Node --
----------------------------------
type Procedure_Specification_Node is
new Fake_Element_Node with private;
type Procedure_Specification_Ptr is
access all Procedure_Specification_Node;
for Procedure_Specification_Ptr'Storage_Pool use Lists.Pool;
function New_Procedure_Specification_Node
(The_Context : ASIS.Context)
return Procedure_Specification_Ptr;
function Names
(Element : Procedure_Specification_Node) return Asis.Element;
procedure Set_Names
(Element : in out Procedure_Specification_Node;
Value : in Asis.Element);
function Profile
(Element : Procedure_Specification_Node) return Asis.Element;
procedure Set_Profile
(Element : in out Procedure_Specification_Node;
Value : in Asis.Element);
function End_Position
(Element : Procedure_Specification_Node) return Asis.Text_Position;
procedure Set_End_Position
(Element : in out Procedure_Specification_Node;
Value : in Asis.Text_Position);
function Clone
(Element : Procedure_Specification_Node;
Parent : Asis.Element)
return Asis.Element;
---------------------------------
-- Function_Specification_Node --
---------------------------------
type Function_Specification_Node is
new Procedure_Specification_Node with private;
type Function_Specification_Ptr is
access all Function_Specification_Node;
for Function_Specification_Ptr'Storage_Pool use Lists.Pool;
function New_Function_Specification_Node
(The_Context : ASIS.Context)
return Function_Specification_Ptr;
function Clone
(Element : Function_Specification_Node;
Parent : Asis.Element)
return Asis.Element;
--------------------------------
-- Package_Specification_Node --
--------------------------------
type Package_Specification_Node is
new Fake_Element_Node with private;
type Package_Specification_Ptr is
access all Package_Specification_Node;
for Package_Specification_Ptr'Storage_Pool use Lists.Pool;
function New_Package_Specification_Node
(The_Context : ASIS.Context)
return Package_Specification_Ptr;
function Names
(Element : Package_Specification_Node) return Asis.Element;
procedure Set_Names
(Element : in out Package_Specification_Node;
Value : in Asis.Element);
function Visible_Part_Declarative_Items
(Element : Package_Specification_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Visible_Part_Declarative_Items
(Element : in out Package_Specification_Node;
Value : in Asis.Element);
function Visible_Part_Declarative_Items_List
(Element : Package_Specification_Node) return Asis.Element;
function Private_Part_Declarative_Items
(Element : Package_Specification_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Private_Part_Declarative_Items
(Element : in out Package_Specification_Node;
Value : in Asis.Element);
function Private_Part_Declarative_Items_List
(Element : Package_Specification_Node) return Asis.Element;
function Compound_Name
(Element : Package_Specification_Node) return Asis.Element;
procedure Set_Compound_Name
(Element : in out Package_Specification_Node;
Value : in Asis.Element);
function End_Position
(Element : Package_Specification_Node) return Asis.Text_Position;
procedure Set_End_Position
(Element : in out Package_Specification_Node;
Value : in Asis.Text_Position);
function Clone
(Element : Package_Specification_Node;
Parent : Asis.Element)
return Asis.Element;
private
type Fake_Element_Node is abstract
new Element_Node with
record
Start_Position : aliased Asis.Text_Position;
end record;
type Token_Node is
new Fake_Element_Node with
record
End_Position : aliased Asis.Text_Position;
Raw_Image : aliased Gela_String;
end record;
type Private_Indicator_Node is
new Fake_Element_Node with
record
Next_Element : aliased Asis.Element;
End_Position : aliased Asis.Text_Position;
end record;
type Handled_Statements_Node is
new Fake_Element_Node with
record
Statements : aliased Primary_Statement_Lists.List;
Exception_Handlers : aliased Primary_Handler_Lists.List;
Identifier : aliased Asis.Element;
End_Position : aliased Asis.Text_Position;
end record;
type Function_Profile_Node is
new Fake_Element_Node with
record
Parameter_Profile : aliased Primary_Parameter_Lists.List;
Result_Profile : aliased Asis.Expression;
End_Position : aliased Asis.Text_Position;
end record;
type Procedure_Specification_Node is
new Fake_Element_Node with
record
Names : aliased Asis.Element;
Profile : aliased Asis.Element;
End_Position : aliased Asis.Text_Position;
end record;
type Function_Specification_Node is
new Procedure_Specification_Node with
record
null;
end record;
type Package_Specification_Node is
new Fake_Element_Node with
record
Names : aliased Asis.Element;
Visible_Part_Declarative_Items : aliased Primary_Declaration_Lists.List;
Private_Part_Declarative_Items : aliased Primary_Declaration_Lists.List;
Compound_Name : aliased Asis.Element;
End_Position : aliased Asis.Text_Position;
end record;
end Asis.Gela.Elements.Helpers;
|
Categories/Congruence.agda | copumpkin/categories | 98 | 15920 | module Categories.Congruence where
open import Level
open import Relation.Binary hiding (_⇒_; Setoid)
open import Categories.Support.PropositionalEquality
open import Categories.Support.Equivalence
open import Categories.Support.EqReasoning
open import Categories.Category hiding (module Heterogeneous; _[_∼_])
record Congruence {o ℓ e} (C : Category o ℓ e) q : Set (o ⊔ ℓ ⊔ e ⊔ suc q) where
open Category C
field
_≡₀_ : Rel Obj q
equiv₀ : IsEquivalence _≡₀_
module Equiv₀ = IsEquivalence equiv₀
field
coerce : ∀ {X₁ X₂ Y₁ Y₂} → X₁ ≡₀ X₂ → Y₁ ≡₀ Y₂ → X₁ ⇒ Y₁ → X₂ ⇒ Y₂
.coerce-resp-≡ : ∀ {X₁ X₂ Y₁ Y₂} (xpf : X₁ ≡₀ X₂) (ypf : Y₁ ≡₀ Y₂)
→ {f₁ f₂ : X₁ ⇒ Y₁} → f₁ ≡ f₂
→ coerce xpf ypf f₁ ≡ coerce xpf ypf f₂
.coerce-refl : ∀ {X Y} (f : X ⇒ Y) → coerce Equiv₀.refl Equiv₀.refl f ≡ f
.coerce-invariant : ∀ {X₁ X₂ Y₁ Y₂} (xpf₁ xpf₂ : X₁ ≡₀ X₂)
(ypf₁ ypf₂ : Y₁ ≡₀ Y₂)
→ (f : X₁ ⇒ Y₁)
→ coerce xpf₁ ypf₁ f ≡ coerce xpf₂ ypf₂ f
.coerce-trans : ∀ {X₁ X₂ X₃ Y₁ Y₂ Y₃} (xpf₁ : X₁ ≡₀ X₂) (xpf₂ : X₂ ≡₀ X₃)
(ypf₁ : Y₁ ≡₀ Y₂) (ypf₂ : Y₂ ≡₀ Y₃)
→ (f : X₁ ⇒ Y₁)
→ coerce (Equiv₀.trans xpf₁ xpf₂) (Equiv₀.trans ypf₁ ypf₂) f
≡ coerce xpf₂ ypf₂ (coerce xpf₁ ypf₁ f)
.coerce-∘ : ∀ {X₁ X₂ Y₁ Y₂ Z₁ Z₂}
→ (pfX : X₁ ≡₀ X₂) (pfY : Y₁ ≡₀ Y₂) (pfZ : Z₁ ≡₀ Z₂)
→ (g : Y₁ ⇒ Z₁) (f : X₁ ⇒ Y₁)
→ coerce pfX pfZ (g ∘ f) ≡ coerce pfY pfZ g ∘ coerce pfX pfY f
.coerce-local : ∀ {X Y} (xpf : X ≡₀ X) (ypf : Y ≡₀ Y) {f : X ⇒ Y} → coerce xpf ypf f ≡ f
coerce-local xpf ypf {f} =
begin
coerce xpf ypf f
↓⟨ coerce-invariant xpf Equiv₀.refl ypf Equiv₀.refl f ⟩
coerce Equiv₀.refl Equiv₀.refl f
↓⟨ coerce-refl f ⟩
f
∎
where open HomReasoning
.coerce-zigzag : ∀ {X₁ X₂ Y₁ Y₂} (pfX : X₁ ≡₀ X₂) (rfX : X₂ ≡₀ X₁)
(pfY : Y₁ ≡₀ Y₂) (rfY : Y₂ ≡₀ Y₁)
→ {f : X₁ ⇒ Y₁}
→ coerce rfX rfY (coerce pfX pfY f) ≡ f
coerce-zigzag pfX rfX pfY rfY {f} =
begin
coerce rfX rfY (coerce pfX pfY f)
↑⟨ coerce-trans _ _ _ _ _ ⟩
coerce (trans pfX rfX) (trans pfY rfY) f
↓⟨ coerce-local _ _ ⟩
f
∎
where
open HomReasoning
open Equiv₀
.coerce-uncong : ∀ {X₁ X₂ Y₁ Y₂} (pfX : X₁ ≡₀ X₂) (pfY : Y₁ ≡₀ Y₂) (f g : X₁ ⇒ Y₁) → coerce pfX pfY f ≡ coerce pfX pfY g → f ≡ g
coerce-uncong xpf ypf f g fg-pf =
begin
f
↑⟨ coerce-zigzag _ _ _ _ ⟩
coerce (sym xpf) (sym ypf) (coerce xpf ypf f)
↓⟨ coerce-resp-≡ _ _ fg-pf ⟩
coerce (sym xpf) (sym ypf) (coerce xpf ypf g)
↓⟨ coerce-zigzag _ _ _ _ ⟩
g
∎
where
open HomReasoning
open Equiv₀
.coerce-slide⇒ : ∀ {X₁ X₂ Y₁ Y₂} (pfX : X₁ ≡₀ X₂) (rfX : X₂ ≡₀ X₁)
(pfY : Y₁ ≡₀ Y₂) (rfY : Y₂ ≡₀ Y₁)
→ (f : X₁ ⇒ Y₁) (g : X₂ ⇒ Y₂)
→ coerce pfX pfY f ≡ g → f ≡ coerce rfX rfY g
coerce-slide⇒ pfX rfX pfY rfY f g eq =
begin
f
↑⟨ coerce-zigzag _ _ _ _ ⟩
coerce rfX rfY (coerce pfX pfY f)
↓⟨ coerce-resp-≡ _ _ eq ⟩
coerce rfX rfY g
∎
where open HomReasoning
.coerce-slide⇐ : ∀ {X₁ X₂ Y₁ Y₂} (pfX : X₁ ≡₀ X₂) (rfX : X₂ ≡₀ X₁)
(pfY : Y₁ ≡₀ Y₂) (rfY : Y₂ ≡₀ Y₁)
→ (f : X₁ ⇒ Y₁) (g : X₂ ⇒ Y₂)
→ f ≡ coerce rfX rfY g → coerce pfX pfY f ≡ g
coerce-slide⇐ pfX rfX pfY rfY f g eq =
begin
coerce pfX pfY f
↓⟨ coerce-resp-≡ _ _ eq ⟩
coerce pfX pfY (coerce rfX rfY g)
↓⟨ coerce-zigzag _ _ _ _ ⟩
g
∎
where open HomReasoning
.coerce-id : ∀ {X Y} (pf₁ pf₂ : X ≡₀ Y) → coerce pf₁ pf₂ id ≡ id
coerce-id pf₁ pf₂ =
begin
coerce pf₁ pf₂ id
↑⟨ identityˡ ⟩
id ∘ coerce pf₁ pf₂ id
↑⟨ ∘-resp-≡ˡ (coerce-local _ _) ⟩
coerce (trans (sym pf₂) pf₂) (trans (sym pf₂) pf₂) id ∘ coerce pf₁ pf₂ id
↓⟨ ∘-resp-≡ˡ (coerce-trans _ _ _ _ _) ⟩
coerce pf₂ pf₂ (coerce (sym pf₂) (sym pf₂) id) ∘ coerce pf₁ pf₂ id
↑⟨ coerce-∘ _ _ _ _ _ ⟩
coerce pf₁ pf₂ (coerce (sym pf₂) (sym pf₂) id ∘ id)
↓⟨ coerce-resp-≡ _ _ identityʳ ⟩
coerce pf₁ pf₂ (coerce (sym pf₂) (sym pf₂) id)
↑⟨ coerce-trans _ _ _ _ _ ⟩
coerce (trans (sym pf₂) pf₁) (trans (sym pf₂) pf₂) id
↓⟨ coerce-local _ _ ⟩
id
∎
where
open HomReasoning
open Equiv₀
module Heterogeneous {o ℓ e} {C : Category o ℓ e} {q} (Q : Congruence C q) where
open Category C
open Congruence Q
open Equiv renaming (refl to refl′; sym to sym′; trans to trans′; reflexive to reflexive′)
open Equiv₀ renaming (refl to refl₀; sym to sym₀; trans to trans₀; reflexive to reflexive₀)
infix 4 _∼_
data _∼_ {A B} (f : A ⇒ B) {X Y} (g : X ⇒ Y) : Set (o ⊔ ℓ ⊔ e ⊔ q) where
≡⇒∼ : (ax : A ≡₀ X) (by : B ≡₀ Y) → .(coerce ax by f ≡ g) → f ∼ g
refl : ∀ {A B} {f : A ⇒ B} → f ∼ f
refl = ≡⇒∼ refl₀ refl₀ (coerce-refl _)
sym : ∀ {A B} {f : A ⇒ B} {D E} {g : D ⇒ E} → f ∼ g → g ∼ f
sym (≡⇒∼ A≡D B≡E f≡g) = ≡⇒∼ (sym₀ A≡D) (sym₀ B≡E) (coerce-slide⇐ _ _ _ _ _ _ (sym′ f≡g))
trans : ∀ {A B} {f : A ⇒ B}
{D E} {g : D ⇒ E}
{F G} {h : F ⇒ G}
→ f ∼ g → g ∼ h → f ∼ h
trans (≡⇒∼ A≡D B≡E f≡g) (≡⇒∼ D≡F E≡G g≡h) = ≡⇒∼
(trans₀ A≡D D≡F)
(trans₀ B≡E E≡G)
(trans′ (trans′ (coerce-trans _ _ _ _ _) (coerce-resp-≡ _ _ f≡g)) g≡h)
reflexive : ∀ {A B} {f g : A ⇒ B} → f ≣ g → f ∼ g
reflexive f≣g = ≡⇒∼ refl₀ refl₀ (trans′ (coerce-refl _) (reflexive′ f≣g))
∘-resp-∼ : ∀ {A B C A′ B′ C′} {f : B ⇒ C} {h : B′ ⇒ C′} {g : A ⇒ B} {i : A′ ⇒ B′} → f ∼ h → g ∼ i → (f ∘ g) ∼ (h ∘ i)
∘-resp-∼ {f = f} {h} {g} {i} (≡⇒∼ B≡B′₁ C≡C′ f≡h) (≡⇒∼ A≡A′ B≡B′₂ g≡i) = ≡⇒∼
A≡A′
C≡C′
(begin
coerce A≡A′ C≡C′ (f ∘ g)
↓⟨ coerce-∘ _ _ _ _ _ ⟩
coerce B≡B′₁ C≡C′ f ∘ coerce A≡A′ B≡B′₁ g
↓⟨ ∘-resp-≡ʳ (coerce-invariant _ _ _ _ _) ⟩
coerce B≡B′₁ C≡C′ f ∘ coerce A≡A′ B≡B′₂ g
↓⟨ ∘-resp-≡ f≡h g≡i ⟩
h ∘ i
∎)
where open HomReasoning
∘-resp-∼ˡ : ∀ {A B C C′} {f : B ⇒ C} {h : B ⇒ C′} {g : A ⇒ B} → f ∼ h → (f ∘ g) ∼ (h ∘ g)
∘-resp-∼ˡ {f = f} {h} {g} (≡⇒∼ B≡B C≡C′ f≡h) = ≡⇒∼ refl₀ C≡C′
(begin
coerce refl₀ C≡C′ (f ∘ g)
↓⟨ coerce-∘ _ _ _ _ _ ⟩
coerce B≡B C≡C′ f ∘ coerce refl₀ B≡B g
↓⟨ ∘-resp-≡ʳ (coerce-local _ _) ⟩
coerce B≡B C≡C′ f ∘ g
↓⟨ ∘-resp-≡ˡ f≡h ⟩
h ∘ g
∎)
where open HomReasoning
∘-resp-∼ʳ : ∀ {A A′ B C} {f : A ⇒ B} {h : A′ ⇒ B} {g : B ⇒ C} → f ∼ h → (g ∘ f) ∼ (g ∘ h)
∘-resp-∼ʳ {f = f} {h} {g} (≡⇒∼ A≡A′ B≡B f≡h) = ≡⇒∼ A≡A′ refl₀
(begin
coerce A≡A′ refl₀ (g ∘ f)
↓⟨ coerce-∘ _ _ _ _ _ ⟩
coerce B≡B refl₀ g ∘ coerce A≡A′ B≡B f
↓⟨ ∘-resp-≡ˡ (coerce-local _ _) ⟩
g ∘ coerce A≡A′ B≡B f
↓⟨ ∘-resp-≡ʳ f≡h ⟩
g ∘ h
∎)
where open HomReasoning
.∼⇒≡ : ∀ {A B} {f g : A ⇒ B} → f ∼ g → f ≡ g
∼⇒≡ (≡⇒∼ A≡A B≡B f≡g) = trans′ (sym′ (coerce-local A≡A B≡B)) (irr f≡g)
domain-≣ : ∀ {A A′ B B′} {f : A ⇒ B} {f′ : A′ ⇒ B′} → f ∼ f′ → A ≡₀ A′
domain-≣ (≡⇒∼ eq _ _) = eq
codomain-≣ : ∀ {A A′ B B′} {f : A ⇒ B} {f′ : A′ ⇒ B′} → f ∼ f′ → B ≡₀ B′
codomain-≣ (≡⇒∼ _ eq _) = eq
∼-cong : ∀ {t : Level} {T : Set t} {dom cod : T → Obj} (f : (x : T) → dom x ⇒ cod x) → ∀ {i j} (eq : i ≣ j) → f i ∼ f j
∼-cong f ≣-refl = refl
-- henry ford versions
.∼⇒≡₂ : ∀ {A A′ B B′} {f : A ⇒ B} {f′ : A′ ⇒ B′} → f ∼ f′ → (A≡A′ : A ≡₀ A′) (B≡B′ : B ≡₀ B′) → coerce A≡A′ B≡B′ f ≡ f′
∼⇒≡₂ (≡⇒∼ pfA pfB pff) A≡A′ B≡B′ = trans′ (coerce-invariant _ _ _ _ _) (irr pff)
-- .∼⇒≡ˡ : ∀ {A B B′} {f : A ⇒ B} {f′ : A ⇒ B′} → f ∼ f′ → (B≣B′ : B ≣ B′) → floatˡ B≣B′ f ≡ f′
-- ∼⇒≡ˡ pf ≣-refl = ∼⇒≡ pf
-- .∼⇒≡ʳ : ∀ {A A′ B} {f : A ⇒ B} {f′ : A′ ⇒ B} → f ∼ f′ → (A≣A′ : A ≣ A′) → floatʳ A≣A′ f ≡ f′
-- ∼⇒≡ʳ pf ≣-refl = ∼⇒≡ pf
-- ≡⇒∼ʳ : ∀ {A A′ B} {f : A ⇒ B} {f′ : A′ ⇒ B} → (A≣A′ : A ≣ A′) → .(floatʳ A≣A′ f ≡ f′) → f ∼ f′
-- ≡⇒∼ʳ ≣-refl pf = ≡⇒∼ pf
coerce-resp-∼ : ∀ {A A′ B B′} (A≡A′ : A ≡₀ A′) (B≡B′ : B ≡₀ B′) {f : C [ A , B ]} → f ∼ coerce A≡A′ B≡B′ f
coerce-resp-∼ A≡A′ B≡B′ = ≡⇒∼ A≡A′ B≡B′ refl′
-- floatˡ-resp-∼ : ∀ {A B B′} (B≣B′ : B ≣ B′) {f : C [ A , B ]} → f ∼ floatˡ B≣B′ f
-- floatˡ-resp-∼ ≣-refl = refl
-- floatʳ-resp-∼ : ∀ {A A′ B} (A≣A′ : A ≣ A′) {f : C [ A , B ]} → f ∼ floatʳ A≣A′ f
-- floatʳ-resp-∼ ≣-refl = refl
infixr 4 ▹_
record -⇒- : Set (o ⊔ ℓ) where
constructor ▹_
field
{Dom} : Obj
{Cod} : Obj
morphism : Dom ⇒ Cod
∼-setoid : Setoid _ _
∼-setoid = record {
Carrier = -⇒-;
_≈_ = λ x y → -⇒-.morphism x ∼ -⇒-.morphism y;
isEquivalence = record { refl = refl; sym = sym; trans = trans } }
module HetReasoning where
open SetoidReasoning ∼-setoid public
_[_∼_] : ∀ {o ℓ e} {C : Category o ℓ e} {q} (Q : Congruence C q) {A B} (f : C [ A , B ]) {X Y} (g : C [ X , Y ]) → Set (q ⊔ o ⊔ ℓ ⊔ e)
Q [ f ∼ g ] = Heterogeneous._∼_ Q f g
TrivialCongruence : ∀ {o ℓ e} (C : Category o ℓ e) → Congruence C _
TrivialCongruence C = record
{ _≡₀_ = _≣_
; equiv₀ = ≣-isEquivalence
; coerce = ≣-subst₂ (_⇒_)
; coerce-resp-≡ = resp-≡
; coerce-refl = λ f → refl
; coerce-invariant = invariant
; coerce-trans = tranz
; coerce-∘ = compose
}
where
open Category C
open Equiv
-- XXX must this depend on proof irrelevance?
.resp-≡ : ∀ {X₁ X₂ Y₁ Y₂} (xpf : X₁ ≣ X₂) (ypf : Y₁ ≣ Y₂) {f₁ f₂ : X₁ ⇒ Y₁}
→ f₁ ≡ f₂ → ≣-subst₂ _⇒_ xpf ypf f₁ ≡ ≣-subst₂ _⇒_ xpf ypf f₂
resp-≡ ≣-refl ≣-refl eq = eq
.invariant : ∀ {X₁ X₂ Y₁ Y₂} (xpf₁ xpf₂ : X₁ ≣ X₂) (ypf₁ ypf₂ : Y₁ ≣ Y₂)
→ (f : X₁ ⇒ Y₁)
→ ≣-subst₂ _⇒_ xpf₁ ypf₁ f ≡ ≣-subst₂ _⇒_ xpf₂ ypf₂ f
invariant ≣-refl ≣-refl ≣-refl ≣-refl f = refl
.tranz : ∀ {X₁ X₂ X₃ Y₁ Y₂ Y₃} (xpf₁ : X₁ ≣ X₂) (xpf₂ : X₂ ≣ X₃)
(ypf₁ : Y₁ ≣ Y₂) (ypf₂ : Y₂ ≣ Y₃)
→ (f : X₁ ⇒ Y₁)
→ ≣-subst₂ _⇒_ (≣-trans xpf₁ xpf₂) (≣-trans ypf₁ ypf₂) f
≡ ≣-subst₂ _⇒_ xpf₂ ypf₂ (≣-subst₂ _⇒_ xpf₁ ypf₁ f)
tranz ≣-refl xpf₂ ≣-refl ypf₂ f = refl
.compose : ∀ {X₁ X₂ Y₁ Y₂ Z₁ Z₂} (pfX : X₁ ≣ X₂)(pfY : Y₁ ≣ Y₂)(pfZ : Z₁ ≣ Z₂)
→ (g : Y₁ ⇒ Z₁) (f : X₁ ⇒ Y₁)
→ ≣-subst₂ _⇒_ pfX pfZ (g ∘ f)
≡ ≣-subst₂ _⇒_ pfY pfZ g ∘ ≣-subst₂ _⇒_ pfX pfY f
compose ≣-refl ≣-refl ≣-refl g f = refl
|
Input/Macros/test1.asm | AhmedAlaa2024/Chat-and-Game-x86_Assembly | 0 | 178075 | INCLUDE maths.inc
.MODEL SMALL
.STACK 64
.DATA
;DEFINE YOUR DATA HERE
COMMAND1 DB 'ADD AX,BX'
INCLUDE data.inc
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV ES,AX
;================================
MATH_OPERATION_CLASSIFY COMMAND1, OP_FLAG
;================================
;Safely return to OS
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN |
dos/DosQSysInfo.asm | osfree-project/FamilyAPI | 0 | 87249 | ;/*!
; @file
;
; @ingroup fapi
;
; @brief DosQSysInfo DOS wrapper
;
; (c) osFree Project 2021, <http://www.osFree.org>
; for licence see licence.txt in root directory, or project website
;
; This is Family API implementation for DOS, used with BIND tools
; to link required API
;
; @author <NAME> (<EMAIL>)
;
; Documentation: http://osfree.org/doku/en:docs:fapi:dosqsysinfo
;
;* 0 NO_ERROR
;* 87 ERROR_INVALID_PARAMETER
;*111 ERROR_BUFFER_OVERFLOW
;
;@todo Seems support undocumented indexes from 32-bit world. Need to expand later.
;
;*/
.8086
; Helpers
INCLUDE helpers.inc
INCLUDE bseerr.inc
INCLUDE GlobalVars.inc
_TEXT SEGMENT BYTE PUBLIC 'CODE' USE16
@PROLOG DOSQSYSINFO
DATABUFLEN DW ? ;Data buffer size
DATABUF DD ? ;System information (returned)
INDEX DW ? ;Which variable
@START DOSQSYSINFO
MOV AX, [DS:BP].ARGS.INDEX
CMP AX, 0
JZ @F
INVPARAM:
MOV AX, ERROR_INVALID_PARAMETER
JMP EXIT
@@:
MOV BX, [DS:BP].ARGS.DATABUFLEN
CMP BX, 2
JZ @F
JA INVPARAM
MOV AX, ERROR_BUFFER_OVERFLOW
JMP EXIT
@@:
LES DI, [DS:BP].ARGS.DATABUF
MOV AX, [MAXPATHLEN]
MOV [ES:DI], AX
XOR AX, AX
EXIT:
@EPILOG DOSQSYSINFO
_TEXT ENDS
END
|
oeis/078/A078700.asm | neoneye/loda-programs | 11 | 88793 | <reponame>neoneye/loda-programs
; A078700: Number of symmetric ways to lace a shoe that has n pairs of eyelets such that each eyelet has at least one direct connection to the opposite side.
; Submitted by <NAME>(s4)
; 1,2,6,30,192,1560,15120,171360,2217600,32296320,522547200,9300614400,180583603200,3798482688000,86044973414400,2088355965696000,54064489070592000,1487129136869376000,43312058119249920000
mov $1,1
mov $2,1
lpb $0
mul $1,$0
mul $2,$0
sub $0,1
mov $3,$2
add $2,$1
mov $1,$3
lpe
mov $0,$2
|
cv/cvpuball.asm | DigitalMars/optlink | 28 | 175446 | <filename>cv/cvpuball.asm
TITLE CVPUBALL - Copyright (c) SLR Systems 1994
INCLUDE MACROS
if fg_cvpack
INCLUDE SYMBOLS
INCLUDE MODULES
INCLUDE SEGMENTS
INCLUDE CVTYPES
INCLUDE SEGMSYMS
if fg_pe
INCLUDE PE_STRUC
endif
PUBLIC CV_PUBLICS_ALL_4
.DATA
EXTERNDEF CV_TEMP_RECORD:BYTE
EXTERNDEF CURNMOD_NUMBER:DWORD,CV_PUB_TXT_OFFSET:DWORD,CV_PUB_SYMBOL_ID:DWORD,CVG_SEGMENT:DWORD
EXTERNDEF BYTES_SO_FAR:DWORD,CVG_SYMBOL_OFFSET:DWORD,CVG_SEGMENT_OFFSET:DWORD,CVG_SYMBOL_HASH:DWORD
EXTERNDEF PE_BASE:DWORD,CURNMOD_GINDEX:DWORD,FIRST_MODULE_GINDEX:DWORD
EXTERNDEF MODULE_GARRAY:STD_PTR_S,SYMBOL_GARRAY:STD_PTR_S,SEGMENT_GARRAY:STD_PTR_S,PE_OBJECT_GARRAY:STD_PTR_S
EXTERNDEF FIRST_IMPMOD_GINDEX:DWORD,IMPMOD_GARRAY:IMPMOD_STRUCT
EXTERNDEF ICODE_PEOBJECT_GINDEX:DWORD,ICODE_PEOBJECT_NUMBER:DWORD
EXTERNDEF PE_THUNKS_RVA:DWORD,PE_IMPORTS_OBJECT_NUMBER:DWORD,PE_IMPORTS_OBJECT_GINDEX:DWORD
.CODE ROOT_TEXT
EXTERNDEF MOVE_ASCIZ_ESI_EDI:PROC
.CODE CVPACK_TEXT
EXTERNDEF MOVE_TEXT_TO_OMF:PROC,HANDLE_CV_INDEX:PROC,FLUSH_CV_TEMP:PROC,_store_cv_symbol_info:proc
EXTERNDEF _output_cv_symbol_align:proc,_init_cv_symbol_hashes:proc,_flush_cv_symbol_hashes:proc,SAY_VERBOSE:PROC
EXTERNDEF GET_NAME_HASH32:PROC,MOVE_ASCIZ_ESI_EDI:PROC
CV_PUBLICS_ALL_4_VARS STRUC
THUNKS_RVA_BP DD ?
PUBLIC_VECTOR_BP DD ?
IMPSYM_RVA_BP DD ?
IMPNAME_BUFFER_BP DD ?
IMPNAME_BUFFER2_BP DW ?
NAME_BUFFER_BP DB SYMBOL_TEXT_SIZE+2 DUP (?)
CV_PUBLICS_ALL_4_VARS ENDS
FIX MACRO X
X EQU ([EBP-SIZE CV_PUBLICS_ALL_4_VARS].(X&_BP))
ENDM
FIX THUNKS_RVA
FIX PUBLIC_VECTOR
FIX IMPSYM_RVA
FIX IMPNAME_BUFFER
FIX IMPNAME_BUFFER2
FIX NAME_BUFFER
CV_PUBLICS_ALL_4 PROC
;
;OUTPUT GLOBALPUBLIC TABLE
;
;
;INITIALIZE STUFF
;
PUSHM EBP,EDI,ESI,EBX
MOV EAX,SYMBOL_TEXT_SIZE/2 - 4
MOV EBP,ESP
SUB ESP,SIZE CV_PUBLICS_ALL_4_VARS - SYMBOL_TEXT_SIZE - 4
PUSH EBP
SUB ESP,EAX
PUSH EBP
SUB ESP,EAX
PUSH EBP
ASSUME EBP:PTR CV_PUBLICS_ALL_4_VARS
MOV EAX,OFF DOING_SSTGLOBALPUB_MSG
CALL SAY_VERBOSE
SETT DOING_4K_ALIGN ;WE WANT S_ALIGN SYMBOLS WHERE NEEDED
RESS ANY_PUBLICS
;
;MODULE BY MODULE, ADD PUBLIC SYMBOLS TO TABLE
;
MOV ESI,FIRST_MODULE_GINDEX
JMP L3$
L1$:
CONVERT ESI,ESI,MODULE_GARRAY
ASSUME ESI:PTR MODULE_STRUCT
MOV BL,[ESI]._M_FLAGS
MOV EAX,[ESI]._M_NEXT_MODULE_GINDEX
AND BL,MASK M_OMIT_$$PUBLICS ;DID LNKDIR PCODE DIRECTIVE SAY NO?
PUSH EAX
JNZ L2$
MOV EAX,[ESI]._M_FIRST_PUB_GINDEX
MOV PUBLIC_VECTOR,OFFSET STORE_THIS_PUBLIC
CALL STORE_MY_PUBLICS
L2$:
POP ESI
L3$:
TEST ESI,ESI
JNZ L1$
;
;NOW SCAN FOR IMPORTS
;
GETT CL,OUTPUT_PE
TEST CL,CL
JZ L6$
CALL INIT_IMPORT_STUFF
MOV EAX,FIRST_IMPMOD_GINDEX
PUSH EAX
JMP L5$
L4$:
CONVERT ESI,ESI,IMPMOD_GARRAY
ASSUME ESI:PTR IMPMOD_STRUCT
MOV EAX,[ESI]._IMPM_NEXT_GINDEX
PUSH EAX
MOV EAX,[ESI]._IMPM_NAME_SYM_GINDEX
MOV PUBLIC_VECTOR,OFFSET STORE_THIS_IMPORT
CALL STORE_MY_PUBLICS
MOV EAX,[ESI]._IMPM_ORD_SYM_GINDEX
CALL STORE_MY_PUBLICS
ADD THUNKS_RVA,4
L5$:
POP ESI
TEST ESI,ESI
JNZ L4$
L6$:
BITT ANY_PUBLICS
JZ L9$
MOV EAX,OFF CV_TEMP_RECORD
MOV CURNMOD_NUMBER,-1
MOV DPTR [EAX],6 + S_ALIGN*64K
MOV DPTR 4[EAX],-1
push EAX
call _output_cv_symbol_align ;DO DWORD ALIGN, 4K ALIGN, RETURN OFFSET
add ESP,4
;
;CLEANUP INCLUDES:
; 1. DO NAME HASH TABLE
; 2. DO ADDRESS HASH TABLE
; 3. WRITE HEADER
; 4. DO CV_INDEX
;
push EDI
MOV EAX,012AH
push EAX
call _flush_cv_symbol_hashes
add ESP,8
L9$:
MOV ESP,EBP
POPM EBX,ESI,EDI,EBP
RET
CV_PUBLICS_ALL_4 ENDP
STORE_MY_PUBLICS PROC NEAR
PUSHM ESI
;
;OUTPUT PUBLICS PLEASE
;
L0$:
TEST EAX,EAX
JZ L9$
CONVERT EAX,EAX,SYMBOL_GARRAY
ASSUME EAX:PTR SYMBOL_STRUCT
MOV ESI,EAX
MOV BL,[EAX]._S_REF_FLAGS
MOV EAX,[EAX]._S_NEXT_SYM_GINDEX
AND BL,MASK S_SPACES + MASK S_NO_CODEVIEW
JNZ L0$
PUSH EAX
;
;ESI IS SYMBOL
;
GETT AL,ANY_PUBLICS
TEST AL,AL
JZ L1$
L2$:
CALL PUBLIC_VECTOR
POP EAX
JMP L0$
L9$:
POPM ESI
RET
L1$:
SETT ANY_PUBLICS
call _init_cv_symbol_hashes
JMP L2$
STORE_MY_PUBLICS ENDP
STORE_THIS_PUBLIC PROC NEAR
;
;ESI IS SYMBOL
;
MOV EDI,OFF CV_TEMP_RECORD
CALL CREATE_PUBSYM ;RETURNS DX == SEGMENT, CX:BX IS OFFSET
MOV EAX,OFF CV_TEMP_RECORD
MOV CVG_SEGMENT_OFFSET,EBX
MOV CVG_SEGMENT,EDX
push EAX
call _output_cv_symbol_align ;DO DWORD ALIGN, 4K ALIGN, RETURN OFFSET
add ESP,4
MOV CVG_SYMBOL_OFFSET,EAX ;STORE SYMBOL OFFSET
MOV EAX,CV_PUB_TXT_OFFSET
ADD EAX,OFF CV_TEMP_RECORD
CALL GET_NAME_HASH32
MOV CVG_SYMBOL_HASH,EAX
jmp _store_cv_symbol_info ;STORE INFO FOR SYMBOL HASHES
; RET
STORE_THIS_PUBLIC ENDP
CREATE_PUBSYM PROC NEAR
;
;RETURN EDX = SEGMENT, EBX IS OFFSET
;
ASSUME ESI:PTR SYMBOL_STRUCT
MOV EDX,[ESI]._S_SEG_GINDEX
MOV EAX,[ESI]._S_OFFSET
TEST EDX,EDX
JZ L4$
CONVERT EDX,EDX,SEGMENT_GARRAY
ASSUME EDX:PTR SEGMENT_STRUCT
GETT CL,OUTPUT_PE
OR CL,CL
JNZ L1$
MOV ECX,[EDX]._SEG_OFFSET
MOV EDX,[EDX]._SEG_CV_NUMBER
SUB EAX,ECX
JMP L4$
L1$:
MOV ECX,[EDX]._SEG_PEOBJECT_GINDEX
MOV EDX,[EDX]._SEG_PEOBJECT_NUMBER
CONVERT ECX,ECX,PE_OBJECT_GARRAY
ASSUME ECX:PTR PE_OBJECT_STRUCT
SUB EAX,PE_BASE
MOV ECX,[ECX]._PEOBJECT_RVA
SUB EAX,ECX
L4$:
;
;EAX IS OFFSET
;EDX IS SEGMENT #
;
MOV EBX,EDI
MOV ECX,103H ;ASSUME 16BIT?
PUSHM EAX,EDX
MOV [EDI+4],EAX ;STORE OFFSET
GETT AL,OUTPUT_32BITS
ADD EDI,10 ;UPDATE PER 16-BIT
LEA ESI,[ESI]._S_NAME_TEXT
OR AL,AL
JZ DO_16
ADD EDI,2
MOV CH,2 ;ECX=203H
DO_16:
MOV WPTR [EBX+2],CX
MOV [EDI-4],EDX
CALL MOVE_TEXT_TO_OMF
LEA EAX,[EDI-2]
POP EDX
SUB EAX,EBX
MOV WPTR [EBX],AX ;RECORD LENGTH
POP EBX
;
;RETURN EDX = SEGMENT, EBX IS OFFSET
;
RET
CREATE_PUBSYM ENDP
INIT_IMPORT_STUFF PROC NEAR
MOV EAX,PE_THUNKS_RVA
MOV THUNKS_RVA,EAX
MOV IMPNAME_BUFFER,'mi__'
MOV IMPNAME_BUFFER2,'_p'
MOV EAX,ICODE_PEOBJECT_GINDEX
CONVERT EAX,EAX,PE_OBJECT_GARRAY
ASSUME EAX:PTR PE_OBJECT_STRUCT
TEST EAX,EAX
JZ L1
MOV EAX,[EAX]._PEOBJECT_RVA
ADD EAX,PE_BASE
MOV IMPSYM_RVA,EAX
L1:
MOV EAX,PE_IMPORTS_OBJECT_GINDEX
CONVERT EAX,EAX,PE_OBJECT_GARRAY
TEST EAX,EAX
JZ L2
MOV EAX,[EAX]._PEOBJECT_RVA
SUB THUNKS_RVA,EAX
L2:
RET
INIT_IMPORT_STUFF ENDP
STORE_THIS_IMPORT PROC NEAR
;
;ESI IS SYMBOL
;
MOV EDI,OFF CV_TEMP_RECORD
PUSHM ESI
CALL CREATE_PUBIMPSYM ;RETURNS DX == SEGMENT, CX:BX IS OFFSET
MOV EAX,OFF CV_TEMP_RECORD
MOV CVG_SEGMENT_OFFSET,EBX
MOV CVG_SEGMENT,EDX
push EAX
call _output_cv_symbol_align ;DO DWORD ALIGN, 4K ALIGN, RETURN OFFSET
add ESP,4
MOV CVG_SYMBOL_OFFSET,EAX ;STORE SYMBOL OFFSET
MOV EAX,CV_PUB_TXT_OFFSET
ADD EAX,OFF CV_TEMP_RECORD
CALL GET_NAME_HASH32
MOV CVG_SYMBOL_HASH,EAX
call _store_cv_symbol_info ;STORE INFO FOR SYMBOL HASHES
MOV EDI,OFF CV_TEMP_RECORD
POPM ESI
CALL CREATE_PUB__IMP ;RETURNS DX == SEGMENT, CX:BX IS OFFSET
MOV EAX,OFF CV_TEMP_RECORD
MOV CVG_SEGMENT_OFFSET,EBX
MOV CVG_SEGMENT,EDX
push EAX
call _output_cv_symbol_align ;DO DWORD ALIGN, 4K ALIGN, RETURN OFFSET
add ESP,4
MOV CVG_SYMBOL_OFFSET,EAX ;STORE SYMBOL OFFSET
MOV EAX,CV_PUB_TXT_OFFSET
ADD EAX,OFF CV_TEMP_RECORD
CALL GET_NAME_HASH32
MOV CVG_SYMBOL_HASH,EAX
jmp _store_cv_symbol_info ;STORE INFO FOR SYMBOL HASHES
; RET
STORE_THIS_IMPORT ENDP
CREATE_PUBIMPSYM PROC NEAR
;
;RETURN EDX = SEGMENT, EBX IS OFFSET
;
ASSUME ESI:PTR SYMBOL_STRUCT
MOV EAX,[ESI]._S_OFFSET
MOV EDX,ICODE_PEOBJECT_NUMBER
SUB EAX,IMPSYM_RVA
;
;EAX IS OFFSET
;EDX IS SEGMENT #
;
MOV EBX,EDI
MOV ECX,203H ;ASSUME 32BIT
PUSHM EAX,EDX
MOV [EDI+4],EAX ;STORE OFFSET
ADD EDI,12 ;UPDATE PER 32-BIT
LEA ESI,[ESI]._S_NAME_TEXT
MOV WPTR [EBX+2],CX
MOV [EDI-4],EDX
CALL MOVE_TEXT_TO_OMF
LEA EAX,[EDI-2]
POP EDX
SUB EAX,EBX
MOV WPTR [EBX],AX ;RECORD LENGTH
POP EBX
;
;RETURN EDX = SEGMENT, EBX IS OFFSET
;
RET
CREATE_PUBIMPSYM ENDP
CREATE_PUB__IMP PROC NEAR
;
;RETURN EDX = SEGMENT, EBX IS OFFSET
;
ASSUME ESI:PTR SYMBOL_STRUCT
MOV EAX,THUNKS_RVA
ADD THUNKS_RVA,4
MOV EDX,PE_IMPORTS_OBJECT_NUMBER
;
;EAX IS OFFSET
;EDX IS SEGMENT #
;
MOV EBX,EDI
MOV ECX,203H ;ASSUME 32BIT
PUSHM EAX,EDX
MOV [EDI+4],EAX ;STORE OFFSET
ADD EDI,12 ;UPDATE PER 32-BIT
MOV WPTR [EBX+2],CX
MOV [EDI-4],EDX
PUSHM EDI
LEA ESI,[ESI]._S_NAME_TEXT
LEA EDI,NAME_BUFFER
CALL MOVE_ASCIZ_ESI_EDI
POPM EDI
LEA ESI,IMPNAME_BUFFER
CALL MOVE_TEXT_TO_OMF
LEA EAX,[EDI-2]
POP EDX
SUB EAX,EBX
MOV WPTR [EBX],AX ;RECORD LENGTH
POP EBX
;
;RETURN EDX = SEGMENT, EBX IS OFFSET
;
RET
CREATE_PUB__IMP ENDP
.CONST
DOING_SSTGLOBALPUB_MSG DB SIZEOF DOING_SSTGLOBALPUB_MSG-1,'Doing SSTGLOBALPUB',0DH,0AH
endif
END
|
PMOO/ADA/LAB2/PARTE_2/es_par.adb | usainzg/EHU | 0 | 28802 | function Es_Par(N: Integer) return Boolean is
begin
if N mod 2 = 0 then
return True;
end if;
return False;
end Es_Par; |
data/github.com/peterldowns/iterm2-finder-tools/49b1fe78bb50329b864902850104504ccfb53b45/application/application.applescript | ajnavarro/language-dataset | 9 | 2092 | on run {input, parameters}
tell application "Finder"
set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
end tell
CD_to(dir_path)
end run
on CD_to(theDir)
tell application "iTerm"
activate
set term to current terminal
try
term
on error
set term to (make new terminal)
end try
tell term
launch session "Default"
set sesh to current session
end tell
tell sesh
write text "cd " & theDir
end tell
end tell
end CD_to
|
src/sets/finite.agda | pcapriotti/agda-base | 20 | 17082 | {-# OPTIONS --without-K #-}
module sets.finite where
open import sets.finite.core public
|
test/Fail/Issue3684.agda | hborum/agda | 2 | 7334 | <reponame>hborum/agda
-- Andreas, 2019-04-12, issue #3684
-- Report also available record fields in case user gives spurious fields.
-- {-# OPTIONS -v tc.record:30 #-}
record R : Set₁ where
field
foo {boo} moo : Set
test : (A : Set) → R
test A = record
{ moo = A
; bar = A
; far = A
}
-- The record type R does not have the fields bar, far but it would
-- have the fields foo, boo
-- when checking that the expression
-- record { moo = A ; bar = A ; far = A } has type R
|
thirdparty/adasdl/thin/adasdl/AdaSDL_image/showimage.adb | Lucretia/old_nehe_ada95 | 0 | 10085 |
--
-- SHOWIMAGE: Port to the Ada programming language of a test application for the
-- the SDL image library.
--
-- The original code was written in C by <NAME> http://www.libsdl.org.
--
-- 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.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- Ada code written by:
-- <NAME> --
-- Ponta Delgada - Azores - Portugal --
-- E-mail: <EMAIL> --
-- http://www.adapower.net/~avargas --
with System;
with Interfaces.C.Strings;
with Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib;
with SDL.Video;
with SDL.Types; use SDL.Types;
with SDL.Byteorder;
with SDL.Byteorder.Extra;
with SDL.Quit;
with SDL.Error;
with SDL.Events;
with SDL_Image;
procedure ShowImage is
package C renames Interfaces.C;
use type C.int;
package It renames Interfaces;
use type It.Unsigned_32;
package CL renames Ada.Command_Line;
package CS renames Interfaces.C.Strings;
package V renames SDL.Video;
use type V.Palette_ptr;
use type V.Surface_ptr;
use type V.Surface_Flags;
package Er renames SDL.Error;
package Ev renames SDL.Events;
use type Ev.Event_Type;
package IMG renames SDL_Image;
-- Draw a Gimpish background pattern to show transparency in the image
-- ======================================
procedure draw_background (screen : V.Surface_ptr) is
use Uint8_PtrOps;
use Uint8_Ptrs;
use Uint16_PtrOps;
use Uint16_Ptrs;
use Uint32_PtrOps;
use Uint32_Ptrs;
use SDL.Byteorder;
use SDL.Byteorder.Extra;
package It renames Interfaces;
dst : System.Address := screen.pixels;
bpp : C.int := C.int (screen.format.BytesPerPixel);
type col_Array is array (It.Unsigned_32 range 0 .. 1) of It.Unsigned_32;
col : col_Array;
IS_LIL_ENDIAN : boolean := BYTE_ORDER = LIL_ENDIAN;
begin
col (0) := It.Unsigned_32 (V.MapRGB (screen.format, 16#66#, 16#66#, 16#66#));
col (1) := It.Unsigned_32 (V.MapRGB (screen.format, 16#99#, 16#99#, 16#99#));
for y in It.Unsigned_32 range 0 .. It.Unsigned_32 (screen.h) - 1 loop
for x in It.Unsigned_32 range 0 .. It.Unsigned_32 (screen.w) loop
-- use an 8x8 checkboard pattern
declare
cl : It.Unsigned_32 := col (It.Shift_Right (x xor y, 3) and 1);
begin
case bpp is -- The following code is not very nice. Suggestions?
when 1 =>
Uint8_PtrOps.Pointer (
Uint8_PtrOps.Pointer (Uint8_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x)
).all := Uint8 (cl);
when 2 =>
Uint16_PtrOps.Pointer (
Uint16_PtrOps.Pointer (Uint16_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x)
).all := Uint16 (cl);
when 3 =>
if IS_LIL_ENDIAN then
Uint8_PtrOps.Pointer (
Uint8_PtrOps.Pointer (Uint8_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x * 3)
).all := Uint8 (cl);
Uint8_PtrOps.Pointer (
Uint8_PtrOps.Pointer (Uint8_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x * 3 + 1)
).all := Uint8 (It.Shift_Right (cl, 8));
Uint8_PtrOps.Pointer (
Uint8_PtrOps.Pointer (Uint8_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x * 3 + 2)
).all := Uint8 (It.Shift_Right (cl, 16));
else
Uint8_PtrOps.Pointer (
Uint8_PtrOps.Pointer (Uint8_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x * 3)
).all := Uint8 (It.Shift_Right (cl, 16));
Uint8_PtrOps.Pointer (
Uint8_PtrOps.Pointer (Uint8_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x * 3 + 1)
).all := Uint8 (It.Shift_Right (cl, 8));
Uint8_PtrOps.Pointer (
Uint8_PtrOps.Pointer (Uint8_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x * 3 + 2)
).all := Uint8 (cl);
end if;
when 4 =>
Uint32_PtrOps.Pointer (
Uint32_PtrOps.Pointer (Uint32_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (x)
).all := Uint32 (cl);
when others => null;
end case;
end;
dst := Uint8_Ptrs.To_Address (Uint8_Ptrs.Object_Pointer (
Uint8_PtrOps.Pointer (Uint8_Ptrs.To_Pointer (dst))
+ C.ptrdiff_t (screen.pitch)));
end loop;
end loop;
end draw_background;
-- ======================================
screen, image : V.Surface_ptr;
depth : C.int;
begin
-- Check command line usage
if CL.Argument_Count = 0 then
Put_Line ("Usage: " & CL.Command_Name & " <image_file>");
GNAT.OS_Lib.OS_Exit (1);
end if;
-- Initialize the SDL library
if SDL.Init (SDL.INIT_VIDEO) < 0 then
Put_Line ("Couldn't initialize SDL: " & IMG.Get_Error);
GNAT.OS_Lib.OS_Exit (255);
end if;
-- Open the image file
image := IMG.Load (CL.Argument (1));
if image = null then
Put_Line ("Couldn't load " & CL.Argument (1)& ": " & IMG.Get_Error);
SDL.SDL_Quit;
GNAT.OS_Lib.OS_Exit (2);
end if;
V.WM_Set_Caption (CL.Argument (1), "showimage");
-- Create a display for the image
depth := V.VideoModeOK (image.w, image.h, 32, V.SWSURFACE);
-- Use the deepest native mode, except that we emulate 32bpp for
-- viewing non-indexed images on 8bpp screens
if image.format.BytesPerPixel > 1 and depth = 8 then
depth := 32;
end if;
screen := V.SetVideoMode (image.w, image.h, depth, V.SWSURFACE);
if screen = null then
Put_Line ("Couldn't set "
& C.int'Image (image.w) & "x"
& C.int'Image (image.h) & "x"
& C.int'Image (depth)
& " video mode: "
& IMG.Get_Error);
SDL.SDL_Quit;
GNAT.OS_Lib.OS_Exit (3);
end if;
-- set the palette, if one exists
if image.format.palette /= null then
V.SetColors (screen, image.format.palette.colors,
0, image.format.palette.ncolors);
end if;
-- Draw a background pattern if the surface has transparency
if (image.flags and (V.SRCALPHA or V.SRCCOLORKEY)) /= 0 then
null;
end if;
-- Display the image
V.BlitSurface (image, null, screen, null);
V.UpdateRect (screen, 0, 0, 0, 0);
-- Wait for any keyboard or mouse input
for i in Ev.NOEVENT .. Ev.NUMEVENTS - 1 loop
case i is
when Ev.KEYDOWN | Ev.MOUSEBUTTONDOWN | Ev.QUIT =>
-- Valid event, keep it
null;
when others =>
-- We don't want this event
Ev.EventState (Ev.Event_Type (i), Ev.IGNORE);
end case;
end loop;
Ev.WaitEvent (null);
-- We're done!
V.FreeSurface (image);
SDL.SDL_Quit;
GNAT.OS_Lib.OS_Exit (0);
end ShowImage;
|
src/main/antlr/com/concurnas/compiler/Concurnas.g4 | michaeldesu/Concurnas | 201 | 3857 | grammar Concurnas;
@header{
package com.concurnas.compiler;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Stack;
}
@lexer::members {
private int defaultTransHandlerId = 0;
boolean skipNewLine=false;
Stack<Boolean> prevskip = new Stack<Boolean>();
public boolean permitDollarPrefixRefName = false;
}
@parser::members{
private Stack<Boolean> isInArrayDef = new Stack<Boolean>();
private boolean notArrayDef(){
if(!isInArrayDef.isEmpty()){
return !isInArrayDef.peek();
}
return true;
}
public void setInArrayDef(){
isInArrayDef.push(true);
}
public void setNotInArrayDef(){
isInArrayDef.push(false);
}
public void popInArrayDef(){
isInArrayDef.pop();
}
}
code
: line* EOF
;
line
:
stmts
| nls=NEWLINE+
| nop=';' ';' //nop
;
stmts: csOrss ( (';'|NEWLINE+) csOrss)* (';'|NEWLINE+)? ;
csOrss: comppound_str_concat|compound_stmt|simple_stmt;//actor MyClass(12) expression reachable version takes priority over compound statement
comppound_str_concat: compound_stmt additiveOp_*;//permits us to do this: a = {} + "str concat"
single_line_block
: NEWLINE* '=>' NEWLINE* single_line_element (';' single_line_element)* ';'? //NEWLINE
;
single_line_element: comppound_str_concat|compound_stmt|simple_stmt| (nop=';');
///////////// simple_stmt /////////////
simple_stmt :
exprListShortcut
| assignment
| annotations
| assert_stmt
| delete_stmt
| return_stmt
| throw_stmt
| flow_stmt
| import_stmt
| typedef_stmt
| await_stmt
| lonleyExpression
//| u=using_stmt {$ret = $u.ret;} //dsls
;
lonleyExpression: expr_stmt_tuple;
exprListShortcut :
a1=refName atype1=mustBeArrayType ( aassStyle=assignStyle arhsExpr = expr_stmt_tuple)? //to deal with cases: myvar Integer[][] = null - which are otherwise picked up by next line...
| e1=refName e2=refName (rest=expr_stmt_)+;//to deal with cases such as: thing call arg. But watch out for: thing String[]
mustBeArrayType: (primitiveType | namedType | tupleType) trefOrArrayRef+ | funcType trefOrArrayRef*;
transientAndShared: //can be defined either way around
trans='transient'
| shared='shared'
| lazy='lazy'
| trans='transient' shared='shared'
| trans='transient' lazy='lazy'
| lazy='lazy' shared='shared'
| shared='shared' trans='transient'
| lazy='lazy' trans='transient'
| shared='shared' lazy='lazy'
| lazy='lazy' shared='shared' trans='transient'
| lazy='lazy' trans='transient' shared='shared'
| shared='shared' lazy='lazy' trans='transient'
| shared='shared' trans='transient' lazy='lazy'
| trans='transient' lazy='lazy' shared='shared'
| trans='transient' shared='shared' lazy='lazy'
;
assignment:
(annotations NEWLINE? )? ppp? (override='override')? transAndShared=transientAndShared? gpuVarQualifier? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? (refname = refName typeNoNTTuple) ( assStyle=assignStyle ( rhsAnnotShurtcut = annotation | rhsAssignment = assignmentForcedRHS | rhsExpr = expr_stmt_tuple ) | onchangeEveryShorthand )?
| (annotations NEWLINE? )? ppp? (override='override')? transAndShared=transientAndShared? gpuVarQualifier? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? refname = refName (refCnt+=':')* ( assStyle=assignStyle ( rhsAnnotShurtcut = annotation | rhsAssignment = assignmentForcedRHS | rhsExpr = expr_stmt_tuple ) | onchangeEveryShorthand)
| LPARA {setNotInArrayDef();} assignmentTupleDereflhsOrNothing (',' assignmentTupleDereflhsOrNothing)+ RPARA {popInArrayDef();} ( assStyle=assignStyle ( rhsAssignment = assignmentForcedRHS | rhsExpr = expr_stmt_tuple ) | onchangeEveryShorthand)
| ppp? (override='override')? transAndShared=transientAndShared? gpuVarQualifier? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? assignee=expr_stmt ( assStyle=assignStyle (rhsAnnotShurtcut = annotation | rhsAssignment = assignmentForcedRHS | rhsExpr = expr_stmt_tuple ) | onchangeEveryShorthand)
| lonleyannotation = annotation
;
assignmentForcedRHS:
(annotations NEWLINE? )? ppp? (override='override')? transAndShared=transientAndShared? gpuVarQualifier? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? (refname = refName type) ( assStyle=assignStyle ( rhsAnnotShurtcut = annotation | rhsAssignment = assignmentForcedRHS | rhsExpr = expr_stmt_tuple ) | onchangeEveryShorthand )
| (annotations NEWLINE? )? ppp? (override='override')? transAndShared=transientAndShared? gpuVarQualifier? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? refname = refName (refCnt+=':')* ( assStyle=assignStyle ( rhsAnnotShurtcut = annotation | rhsAssignment = assignmentForcedRHS | rhsExpr = expr_stmt_tuple ) | onchangeEveryShorthand)
| LPARA {setNotInArrayDef();} assignmentTupleDereflhsOrNothing (',' assignmentTupleDereflhsOrNothing)+ RPARA {popInArrayDef();} ( assStyle=assignStyle ( rhsAssignment = assignmentForcedRHS | rhsExpr = expr_stmt_tuple ) | onchangeEveryShorthand)
| ppp? (override='override')? transAndShared=transientAndShared? gpuVarQualifier? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? assignee=expr_stmt ( assStyle=assignStyle (rhsAnnotShurtcut = annotation | rhsAssignment = assignmentForcedRHS | rhsExpr = expr_stmt_tuple ) | onchangeEveryShorthand)
| lonleyannotation = annotation
;
assignmentTupleDereflhsOrNothing:
assignmentTupleDereflhs?
;
assignmentTupleDereflhs:
(annotations NEWLINE? )? ppp? (override='override')? transAndShared=transientAndShared? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? (refname = refName type)
| (annotations NEWLINE? )? ppp? (override='override')? transAndShared=transientAndShared? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? refname = refName (refCnt+=':')*
| ppp? transAndShared=transientAndShared? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? assignee=expr_stmt
;
//assignmentNamdAndTypeOnly: (annotations NEWLINE? )? ppp? trans='transient'? gpuVarQualifier? valvar=(VAL|VAR)? prefix=('-'|'+'|'~')? (refname = refName type);
onchangeEveryShorthand :
('<-' | isEvery='<=') (LPARA {setNotInArrayDef();} onChangeEtcArgs RPARA {popInArrayDef();})? expr_stmt_tuple
;
assert_stmt
: 'assert' e=expr_stmt_ s=stringNode?
;
delete_stmt
: 'del' expr_stmt (',' expr_stmt)* ','?
;
flow_stmt
: 'break' expr_stmt_tuple?
| 'continue' expr_stmt_tuple?
;
throw_stmt : 'throw' expr_stmt;
return_stmt : 'return' expr_stmt_tuple? ;
import_stmt
: import_stmt_impot
| import_stmt_from
;
import_stmt_impot
: ('import' | using='using') prim=dotted_as_name (',' sec+=dotted_as_name )* ','?
| ('import' | using='using') dotted_name DOT star='*'
;
import_stmt_from
: 'from' dotted_name ('import' | using='using') (import_as_name (',' import_as_name )* ','? | star='*')
;
import_as_name
: NAME ('as' NAME)?
;
dotted_as_name
: dotted_name ('as' NAME)?
;
typedef_stmt
: pppNoInject? 'typedef' NAME typedefArgs? '=' type
;
typedefArgs: '<' NAME (',' NAME )* ','? '>';
await_stmt
: 'await' LPARA {setNotInArrayDef();} onChangeEtcArgs ( ';' ( expr_stmt | block )? )? RPARA {popInArrayDef();} //TODO: expand the syntax permitte here
;
///////////// compound stmt /////////////
compound_stmt
:
( (annotations NEWLINE*)?
(
funcdef
| constructorDef
| classdef
| objectProvider
| annotationDef
| enumdef
)
)
| comp = compound_stmt_atomic_base
;
compound_stmt_atomic_base
: fors
| match_stmt
| if_stmt
| async_block
| while_stmt
| loop_stmt
| try_stmt
| block_async
| with_stmt
| trans_block
| init_block
| sync_block
| onchange
| every
;
blockOrBlock : block | single_line_block;
funcdef
: ppp? ( (override='override')? ('def' | gpuitem = 'gpudef' | gpuitem ='gpukernel' kerneldim = intNode) | (override='override') ) ( (extFuncOn ('|' extFuncOn)* )? funcDefName DOT?)?
genericQualiList?
LPARA {setNotInArrayDef();} funcParams? RPARA {popInArrayDef();} retTypeIncVoid? blockOrBlock?
;
funcDefName
: NAME //now for operator overloading...
| '='
| '+' | '-'
| '*'| '/'
| '**'| '++' | '--'
| 'mod' | 'or'| 'and'| 'not'
| '<''<' | '>' '>' | '>' '>' '>'
| 'comp' | 'band' | 'bor' | 'bxor'
| '-=' | '*=' | '/=' | 'mod=' | '**=' | '+=' | 'or=' | 'and=' | '<<='
| '>>=' | '>>>=' | 'band=' | 'bor=' | 'bxor='
;
extFuncOn
: extFunOn=type
//: extFunOn=namedType_ExActor|extFunOnPrim=primitiveType
;
funcParams
: funcParam (',' funcParam)* (',')?
;
funcParam:
annotations? sharedOrLazy? (gpuVarQualifier gpuInOutFuncParamModifier?)? (isFinal=VAL|VAR)?
(
NAME ( type isvararg='...'?)? ('=' expr_stmt )
|
NAME? ( type isvararg='...'?) ('=' expr_stmt )?
)
;
sharedOrLazy:
lazy = 'lazy' shared='shared'?
| shared='shared' lazy='lazy'?
;
gpuVarQualifier: 'global'|'local'|'constant';
gpuInOutFuncParamModifier : 'in'|'out';
constructorDef
: ppp? 'def'? 'this' LPARA {setNotInArrayDef();} funcParams? RPARA {popInArrayDef();} blockOrBlock
;
objectProviderArgs
: objectProviderArg (',' objectProviderArg )* (',')?
;
objectProviderArg:
annotations? pppNoInject? transAndShared=transientAndShared?
(isFinal=VAL|VAR)? NAME ((type | (refCnt+=':')+) isvararg='...'? )? ( '=' expr_stmt )?
;
objectProvider: pppNoInject? (trans='transient' | shared='shared')? 'provider' providerName=NAME
genericQualiList?
(LPARA {setNotInArrayDef();} objectProviderArgs? RPARA {popInArrayDef();})?
objectProviderBlock
;
objectProviderBlock:
LBRACE NEWLINE* linex+=objectProviderLine* RBRACE
;
objectProviderLine:
(pppNoInject? (single='single'|shared='shared')? 'provide' genericQualiList? lazy='lazy'? fieldName=stringNode? provName=NAME? provide=type ('=>' provideExpr=expr_stmt | objectProviderNestedDeps )?
| opdl=objectProviderLineDep) (';'|NEWLINE+)
;
objectProviderNestedDeps : LBRACE ((';'|NEWLINE+)? nestedDep+=objectProviderLineDep ((';'|NEWLINE+) nestedDep+=objectProviderLineDep)* )? (';'|NEWLINE+)? RBRACE;
objectProviderLineDep: (single='single'|shared='shared')? lazy='lazy'? fieldName=stringNode? nameFrom=type ('=>' exprTo=expr_stmt | '<=' typeOnlyRHS=type objectProviderNestedDeps?)?;
classdef
: p=ppp? aoc=('abstract'|'open'|'closed')? (trans='transient' | shared='shared')? ('class'|istrait='trait'|isactor='actor') className=NAME
genericQualiList?
(LPARA {setNotInArrayDef();} classdefArgs? RPARA {popInArrayDef();})?
(
istypedActor='of' ( typedActorOn=namedType_ExActor typeActeeExprList=expr_stmtList? )
)?
(
NEWLINE* ('extends'|'<') superCls=dotted_name ('<' superGenType+=type (',' superGenType+=type )* ','? '>')?
extExpressions=expr_stmtList?
)?
(
NEWLINE* ('with'|'~') implInstance ((',' implInstance)*) ','?
)?
(block | NEWLINE+ | EOF)
;
implInstance:
impli=dotted_name ('<' implType+=type (',' implType+=type )* ','? '>')?
;
localclassdef
: (trans='transient' | shared='shared')? ('class'|isactor='actor')
genericQualiList?
(LPARA {setNotInArrayDef();} classdefArgs? RPARA {popInArrayDef();})?
(
istypedActor='of' ( typedActorOn=namedType_ExActor typeActeeExprList=expr_stmtList? )
)?
(
('extends'|'<') superCls=dotted_name ('<' type (',' type )* ','? '>')?
extExpressions=expr_stmtList?
)?
(
('with'|'~') implInstance ((',' implInstance)* | ','?)
)?
block
;
anonclassdef
: ('new' isactor='actor'? )
(
superCls=dotted_name ('<' type (',' type )* ','? '>')?
)
(
('with'|'~') implInstance ((',' implInstance)* | ','?)
)?
block?
;
expr_stmtList : (LPARA {setNotInArrayDef();} (expr_stmt ( ',' expr_stmt )*)? RPARA {popInArrayDef();});
classdefArgs
: classdefArg (',' classdefArg )* (',')?
;
classdefArg:
annotations? pppNoInject? (override='override')? transAndShared=transientAndShared? (isFinal=VAL|VAR)? (prefix=('-'|'+'|'~'))? NAME ((type | (refCnt+=':')+) isvararg='...'? )? ( '=' expr_stmt )?
;
annotationDef
: pppNoInject? 'annotation' NAME
( LPARA {setNotInArrayDef();} annotationArg (',' annotationArg )* ','? RPARA {popInArrayDef();} )?
block?
;
annotationArg:
annotations? NAME type? ('=' expr_stmt)?
;
enumdef
: pppNoInject? 'enum' NAME (LPARA {setNotInArrayDef();} classdefArgs? RPARA {popInArrayDef();})? enumblock
;
enumItem
: annotations? NAME pureFuncInvokeArgs? block?//dont need to have args?
;
enumblock
: LBRACE NEWLINE* enumItem ( NEWLINE* ',' NEWLINE* enumItem )* (';'|NEWLINE*) line* NEWLINE* RBRACE
;
///////////// compound stmt:compound_stmt_atomic_base /////////////
fors
: for_stmt
| for_stmt_old
;
for_stmt
: forblockvariant LPARA {setNotInArrayDef();} ( (localVarName=NAME localVarType=type?) | ( LPARA {setNotInArrayDef();} forVarTupleOrNothing (',' forVarTupleOrNothing)+ RPARA {popInArrayDef();})) 'in' expr=expr_stmt_tuple
(';' (idxName=NAME idxType=type? (('\\=' | '=') idxExpr=expr_stmt)?) )? RPARA {popInArrayDef();} mainblock=block
(NEWLINE* 'else' elseblock=block )?
;
forVarTupleOrNothing: forVarTuple?;
forVarTuple: localVarName=NAME localVarType=type?;
for_stmt_old
: forblockvariant LPARA {setNotInArrayDef();} ( (NAME type? assignStyle assigFrom=expr_stmt_tuple) | assignExpr=expr_stmt_tuple )?
';' check=expr_stmt?
';' postExpr=expr_stmt?
RPARA {popInArrayDef();}
mainblock=block
( NEWLINE* 'else' elseblock=block )?
;
forblockvariant:'for'|'parfor' |'parforsync';
match_stmt
:
'match' NEWLINE* LPARA {setNotInArrayDef();} NEWLINE* simple_stmt NEWLINE* RPARA {popInArrayDef();} NEWLINE*
LBRACE NEWLINE*
match_case_stmt*
( NEWLINE* 'else' elseb=blockOrBlock)?
NEWLINE* RBRACE
;
match_case_stmt: match_case_stmt_case | match_case_stmt_nocase;
match_case_stmt_case:
(NEWLINE* 'case' LPARA {setNotInArrayDef();}
( (( match_case_stmt_typedCase //CaseExpressionAssign
| match_case_stmt_assign //TypedCaseExpression
| match_case_stmt_assignTuple
| case_expr_chain_Tuple
| case_expr_chain_or //, passthrough
| match_case_assign_typedObjectAssign
) matchAlso=match_also_attachment?)
| justAlso=match_also_attachment//needs an also...
) RPARA {popInArrayDef();}
blockOrBlock
)
;
match_case_stmt_nocase:
(NEWLINE*
( (( match_case_stmt_typedCase //TypedCaseExpression
| match_case_stmt_assign //CaseExpressionAssign
| match_case_stmt_assignTuple
| case_expr_chain_Tuple
| case_expr_chain_or //, passthrough
| match_case_assign_typedObjectAssign
) matchAlso=match_also_attachment?)
| justAlso=match_also_attachment//needs an also...
)
blockOrBlock
)
;
match_also_attachment: 'also' expr_stmt;
match_case_stmt_typedCase: (type ( 'or' type )* ( ';' (case_expr_chain_Tuple | case_expr_chain_or) )? ); //TypedCaseExpression
match_case_stmt_assign: ( (var='var'|isfinal='val')? NAME ( type ( 'or' type )* )? ( ';' expr_stmt)? );//CaseExpressionAssign
match_case_assign_typedObjectAssign: (var='var'|isfinal='val')? NAME bitwise_or;
match_case_stmt_assignTuple: ( LPARA {setNotInArrayDef();} matchTupleAsignOrNone (',' matchTupleAsignOrNone)+ RPARA {popInArrayDef();}) ( ';' expr_stmt)? ;//CaseExpressionAssign
matchTupleAsignOrNone: matchTupleAsign?;
matchTupleAsign: NAME type;
case_expr_chain_Tuple:
LPARA {setNotInArrayDef();} case_expr_chain_orOrNone (',' case_expr_chain_orOrNone )+ RPARA {popInArrayDef();}
;
case_expr_chain_orOrNone: case_expr_chain_or?;
case_expr_chain_or
:
ce = case_expr_chain_and ( 'or' case_expr_chain_and )*
;
case_expr_chain_and
:
ce = case_expr ( 'and' case_expr )*
;
case_expr
: bitwise_or ( case_operator)?
| case_operator_pre bitwise_or
;
case_operator : '==' | '<' | '<>' | '&==' | '&<>' | '>' | '>==' | '<==' ;
case_operator_pre
: case_operator | 'in' | 'not' 'in'
;
if_stmt
:
'if' LPARA {setNotInArrayDef();} ifexpr=expr_stmt RPARA {popInArrayDef();} ifblk=block
elifUnit*
( ( NEWLINE* 'else' elseblk=block) )?
;
elifUnit : NEWLINE* ('elif' | 'else' 'if') LPARA {setNotInArrayDef();} expr_stmt RPARA {popInArrayDef();} block ;
async_block
: 'async' LBRACE
(
line
| 'pre' preblk+=block
| 'post' postblk+=block
)*
RBRACE
;
while_stmt
: 'while' LPARA {setNotInArrayDef();} mainExpr=expr_stmt
(';' (idxName=NAME idxType=type? (('\\=' | '=') idxExpr=expr_stmt)?) )?// | nameAlone=NAME
RPARA {popInArrayDef();} mainBlock=block
( NEWLINE* 'else' elseblock=block )?
;
loop_stmt
: 'loop'
(LPARA {setNotInArrayDef();} (idxName=NAME idxType=type? (('\\=' | '=') idxExpr=expr_stmt)?) RPARA {popInArrayDef();} )? mainBlock=block
;
try_stmt
: 'try' (LPARA {setNotInArrayDef();} simple_stmt (';'? simple_stmt )* ';'? RPARA {popInArrayDef();})? mainblock=block
catchBlock*
( NEWLINE* 'finally' finblock=block )?
;
catchBlock: NEWLINE* 'catch' LPARA {setNotInArrayDef();} NAME (type ('or' type )* )? RPARA {popInArrayDef();} block ;
block_async
: block_ ( async='!'( LPARA {setNotInArrayDef();} executor=expr_stmt RPARA {popInArrayDef();} )? )?
;
with_stmt
: 'with'
LPARA {setNotInArrayDef();} expr_stmt RPARA {popInArrayDef();}
block
;
trans_block
: 'trans' b=block
;
init_block
: 'init' block
;
sync_block
: 'sync' b=block
;
onchange
: 'onchange' (LPARA {setNotInArrayDef();} onChangeEtcArgs (';' opts+=NAME (',' opts+=NAME )* (',')? )? RPARA {popInArrayDef();})? (block )//| single_line_block
;
every
: 'every' (LPARA {setNotInArrayDef();} onChangeEtcArgs (';' opts+=NAME (',' opts+=NAME )* (',')? )? RPARA {popInArrayDef();})? (block )//| single_line_block
;
///////////// annotations /////////////
annotations
: annotation (NEWLINE* ','? NEWLINE* annotation )*
;
annotation
:'@' (LBRACK loc+=('this'|NAME ) (',' loc+=('this'|NAME ) )* (',' )? RBRACK )?
dotted_name
( LPARA {setNotInArrayDef();} (namedAnnotationArgList | expr_stmt )? RPARA {popInArrayDef();} )?
;
namedAnnotationArgList
: n2expr (',' n2expr )* ','?
;
n2expr : NAME '=' expr_stmt;
///////////// common /////////////
genericQualiList: '<' nameAndUpperBound (',' nameAndUpperBound )* ','? '>';
nameAndUpperBound: NAME namedType? nullable='?'?;
dottedNameList
: dotted_name (',' dotted_name )* ','?
;
inoutGenericModifier : 'in' | 'out';
onChangeEtcArgs
: onChangeEtcArg (',' onChangeEtcArg)*
;
onChangeEtcArg
: valvar=(VAL|VAR)? NAME (type | (refCnt+=':')+)? '=' expr_stmt
| expr_stmt
;
dotted_name
: NAME ( DOT NAME )*
;
assignStyle : '\\=' | '=' | '+=' | '-=' | '*=' | '/=' | 'mod=' | '**=' | 'or=' | 'and=' | '<<=' | '>>=' | '>>>=' | 'band=' | 'bor='| 'bxor=';
block
: NEWLINE* block_
;
block_
: LBRACE line* RBRACE
;
pureFuncInvokeArgs
: LPARA {setNotInArrayDef();} (pureFuncInvokeArg (',' pureFuncInvokeArg)* ','? )? RPARA {popInArrayDef();}
;
pureFuncInvokeArg
: (NAME '=' )? ( expr_stmt | primitiveType | funcType | tupleType)
;
funcRefArgs
: LPARA {setNotInArrayDef();} ( funcRefArg ( ',' funcRefArg )* ','? )? RPARA {popInArrayDef();}
;
funcRefArg
: (NAME '=')? ( '?' lazy='lazy'? type | lazy='lazy'? primitiveType | lazy='lazy'? funcType nullable='?'? | lazy='lazy'? LPARA {setNotInArrayDef();} tupleType RPARA {popInArrayDef();} nullable='?'? | lazy='lazy'? namedType nullable='?' | expr_stmt | (refcnt+=':')+ )
;
genTypeList
:
'<' genTypeListElemnt ( ',' genTypeListElemnt )* ','? '>'
;
genTypeListElemnt
: '?' | ( inoutGenericModifier? type )
;
///////////// types /////////////
trefOrArrayRef:
hasAr=LBRACK (arLevels=intNode) RBRACK
| (hasArAlt+=LBRACK RBRACK)+
| refOrNullable
;
refOrNullable: ':' dotted_name?
| nullable='?'
| nullableErr='??'
;
type:
bareTypeParamTuple ('|' bareTypeParamTuple)* trefOrArrayRef*
;
bareTypeParamTuple:
pointerQualifier? primitiveType
| namedType
| funcType
| LPARA {setNotInArrayDef();} tupleType RPARA {popInArrayDef();}
;
typeNoNTTuple:
bareTypeParamTupleNoNT ('|' bareTypeParamTupleNoNT)* trefOrArrayRef*
;
bareTypeParamTupleNoNT:
pointerQualifier? primitiveType
| namedType
| funcType
| LPARA {setNotInArrayDef();} tupleTypeNoNT RPARA {popInArrayDef();}
;
tupleTypeNoNT : bareButTupleNoNT (',' bareButTupleNoNT )+ ;
bareButTupleNoNT: primitiveType | funcType;
ppp: inject=INJECT? pp=(PRIVATE | PROTECTED | PUBLIC | PACKAGE)
| inject=INJECT pp=(PRIVATE | PROTECTED | PUBLIC | PACKAGE)?;
pppNoInject: PRIVATE | PROTECTED | PUBLIC | PACKAGE;
pointerQualifier : (cnt+='*'|cnt2+='**')+;
//typeNoPrim : namedType | funcType | tupleType;
namedType
: isactor='actor' namedType_ExActor?
| namedType_ExActor
;
namedType_ExActor
: primaryName=dotted_name priamryGens=genTypeList? (DOT nameAndgens)* ( 'of' of=namedType)? //'of' namedType ?
;
nameAndgens : NAME genTypeList?;
tupleType : bareButTuple (',' bareButTuple )+ ;
bareButTuple: (primitiveType | namedType | funcType ) trefOrArrayRef*;
funcType :
funcType_
| LPARA {setNotInArrayDef();} funcType_ RPARA {popInArrayDef();}
;
funcType_
: genericQualiList?
LPARA {setNotInArrayDef();} ( (type (',' type)*)? ','? | constr='*' ) RPARA {popInArrayDef();} retTypeIncVoid
;
retTypeIncVoid
: type
| 'void'
;
primitiveType: ('boolean'|'bool') | 'size_t' | 'int' | 'long' | 'float' | 'double' | 'byte' | 'short' | 'char' | 'lambda';
///////////// expresssions /////////////
expr_stmt_tuple : expr_stmt ( (',' expr_stmt)+ ','? )?;
expr_stmt
: for_list_comprehension
;
for_list_comprehension
: mainExpr=expr_list ( flc_forStmt_+ ('if' condexpr=expr_stmt)?)?
;
flc_forStmt_:
forblockvariant (localVarName=NAME localVarType=type? | ( LPARA {setNotInArrayDef();} forVarTupleOrNothing (',' forVarTupleOrNothing)+ RPARA {popInArrayDef();})) 'in' expr=expr_list
;
expr_list
: /*block_async |*/ lambdadefOneLine | lambdadef | anonLambdadef | expr_stmt_+ ;//shortcut in the lambdadef as it ends with a newline so cannot be an expr stmt
lambdadefOneLine : annotations? 'def' genericQualiList? LPARA {setNotInArrayDef();} funcParams? RPARA {popInArrayDef();} retTypeIncVoid? single_line_block ;
lambdadef
: annotations? 'def' genericQualiList? LPARA {setNotInArrayDef();} funcParams? RPARA {popInArrayDef();} retTypeIncVoid? (block | (single_line_block NEWLINE+)) ;
anonLambdadef : ((NAME (',' NAME)*) | LPARA {setNotInArrayDef();} ( typeAnonParam (',' typeAnonParam)*) RPARA {popInArrayDef();}) retType=type? single_line_block;
typeAnonParam: NAME type?;
expr_stmt_: if_expr//for_list_comprehension
;
if_expr: op1=expr_stmt_or ('if' test=expr_stmt_or 'else' op2=expr_stmt_or )?;
expr_stmt_or: head=expr_stmt_and ( 'or' ors+=expr_stmt_and)*;
expr_stmt_and: head=bitwise_or ( 'and' ands+=bitwise_or)*;
bitwise_or: head=bitwise_xor ( 'bor' ands+=bitwise_xor)*;
bitwise_xor: head=bitwise_and ( 'bxor' ands+=bitwise_and)*;
bitwise_and: head=expr_stmt_BelowEQ ( 'band' ands+=expr_stmt_BelowEQ)*;
expr_stmt_BelowEQ : head=instanceof_expr ( eqAndExpression_)*;
eqAndExpression_: equalityOperator instanceof_expr;
instanceof_expr : castExpr (( 'is' | invert='isnot' | ('is' invert='not')) type ('or' type)* )?;
castExpr: lTGTExpr ('as' type)*;
lTGTExpr : shiftExpr ( relOpAndExpression_)*;
relOpAndExpression_: relationalOperator shiftExpr;
shiftExpr: additiveExpr ( shiftExprOp_)*;
shiftExprOp_: (lshift='<' '<' | rshift='>' '>' | rshiftu='>' '>' '>') additiveExpr;
additiveExpr: divisiveExpr ( additiveOp_)*;
additiveOp_ : ({notArrayDef()}? op='-' divisiveExpr ) | op='+' divisiveExpr;
divisiveExpr: powExpr ( divisiveExprOP_)*;
divisiveExprOP_:op=('*'|'/'|'mod') powExpr;
powExpr : lhs=notExpr ( '**' rhs+=notExpr)*;
notExpr: isnot='not'? containsExpr;
containsExpr : lhs=prefixExpr ( (invert='not'? 'in') rhs=prefixExpr)?;
prefixExpr : prefixOp=('++' | '--' | '-' | '+' | 'comp')? postfixExpr;
postfixExpr : sizeOfExpr postfixOp=('++' | '--')?;
sizeOfExpr: (sizeof='sizeof' ('<' variant=dotted_name '>')? )? asyncSpawnExpr;
asyncSpawnExpr: notNullAssertion (isAsync='!' (LPARA {setNotInArrayDef();} expr_stmt RPARA {popInArrayDef();})? )?;
notNullAssertion : elvisOperator ( nna='??')?;
elvisOperator : lhsExpr=vectorize ( '?:' elsExpr=if_expr)? ;
vectorize: primary=vectorize vectorize_element+
| passthrough=dotOperatorExpr
;
vectorize_element:
nullsafe='?'? ('^' (doubledot='^')? ) (constru=constructorInvoke | arrayRefElements+ | afterVecExpr=refName genTypeList? (pureFuncInvokeArgs | '&' funcRefArgs?)? )?
;
dotOperatorExpr: ((pntUnrefCnt+='*'|pntUnrefCnt2+='**' )+ | address='~')? copyExpr ( NEWLINE* dotOpArg NEWLINE* copyExpr)*;
copyExpr : expr_stmt_BelowDot (isCopy='@' (hasCopier=LPARA {setNotInArrayDef();} ( (copyExprItem (',' copyExprItem)* ','?)? (';' modifier+=NAME (',' modifier+=NAME)* ','? )? ) RPARA {popInArrayDef();} )? )?;
copyExprItem: ename=NAME '=' expr_stmt
| incName=NAME
| '<' exclName+=NAME (',' exclName+=NAME)* ','? '>'
| (copyName=NAME | superCopy='super' )'@' ( hasCopier=LPARA {setNotInArrayDef();} ( (copyExprItem (',' copyExprItem)* ','?)? (';' modifier+=NAME (',' modifier+=NAME)* ','? )? ) RPARA {popInArrayDef();} )?
;
expr_stmt_BelowDot //seperate rule for match operations - basically atoms
: (isthis='this' pureFuncInvokeArgs | 'super' pureFuncInvokeArgs) #superOrThisConstructorInvoke
| NAME genTypeList? pureFuncInvokeArgs #FuncInvokeExprName
| expr_stmt_BelowDot genTypeList? pureFuncInvokeArgs #FuncInvokeExpr
| NAME genTypeList #RefQualifiedGeneric //{ $ret = new RefQualifiedGenericNamedType(getLine(input), getColumn(input), $namedT.text, $gg.genTypes); }//ret namedType
| LPARA {setNotInArrayDef();} 'actor' dotted_name genTypeList? RPARA {popInArrayDef();} #RefQualifiedGenericActor //{ $ret = gg==null? new RefQualifiedGenericNamedType(getLine(input), getColumn(input), $namedTa.ret, true) : new RefQualifiedGenericNamedType(getLine(input), getColumn(input), $namedTa.ret, $gg.genTypes, true); }//ret namedType
| expr_stmt_BelowDot genTypeList? '&' funcRefArgs? #FuncRefExpr
| expr_stmt_BelowDot (refCnt+=':')* arrayRefElements+ (extraEmptyBracks+=LBRACK RBRACK)* #ArrayRefExpr
| main=expr_stmt_BelowDot (refCnt+=':')+ post=expr_stmt_BelowDot? #RefExpr
| notNullAssertion2 #AtomPassThrough
;
arrayRefElements: (nullSafe='?'? LBRACK arrayRefElement (',' arrayRefElement)* (trailcomma+=',')* RBRACK ) ;
notNullAssertion2 : atom (NEWLINE* nna='??')?;
atom
: classNode
| thisNode
| outNode
| refName
| superNode
| ofNode
| annotation
| booleanNode
| changedNode
| arrayDef
| mapDef
| constructorInvoke
| compound_stmt_atomic_base //set ret.setShouldBePresevedOnStack(true); after extraction
| localclassdef
| anonclassdef
| lambdadef
| intNode
| longNode
| shortNode
| floatNode
| doubleNode
| nullNode
| stringNode
| regexStringNode
| langExtNode
| nestedNode
;//move to add Labels above
nestedNode: {setNotInArrayDef();} LPARA expr_stmt_tuple RPARA {popInArrayDef();};
classNode: type '.' 'class';
superNode : 'super' (LBRACK superQuali=dotted_name RBRACK)? ( dotOpArg expr_stmt_BelowDot )+;
changedNode:'changed';
outNode:'out';
thisNode:'this' (LBRACK (thisQuali=dotted_name| thisQualiPrim=primitiveType) RBRACK)?;
nullNode: 'null';
intNode : INT;
longNode : LONGINT;
shortNode : SHORTINT;
floatNode : FLOAT;
doubleNode : DOUBLE;
booleanNode : 'true' | 'false';
stringNode : STRING_ITMcit | isQuote=STRING_ITMquot;
langExtNode: name=NAME body=LANG_EXT;
regexStringNode : REGEX_STRING_ITM;
ofNode : 'of';
arrayRefElement
: (lhs=expr_stmt DDD rhs=expr_stmt)
| (post=expr_stmt DDD )
| ( DDD pre=expr_stmt)
| ( simple=expr_stmt )
;
refName
: NAME
;
dotOpArg
: '.'|'\\.'|'..'|'?.'
;
arrayDef
: LBRACK RBRACK
| (isArray=ALBRACK | LBRACK) NEWLINE* ((expr_stmt ( ( NEWLINE* ',' NEWLINE* expr_stmt )+ ','? | NEWLINE*',') ) | ',') NEWLINE* RBRACK //list def or single element array
| arrayDefComplex
;
arrayDefComplex: ALBRACK expr_stmt_+ arrayDefComplexNPLus1Row* (NEWLINE* ';' NEWLINE*)? RBRACK
| {setInArrayDef();} LBRACK expr_stmt_+ arrayDefComplexNPLus1Row* (NEWLINE* ';' NEWLINE*)? RBRACK {popInArrayDef();}
;
arrayDefComplexNPLus1Row
: (';' NEWLINE* | NEWLINE+) expr_stmt_+
;
mapDef
: LBRACE NEWLINE* mapDefElement (NEWLINE* ',' NEWLINE* mapDefElement )* (NEWLINE* ',')? NEWLINE* RBRACE
;
mapDefElement: (isDefault='default' | key=expr_stmt) NEWLINE* '->' NEWLINE* value=expr_stmt;
///////////// expresssions:constructors/////////////
constructorInvoke
: namedActorConstructor
| ( 'new' ( namedConstructor | arrayConstructor | primNamedOrFuncType refOrNullable+ ) ) //
| arrayConstructorPrimNoNew
| newreftypeOnOwn
;
namedConstructor
: type ( ( isConsRef='&' funcRefArgs) | isConsRef='&' | pureFuncInvokeArgs)
;
namedActorConstructor
: isNewDefiend='new'? 'actor' namedType_ExActor ( (isConsRef='&' funcRefArgs) | isConsRef='&' | pureFuncInvokeArgs)
;
arrayConstructor
:
primNamedOrFuncType ('|' primNamedOrFuncType)*
(LBRACK arconExprsSubsection RBRACK)+ (nullEnd+=LBRACK RBRACK)*
(LPARA {setNotInArrayDef();} expr_stmt_tuple RPARA {popInArrayDef();} )?
//constructor args...
;
primNamedOrFuncType : (pointerQualifier? primitiveType | namedType | funcType | tupleType) refOrNullable*;
arrayConstructorPrimNoNew:
primitiveType (LBRACK arconExprsSubsection RBRACK)+ (nullEnd+=LBRACK RBRACK)*
(LPARA {setNotInArrayDef();} expr_stmt_tuple RPARA {popInArrayDef();} )?
;
arconExprsSubsection:
expr_stmt (',' expr_stmt )* (commaEnd+=',')*
;
newreftypeOnOwn
: typex=typeEclRef trefOrArrayRef+ pureFuncInvokeArgs
;
typeEclRef
: primitiveType | namedType | funcType | tupleType
;
///////////// expresssions:operators /////////////
equalityOperator
: '==' | '&==' | '<>' | '&<>'
;
relationalOperator
: '<' | '>' | '>==' | '<=='
;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//TOKEN Names//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
VAL: 'val';
VAR: 'var';
PRIVATE: 'private';
PUBLIC: 'public';
INJECT: 'inject';
PROTECTED: 'protected';
PACKAGE:'package';
/////////////////////////////////////////////////////////lexer/////////////////////////////////////////////////////////
DOT: '.';
DOTDOT: '..';
DDD: '...';
LONGINT
: INT ('l'|'L')
;
SHORTINT
: INT ('s'|'S')
;
fragment HexDigits
: HexDigit ((HexDigit | '_')* HexDigit)?
;
fragment HexDigit
: [0-9a-fA-F]
;
fragment
HexIntegerLiteral
: '0' [xX] HexDigits
;
fragment
DIGITS : ( '0' .. '9' )+ ;
INT : HexIntegerLiteral
| (
'0' ( 'b' | 'B' ) ( '0' .. '9' )+
| '0' DIGITS*
| '1'..'9' DIGITS* //TODO: starting with as many 0 as you like is ok
)
;
fragment DBL_FRAG
: '.' DIGITS (Exponent)?
| DIGITS ( '.' (DIGITS (Exponent)?)? | Exponent)
;
fragment
Exponent
: ('e' | 'E') ( '+' | '-' )? DIGITS
;
FLOAT : (DBL_FRAG | INT) ('f' |'F');
DOUBLE: DBL_FRAG ('d'|'D')? | INT ('d'|'D');
NAME: //{permitDollarPrefixRefName}? => '$'+ NAME_ITMS |
NAME_ITMS//a nice list of keywords...!!! <- do this before release!
//TODO: add other keywords here
| '\\abstract' {setText("abstract");}
| '\\actor' {setText("actor");}
| '\\also' {setText("also");}
| '\\annotation' {setText("annotation");}
| '\\assert' {setText("assert");}
| '\\async' {setText("async");}
| '\\await' {setText("await");}
| '\\bool' {setText("bool");}
| '\\boolean' {setText("boolean");}
| '\\break' {setText("break");}
| '\\byte' {setText("byte");}
| '\\case' {setText("case");}
| '\\catch' {setText("catch");}
| '\\changed' {setText("changed");}
| '\\char' {setText("char");}
| '\\class' {setText("class");}
| '\\closed' {setText("closed");}
| '\\constant' {setText("constant");}
| '\\continue' {setText("continue");}
| '\\def' {setText("def");}
| '\\default' {setText("default");}
| '\\del' {setText("del");}
| '\\double' {setText("double");}
| '\\elif' {setText("elif");}
| '\\else' {setText("else");}
| '\\enum' {setText("enum");}
| '\\every' {setText("every");}
| '\\extends' {setText("extends");}
| '\\false' {setText("false");}
| '\\finally' {setText("finally");}
| '\\float' {setText("float");}
| '\\for' {setText("for");}
| '\\from' {setText("from");}
| '\\global' {setText("global");}
| '\\gpudef' {setText("gpudef");}
| '\\gpukernel' {setText("gpukernel");}
| '\\if' {setText("if");}
| '\\import' {setText("import");}
| '\\in' {setText("contains");}
| '\\init' {setText("init");}
| '\\inject' {setText("inject");}
| '\\int' {setText("int");}
| '\\lambda' {setText("lambda");}
| '\\local' {setText("local");}
| '\\long' {setText("long");}
| '\\loop' {setText("loop");}
| '\\match' {setText("match");}
| '\\new' {setText("new");}
| '\\nodefault' {setText("nodefault");}
| '\\null' {setText("null");}
| '\\of' {setText("of");}
| '\\onchange' {setText("onchange");}
| '\\open' {setText("open");}
| '\\out' {setText("out");}
| '\\override' {setText("override");}
| '\\package' {setText("package");}
| '\\parfor' {setText("parfor");}
| '\\parforsync' {setText("parforsync");}
| '\\post' {setText("post");}
| '\\pre' {setText("pre");}
| '\\private' {setText("private");}
| '\\protected' {setText("protected");}
| '\\provide' {setText("provide");}
| '\\provider' {setText("provider");}
| '\\public' {setText("public");}
| '\\return' {setText("return");}
| '\\shared' {setText("shared");}
| '\\short' {setText("short");}
| '\\single' {setText("single");}
| '\\size_t' {setText("size_t");}
| '\\sizeof' {setText("sizeof");}
| '\\super' {setText("super");}
| '\\sync' {setText("sync");}
| '\\this' {setText("this");}
| '\\throw' {setText("throw");}
| '\\to' {setText("to");}
| '\\trait' {setText("trait");}
| '\\trans' {setText("trans");}
| '\\transient' {setText("transient");}
| '\\true' {setText("true");}
| '\\try' {setText("try");}
| '\\typedef' {setText("typedef");}
| '\\unchecked' {setText("unchecked");}
| '\\using' {setText("using");}
| '\\val' {setText("val");}
| '\\var' {setText("var");}
| '\\void' {setText("void");}
| '\\while' {setText("while");}
| '\\with' {setText("with");}
| '\\and' {setText("and");}
| '\\as' {setText("as");}
| '\\band' {setText("band");}
| '\\bor' {setText("bor");}
| '\\bxor' {setText("bxor");}
| '\\comp' {setText("comp");}
| '\\is' {setText("is");}
| '\\isnot' {setText("isnot");}
| '\\mod' {setText("mod");}
| '\\not' {setText("not");}
| '\\or' {setText("or");}
;
fragment
NAME_ITMS: {permitDollarPrefixRefName}? ('0' .. '9')* ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '$' | '\u0080'..'\ufffe') ( 'a' .. 'z' | '$' | 'A' .. 'Z' | '_' | '0' .. '9' | '\u0080'..'\ufffe' )*
| ('0' .. '9')* ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '\u0080'..'\ufffe') ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '\u0080'..'\ufffe' )*
;
fragment EscapeSequence
: '\\' [btnfr{"'\\]
| '\\' ([0-3]? [0-7])? [0-7]
| '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit
;
STRING_ITMcit
: '"' ( ~( '\\' | '"' ) | EscapeSequence )*'"'
;
STRING_ITMquot
: '\'' ( ~( '\\' | '\'' ) | EscapeSequence )*'\''
;
fragment EscapeSequenceLE
: '\\' [{|\\]
;
LANG_EXT
: '||' ( ~( '\\' | '|' ) | EscapeSequenceLE )* '||'
;
REGEX_STRING_ITM
: 'r"' ( ~( '\\' | '"' ) )*'"'
| 'r\'' ( ~( '\\' | '\'' ) )*'\''
;
MULTILINE_COMMENT
: '/*'
( (MULTILINE_COMMENT | .) )*?
'*/' -> skip
;
LINE_COMMENT
: '//' ~('\n'|'\r')* -> skip
;
IGNORE_NEWLINE : '\r'? '\n' {skipNewLine}? -> skip ;
NEWLINE : '\r'? '\n';
LPARA: '(' { prevskip.add(skipNewLine); skipNewLine=true; } ;
RPARA: ')' { skipNewLine=prevskip.isEmpty()?false:prevskip.pop(); };
LBRACK: '['{ prevskip.add(skipNewLine); skipNewLine=false; } ;
ALBRACK: 'a['{ prevskip.add(skipNewLine); skipNewLine=false; } ;
RBRACK: ']'{ skipNewLine=prevskip.isEmpty()?false:prevskip.pop(); };
LBRACE:'{'{ prevskip.add(skipNewLine); skipNewLine=false; } ;
RBRACE:'}'{ skipNewLine=prevskip.isEmpty()?false:prevskip.pop(); };
WS : (' ' | '\t' | '\f' )+ -> skip ;
WS2 :
'\\' (' ' | '\t' | '\f' | LINE_COMMENT|MULTILINE_COMMENT )* ('\r'? '\n')+ -> skip
;//ignore newline if prefixed with \ just like in python
|
capacityupgrades.asm | compiling/z3randomizer | 26 | 247144 | ;================================================================================
; Capacity Logic
;================================================================================
!BOMB_UPGRADES = "$7EF370"
!BOMB_CURRENT = "$7EF343"
;--------------------------------------------------------------------------------
IncrementBombs:
LDA !BOMB_UPGRADES ; get bomb upgrades
!ADD.l StartingMaxBombs : BEQ + ; Skip if we can't have bombs
DEC
CMP !BOMB_CURRENT
!BLT +
LDA !BOMB_CURRENT
CMP.b #99 : !BGE +
INC : STA !BOMB_CURRENT
+
RTL
;--------------------------------------------------------------------------------
!ARROW_UPGRADES = "$7EF371"
!ARROW_CURRENT = "$7EF377"
;--------------------------------------------------------------------------------
IncrementArrows:
LDA !ARROW_UPGRADES ; get arrow upgrades
!ADD.l StartingMaxArrows : DEC
CMP !ARROW_CURRENT
!BLT +
LDA !ARROW_CURRENT
CMP.b #99 : !BGE +
INC : STA !ARROW_CURRENT
+
RTL
;--------------------------------------------------------------------------------
CompareBombsToMax:
LDA !BOMB_UPGRADES ; get bomb upgrades
!ADD.l StartingMaxBombs
CMP !BOMB_CURRENT
RTL
;-------------------------------------------------------------------------------- |
alloy4fun_models/trashltl/models/15/mi5NXwmQNCiPa4v5n.als | Kaixi26/org.alloytools.alloy | 0 | 1251 | open main
pred idmi5NXwmQNCiPa4v5n_prop16 {
always Protected in Protected'
}
pred __repair { idmi5NXwmQNCiPa4v5n_prop16 }
check __repair { idmi5NXwmQNCiPa4v5n_prop16 <=> prop16o } |
src/parser/PSS.g4 | PSSTools/pssparser | 1 | 7894 | <filename>src/parser/PSS.g4
/****************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
****************************************************************************/
grammar PSS;
compilation_unit :
portable_stimulus_description* EOF
;
portable_stimulus_description :
/* package_body_item
|*/ package_declaration
| component_declaration
;
package_declaration:
'package' name=package_identifier '{'
package_body_item*
'}'
;
package_body_item:
abstract_action_declaration
| struct_declaration
| enum_declaration
| covergroup_declaration
| function_decl
| import_class_decl
| pss_function_defn
| function_qualifiers
| target_template_function
| export_action
| typedef_declaration
| import_stmt
| extend_stmt
| const_field_declaration
| static_const_field_declaration
| compile_assert_stmt
| package_body_compile_if
// >>= PSS 1.1
| component_declaration
// <<= PSS 1.1
| ';'
;
import_stmt:
'import' package_import_pattern ';'
;
package_import_pattern:
type_identifier ('::' wildcard='*')?
;
extend_stmt:
(
('extend' ext_type='action' type_identifier '{'
action_body_item*
'}'
) |
('extend' ext_type='component' type_identifier '{'
component_body_item*
'}'
) |
('extend' struct_kind type_identifier '{'
struct_body_item*
'}'
) |
('extend' ext_type='enum' type_identifier '{'
(enum_item (',' enum_item)*)?
'}'
)
)
;
const_field_declaration :
'const' const_data_declaration
;
const_data_declaration:
scalar_data_type const_data_instantiation (',' const_data_instantiation)* ';'
;
const_data_instantiation:
identifier '=' init=constant_expression
;
static_const_field_declaration :
'static' 'const' const_data_declaration
;
action_declaration:
'action' action_identifier template_param_decl_list? (action_super_spec)?
'{'
action_body_item*
'}'
;
abstract_action_declaration :
'abstract' 'action' action_identifier template_param_decl_list? (action_super_spec)?
'{'
action_body_item*
'}'
;
action_super_spec:
':' type_identifier
;
action_body_item:
activity_declaration
| overrides_declaration
| constraint_declaration
| action_field_declaration
| symbol_declaration
| covergroup_declaration
| exec_block_stmt
| static_const_field_declaration
| action_scheduling_constraint
//TODO | attr_group
| compile_assert_stmt
| covergroup_instantiation
| action_body_compile_if
| inline_covergroup
// >>= PSS 1.1
| ';'
// <<= PSS 1.1
;
activity_declaration: 'activity' '{' activity_stmt* '}'
;
action_field_declaration:
// >>= PSS 1.1
object_ref_declaration
// <<= PSS 1.1
| attr_field
| activity_data_field
| attr_group
| action_handle_declaration
| activity_data_field
;
// >>= PSS 1.1
object_ref_declaration:
flow_ref_declaration
| resource_ref_declaration
;
// <<= PSS 1.1
// >>= PSS 1.1
flow_ref_declaration:
(is_input='input' | is_output='output') flow_object_type object_ref_field (',' object_ref_field)* ';'
;
resource_ref_declaration:
(lock='lock' | share='share') resource_object_type object_ref_field (',' object_ref_field)* ';'
;
object_ref_field:
identifier array_dim?
;
// <<= PSS 1.1
flow_object_type:
type_identifier
;
resource_object_type:
type_identifier
;
attr_field:
access_modifier? rand='rand'? declaration=data_declaration
;
access_modifier:
'public' | 'protected' | 'private'
;
attr_group:
access_modifier ':'
;
// NOTE: refactored grammar
action_handle_declaration:
action_type_identifier action_instantiation (',' action_instantiation)* ';'
;
action_instantiation:
action_identifier array_dim?
;
//action_instantiation:
// ids+=action_identifier (array_dim)? (',' ids+=action_identifier (array_dim)? )*
// ;
activity_data_field:
'action' data_declaration
;
// TODO: BNF has hierarchical_id
action_scheduling_constraint:
'constraint' (is_parallel='parallel' | is_sequence='sequence') '{'
variable_ref_path ',' variable_ref_path (',' variable_ref_path)* '}' ';'
;
// Exec
exec_block_stmt:
target_file_exec_block
| exec_block
| target_code_exec_block
;
exec_block:
'exec' exec_kind_identifier '{' exec_stmt* '}'
;
exec_kind_identifier:
'pre_solve'
| 'post_solve'
| 'body'
| 'header'
| 'declaration'
| 'run_start'
| 'run_end'
| 'init'
// >>= PSS 1.1
| 'init_up'
| 'init_down'
// <<= PSS 1.1
;
exec_stmt:
procedural_stmt
| exec_super_stmt
;
exec_super_stmt:
'super' ';'
;
assign_op:
'=' | '+=' | '-=' | '<<=' | '>>=' | '|=' | '&='
;
target_code_exec_block:
'exec' exec_kind_identifier language_identifier '=' string ';'
;
target_file_exec_block:
'exec' 'file' filename_string '=' string ';'
;
// == PSS-1.1
struct_declaration: struct_kind identifier template_param_decl_list? (struct_super_spec)? '{'
struct_body_item*
'}'
;
struct_kind:
img='struct'
| object_kind
;
object_kind:
img='buffer'
| img='stream'
| img='state'
| img='resource'
;
struct_super_spec : ':' type_identifier
;
struct_body_item:
constraint_declaration
| attr_field
| typedef_declaration
| covergroup_declaration
| exec_block_stmt
| static_const_field_declaration
| attr_group
| compile_assert_stmt
| covergroup_instantiation
| struct_body_compile_if
// >>= PSS 1.1
| ';'
// <<= PSS 1.1
;
function_decl:
'function' method_prototype ';'
;
method_prototype:
method_return_type method_identifier method_parameter_list_prototype
;
method_return_type:
'void'
| data_type
;
method_parameter_list_prototype:
'('
(
method_parameter (',' method_parameter)*
)?
')'
;
method_parameter:
method_parameter_dir? data_type identifier
;
method_parameter_dir:
'input'
|'output'
|'inout'
;
function_qualifiers:
('import' import_function_qualifiers? 'function' type_identifier ';')
| ('import' import_function_qualifiers? 'function' method_prototype ';')
;
import_function_qualifiers:
method_qualifiers (language_identifier)?
| language_identifier
;
method_qualifiers:
'target'
| 'solve'
;
target_template_function:
'target' language_identifier 'function' method_prototype '=' string ';'
;
// TODO: method_parameter_list appears unused
method_parameter_list:
'(' (expression (',' expression)*)? ')'
;
// >>= PSS 1.1
pss_function_defn:
method_qualifiers? 'function' method_prototype '{' procedural_stmt* '}'
;
procedural_stmt:
procedural_block_stmt
| procedural_expr_stmt
| procedural_return_stmt
| procedural_if_else_stmt
| procedural_match_stmt
| procedural_repeat_stmt
| procedural_foreach_stmt
| procedural_break_stmt
| procedural_continue_stmt
| procedural_var_decl_stmt // TODO: positioning this first causes assign to be incorrectly recognized as data_declaration
| ';' // TODO: need to incorporate
;
procedural_block_stmt:
('sequence')? '{' procedural_stmt* '}'
;
procedural_var_decl_stmt:
data_declaration
;
procedural_expr_stmt:
(expression ';')
| (variable_ref_path assign_op expression ';')
;
procedural_return_stmt:
'return' expression? ';'
;
procedural_if_else_stmt:
'if' '(' expression ')' procedural_stmt ( 'else' procedural_stmt )?
;
procedural_match_stmt:
'match' '(' expression ')' '{' procedural_match_choice procedural_match_choice* '}'
;
procedural_match_choice:
('[' open_range_list ']' ':' procedural_stmt)
| ('default' ':' procedural_stmt)
;
procedural_repeat_stmt:
(is_while='while' '(' expression ')' procedural_stmt)
| (is_repeat='repeat' '(' (identifier ':')? expression ')' procedural_stmt)
| (is_repeat_while='repeat' procedural_stmt 'while' '(' expression ')' ';')
;
procedural_foreach_stmt:
'foreach' '(' (iterator_identifier ':')? expression ('[' index_identifier ']')? ')' procedural_stmt
;
procedural_break_stmt:
'break' ';'
;
procedural_continue_stmt:
'continue' ';'
;
// <<= PSS 1.1
// == PSS-1.1
component_declaration:
'component' component_identifier template_param_decl_list?
(component_super_spec)? '{'
component_body_item*
'}'
;
component_super_spec :
':' type_identifier
;
component_body_item:
overrides_declaration
| component_field_declaration
| action_declaration
| object_bind_stmt
| exec_block
// >>= PSS 1.1 -- replace package_body_item
| abstract_action_declaration
| struct_declaration
| enum_declaration
| covergroup_declaration
| function_decl
| import_class_decl
| pss_function_defn
| function_qualifiers
| target_template_function
| export_action
| typedef_declaration
| import_stmt
| extend_stmt
| const_field_declaration
| static_const_field_declaration
| compile_assert_stmt
// <<= PSS 1.1
| attr_group
| component_body_compile_if
// >>= PSS 1.1
| ';'
// <<= PSS 1.1
;
component_field_declaration:
component_data_declaration |
component_pool_declaration
;
component_data_declaration:
(is_static='static' is_const='const')? data_declaration
;
component_pool_declaration:
'pool' ('[' expression ']')? type_identifier identifier (',' identifier)* ';'
;
object_bind_stmt:
'bind' hierarchical_id object_bind_item_or_list ';'
;
object_bind_item_or_list:
component_path
| ('{' component_path (',' component_path)* '}')
;
// TODO: I believe component_identifier should allow array
component_path:
(component_identifier ('.' component_path_elem)*)
| is_wildcard='*'
;
// TODO: Arrayed flow-object references require arrayed access
component_path_elem:
component_action_identifier ('[' constant_expression ']')?
| is_wildcard='*'
;
activity_stmt:
(identifier ':')? labeled_activity_stmt
| activity_data_field
| activity_bind_stmt
| action_handle_declaration
| activity_constraint_stmt
| action_scheduling_constraint
// >>= PSS 1.1
| activity_replicate_stmt
// <<= PSS 1.1
;
labeled_activity_stmt:
activity_if_else_stmt
| activity_repeat_stmt
| activity_foreach_stmt
| activity_action_traversal_stmt
| activity_sequence_block_stmt
| activity_select_stmt
| activity_match_stmt
| activity_parallel_stmt
| activity_schedule_stmt
| activity_super_stmt
| function_symbol_call
// >>= PSS 1.1
// TODO: need to change align-semicolon spec
| ';'
// <<= PSS 1.1
;
activity_if_else_stmt:
'if' '(' expression ')' activity_stmt
('else' activity_stmt)?
;
activity_repeat_stmt:
(
(is_while='while' '(' expression ')' activity_stmt) |
(is_repeat='repeat' '(' (loop_var=identifier ':')? expression ')' activity_stmt) |
(is_do_while='repeat' activity_stmt is_do_while='while' '(' expression ')' ';')
)
;
activity_replicate_stmt:
'replicate' '(' (index_identifier ':')? expression ')' ( identifier '[' ']' ':')?
labeled_activity_stmt
;
activity_sequence_block_stmt:
('sequence')? '{' activity_stmt* '}'
;
activity_constraint_stmt:
'constraint' constraint_set
;
activity_foreach_stmt:
'foreach' '(' (it_id=iterator_identifier)? expression ('[' idx_id=index_identifier ']')? ')'
activity_stmt
;
activity_action_traversal_stmt:
(identifier ('[' expression ']')? ';')
| (identifier ('[' expression ']')? 'with' constraint_set)
| (is_do='do' type_identifier ';')
| (is_do='do' type_identifier 'with' constraint_set)
;
activity_select_stmt:
'select' '{'
select_branch
select_branch
select_branch*
'}'
;
select_branch:
(
('(' guard=expression ')' ('[' weight=expression ']')? ':')
| ('[' weight=expression ']' ':')
)? activity_stmt
;
activity_match_stmt:
'match' '(' expression ')' '{'
match_choice
match_choice
match_choice*
'}'
;
match_choice:
('[' open_range_list ']' ':' activity_stmt)
| (is_default='default' ':' activity_stmt)
;
activity_parallel_stmt:
'parallel' activity_join_spec? '{'
activity_stmt*
'}'
;
activity_schedule_stmt:
'schedule' activity_join_spec? '{'
activity_stmt*
'}'
;
// >>= PSS 1.1
activity_join_spec:
activity_join_branch_spec
| activity_join_select_spec
| activity_join_none_spec
| activity_join_first_spec
;
activity_join_branch_spec:
'join_branch' '(' label_identifier (',' label_identifier)* ')'
;
activity_join_select_spec:
'join_select' '(' expression ')'
;
activity_join_none_spec:
'join_none'
;
activity_join_first_spec:
'join_first' '(' expression ')'
;
// <<= PSS 1.1
activity_bind_stmt:
'bind' hierarchical_id activity_bind_item_or_list ';'
;
activity_bind_item_or_list:
hierarchical_id
| ('{' hierarchical_id (',' hierarchical_id)* '}')
;
symbol_declaration:
'symbol' identifier ('(' symbol_paramlist ')')? '{' activity_stmt* '}'
;
symbol_paramlist:
(symbol_param (',' symbol_param)*)?
;
symbol_param:
data_type identifier
;
activity_super_stmt:
'super' ';'
;
overrides_declaration:
'override' '{' override_stmt* '}'
;
override_stmt:
type_override
| instance_override
// >>= PSS 1.1
| ';'
// <<= PSS 1.1
;
type_override:
'type' target=type_identifier 'with' override=type_identifier ';'
;
instance_override:
'instance' target=hierarchical_id 'with' override=type_identifier ';'
;
data_declaration:
data_type data_instantiation (',' data_instantiation)* ';'
;
data_instantiation:
identifier (array_dim)? ('=' constant_expression)?
;
/*
covergroup_portmap_list:
(
// Name-mapped port binding
(covergroup_portmap (',' covergroup_portmap)*)
// Positional port binding
| (hierarchical_id (',' hierarchical_id)*)
)?
;
covergroup_portmap:
'.' identifier '(' hierarchical_id ')'
;
*/
array_dim:
'[' constant_expression ']'
;
data_type:
scalar_data_type
// >>= PSS 1.1
| container_type
// <<= PSS 1.1
| user_defined_datatype
;
// >>= PSS 1.1
container_type:
| ('array' '<' container_elem_type ',' array_size_expression '>')
| ('list' '<' container_elem_type '>')
| ('map' '<' container_key_type ',' container_elem_type '>')
| ('set' '<' container_key_type '>')
;
array_size_expression:
constant_expression
;
container_elem_type:
container_type
| scalar_data_type
| type_identifier
;
container_key_type:
scalar_data_type
| enum_identifier
;
// <<= PSS 1.1
scalar_data_type:
chandle_type |
integer_type |
string_type |
bool_type
;
chandle_type:
'chandle'
;
integer_type:
integer_atom_type ('[' lhs=expression (':' rhs=expression)? ']')?
(is_in='in' '[' domain=domain_open_range_list ']')?
;
integer_atom_type:
'int'
| 'bit'
;
domain_open_range_list:
domain_open_range_value (',' domain_open_range_value)*
;
domain_open_range_value:
lhs=expression (limit_high='..' (rhs=expression)?)?
| lhs=expression limit_high='..'
| (limit_low='..' rhs=expression)
| lhs=expression
;
string_type: 'string' ( 'in' '[' DOUBLE_QUOTED_STRING (',' DOUBLE_QUOTED_STRING)* ']')?
;
bool_type:
'bool'
;
user_defined_datatype:
type_identifier
;
enum_declaration:
'enum' enum_identifier '{'
(enum_item (',' enum_item)*)?
'}'
;
enum_item:
identifier ('=' constant_expression)?
;
enum_type:
enum_type_identifier ('in' '[' open_range_list ']')?
;
enum_type_identifier:
type_identifier
;
typedef_declaration:
'typedef' data_type type_identifier ';'
;
// >>= PSS-1.1
template_param_decl_list:
'<' template_param_decl ( ',' template_param_decl )* '>'
;
template_param_decl:
type_param_decl
| value_param_decl
;
type_param_decl:
generic_type_param_decl
| category_type_param_decl
;
generic_type_param_decl:
'type' identifier ( '=' type_identifier )?
;
category_type_param_decl:
type_category identifier ( type_restriction )? ( '=' type_identifier )?
;
type_restriction:
':' type_identifier
;
type_category:
'action'
| 'component'
| struct_kind
;
value_param_decl:
data_type identifier ( '=' constant_expression )?
;
template_param_value_list:
'<' ( template_param_value ( ',' template_param_value )* )? '>'
;
template_param_value:
constant_expression
| type_identifier
;
// <<= PSS-1.1
constraint_declaration:
(
// Note: 1.0 doesn't allow a semicolon after the block constraint forms,
// despite examples showing this
((is_dynamic='dynamic')? 'constraint' identifier '{' constraint_body_item* '}' )
| ('constraint' constraint_set )
)
;
//constraint_declaration ::=
// [ dynamic ] constraint identifier { { constraint_body_item } }
// | constraint constraint_set
constraint_body_item:
expression_constraint_item
| implication_constraint_item
| foreach_constraint_item
| if_constraint_item
| unique_constraint_item
// >>= PSS 1.1
| default_constraint_item
| forall_constraint_item
| ';'
// <<= PSS 1.1
;
// >>= PSS 1.1
default_constraint_item:
default_constraint
| default_disable_constraint
;
default_constraint:
'default' hierarchical_id '==' constant_expression ';'
;
default_disable_constraint:
'default' 'disable' hierarchical_id ';'
;
forall_constraint_item:
'forall' '(' identifier ':' type_identifier ('in' variable_ref_path)? ')' constraint_set
;
// <<= PSS 1.1
expression_constraint_item:
expression ';'
;
implication_constraint_item:
expression '->' constraint_set
;
constraint_set:
constraint_body_item |
constraint_block
;
constraint_block:
'{' constraint_body_item* '}'
;
foreach_constraint_item:
'foreach' '(' (it_id=iterator_identifier ':')? expression ('[' idx_id=index_identifier ']')? ')' constraint_set
;
if_constraint_item:
'if' '(' expression ')' constraint_set ('else' constraint_set )?
;
unique_constraint_item:
'unique' '{' hierarchical_id_list '}' ';'
;
single_stmt_constraint:
expression_constraint_item |
unique_constraint_item
;
covergroup_declaration:
'covergroup' name=covergroup_identifier ('(' covergroup_port (',' covergroup_port)* ')')? '{'
covergroup_body_item*
'}'
;
covergroup_port:
data_type identifier
;
covergroup_body_item:
covergroup_option
| covergroup_coverpoint
| covergroup_cross
// >>= PSS 1.1
| ';'
// <<= PSS 1.1
;
covergroup_option:
'option' '.' identifier '=' constant_expression ';'
;
covergroup_instantiation:
covergroup_type_instantiation
| inline_covergroup
;
inline_covergroup:
'covergroup' '{'
covergroup_body_item*
'}' identifier ';'
;
covergroup_type_instantiation:
covergroup_type_identifier covergroup_identifier
'(' covergroup_portmap_list ')' ('with' '{' (covergroup_option)? '}')? ';'
;
covergroup_portmap_list:
(
(covergroup_portmap (',' covergroup_portmap)?)
| hierarchical_id_list
)
;
covergroup_portmap:
'.' identifier '(' hierarchical_id ')'
;
covergroup_coverpoint:
(data_type? coverpoint_identifier ':')? 'coverpoint' target=expression ('iff' '(' iff=expression ')')?
bins_or_empty
;
bins_or_empty:
('{' covergroup_coverpoint_body_item* '}' )
| ';'
;
covergroup_coverpoint_body_item:
covergroup_option
| covergroup_coverpoint_binspec
;
covergroup_coverpoint_binspec: (
(bins_keyword identifier (is_array='['constant_expression? ']')? '=' coverpoint_bins)
)
;
coverpoint_bins:
(
('[' covergroup_range_list ']' ('with' '(' covergroup_expression ')')? ';')
| (coverpoint_identifier 'with' '(' covergroup_expression ')' ';')
| is_default='default' ';'
)
;
covergroup_range_list:
covergroup_value_range (',' covergroup_value_range)*
;
covergroup_value_range:
expression
| (expression '..' expression?)
| (expression? '..' expression)
;
bins_keyword:
'bins'
| 'illegal_bins'
| 'ignore_bins'
;
covergroup_cross:
identifier ':' 'cross' coverpoint_identifier (',' coverpoint_identifier)*
('iff' '(' iff=expression ')')? cross_item_or_null
;
cross_item_or_null:
('{' covergroup_cross_body_item* '}' )
| ';'
;
covergroup_cross_body_item:
covergroup_option
| covergroup_cross_binspec
;
covergroup_cross_binspec:
bins_type=bins_keyword name=identifier
'=' covercross_identifier 'with' '(' expr=covergroup_expression ')' ';'
;
// TODO: no definition in the BNF
covergroup_expression:
expression
;
package_body_compile_if:
'compile' 'if' '(' cond=constant_expression ')' true_body=package_body_compile_if_item
('else' false_body=package_body_compile_if_item)?
;
package_body_compile_if_item:
package_body_item
| ('{' package_body_item* '}')
;
action_body_compile_if:
'compile' 'if' '(' cond=constant_expression ')' true_body=action_body_compile_if_item
('else' false_body=action_body_compile_if_item)?
;
action_body_compile_if_item:
action_body_item
| ('{' action_body_item* '}')
;
component_body_compile_if:
'compile' 'if' '(' cond=constant_expression ')' true_body=component_body_compile_if_item
('else' false_body=component_body_compile_if_item)?
;
component_body_compile_if_item:
component_body_item
| ('{' component_body_item* '}')
;
struct_body_compile_if:
'compile' 'if' '(' cond=constant_expression ')' true_body=struct_body_compile_if_item
('else' false_body=struct_body_compile_if_item)?
;
struct_body_compile_if_item:
struct_body_item
| ('{' struct_body_item* '}')
;
// == PSS 1.1 -- replace static_ref with static_ref_path
compile_has_expr:
'compile' 'has' '(' static_ref_path ')'
;
compile_assert_stmt :
'compile' 'assert' '(' cond=constant_expression (',' msg=string)? ')' ';'
;
constant_expression: expression;
expression:
unary_op lhs=expression |
lhs=expression exp_op rhs=expression |
lhs=expression mul_div_mod_op rhs=expression |
lhs=expression add_sub_op rhs=expression |
lhs=expression shift_op rhs=expression |
lhs=expression inside_expr_term |
lhs=expression logical_inequality_op rhs=expression |
lhs=expression eq_neq_op rhs=expression |
lhs=expression binary_and_op rhs=expression |
lhs=expression binary_xor_op rhs=expression |
lhs=expression binary_or_op rhs=expression |
lhs=expression logical_and_op rhs=expression |
lhs=expression logical_or_op rhs=expression |
lhs=expression conditional_expr |
primary
;
conditional_expr :
'?' true_expr=expression ':' false_expr=expression
;
logical_or_op : '||';
logical_and_op : '&&';
binary_or_op : '|';
binary_xor_op : '^';
binary_and_op : '&';
inside_expr_term :
'in' '[' open_range_list ']'
;
open_range_list:
open_range_value (',' open_range_value)*
;
open_range_value:
lhs=expression ('..' rhs=expression)?
;
logical_inequality_op:
'<'|'<='|'>'|'>='
;
unary_op: '+' | '-' | '!' | '~' | '&' | '|' | '^';
exp_op: '**';
primary:
number
| bool_literal
| paren_expr
| string
| variable_ref_path
| method_function_symbol_call
| static_ref_path
| is_super='super' '.' variable_ref_path
| compile_has_expr
| cast_expression // TODO: File Jama issue
;
paren_expr:
'(' expression ')'
;
// TODO: casting_type is undefined
cast_expression:
'(' casting_type ')' expression
;
casting_type:
data_type
;
variable_ref_path:
hierarchical_id ('[' expression (':' expression)? ']')?
;
method_function_symbol_call:
method_call
| function_symbol_call
;
// TODO: trailing ';' is incorrect
method_call:
hierarchical_id method_parameter_list /*';'*/
;
// TODO: trailing ';' is incorrect
function_symbol_call:
function_symbol_id method_parameter_list /*';'*/
;
function_symbol_id:
function_id
| symbol_identifier
;
function_id:
identifier ('::' identifier)*
;
static_ref_path:
is_global='::'? static_ref_path_elem ('::' static_ref_path_elem)*
;
static_ref_path_elem:
identifier template_param_value_list?
;
mul_div_mod_op: '*' | '/' | '%';
add_sub_op: '+' | '-';
// Note: Implementation difference vs spec
// shift_op: '<<' | '>>';
shift_op: '<<' | '>' '>';
eq_neq_op: '==' | '!=';
constant:
number
| identifier
;
identifier:
ID
| ESCAPED_ID
;
hierarchical_id_list:
hierarchical_id (',' hierarchical_id)*
;
hierarchical_id:
hierarchical_id_elem ('.' hierarchical_id_elem)*
;
hierarchical_id_elem:
identifier ('[' expression ']')?
;
action_type_identifier: type_identifier;
// == PSS 1.1
type_identifier:
(is_global='::')? type_identifier_elem ('::' type_identifier_elem)*
;
// >>= PSS 1.1
type_identifier_elem:
identifier template_param_value_list?
;
// <<= PSS 1.1
package_identifier:
identifier
;
// TODO: unused?
covercross_identifier : identifier;
covergroup_identifier : identifier;
coverpoint_target_identifier : hierarchical_id;
action_identifier: identifier;
struct_identifier: identifier;
component_identifier: identifier;
component_action_identifier: identifier;
coverpoint_identifier : identifier;
enum_identifier: identifier;
import_class_identifier: identifier;
// >>= PSS 1.1
label_identifier: identifier;
// <<= PSS 1.1
language_identifier: identifier;
method_identifier: identifier;
symbol_identifier: identifier;
variable_identifier: identifier;
iterator_identifier: identifier;
index_identifier: identifier;
buffer_type_identifier: type_identifier;
covergroup_type_identifier: type_identifier;
resource_type_identifier: type_identifier;
state_type_identifier: type_identifier;
stream_type_identifier: type_identifier;
// Move to LexicalRules
//filename_string: DOUBLE_QUOTED_STRING;
bool_literal:
'true'|'false'
;
number:
based_hex_number
| based_dec_number
| based_bin_number
| based_oct_number
| dec_number
| oct_number
| hex_number
;
based_hex_number: DEC_LITERAL? BASED_HEX_LITERAL;
BASED_HEX_LITERAL: '\'' ('s'|'S')? ('h'|'H') ('0'..'9'|'a'..'f'|'A'..'F') ('0'..'9'|'a'..'f'|'A'..'F'|'_')*;
based_dec_number: DEC_LITERAL? BASED_DEC_LITERAL;
BASED_DEC_LITERAL: '\'' ('s'|'S')? ('d'|'D') ('0'..'9') ('0'..'9'|'_')*;
dec_number: DEC_LITERAL;
DEC_LITERAL: ('1'..'9') ('0'..'9'|'_')*;
based_bin_number: DEC_LITERAL? BASED_BIN_LITERAL;
BASED_BIN_LITERAL: '\'' ('s'|'S')? ('b'|'B') (('0'..'1') ('0'..'1'|'_')*);
based_oct_number: DEC_LITERAL? BASED_OCT_LITERAL;
BASED_OCT_LITERAL: '\'' ('s'|'S')? ('o'|'O') (('0'..'7') ('0'..'7'|'_')*);
oct_number: OCT_LITERAL;
OCT_LITERAL: '0' ('0'..'7')*;
hex_number: HEX_LITERAL;
HEX_LITERAL: '0x' ('0'..'9'|'a'..'f'|'A'..'F') ('0'..'9'|'a'..'f'|'A'..'F'|'_')*;
WS : [ \t\n\r]+ -> channel (HIDDEN) ;
//WS : [ \t\n\r]+ -> skip;
/**
* BNF: SL_COMMENT ::= <kw>//</kw>\n
*/
SL_COMMENT : '//' .*? '\r'? ('\n'|EOF) -> channel (HIDDEN) ;
//SL_COMMENT : '//' .*? '\r'? ('\n'|EOF) -> skip;
/*
* BNF: ML_COMMENT ::= <kw>/*</kw><kw>*\057</kw>
*/
ML_COMMENT : '/*' .*? '*/' -> channel (HIDDEN) ;
//ML_COMMENT : '/*' .*? '*/' -> skip;
string: DOUBLE_QUOTED_STRING | TRIPLE_DOUBLE_QUOTED_STRING;
filename_string: DOUBLE_QUOTED_STRING;
DOUBLE_QUOTED_STRING : '"' (~ [\n\r])* '"' ;
// TODO: unescaped_character, escaped_character
/**
* BNF: TRIPLE_DOUBLE_QUOTED_STRING ::= <kw>"""</kw><kw>"""</kw>
*/
TRIPLE_DOUBLE_QUOTED_STRING:
'"""' TripleQuotedStringPart*? '"""'
;
fragment TripleQuotedStringPart : EscapedTripleQuote | SourceCharacter;
fragment EscapedTripleQuote: '\\"""';
fragment SourceCharacter :[\u0009\u000A\u000D\u0020-\uFFFF];
// TODO: move to LexicalRules
ID : [a-zA-Z_] [a-zA-Z0-9_]* ;
ESCAPED_ID : '\\' ('\u0021'..'\u007E')+ ~ [ \r\t\n]* ;
export_action:
'export' (method_qualifiers)? action_type_identifier method_parameter_list_prototype ';'
;
import_class_decl:
'import' 'class' import_class_identifier (import_class_extends)? '{'
import_class_method_decl*
'}'
;
import_class_extends:
':' type_identifier (',' type_identifier)*
;
import_class_method_decl:
method_prototype ';'
;
|
Scaliger-Ada_conversion.adb | Louis-Aime/Milesian_calendar_Ada | 0 | 3905 | -- Package body Scaliger.Ada_conversion
----------------------------------------------------------------------------
-- Copyright Miletus 2015
-- 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:
-- 1. The above copyright notice and this permission notice shall be included
-- in all copies or substantial portions of the Software.
-- 2. Changes with respect to any former version shall be documented.
--
-- The software is provided "as is", without warranty of any kind,
-- express of implied, including but not limited to the warranties of
-- merchantability, fitness for a particular purpose and noninfringement.
-- In no event shall the authors of 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.
-- Inquiries: www.calendriermilesien.org
-------------------------------------------------------------------------------
with Calendar; use Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
package body Scaliger.Ada_conversion is
-- Julian_Time and Julian_Duration are also in seconds.
Day_Unit : constant := 86_400;
Half_Day : constant := 43_200.0; -- used as a fixed real operand
-- Work_Day_Unit: constant Work_duration := 86_400.0;
-- One day expressed in seconds.
Ada_Zero_Time : Time := Time_Of (2150, 1, 1, 0.0,
Time_Zone => 0);
-- Ada time epoch choosen in the middle of the Ada time span (1901..2399)
-- in order to minimize computation problems with a too high duration
Ada_Zero_in_Julian : constant := 2_506_331.5 * Day_Unit;
-- Julian time corresponding to Ada_Zero_Time
Ada_Zero_Day_in_Julian : constant := 2_506_332;
-- Julian day corresponding to the day of the Ada epoch, at 12h UTC
function Julian_Time_Of (Ada_Timestamp : Time) return Historical_Time is
Ada_Time_Offset : Duration := Ada_Timestamp - Ada_Zero_Time;
begin
return Historical_Duration (Ada_Time_Offset) + Ada_Zero_in_Julian;
end Julian_Time_Of;
function Time_Of (Julian_Timestamp : Historical_Time) return Time is
Duration_offset : Duration :=
Duration_Of (Julian_Timestamp - Ada_Zero_in_Julian);
-- Here the accuracy relies on function Duration_Of
begin
return Ada_Zero_Time + Duration_offset;
end Time_Of;
function Julian_Duration_Of (Ada_Offset : Duration) return Historical_Duration is
begin
return Historical_Duration (Ada_Offset);
end Julian_Duration_Of;
function Julian_Duration_Of (Day : Julian_Day_Duration) return Historical_Duration is
begin
return Day_Unit * Historical_Duration (Day);
end Julian_Duration_Of;
function Duration_Of (Julian_Offset : Historical_Duration) return Duration is
-- since Julian Duration is stored as seconds,
-- we make here a simple type conversion.
-- The only problem could be an error of bounds.
begin
return Duration (Julian_Offset);
end Duration_Of;
function Day_Julian_Offset (Ada_Daytime : Day_Duration)
return Day_Historical_Duration is
-- Time of the day expressed in UTC time (0..86_400.0 s)
-- to Julian duration expressed in (-0.5..+0.5) but stored in seconds
Offset : Historical_Duration := Historical_Duration(Ada_Daytime)- Half_Day;
begin
return Offset;
end Day_Julian_Offset;
function Day_Offset (Julian_Offset : Day_Historical_Duration)return Day_Duration
is
-- Julian day duration -0.5..+0.5 but stored in seconds
-- to time of day 0..86_400.0 s
Offset : Duration := Duration(Julian_Offset) + Half_Day;
begin
return Offset;
exception
when Constraint_Error => -- if more than 86400.0 seconds...
return 86400.0;
end Day_Offset;
function Julian_Day_Of (Julian_Timestamp : Historical_Time) return Julian_Day is
begin
return Julian_Day (Julian_Timestamp / Day_Unit);
-- This will convert to the nearest integer value exactly as required:
-- this is a numeric type conversion, and
-- "If the target type is an integer type
-- and the operand type is real,
-- the result is rounded to the nearest integer
-- (away from zero if exactly halfway between two integers)".
-- (Ada 2005 manual, 4.6, line 33).
end Julian_Day_Of;
function Julian_Day_Of (Ada_Timestamp : Time) return Julian_Day is
begin
return Julian_Day (Julian_Time_Of(Ada_Timestamp) / Day_Unit);
end Julian_Day_Of;
function Time_Of_At_Noon (Julian_Date : Julian_Day) return Time is
subtype Ada_Calendar_Days_Offset is Julian_Day'Base
range -250*366..250*366;
Day_offset : Ada_Calendar_Days_Offset
:= (Julian_Date - Ada_Zero_Day_in_Julian);
Duration_offset : Duration := Duration (Day_offset*Day_Unit + Day_Unit/2);
-- raises contraint error if not in Ada calendar.
begin
return Ada_Zero_Time + Duration_offset;
end Time_Of_At_Noon;
end Scaliger.Ada_conversion;
|
tools/yasm/tests/nasm/org.asm | fasttr-org/ftr | 0 | 161226 | [ORG 0x100]
[SECTION .blah]
[ORG a]
[ORG t=0x100]
a:
[SECTION .text ALIGN=a]
[SECTION .data ALIGN=16]
[SECTION .bss align=15]
[SECTION .bss align=]
[SECTION .bss align]
|
dist/vale/curve25519-x86_64-msvc.asm | santtu/hacl-star | 1,332 | 244321 | <filename>dist/vale/curve25519-x86_64-msvc.asm<gh_stars>1000+
.code
ALIGN 16
add_scalar_e proc
push rdi
push rsi
mov rdi, rcx
mov rsi, rdx
mov rdx, r8
;# Clear registers to propagate the carry bit
xor r8d, r8d
xor r9d, r9d
xor r10d, r10d
xor r11d, r11d
xor eax, eax
;# Begin addition chain
add rdx, qword ptr [rsi + 0]
mov qword ptr [rdi + 0], rdx
adcx r8, qword ptr [rsi + 8]
mov qword ptr [rdi + 8], r8
adcx r9, qword ptr [rsi + 16]
mov qword ptr [rdi + 16], r9
adcx r10, qword ptr [rsi + 24]
mov qword ptr [rdi + 24], r10
;# Return the carry bit in a register
adcx rax, r11
pop rsi
pop rdi
ret
add_scalar_e endp
ALIGN 16
fadd_e proc
push rdi
push rsi
mov rdi, rcx
mov rsi, rdx
mov rdx, r8
;# Compute the raw addition of f1 + f2
mov r8, qword ptr [rdx + 0]
add r8, qword ptr [rsi + 0]
mov r9, qword ptr [rdx + 8]
adcx r9, qword ptr [rsi + 8]
mov r10, qword ptr [rdx + 16]
adcx r10, qword ptr [rsi + 16]
mov r11, qword ptr [rdx + 24]
adcx r11, qword ptr [rsi + 24]
;# Wrap the result back into the field
;# Step 1: Compute carry*38
mov rax, 0
mov rdx, 38
cmovc rax, rdx
;# Step 2: Add carry*38 to the original sum
xor ecx, ecx
add r8, rax
adcx r9, rcx
mov qword ptr [rdi + 8], r9
adcx r10, rcx
mov qword ptr [rdi + 16], r10
adcx r11, rcx
mov qword ptr [rdi + 24], r11
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rdx
add r8, rax
mov qword ptr [rdi + 0], r8
pop rsi
pop rdi
ret
fadd_e endp
ALIGN 16
fsub_e proc
push rdi
push rsi
mov rdi, rcx
mov rsi, rdx
mov rdx, r8
;# Compute the raw substraction of f1-f2
mov r8, qword ptr [rsi + 0]
sub r8, qword ptr [rdx + 0]
mov r9, qword ptr [rsi + 8]
sbb r9, qword ptr [rdx + 8]
mov r10, qword ptr [rsi + 16]
sbb r10, qword ptr [rdx + 16]
mov r11, qword ptr [rsi + 24]
sbb r11, qword ptr [rdx + 24]
;# Wrap the result back into the field
;# Step 1: Compute carry*38
mov rax, 0
mov rcx, 38
cmovc rax, rcx
;# Step 2: Substract carry*38 from the original difference
sub r8, rax
sbb r9, 0
sbb r10, 0
sbb r11, 0
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rcx
sub r8, rax
;# Store the result
mov qword ptr [rdi + 0], r8
mov qword ptr [rdi + 8], r9
mov qword ptr [rdi + 16], r10
mov qword ptr [rdi + 24], r11
pop rsi
pop rdi
ret
fsub_e endp
ALIGN 16
fmul_scalar_e proc
push rdi
push r13
push rbx
push rsi
mov rdi, rcx
mov rsi, rdx
mov rdx, r8
;# Compute the raw multiplication of f1*f2
mulx rcx, r8, qword ptr [rsi + 0]
;# f1[0]*f2
mulx rbx, r9, qword ptr [rsi + 8]
;# f1[1]*f2
add r9, rcx
mov rcx, 0
mulx r13, r10, qword ptr [rsi + 16]
;# f1[2]*f2
adcx r10, rbx
mulx rax, r11, qword ptr [rsi + 24]
;# f1[3]*f2
adcx r11, r13
adcx rax, rcx
;# Wrap the result back into the field
;# Step 1: Compute carry*38
mov rdx, 38
imul rax, rdx
;# Step 2: Fold the carry back into dst
add r8, rax
adcx r9, rcx
mov qword ptr [rdi + 8], r9
adcx r10, rcx
mov qword ptr [rdi + 16], r10
adcx r11, rcx
mov qword ptr [rdi + 24], r11
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rdx
add r8, rax
mov qword ptr [rdi + 0], r8
pop rsi
pop rbx
pop r13
pop rdi
ret
fmul_scalar_e endp
ALIGN 16
fmul_e proc
push r13
push r14
push r15
push rbx
push rsi
push rdi
mov rdi, rcx
mov rsi, rdx
mov r15, r8
mov rcx, r9
;# Compute the raw multiplication: tmp <- src1 * src2
;# Compute src1[0] * src2
mov rdx, qword ptr [rsi + 0]
mulx r9, r8, qword ptr [rcx + 0]
xor r10d, r10d
mov qword ptr [rdi + 0], r8
mulx r11, r10, qword ptr [rcx + 8]
adox r10, r9
mov qword ptr [rdi + 8], r10
mulx r13, rbx, qword ptr [rcx + 16]
adox rbx, r11
mulx rdx, r14, qword ptr [rcx + 24]
adox r14, r13
mov rax, 0
adox rax, rdx
;# Compute src1[1] * src2
mov rdx, qword ptr [rsi + 8]
mulx r9, r8, qword ptr [rcx + 0]
xor r10d, r10d
adcx r8, qword ptr [rdi + 8]
mov qword ptr [rdi + 8], r8
mulx r11, r10, qword ptr [rcx + 8]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 16], r10
mulx r13, rbx, qword ptr [rcx + 16]
adox rbx, r11
adcx rbx, r14
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 24]
adox r14, r13
adcx r14, rax
mov rax, 0
adox rax, rdx
adcx rax, r8
;# Compute src1[2] * src2
mov rdx, qword ptr [rsi + 16]
mulx r9, r8, qword ptr [rcx + 0]
xor r10d, r10d
adcx r8, qword ptr [rdi + 16]
mov qword ptr [rdi + 16], r8
mulx r11, r10, qword ptr [rcx + 8]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 24], r10
mulx r13, rbx, qword ptr [rcx + 16]
adox rbx, r11
adcx rbx, r14
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 24]
adox r14, r13
adcx r14, rax
mov rax, 0
adox rax, rdx
adcx rax, r8
;# Compute src1[3] * src2
mov rdx, qword ptr [rsi + 24]
mulx r9, r8, qword ptr [rcx + 0]
xor r10d, r10d
adcx r8, qword ptr [rdi + 24]
mov qword ptr [rdi + 24], r8
mulx r11, r10, qword ptr [rcx + 8]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 32], r10
mulx r13, rbx, qword ptr [rcx + 16]
adox rbx, r11
adcx rbx, r14
mov qword ptr [rdi + 40], rbx
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 24]
adox r14, r13
adcx r14, rax
mov qword ptr [rdi + 48], r14
mov rax, 0
adox rax, rdx
adcx rax, r8
mov qword ptr [rdi + 56], rax
;# Line up pointers
mov rsi, rdi
mov rdi, r15
;# Wrap the result back into the field
;# Step 1: Compute dst + carry == tmp_hi * 38 + tmp_lo
mov rdx, 38
mulx r13, r8, qword ptr [rsi + 32]
xor ecx, ecx
adox r8, qword ptr [rsi + 0]
mulx rbx, r9, qword ptr [rsi + 40]
adcx r9, r13
adox r9, qword ptr [rsi + 8]
mulx r13, r10, qword ptr [rsi + 48]
adcx r10, rbx
adox r10, qword ptr [rsi + 16]
mulx rax, r11, qword ptr [rsi + 56]
adcx r11, r13
adox r11, qword ptr [rsi + 24]
adcx rax, rcx
adox rax, rcx
imul rax, rdx
;# Step 2: Fold the carry back into dst
add r8, rax
adcx r9, rcx
mov qword ptr [rdi + 8], r9
adcx r10, rcx
mov qword ptr [rdi + 16], r10
adcx r11, rcx
mov qword ptr [rdi + 24], r11
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rdx
add r8, rax
mov qword ptr [rdi + 0], r8
pop rdi
pop rsi
pop rbx
pop r15
pop r14
pop r13
ret
fmul_e endp
ALIGN 16
fmul2_e proc
push r13
push r14
push r15
push rbx
push rsi
push rdi
mov rdi, rcx
mov rsi, rdx
mov r15, r8
mov rcx, r9
;# Compute the raw multiplication tmp[0] <- f1[0] * f2[0]
;# Compute src1[0] * src2
mov rdx, qword ptr [rsi + 0]
mulx r9, r8, qword ptr [rcx + 0]
xor r10d, r10d
mov qword ptr [rdi + 0], r8
mulx r11, r10, qword ptr [rcx + 8]
adox r10, r9
mov qword ptr [rdi + 8], r10
mulx r13, rbx, qword ptr [rcx + 16]
adox rbx, r11
mulx rdx, r14, qword ptr [rcx + 24]
adox r14, r13
mov rax, 0
adox rax, rdx
;# Compute src1[1] * src2
mov rdx, qword ptr [rsi + 8]
mulx r9, r8, qword ptr [rcx + 0]
xor r10d, r10d
adcx r8, qword ptr [rdi + 8]
mov qword ptr [rdi + 8], r8
mulx r11, r10, qword ptr [rcx + 8]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 16], r10
mulx r13, rbx, qword ptr [rcx + 16]
adox rbx, r11
adcx rbx, r14
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 24]
adox r14, r13
adcx r14, rax
mov rax, 0
adox rax, rdx
adcx rax, r8
;# Compute src1[2] * src2
mov rdx, qword ptr [rsi + 16]
mulx r9, r8, qword ptr [rcx + 0]
xor r10d, r10d
adcx r8, qword ptr [rdi + 16]
mov qword ptr [rdi + 16], r8
mulx r11, r10, qword ptr [rcx + 8]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 24], r10
mulx r13, rbx, qword ptr [rcx + 16]
adox rbx, r11
adcx rbx, r14
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 24]
adox r14, r13
adcx r14, rax
mov rax, 0
adox rax, rdx
adcx rax, r8
;# Compute src1[3] * src2
mov rdx, qword ptr [rsi + 24]
mulx r9, r8, qword ptr [rcx + 0]
xor r10d, r10d
adcx r8, qword ptr [rdi + 24]
mov qword ptr [rdi + 24], r8
mulx r11, r10, qword ptr [rcx + 8]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 32], r10
mulx r13, rbx, qword ptr [rcx + 16]
adox rbx, r11
adcx rbx, r14
mov qword ptr [rdi + 40], rbx
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 24]
adox r14, r13
adcx r14, rax
mov qword ptr [rdi + 48], r14
mov rax, 0
adox rax, rdx
adcx rax, r8
mov qword ptr [rdi + 56], rax
;# Compute the raw multiplication tmp[1] <- f1[1] * f2[1]
;# Compute src1[0] * src2
mov rdx, qword ptr [rsi + 32]
mulx r9, r8, qword ptr [rcx + 32]
xor r10d, r10d
mov qword ptr [rdi + 64], r8
mulx r11, r10, qword ptr [rcx + 40]
adox r10, r9
mov qword ptr [rdi + 72], r10
mulx r13, rbx, qword ptr [rcx + 48]
adox rbx, r11
mulx rdx, r14, qword ptr [rcx + 56]
adox r14, r13
mov rax, 0
adox rax, rdx
;# Compute src1[1] * src2
mov rdx, qword ptr [rsi + 40]
mulx r9, r8, qword ptr [rcx + 32]
xor r10d, r10d
adcx r8, qword ptr [rdi + 72]
mov qword ptr [rdi + 72], r8
mulx r11, r10, qword ptr [rcx + 40]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 80], r10
mulx r13, rbx, qword ptr [rcx + 48]
adox rbx, r11
adcx rbx, r14
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 56]
adox r14, r13
adcx r14, rax
mov rax, 0
adox rax, rdx
adcx rax, r8
;# Compute src1[2] * src2
mov rdx, qword ptr [rsi + 48]
mulx r9, r8, qword ptr [rcx + 32]
xor r10d, r10d
adcx r8, qword ptr [rdi + 80]
mov qword ptr [rdi + 80], r8
mulx r11, r10, qword ptr [rcx + 40]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 88], r10
mulx r13, rbx, qword ptr [rcx + 48]
adox rbx, r11
adcx rbx, r14
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 56]
adox r14, r13
adcx r14, rax
mov rax, 0
adox rax, rdx
adcx rax, r8
;# Compute src1[3] * src2
mov rdx, qword ptr [rsi + 56]
mulx r9, r8, qword ptr [rcx + 32]
xor r10d, r10d
adcx r8, qword ptr [rdi + 88]
mov qword ptr [rdi + 88], r8
mulx r11, r10, qword ptr [rcx + 40]
adox r10, r9
adcx r10, rbx
mov qword ptr [rdi + 96], r10
mulx r13, rbx, qword ptr [rcx + 48]
adox rbx, r11
adcx rbx, r14
mov qword ptr [rdi + 104], rbx
mov r8, 0
mulx rdx, r14, qword ptr [rcx + 56]
adox r14, r13
adcx r14, rax
mov qword ptr [rdi + 112], r14
mov rax, 0
adox rax, rdx
adcx rax, r8
mov qword ptr [rdi + 120], rax
;# Line up pointers
mov rsi, rdi
mov rdi, r15
;# Wrap the results back into the field
;# Step 1: Compute dst + carry == tmp_hi * 38 + tmp_lo
mov rdx, 38
mulx r13, r8, qword ptr [rsi + 32]
xor ecx, ecx
adox r8, qword ptr [rsi + 0]
mulx rbx, r9, qword ptr [rsi + 40]
adcx r9, r13
adox r9, qword ptr [rsi + 8]
mulx r13, r10, qword ptr [rsi + 48]
adcx r10, rbx
adox r10, qword ptr [rsi + 16]
mulx rax, r11, qword ptr [rsi + 56]
adcx r11, r13
adox r11, qword ptr [rsi + 24]
adcx rax, rcx
adox rax, rcx
imul rax, rdx
;# Step 2: Fold the carry back into dst
add r8, rax
adcx r9, rcx
mov qword ptr [rdi + 8], r9
adcx r10, rcx
mov qword ptr [rdi + 16], r10
adcx r11, rcx
mov qword ptr [rdi + 24], r11
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rdx
add r8, rax
mov qword ptr [rdi + 0], r8
;# Step 1: Compute dst + carry == tmp_hi * 38 + tmp_lo
mov rdx, 38
mulx r13, r8, qword ptr [rsi + 96]
xor ecx, ecx
adox r8, qword ptr [rsi + 64]
mulx rbx, r9, qword ptr [rsi + 104]
adcx r9, r13
adox r9, qword ptr [rsi + 72]
mulx r13, r10, qword ptr [rsi + 112]
adcx r10, rbx
adox r10, qword ptr [rsi + 80]
mulx rax, r11, qword ptr [rsi + 120]
adcx r11, r13
adox r11, qword ptr [rsi + 88]
adcx rax, rcx
adox rax, rcx
imul rax, rdx
;# Step 2: Fold the carry back into dst
add r8, rax
adcx r9, rcx
mov qword ptr [rdi + 40], r9
adcx r10, rcx
mov qword ptr [rdi + 48], r10
adcx r11, rcx
mov qword ptr [rdi + 56], r11
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rdx
add r8, rax
mov qword ptr [rdi + 32], r8
pop rdi
pop rsi
pop rbx
pop r15
pop r14
pop r13
ret
fmul2_e endp
ALIGN 16
fsqr_e proc
push r15
push r13
push r14
push r12
push rbx
push rsi
push rdi
mov rdi, rcx
mov rsi, rdx
mov r12, r8
;# Compute the raw multiplication: tmp <- f * f
;# Step 1: Compute all partial products
mov rdx, qword ptr [rsi + 0]
;# f[0]
mulx r14, r8, qword ptr [rsi + 8]
xor r15d, r15d
;# f[1]*f[0]
mulx r10, r9, qword ptr [rsi + 16]
adcx r9, r14
;# f[2]*f[0]
mulx rcx, rax, qword ptr [rsi + 24]
adcx r10, rax
;# f[3]*f[0]
mov rdx, qword ptr [rsi + 24]
;# f[3]
mulx rbx, r11, qword ptr [rsi + 8]
adcx r11, rcx
;# f[1]*f[3]
mulx r13, rax, qword ptr [rsi + 16]
adcx rbx, rax
;# f[2]*f[3]
mov rdx, qword ptr [rsi + 8]
adcx r13, r15
;# f1
mulx rcx, rax, qword ptr [rsi + 16]
mov r14, 0
;# f[2]*f[1]
;# Step 2: Compute two parallel carry chains
xor r15d, r15d
adox r10, rax
adcx r8, r8
adox r11, rcx
adcx r9, r9
adox rbx, r15
adcx r10, r10
adox r13, r15
adcx r11, r11
adox r14, r15
adcx rbx, rbx
adcx r13, r13
adcx r14, r14
;# Step 3: Compute intermediate squares
mov rdx, qword ptr [rsi + 0]
mulx rcx, rax, rdx
;# f[0]^2
mov qword ptr [rdi + 0], rax
add r8, rcx
mov qword ptr [rdi + 8], r8
mov rdx, qword ptr [rsi + 8]
mulx rcx, rax, rdx
;# f[1]^2
adcx r9, rax
mov qword ptr [rdi + 16], r9
adcx r10, rcx
mov qword ptr [rdi + 24], r10
mov rdx, qword ptr [rsi + 16]
mulx rcx, rax, rdx
;# f[2]^2
adcx r11, rax
mov qword ptr [rdi + 32], r11
adcx rbx, rcx
mov qword ptr [rdi + 40], rbx
mov rdx, qword ptr [rsi + 24]
mulx rcx, rax, rdx
;# f[3]^2
adcx r13, rax
mov qword ptr [rdi + 48], r13
adcx r14, rcx
mov qword ptr [rdi + 56], r14
;# Line up pointers
mov rsi, rdi
mov rdi, r12
;# Wrap the result back into the field
;# Step 1: Compute dst + carry == tmp_hi * 38 + tmp_lo
mov rdx, 38
mulx r13, r8, qword ptr [rsi + 32]
xor ecx, ecx
adox r8, qword ptr [rsi + 0]
mulx rbx, r9, qword ptr [rsi + 40]
adcx r9, r13
adox r9, qword ptr [rsi + 8]
mulx r13, r10, qword ptr [rsi + 48]
adcx r10, rbx
adox r10, qword ptr [rsi + 16]
mulx rax, r11, qword ptr [rsi + 56]
adcx r11, r13
adox r11, qword ptr [rsi + 24]
adcx rax, rcx
adox rax, rcx
imul rax, rdx
;# Step 2: Fold the carry back into dst
add r8, rax
adcx r9, rcx
mov qword ptr [rdi + 8], r9
adcx r10, rcx
mov qword ptr [rdi + 16], r10
adcx r11, rcx
mov qword ptr [rdi + 24], r11
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rdx
add r8, rax
mov qword ptr [rdi + 0], r8
pop rdi
pop rsi
pop rbx
pop r12
pop r14
pop r13
pop r15
ret
fsqr_e endp
ALIGN 16
fsqr2_e proc
push r15
push r13
push r14
push r12
push rbx
push rsi
push rdi
mov rdi, rcx
mov rsi, rdx
mov r12, r8
;# Step 1: Compute all partial products
mov rdx, qword ptr [rsi + 0]
;# f[0]
mulx r14, r8, qword ptr [rsi + 8]
xor r15d, r15d
;# f[1]*f[0]
mulx r10, r9, qword ptr [rsi + 16]
adcx r9, r14
;# f[2]*f[0]
mulx rcx, rax, qword ptr [rsi + 24]
adcx r10, rax
;# f[3]*f[0]
mov rdx, qword ptr [rsi + 24]
;# f[3]
mulx rbx, r11, qword ptr [rsi + 8]
adcx r11, rcx
;# f[1]*f[3]
mulx r13, rax, qword ptr [rsi + 16]
adcx rbx, rax
;# f[2]*f[3]
mov rdx, qword ptr [rsi + 8]
adcx r13, r15
;# f1
mulx rcx, rax, qword ptr [rsi + 16]
mov r14, 0
;# f[2]*f[1]
;# Step 2: Compute two parallel carry chains
xor r15d, r15d
adox r10, rax
adcx r8, r8
adox r11, rcx
adcx r9, r9
adox rbx, r15
adcx r10, r10
adox r13, r15
adcx r11, r11
adox r14, r15
adcx rbx, rbx
adcx r13, r13
adcx r14, r14
;# Step 3: Compute intermediate squares
mov rdx, qword ptr [rsi + 0]
mulx rcx, rax, rdx
;# f[0]^2
mov qword ptr [rdi + 0], rax
add r8, rcx
mov qword ptr [rdi + 8], r8
mov rdx, qword ptr [rsi + 8]
mulx rcx, rax, rdx
;# f[1]^2
adcx r9, rax
mov qword ptr [rdi + 16], r9
adcx r10, rcx
mov qword ptr [rdi + 24], r10
mov rdx, qword ptr [rsi + 16]
mulx rcx, rax, rdx
;# f[2]^2
adcx r11, rax
mov qword ptr [rdi + 32], r11
adcx rbx, rcx
mov qword ptr [rdi + 40], rbx
mov rdx, qword ptr [rsi + 24]
mulx rcx, rax, rdx
;# f[3]^2
adcx r13, rax
mov qword ptr [rdi + 48], r13
adcx r14, rcx
mov qword ptr [rdi + 56], r14
;# Step 1: Compute all partial products
mov rdx, qword ptr [rsi + 32]
;# f[0]
mulx r14, r8, qword ptr [rsi + 40]
xor r15d, r15d
;# f[1]*f[0]
mulx r10, r9, qword ptr [rsi + 48]
adcx r9, r14
;# f[2]*f[0]
mulx rcx, rax, qword ptr [rsi + 56]
adcx r10, rax
;# f[3]*f[0]
mov rdx, qword ptr [rsi + 56]
;# f[3]
mulx rbx, r11, qword ptr [rsi + 40]
adcx r11, rcx
;# f[1]*f[3]
mulx r13, rax, qword ptr [rsi + 48]
adcx rbx, rax
;# f[2]*f[3]
mov rdx, qword ptr [rsi + 40]
adcx r13, r15
;# f1
mulx rcx, rax, qword ptr [rsi + 48]
mov r14, 0
;# f[2]*f[1]
;# Step 2: Compute two parallel carry chains
xor r15d, r15d
adox r10, rax
adcx r8, r8
adox r11, rcx
adcx r9, r9
adox rbx, r15
adcx r10, r10
adox r13, r15
adcx r11, r11
adox r14, r15
adcx rbx, rbx
adcx r13, r13
adcx r14, r14
;# Step 3: Compute intermediate squares
mov rdx, qword ptr [rsi + 32]
mulx rcx, rax, rdx
;# f[0]^2
mov qword ptr [rdi + 64], rax
add r8, rcx
mov qword ptr [rdi + 72], r8
mov rdx, qword ptr [rsi + 40]
mulx rcx, rax, rdx
;# f[1]^2
adcx r9, rax
mov qword ptr [rdi + 80], r9
adcx r10, rcx
mov qword ptr [rdi + 88], r10
mov rdx, qword ptr [rsi + 48]
mulx rcx, rax, rdx
;# f[2]^2
adcx r11, rax
mov qword ptr [rdi + 96], r11
adcx rbx, rcx
mov qword ptr [rdi + 104], rbx
mov rdx, qword ptr [rsi + 56]
mulx rcx, rax, rdx
;# f[3]^2
adcx r13, rax
mov qword ptr [rdi + 112], r13
adcx r14, rcx
mov qword ptr [rdi + 120], r14
;# Line up pointers
mov rsi, rdi
mov rdi, r12
;# Step 1: Compute dst + carry == tmp_hi * 38 + tmp_lo
mov rdx, 38
mulx r13, r8, qword ptr [rsi + 32]
xor ecx, ecx
adox r8, qword ptr [rsi + 0]
mulx rbx, r9, qword ptr [rsi + 40]
adcx r9, r13
adox r9, qword ptr [rsi + 8]
mulx r13, r10, qword ptr [rsi + 48]
adcx r10, rbx
adox r10, qword ptr [rsi + 16]
mulx rax, r11, qword ptr [rsi + 56]
adcx r11, r13
adox r11, qword ptr [rsi + 24]
adcx rax, rcx
adox rax, rcx
imul rax, rdx
;# Step 2: Fold the carry back into dst
add r8, rax
adcx r9, rcx
mov qword ptr [rdi + 8], r9
adcx r10, rcx
mov qword ptr [rdi + 16], r10
adcx r11, rcx
mov qword ptr [rdi + 24], r11
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rdx
add r8, rax
mov qword ptr [rdi + 0], r8
;# Step 1: Compute dst + carry == tmp_hi * 38 + tmp_lo
mov rdx, 38
mulx r13, r8, qword ptr [rsi + 96]
xor ecx, ecx
adox r8, qword ptr [rsi + 64]
mulx rbx, r9, qword ptr [rsi + 104]
adcx r9, r13
adox r9, qword ptr [rsi + 72]
mulx r13, r10, qword ptr [rsi + 112]
adcx r10, rbx
adox r10, qword ptr [rsi + 80]
mulx rax, r11, qword ptr [rsi + 120]
adcx r11, r13
adox r11, qword ptr [rsi + 88]
adcx rax, rcx
adox rax, rcx
imul rax, rdx
;# Step 2: Fold the carry back into dst
add r8, rax
adcx r9, rcx
mov qword ptr [rdi + 40], r9
adcx r10, rcx
mov qword ptr [rdi + 48], r10
adcx r11, rcx
mov qword ptr [rdi + 56], r11
;# Step 3: Fold the carry bit back in; guaranteed not to carry at this point
mov rax, 0
cmovc rax, rdx
add r8, rax
mov qword ptr [rdi + 32], r8
pop rdi
pop rsi
pop rbx
pop r12
pop r14
pop r13
pop r15
ret
fsqr2_e endp
ALIGN 16
cswap2_e proc
push rdi
push rsi
mov rdi, rcx
mov rsi, rdx
mov rdx, r8
;# Transfer bit into CF flag
add rdi, 18446744073709551615
;# cswap p1[0], p2[0]
mov r8, qword ptr [rsi + 0]
mov r9, qword ptr [rdx + 0]
mov r10, r8
cmovc r8, r9
cmovc r9, r10
mov qword ptr [rsi + 0], r8
mov qword ptr [rdx + 0], r9
;# cswap p1[1], p2[1]
mov r8, qword ptr [rsi + 8]
mov r9, qword ptr [rdx + 8]
mov r10, r8
cmovc r8, r9
cmovc r9, r10
mov qword ptr [rsi + 8], r8
mov qword ptr [rdx + 8], r9
;# cswap p1[2], p2[2]
mov r8, qword ptr [rsi + 16]
mov r9, qword ptr [rdx + 16]
mov r10, r8
cmovc r8, r9
cmovc r9, r10
mov qword ptr [rsi + 16], r8
mov qword ptr [rdx + 16], r9
;# cswap p1[3], p2[3]
mov r8, qword ptr [rsi + 24]
mov r9, qword ptr [rdx + 24]
mov r10, r8
cmovc r8, r9
cmovc r9, r10
mov qword ptr [rsi + 24], r8
mov qword ptr [rdx + 24], r9
;# cswap p1[4], p2[4]
mov r8, qword ptr [rsi + 32]
mov r9, qword ptr [rdx + 32]
mov r10, r8
cmovc r8, r9
cmovc r9, r10
mov qword ptr [rsi + 32], r8
mov qword ptr [rdx + 32], r9
;# cswap p1[5], p2[5]
mov r8, qword ptr [rsi + 40]
mov r9, qword ptr [rdx + 40]
mov r10, r8
cmovc r8, r9
cmovc r9, r10
mov qword ptr [rsi + 40], r8
mov qword ptr [rdx + 40], r9
;# cswap p1[6], p2[6]
mov r8, qword ptr [rsi + 48]
mov r9, qword ptr [rdx + 48]
mov r10, r8
cmovc r8, r9
cmovc r9, r10
mov qword ptr [rsi + 48], r8
mov qword ptr [rdx + 48], r9
;# cswap p1[7], p2[7]
mov r8, qword ptr [rsi + 56]
mov r9, qword ptr [rdx + 56]
mov r10, r8
cmovc r8, r9
cmovc r9, r10
mov qword ptr [rsi + 56], r8
mov qword ptr [rdx + 56], r9
pop rsi
pop rdi
ret
cswap2_e endp
end
|
bundles/org.pgcase.xobot.parsers/grammar/org/pgcase/xobot/parsers/postgres/PlPgSql.g4 | pgcase/xobot-ide | 2 | 2347 | <reponame>pgcase/xobot-ide<filename>bundles/org.pgcase.xobot.parsers/grammar/org/pgcase/xobot/parsers/postgres/PlPgSql.g4<gh_stars>1-10
grammar PlPgSql;
import PlPgSqlKeyWords, Sql;
pl_function: comp_options pl_block opt_semi
;
comp_options: comp_options comp_option
|
;
comp_option: '#' K_OPTION K_DUMP
| '#' K_VARIABLE_CONFLICT K_ERROR
| '#' K_VARIABLE_CONFLICT K_USE_VARIABLE
| '#' K_VARIABLE_CONFLICT K_USE_COLUMN
;
opt_semi: ';'
|
;
pl_block: decl_sect BEGIN_P proc_sect exception_sect END_P opt_label
;
decl_sect: opt_block_label decl_start decl_stmts
| opt_block_label decl_start
| opt_block_label
;
decl_start: DECLARE
;
decl_stmts: decl_stmts decl_stmt
| decl_stmt
;
decl_stmt: decl_statement
| LESS_LESS any_identifier GREATER_GREATER
| DECLARE
;
decl_statement: decl_varname decl_const decl_datatype decl_collate decl_notnull decl_defval
| decl_varname opt_scrollable K_CURSOR decl_cursor_args decl_is_for decl_cursor_query ';'
| decl_varname K_ALIAS FOR decl_aliasitem ';'
;
opt_scrollable:
| K_NO K_SCROLL
| K_SCROLL
;
decl_cursor_query: stmt
;
decl_cursor_args: '(' decl_cursor_arglist ')'
|
;
decl_cursor_arglist: decl_cursor_arglist ',' decl_cursor_arg
| decl_cursor_arg
;
decl_cursor_arg: decl_varname decl_datatype
;
decl_is_for: IS
| FOR
;
decl_aliasitem: any_identifier
;
decl_varname: any_identifier
;
decl_const:
| K_CONSTANT
;
// FIXME not 100% correct
decl_datatype: typename
| typename '%' TYPE_P
| typename '%' K_ROWTYPE
;
decl_collate:
| K_COLLATE IDENT
;
decl_notnull:
| NOT NULL_P
;
decl_defval: ';'
| decl_defkey stmt ';'
| decl_defkey a_expr ';' // FIXME not sure if this is correct
;
decl_defkey: assign_operator
| DEFAULT
;
assign_operator: '='
| COLON_EQUALS
;
proc_sect: proc_stmts
|
;
proc_stmts: proc_stmts proc_stmt
| proc_stmt
;
proc_stmt: pl_block ';'
| stmt_assign
| stmt_if
| stmt_case
| stmt_loop
| stmt_while
| stmt_for
| stmt_foreach_a
| stmt_exit
| stmt_return
| stmt_raise
| stmt_execsql ';'
| stmt_dynexecute
| stmt_perform
| stmt_getdiag
| stmt_open
| stmt_fetch
| stmt_move
| stmt_close
| stmt_null
;
stmt_perform: K_PERFORM expr_until_semi
;
stmt_assign: assign_var assign_operator expr_until_semi
;
stmt_getdiag: K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';'
;
getdiag_area_opt:
| K_CURRENT
| K_STACKED
;
getdiag_list: getdiag_list ',' getdiag_list_item
| getdiag_list_item
;
getdiag_list_item: getdiag_target assign_operator getdiag_item
;
// TODO
getdiag_item : K_ROW_COUNT
| K_RESULT_OID
| K_PG_EXCEPTION_DETAIL
| K_PG_EXCEPTION_HINT
| K_PG_EXCEPTION_CONTEXT
| K_MESSAGE_TEXT
| K_RETURNED_SQLSTATE
;
// TODO
getdiag_target: IDENT
;
// TODO
assign_var: assign_var '[' expr_until_rightbracket
// | IDENT
| any_identifier
;
stmt_if: IF_P expr_until_then proc_sect stmt_elsif* stmt_else? END_P IF_P ';'
;
// stmt_elsifs : stmt_elsif*
// ;
stmt_elsif : K_ELSIF expr_until_then proc_sect
;
stmt_else : ELSE proc_sect
// |
;
stmt_case: CASE opt_expr_until_when case_when_list opt_case_else END_P CASE ';'
;
// TODO
opt_expr_until_when: a_expr
|
;
case_when_list: case_when_list case_when
| case_when
;
case_when: WHEN expr_until_then proc_sect
;
opt_case_else: ELSE proc_sect
|
;
stmt_loop: opt_block_label K_LOOP loop_body
;
stmt_while: opt_block_label K_WHILE expr_until_loop loop_body
;
stmt_for: opt_block_label FOR for_control loop_body
;
// TODO
// TODO what about cursor parameters (see original grammar)?
for_control: for_variable IN_P K_EXECUTE select_clause K_LOOP
| for_variable IN_P select_clause USING a_expr (a_expr ',')* K_LOOP
| for_variable IN_P a_expr K_LOOP
| for_variable IN_P a_expr DOT_DOT a_expr K_LOOP
| for_variable IN_P K_REVERSE a_expr DOT_DOT a_expr K_LOOP
| for_variable IN_P select_clause K_LOOP
;
// TODO
for_variable: IDENT
;
stmt_foreach_a: opt_block_label K_FOREACH for_variable foreach_slice IN_P ARRAY expr_until_loop loop_body
;
foreach_slice:
| K_SLICE ICONST
;
stmt_exit: exit_type opt_label opt_exitcond
;
exit_type: K_EXIT
| K_CONTINUE
;
// TODO
stmt_return: K_RETURN K_QUERY select_clause ';'
| K_RETURN K_NEXT a_expr ';'
| K_RETURN a_expr? ';'
;
// TODO
// TODO it seems that there is also something with USING...
stmt_raise: K_RAISE raiseLevel (format=SCONST (',' raise_expr)*)? usingClause? ';'
;
// TODO
raiseLevel : /* EMPTY */ | K_EXCEPTION | K_WARNING | K_NOTICE | K_INFO | K_LOG | K_DEBUG ;
raise_expr : a_expr;
loop_body: proc_sect END_P K_LOOP opt_label ';'
;
// TODO
// can not reuse SQL rule stmt because it has an empty alternative
// TODO check if ';' is correct
stmt_execsql: alterDatabaseStmt
| alterDatabaseSetStmt
| alterDefaultPrivilegesStmt
| alterDomainStmt
| alterEnumStmt
| alterExtensionStmt
| alterExtensionContentsStmt
| alterFdwStmt
| alterForeignServerStmt
| alterForeignTableStmt
| alterFunctionStmt
| alterGroupStmt
| alterObjectSchemaStmt
| alterOwnerStmt
| alterSeqStmt
| alterTableStmt
| alterCompositeTypeStmt
| alterRoleSetStmt
| alterRoleStmt
| alterTSConfigurationStmt
| alterTSDictionaryStmt
| alterUserMappingStmt
| alterUserSetStmt
| alterUserStmt
| analyzeStmt
| checkPointStmt
| closePortalStmt
| clusterStmt
| commentStmt
| constraintsSetStmt
| copyStmt
| createAsStmt
| createAssertStmt
| createCastStmt
| createConversionStmt
| createDomainStmt
| createExtensionStmt
| createFdwStmt
| createForeignServerStmt
| createForeignTableStmt
| createFunctionStmt
| createGroupStmt
| createOpClassStmt
| createOpFamilyStmt
| alterOpFamilyStmt
| createPLangStmt
| createSchemaStmt
| createSeqStmt
| createStmt
| createTableSpaceStmt
| createTrigStmt
| createRoleStmt
| createUserStmt
| createUserMappingStmt
| createdbStmt
| deallocateStmt
| declareCursorStmt
| defineStmt
| deleteStmt
| discardStmt
| doStmt
| dropAssertStmt
| dropCastStmt
| dropFdwStmt
| dropForeignServerStmt
| dropGroupStmt
| dropOpClassStmt
| dropOpFamilyStmt
| dropOwnedStmt
| dropPLangStmt
| dropRuleStmt
| dropStmt
| dropTableSpaceStmt
| dropTrigStmt
| dropRoleStmt
| dropUserStmt
| dropUserMappingStmt
| dropdbStmt
| executeStmt
| explainStmt
| fetchStmt
| grantStmt
| grantRoleStmt
| indexStmt
| insertStmt
| listenStmt
| loadStmt
| lockStmt
| notifyStmt
| prepareStmt
| reassignOwnedStmt
| reindexStmt
| removeAggrStmt
| removeFuncStmt
| removeOperStmt
| renameStmt
| revokeStmt
| revokeRoleStmt
| ruleStmt
| secLabelStmt
| selectStmt
| transactionStmt
| truncateStmt
| unlistenStmt
| updateStmt
| vacuumStmt
| variableResetStmt
| variableSetStmt
| variableShowStmt
| viewStmt
;
// TODO
stmt_dynexecute: K_EXECUTE a_expr usingClause? (INTO target=IDENT)? ';'
;
usingClause : USING '(' usingClauseArgumentsList ')'
| USING usingClauseArgumentsList
;
usingClauseArgumentsList : usingClauseArgument (',' usingClauseArgument)*
;
usingClauseArgument : stmt_assign | any_identifier
;
stmt_open: K_OPEN cursor_variable (K_NO? K_SCROLL)? FOR select_clause
| K_OPEN cursor_variable (K_NO? K_SCROLL)? FOR K_EXECUTE queryString=SCONST usingClause?
| K_OPEN cursor_variable '(' cursorArgumentsList ')'
| K_OPEN cursor_variable
;
cursorArgumentsList: cursorArgument (',' cursorArgument)*
;
cursorArgument : IDENT
;
stmt_fetch: K_FETCH opt_fetch_direction cursor_variable INTO target=IDENT ';'
;
stmt_move: K_MOVE opt_fetch_direction cursor_variable ';'
;
// TODO
opt_fetch_direction: | K_FORWARD | K_BACKWARD
;
stmt_close: K_CLOSE cursor_variable ';'
;
stmt_null: NULL_P ';'
;
cursor_variable: IDENT
;
// TODO wrong generation? empty was missing
exception_sect: K_EXCEPTION proc_exceptions a_expr
| K_EXCEPTION proc_exceptions
|
;
proc_exceptions: proc_exceptions proc_exception
| proc_exception
;
proc_exception: WHEN proc_conditions THEN proc_sect
;
proc_conditions: proc_conditions OR proc_condition
| proc_condition
;
proc_condition: IDENT sqlState=SCONST
| any_identifier
;
//proc_condition: K_SQLSTATE sqlState=SCONST
// | any_identifier
// ;
expr_until_semi: any_identifier
| a_expr ';'
| opt_distinct target_list from_clause where_clause ';' // TODO
;
expr_until_rightbracket: a_expr ']' // TODO
;
expr_until_then: a_expr THEN // TODO
;
expr_until_loop: a_expr K_LOOP // TODO
;
opt_block_label: LESS_LESS any_identifier GREATER_GREATER
|
;
opt_label: any_identifier
|
;
opt_exitcond: ';'
| WHEN expr_until_semi
;
// FIXME
any_identifier: qualified_name
| unreserved_keyword
| IDENT // TODO
;
|
ASM/INCLUDE/FloatToStr.asm | mhoellerschlieper/CubeOS.Compiler | 11 | 25827 | ;Quelle: http://www.masm32.com/board/index.php?topic=9906.0
;
; SEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
; 10000000000000000000000000000000 00000000000000000000000000000000
; 01111111111100000000000000000000 00000000000000000000000000000000
; 00000000000011111111111111111111 11111111111111111111111111111111
; 100000000000000000000 00000000000000000000000000000000 ; implied
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
R8_BIAS equ 1023
R8_MANT equ 52
R8ToStr proc r8:REAL8, lpBuffer:PTR
push ebp
push esi
push edi
push ebx
locals = 32+3*4
tmpbuff equ <[esp]>
iTrail equ <dword ptr [esp+32]>
iExp equ <dword ptr [esp+32+4]>
nSign equ <dword ptr [esp+32+4+4]>
add esp,-locals
mov ecx,10000000000000000000000000000000b
mov ebx,[esp+2*4][4*4][locals]
mov esi,[esp+1*4][4*4][locals]
and ecx,ebx; sign bit
and ebx,not 10000000000000000000000000000000b
mov nSign,ecx
mov edi,ebx
shr ebx,20; 01111111111100000000000000000000
and edi,00000000000011111111111111111111b
cmp ebx,11111111111b
je @@_NaN_Infinity
mov eax,esi
or eax,edi
or eax,ebx
jz @@Zero
sub ebx,R8_BIAS; exponent
or edi,00000000000100000000000000000000b; high 20 bits + 1 implied
xor ebp,ebp
mov iExp,ebx
;; 52bits in edi::esi
.if sdword ptr ebx > 63
shld edi,esi,63-R8_MANT
shl esi,63-R8_MANT
.repeat
call __div10
; mod 10
lea ecx,[eax*4+eax]
add ecx,ecx
sub esi,ecx
bsr ecx,edx
neg ecx
add ecx,31
shld edx,eax,cl
shl eax,cl
mov ebx,iExp
sub ebx,ecx
or esi,eax
mov edi,edx
mov iExp,ebx
add ebp,1
.until sdword ptr ebx <= 63
mov ecx,63
sub ecx,ebx
shrd esi,edi,cl
shr edi,cl
.else
.while sdword ptr ebx < R8_MANT
.while ! (edi & 0F0000000h)
mov eax,esi
mov edx,edi
shld edi,esi,2
shl esi,2
add esi,eax
adc edi,edx
add ebx,1
dec ebp
.endw
bsr ecx,edi
sub ecx,31-4
sbb edx,edx
not edx
and ecx,edx
shrd esi,edi,cl
shr edi,cl
add ebx,ecx
.endw
lea ecx,[ebx-R8_MANT]
shld edi,esi,cl
shl esi,cl
.endif
; mov edx,nSign
; pushad
; shr edx,1
; sbb edx,edx
; and edx,'-'-'+'
; add edx,'+'
; invoke printf,T("%c%I64u.0e%i",13,10),edx,edi::esi,ebp
; popad
; job done, now just the hard part - formating
;; adjust number to 16 digits 2386F26FC0FFFFh
.while edi >= 2386F2h; LOW = 6FC0FFFF
.break .if edi == 2386F2h && esi < 6FC0FFFFh
call __div10
mov esi,eax
mov edi,edx
add ebp,1;; increase exponent
.endw
;; round it if needed (if 16 digit) 38D7EA4C67FFFh
.if edi>=38D7Eh;A4C67FFF
.if ! (edi == 38D7Eh && esi < 0A4C67FFFh)
add esi,5
adc edi,0
call __div10
add ebp,1; increase exponent
mov esi,eax
mov edi,edx
.endif
.endif
mov iExp,ebp
;; trailing zero count
xor ebp,ebp
jmp @F
.repeat
mov esi,eax
mov edi,edx
add ebp,1
@@: call __div10
lea ecx,[eax*4+eax]
neg ecx
add ecx,ecx
add ecx,esi
.until !zero?
mov iTrail,ebp
xor ebp,ebp
jmp @F
.repeat
call __div10
@@: lea ecx,[eax*4+eax]
neg ecx
lea ecx,[ecx*2+esi+'0']
mov tmpbuff[ebp],cl
add ebp,1
mov esi,eax
mov edi,edx
or eax,edx
.until zero?
mov ecx,nSign
mov esi,[esp+3*4][4*4][locals]
add ecx,ecx
mov edx,'-'
mov edi,iExp; exp
sbb ecx,ecx
and edx,ecx
mov [esi],dl
sub esi,ecx
add edi,iTrail
xchg esi,ebp
.if zero?;; exponent is 0
.repeat
mov al,tmpbuff[esi-1]
mov [ebp],al
add ebp,1
sub esi,1
.until zero?
.elseif (sdword ptr edi >=-15 && sdword ptr edi < 0)
;; check for format without exp
add edi,esi
.if sdword ptr edi <= 0
mov [ebp],word ptr '.0'
add ebp,2
.while sdword ptr edi < 0
mov [ebp],byte ptr '0'
add ebp,1
add edi,1
.endw
.repeat
mov al,tmpbuff[esi-1]
mov [ebp],al
add ebp,1
sub esi,1
.until zero?
.else
.repeat
mov al,tmpbuff[esi-1]
mov [ebp],al
add ebp,1
sub edi,1
.if zero?
mov [ebp],byte ptr '.'
add ebp,1
.endif
sub esi,1
.until zero?
.endif
.else
;
mov al,tmpbuff[esi-1]
mov [ebp],al
add ebp,1
sub esi,1
jz @F
mov [ebp],byte ptr '.'
add ebp,1
.repeat
mov al,tmpbuff[esi-1]
mov [ebp],al
add ebp,1
add edi,1
sub esi,1
.until zero?
@@:
mov [ebp],byte ptr 'e'
add ebp,1
mov eax,edi
cdq
and edx,'-'-'+'
add edx,'+'
mov [ebp],dl
add ebp,1
; abs
cdq
xor eax,edx
sub eax,edx
mov edi,0CCCCCCCDh; magic
mov ecx,eax
mul edi
shr edx,3
lea ebx,[edx*4+edx]
neg ebx
lea ebx,[ebx*2+ecx+'0']
mov eax,edx
.if edx
mov ecx,eax
mul edi
shr edx,3
lea esi,[edx*4+edx]
neg esi
lea esi,[esi*2+ecx+'0']
mov eax,edx
.if edx
mov ecx,eax
mul edi
shr edx,3
lea eax,[edx*4+edx]
neg eax
lea eax,[eax*2+ecx+'0']
mov [ebp],al
add ebp,1
.endif
mov eax,esi
mov [ebp],al
add ebp,1
.endif
mov [ebp],bl
add ebp,1
.endif
@@Done:
mov byte ptr [ebp],0
mov eax,ebp
sub eax,[esp+3*4][4*4][locals]
add esp,locals
pop ebx
pop edi
pop esi
pop ebp
ret 3*4
@@_NaN_Infinity:
mov ecx,nSign
mov ebp,[esp+3*4][4*4][locals]
add ecx,ecx
mov edx,'-'
sbb ecx,ecx
and edx,ecx
mov [ebp],dl
sub ebp,ecx
mov dword ptr [ebp],'#.1'
mov eax,edi
or eax,esi
.if !eax
mov eax,'FNI'
mov [ebp+3],eax
add ebp,6
.elseif edi & 10000000000000000000b
mov eax,'NANQ'
mov [ebp+3],eax
add ebp,7
.elseif ! (edi & 10000000000000000000b)
mov eax,'NANS'
mov [ebp+3],eax
add ebp,7
.else
mov eax,'DNI'
mov [ebp+3],eax
add ebp,6
.endif
jmp @@Done
@@_Subnormal:
mov ebp,[esp+3*4][4*4][locals]
mov dword ptr [ebp],'!RRE'
add ebp,4
jmp @@Done
@@Zero:
mov ebp,[esp+3*4][4*4][locals]
mov byte ptr [ebp],'0'
add ebp,1
jmp @@Done
;; div <edi::esi> by 10
;; ret <edx::eax>
align 8
__div10:
; div 10
mov eax,0CCCCCCCDh; = b0
mul esi; get a0*b0 = d1:d0
mov ecx,edx;d1
mov eax,0CCCCCCCDh; = b0
xor ebx,ebx
mul edi; get a1*b0 = e1:e0
add ecx,eax;e0
adc ebx,edx;e1
mov eax,0CCCCCCCCh; =b1
mul esi; get a0*b1 = f1:f0
add ecx,eax;f0
adc ebx,edx;f1
mov ecx,0
mov eax,0CCCCCCCCh; =b1
adc ecx,ecx
mul edi; get a1*b1 = g1:g0
add eax,ebx;g0
adc edx,ecx;g1
shrd eax,edx,3
shr edx,3;;------ quotient in edx::eax
retn
R8ToStr endp
|
oeis/054/A054099.asm | neoneye/loda-programs | 11 | 172609 | ; A054099: Sum{T(n,k): k=0,1,...,n}, array T as in A054098.
; Submitted by <NAME>
; 1,3,6,14,44,178,892,5354,37480,299842,2698580,26985802,296843824,3562125890,46307636572,648306912010,9724603680152,155593658882434,2645092201001380
lpb $0
sub $0,1
add $1,$3
mul $1,$2
cmp $3,0
add $3,1
add $1,$3
add $2,1
lpe
mov $0,$1
add $0,1
|
mastersystem/zxb-sms-2012-02-23/zxb-sms/wip/zxb/library-asm/strlen.asm | gb-archive/really-old-stuff | 10 | 6208 | ; Returns len if a string
; If a string is NULL, its len is also 0
; Result returned in HL
__STRLEN: ; Direct FASTCALL entry
ld a, h
or l
ret z
ld a, (hl)
inc hl
ld h, (hl) ; LEN(str) in HL
ld l, a
ret
|
examples/qsolver.asm | Mogby/Processor | 2 | 86918 | ; start of program
main:
read
popr 0
read
popr 1
read
popr 2 ; ; v[0] = a, v[1] = b, v[2] = c
push qsolver
call ; ; v[0] = root1, v[1] = root2, v[2] = num_roots
pushr 2
push 0
push no_roots
je
pushr 2
push -1
push inf_roots
je
pushr 2
push 1
push finish
jg ; exit if num_roots = 0
pushr 1
pushr 2 ; root2 num_roots ; v[0] = root1
push write_real
call
push 2
push finish ; root2 num_roots 2 finish
jg ; exit if num_roots = 1
popr 0
push write_real
call
push finish
jmp
; qsolver function
qsolver: ; ; v[0] = a, v[1] = b, v[2] = c
pushr 0
push 0
push linsolver ; a 0 linsolver
je
push 4
pushr 0
mul
pushr 2
mul ; 4ac
pushr 1
pushr 1
mul ; 4ac b^2
sub ; b^2-4ac
dup
popr 3 ; b^2-4ac ; v[0] = a, v[1] = b, v[2] = c, v[3] = b^2-4ac
push 0
push has_roots ; b^2-4ac 0 one_root
jle
push 0
popr 2
ret ; no roots
has_roots: ; ; v[0] = a, v[1] = b, v[2] = c, v[3] = b^2-4ac
pushr 3
push 100
mul
sqrt
popr 3 ; ; v[0] = a, v[1] = b, v[2] = c, v[3] = 10*sqrt(b^2-4ac)
pushr 3
push 0
push one_root
je
pushr 3
push 0
push two_roots
jl
push 0
popr 2 ; ; v[2] = 0
ret
one_root: ; ; v[0] = a, v[1] = b, v[2] = c, v[3] = 10*sqrt(b^2-4ac)
pushr 0
push -5
pushr 1
mul
div
popr 0
push 1
popr 2 ; ; v[0] = -10b/(2a) = -5b/a, v[2] = 1
ret
two_roots: ; ; v[0] = a, v[1] = b, v[2] = c, v[3] = 10*sqrt(b^2-4ac)
pushr 0
dup
push 2
pushr 3
div
push -5
pushr 1 ; a a 5*sqrt(b^2-4ac) -5b
mul
sub
div
popr 0 ; a ; v[0] = root1, v[1] = b, v[2] = c, v[3] = 10*sqrt(b^2-4ac)
push -2
pushr 3
div
push -5
pushr 1
mul
sub
div
popr 1 ; ; v[0] = root1, v[1] = root2
push 2
popr 2
ret
linsolver: ; ; v[0] = 0, v[1] = b, v[2] = c
pushr 1
push 0
push linsolver_b0
je
pushr 1
pushr 2
push 10
mul ; b 10*c
div ; 10*c/b
push -1
mul ; -10*c/b
popr 0 ; ; v[0] = -10*c/b
push 1
popr 2
ret
linsolver_b0: ; ; v[0] = 0, v[1] = 0, v[2] = c
pushr 2
push 0
push linsolver_b0_c0
je
push 0
popr 2
ret
linsolver_b0_c0: ; ; v[0] = 0, v[1] = 0, v[2] = 0
push -1
popr 2
ret
; write_real function
write_real: ; ; v[0] = num
push 0
pushr 0
push write_real_ge0
jge
push 45
writech ; '-' sign
pushr 0
push -1
mul
popr 0 ; ; v[0] = -num
write_real_ge0: ; ; v[0] = num, num >= 0
push 10
pushr 0
div
write ; integer part
push 46
writech ; decimal point
push 10
pushr 0
mod
write ; digit after point
push 10
writech ; break line
ret
no_roots:
push 101 ; 'e'
push 110 ; 'n'
push 111 ; 'o'
push 110 ; 'n'
writech
writech
writech
writech ; 'none'
push 10
writech ; break line
push finish
jmp
inf_roots:
push 102 ; 'f'
push 110 ; 'n'
push 105 ; 'i'
writech
writech
writech ; 'inf'
push 10
writech ; break line
push finish
jmp
; end of program
finish: |
pkgs/tools/yasm/src/libyasm/tests/timesover-err.asm | manggoguy/parsec-modified | 2,151 | 161142 | times 512 db 0
times 01FEh-($-$$) db 0
|
programs/yotta.asm | CH-Electronics/chos | 0 | 23650 | <reponame>CH-Electronics/chos<filename>programs/yotta.asm
bits 16
org 32768
%include 'mikedev.inc'
; Key code values with BIOS (using scan code set 1)
%define UP_KEYCODE 0x48E0
%define DOWN_KEYCODE 0x50E0
%define LEFT_KEYCODE 0x4BE0
%define RIGHT_KEYCODE 0x4DE0
%define INSERT_KEYCODE 0x52E0
%define DELETE_KEYCODE 0x53E0
%define HOME_KEYCODE 0x47E0
%define END_KEYCODE 0x4FE0
%define PAGEUP_KEYCODE 0x49E0
%define PAGEDOWN_KEYCODE 0x51E0
; BASIC programs can still use this as whilst running.
%define variables_tmp 65000
%define filename_tmp 65052
%define parameters_tmp 65065
code_start:
; Launcher code --- Starts the control section (BASIC part)
; Uses BASIC/Assembly hybrid
run_main:
mov word ax, program_start
mov word bx, program_end
sub bx, ax
call os_run_basic
call os_show_cursor
cmp byte [exit_code], 2
je run_basic
cmp byte [exit_code], 1
je crash
ret
; BASIC runner --- Little bit tricky, loads the BASIC program immediately after
; it, overwriting most of the editor and original code location to maximize
; memory available, then reloads everything. Completely fine, just don't rename
; the editor binary.
run_basic:
mov si, [p1]
mov di, .filename
mov cx, 13
rep movsb
mov si, [p2]
mov di, .variables
mov cx, 26
rep movsw
call os_clear_screen
mov ax, .filename
mov cx, basic_load_area
call os_load_file
jc crash
mov ax, basic_load_area
mov si, .parameters
call os_run_basic
mov si, .finished_msg
call os_print_string
call os_wait_for_key
mov si, .filename
mov di, filename_tmp
mov cx, 13
rep movsb
mov si, .variables
mov di, variables_tmp
mov cx, 26
rep movsw
mov si, .parameters
mov di, parameters_tmp
mov cx, 128
rep movsw
mov si, .reload_msg
call os_print_string
mov ax, .editor_filename
mov cx, code_start
call os_load_file
jc crash
mov si, filename_tmp
mov di, .filename
mov cx, 13
rep movsb
mov si, variables_tmp
mov di, .variables
mov cx, 26
rep movsw
mov si, parameters_tmp
mov di, .parameters
mov cx, 128
rep movsw
mov word [cmd], .variables
mov byte [exit_code], 2
mov si, .filename
jmp run_main
ret
.filename times 13 db 0
.editor_filename db 'YOTTA.BIN', 0
.variables times 26 dw 0
.parameters times 128 db 0
.finished_msg db '>>> BASIC Program Finished, press any key to continue...', 13, 10, 0
.reload_msg db 'Reloading the editor...', 0
basic_load_area:
; Crash handler --- The program crash indicator should be zero if the program
; ended successfully, otherwise assume the control section (BASIC part) messed
; up somehow.
crash:
call os_wait_for_key
call os_clear_screen
mov si, crash_msg
call os_print_string
ret
crash_msg db "Yotta has crashed :(", 13, 10
db 'You can report this bug by putting a bug report on the MikeOS Forum or email:'
db 13, 10, '<EMAIL>', 13, 10, 0
; A whole heap of commands that make up the command section. Can be called by
; the control section, see 'doc/registers.txt' for the information on the
; calling procedure and 'doc/command.txt' for information on commands and
; parameters involved.
phase_cmd:
mov word ax, [cmd]
cmp ax, 0
je insert_bytes_cmd
cmp ax, 1
je remove_bytes_cmd
cmp ax, 2
je search_cmd
cmp ax, 3
je draw_cmd
cmp ax, 4
je set_filename
cmp ax, 5
je set_caption
cmp ax, 6
je input_caption
cmp ax, 7
je set_basic_parameters
cmp ax, 8
je render_text
cmp ax, 9
je set_modified
cmp ax, 10
je clear_text_area
cmp ax, 11
je shift_right_text
cmp ax, 12
je shift_left_text
cmp ax, 13
je ask_caption
cmp ax, 14
je get_help
cmp ax, 17
je read_key
cmp ax, 18
je scroll_up
cmp ax, 19
je scroll_down
cmp ax, 20
je set_text_limits
ret
insert_bytes_cmd:
; IN: p1 = location, p2 = bytes to insert
mov si, [text_end]
mov di, si
add di, [p2]
mov cx, si
inc cx
sub cx, [p1]
cmp cx, 0
je .skip_move
std
rep movsb
cld
.skip_move:
mov ax, [p2]
add [text_end], ax
ret
remove_bytes_cmd:
; IN: p1 = location, p2 = bytes to remove
mov di, [p1]
mov si, di
add si, [p2]
mov cx, [text_end]
inc cx
sub cx, si
cmp cx, 0
je .skip_move
rep movsb
.skip_move:
mov ax, [p2]
sub [text_end], ax
ret
draw_cmd:
call os_clear_screen
mov dx, 0000h
call os_move_cursor
mov bl, 070h
mov dh, 00h
mov dl, 00h
mov si, 50h
mov di, 01h
call os_draw_block
mov si, name_and_version
call os_print_string
mov dh, 23
mov dl, 0
call os_move_cursor
mov ah, 09h
mov al, 20h
mov bh, 00h
mov bl, 07h
mov cx, 0F0h
int 10h
mov word si, key_strings
mov cx, 12
.print_shortcuts:
push cx
mov ah, 09h
mov al, 20h
mov bh, 00h
mov bl, 070h
mov cx, 2
int 10h
call os_print_string
add si, 14
pop cx
loop .print_shortcuts
ret
key_strings db '^G Get Help ', 0
db '^O WriteOut ', 0
db '^R Read File ', 0
db '^Y Prev Page ', 0
db '^K Cut Text ', 0
db '^C Cur Pos ', 13, 10, 0
db '^X Exit ', 0
db '^Z Run BASIC ', 0
db '^W Where Is ', 0
db '^V Next Page ', 0
db '^U PasteText ', 0
db '^J Copy Text ', 0
name_and_version db 'yotta 1.03x10^25', 0
set_filename:
; IN: p1 = filename (blank for none)
mov si, [p1]
lodsb
cmp al, 0
je .blank
mov ax, [p1]
call os_string_length
add ax, 6
shr ax, 1
mov bx, 40
sub bx, ax
mov dh, 0
mov dl, bl
call os_move_cursor
mov si, file_word
call os_print_string
add dl, 6
call os_move_cursor
mov si, [p1]
call os_print_string
ret
.blank:
mov dh, 0
mov dl, 35
call os_move_cursor
mov si, no_file_word
call os_print_string
ret
no_file_word db 'New Buffer', 0
file_word db 'File: ', 0
set_caption:
; IN: p1 = caption
mov dh, 22
mov dl, 0
call os_move_cursor
mov ah, 09h
mov al, 0
mov bh, 0
mov bl, 7
mov cx, 80
int 10h
mov ax, [p1]
call os_string_length
cmp ax, 0
je .done
add ax, 4
shr ax, 1
mov bx, 40
sub bx, ax
mov dh, 22
mov dl, bl
call os_move_cursor
mov ax, [p1]
call os_string_length
add ax, 4
mov cx, ax
mov ah, 09h
mov al, 20h
mov bh, 0
mov bl, 112
int 10h
mov si, opening_bracket
call os_print_string
add dl, 2
call os_move_cursor
mov si, [p1]
call os_print_string
mov ax, [p1]
call os_string_length
add dl, al
call os_move_cursor
mov si, closing_bracket
call os_print_string
.done:
ret
opening_bracket db '[ ', 0
closing_bracket db ' ]', 0
input_caption:
; IN: p1 = prompt, p2 = input buffer
mov dh, 22
mov dl, 0
call os_move_cursor
mov ah, 09h
mov al, 20h
mov bh, 0
mov bl, 070h
mov cx, 80
int 10h
mov word si, [p1]
call os_print_string
mov word ax, [p1]
call os_string_length
mov dl, al
call os_move_cursor
call os_show_cursor
mov word ax, [p2]
call os_input_string
call os_hide_cursor
mov dl, 0
call os_move_cursor
mov ah, 09h
mov al, 20h
mov bh, 0
mov bl, 7
mov cx, 80
int 10h
ret
set_basic_parameters:
; IN: p1 = parameter string pointer
mov si, [p1]
mov di, run_basic.parameters
call os_string_copy
ret
ask_caption:
; IN: p1 = prompt, p2 = answer (Y/N/C = 0/1/2)
mov dh, 22
mov dl, 0
call os_move_cursor
mov ah, 09h
mov al, 20h
mov bh, 0
mov bl, 070h
mov cx, 80
int 10h
mov word si, [p1]
call os_print_string
mov word ax, [p1]
call os_string_length
mov dl, al
call os_move_cursor
mov word si, .ask_prompt
call os_print_string
.get_key:
call os_wait_for_key
cmp al, 'Y'
je .yes
cmp al, 'y'
je .yes
cmp al, 13
je .yes
cmp al, 'N'
je .no
cmp al, 'n'
je .no
cmp al, 'C'
je .cancel
cmp al, 'c'
je .cancel
cmp al, 27
je .cancel
jmp .get_key
.yes:
mov word [p2], 0
jmp .finished
.no:
mov word [p2], 1
jmp .finished
.cancel:
mov word [p2], 2
.finished:
mov dl, 0
call os_move_cursor
mov ah, 09h
mov al, 20h
mov bh, 0
mov bl, 7
mov cx, 80
int 10h
ret
.ask_prompt db '(Y)es/(N)o/(C)ancel', 0
render_text:
; IN: p1 = line offset, p2 = start line, p3 = total lines
cmp word [p1], 0
je .finish
mov word si, [p1]
mov dh, [p2]
mov dl, 0
mov ah, 9
mov bh, 0
mov bl, 7
mov cx, 1
cmp si, [text_start]
jl .finish
cmp si, [text_end]
jge .finish
add [p3], dh
.text_loop:
lodsb
call os_move_cursor
; cmp al, 09h
; je .tab
cmp al, 0Ah
je .line_feed
int 10h
inc dl
.check_limits:
cmp dh, [p3]
jge .finish
cmp word si, [text_end]
jg .finish
cmp dl, 80
jge .line_overflow
jmp .text_loop
.newline:
inc dh
mov dl, 0
jmp .check_limits
.line_overflow:
mov al, '$'
int 10h
.skip_remaining:
lodsb
cmp al, 0Ah
je .newline
jmp .skip_remaining
.line_feed:
mov al, 0FFh
int 10h
jmp .newline
.finish:
ret
set_modified:
; IN: p1 = modified on/off
mov dh, 0
mov dl, 72
call os_move_cursor
cmp word [p1], 0
je .remove_modified
.set_modified:
mov si, modified_word
call os_print_string
ret
.remove_modified:
mov si, blank_word
call os_print_string
ret
modified_word db 'Modified', 0
blank_word db ' ', 0
clear_text_area:
mov dh, 2
mov dl, 0
call os_move_cursor
mov ah, 09h
mov al, 0h
mov bh, 00h
mov bl, 07h
mov cx, 1600
int 10h
ret
shift_right_text:
; IN: p1 = column, p2 = row
mov word ax, [p1]
mov cl, al
mov word ax, [p2]
mov dh, al
call os_move_cursor
cmp cl, 78
jge .finished
mov bh, 0
mov dl, 77
call os_move_cursor
.move_loop:
mov ah, 08h
int 10h
inc dl
call os_move_cursor
mov ah, 0Eh
int 10h
dec dl
cmp dl, cl
je .finished
dec dl
call os_move_cursor
jmp .move_loop
.finished:
ret
shift_left_text:
; IN: p1 = column, p2 = row
mov word ax, [p1]
mov dl, al
mov word ax, [p2]
mov dh, al
mov bh, 0
inc dl
call os_move_cursor
.move_loop:
mov ah, 08h
int 10h
dec dl
call os_move_cursor
mov ah, 0Eh
int 10h
add dl, 2
cmp dl, 78
jg .finished
call os_move_cursor
jmp .move_loop
.finished:
mov dl, 78
call os_move_cursor
mov ah, 0Eh
mov al, 0
int 10h
ret
get_help:
call clear_text_area
mov dl, 0
mov dh, 2
call os_move_cursor
mov si, help_text_1
call os_print_string
mov si, help_text_system
mov ax, code_start
call print_buffer_size
mov si, help_text_program
mov ax, [p1]
sub ax, code_start
call print_buffer_size
mov si, help_text_file
mov ax, [p2]
sub ax, [p1]
call print_buffer_size
mov si, help_text_free
mov ax, 0
sub ax, [p2]
call print_buffer_size
call next_screen_delay
mov si, help_text_2
call os_print_string
call next_screen_delay
mov si, help_text_3
call os_print_string
call next_screen_delay
ret
; SI = message, AX = size (bytes)
print_buffer_size:
call os_print_string
mov bx, ax
call os_int_to_string
mov si, ax
call os_print_string
mov si, help_text_bytes
call os_print_string
cmp bx, 1
je .onebyte
mov ah, 0x0E
mov al, 's'
mov bh, 0
int 10h
.onebyte:
call os_print_newline
ret
next_screen_delay:
call os_print_newline
mov si, help_text_wait
call os_print_string
call os_wait_for_key
call clear_text_area
ret
help_text_1:
db 'yotta: a nano clone for MikeOS', 13, 10
db 'Version 1.03x10^25', 13, 10
db 'Copyright (C) <NAME> 2015', 13, 10
db 'Licenced under the GNU GPL v3', 13, 10
db 'Email: <EMAIL>', 13, 10
db 13, 10
db 'Memory Usage', 13, 10
db '============', 13, 10
db 'Total: 65536 bytes', 13, 10, 0
help_text_system db 'System: ', 0
help_text_program db 'Program: ', 0
help_text_file db 'File: ', 0
help_text_free db 'Free: ', 0
help_text_bytes db ' byte', 0
help_text_wait db 'Press any key to continue...', 0
help_text_2:
db 'Key Combinations:', 13, 10
db 13, 10
db '^A Start of Line', 13, 10
db '^B Previous Character', 13, 10
db '^C Cursor Position', 13, 10
db '^D Delete Character', 13, 10
db '^E End of Line', 13, 10
db '^F Next Character', 13, 10
db '^G Display this help', 13, 10
db '^H Backspace', 13, 10
db '^I Goto Line', 13, 10
db '^J Copy Text', 13, 10
db '^K Cut Text', 13, 10
db '^L Redraw Screen', 13, 10
db '^M New Line', 13, 10
db '^N Next Line', 13, 10
db '^O Write File', 13, 10
db '^P Previous Line', 13, 10, 0
help_text_3:
db '^Q End of File', 13, 10
db '^R Read File', 13, 10
db '^S Start of File', 13, 10
db '^T Set BASIC parameters', 13, 10
db '^U Paste Text', 13, 10
db '^V Next Page', 13, 10
db '^W Search Text', 13, 10
db '^X Exit', 13, 10
db '^Y Previous Page', 13, 10
db '^Z Run BASIC program', 13, 10, 0
read_key:
call os_wait_for_key
mov bx, ax
call flush_key_buffer
mov ax, bx
cmp ax, UP_KEYCODE
je .up_key
cmp ax, DOWN_KEYCODE
je .down_key
cmp ax, LEFT_KEYCODE
je .left_key
cmp ax, RIGHT_KEYCODE
je .right_key
cmp ax, INSERT_KEYCODE
je .insert_key
cmp ax, DELETE_KEYCODE
je .delete_key
cmp ax, HOME_KEYCODE
je .home_key
cmp ax, END_KEYCODE
je .end_key
cmp ax, PAGEUP_KEYCODE
je .pageup_key
cmp ax, PAGEDOWN_KEYCODE
je .pagedown_key
and ax, 0x00FF
.done:
mov [p1], ax
ret
.up_key:
mov ax, 0x80
je .done
.down_key:
mov ax, 0x81
je .done
.left_key:
mov ax, 0x82
je .done
.right_key:
mov ax, 0x83
je .done
.insert_key:
mov ax, 0x84
je .done
.delete_key:
mov ax, 0x7F
je .done
.home_key:
mov ax, 0x85
je .done
.end_key:
mov ax, 0x86
je .done
.pageup_key:
mov ax, 0x87
je .done
.pagedown_key:
mov ax, 0x88
je .done
flush_key_buffer:
mov ah, 0x11
int 0x16
jz .done
mov ax, 0x10
int 0x16
jmp flush_key_buffer
.done:
ret
search_cmd:
; IN: p1 = file start, p2 = file length, p3 = search term
; OUT: p1 = 0/1 for no match/match, p2 = match pointer, p3 = lines skipped
mov di, [p1]
mov dx, [p2]
mov si, [p3]
mov word [.nl_count], 0
mov ax, si
call os_string_uppercase
call os_string_length
mov bx, ax
mov ah, [si]
.find_match:
cmp dx, 0
je .no_match
dec dx
mov al, [di]
inc di
cmp al, 10
je .newline
cmp al, ah
jne .find_match
push di
dec di
mov si, [p3]
mov cx, bx
.check_match:
cmp cx, 0
je .found_match
dec cx
mov ah, [si]
mov al, [di]
inc si
inc di
cmp al, 'a'
jl .check_char
cmp al, 'z'
jg .check_char
sub al, 0x20
.check_char:
cmp al, ah
je .check_match
.bad_match:
pop di
jmp .find_match
.newline:
inc word [.nl_count]
jmp .find_match
.found_match:
pop di
dec di
mov word [p1], 1
mov [p2], di
mov ax, [.nl_count]
mov [p3], ax
ret
.no_match:
mov word [p1], 0
ret
.nl_count dw 0
scroll_up:
; P1 = first line offset, P2 = lines to scroll
; P1 = new offset, P2 = actual lines scrolled
mov si, [p1]
mov cx, [p2]
inc cx
.find_nl:
cmp si, [text_start]
jle .stopped
dec si
mov al, [si]
cmp al, 10
jne .find_nl
.found_nl:
dec cx
cmp cx, 0
jne .find_nl
inc si
mov ax, [p2]
mov [.lines_scrolled], ax
.scroll:
mov [.new_offset], si
cmp word [.lines_scrolled], 20
jge .redraw
mov ah, 0x07
mov al, [.lines_scrolled]
mov bh, 7
mov ch, 2
mov cl, 0
mov dh, 21
mov dl, 79
int 0x10
.render:
mov [p1], si
mov ax, [p2]
mov word [p2], 2
mov word [p3], ax
call render_text
mov ax, [.new_offset]
mov [p1], ax
mov ax, [.lines_scrolled]
mov [p2], ax
ret
.stopped:
dec cx
mov ax, [p2]
sub ax, cx
mov [.lines_scrolled], ax
jmp .scroll
.redraw:
mov word [p2], 20
jmp .render
.lines_scrolled dw 0
.new_offset dw 0
scroll_down:
; IN: P1 = screen start, P2 = lines to scroll
; OUT: P1 = new screen start, P2 = lines scrolled, P3 = first new line
mov si, [p1]
mov cx, [p2]
call find_forward_line
mov [.lines_scrolled], cx
mov [.new_position], si
cmp cx, 20
jge .redraw
mov di, 22
sub di, [.lines_scrolled]
mov ah, 0x06
mov al, [.lines_scrolled]
mov bh, 7
mov ch, 2
mov cl, 0
mov dh, 21
mov dl, 79
int 0x10
mov si, [.new_position]
mov cx, di
sub cx, 2
call find_forward_line
mov [.first_new_line], si
mov [p1], si
mov [p2], di
mov ax, [.lines_scrolled]
mov [p3], ax
.render:
call render_text
mov ax, [.new_position]
mov [p1], ax
mov ax, [.lines_scrolled]
mov [p2], ax
mov ax, [.first_new_line]
mov [p3], ax
ret
.cancel:
mov word [p2], 0
mov ax, [p1]
mov [p3], ax
ret
.redraw:
mov word [p2], 2
mov word [p3], 20
jmp .render
.lines_scrolled dw 0
.new_position dw 0
.first_new_line dw 0
; IN: SI = start, CX = lines to skip
; OUT: SI = new position, CX = lines skipped
find_forward_line:
push ax
push bx
push dx
mov dx, cx
mov bx, [text_end]
.find_nl:
cmp si, bx
jge .cancel
lodsb
cmp al, 10
jne .find_nl
.found_nl:
dec cx
cmp cx, 0
jne .find_nl
.cancel:
sub dx, cx
xchg dx, cx
pop dx
pop bx
pop ax
ret
; IN: P1 = text start, P2 = text end
set_text_limits:
mov ax, [p1]
mov [text_start], ax
mov ax, [p2]
mov [text_end], ax
ret
text_start dw 0
text_end dw 0
; Registers used by the control section to run sections of the command section.
; See doc/registers.txt for information about this data
registers:
cmd dw 0
p1 dw 0
p2 dw 0
p3 dw 0
p4 dw 0
p5 dw 0
p6 dw 0
exit_code db 1
data_pointer dw cmd
phase_cmd_pointer dw phase_cmd
; Include the control section (BASIC part) after the command section (binary
; part). Contains BASIC programming but not an independent program, needs
; the command section and the launcher to run properly.
; Has to have '.txt' on the end or the build script will think it is a
; stand alone program and add it to disk.
program_start:
incbin 'yotta.bas.txt'
program_end:
|
scripts/Batch Cue Edits/Name Cues in Sequence.applescript | samschloegel/qlab-scripts | 8 | 1680 | -- For help, bug reports, or feature suggestions, please visit https://github.com/samschloegel/qlab-scripts
-- Built for QLab 4. v211121-01
tell application id "com.figure53.QLab.4" to tell front workspace
set theSelection to (selected as list)
try
set newName to display dialog "Name?" default answer "" buttons {"Cancel", "Continue"} default button "Continue"
if button returned of newName is "Cancel" then return
set newName to text returned of newName
--
set startNum to display dialog "Starting number?" default answer "1" buttons {"Cancel", "Continue"} default button "Continue"
if button returned of startNum is "Cancel" then return
set startNum to (text returned of startNum as integer)
--
set increment to display dialog "Increment by..." default answer "1" buttons {"Cancel", "Continue"} default button "Continue"
if button returned of increment is "Cancel" then return
set increment to (text returned of increment as integer)
on error
display alert "Script cancelled"
return
end try
repeat with eachCue in theSelection
set q name of eachCue to (newName & " " & startNum)
set startNum to (startNum + increment)
end repeat
end tell |
oeis/001/A001721.asm | neoneye/loda-programs | 11 | 169634 | ; A001721: Generalized Stirling numbers.
; Submitted by <NAME>
; 1,11,107,1066,11274,127860,1557660,20355120,284574960,4243508640,67285058400,1131047366400,20099588140800,376612896038400,7422410595801600,153516757766400000,3325222830101760000,75283691519393280000,1778358268603445760000,43757765810602905600000,1119796162003957616640000,29761000630575022448640000,820350827905800840929280000,23423526075129854886051840000,691985937204253869216399360000,21127984865866770324597964800000,666019733334044507505716428800000,21655249743946837690921490841600000
add $0,1
mov $1,1
mov $2,4
lpb $0
sub $0,1
add $2,1
mul $3,$2
add $3,$1
mul $1,$2
lpe
mov $0,$3
|
oeis/216/A216132.asm | neoneye/loda-programs | 11 | 11643 | ; A216132: 11^n mod 10000.
; Submitted by <NAME>(s4)
; 11,121,1331,4641,1051,1561,7171,8881,7691,4601,611,6721,3931,3241,5651,2161,3771,1481,6291,9201,1211,3321,6531,1841,251,2761,371,4081,4891,3801,1811,9921,9131,441,4851,3361,6971,6681,3491,8401,2411,6521,1731,9041,9451,3961,3571,9281,2091,3001,3011,3121,4331,7641,4051,4561,171,1881,691,7601,3611,9721,6931,6241,8651,5161,6771,4481,9291,2201,4211,6321,9531,4841,3251,5761,3371,7081,7891,6801,4811,2921,2131,3441,7851,6361,9971,9681,6491,1401,5411,9521,4731,2041,2451,6961,6571,2281,5091,6001
add $0,1
mov $1,11
pow $1,$0
div $1,10
mod $1,-1000
mov $0,$1
mul $0,10
add $0,1
|
Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xca.log_9584_466.asm | ljhsiun2/medusa | 9 | 166707 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r8
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x13691, %rsi
lea addresses_A_ht+0x1266b, %rdi
clflush (%rdi)
nop
xor $60988, %r8
mov $119, %rcx
rep movsl
nop
nop
nop
nop
sub %r11, %r11
lea addresses_normal_ht+0xd66b, %rdx
nop
nop
inc %rax
vmovups (%rdx), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $0, %xmm2, %rcx
nop
nop
nop
inc %rax
lea addresses_UC_ht+0x1626b, %r11
and $5178, %rsi
movl $0x61626364, (%r11)
inc %rcx
lea addresses_D_ht+0x1a8cb, %rax
nop
nop
and %rsi, %rsi
mov $0x6162636465666768, %rcx
movq %rcx, (%rax)
nop
nop
nop
nop
add %r11, %r11
lea addresses_UC_ht+0x1a03, %rsi
lea addresses_UC_ht+0xc057, %rdi
nop
nop
nop
nop
add %rax, %rax
mov $83, %rcx
rep movsl
nop
nop
xor $45780, %r11
lea addresses_WC_ht+0x1216b, %rdx
nop
nop
nop
nop
nop
and %r11, %r11
movl $0x61626364, (%rdx)
nop
nop
nop
nop
xor %rax, %rax
lea addresses_normal_ht+0x795b, %r11
nop
nop
nop
nop
nop
xor %rax, %rax
movb $0x61, (%r11)
nop
nop
and $56926, %rdi
lea addresses_D_ht+0x192e3, %r11
sub %rcx, %rcx
movb (%r11), %dl
nop
nop
nop
nop
inc %rdx
lea addresses_normal_ht+0x12dab, %r8
nop
nop
nop
inc %rdx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm6
vmovups %ymm6, (%r8)
nop
nop
nop
nop
nop
cmp %r8, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r15
push %r9
push %rbx
push %rsi
// Store
lea addresses_UC+0x45bd, %r13
nop
add $16441, %r15
movl $0x51525354, (%r13)
nop
nop
dec %r9
// Store
lea addresses_A+0x1b26b, %r9
nop
sub %r14, %r14
mov $0x5152535455565758, %r15
movq %r15, (%r9)
inc %r15
// Store
lea addresses_A+0x1b26b, %rbx
nop
nop
nop
nop
nop
xor %rsi, %rsi
movb $0x51, (%rbx)
nop
nop
and %r13, %r13
// Store
mov $0x49085c000000022b, %r13
nop
nop
cmp $32091, %r14
mov $0x5152535455565758, %r15
movq %r15, %xmm4
vmovups %ymm4, (%r13)
nop
nop
nop
nop
cmp $42711, %r14
// Store
lea addresses_WC+0xb29b, %r13
nop
nop
nop
nop
dec %r15
movl $0x51525354, (%r13)
nop
nop
nop
nop
cmp $12234, %r9
// Store
lea addresses_US+0xec6b, %rbx
nop
nop
nop
dec %r14
mov $0x5152535455565758, %r11
movq %r11, %xmm4
movups %xmm4, (%rbx)
nop
add $5488, %r11
// Store
lea addresses_PSE+0xccf1, %r15
add %r14, %r14
movb $0x51, (%r15)
nop
nop
inc %rbx
// Faulty Load
lea addresses_A+0x1b26b, %rsi
nop
xor %r15, %r15
movb (%rsi), %bl
lea oracles, %r14
and $0xff, %rbx
shlq $12, %rbx
mov (%r14,%rbx,1), %rbx
pop %rsi
pop %rbx
pop %r9
pop %r15
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': True, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 7}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 2}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': True, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'51': 9584}
51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
*/
|
oeis/246/A246058.asm | neoneye/loda-programs | 11 | 99265 | ; A246058: a(n) = (16*10^n-7)/9.
; 1,17,177,1777,17777,177777,1777777,17777777,177777777,1777777777,17777777777,177777777777,1777777777777,17777777777777,177777777777777,1777777777777777,17777777777777777,177777777777777777,1777777777777777777,17777777777777777777,177777777777777777777,1777777777777777777777,17777777777777777777777,177777777777777777777777,1777777777777777777777777,17777777777777777777777777,177777777777777777777777777,1777777777777777777777777777,17777777777777777777777777777,177777777777777777777777777777
mov $1,10
pow $1,$0
div $1,9
mul $1,16
add $1,1
mov $0,$1
|
oeis/097/A097137.asm | neoneye/loda-programs | 11 | 243135 | <filename>oeis/097/A097137.asm
; A097137: Convolution of 3^n and floor(n/2).
; Submitted by <NAME>(s3)
; 0,0,1,4,14,44,135,408,1228,3688,11069,33212,99642,298932,896803,2690416,8071256,24213776,72641337,217924020,653772070,1961316220,5883948671,17651846024,52955538084,158866614264,476599842805,1429799528428,4289398585298,12868195755908,38604587267739,115813761803232,347441285409712,1042323856229152,3126971568687473,9380914706062436,28142744118187326,84428232354561996,253284697063686007,759854091191058040,2279562273573174140,6838686820719522440,20516060462158567341,61548181386475702044
mov $1,3
pow $1,$0
div $1,2
mul $1,3
div $1,2
sub $1,$0
mov $0,$1
div $0,4
|
llvm-gcc-4.2-2.9/gcc/ada/s-exctab.adb | vidkidz/crossbridge | 1 | 127 | <reponame>vidkidz/crossbridge<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . E X C E P T I O N _ T A B L E --
-- --
-- B o d y --
-- --
-- Copyright (C) 1996-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. --
-- --
------------------------------------------------------------------------------
with System.HTable;
with System.Soft_Links; use System.Soft_Links;
package body System.Exception_Table is
use System.Standard_Library;
type HTable_Headers is range 1 .. 37;
procedure Set_HT_Link (T : Exception_Data_Ptr; Next : Exception_Data_Ptr);
function Get_HT_Link (T : Exception_Data_Ptr) return Exception_Data_Ptr;
function Hash (F : System.Address) return HTable_Headers;
function Equal (A, B : System.Address) return Boolean;
function Get_Key (T : Exception_Data_Ptr) return System.Address;
package Exception_HTable is new System.HTable.Static_HTable (
Header_Num => HTable_Headers,
Element => Exception_Data,
Elmt_Ptr => Exception_Data_Ptr,
Null_Ptr => null,
Set_Next => Set_HT_Link,
Next => Get_HT_Link,
Key => System.Address,
Get_Key => Get_Key,
Hash => Hash,
Equal => Equal);
-----------
-- Equal --
-----------
function Equal (A, B : System.Address) return Boolean is
S1 : constant Big_String_Ptr := To_Ptr (A);
S2 : constant Big_String_Ptr := To_Ptr (B);
J : Integer := 1;
begin
loop
if S1 (J) /= S2 (J) then
return False;
elsif S1 (J) = ASCII.NUL then
return True;
else
J := J + 1;
end if;
end loop;
end Equal;
-----------------
-- Get_HT_Link --
-----------------
function Get_HT_Link (T : Exception_Data_Ptr) return Exception_Data_Ptr is
begin
return T.HTable_Ptr;
end Get_HT_Link;
-------------
-- Get_Key --
-------------
function Get_Key (T : Exception_Data_Ptr) return System.Address is
begin
return T.Full_Name;
end Get_Key;
-------------------------------
-- Get_Registered_Exceptions --
-------------------------------
procedure Get_Registered_Exceptions
(List : out Exception_Data_Array;
Last : out Integer)
is
Data : Exception_Data_Ptr := Exception_HTable.Get_First;
begin
Lock_Task.all;
Last := List'First - 1;
while Last < List'Last and then Data /= null loop
Last := Last + 1;
List (Last) := Data;
Data := Exception_HTable.Get_Next;
end loop;
Unlock_Task.all;
end Get_Registered_Exceptions;
----------
-- Hash --
----------
function Hash (F : System.Address) return HTable_Headers is
type S is mod 2**8;
Str : constant Big_String_Ptr := To_Ptr (F);
Size : constant S := S (HTable_Headers'Last - HTable_Headers'First + 1);
Tmp : S := 0;
J : Positive;
begin
J := 1;
loop
if Str (J) = ASCII.NUL then
return HTable_Headers'First + HTable_Headers'Base (Tmp mod Size);
else
Tmp := Tmp xor S (Character'Pos (Str (J)));
end if;
J := J + 1;
end loop;
end Hash;
------------------------
-- Internal_Exception --
------------------------
function Internal_Exception
(X : String;
Create_If_Not_Exist : Boolean := True) return Exception_Data_Ptr
is
type String_Ptr is access all String;
Copy : aliased String (X'First .. X'Last + 1);
Res : Exception_Data_Ptr;
Dyn_Copy : String_Ptr;
begin
Copy (X'Range) := X;
Copy (Copy'Last) := ASCII.NUL;
Res := Exception_HTable.Get (Copy'Address);
-- If unknown exception, create it on the heap. This is a legitimate
-- situation in the distributed case when an exception is defined only
-- in a partition
if Res = null and then Create_If_Not_Exist then
Dyn_Copy := new String'(Copy);
Res :=
new Exception_Data'
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Copy'Length,
Full_Name => Dyn_Copy.all'Address,
HTable_Ptr => null,
Import_Code => 0,
Raise_Hook => null);
Register_Exception (Res);
end if;
return Res;
end Internal_Exception;
------------------------
-- Register_Exception --
------------------------
procedure Register_Exception (X : Exception_Data_Ptr) is
begin
Exception_HTable.Set (X);
end Register_Exception;
---------------------------------
-- Registered_Exceptions_Count --
---------------------------------
function Registered_Exceptions_Count return Natural is
Count : Natural := 0;
Data : Exception_Data_Ptr := Exception_HTable.Get_First;
begin
-- We need to lock the runtime in the meantime, to avoid concurrent
-- access since we have only one iterator.
Lock_Task.all;
while Data /= null loop
Count := Count + 1;
Data := Exception_HTable.Get_Next;
end loop;
Unlock_Task.all;
return Count;
end Registered_Exceptions_Count;
-----------------
-- Set_HT_Link --
-----------------
procedure Set_HT_Link
(T : Exception_Data_Ptr;
Next : Exception_Data_Ptr)
is
begin
T.HTable_Ptr := Next;
end Set_HT_Link;
-- Register the standard exceptions at elaboration time
begin
Register_Exception (Abort_Signal_Def'Access);
Register_Exception (Tasking_Error_Def'Access);
Register_Exception (Storage_Error_Def'Access);
Register_Exception (Program_Error_Def'Access);
Register_Exception (Numeric_Error_Def'Access);
Register_Exception (Constraint_Error_Def'Access);
end System.Exception_Table;
|
source/hash/a-szbzha.ads | ytomino/drake | 33 | 10404 | pragma License (Unrestricted);
with Ada.Containers;
generic
with package Bounded is new Generic_Bounded_Length (<>);
function Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash (
Key : Bounded.Bounded_Wide_Wide_String)
return Containers.Hash_Type;
pragma Preelaborate (Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash);
|
Student/examples/Correct/CPRL0/Correct_108.asm | SoftMoore/CPRL-Kt | 6 | 1807 | PROGRAM 10
LDCSTR "Enter value for n1: "
PUTSTR
LDGADDR 2
GETINT
STOREW
LDCSTR "Enter value for n2: "
PUTSTR
LDGADDR 6
GETINT
STOREW
LDCSTR "n1 = "
PUTSTR
LDGADDR 2
LOADW
PUTINT
LDCSTR "; n2 = "
PUTSTR
LDGADDR 6
LOADW
PUTINT
PUTEOL
LDGADDR 0
LDGADDR 2
LOADW
LDCINT 0
CMP
BZ L0
LDCB 1
BR L1
L0:
LDCB 0
L1:
STOREB
LDGADDR 1
LDGADDR 6
LOADW
LDCINT 0
CMP
BZ L2
LDCB 1
BR L3
L2:
LDCB 0
L3:
STOREB
LDCSTR "b1 and b2 = "
PUTSTR
LDGADDR 0
LOADB
BNZ L4
LDCB 0
BR L5
L4:
LDGADDR 1
LOADB
L5:
BZ L6
LDCSTR "true"
PUTSTR
PUTEOL
BR L7
L6:
LDCSTR "false"
PUTSTR
PUTEOL
L7:
LDCSTR "b1 or b2 = "
PUTSTR
LDGADDR 0
LOADB
BZ L8
LDCB 1
BR L9
L8:
LDGADDR 1
LOADB
L9:
BZ L10
LDCSTR "true"
PUTSTR
PUTEOL
BR L11
L10:
LDCSTR "false"
PUTSTR
PUTEOL
L11:
HALT
|
Transynther/x86/_processed/NC/_zr_/i7-7700_9_0xca_notsx.log_21829_1970.asm | ljhsiun2/medusa | 9 | 4334 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x944d, %rsi
lea addresses_A_ht+0x55cd, %rdi
clflush (%rsi)
nop
nop
nop
nop
and $46639, %rdx
mov $82, %rcx
rep movsb
nop
nop
nop
nop
xor %r8, %r8
lea addresses_WT_ht+0x1eacd, %r11
nop
nop
nop
nop
and $49092, %rsi
movb $0x61, (%r11)
nop
nop
nop
nop
and %rcx, %rcx
lea addresses_WT_ht+0xec4d, %rsi
lea addresses_WT_ht+0xc4de, %rdi
and $11596, %r12
mov $87, %rcx
rep movsq
nop
nop
nop
xor $7252, %rsi
lea addresses_normal_ht+0xe85d, %r12
clflush (%r12)
inc %r8
mov $0x6162636465666768, %rdi
movq %rdi, %xmm2
and $0xffffffffffffffc0, %r12
vmovntdq %ymm2, (%r12)
nop
nop
nop
nop
nop
and $45589, %rcx
lea addresses_WT_ht+0x9a0d, %r12
nop
nop
nop
nop
nop
add $51580, %r11
mov (%r12), %edi
nop
nop
nop
nop
and %rdi, %rdi
lea addresses_D_ht+0x14e81, %rsi
lea addresses_WT_ht+0xe24d, %rdi
clflush (%rsi)
nop
and $60827, %r15
mov $34, %rcx
rep movsl
nop
nop
cmp $44311, %rsi
lea addresses_D_ht+0x1a4dd, %rdx
add %r15, %r15
mov $0x6162636465666768, %rsi
movq %rsi, %xmm7
vmovups %ymm7, (%rdx)
nop
nop
sub $40882, %rdi
lea addresses_UC_ht+0xbffd, %rsi
lea addresses_UC_ht+0xe48d, %rdi
nop
nop
cmp $28440, %rdx
mov $75, %rcx
rep movsb
nop
xor %rdx, %rdx
lea addresses_normal_ht+0xc565, %rsi
nop
nop
nop
nop
inc %r11
movups (%rsi), %xmm1
vpextrq $1, %xmm1, %r15
xor %rcx, %rcx
lea addresses_A_ht+0xff50, %r15
nop
nop
xor %rdx, %rdx
movw $0x6162, (%r15)
nop
nop
nop
nop
cmp $46821, %r11
lea addresses_normal_ht+0x7a4d, %rsi
lea addresses_A_ht+0x1e58d, %rdi
nop
nop
nop
xor $1952, %r8
mov $53, %rcx
rep movsq
nop
and $13934, %r8
lea addresses_UC_ht+0x15271, %rsi
lea addresses_A_ht+0x19c4d, %rdi
nop
nop
cmp $3052, %rdx
mov $21, %rcx
rep movsq
and %r12, %r12
lea addresses_A_ht+0x1cbad, %rsi
lea addresses_normal_ht+0xf31d, %rdi
nop
nop
nop
nop
mfence
mov $36, %rcx
rep movsl
nop
nop
cmp %r12, %r12
lea addresses_normal_ht+0x144d, %rsi
lea addresses_WC_ht+0xf44d, %rdi
xor $59763, %r12
mov $106, %rcx
rep movsw
nop
nop
and $19609, %rdi
lea addresses_UC_ht+0x1ac4d, %rcx
nop
nop
dec %rdi
movb $0x61, (%rcx)
nop
cmp $14340, %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r8
push %rdi
push %rdx
push %rsi
// Store
lea addresses_A+0x1444d, %r12
nop
nop
nop
and $9553, %r8
movw $0x5152, (%r12)
nop
nop
nop
add $44667, %r10
// Store
lea addresses_A+0x9f8d, %rdx
nop
add %rdi, %rdi
mov $0x5152535455565758, %r12
movq %r12, (%rdx)
nop
nop
nop
nop
cmp %r8, %r8
// Store
mov $0x84d, %r10
clflush (%r10)
nop
nop
nop
add %r12, %r12
movl $0x51525354, (%r10)
nop
cmp $64856, %rdi
// Store
lea addresses_RW+0x880d, %rdx
nop
and $15882, %r12
movb $0x51, (%rdx)
nop
nop
nop
nop
cmp %rdx, %rdx
// Store
lea addresses_normal+0x144d, %rsi
nop
nop
add $41032, %r8
movw $0x5152, (%rsi)
add $54352, %rdi
// Faulty Load
mov $0x2a9f20000000c4d, %r8
nop
nop
sub %r10, %r10
mov (%r8), %r13
lea oracles, %rdx
and $0xff, %r13
shlq $12, %r13
mov (%rdx,%r13,1), %r13
pop %rsi
pop %rdx
pop %rdi
pop %r8
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9, 'same': False, 'type': 'addresses_A'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 4, 'same': False, 'type': 'addresses_A'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 6, 'same': False, 'type': 'addresses_RW'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'dst': {'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 6, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 11, 'same': True, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 10, 'same': True, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
theorems/cw/cohomology/ReconstructedCochainsEquivCellularCochains.agda | timjb/HoTT-Agda | 0 | 11301 | {-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cw.CW
open import cw.FinCW
open import cw.FinBoundary
open import cohomology.Theory
open import cohomology.ChainComplex
module cw.cohomology.ReconstructedCochainsEquivCellularCochains
(OT : OrdinaryTheory lzero) where
open OrdinaryTheory OT
open import cw.cohomology.cellular.ChainComplex as CCC
open import cw.cohomology.reconstructed.cochain.Complex OT as RCC
open import cw.cohomology.ReconstructedCochainsIsoCellularCochains OT
open import cw.cohomology.cochainequiv.AugmentCommSquare OT
open import cw.cohomology.cochainequiv.FirstCoboundaryCommSquare OT
open import cw.cohomology.cochainequiv.HigherCoboundaryCommSquare OT
private
frcc-comm-fccc-Type : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n)
{m} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n))
(coboundary : AbGroup.grp (RCC.cochain-template ⊙⦉ ⊙fin-skel ⦊ m≤n?)
→ᴳ AbGroup.grp (RCC.cochain-template ⊙⦉ ⊙fin-skel ⦊ Sm≤n?))
(boundary : AbGroup.grp (CCC.chain-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ Sm≤n?)
→ᴳ AbGroup.grp (CCC.chain-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ m≤n?))
→ Type₀
frcc-comm-fccc-Type {n} ⊙fin-skel {m} m≤n? Sm≤n? coboundary boundary =
CommSquareᴳ
coboundary
(pre∘ᴳ-hom (C2-abgroup 0) boundary)
(GroupIso.f-hom (rcc-iso-ccc-template ⊙⦉ ⊙fin-skel ⦊ m≤n?
(⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero)))
(GroupIso.f-hom (rcc-iso-ccc-template ⊙⦉ ⊙fin-skel ⦊ Sm≤n?
(⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero)))
CCC-boundary-template' : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n)
→ {m : ℕ} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n))
→ AbGroup.grp (CCC.chain-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ Sm≤n?)
→ᴳ AbGroup.grp (CCC.chain-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ m≤n?)
CCC-boundary-template' ⊙fin-skel =
CCC.boundary-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))
RCC-coboundary-template' : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n)
→ {m : ℕ} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n))
→ AbGroup.grp (RCC.cochain-template ⊙⦉ ⊙fin-skel ⦊ m≤n?)
→ᴳ AbGroup.grp (RCC.cochain-template ⊙⦉ ⊙fin-skel ⦊ Sm≤n?)
RCC-coboundary-template' ⊙fin-skel = RCC.coboundary-template ⊙⦉ ⊙fin-skel ⦊
abstract
{- This can be directly generalized to the non-finite cases. -}
frcc-comm-fccc-above : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n)
{m} (m≤n? : Dec (m ≤ n)) (Sm≰n : ¬ (S m ≤ n))
→ frcc-comm-fccc-Type ⊙fin-skel m≤n? (inr Sm≰n)
(RCC-coboundary-template' ⊙fin-skel m≤n? (inr Sm≰n))
(CCC-boundary-template' ⊙fin-skel m≤n? (inr Sm≰n))
frcc-comm-fccc-above ⊙fin-skel m≤n? Sm≰n =
(comm-sqrᴳ λ g → group-hom= $ λ= λ _ →
! $ GroupHom.pres-ident
(GroupIso.f
(rcc-iso-ccc-template ⊙⦉ ⊙fin-skel ⦊ m≤n?
(⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero)) g))
frcc-comm-fccc-nth-zero : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) (0≤n : 0 ≤ n) (1≤n : 1 ≤ n)
→ frcc-comm-fccc-Type ⊙fin-skel (inl 0≤n) (inl 1≤n)
(RCC-coboundary-template' ⊙fin-skel (inl 0≤n) (inl 1≤n))
(CCC-boundary-template' ⊙fin-skel (inl 0≤n) (inl 1≤n))
frcc-comm-fccc-nth-zero ⊙fin-skel (inl idp) (inl 1=0) = ⊥-rec (ℕ-S≠O O 1=0)
frcc-comm-fccc-nth-zero ⊙fin-skel (inl idp) (inr ())
frcc-comm-fccc-nth-zero ⊙fin-skel (inr ltS) (inl 1=1) =
transport!
(λ 1=1 → frcc-comm-fccc-Type ⊙fin-skel (inl lteS) (inl (inl 1=1))
(RCC-coboundary-template' ⊙fin-skel (inl lteS) (inl (inl 1=1)))
(CCC-boundary-template' ⊙fin-skel (inl lteS) (inl (inl 1=1))))
(prop-has-all-paths 1=1 idp)
(coe!
(ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel {m = O} (inl (inr ltS)) (inl (inl idp)) p₁ p₂)
(RCC.coboundary-first-template-β ⊙⦉ ⊙fin-skel ⦊)
(CCC.boundary-template-β ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))))
(fst (first-coboundary-comm-sqrᴳ ⊙fin-skel)))
frcc-comm-fccc-nth-zero ⊙fin-skel (inr ltS) (inr (ltSR ()))
frcc-comm-fccc-nth-zero ⊙fin-skel (inr (ltSR 0<n)) (inl 1=Sn) = ⊥-rec (<-to-≠ (<-ap-S 0<n) 1=Sn)
frcc-comm-fccc-nth-zero ⊙fin-skel (inr (ltSR ltS)) (inr 1<2) =
transport!
(λ 1<2 → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr 1<2))
(RCC-coboundary-template' ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr 1<2)))
(CCC-boundary-template' ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr 1<2))))
(prop-has-all-paths 1<2 ltS)
(coe!
(ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr ltS)) p₁ p₂)
(RCC.coboundary-first-template-descend-from-two ⊙⦉ ⊙fin-skel ⦊)
(CCC.boundary-template-descend-from-two-above ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))))
(frcc-comm-fccc-nth-zero (⊙fcw-init ⊙fin-skel) (inr ltS) (inl idp)))
frcc-comm-fccc-nth-zero ⊙fin-skel (inr (ltSR (ltSR ()))) (inr ltS)
frcc-comm-fccc-nth-zero ⊙fin-skel (inr (ltSR (ltSR 0<n))) (inr (ltSR 1<Sn)) =
(coe!
(ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR (ltSR 0<n)))) (inl (inr (ltSR 1<Sn))) p₁ p₂)
(RCC.coboundary-first-template-descend-from-far ⊙⦉ ⊙fin-skel ⦊ (ltSR 0<n) 1<Sn)
(CCC.boundary-template-descend-from-far ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))
(ltSR 0<n) 1<Sn))
(frcc-comm-fccc-nth-zero (⊙fcw-init ⊙fin-skel) (inr (ltSR 0<n)) (inr 1<Sn)))
frcc-comm-fccc-nth-higher : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) {m} (Sm≤n : S m ≤ n) (SSm≤n : S (S m) ≤ n)
→ frcc-comm-fccc-Type ⊙fin-skel (inl Sm≤n) (inl SSm≤n)
(RCC-coboundary-template' ⊙fin-skel (inl Sm≤n) (inl SSm≤n))
(CCC-boundary-template' ⊙fin-skel (inl Sm≤n) (inl SSm≤n))
frcc-comm-fccc-nth-higher ⊙fin-skel (inl idp) (inl SSm=Sm) = ⊥-rec (<-to-≠ ltS (! SSm=Sm))
frcc-comm-fccc-nth-higher ⊙fin-skel (inl idp) (inr SSm<Sm) = ⊥-rec (<-to-≠ (<-trans SSm<Sm ltS) idp)
frcc-comm-fccc-nth-higher ⊙fin-skel {m} (inr ltS) (inl SSm=SSm) =
transport!
(λ SSm=SSm → frcc-comm-fccc-Type ⊙fin-skel (inl lteS) (inl (inl SSm=SSm))
(RCC-coboundary-template' ⊙fin-skel (inl lteS) (inl (inl SSm=SSm)))
(CCC-boundary-template' ⊙fin-skel (inl lteS) (inl (inl SSm=SSm))))
(prop-has-all-paths SSm=SSm idp)
(coe!
(ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel {m = S m} (inl (inr ltS)) (inl (inl idp)) p₁ p₂)
(RCC.coboundary-higher-template-β ⊙⦉ ⊙fin-skel ⦊)
(CCC.boundary-template-β ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))))
(fst (higher-coboundary-comm-sqrᴳ ⊙fin-skel)))
frcc-comm-fccc-nth-higher ⊙fin-skel (inr ltS) (inr SSm<SSm) = ⊥-rec (<-to-≠ SSm<SSm idp)
frcc-comm-fccc-nth-higher ⊙fin-skel (inr (ltSR Sm<n)) (inl SSm=Sn) = ⊥-rec (<-to-≠ (<-ap-S Sm<n) SSm=Sn)
frcc-comm-fccc-nth-higher ⊙fin-skel (inr (ltSR ltS)) (inr SSm<SSSm) =
transport!
(λ SSm<SSSm → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr SSm<SSSm))
(RCC-coboundary-template' ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr SSm<SSSm)))
(CCC-boundary-template' ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr SSm<SSSm))))
(prop-has-all-paths SSm<SSSm ltS)
(coe!
(ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr ltS)) p₁ p₂)
(RCC.coboundary-higher-template-descend-from-one-above ⊙⦉ ⊙fin-skel ⦊)
(CCC.boundary-template-descend-from-two-above ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))))
(frcc-comm-fccc-nth-higher (⊙fcw-init ⊙fin-skel) (inr ltS) (inl idp)))
frcc-comm-fccc-nth-higher ⊙fin-skel (inr (ltSR (ltSR Sm<Sm))) (inr ltS) = ⊥-rec (<-to-≠ Sm<Sm idp)
frcc-comm-fccc-nth-higher ⊙fin-skel (inr (ltSR (ltSR Sm<n))) (inr (ltSR SSm<Sn)) =
(coe!
(ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR (ltSR Sm<n)))) (inl (inr (ltSR SSm<Sn))) p₁ p₂)
(RCC.coboundary-higher-template-descend-from-far ⊙⦉ ⊙fin-skel ⦊ (ltSR Sm<n) SSm<Sn)
(CCC.boundary-template-descend-from-far ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))
(ltSR Sm<n) SSm<Sn))
(frcc-comm-fccc-nth-higher (⊙fcw-init ⊙fin-skel) (inr (ltSR Sm<n)) (inr SSm<Sn)))
frcc-comm-fccc-template : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n)
{m} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n))
→ frcc-comm-fccc-Type ⊙fin-skel m≤n? Sm≤n?
(RCC-coboundary-template' ⊙fin-skel m≤n? Sm≤n?)
(CCC-boundary-template' ⊙fin-skel m≤n? Sm≤n?)
frcc-comm-fccc-template ⊙fin-skel m≤n? (inr Sm≰n) = frcc-comm-fccc-above ⊙fin-skel m≤n? Sm≰n
frcc-comm-fccc-template ⊙fin-skel (inr m≰n) (inl Sm≤n) = ⊥-rec $ m≰n (≤-trans lteS Sm≤n)
frcc-comm-fccc-template ⊙fin-skel {m = O} (inl m≤n) (inl Sm≤n) = frcc-comm-fccc-nth-zero ⊙fin-skel m≤n Sm≤n
frcc-comm-fccc-template ⊙fin-skel {m = S m} (inl Sm≤n) (inl SSm≤n) = frcc-comm-fccc-nth-higher ⊙fin-skel Sm≤n SSm≤n
frcc-comm-fccc : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) m
→ frcc-comm-fccc-Type ⊙fin-skel (≤-dec m n) (≤-dec (S m) n)
(RCC-coboundary-template' ⊙fin-skel (≤-dec m n) (≤-dec (S m) n))
(CCC-boundary-template' ⊙fin-skel (≤-dec m n) (≤-dec (S m) n))
frcc-comm-fccc {n} ⊙fin-skel m =
frcc-comm-fccc-template ⊙fin-skel {m} (≤-dec m n) (≤-dec (S m) n)
frcc-comm-fccc-augment : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n)
→ CommSquareᴳ
(CochainComplex.augment (RCC.cochain-complex ⊙⦉ ⊙fin-skel ⦊))
(pre∘ᴳ-hom (C2-abgroup 0) (FreeAbGroup-extend (Lift-abgroup {j = lzero} ℤ-abgroup) λ _ → lift 1))
(GroupIso.f-hom rhead-iso-chead)
(GroupIso.f-hom (rcc-iso-ccc-template ⊙⦉ ⊙fin-skel ⦊ (inl (O≤ n))
(⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero)))
frcc-comm-fccc-augment {n = O} ⊙fin-skel =
fst (augment-comm-sqrᴳ ⊙fin-skel)
frcc-comm-fccc-augment {n = S O} ⊙fin-skel =
frcc-comm-fccc-augment (⊙fcw-init ⊙fin-skel)
frcc-comm-fccc-augment {n = S (S n)} ⊙fin-skel =
frcc-comm-fccc-augment (⊙fcw-init ⊙fin-skel)
frcc-equiv-fccc : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) →
CochainComplexEquiv
(RCC.cochain-complex ⊙⦉ ⊙fin-skel ⦊)
(CCC.cochain-complex ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))
(C2-abgroup 0))
frcc-equiv-fccc {n} ⊙fin-skel = record
{ head = rhead-iso-chead
; cochain = λ m → rcc-iso-ccc ⊙⦉ ⊙fin-skel ⦊ m (⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero)
; augment = frcc-comm-fccc-augment ⊙fin-skel
; coboundary = frcc-comm-fccc ⊙fin-skel}
frc-iso-fcc : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) (m : ℤ)
→ cohomology-group (RCC.cochain-complex ⊙⦉ ⊙fin-skel ⦊) m
≃ᴳ cohomology-group
(CCC.cochain-complex ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊
(FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel))
(FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel))
(C2-abgroup 0))
m
frc-iso-fcc ⊙fin-skel = cohomology-group-emap (frcc-equiv-fccc ⊙fin-skel)
|
libsrc/msx/msx_vwrite.asm | andydansby/z88dk-mk2 | 1 | 324 | ;
; MSX specific routines
;
; GFX - a small graphics library
; Copyright (C) 2004 <NAME>
;
; extern void msx_vwrite(void *source, u_int dest, u_int count)
;
; Transfer count bytes from RAM to VRAM (BIOS paged version)
;
; $Id: msx_vwrite.asm,v 1.7 2009/06/22 21:44:17 dom Exp $
;
XLIB msx_vwrite
LIB msxbios
IF FORmsx
INCLUDE "msxbios.def"
ELSE
INCLUDE "svibios.def"
ENDIF
msx_vwrite:
ld ix,2
add ix,sp
ld c, (ix+0) ; count
ld b, (ix+1)
ld e, (ix+2) ; dest
ld d, (ix+3)
ld l, (ix+4) ; source
ld h, (ix+5)
ld ix,LDIRVM
jp msxbios
|
OTTTests/TestsTransport.agda | hbasold/Sandbox | 0 | 12889 | <filename>OTTTests/TestsTransport.agda
module TestsTransport where
open import Function
open import Data.Product
open import Relation.Binary.PropositionalEquality as P
open ≡-Reasoning
open import Isomorphisms
open import Tests
Foo : (A : Set) → (T : Testable A) →
(x y : A) → (φ : Test T) → Set
Foo A T x y ⊤ =
_⊨_ {A} {T} x ⊤ ≡ _⊨_ {A} {T} y ⊤
Foo A T x y ⊥ =
_⊨_ {A} {T} x ⊥ ≡ _⊨_ {A} {T} y ⊥
Foo A T x y (nonTriv nt) = sat≡ (kind T) (subT nt) (obs T)
where
sat≡ : (k : Kind) → SubTests T k → (A → ObsTy (index T) (parts T) k) → Set
sat≡ ind φs o =
cotuple (λ i y → y ⊨ app φs i) (o x)
≡ cotuple (λ i y → y ⊨ app φs i) (o y)
sat≡ coind (i , φ) o =
app (o x) i ⊨ φ ≡ app (o y) i ⊨ φ
-- Note: Maybe Reveal_is_ can help to match on (kind T)??
{-
≃-transport : {A B : Set} → {T : Testable A} → (I : Iso A B) →
(x y : A) → x ≃〈 T 〉 y →
(Iso.iso I x) ≃〈 iso-testable T I 〉 (Iso.iso I y)
≃-transport {A} {B} {T₁} I x y p = record { eqProof = q }
where
T₂ = iso-testable T₁ I
f : A → B
f = Iso.iso I
g : B → A
g = IsIso.inv (Iso.indeedIso I)
o₁ = obs T₁
o₂ = obs T₂
lem : (a : A) → (o₂ ∘ f) a ≡ o₁ a
lem a =
begin
(o₂ ∘ f) a
≡⟨ refl ⟩
(o₁ ∘ g ∘ f) a
≡⟨ cong (λ x₁ → o₁ x₁) (IsIso.isLeftInv (Iso.indeedIso I) a) ⟩
o₁ a
∎
q : (φ : Test T₂) → f x ⊨ φ ≡ f y ⊨ φ
q ⊤ = refl
q ⊥ = refl
q (nonTriv (nonTrivTest t)) =
begin
sat (kind T₂) t (o₂ (f x))
≡⟨ cong (λ u → sat (kind T₂) t u) (lem x) ⟩
sat (kind T₂) t (o₁ x)
≡⟨ sat≡ (index T₁) (parts T₁) (kind T₁)
o₂ (obsIso T₂) (partsTestable T₁) o₁ (obsIso T₁) lem p t ⟩
sat (kind T₂) t (o₁ y)
≡⟨ cong (λ u → sat (kind T₂) t u) (sym $ lem y) ⟩
sat (kind T₂) t (o₂ (f y))
∎
where
-- Agda complains at this point that
-- T₁ != record { index = index T₁ ; parts = parts T₁ ; kind = kind T₁
-- ; obs = obs T₁ ; obsIso = obsIso T₁
-- ; partsTestable = partsTestable T₁}
-- ...
-- Is it possible to circumvent this issue?
sat≡ : (Idx : Set) → (P : Idx → Set) → (k : Kind) →
(o₂ : B → ObsTy Idx P k) → (isoT₂ : IsIso o₂) →
(pTestable : (i : Idx) → Testable (P i)) →
(o₁ : A → ObsTy Idx P k) → (isoT₁ : IsIso o₁) →
((a : A) → (o₂ ∘ f) a ≡ o₁ a) →
x ≃〈 record
{ index = Idx
; parts = P
; kind = k
; obs = o₁
; obsIso = isoT₁
; partsTestable = pTestable
} 〉 y →
(t' : SubTests
( record
{ index = Idx ; parts = P ; kind = k ; obs = o₂
; obsIso = isoT₂ ; partsTestable = pTestable }) k ) →
sat k t' (o₁ x) ≡ sat k t' (o₁ y)
sat≡ = {!!}
-}
{-
≃-transport {A} {B} {T₁} I x y p =
q (index T₁) (parts T₁) (kind T₁) (obs T₂) (obsIso T₂) (partsTestable T₁)
(obs T₁) (obsIso T₁) lem {!!}
-- Agda complains at this point that
-- T₁ != record { index = index T₁ ; parts = parts T₁ ; kind = kind T₁
-- ; obs = obs T₁ ; obsIso = obsIso T₁
-- ; partsTestable = partsTestable T₁}
-- ...
-- Is it possible to circumvent this issue?
where
T₂ = iso-testable T₁ I
f : A → B
f = Iso.iso I
g : B → A
g = IsIso.inv (Iso.indeedIso I)
o₁ = obs T₁
o₂ = obs T₂
lem : (a : A) → (o₂ ∘ f) a ≡ o₁ a
lem a =
begin
(o₂ ∘ f) a
≡⟨ refl ⟩
(o₁ ∘ g ∘ f) a
≡⟨ cong (λ x₁ → o₁ x₁) (IsIso.isLeftInv (Iso.indeedIso I) a) ⟩
o₁ a
∎
q : (Idx : Set) → (P : Idx → Set) → (k : Kind) →
(o₂ : B → ObsTy Idx P k) → (isoT₂ : IsIso o₂) →
(pTestable : (i : Idx) → Testable (P i)) →
(o₁ : A → ObsTy Idx P k) → (isoT₁ : IsIso o₁) →
((a : A) → (o₂ ∘ f) a ≡ o₁ a) →
x ≃〈 record
{ index = Idx
; parts = P
; kind = k
; obs = o₁
; obsIso = isoT₁
; partsTestable = pTestable
} 〉 y →
f x ≃〈 record
{ index = Idx
; parts = P
; kind = k
; obs = o₂
; obsIso = isoT₂
; partsTestable = pTestable
} 〉
f y
q Idx P ind o₂ isoT₂ pTestable o₁ isoT₁ lem p = record { eqProof = qi }
where
T₁' = record
{ index = Idx ; parts = P ; kind = ind
; obs = o₁ ; obsIso = isoT₁ ; partsTestable = pTestable }
T₂' = record
{ index = Idx ; parts = P ; kind = ind
; obs = o₂ ; obsIso = isoT₂ ; partsTestable = pTestable }
qi : (φ : Test T₂') → f x ⊨ φ ≡ f y ⊨ φ
qi ⊤ = refl
qi ⊥ = refl
qi (nonTriv (nonTrivTest φs)) =
begin
cotuple (λ i z → z ⊨ app φs i) (o₂ (f x))
≡⟨ cong (λ u → cotuple (λ i z → z ⊨ app φs i) u) (lem x) ⟩
cotuple (λ i z → z ⊨ app φs i) (o₁ x)
≡⟨ refl ⟩
_⊨_ {A} {T₁'} x (nonTriv (nonTrivTest φs))
≡⟨ eqProof p (nonTriv (nonTrivTest φs)) ⟩
_⊨_ {A} {T₁'} y (nonTriv (nonTrivTest φs))
≡⟨ refl ⟩
cotuple (λ i z → z ⊨ app φs i) (o₁ y)
≡⟨ cong (λ u → cotuple (λ i z → z ⊨ app φs i) u) (sym $ lem y) ⟩
cotuple (λ i z → z ⊨ app φs i) (o₂ (f y))
∎
q Idx P coind o₂ isoT₂ pTestable o₁ isoT₁ lem p = record { eqProof = qc }
where
T₁' = record
{ index = Idx ; parts = P ; kind = coind
; obs = o₁ ; obsIso = isoT₁ ; partsTestable = pTestable }
T₂' = record
{ index = Idx ; parts = P ; kind = coind
; obs = o₂ ; obsIso = isoT₂ ; partsTestable = pTestable }
qc : (φ : Test T₂') → f x ⊨ φ ≡ f y ⊨ φ
qc ⊤ = refl
qc ⊥ = refl
qc (nonTriv (nonTrivTest (i , φ))) =
begin
app (o₂ (f x)) i ⊨ φ
≡⟨ cong (λ u → app u i ⊨ φ) (lem x) ⟩
app (o₁ x) i ⊨ φ
≡⟨ {!!} ⟩
app (o₁ y) i ⊨ φ
≡⟨ cong (λ u → app u i ⊨ φ) (sym $ lem y) ⟩
app (o₂ (f y)) i ⊨ φ
∎
-}
|
programs/oeis/268/A268727.asm | jmorken/loda | 1 | 175017 | ; A268727: One-based index of the toggled bit between n and A268717(n+1): a(n) = A070939(A003987(n,A268717(1+n))).
; 1,2,3,1,4,1,1,2,5,1,1,2,1,2,3,1,6,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,7,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,1,2,3,1,4,1,1,2,5,1,1,2,1,2,3,1,8,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,1,2,3,1,4,1,1,2,5,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,5,1,1,2,1,2,3,1,6,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,9,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,1,2,3,1,4,1,1,2,5,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,5,1,1,2,1,2,3,1,6,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,1,2,3,1,4,1,1,2,5,1,1,2,1,2,3,1,6,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,7,1,1,2,1,2,3,1,1,2,3,1,4,1,1,2,1,2,3,1,4,1,1,2,5,1
mov $8,$0
mov $10,2
lpb $10
clr $0,8
mov $0,$8
sub $10,1
add $0,$10
sub $0,1
lpb $0
mov $1,$0
cal $1,115384 ; Partial sums of Thue-Morse numbers A010060.
div $0,2
add $2,$1
mov $6,$2
lpe
mov $1,$6
mov $11,$10
lpb $11
mov $9,$1
sub $11,1
lpe
lpe
lpb $8
mov $8,0
sub $9,$1
lpe
mov $1,$9
add $1,1
|
output/test4_corrected.asm | josuerocha/KPiler | 1 | 3511 | START
PUSHN 3
PUSHN 3
PUSHS "Nome: "
WRITES
READ
STOREL 3
PUSHS "Sobrenome: "
WRITES
READ
STOREL 4
PUSHS "!"
PUSHL 4
PUSHS " "
PUSHL 3
PUSHS "Ola, "
CONCAT
CONCAT
CONCAT
CONCAT
STOREL 5
PUSHS "1"
PUSHL 5
CONCAT
STOREL 5
PUSHL 5
WRITES
READ
ATOI
STOREL 0
READ
ATOI
STOREL 2
PUSHL 0
PUSHL 2
SUP
NOT
JZ A
JUMP B
A: PUSHL 2
STOREL 1
PUSHL 0
STOREL 2
PUSHL 1
STOREL 0
B: PUSHS "Apos a troca: "
WRITES
PUSHL 0
WRITEI
PUSHL 2
WRITEI
STOP
|
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_1_1671.asm | ljhsiun2/medusa | 9 | 6275 | .global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0xb0fc, %rsi
lea addresses_D_ht+0x3380, %rdi
and $28696, %rax
mov $87, %rcx
rep movsw
sub $45565, %rcx
lea addresses_normal_ht+0x5f14, %rsi
lea addresses_normal_ht+0x18b80, %rdi
nop
nop
nop
nop
nop
and $56779, %r9
mov $18, %rcx
rep movsb
nop
nop
nop
nop
sub $16113, %rax
lea addresses_WC_ht+0x13d20, %r15
nop
nop
dec %rcx
movups (%r15), %xmm6
vpextrq $0, %xmm6, %rax
xor $25575, %r15
lea addresses_WT_ht+0x14280, %r9
nop
nop
nop
xor %rbx, %rbx
movb $0x61, (%r9)
nop
nop
nop
xor %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r15
push %rax
push %rdi
push %rdx
push %rsi
// Store
mov $0xcf8, %r14
nop
nop
nop
nop
nop
xor $27641, %rax
movw $0x5152, (%r14)
nop
nop
nop
cmp $44057, %rax
// Store
lea addresses_PSE+0x1db04, %rdx
nop
nop
nop
nop
nop
sub $32030, %r10
movw $0x5152, (%rdx)
nop
nop
nop
nop
nop
sub $12742, %rdi
// Store
lea addresses_WT+0x17280, %r10
nop
nop
nop
nop
nop
sub %rax, %rax
mov $0x5152535455565758, %rdi
movq %rdi, (%r10)
sub %r15, %r15
// Faulty Load
lea addresses_normal+0xbb80, %rax
nop
nop
nop
nop
nop
inc %rdi
mov (%rax), %esi
lea oracles, %rdi
and $0xff, %rsi
shlq $12, %rsi
mov (%rdi,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rax
pop %r15
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 8, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'34': 1}
34
*/
|
programs/oeis/060/A060865.asm | neoneye/loda | 22 | 173357 | ; A060865: a(n) is the exact power of 2 that divides the n-th Fibonacci number (A000045).
; 1,1,2,1,1,8,1,1,2,1,1,16,1,1,2,1,1,8,1,1,2,1,1,32,1,1,2,1,1,8,1,1,2,1,1,16,1,1,2,1,1,8,1,1,2,1,1,64,1,1,2,1,1,8,1,1,2,1,1,16,1,1,2,1,1,8,1,1,2,1,1,32,1,1,2,1,1,8,1,1,2,1,1,16,1,1,2,1,1,8,1,1,2,1,1,128,1,1,2,1
seq $0,71 ; a(n) = Fibonacci(n) - 1.
seq $0,100892 ; a(n) = (2*n-1) XOR (2*n+1), bitwise.
div $0,4
add $0,1
|
swap.asm | shaochenren/Assembly-Time-read | 0 | 90603 | extern printf
global swap
section .data
section .bss
section .text
swap:
push rbp ;Backup rbp
mov rbp,rsp ;The base pointer now points to top of stack
push rdi ;Backup rdi
push rsi ;Backup rsi
push rdx ;Backup rdx
push rcx ;Backup rcx
push r8 ;Backup r8
push r9 ;Backup r9
push r10 ;Backup r10
push r11 ;Backup r11
push r12 ;Backup r12
push r13 ;Backup r13
push r14 ;Backup r14
push r15 ;Backup r15
push rbx ;Backup rbx
pushf
mov r8, [rdi]
mov r9, [rsi]
mov [rdi], r9
mov [rsi], r8
popf
pop rbx
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rcx
pop rdx
pop rsi
pop rdi
pop rbp
ret
|
Applications/Reminders/every/every list/test.applescript | looking-for-a-job/applescript-examples | 1 | 4405 | #!/usr/bin/env osascript
tell application "Reminders"
repeat
end tell
|
source/slim-menu_commands.ads | reznikmm/slimp | 0 | 14997 | <reponame>reznikmm/slimp
-- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package Slim.Menu_Commands is
type Menu_Command is limited interface;
type Menu_Command_Access is access all Menu_Command'Class;
not overriding procedure Run (Self : Menu_Command) is abstract;
end Slim.Menu_Commands;
|
dynamorio/core/arch/aarch64/memfuncs.asm | andre-motta/Project3Compilers | 107 | 105135 | <filename>dynamorio/core/arch/aarch64/memfuncs.asm
/* **********************************************************
* Copyright (c) 2019-2020 Google, Inc. All rights reserved.
* Copyright (c) 2016 ARM Limited. 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 ARM Limited 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 ARM LIMITED 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.
*/
/*
* memfuncs.asm: Contains our custom memcpy and memset routines.
*
* See the long comment at the top of x86/memfuncs.asm.
*/
#include "../asm_defines.asm"
START_FILE
#ifdef UNIX
/* Private memcpy.
* FIXME i#1569: We should optimize this as it can be on the critical path.
*/
DECLARE_FUNC(memcpy)
GLOBAL_LABEL(memcpy:)
mov x3, ARG1
cbz ARG3, 2f
1: ldrb w4, [ARG2], #1
strb w4, [x3], #1
sub ARG3, ARG3, #1
cbnz ARG3, 1b
2: ret
END_FUNC(memcpy)
/* Private memset.
* FIXME i#1569: we should optimize this as it can be on the critical path.
*/
DECLARE_FUNC(memset)
GLOBAL_LABEL(memset:)
mov x3, ARG1
cbz ARG3, 2f
1: strb w1, [x3], #1
sub ARG3, ARG3, #1
cbnz ARG3, 1b
2: ret
END_FUNC(memset)
/* See x86.asm notes about needing these to avoid gcc invoking *_chk */
.global __memcpy_chk
.hidden __memcpy_chk
WEAK(__memcpy_chk)
.set __memcpy_chk,memcpy
.global __memset_chk
.hidden __memset_chk
WEAK(__memset_chk)
.set __memset_chk,memset
#endif /* UNIX */
END_FILE
|
externals/mpir-3.0.0/mpn/x86_64w/k8/rshift2.asm | JaminChan/eos_win | 12 | 166313 | ; PROLOGUE(mpn_rshift2)
; Copyright 2009 <NAME>
;
; Windows Conversion Copyright 2008 <NAME>
;
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published
; by the Free Software Foundation; either version 2.1 of the License, or (at
; your option) any later version.
; The MPIR 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 Lesser General Public
; License for more details.
; You should have received a copy of the GNU Lesser General Public License
; along with the MPIR Library; see the file COPYING.LIB. If not, write
; to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
; Boston, MA 02110-1301, USA.
;
; mp_limb_t mpn_rshift2(mp_ptr, mp_ptr, mp_size_t)
; rax rdi rsi rdx
; rax rcx rdx r8
%include "yasm_mac.inc"
%define reg_save_list rsi, rdi
CPU Athlon64
BITS 64
FRAME_PROC mpn_rshift2, 0, reg_save_list
lea rsi, [rdx+24]
lea rdi, [rcx+24]
mov rcx, r8
xor eax, eax
xor edx, edx
sub rcx, 4
jc .2
xalign 16
.1: mov r8, [rsi+rcx*8]
mov r9, [rsi+rcx*8-8]
mov r10, [rsi+rcx*8-16]
mov r11, [rsi+rcx*8-24]
add rax, rax
rcr r8, 1
rcr r9, 1
rcr r10, 1
rcr r11, 1
sbb rax, rax
add rdx, rdx
rcr r8, 1
rcr r9, 1
rcr r10, 1
rcr r11, 1
mov [rdi+rcx*8-24], r11
sbb rdx, rdx
mov [rdi+rcx*8], r8
sub rcx, 4
mov [rdi+rcx*8+24], r9
mov [rdi+rcx*8+16], r10
jnc .1
.2: cmp rcx, -2
ja .4
je .5
jp .6
.3: lea rax, [rax+rdx*2]
neg rax
shl rax, 62
EXIT_PROC reg_save_list
xalign 16
.4: mov r8, [rsi+rcx*8]
mov r9, [rsi+rcx*8-8]
mov r10, [rsi+rcx*8-16]
add rax, rax
rcr r8, 1
rcr r9, 1
rcr r10, 1
sbb rax, rax
add rdx, rdx
rcr r8, 1
rcr r9, 1
rcr r10, 1
sbb rdx, rdx
mov [rdi+rcx*8], r8
mov [rdi+rcx*8-8], r9
mov [rdi+rcx*8-16], r10
lea rax, [rax+rdx*2]
neg rax
shl rax, 62
EXIT_PROC reg_save_list
xalign 16
.5: mov r8, [rsi+rcx*8]
mov r9, [rsi+rcx*8-8]
add rax, rax
rcr r8, 1
rcr r9, 1
sbb rax, rax
add rdx, rdx
rcr r8, 1
rcr r9, 1
sbb rdx, rdx
mov [rdi+rcx*8], r8
mov [rdi+rcx*8-8], r9
lea rax, [rax+rdx*2]
neg rax
shl rax, 62
EXIT_PROC reg_save_list
xalign 16
.6: mov r8, [rsi+rcx*8]
add rax, rax
rcr r8, 1
sbb rax, rax
add rdx, rdx
rcr r8, 1
sbb rdx, rdx
mov [rdi+rcx*8], r8
lea rax, [rax+rdx*2]
neg rax
shl rax, 62
.7: END_PROC reg_save_list
end
|
src/adaphysics2ddemo.ads | Kidev/DemoAdaPhysics2D | 5 | 400 | with Menus; use Menus;
package AdaPhysics2DDemo is
procedure Start(This : in out Menu);
end AdaPhysics2DDemo;
|
Cubical/Algebra/Polynomials/Univariate/Base.agda | howsiyu/cubical | 0 | 323 | {-A
Polynomials over commutative rings
==================================
-}
{-# OPTIONS --safe #-}
----------------------------------
module Cubical.Algebra.Polynomials.Univariate.Base where
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Data.Nat renaming (_+_ to _Nat+_; _·_ to _Nat·_) hiding (·-comm)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Empty.Base renaming (rec to ⊥rec )
open import Cubical.Data.Bool
open import Cubical.Algebra.Group hiding (Bool)
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
------------------------------------------------------------------------------------
private
variable
ℓ ℓ' : Level
A : Type ℓ
module PolyMod (R' : CommRing ℓ) where
private
R = fst R'
open CommRingStr (snd R') public
-------------------------------------------------------------------------------------------
-- First definition of a polynomial.
-- A polynomial a₁ + a₂x + ... + aⱼxʲ of degree j is represented as a list [a₁, a₂, ...,aⱼ]
-- modulo trailing zeros.
-------------------------------------------------------------------------------------------
data Poly : Type ℓ where
[] : Poly
_∷_ : (a : R) → (p : Poly) → Poly
drop0 : 0r ∷ [] ≡ []
infixr 5 _∷_
module Elim (B : Poly → Type ℓ')
([]* : B [])
(cons* : (r : R) (p : Poly) (b : B p) → B (r ∷ p))
(drop0* : PathP (λ i → B (drop0 i)) (cons* 0r [] []*) []*) where
f : (p : Poly) → B p
f [] = []*
f (x ∷ p) = cons* x p (f p)
f (drop0 i) = drop0* i
-- Given a proposition (as type) ϕ ranging over polynomials, we prove it by:
-- ElimProp.f ϕ ⌜proof for base case []⌝ ⌜proof for induction case a ∷ p⌝
-- ⌜proof that ϕ actually is a proposition over the domain of polynomials⌝
module ElimProp (B : Poly → Type ℓ')
([]* : B [])
(cons* : (r : R) (p : Poly) (b : B p) → B (r ∷ p))
(BProp : {p : Poly} → isProp (B p)) where
f : (p : Poly) → B p
f = Elim.f B []* cons* (toPathP (BProp (transport (λ i → B (drop0 i)) (cons* 0r [] []*)) []*))
module Rec (B : Type ℓ')
([]* : B)
(cons* : R → B → B)
(drop0* : cons* 0r []* ≡ []*)
(Bset : isSet B) where
f : Poly → B
f = Elim.f (λ _ → B) []* (λ r p b → cons* r b) drop0*
module RecPoly ([]* : Poly) (cons* : R → Poly → Poly) (drop0* : cons* 0r []* ≡ []*) where
f : Poly → Poly
f [] = []*
f (a ∷ p) = cons* a (f p)
f (drop0 i) = drop0* i
--------------------------------------------------------------------------------------------------
-- Second definition of a polynomial. The purpose of this second definition is to
-- facilitate the proof that the first definition is a set. The two definitions are
-- then shown to be equivalent.
-- A polynomial a₀ + a₁x + ... + aⱼxʲ of degree j is represented as a function f
-- such that for i ∈ ℕ we have f(i) = aᵢ if i ≤ j, and 0 for i > j
--------------------------------------------------------------------------------------------------
PolyFun : Type ℓ
PolyFun = Σ[ p ∈ (ℕ → R) ] (∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → p m ≡ 0r))
isSetPolyFun : isSet PolyFun
isSetPolyFun = isSetΣSndProp (isSetΠ (λ x → isSetCommRing R')) λ f x y → squash x y
--construction of the function that represents the polynomial
Poly→Fun : Poly → (ℕ → R)
Poly→Fun [] = (λ _ → 0r)
Poly→Fun (a ∷ p) = (λ n → if isZero n then a else Poly→Fun p (predℕ n))
Poly→Fun (drop0 i) = lemma i
where
lemma : (λ n → if isZero n then 0r else 0r) ≡ (λ _ → 0r)
lemma i zero = 0r
lemma i (suc n) = 0r
Poly→Prf : (p : Poly) → ∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → (Poly→Fun p m ≡ 0r))
Poly→Prf = ElimProp.f (λ p → ∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → (Poly→Fun p m ≡ 0r)))
∣ 0 , (λ m ineq → refl) ∣
(λ r p → map ( λ (n , ineq) → (suc n) ,
λ { zero h → ⊥rec (znots (sym (≤0→≡0 h))) ;
(suc m) h → ineq m (pred-≤-pred h)
}
)
)
squash
Poly→PolyFun : Poly → PolyFun
Poly→PolyFun p = (Poly→Fun p) , (Poly→Prf p)
----------------------------------------------------
-- Start of code by <NAME> and <NAME>
at0 : (ℕ → R) → R
at0 f = f 0
atS : (ℕ → R) → (ℕ → R)
atS f n = f (suc n)
polyEq : (p p' : Poly) → Poly→Fun p ≡ Poly→Fun p' → p ≡ p'
polyEq [] [] _ = refl
polyEq [] (a ∷ p') α =
sym drop0 ∙∙ cong₂ _∷_ (cong at0 α) (polyEq [] p' (cong atS α)) ∙∙ refl
polyEq [] (drop0 j) α k =
hcomp
(λ l → λ
{ (j = i1) → drop0 l
; (k = i0) → drop0 l
; (k = i1) → drop0 (j ∧ l)
})
(is-set 0r 0r (cong at0 α) refl j k ∷ [])
polyEq (a ∷ p) [] α =
refl ∙∙ cong₂ _∷_ (cong at0 α) (polyEq p [] (cong atS α)) ∙∙ drop0
polyEq (a ∷ p) (a₁ ∷ p') α =
cong₂ _∷_ (cong at0 α) (polyEq p p' (cong atS α))
polyEq (a ∷ p) (drop0 j) α k =
hcomp -- filler
(λ l → λ
{ (k = i0) → a ∷ p
; (k = i1) → drop0 (j ∧ l)
; (j = i0) → at0 (α k) ∷ polyEq p [] (cong atS α) k
})
(at0 (α k) ∷ polyEq p [] (cong atS α) k)
polyEq (drop0 i) [] α k =
hcomp
(λ l → λ
{ (i = i1) → drop0 l
; (k = i0) → drop0 (i ∧ l)
; (k = i1) → drop0 l
})
(is-set 0r 0r (cong at0 α) refl i k ∷ [])
polyEq (drop0 i) (a ∷ p') α k =
hcomp -- filler
(λ l → λ
{ (k = i0) → drop0 (i ∧ l)
; (k = i1) → a ∷ p'
; (i = i0) → at0 (α k) ∷ polyEq [] p' (cong atS α) k
})
(at0 (α k) ∷ polyEq [] p' (cong atS α) k)
polyEq (drop0 i) (drop0 j) α k =
hcomp
(λ l → λ
{ (k = i0) → drop0 (i ∧ l)
; (k = i1) → drop0 (j ∧ l)
; (i = i0) (j = i0) → at0 (α k) ∷ []
; (i = i1) (j = i1) → drop0 l
})
(is-set 0r 0r (cong at0 α) refl (i ∧ j) k ∷ [])
PolyFun→Poly+ : (q : PolyFun) → Σ[ p ∈ Poly ] Poly→Fun p ≡ q .fst
PolyFun→Poly+ (f , pf) = rec lem (λ x → rem1 f (x .fst) (x .snd) ,
funExt (rem2 f (fst x) (snd x))
) pf
where
lem : isProp (Σ[ p ∈ Poly ] Poly→Fun p ≡ f)
lem (p , α) (p' , α') =
ΣPathP (polyEq p p' (α ∙ sym α'), isProp→PathP (λ i → (isSetΠ λ _ → is-set) _ _) _ _)
rem1 : (p : ℕ → R) (n : ℕ) → ((m : ℕ) → n ≤ m → p m ≡ 0r) → Poly
rem1 p zero h = []
rem1 p (suc n) h = p 0 ∷ rem1 (λ x → p (suc x)) n (λ m x → h (suc m) (suc-≤-suc x))
rem2 : (f : ℕ → R) (n : ℕ) → (h : (m : ℕ) → n ≤ m → f m ≡ 0r) (m : ℕ) →
Poly→Fun (rem1 f n h) m ≡ f m
rem2 f zero h m = sym (h m zero-≤)
rem2 f (suc n) h zero = refl
rem2 f (suc n) h (suc m) = rem2 (λ x → f (suc x)) n (λ k p → h (suc k) (suc-≤-suc p)) m
PolyFun→Poly : PolyFun → Poly
PolyFun→Poly q = PolyFun→Poly+ q .fst
PolyFun→Poly→PolyFun : (p : Poly) → PolyFun→Poly (Poly→PolyFun p) ≡ p
PolyFun→Poly→PolyFun p = polyEq _ _ (PolyFun→Poly+ (Poly→PolyFun p) .snd)
--End of code by Mörtberg and Cavallo
-------------------------------------
isSetPoly : isSet Poly
isSetPoly = isSetRetract Poly→PolyFun
PolyFun→Poly
PolyFun→Poly→PolyFun
isSetPolyFun
|
Task/Day-of-the-week/AppleScript/day-of-the-week-3.applescript | LaudateCorpus1/RosettaCodeData | 1 | 962 | <gh_stars>1-10
{2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067,
2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118}
|
oeis/086/A086801.asm | neoneye/loda-programs | 11 | 102043 | ; A086801: a(n) = prime(n) - 3.
; Submitted by <NAME>(s3)
; -1,0,2,4,8,10,14,16,20,26,28,34,38,40,44,50,56,58,64,68,70,76,80,86,94,98,100,104,106,110,124,128,134,136,146,148,154,160,164,170,176,178,188,190,194,196,208,220,224,226,230,236,238,248,254,260,266,268,274,278
mul $0,2
max $0,1
seq $0,173919 ; Numbers that are prime or one less than a prime.
sub $0,3
|
src/Categories/Morphism/Lifts/Properties.agda | Trebor-Huang/agda-categories | 5 | 526 | <filename>src/Categories/Morphism/Lifts/Properties.agda
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Morphism.Lifts.Properties {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level
open import Data.Product using (_,_; proj₁; proj₂)
open import Categories.Category.Construction.Arrow 𝒞
open import Categories.Diagram.Pullback 𝒞
open import Categories.Diagram.Pushout 𝒞
open import Categories.Morphism.Lifts 𝒞
open import Categories.Morphism.Reasoning 𝒞 renaming (glue to glue-■)
import Categories.Morphism as Mor
open Category 𝒞
open Definitions 𝒞
open HomReasoning
-- We want to talk about retracts of morphisms, so
-- we don't use the definition of 'Retract' applied to '𝒞'
open Mor 𝒞 hiding (Retract)
open Mor using (Retract)
open Morphism⇒
--------------------------------------------------------------------------------
-- Lifting and Retractions
module _ {X Y T} {f : X ⇒ Y} {i : X ⇒ T} {p : T ⇒ Y} (factors : f ≈ p ∘ i) where
-- If 'f' factors into 'p ∘ i' and 'f' has the left lifting property
-- with respect to 'p', then 'f' is a retraction of 'i' in the arrow
-- category of 𝒞.
retract-liftˡ : Lifts f p → Retract Arrow (mor f) (mor i)
retract-liftˡ lifts = record
{ section = mor⇒ (fill-commˡ ○ ⟺ identityʳ)
; retract = mor⇒ (⟺ factors ○ ⟺ identityʳ)
; is-retract = identity² , fill-commʳ
}
where
open Filler (lifts (identityˡ ○ factors))
-- We have an analogous situation for right lifts.
retract-liftʳ : Lifts i f → Retract Arrow (mor f) (mor p)
retract-liftʳ lifts = record
{ section = mor⇒ (identityˡ ○ factors)
; retract = mor⇒ (identityˡ ○ ⟺ fill-commʳ)
; is-retract = fill-commˡ , identity²
}
where
open Filler (lifts (⟺ factors ○ ⟺ identityʳ))
--------------------------------------------------------------------------------
-- Closure Properties of Injective and Projective morphisms.
module _ {j} (J : MorphismClass j) where
private
variable
X Y Z : Obj
f g h i p : X ⇒ Y
-- If 'f' is an isomorphism, then it must be J-Projective.
iso-proj : ∀ {X Y} (f : X ⇒ Y) → IsIso f → Proj J f
iso-proj f f-iso g g∈J {h} {i} comm = record
{ filler = h ∘ inv
; fill-commˡ = cancelʳ isoˡ
; fill-commʳ = extendʳ (⟺ comm) ○ elimʳ isoʳ
}
where
open IsIso f-iso
-- Dually, If 'f' is an isomorphism, then it must be J-Injective.
iso-inj : ∀ {X Y} (f : X ⇒ Y) → IsIso f → Inj J f
iso-inj f f-iso g g∈J {h} {i} comm = record
{ filler = inv ∘ i
; fill-commˡ = extendˡ comm ○ elimˡ isoˡ
; fill-commʳ = cancelˡ isoʳ
}
where
open IsIso f-iso
-- J-Projective morphisms are closed under composition.
proj-∘ : ∀ {X Y Z} {f : Y ⇒ Z} {g : X ⇒ Y} → Proj J f → Proj J g → Proj J (f ∘ g)
proj-∘ {f = f} {g = g} f-proj g-proj h h∈J {k} {i} comm = record
{ filler = UpperFiller.filler
; fill-commˡ = begin
UpperFiller.filler ∘ f ∘ g
≈⟨ pullˡ UpperFiller.fill-commˡ ⟩
LowerFiller.filler ∘ g
≈⟨ LowerFiller.fill-commˡ ⟩
k
∎
; fill-commʳ = UpperFiller.fill-commʳ
}
where
module LowerFiller = Filler (g-proj h h∈J (assoc ○ comm))
module UpperFiller = Filler (f-proj h h∈J (⟺ LowerFiller.fill-commʳ))
-- J-Injective morphisms are closed under composition.
inj-∘ : ∀ {X Y Z} {f : Y ⇒ Z} {g : X ⇒ Y} → Inj J f → Inj J g → Inj J (f ∘ g)
inj-∘ {f = f} {g = g} f-inj g-inj h h∈J {k} {i} comm = record
{ filler = LowerFiller.filler
; fill-commˡ = LowerFiller.fill-commˡ
; fill-commʳ = begin
(f ∘ g) ∘ LowerFiller.filler
≈⟨ pullʳ LowerFiller.fill-commʳ ⟩
f ∘ UpperFiller.filler
≈⟨ UpperFiller.fill-commʳ ⟩
i
∎
}
where
module UpperFiller = Filler (f-inj h h∈J (comm ○ assoc))
module LowerFiller = Filler (g-inj h h∈J UpperFiller.fill-commˡ)
-- J-Projective morphisms are stable under pushout.
proj-pushout : ∀ {X Y Z} {p : X ⇒ Y} {f : X ⇒ Z} → (P : Pushout p f) → Proj J p → Proj J (Pushout.i₂ P)
proj-pushout {p = p} {f = f} po p-proj h h∈J sq = record
{ filler = universal fill-commˡ
; fill-commˡ = universal∘i₂≈h₂
; fill-commʳ = unique-diagram (pullʳ universal∘i₁≈h₁ ○ fill-commʳ) (pullʳ universal∘i₂≈h₂ ○ ⟺ sq)
}
where
open Pushout po
open Filler (p-proj h h∈J (glue-■ sq commute))
-- J-Injective morphisms are stable under pullback.
inj-pullback : ∀ {X Y Z} {i : X ⇒ Z} {f : Y ⇒ Z} → (P : Pullback i f) → Inj J i → Inj J (Pullback.p₂ P)
inj-pullback {i = i} {f = f} pb i-inj h h∈J sq = record
{ filler = universal fill-commʳ
; fill-commˡ = unique-diagram (pullˡ p₁∘universal≈h₁ ○ fill-commˡ) (pullˡ p₂∘universal≈h₂ ○ sq)
; fill-commʳ = p₂∘universal≈h₂
}
where
open Pullback pb
open Filler (i-inj h h∈J (glue-■ (⟺ commute) sq))
-- J-Projective morphisms are stable under retractions.
proj-retract : Proj J p → Retract Arrow (mor f) (mor p) → Proj J f
proj-retract {p = p} {f = f} p-proj f-retracts h h∈J {g} {k} sq = record
{ filler = filler ∘ cod⇒ section
; fill-commˡ = begin
(filler ∘ cod⇒ section) ∘ f
≈⟨ extendˡ (square section) ⟩
(filler ∘ p) ∘ dom⇒ section
≈⟨ fill-commˡ ⟩∘⟨refl ⟩
(g ∘ dom⇒ retract) ∘ dom⇒ section
≈⟨ cancelʳ (proj₁ is-retract) ⟩
g
∎
; fill-commʳ = begin
h ∘ filler ∘ cod⇒ section
≈⟨ extendʳ fill-commʳ ⟩
k ∘ (cod⇒ retract ∘ cod⇒ section)
≈⟨ elimʳ (proj₂ is-retract) ⟩
k
∎
}
where
open Retract f-retracts
open Filler (p-proj h h∈J (glue-■ sq (square retract)))
-- J-Injective morphisms are stable under retractions.
inj-retract : Inj J i → Retract Arrow (mor f) (mor i) → Inj J f
inj-retract {i = i} {f = f} i-inj f-retracts h h∈J {g} {k} sq = record
{ filler = dom⇒ retract ∘ filler
; fill-commˡ = begin
(dom⇒ retract ∘ filler) ∘ h
≈⟨ extendˡ fill-commˡ ⟩
(dom⇒ retract ∘ dom⇒ section) ∘ g
≈⟨ elimˡ (proj₁ is-retract) ⟩
g
∎
; fill-commʳ = begin
f ∘ dom⇒ retract ∘ filler
≈⟨ extendʳ (⟺ (square retract)) ⟩
cod⇒ retract ∘ i ∘ filler
≈⟨ refl⟩∘⟨ fill-commʳ ⟩
cod⇒ retract ∘ cod⇒ section ∘ k
≈⟨ cancelˡ (proj₂ is-retract) ⟩
k
∎
}
where
open Retract f-retracts
open Filler (i-inj h h∈J (glue-■ (square section) sq))
|
src/ado-c.ads | Letractively/ada-ado | 0 | 22642 | -----------------------------------------------------------------------
-- ado-c -- Support for driver implementation
-- Copyright (C) 2009, 2010, 2011, 2012 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces.C;
with Interfaces.C.Strings;
with Ada.Finalization;
with Ada.Strings.Unbounded;
with Ada.Unchecked_Conversion;
with System;
package ADO.C is
type String_Ptr is limited private;
-- Convert a string to a C string.
function To_String_Ptr (S : String) return String_Ptr;
-- Convert an unbounded string to a C string.
function To_String_Ptr (S : Ada.Strings.Unbounded.Unbounded_String) return String_Ptr;
-- Get the C string pointer.
function To_C (S : String_Ptr) return Interfaces.C.Strings.chars_ptr;
-- Set the string
procedure Set_String (S : in out String_Ptr;
Value : in String);
function To_chars_ptr is
new Ada.Unchecked_Conversion (System.Address, Interfaces.C.Strings.chars_ptr);
private
use Interfaces.C;
type String_Ptr is new Ada.Finalization.Limited_Controlled with record
Ptr : Strings.chars_ptr := Interfaces.C.Strings.Null_Ptr;
end record;
-- Reclaim the storage held by the C string.
procedure Finalize (S : in out String_Ptr);
end ADO.C;
|
Library/Kernel/Heap/heapErrorCheck.asm | steakknife/pcgeos | 504 | 85137 | <gh_stars>100-1000
COMMENT @-----------------------------------------------------------------------
Copyright (c) GeoWorks 1988 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Kernel
FILE: heapErrorCheck.asm
AUTHOR: <NAME>
ROUTINES:
Name Description
---- -----------
ECCheckMemHandle Verify BX is a valid memory handle
ECCheckMemHandleNS Verify BX is a valid memory handle w/o
worrying about sharing errors
CheckHandleLegal Verify handle ID is valid
EC ONLY:
CheckLocked Make sure handle isn't locked
CheckToLock Make sure lock count won't be exceeded.
Calls ECCheckMemHandle
CheckToLockNS Make sure lock count won't be exceeded,
but call ECCheckMemHandleNS.
CheckToUnlock Make sure handle is valid and locked
CheckToUnlockNS Same, but call ECCheckMemHandleNS to check
handle validity.
CheckDS_ES Make sure DS and ES point into the heap
ECCheckBounds
AssertHeapMine Make sure the heap is locked by the current
thread.
ECMemVerifyHeapLow Make sure heap is consistent.
DESCRIPTION:
This file contains error checking code for the heap
$Id: heapErrorCheck.asm,v 1.1 97/04/05 01:13:54 newdeal Exp $
-------------------------------------------------------------------------------@
kcode segment
if ERROR_CHECK
FarLoadVarSegDS proc far
call LoadVarSegDS
ret
FarLoadVarSegDS endp
endif ;ERROR_CHECK
kcode ends
ECCode segment
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckHandleLegal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make sure the passed handle is reasonable. Doesn't check
*type* of handle or anything, just the handle ID itself.
CALLED BY: EXTERNAL/INTERNAL
PASS: bx = handle ID to check
RETURN: nothing
DESTROYED: nothing (flags preserved)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 8/30/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if ERROR_CHECK
CheckHandleLegal proc far
pushf
push ds
call FarLoadVarSegDS
test bl,00001111b ;make sure it's is on a 16 byte boundry
jnz illegalHandle
cmp bx, ds:[loaderVars].KLV_handleTableStart
jb illegalHandle
cmp bx,ds:[loaderVars].KLV_lastHandle ;make sure it's not too large
jae illegalHandle
pop ds
popf
ret
illegalHandle:
ERROR ILLEGAL_HANDLE
CheckHandleLegal endp
endif
COMMENT @----------------------------------------------------------------------
FUNCTION: ECCheckMemHandle
DESCRIPTION: Check a memory handle for validity
CALLED BY: GLOBAL
PASS:
bx - memory handle
RETURN:
none
DESTROYED:
nothing -- even the flags are kept intact
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 9/89 Initial version
------------------------------------------------------------------------------@
ECCheckMemHandleFar proc far
EC < call ECCheckMemHandle >
ret
ECCheckMemHandleFar endp
public ECCheckMemHandleFar
if ERROR_CHECK
ECCheckMemHandle proc near
pushf
push ds
LoadVarSeg ds
HMA < cmp ds:[bx].HG_type, SIG_UNUSED_FF >
HMA < je isMem >
cmp ds:[bx].HG_type, SIG_NON_MEM
ERROR_AE NOT_MEM_HANDLE
HMA <isMem: >
call ECCheckMemHandleNS
test ds:[sysECLevel], mask ECF_HIGH
jz done
push ax, si
test ds:[bx][HM_flags],mask HF_SHARABLE
jnz 20$
mov ax,ss:[TPD_processHandle]
cmp ax, handle 0
jz 20$
mov si,ds:[bx][HM_owner]
cmp ax,si
jz 20$
cmp ds:[si].HG_type,SIG_VM
ERROR_NZ HANDLE_SHARING_ERROR
20$:
pop ax, si
done:
pop ds
popf
ret
ECCheckMemHandle endp
endif
COMMENT @----------------------------------------------------------------------
FUNCTION: ECCheckMemHandleNS
DESCRIPTION: Check a memory handle for validity -- won't check for
sharing violations
CALLED BY: GLOBAL
PASS:
bx - memory handle
RETURN:
none
DESTROYED:
nothing -- even the flags are kept intact (ints left in whatever state
they were in when routine was called)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 9/89 Initial version
------------------------------------------------------------------------------@
ECCheckMemHandleNSFar proc far
EC < call ECCheckMemHandleNS >
ret
ECCheckMemHandleNSFar endp
public ECCheckMemHandleNSFar
if ERROR_CHECK
ECCheckMemHandleNS proc near
pushf
push ds
LoadVarSeg ds
call CheckHandleLegal
cmp ds:[bx][HM_owner],0
ERROR_Z HANDLE_FREE
HMA < cmp ds:[bx].HG_type, SIG_UNUSED_FF >
HMA < je isMem >
cmp ds:[bx].HG_type, SIG_NON_MEM
ERROR_AE ILLEGAL_HANDLE
HMA <isMem: >
test ds:[sysECLevel], mask ECF_HIGH
jz done
INT_OFF ; consistency 'R' us
push ax
push cx
mov ax,ds:[bx].HM_addr
mov cl,ds:[bx].HM_flags
tst ax
jz 10$
cmp ax,ds:[loaderVars].KLV_heapStart ;check for bad address
jb illegalHandleData
cmp ax,ds:[loaderVars].KLV_heapEnd
if FULL_EXECUTE_IN_PLACE
jb 20$ ;betw. start & end->OK
; It is OK to have XIP resources above the end of the heap, as long
; as they have non-zero lock counts.
cmp bx, LAST_XIP_RESOURCE_HANDLE
ja illegalHandleData ;not XIP handle
tst ds:[bx][HM_lockCount]
jz illegalHandleData ;handle count = 0..BAD
else ;FULL_EXECUTE_IN_PLACE is FALSE
jae illegalHandleData
endif ;FULL_EXECUTE_IN_PLACE
20$::
test cl,mask HF_DISCARDED or mask HF_SWAPPED
ERROR_NZ CORRUPTED_HEAP
cmp ds:[bx][HM_size],1000h
ERROR_AE BAD_PARA_SIZE
10$:
pop cx
pop ax
done:
pop ds
call SafePopf
ret
illegalHandleData:
ERROR ILLEGAL_HANDLE_DATA
ECCheckMemHandleNS endp
endif
COMMENT @----------------------------------------------------------------------
FUNCTION: ECCheckBounds ECAssertValidFarPointerXIP
DESCRIPTION: Verify that DS is a valid segment, and that SI is a
valid offset in that segment. If DS is an lmem block,
verify that SI is inside a chunk in that block, or in
the Header of that block.
CALLED BY: GLOBAL
PASS:
For ECCheckBounds:
ds:si - pointer to check
For ECAssertValidFarPointerXIP
bx:si - vfptr to check (not passed in ds:si because could be vfptr)
For ECAssertValidTrueFarPointerXIP
bx:si - fptr to check (*cannot* be a vfptr)
RETURN:
none (dies if assertion fails)
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 9/ 9/91 Initial version
------------------------------------------------------------------------------@
if ERROR_CHECK
if FULL_EXECUTE_IN_PLACE
ECAssertValidTrueFarPointerXIP proc far
pushf
; Make sure that no virtual far pointers are passed in.
HMA < cmp bx, HMA_SEGMENT ;check hi-mem segment >
HMA < je realSegment >
cmp bh, high MAX_SEGMENT
ERROR_AE ILLEGAL_SEGMENT
realSegment::
popf
FALL_THRU ECAssertValidFarPointerXIP
ECAssertValidTrueFarPointerXIP endp
endif
ECAssertValidFarPointerXIP proc far
FXIP < pushf >
FXIP < push ds, bx >
FXIP < LoadVarSeg ds >
FXIP < sub bx, ds:[loaderVars].KLV_mapPageAddr >
FXIP < jc notXIP >
FXIP < cmp bx, MAPPING_PAGE_SIZE/16 >
FXIP < ERROR_B FAR_POINTER_TO_MOVABLE_XIP_RESOURCE >
notXIP::
FXIP < pop ds, bx >
FXIP < popf >
push cx
mov cx, bx
GOTO ECCheckBoundsCommon, cx
ECAssertValidFarPointerXIP endp
ECCheckBounds proc far
push cx
call CheckDS_ES
mov cx, ds
FALL_THRU ECCheckBoundsCommon, cx
ECCheckBounds endp
ECCheckBoundsCommon proc far
; Takes: CX:SI <- far ptr/virtual far ptr
uses ax, bx, ds, di
.enter
pushf
push cx
mov ax, ss
cmp cx, ax
jne notInvalidStack
cmp si, ss:[TPD_stackBot]
jb notInvalidStack
cmp si, sp
ERROR_B INVALID_POINTER_INTO_STACK
notInvalidStack:
call MemSegmentToHandle
ERROR_NC ILLEGAL_SEGMENT
mov bx, cx
LoadVarSeg ds
call GetByteSizeFar ; ax, cx <- # bytes
cmp si, cx
ERROR_AE ADDRESS_OUT_OF_BOUNDS
pop ax ; ax = passed in segment
test ds:[sysECLevel], mask ECF_LMEM
jz done
test ds:[bx].HM_flags, mask HF_LMEM
jz done
;
; Make sure the offset points to an lmem chunk
;
mov ds, ax
test ds:[LMBH_flags], mask LMF_NO_HANDLES
jnz done
mov cx, ds:[LMBH_nHandles]
mov bx, ds:[LMBH_offset]
;
; Allow the pointer to point within the lmem block header
; (which for GStates and Windows may be the only data)
;
cmp si, bx ; pointer into header?
jb done ; branch if so
startLoop:
;
; Added 10/19/94 -jw
;
; Allow pointers to the chunk handle, since that's a valid pointer.
; vvvvvvvvvvvvvvvvvvvvvvvvvvvv
cmp si, bx ; pointer to chunk handle?
jne checkBounds ; if not, check the offset
tst {word}ds:[bx] ; Check for free chunk
jnz done ; If not free, pointer is valid
ERROR ADDRESS_OUT_OF_BOUNDS ; Otherwise die die die
checkBounds:
; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mov di, ds:[bx]
tst di ; is chunk free?
jz next
;
; Added 11/10/94 - atw
;
; Allow pointers to the size word of a chunk (which comes before the
; data)
;
lea di, ds:[di].LMC_size ;If the chunk is empty, DI will be
; -3, so the following comparison
; is still valid
cmp di, si
ja next ; SI is before this chunk, or chunk is
; empty (di=-3)
add di, ds:[di] ; di <- after end of the chunk
cmp di, si
ja done
next:
add bx, 2 ; point to next handle
loop startLoop
ERROR ADDRESS_OUT_OF_BOUNDS
done:
popf
.leave
FALL_THRU_POP cx
ret
ECCheckBoundsCommon endp
else
; The Non-EC stub. Should never be called, but needed to
; keep the right kernel relocation numbers between EC and NONEC
ECAssertValidFarPointerXIP proc far
FALL_THRU ECCheckBounds
ECAssertValidFarPointerXIP endp
ECCheckBounds proc far
ret
ECCheckBounds endp
endif
COMMENT @----------------------------------------------------------------------
FUNCTION: ECCheckSegment
DESCRIPTION: Check a segment value for validity
CALLED BY: GLOBAL
PASS:
ax - segment value
RETURN:
none
DESTROYED:
nothing -- even the flags are kept intact
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 9/89 Initial version
------------------------------------------------------------------------------@
NEC <ECCheckSegment proc far >
NEC < FALL_THRU FarCheckDS_ES >
NEC <ECCheckSegment endp >
NEC <FarCheckDS_ES proc far >
NEC < ret >
NEC <FarCheckDS_ES endp >
if ERROR_CHECK
ECCheckSegment proc far
pushf
cmp ax, NULL_SEGMENT
jz done
call NullSeg
cmp ax, NULL_SEGMENT
ERROR_Z ILLEGAL_SEGMENT
done:
popf
ret
ECCheckSegment endp
;-------------------------------------------------
CheckToLock proc far
push ax
mov ax, offset ECCheckMemHandle
call CheckToLockCommon
pop ax
ret
CheckToLock endp
CheckToLockNS proc far
push ax
mov ax, offset ECCheckMemHandleNS
call CheckToLockCommon
pop ax
ret
CheckToLockNS endp
CheckToLockCommon proc near
pushf
push ds
LoadVarSeg ds
call ax
test ds:[bx].HM_flags, mask HF_FIXED
jnz tooManyLocks
cmp ds:[bx].HM_lockCount,MAX_LOCKS
jae tooManyLocks
cmp ds:[bx].HM_lockCount,MAX_LOCKS/2
jae lotsOfLocks
keepGoing:
pop ds
;
; Do not do this if interrupts are currently off -- it can cause
; interrupts to be turned on and lead to much unhappiness.
; -- ardeb 11/8/95
;
push bp
mov bp, sp
test {CPUFlags}ss:[bp+2], mask CPU_INTERRUPT
jz dsEsDone
call CheckDS_ES
dsEsDone:
pop bp
call SafePopf
ret
lotsOfLocks:
;
; This label exists only to allow one to set a breakpoint and
; possibly catch places where the lock count of a block is getting
; large, before it achieves critical death status later on...
;
jmp keepGoing
CheckToLockCommon endp
tooManyLocks:
ERROR TOO_MANY_LOCKS
;-------------------------------------------------
CheckToUnlockNS proc far
pushf
call ECCheckMemHandleNS
push ds
LoadVarSeg ds
cmp ds:[bx][HM_lockCount],0
ERROR_Z BAD_UNLOCK
test ds:[bx].HM_flags, mask HF_FIXED
ERROR_NZ BAD_UNLOCK
cmp ds:[bx].HM_lockCount, LOCK_COUNT_MOVABLE_PERMANENTLY_FIXED
ERROR_E BAD_UNLOCK
pop ds
popf
ret
CheckToUnlockNS endp
CheckSegmentECEnabled proc far
push ds
LoadVarSeg ds
test ds:[sysECLevel], mask ECF_SEGMENT
pop ds
ret
CheckSegmentECEnabled endp
CheckNormalECEnabled proc far
push ds
LoadVarSeg ds
test ds:[sysECLevel], mask ECF_NORMAL
pop ds
ret
CheckNormalECEnabled endp
;-------------------------------------------------
FarCheckDS_ES proc far
call CheckDS_ES
ret
FarCheckDS_ES endp
CheckDS_ES proc near
pushf
call CheckSegmentECEnabled
jz done
push ax
mov ax, ds
call ECCheckSegment
mov ax, es
call ECCheckSegment
pop ax
done:
popf
ret
CheckDS_ES endp
;-------------------------------------------------
NullSegmentRegisters proc far
pushf
call CheckSegmentECEnabled
jz done
push ax
mov ax, ds
call NullSeg
mov ds, ax
mov ax, es
call NullSeg
mov es, ax
pop ax
done:
popf
ret
NullSegmentRegisters endp
NullSeg proc near
tst ax
jz done
cmp ax, NULL_SEGMENT
jz done
;; cmp ax, 0xffff ;HACK FOR THE WINDOW SYSTEM
;; jz done
push cx, ds
cmp ax, 40h ; allow segments pointing into
jb nullIt ; DOS for things like the FS driver
; XXX: this is bullshit. The code does
; *NOT* do this -- ardeb
je popDone ; allow BIOS data area segment...
if UTILITY_MAPPING_WINDOW
;
; leave segment in utility mapping window alone
;
LoadVarSeg ds
tst ds:[utilWindowSegment]
jz notMappingWindow
cmp ax, ds:[utilWindowSegment]
jb notMappingWindow
push ax
mov ax, ds:[utilWindowSize]
mov cx, ds:[utilWindowNumWindows]
dec cx
jcxz haveWindowSize
getWindowSize:
add ax, ds:[utilWindowSize]
loop getWindowSize
haveWindowSize:
shr ax, 1
shr ax, 1
shr ax, 1
shr ax, 1
add ax, ds:[utilWindowSegment]
mov cx, ax ; cx = end of mapping window
pop ax ; ax = segment to check
cmp ax, cx
jb popDone ; in mapping window, leave alone
notMappingWindow:
endif ; UTILITY_MAPPING_WINDOW
if FULL_EXECUTE_IN_PLACE
;
; On XIP systems, if the segment is in the map area, just blindly
; accept it (don't NULL it out) as this routine could be called from
; a routine in movable memory, and so a pointer into the original
; caller's code segment would be treated as invalid. It's better
; to let some possibly invalid segments through than to die
; when passed valid segments.
;
LoadVarSeg ds
;
; Also, if the segment points to the FullXIPHeader block (which
; doesn't have an associated handle), don't null it. This allows
; us to use strings in GeodeNameTableEntry. --- AY 11/14/94
;
; Moved up here, as the mapPage is *not* necessarily below the xip
; header - atw 11/17/94
;
cmp ax, ds:[loaderVars].KLV_xipHeader
je popDone
cmp ax, ds:[loaderVars].KLV_mapPageAddr
jb notInMapArea
push ax
sub ax, ds:[loaderVars].KLV_mapPageAddr
cmp ax, MAPPING_PAGE_SIZE/16
pop ax
jb popDone
notInMapArea:
endif
mov cx, ax
call MemSegmentToHandle
jc found
nullIt:
mov ax, NULL_SEGMENT
jmp popDone
found:
push bx
LoadVarSeg ds
mov bx, cx
test ds:[bx].HM_flags, mask HF_FIXED
jnz 10$
; if this is the block being swapped then it is ok for the lock count
; to be 0
cmp bx, ds:[handleBeingSwappedDontMessWithIt]
jz 10$
cmp ds:[bx].HM_lockCount, 0
jnz 10$
mov ax, NULL_SEGMENT
10$:
pop bx
popDone:
pop cx, ds
done:
ret
NullSeg endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NullDS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Force DS to be NULL_SEGMENT
CALLED BY: (EXTERNAL)
PASS: nothing
RETURN: ds = NULL_SEGMENT
DESTROYED: nothing (flags preserved)
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
nullSeg word NULL_SEGMENT
NullDS proc far
mov ds, cs:[nullSeg]
ret
NullDS endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NullES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Force ES to be NULL_SEGMENT
CALLED BY: (EXTERNAL)
PASS: nothing
RETURN: es = NULL_SEGMENT
DESTROYED: nothing (flags preserved)
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NullES proc far
mov es, cs:[nullSeg]
ret
NullES endp
COMMENT @----------------------------------------------------------------------
FUNCTION: CheckToPOrV
DESCRIPTION: Make sure a handle is legal to P or V
CALLED BY: Utility
PASS:
bx - handle
RETURN:
none
DESTROYED:
nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 9/89 Initial version
------------------------------------------------------------------------------@
CheckToV proc far
pushf
push ds
LoadVarSeg ds
INT_OFF
cmp ds:[bx].HM_otherInfo, 0
jz semOK
jmp checkBlkdThread
CheckToV endp
CheckToP proc far
pushf
push ds
LoadVarSeg ds
INT_OFF
cmp ds:[bx].HM_otherInfo, 1
jbe semOK
checkBlkdThread label near
push bx
mov bx, ds:[bx].HM_otherInfo
call ECCheckThreadHandleFar
pop bx
semOK label near
cmp ds:[bx].HG_type, SIG_VM
jz 10$
cmp ds:[bx].HG_type, SIG_FILE
je 10$
call ECCheckMemHandleNS
10$:
pop ds
popf
ret
CheckToP endp
COMMENT @----------------------------------------------------------------------
FUNCTION: CheckBX_SIAdjacent
DESCRIPTION: Make sure handles bx and si are adjacent
CALLED BY: Utility
PASS:
bx - handle
si - handle
RETURN:
none
DESTROYED:
nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 9/89 Initial version
------------------------------------------------------------------------------@
CheckBX_SIAdjacent proc far
pushf
push ds
LoadVarSeg ds
cmp bx,ds:[bx].HM_next
jz corrupt
cmp bx,ds:[bx].HM_prev
jz corrupt
cmp si,ds:[si].HM_next
jz corrupt
cmp si,ds:[si].HM_prev
jz corrupt
cmp ds:[bx].HM_next, si
jnz comb
cmp ds:[si].HM_prev, bx
jnz comb
pop ds
popf
ret
corrupt:
ERROR CORRUPTED_HEAP
comb:
ERROR COMBINING_NON_ADJACENT_BLOCKS
CheckBX_SIAdjacent endp
;---------
CheckBX proc far
pushf
push si
push ds
LoadVarSeg ds
mov si,ds:[bx].HM_next
call CheckBX_SIAdjacent
mov si,ds:[bx].HM_prev
xchg bx,si
call CheckBX_SIAdjacent
xchg bx,si
pop ds
pop si
popf
ret
CheckBX endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AssertHeapMine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make sure the heap is locked by the current thread
CALLED BY: INTERNAL
PASS: nothing
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/14/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AssertHeapMine proc far uses ds, ax
.enter
pushf
LoadVarSeg ds
cmp ds:heapSem.TL_sem.Sem_value, 0
jg notMine
mov ax, ds:currentThread
cmp ax, ds:heapSem.TL_owner
je isOk
tst ax ; Allow kernel thread too to handle
; freeing of stack blocks &c.
jz isOk
notMine:
ERROR HEAP_NOT_OWNED_BY_ME
isOk:
popf
.leave
ret
AssertHeapMine endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ECMemVerifyHeapLow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make sure the heap is consistent.
CALLED BY: ECMemVerifyHeap, EXTERNAL
PASS: ds = idata
heap semaphore down
RETURN: nothing
DESTROYED: bx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/13/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ECMemVerifyHeapLow proc far uses bx
.enter
call CheckNormalECEnabled
jz done
mov bx, ds:[loaderVars].KLV_handleBottomBlock
MVH_loop:
call CheckHeapHandle
mov bx, ds:[bx].HM_next
cmp bx, ds:[loaderVars].KLV_handleBottomBlock
jnz MVH_loop
call AssertFreeBlocksCC
call ECCheckBlockChecksum
done:
.leave
ret
ECMemVerifyHeapLow endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckHeapHandleSW
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check a handle that may be swapped
CALLED BY: EXTERNAL/INTERNAL
PASS: bx = handle to check
RETURN: nothing
DESTROYED: nothing (not even flags)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/13/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckHeapHandleSW proc far
pushf
INT_OFF
push ds
LoadVarSeg ds
cmp ds:[bx][HM_addr],0
jz 10$
call CheckHeapHandle
10$:
pop ds
popf
ret
CheckHeapHandleSW endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckHeapHandle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make sure a handle is a valid, resident memory handle
CALLED BY: INTERNAL/EXTERNAL
PASS: bx = handle to check (should likely be locked or the
heap semaphore should be down)
RETURN: nothing
DESTROYED: flags
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/13/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckHeapHandle proc far
push ax
push ds
LoadVarSeg ds
; Block resident?
cmp ds:[bx][HM_addr],0
jz corrupt
; Resonably sized?
cmp ds:[bx][HM_size],0
ifdef PRODUCT_GEOS32 ; GEOS32 doesn't have a heap of linear memory
jnz 11$
else
jz corrupt
; Stretches to next block?
push bx
mov ax,ds:[bx][HM_size]
add ax,ds:[bx][HM_addr]
jc corrupt
mov bx,ds:[bx][HM_next]
cmp bx,ds:[loaderVars].KLV_handleBottomBlock
; was bx last block on heap?
jz 10$ ; => has no next
sub ax,ds:[bx][HM_addr] ; Matches next? Use sub so
jz 10$ ; we can see if next was in
; transit.
; block doesn't reach to next -- see if next was in transit at
; the time. we must do this as unless the heap semaphore is down,
; we've been granted surety only for the handle being checked.
pop bx
sub ax, ds:[bx].HM_addr
cmp ax, ds:[bx].HM_size
je 11$
endif ; defined(PRODUCT_GEOS32)
corrupt:
ERROR CORRUPTED_HEAP
ifndef PRODUCT_GEOS32 ; GEOS32 doesn't have a heap of linear memory
10$:
pop bx
endif ; defined(PRODUCT_GEOS32)
11$:
; Check flag validity
test ds:[bx][HM_flags],mask HF_SWAPPED or mask HF_DISCARDED
jnz corrupt
test ds:[bx][HM_flags],mask HF_LMEM
jnz lmem
20$:
cmp ds:[bx][HM_owner],0 ; block free?
jnz 40$
test ds:[bx][HM_flags], not mask HF_DEBUG ; flags must be zero if so
jnz corrupt
40$:
pop ds
pop ax
ret
lmem:
; This checking has a race condition because FullObjLock momentarily
; has the block with an incorrect LMBH_handle
if 0
INT_OFF
tst ds:[bx].HM_lockCount
jz afterLMemCheck
; handle race condition in FullObjLock where the block is realloced
; to a single paragraph before calling MemSwap.
cmp ds:[bx].HM_size, 1
je afterLMemCheck
; Check lmem parameters
mov ds,ds:[bx][HM_addr]
; Handle matches handle in header?
cmp bx,ds:LMBH_handle
jnz corruptLMem
; Reasonable lmem blocktype?
cmp ds:LMBH_lmemType, LMemType
jae corruptLMem
afterLMemCheck:
INT_ON
endif
LoadVarSeg ds
jmp 20$
if 0
corruptLMem:
ERROR CORRUPTED_LMEM_BLOCK
endif
CheckHeapHandle endp
endif
COMMENT @-----------------------------------------------------------------------
FUNCTION: AssertFreeBlocksCC
DESCRIPTION: Make sure that all bytes in all free blocks are 0xcc
CALLED BY: INTERNAL
AllocHandleAndBytes, ECMemVerifyHeapLow
PASS:
exclusive access to heap variables
ds - kernel data segment
RETURN:
none
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 2/90 Initial version
-------------------------------------------------------------------------------@
if ERROR_CHECK
AssertFreeBlocksCC proc far
pushf
call PushAllFar
call SysGetECLevel
test ax, mask ECF_FREE
jz done
; start at the bottom of the heap
clr si
mov ax, 0xcccc
mov bx, ds:[loaderVars].KLV_handleBottomBlock
if TRACK_FINAL_FREE
clr bp
endif
blockLoop:
cmp ds:[bx].HM_owner, 0
jnz notFree
if TRACK_FINAL_FREE
mov bp, bx ; remember last one seen
endif
; block is free -- test it
mov es, ds:[bx].HM_addr ;es = block
mov dx, ds:[bx].HM_size ;dx = # paragraphs
add si, dx ;add to total
largeLoop:
mov cx, dx
cmp cx, 0xfff
jb 10$
mov cx, 0xfff
10$:
sub dx, cx ;dx = # paragraphs left
shl cx
shl cx
shl cx ;cx = # words
clr di
repe scasw
ERROR_NZ MEM_FREE_BLOCK_DATA_NOT_CC
mov cx, es ;assume > 0xfff paragraphs
add cx, 0xfff
mov es, cx
tst dx
jnz largeLoop
; move to next block
notFree:
mov bx, ds:[bx].HM_next
cmp bx, ds:[loaderVars].KLV_handleBottomBlock
jnz blockLoop
cmp si, ds:[loaderVars].KLV_heapFreeSize
ERROR_NE FREE_SIZE_NOT_CORRECT
if TRACK_FINAL_FREE
cmp bp, ds:[lastFreeBlock]
ERROR_NE LAST_FREE_BLOCK_NOT_CORRECT
endif
done:
call PopAllFar
popf
ret
AssertFreeBlocksCC endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckLastFreeBlock
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make sure the lastFreeBlock variable is set right
CALLED BY: (INTERNAL)
PASS: ds = kdata
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/26/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if TRACK_FINAL_FREE
CheckLastFreeBlock proc near
uses ax, si
.enter
pushf
mov si, ds:[loaderVars].KLV_handleBottomBlock
mov ax, si
checkFreeLoop:
mov si, ds:[si].HM_next
cmp si, ds:[loaderVars].KLV_handleBottomBlock
je checkLastFree
cmp ds:[si].HM_owner, 0
jne checkFreeLoop
mov ax, si
jmp checkFreeLoop
checkLastFree:
cmp ax, ds:[lastFreeBlock]
ERROR_NE LAST_FREE_BLOCK_NOT_CORRECT
popf
.leave
ret
CheckLastFreeBlock endp
endif
COMMENT @----------------------------------------------------------------------
FUNCTION: ECFillCCCC
DESCRIPTION: Fill a block with 0xcc for EC purposes
CALLED BY: GLOBAL
PASS: ds = idata
bx = block to fill
RETURN:
DESTROYED:
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 1/90 Initial version
------------------------------------------------------------------------------@
ECFillCCCC proc far
call PushAllFar
mov es,ds:[bx][HM_addr]
mov dx,ds:[bx][HM_size]
mov ax, 0xcccc
largeLoop:
mov cx, 0xfff
sub dx, cx ;assume 0xfff0 bytes
jae 10$ ;=> ok
add cx, dx ;downgrade count by overshoot
10$:
shl cx ;convert paras to words
shl cx
shl cx ;cx = # words
clr di
rep stosw
mov cx, es ;assume > 0xfff paragraphs
add cx, 0xfff
mov es, cx
tst dx ;XXX: assumes no free block
; > 1/2 megabyte. Fair enough?
jg largeLoop
call PopAllFar
ret
ECFillCCCC endp
COMMENT @----------------------------------------------------------------------
FUNCTION: ECCheckBlockChecksum
DESCRIPTION: Check the checksum of the block passed to SysSetECLevel
CALLED BY: INTERNAL
PASS:
none
RETURN:
none
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 1/90 Initial version
------------------------------------------------------------------------------@
ECCheckBlockChecksumFar proc far
call ECCheckBlockChecksum
ret
ECCheckBlockChecksumFar endp
ForceRef ECCheckBlockChecksumFar ; mostly for calling from Swat...
ECCheckBlockChecksum proc near
pushf
push ds
call FarLoadVarSegDS
test ds:[sysECLevel], mask ECF_BLOCK_CHECKSUM
jz done
; DO NOT USE PushAll !!! It destroys callVector.segment.
; It may not, in the future, however....
push ax, bx, cx, dx, si, di, es
mov bx, ds:[sysECBlock]
mov dx, ds:[bx].HM_addr
tst dx
jz donePop
mov cx, ds:[bx].HM_size
mov ds, dx
; bx = handle
; ds = block
; cx = block size in paragraphs
;----------------
if 1 ;Checksum
; generate the checksum -- cx = # paragraphs
clr si
clr di ;di = checksum
addLoop:
lodsw ;1
add di, ax
lodsw ;2
add di, ax
lodsw ;3
add di, ax
lodsw ;4
add di, ax
lodsw ;5
add di, ax
lodsw ;6
add di, ax
lodsw ;7
add di, ax
lodsw ;8
add di, ax
loop addLoop
call FarLoadVarSegDS
cmp dx, ds:[bx].HM_addr
jnz donePop
; di = checksum (if 0 then make 1)
tst di
jnz notZero
inc di
notZero:
cmp ds:[sysECChecksum],0
jz storeNew
cmp di, ds:[sysECChecksum]
jz storeNew
ERROR BLOCK_CHECHSUM_ERROR
storeNew:
mov ds:[sysECChecksum], di
endif
;----------------
if 0 ;Trying to find the "6 bug"
clr si
dec cx
aloop:
cmp {word} ds:[si+2], 6
jnz diff
found: ;set breakpoint here
nop
diff:
add si, 16
loop aloop
endif
;----------------
donePop:
pop ax, bx, cx, dx, si, di, es
done:
pop ds
popf
ret
ECCheckBlockChecksum endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MemForceMove
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Force the passed block to move on the heap, due to some
error-checking flag having been set.
CALLED BY: (EXTERNAL) MemUnlock, ForceBlockToMove
PASS: ds = dgroup
bx = block to move (keeps same lock count)
cx = non-zero if should only move the block if the
lock count is 0 (and block is still resident) after
grabbing the heap lock.
RETURN: nothing
DESTROYED: cx
SIDE EFFECTS: Block will move on the heap, if possible.
PSEUDO CODE/STRATEGY:
The essence of the strategy here is to give the current
memory to a new handle, pretend the block to move has been
discarded, then call DoReAlloc to allocate more memory for
the block and call our callback routine. The callback routine
then copies the data from the old place to the new. When
DoReAlloc returns, we free the old memory (and the new
handle) and we're done.
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MemForceMove proc far
uses dx, si, di
.enter
;
; We are sometimes called from interrupt code (the sound library
; unlocking the just-finished stream is the most notable case) and
; do *not* want to do this during interrupt code.
;
tst ds:[interruptCount]
jnz exeuntOmnes
;
; Gain exclusive access to the heap for the duration here and zero the
; address of the handle, so anyone else attempting to lock it must
; wait on our release of the semaphore.
;
call FarPHeap
clr dx
xchg ds:[bx].HM_addr, dx
;
; Make sure the block didn't get locked while we were waiting on the
; heapSem.
;
tst dx
jz noMove ; => got swapped/discarded while count
; was 0, which means our purpose was
; accomplished by someone else
jcxz moveIt ; => don't care about lock count...
tst ds:[bx].HM_lockCount
jz moveIt
noMove:
;
; It got locked or swapped in that little window, so restore the
; segment and get out. There's nothing more we need to or can do.
;
mov ds:[bx].HM_addr, dx
jmp unlockMoveDone
moveIt:
;
; First make a copy of the handle whose memory will be moved and
; link it into the heap in place of the one being moved, giving the
; memory to the duplicate. We leave the duplicate unlocked and allow
; it to be swapped, if necessary, to allocate the new memory (hopefully
; it won't happen in the same place :) to avoid memory-full deaths.
; We cannot allow the memory to be discarded, however: that's getting
; too complicated.
;
EC < call AssertHeapMine >
call FarDupHandle ; bx <- new handle
mov ds:[bx].HM_addr, dx ; (set addr so FixLinks2 does
; something)
call FixLinks2Far ; link duplicate in place of old
andnf ds:[bx].HM_flags, not (mask HF_DISCARDABLE or \
mask HF_DEBUG)
;
; Now mark the one being moved as having been discarded, so the callback
; we pass to DoReAlloc will be called.
;
xchg bx, si
ornf ds:[bx].HM_flags, mask HF_DISCARDED
mov ds:[handleBeingForceMoved], bx
clr ax ; same size
clr ch
mov dx, offset MemForceMoveCallback
mov di, si ; di <- data for callback
; (handle w/old mem)
push di ; save for free on return
call DoReAllocFar
mov di, bx ; preserve orig handle
pop bx ; while we pop the handle with
mov ds:[handleBeingForceMoved], 0
; the original memory
jc cannotAlloc
call DoFreeFar
mov bx, di
unlockMoveDone:
call FarVHeap
exeuntOmnes:
.leave
ret
cannotAlloc:
;
; Couldn't allocate memory for the block, so give it back what it had
; before. At the very worst, the dup handle has been swapped out, which
; would also accomplish our end.
;
mov si, di
xchg bx, si ; bx <- orig handle
; si <- dup handle
call SwapHandlesFar
jmp unlockMoveDone
MemForceMove endp
kcode segment ; this has to be kcode, because DoReAlloc does
; a blind near call to it.. ei "call dx"
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MemForceMoveCallback
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Callback routine to copy the contents of a block being
moved by ECF_UNLOCK_MOVE or ECF_LMEM_MOVE
CALLED BY: (INTERNAL) MemForceMove via DoReAlloc
PASS: bx = handle being moved
si = handle holding new memory for it
di = handle holding old memory for it
ds = dgroup
RETURN: nothing
DESTROYED: ax, cx, dx, di
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MemForceMoveCallback proc near
.enter
test ds:[di].HM_flags, mask HF_SWAPPED
jz copyMem
push bx
mov bx, di ; pretend to swap in the old memory
call MemSwapInCallDriver
mov di, bx
pop bx
ERROR_C ECF_UNLOCK_MOVE_FAILED_SORRY
;
; Change the status of the old block from swapped to discarded so we
; don't double-free the swap space (which was freed by the swap-in)
;
xornf ds:[di].HM_flags, mask HF_SWAPPED or mask HF_DISCARDED
jmp done
copyMem:
;
; Use the common move routine to perform the copy.
;
mov ax, ds:[si].HM_addr ; ax <- dest addr
mov cx, ds:[bx].HM_size ; cx <- # paras to move
mov dx, ds:[di].HM_addr ; dx <- src addr
call MoveBlock
done:
.leave
ret
MemForceMoveCallback endp
kcode ends
endif ; ERROR_CHECK
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ECCheckPageChecksum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Does a checksum check on the currently mapped in page
CALLED BY: GLOBAL
PASS: nada
RETURN: nada
DESTROYED: nada
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 5/ 5/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if ERROR_CHECK and FULL_EXECUTE_IN_PLACE
ECCheckPageChecksum proc far uses ds
.enter
pushf
LoadVarSeg ds
tst ds:[xipChecksumPage]
jz exit
push ax
mov ax, ds:[xipChecksumPage]
cmp ax, ds:[curXIPPage]
pop ax
jne exit
; Generate a checksum for the page
push ax, cx, si
mov ds, ds:[loaderVars].KLV_mapPageAddr
clr si ;DS:SI <- ptr to start of page to
; checksum
mov cx, MAPPING_PAGE_SIZE/(size word)
clr ax
next:
add ax, ds:[si]
add si, 2
loop next
; Don't allow a checksum of 0
tst ax
jz 10$
inc ax
10$:
LoadVarSeg ds
tst ds:[xipChecksum]
jnz 20$
mov ds:[xipChecksum], ax
20$:
cmp ax, ds:[xipChecksum]
ERROR_NZ BLOCK_CHECHSUM_ERROR
pop ax, cx, si
exit:
popf
.leave
ret
ECCheckPageChecksum endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ECCheckXIPPageNumber
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Checks if the passed page number is valid for the XIP
image.
CALLED BY: MapXIPPageInline macro
PASS: ax = page number (in multiples of the mapping page size)
RETURN: nothing. Fatal error if invalid.
DESTROYED: flags
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
Each device needs to have its own check.
Make sure you add the product to the list of products in
MapXIPPageInline that calls this function.
REVISION HISTORY:
Name Date Description
---- ---- -----------
JimG 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if ERROR_CHECK and FULL_EXECUTE_IN_PLACE
if GULLIVER_XIP
ECCheckXIPPageNumber proc far
uses ax
.enter
; Convert ax to physical page size if mapping page size !=
; physical page size
if MAPPING_PAGE_SIZE eq PHYSICAL_PAGE_SIZE * 2
shl ax, 1
elseif MAPPING_PAGE_SIZE ne PHYSICAL_PAGE_SIZE
ErrMessage <Write code to deal with big mapping page>
endif
; Unfortunately, zero is valid because when a thread is started, the
; initial ThreadBlockState for a thread has TBS_xipPage initialized
; to zero. This is an interesting problem since DispatchSI, which
; will be the one popping the page number off the stack and calling
; MapXIPPageInline, causes pages 0 (and 1?) to be mapped in even if
; they aren't in the XIP image...
tst ax
jz done
if GULLIVER_XIP
cmp ax, XIP_PAGE_START_1
ERROR_B XIP_PAGE_NUMBER_NOT_IN_VALID_RANGE
cmp ax, XIP_PAGE_END_1
jbe done
cmp ax, XIP_PAGE_START_2
ERROR_B XIP_PAGE_NUMBER_NOT_IN_VALID_RANGE
cmp ax, XIP_PAGE_END_2
ERROR_A XIP_PAGE_NUMBER_NOT_IN_VALID_RANGE
endif
done::
.leave
ret
ECCheckXIPPageNumber endp
endif ;GULLIVER_XIP or PENELOPE_XIP or DOVE_XIP
endif
if ERROR_CHECK
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AddToOddityList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Adds an entry to the Oddity List. Gives an Error if
List is full.
CALLED BY: Originally called by VMWriteBlk to track odd-state
biffing blocks
PASS: bx - Handle to add
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS: Dies if list is full
PSEUDO CODE/STRATEGY:
Lock Oddity List
Find Handle (null)
if result = null
Error
else
calc offset
stick kdata:offset, Handle
Release Oddity List
REVISION HISTORY:
Name Date Description
---- ---- -----------
RG 11/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AddToOddityList proc far
uses bp, ds
.enter
LoadVarSeg ds
call LockOddityList
;
; Find Handle
;
push bx
clr bx
call FindInOddityList
pop bx
;
; if result = 0, list is full!
;
tst bp
ERROR_Z GASP_CHOKE_WHEEZE
;
; place handle in list
;
mov ds:[bp].startOfOddityList, bx
;
; Release the lock
;
call ReleaseOddityList
.leave
ret
AddToOddityList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RemoveFromOddityList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Removes and entry from the Oddity List. Gives an
Error if it wasn't there.. it's not like we should be guessing!
CALLED BY: probably just VMWriteBlk
PASS: bx - Handle to remove
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
Lock Oddity List
Find Handle (Handle)
if result = null
Error
else
calc offset
stick kdata:offset, 0
Release Oddity List
yes.. I know this looks awefully like the Add routine..
REVISION HISTORY:
Name Date Description
---- ---- -----------
RG 11/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RemoveFromOddityList proc far
uses bp, ds
.enter
LoadVarSeg ds
call LockOddityList
call FindInOddityList
tst bp
ERROR_Z GASP_CHOKE_WHEEZE
clr {word}ds:[bp].startOfOddityList
call ReleaseOddityList
.leave
ret
RemoveFromOddityList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FindInOddityList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: looks up a word value in the Oddity List
CALLED BY: anybody..
PASS: bx - value to find
ds - kdata
RETURN: bp - offset from start to requested word, or 0 if not found
DESTROYED: nothing
SIDE EFFECTS: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
RG 11/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FindInOddityList proc far
.enter
call LockOddityList
mov bp, offset startOfOddityList + (size startOfOddityList)-2
loopTop:
cmp bx, ds:[bp]
je done
dec bp
dec bp
cmp bp, offset startOfOddityList
jne loopTop
done:
sub bp, offset startOfOddityList
call ReleaseOddityList
.leave
ret
FindInOddityList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LockOddityList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Locks down a semaphore whose handle is stored at
kdata:startOfOddityList. If the handle = 0 it creates
a semaphore.
CALLED BY: the oddilty list stuff..
PASS: ds - kdata
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
RG 11/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
LockOddityList proc near
uses bx
.enter
pushf ; to restore interrupts to
; initial state
INT_OFF
mov bx, ds:[startOfOddityList]
tst bx
jz createLock
popf
returnFromCreate:
call ThreadGrabThreadLock
.leave
ret
createLock:
call ThreadAllocThreadLock
mov ds:[bx].HS_owner, Handle 0
mov ds:[startOfOddityList], bx
popf
jmp returnFromCreate
LockOddityList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ReleaseOddityList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Just releases the lock..
CALLED BY: oddity list stuff
PASS: ds - kdata
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
RG 11/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ReleaseOddityList proc near
uses bx
.enter
mov bx, ds:[startOfOddityList]
call ThreadReleaseThreadLock
.leave
ret
ReleaseOddityList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ECCheckHandleForWeirdness
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Checks the handle for a special case for these two routines.
CALLED BY: SearchHeap and FindNOldest
PASS: bx - Mem Handle
ds - kdata
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
RG 2/ 8/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ECCheckHandleForWeirdness proc far
.enter
;
; what a mess! OK. The funny business going on here is due to a
; possible recursion because of Objectblocks being biffed
; asynchronously (VMA_TEMP_ASYNC mechanism). So we may have a locked
; VM Block with an address of zero coming through. Since it is
; owned (SearchHeap case) and locked (FindNOldest case) it will be
; skipped in Non-EC, but that CheckHeapHandle will choke in EC. So,
; we check for this case as specifically as we can and skip the
; CheckHeapHandle only in this particular case.
;
tst ds:[bx].HM_addr ; handle the commoncase
jnz okCheckHandle
push bx
mov bx, ds:[bx].HM_owner
cmp ds:[bx].HVM_signature, SIG_VM ; only odd ok case
jne restoreAndCheckHandle
cmp ds:[bx].HVM_semaphore, 1 ; and must be entered
je restoreAndCheckHandle
mov bx, ds:[bx].HVM_headerHandle ; must be entered by
mov bx, ds:[bx].HM_usageValue ; this thread!
cmp bx, ds:[currentThread]
jne restoreAndCheckHandle
pop bx
tst {byte}ds:[bx].HM_lockCount ; and locked
jz okCheckHandle
push bp ; call trashes bp
call FindInOddityList
tst bp
pop bp
jnz afterCheckHandle ; so skip
jmp okCheckHandle
restoreAndCheckHandle:
pop bx
okCheckHandle:
call CheckHeapHandle
afterCheckHandle:
.leave
ret
ECCheckHandleForWeirdness endp
endif ;ERROR_CHECK
ECCode ends
|
alloy4fun_models/trashltl/models/11/qJZPYncmTc4MNJZMc.als | Kaixi26/org.alloytools.alloy | 0 | 1420 | open main
pred idqJZPYncmTc4MNJZMc_prop12 {
eventually (some f : File | eventually after f in Trash)
}
pred __repair { idqJZPYncmTc4MNJZMc_prop12 }
check __repair { idqJZPYncmTc4MNJZMc_prop12 <=> prop12o } |
1A/S5/PIM/tps/tp6/exemples_memoire_dynamique.adb | MOUDDENEHamza/ENSEEIHT | 4 | 3105 | with Piles;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation; --// Pour libérer la mémoire allouée dynamiquement
procedure Exemples_Memoire_Dynamique is
type T_Pointeur_Integer is access Integer;
procedure Free
is new Ada.Unchecked_Deallocation (Integer, T_Pointeur_Integer);
-- ou Ada.Unchecked_Deallocation (Object => Integer, Name => T_Pointeur_Integer);
-- Allocation dynamique de mémoire et libération de cette mémoire.
procedure Illustrer_Memoire_Dynamique is
Ptr1 : T_Pointeur_Integer;
begin
Ptr1 := new Integer; -- Allocation dyamique de mémoire
Ptr1.all := 5; -- Utilisation de cette mémoire
Put_Line ("Ptr1.all = " & Integer'Image (Ptr1.all));
Free (Ptr1); -- Libération de la mémoire
pragma Assert (Ptr1 = Null); -- Free met le pointeur à Null
end Illustrer_Memoire_Dynamique;
-- Mémoire allouée dynamiquement et non libérée.
procedure Illustrer_Memoire_Dynamique_Sans_Free is
Ptr1 : T_Pointeur_Integer;
begin
Ptr1 := new Integer;
Ptr1.all := 5;
Put_Line ("Ptr1.all = " & Integer'Image (Ptr1.all));
Free (Ptr1);
end Illustrer_Memoire_Dynamique_Sans_Free;
-- Illustrer la libération explicite de la mémoire et les précautions à
-- prendre...
procedure Illustrer_Memoire_Dynamique_Erreur is
Ptr1, Ptr2 : T_Pointeur_Integer;
begin
Ptr1 := new Integer;
Ptr2 := Ptr1;
Ptr1.all := 5;
pragma Assert (Ptr1.all = 5);
pragma Assert (Ptr2.all = 5);
Free (Ptr1);
pragma Assert (Ptr1 = Null); -- le pointeur est bien mis à Null
pragma Assert (Ptr2 /= Null);
-- XXX Quelle est la valeur de Ptr2.all ? Null.
--Put_Line ("Ptr2.all = " & Integer'Image (Ptr2.all));
--Ptr2.all := 7;
--pragma Assert (Ptr2.all = 7);
-- XXX A-t-on le droit de manipuler Ptr2.all ? Non.
-- Si on éxucute le programme une exception est levée.
-- XXX Que se passe-t-il si on exécute le programme avec valkyrie ?
--
--
-- Le terme "Unchecked" dans Unchecked_Deallocation vient de là. Ada
-- n'a pas de moyen de contrôler que quand on libère de la mémoire il
-- n'y a plus aucun pointeur dans le programme qui la référence. C'est
-- à la charge du programmeur ! Utiliser un ramasse-miettes (garbage
-- collector) résoud ce problème car il ne libèrera la mémoire que s'il
-- n'y a plus aucune référence dessus.
end Illustrer_Memoire_Dynamique_Erreur;
-- Illustrer les conséquence d'avoir un paramètre en in qui est un pointeur.
procedure Illustrer_Pointeur_In is
procedure SP (Ptr : in T_Pointeur_Integer) is
begin
Ptr.all := 123;
end SP;
Ptr : T_Pointeur_Integer;
begin
Ptr := new Integer;
Ptr.all := 111;
SP (Ptr);
-- XXX Quelle est la valeur de Ptr.all ? 123
Put_Line ("valeur de Ptr.all ? " & Integer'Image (Ptr.all));
Free (Ptr);
end Illustrer_Pointeur_In;
-- Illustrer la question "Faut-il Detruire un pile chaînée si c'est
-- une variable locale d'un sous-programme ?".
procedure Illustrer_Pile_Locale is
package Pile is
new Piles (Integer);
use Pile;
P : T_Pile;
begin
Initialiser (P);
Empiler (P, 4);
Put_Line ("Sommet = " & Integer'Image (Sommet (P)));
Empiler (P, 2);
Put_Line ("Sommet = " & Integer'Image (Sommet (P)));
Detruire (P);
-- XXX P étant une variable locale du sous-programme, a-t-on besoin
-- d'appeler Detruire dessus ? OUI
end Illustrer_Pile_Locale;
begin
Illustrer_Memoire_Dynamique;
Illustrer_Memoire_Dynamique_Sans_Free;
Illustrer_Memoire_Dynamique_Erreur;
Illustrer_Pointeur_In;
Illustrer_Pile_Locale;
end Exemples_Memoire_Dynamique;
|
programs/oeis/098/A098033.asm | jmorken/loda | 1 | 87300 | ; A098033: Parity of p(p+1)/2 for n-th prime p.
; 1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,1,1,1,0,0,1,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,1,0,1,0,0,1,1,0,1,0,1,1,0,0,1,0,0,1,1,1,1,0,1,0,1,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,1,0,1,0,1,0
cal $0,40 ; The prime numbers.
mul $0,15
div $0,2
mod $0,2
mov $1,$0
|
src/Compiler/ASM/Runtime/asm/itoa_and_write.asm | PetukhovVictor/compiler2 | 3 | 240954 | <gh_stars>1-10
%define ASCII_ZERO 48
%define ASCII_MINUS 45
global itoa_and_write
itoa_and_write:
.itoa_start:
test eax, eax ; this test uses the SF flag (significant bit check)
js .itoa_print_minus ; if the first bit is 1 (SF=1), then the number is negative (go to the print minus section)
xor edx, edx ; zeroing EDX (division remainder is written in it)
mov ebx, 10 ; 10 is a divisor (because we output the values in the decimal system)
div ebx ; the division of EAX by 10
push edx ; storing a division remainder (it correspond to the digits that we will output in the reverse order)
test eax, eax ; check that the quotient is 0 (this test uses the ZF flag)
je .itoa_next ; expanding recursion: printing ascii symbols, that correspond to the division remainders
call itoa_and_write ; recursive call to process next symbol
.itoa_next:
pop edx ; get previously stored division remainders
lea eax, [edx + ASCII_ZERO] ; convert division remainder to the ascii symbol code
call write
ret ; recursive return
.itoa_print_minus:
mov ebx, eax ; storing a EAX (because write already use EAX)
mov eax, ASCII_MINUS
call write
mov eax, ebx ; restoring a EAX
neg eax ; number invert to negative
jmp .itoa_start ; continue process symbols
|
src/base/dates/util-dates-iso8601.ads | RREE/ada-util | 60 | 8893 | <reponame>RREE/ada-util
-----------------------------------------------------------------------
-- util-dates-iso8601 -- ISO8601 dates
-- Copyright (C) 2011, 2013, 2016, 2018 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
-- == ISO8601 Dates ==
-- The ISO8601 defines a standard date format that is commonly used and easily parsed by programs.
-- The `Util.Dates.ISO8601` package provides an `Image` function to convert a date into that
-- target format and a `Value` function to parse such format string and return the date.
--
-- Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
-- S : constant String := Util.Dates.ISO8601.Image (Now);
-- Date : Ada.Calendar.time := Util.Dates.ISO8601.Value (S);
--
-- A `Constraint_Error` exception is raised when the date string is not in the correct format.
package Util.Dates.ISO8601 is
type Precision_Type is (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, SUBSECOND);
-- Parses an ISO8601 date and return it as a calendar time.
-- Raises Constraint_Error if the date format is not recognized.
function Value (Date : in String) return Ada.Calendar.Time;
-- Return the ISO8601 date.
function Image (Date : in Ada.Calendar.Time) return String;
function Image (Date : in Date_Record) return String;
function Image (Date : in Ada.Calendar.Time;
Precision : in Precision_Type) return String;
function Image (Date : in Date_Record;
Precision : in Precision_Type) return String;
end Util.Dates.ISO8601;
|
Everything.agda | Akshobhya1234/agda-NonAssociativeAlgebra | 2 | 14099 | import Loop
import Loop.Bundles
import Loop.Definitions
import Loop.Properties
import Loop.Structures
import Magma
import Magma.Bundles
import Magma.Definitions
import Magma.Properties
import Magma.Structures
import Morphism.Structures
import Quasigroup
import Quasigroup.Bundles
import Quasigroup.Definitions
import Quasigroup.Properties
import Quasigroup.Structures
|
focus-formation.agda | hazelgrove/hazelnut-dynamics-agda | 16 | 14535 | open import core
module focus-formation where
-- every ε is an evaluation context -- trivially, here, since we don't
-- include any of the premises in red brackets about finality
focus-formation : ∀{d d' ε} → d == ε ⟦ d' ⟧ → ε evalctx
focus-formation FHOuter = ECDot
focus-formation (FHAp1 sub) = ECAp1 (focus-formation sub)
focus-formation (FHAp2 sub) = ECAp2 (focus-formation sub)
focus-formation (FHNEHole sub) = ECNEHole (focus-formation sub)
focus-formation (FHCast sub) = ECCast (focus-formation sub)
focus-formation (FHFailedCast x) = ECFailedCast (focus-formation x)
|
oeis/040/A040522.asm | neoneye/loda-programs | 11 | 166774 | ; A040522: Continued fraction for sqrt(546).
; Submitted by <NAME>
; 23,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1,2,1,2,46,2,1
mov $1,-82
pow $1,$0
mul $1,14
bin $1,2
mov $0,$1
div $0,9
mul $0,6
sub $0,60
div $0,42
div $1,2
gcd $1,$0
mov $0,$1
div $0,2
add $0,1
|
Cats/Category/Constructions/Epi.agda | alessio-b-zak/cats | 0 | 10573 | <reponame>alessio-b-zak/cats
module Cats.Category.Constructions.Epi where
open import Level
open import Cats.Category.Base
module Build {lo la l≈} (Cat : Category lo la l≈) where
private open module Cat = Category Cat
open Cat.≈-Reasoning
IsEpi : ∀ {A B} → A ⇒ B → Set (lo ⊔ la ⊔ l≈)
IsEpi {A} {B} f = ∀ {C} {g h : B ⇒ C} → g ∘ f ≈ h ∘ f → g ≈ h
|
src/fot/FOTC/Data/Conat/Equality/PropertiesI.agda | asr/fotc | 11 | 15200 | <reponame>asr/fotc<gh_stars>10-100
------------------------------------------------------------------------------
-- Properties for the equality on Conat
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.Conat.Equality.PropertiesI where
open import FOTC.Base
open import FOTC.Data.Conat
open import FOTC.Data.Conat.Equality.Type
------------------------------------------------------------------------------
-- Because a greatest post-fixed point is a fixed-point, then the
-- relation _≈_ is also a pre-fixed point of the functional ≈-F, i.e.
--
-- ≈-F _≈_ ≤ _≈_ (see FOTC.Data.Conat.Equality.Type).
≈-in :
∀ {m n} →
m ≡ zero ∧ n ≡ zero
∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ m' ≈ n') →
m ≈ n
≈-in h = ≈-coind R h' h
where
R : D → D → Set
R m n = m ≡ zero ∧ n ≡ zero
∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ m' ≈ n')
h' : ∀ {m n} → R m n →
m ≡ zero ∧ n ≡ zero
∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ R m' n')
h' (inj₁ prf) = inj₁ prf
h' (inj₂ (m' , n' , prf₁ , prf₂ , m'≈n')) =
inj₂ (m' , n' , prf₁ , prf₂ , ≈-out m'≈n')
≈-refl : ∀ {n} → Conat n → n ≈ n
≈-refl {n} Cn = ≈-coind R h₁ h₂
where
R : D → D → Set
R a b = Conat a ∧ Conat b ∧ a ≡ b
h₁ : ∀ {a b} → R a b →
a ≡ zero ∧ b ≡ zero
∨ (∃[ a' ] ∃[ b' ] a ≡ succ₁ a' ∧ b ≡ succ₁ b' ∧ R a' b')
h₁ (Ca , Cb , h) with Conat-out Ca
... | inj₁ prf = inj₁ (prf , trans (sym h) prf)
... | inj₂ (a' , prf , Ca') =
inj₂ (a' , a' , prf , trans (sym h) prf , (Ca' , Ca' , refl))
h₂ : R n n
h₂ = Cn , Cn , refl
≡→≈ : ∀ {m n} → Conat m → Conat n → m ≡ n → m ≈ n
≡→≈ Cm _ refl = ≈-refl Cm
|
test/Fail/Issue2442-conflicting.agda | shlevy/agda | 1,989 | 14825 | {-# OPTIONS --safe --no-termination-check #-}
module Issue2442-conflicting where
|
support/MinGW/lib/gcc/mingw32/9.2.0/adainclude/a-zchhan.adb | orb-zhuchen/Orb | 0 | 29702 | <filename>support/MinGW/lib/gcc/mingw32/9.2.0/adainclude/a-zchhan.adb<gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ W I D E _ C H A R A C T E R S . H A N D L I N G --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010-2019, 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.Wide_Wide_Characters.Unicode; use Ada.Wide_Wide_Characters.Unicode;
package body Ada.Wide_Wide_Characters.Handling is
---------------------
-- Is_Alphanumeric --
---------------------
function Is_Alphanumeric (Item : Wide_Wide_Character) return Boolean is
begin
return Is_Letter (Item) or else Is_Digit (Item);
end Is_Alphanumeric;
----------------
-- Is_Control --
----------------
function Is_Control (Item : Wide_Wide_Character) return Boolean is
begin
return Get_Category (Item) = Cc;
end Is_Control;
--------------
-- Is_Digit --
--------------
function Is_Digit (Item : Wide_Wide_Character) return Boolean
renames Ada.Wide_Wide_Characters.Unicode.Is_Digit;
----------------
-- Is_Graphic --
----------------
function Is_Graphic (Item : Wide_Wide_Character) return Boolean is
begin
return not Is_Non_Graphic (Item);
end Is_Graphic;
--------------------------
-- Is_Hexadecimal_Digit --
--------------------------
function Is_Hexadecimal_Digit (Item : Wide_Wide_Character) return Boolean is
begin
return Is_Digit (Item)
or else Item in 'A' .. 'F'
or else Item in 'a' .. 'f';
end Is_Hexadecimal_Digit;
---------------
-- Is_Letter --
---------------
function Is_Letter (Item : Wide_Wide_Character) return Boolean
renames Ada.Wide_Wide_Characters.Unicode.Is_Letter;
------------------------
-- Is_Line_Terminator --
------------------------
function Is_Line_Terminator (Item : Wide_Wide_Character) return Boolean
renames Ada.Wide_Wide_Characters.Unicode.Is_Line_Terminator;
--------------
-- Is_Lower --
--------------
function Is_Lower (Item : Wide_Wide_Character) return Boolean is
begin
return Get_Category (Item) = Ll;
end Is_Lower;
-------------
-- Is_Mark --
-------------
function Is_Mark (Item : Wide_Wide_Character) return Boolean
renames Ada.Wide_Wide_Characters.Unicode.Is_Mark;
---------------------
-- Is_Other_Format --
---------------------
function Is_Other_Format (Item : Wide_Wide_Character) return Boolean
renames Ada.Wide_Wide_Characters.Unicode.Is_Other;
------------------------------
-- Is_Punctuation_Connector --
------------------------------
function Is_Punctuation_Connector
(Item : Wide_Wide_Character) return Boolean
renames Ada.Wide_Wide_Characters.Unicode.Is_Punctuation;
--------------
-- Is_Space --
--------------
function Is_Space (Item : Wide_Wide_Character) return Boolean
renames Ada.Wide_Wide_Characters.Unicode.Is_Space;
----------------
-- Is_Special --
----------------
function Is_Special (Item : Wide_Wide_Character) return Boolean is
begin
return Is_Graphic (Item) and then not Is_Alphanumeric (Item);
end Is_Special;
--------------
-- Is_Upper --
--------------
function Is_Upper (Item : Wide_Wide_Character) return Boolean is
begin
return Get_Category (Item) = Lu;
end Is_Upper;
--------------
-- To_Lower --
--------------
function To_Lower (Item : Wide_Wide_Character) return Wide_Wide_Character
renames Ada.Wide_Wide_Characters.Unicode.To_Lower_Case;
function To_Lower (Item : Wide_Wide_String) return Wide_Wide_String is
Result : Wide_Wide_String (Item'Range);
begin
for J in Result'Range loop
Result (J) := To_Lower (Item (J));
end loop;
return Result;
end To_Lower;
--------------
-- To_Upper --
--------------
function To_Upper (Item : Wide_Wide_Character) return Wide_Wide_Character
renames Ada.Wide_Wide_Characters.Unicode.To_Upper_Case;
function To_Upper (Item : Wide_Wide_String) return Wide_Wide_String is
Result : Wide_Wide_String (Item'Range);
begin
for J in Result'Range loop
Result (J) := To_Upper (Item (J));
end loop;
return Result;
end To_Upper;
end Ada.Wide_Wide_Characters.Handling;
|
programs/oeis/001/A001014.asm | karttu/loda | 1 | 81358 | ; A001014: Sixth powers: a(n) = n^6.
; 0,1,64,729,4096,15625,46656,117649,262144,531441,1000000,1771561,2985984,4826809,7529536,11390625,16777216,24137569,34012224,47045881,64000000,85766121,113379904,148035889,191102976,244140625,308915776,387420489,481890304,594823321,729000000,887503681,1073741824,1291467969,1544804416,1838265625,2176782336,2565726409,3010936384,3518743761,4096000000,4750104241,5489031744,6321363049,7256313856,8303765625,9474296896,10779215329,12230590464,13841287201,15625000000,17596287801,19770609664,22164361129,24794911296,27680640625,30840979456,34296447249,38068692544,42180533641,46656000000,51520374361,56800235584,62523502209,68719476736,75418890625,82653950016,90458382169,98867482624,107918163081,117649000000,128100283921,139314069504,151334226289,164206490176,177978515625,192699928576,208422380089,225199600704,243087455521,262144000000,282429536481,304006671424,326940373369,351298031616,377149515625,404567235136,433626201009,464404086784,496981290961,531441000000,567869252041,606355001344,646990183449,689869781056,735091890625,782757789696,832972004929,885842380864,941480149401,1000000000000,1061520150601,1126162419264,1194052296529,1265319018496,1340095640625,1418519112256,1500730351849,1586874322944,1677100110841,1771561000000,1870414552161,1973822685184,2081951752609,2194972623936,2313060765625,2436396322816,2565164201769,2699554153024,2839760855281,2985984000000,3138428376721,3297303959104,3462825991689,3635215077376,3814697265625,4001504141376,4195872914689,4398046511104,4608273662721,4826809000000,5053913144281,5289852801024,5534900853769,5789336458816,6053445140625,6327518887936,6611856250609,6906762437184,7212549413161,7529536000000,7858047974841,8198418170944,8550986578849,8916100448256,9294114390625,9685390482496,10090298369529,10509215371264,10942526586601,11390625000000,11853911588401,12332795428864,12827693806929,13339032325696,13867245015625,14412774445056,14976071831449,15557597153344,16157819263041,16777216000000,17416274304961,18075490334784,18755369578009,19456426971136,20179187015625,20924183895616,21691961596369,22483074023424,23298085122481,24137569000000,25002110044521,25892303048704,26808753332089,27752076864576,28722900390625,29721861554176,30749609024289,31806802621504,32894113444921,34012224000000,35161828327081,36343632130624,37558352909169,38806720086016,40089475140625,41407371740736,42761175875209,44151665987584,45579633110361,47045881000000,48551226272641,50096498540544,51682540549249,53310208315456,54980371265625,56693912375296,58451728309129,60254729561664,62103840598801,64000000000000,65944160601201,67937289638464,69980368892329,72074394832896,74220378765625,76419346977856,78672340886049,80980417183744,83344647990241,85766121000000,88245939632761,90785223184384,93385106978409,96046742518336,98771297640625,101559956668416,104413920565969,107334407093824,110322650964681,113379904000000,116507435287321,119706531338304,122978496247489,126324651851776,129746337890625,133244912166976,136821750708889,140478247931904,144215816802121,148035889000000,151939915084881,155929364660224,160005726539569,164170508913216,168425239515625,172771465793536,177210755074809,181744694737984,186374892382561,191102976000000,195930594145441,200859416110144,205891132094649,211027453382656,216270112515625,221620863468096,227081481823729,232653764952064,238339532186001
mov $1,$0
pow $1,6
|
Structure/Category/Equiv.agda | Lolirofle/stuff-in-agda | 6 | 660 | <reponame>Lolirofle/stuff-in-agda
module Structure.Category.Equiv where
import Lvl
open import Structure.Setoid
open import Structure.Category
-- TODO: https://en.wikipedia.org/wiki/Equivalence_of_categories
module _ {ℓₒ ℓₘ : Lvl.Level} {Obj : Type{ℓₒ}} (Morphism : Obj → Obj → Type{ℓₘ}) ⦃ morphism-equiv : ∀{x y} → Equiv(Morphism x y) ⦄ where
Category-equiv : Equiv(Category(Morphism))
Category-equiv
|
oeis/210/A210381.asm | neoneye/loda-programs | 11 | 160106 | ; A210381: Triangle by rows, derived from the beheaded Pascal's triangle, A074909
; Submitted by <NAME>(s4)
; 1,0,2,0,1,3,0,1,3,4,0,1,4,6,5,0,1,5,10,10,6,0,1,6,15,20,15,7,0,1,7,21,35,35,21,8,0,1,8,28,56,70,56,28,9,0,1,9,36,84,126,126,84,36,10,0,1,10,45,120,210,252,210,120,45,11
lpb $0
add $1,1
sub $0,$1
mov $2,$1
sub $2,$0
lpe
add $0,1
max $0,$1
add $2,1
bin $0,$2
|
agda/Data/Unit/Properties.agda | oisdk/combinatorics-paper | 4 | 4951 | <filename>agda/Data/Unit/Properties.agda
{-# OPTIONS --cubical --safe #-}
module Data.Unit.Properties where
open import Data.Unit
open import Prelude
isProp⊤ : isProp ⊤
isProp⊤ _ _ = refl
|
applescript/iTunes/Unembed Details for Tracks in Current Playlist.applescript | chbrown/sandbox | 0 | 4330 | <filename>applescript/iTunes/Unembed Details for Tracks in Current Playlist.applescript
tell application "iTunes"
set old_indexing to fixed indexing
set fixed indexing to true
set current_playlist to (a reference to (get view of front window))
if selection is not {} then -- test if there is a selection...
set using_selection to true
set idx to (count selection's items)
else -- it's the whole playlist
set selectedTracks to (get a reference to current_playlist)
set using_selection to false
set idx to (count current_playlist's tracks)
end if
repeat with j from 1 to idx
if using_selection then
set this_track to item j of selection
else
set this_track to track j of selectedTracks
end if
-- thisTrack now set, do some stuff to it
try
set track_comment to (get comment of this_track)
set comment_splits to my splitText(";", track_comment)
repeat with comment_split in comment_splits
set {prop_name, prop_value} to my splitText(":", comment_split)
if prop_name is "plays" then
set played count of this_track to prop_value
end if
if prop_name is "rating" then
set rating of this_track to prop_value
end if
if prop_name is "playlist" then
set new_playlist_name to prop_value
if exists (some user playlist whose name is new_playlist_name) then
--set my_opts to (display dialog "This Playlist exists: " & new_playlist_name buttons {"Don't Replace", "Replace"} default button 2 with icon 0)
set new_playlist to user playlist new_playlist_name
else
set new_playlist to (make user playlist with properties {name:new_playlist_name})
end if
--set rating of this_track to prop_value
duplicate this_track to new_playlist
end if
end repeat
on error m
log m -- do you care?
end try
end repeat
set fixed indexing to old_indexing
log "Did " & idx
end tell
on splitText(delimiter, someText)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set output to text items of someText
set AppleScript's text item delimiters to prevTIDs
return output
end splitText |
bb-runtimes/runtimes/ravenscar-sfp-stm32g474/gnarl/a-reatim.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 15929 | <filename>bb-runtimes/runtimes/ravenscar-sfp-stm32g474/gnarl/a-reatim.ads
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . R E A L _ T I M E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2021, AdaCore --
-- --
-- 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. --
-- --
-- --
-- --
-- --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Ravenscar version of this package for generic bare board targets
with System.OS_Interface;
package Ada.Real_Time with
SPARK_Mode,
Abstract_State => (Clock_Time with Synchronous),
Initializes => Clock_Time
is
pragma Assert
(System.OS_Interface.Ticks_Per_Second >= 50_000,
"Ada RM D.8 (30) requires " &
"that Time_Unit shall be less than or equal to 20 microseconds");
type Time is private;
Time_First : constant Time;
Time_Last : constant Time;
Time_Unit : constant := 1.0 / System.OS_Interface.Ticks_Per_Second;
-- The BB platforms use a time stamp counter driven by the system clock,
-- where the duration of the clock tick (Time_Unit) depends on the speed
-- of the underlying hardware. The system clock frequency is used here to
-- determine Time_Unit.
type Time_Span is private;
Time_Span_First : constant Time_Span;
Time_Span_Last : constant Time_Span;
Time_Span_Zero : constant Time_Span;
Time_Span_Unit : constant Time_Span;
Tick : constant Time_Span;
function Clock return Time with
Volatile_Function,
Global => Clock_Time;
function "+" (Left : Time; Right : Time_Span) return Time with
Global => null;
function "-" (Left : Time; Right : Time_Span) return Time with
Global => null;
function "-" (Left : Time; Right : Time) return Time_Span with
Global => null;
function "+" (Left : Time_Span; Right : Time) return Time is
(Right + Left)
with Global => null;
function "<" (Left, Right : Time) return Boolean with
Global => null;
function "<=" (Left, Right : Time) return Boolean with
Global => null;
function ">" (Left, Right : Time) return Boolean with
Global => null;
function ">=" (Left, Right : Time) return Boolean with
Global => null;
function "+" (Left, Right : Time_Span) return Time_Span with
Global => null;
function "-" (Left, Right : Time_Span) return Time_Span with
Global => null;
function "-" (Right : Time_Span) return Time_Span with
Global => null;
function "*" (Left : Time_Span; Right : Integer) return Time_Span with
Global => null;
function "*" (Left : Integer; Right : Time_Span) return Time_Span with
Global => null;
function "/" (Left, Right : Time_Span) return Integer with
Global => null;
function "/" (Left : Time_Span; Right : Integer) return Time_Span with
Global => null;
function "abs" (Right : Time_Span) return Time_Span with
Global => null;
function "<" (Left, Right : Time_Span) return Boolean with
Global => null;
function "<=" (Left, Right : Time_Span) return Boolean with
Global => null;
function ">" (Left, Right : Time_Span) return Boolean with
Global => null;
function ">=" (Left, Right : Time_Span) return Boolean with
Global => null;
function To_Duration (TS : Time_Span) return Duration with
Global => null;
function To_Time_Span (D : Duration) return Time_Span with
Global => null;
function Nanoseconds (NS : Integer) return Time_Span with
Global => null;
function Microseconds (US : Integer) return Time_Span with
Global => null;
function Milliseconds (MS : Integer) return Time_Span with
Global => null;
function Seconds (S : Integer) return Time_Span with
Global => null;
pragma Ada_05 (Seconds);
function Minutes (M : Integer) return Time_Span with
Global => null;
pragma Ada_05 (Minutes);
-- Seconds_Count needs 64 bits. Time is a 64-bits unsigned integer
-- representing clock ticks, and if the clock frequency is lower than
-- 2 ** 32 Hz (~ 4 GHz), which is the case so far, we need more than 32
-- bits to represent the number of seconds. Additionally, Time is
-- unsigned, so Seconds_Count is always positive.
type Seconds_Count is range 0 .. 2 ** 63 - 1;
procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span) with
Global => null;
function Time_Of (SC : Seconds_Count; TS : Time_Span) return Time with
Global => null;
private
pragma SPARK_Mode (Off);
type Time is new System.OS_Interface.Time;
Time_First : constant Time := Time'First;
Time_Last : constant Time := Time'Last;
type Time_Span is new System.OS_Interface.Time_Span;
Time_Span_First : constant Time_Span := Time_Span'First;
Time_Span_Last : constant Time_Span := Time_Span'Last;
Time_Span_Zero : constant Time_Span := 0;
Time_Span_Unit : constant Time_Span := 1;
Tick : constant Time_Span := 1;
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
pragma Import (Intrinsic, "abs");
pragma Inline (Microseconds);
pragma Inline (Milliseconds);
pragma Inline (Nanoseconds);
pragma Inline (Seconds);
pragma Inline (Minutes);
end Ada.Real_Time;
|
agda-stdlib/src/Data/List/Relation/Binary/Subset/Setoid/Properties.agda | DreamLinuxer/popl21-artifact | 5 | 12752 | <reponame>DreamLinuxer/popl21-artifact<filename>agda-stdlib/src/Data/List/Relation/Binary/Subset/Setoid/Properties.agda
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of the extensional sublist relation over setoid equality.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary hiding (Decidable)
module Data.List.Relation.Binary.Subset.Setoid.Properties where
open import Data.Bool.Base using (Bool; true; false)
open import Data.List.Base
open import Data.List.Relation.Unary.Any using (here; there)
import Data.List.Membership.Setoid as Membership
open import Data.List.Membership.Setoid.Properties
import Data.List.Relation.Binary.Subset.Setoid as Sublist
import Data.List.Relation.Binary.Equality.Setoid as Equality
open import Relation.Nullary using (¬_; does)
open import Relation.Unary using (Pred; Decidable)
import Relation.Binary.Reasoning.Preorder as PreorderReasoning
open Setoid using (Carrier)
------------------------------------------------------------------------
-- Relational properties
module _ {a ℓ} (S : Setoid a ℓ) where
open Equality S
open Sublist S
open Membership S
⊆-reflexive : _≋_ ⇒ _⊆_
⊆-reflexive xs≋ys = ∈-resp-≋ S xs≋ys
⊆-refl : Reflexive _⊆_
⊆-refl x∈xs = x∈xs
⊆-trans : Transitive _⊆_
⊆-trans xs⊆ys ys⊆zs x∈xs = ys⊆zs (xs⊆ys x∈xs)
⊆-isPreorder : IsPreorder _≋_ _⊆_
⊆-isPreorder = record
{ isEquivalence = ≋-isEquivalence
; reflexive = ⊆-reflexive
; trans = ⊆-trans
}
⊆-preorder : Preorder _ _ _
⊆-preorder = record
{ isPreorder = ⊆-isPreorder
}
-- Reasoning over subsets
module ⊆-Reasoning where
private
module Base = PreorderReasoning ⊆-preorder
open Base public
hiding (step-∼; step-≈; step-≈˘)
renaming (_≈⟨⟩_ to _≋⟨⟩_)
infix 2 step-⊆ step-≋ step-≋˘
infix 1 step-∈
step-∈ : ∀ x {xs ys} → xs IsRelatedTo ys → x ∈ xs → x ∈ ys
step-∈ x xs⊆ys x∈xs = (begin xs⊆ys) x∈xs
step-⊆ = Base.step-∼
step-≋ = Base.step-≈
step-≋˘ = Base.step-≈˘
syntax step-∈ x xs⊆ys x∈xs = x ∈⟨ x∈xs ⟩ xs⊆ys
syntax step-⊆ xs ys⊆zs xs⊆ys = xs ⊆⟨ xs⊆ys ⟩ ys⊆zs
syntax step-≋ xs ys⊆zs xs≋ys = xs ≋⟨ xs≋ys ⟩ ys⊆zs
syntax step-≋˘ xs ys⊆zs xs≋ys = xs ≋˘⟨ xs≋ys ⟩ ys⊆zs
------------------------------------------------------------------------
-- filter
module _ {a p ℓ} (S : Setoid a ℓ)
{P : Pred (Carrier S) p} (P? : Decidable P) where
open Setoid S renaming (Carrier to A)
open Sublist S
filter⁺ : ∀ xs → filter P? xs ⊆ xs
filter⁺ (x ∷ xs) y∈f[x∷xs] with does (P? x)
... | false = there (filter⁺ xs y∈f[x∷xs])
... | true with y∈f[x∷xs]
... | here y≈x = here y≈x
... | there y∈f[xs] = there (filter⁺ xs y∈f[xs])
|
programs/oeis/095/A095144.asm | neoneye/loda | 22 | 88144 | <reponame>neoneye/loda
; A095144: Triangle formed by reading Pascal's triangle (A007318) mod 11.
; 1,1,1,1,2,1,1,3,3,1,1,4,6,4,1,1,5,10,10,5,1,1,6,4,9,4,6,1,1,7,10,2,2,10,7,1,1,8,6,1,4,1,6,8,1,1,9,3,7,5,5,7,3,9,1,1,10,1,10,1,10,1,10,1,10,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,2,1,0,0,0,0,0,0
seq $0,7318 ; Pascal's triangle read by rows: C(n,k) = binomial(n,k) = n!/(k!*(n-k)!), 0 <= k <= n.
mod $0,11
|
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4 | Kugin/shardingsphere | 0 | 5314 | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
lexer grammar Keyword;
import Alphabet;
WS
: [ \t\r\n] + ->skip
;
ADD
: A D D
;
CREATE
: C R E A T E
;
ALTER
: A L T E R
;
MODIFY
: M O D I F Y
;
DROP
: D R O P
;
SHOW
: S H O W
;
START
: S T A R T
;
STOP
: S T O P
;
RESET
: R E S E T
;
CHECK
: C H E C K
;
RESOURCE
: R E S O U R C E
;
RESOURCES
: R E S O U R C E S
;
RULE
: R U L E
;
FROM
: F R O M
;
SHARDING
: S H A R D I N G
;
REPLICA_QUERY
: R E P L I C A UL_ Q U E R Y
;
ENCRYPT
: E N C R Y P T
;
SHADOW
: S H A D O W
;
PRIMARY
: P R I M A R Y
;
REPLICA
: R E P L I C A
;
BINDING_TABLE
: B I N D I N G UL_ T A B L E
;
BROADCAST_TABLES
: B R O A D C A S T UL_ T A B L E S
;
GENERATED_KEY
: G E N E R A T E D UL_ K E Y
;
DEFAULT_TABLE_STRATEGY
: D E F A U L T UL_ T A B L E UL_ S T R A T E G Y
;
SCALING
: S C A L I N G
;
JOB
: J O B
;
LIST
: L I S T
;
STATUS
: S T A T U S
;
HOST
: H O S T
;
PORT
: P O R T
;
DB
: D B
;
USER
: U S E R
;
PASSWORD
: <PASSWORD>
;
TABLE
: T A B L E
;
SHARDING_COLUMN
: S H A R D I N G UL_ C O L U M N
;
TYPE
: T Y P E
;
NAME
: N A M E
;
PROPERTIES
: P R O P E R T I E S
;
COLUMN
: C O L U M N
;
|
old/Sets/PredicateSet/Finite.agda | Lolirofle/stuff-in-agda | 6 | 5988 | module Sets.PredicateSet.Finite{ℓₗ}{ℓₒ} where
import Lvl
open import Functional
open import Logic.Propositional{ℓₗ Lvl.⊔ ℓₒ}
open import Logic.Predicate{ℓₗ}{ℓₒ}
open import Numeral.Finite
open import Numeral.Natural
import Relator.Equals
open import Sets.PredicateSet
open import Structure.Function.Domain
open import Type{ℓₒ}
{-
record Irrelevant∃ {X : Type} (Pred : X → Stmt) : Stmt where
field
witness : X
⦃ .proof ⦄ : Pred(witness)
record Finite {T} (S : PredSet{ℓₗ}{ℓₒ}(T)) : Stmt where
field
count : ℕ
bijection : 𝕟(count) → Irrelevant∃(x ↦ (x ∈ S))
proof : Bijective(bijection) -- TODO: Bijective must allow different levels
-}
|
Transynther/x86/_processed/AVXALIGN/_zr_/i7-7700_9_0x48_notsx.log_14_1007.asm | ljhsiun2/medusa | 9 | 98553 | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %rax
push %rbx
push %rdi
push %rsi
lea addresses_A_ht+0x18a, %rbx
clflush (%rbx)
nop
nop
nop
nop
xor $51061, %rax
movups (%rbx), %xmm6
vpextrq $1, %xmm6, %rdi
nop
nop
sub %rbx, %rbx
lea addresses_WC_ht+0xcd54, %r12
and %rax, %rax
movw $0x6162, (%r12)
nop
nop
and $4691, %rsi
pop %rsi
pop %rdi
pop %rbx
pop %rax
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r9
push %rax
push %rbp
push %rbx
push %rdx
// Store
mov $0x98a, %rbx
nop
nop
nop
nop
add %rax, %rax
mov $0x5152535455565758, %r10
movq %r10, (%rbx)
nop
nop
nop
nop
xor $44121, %r10
// Store
lea addresses_PSE+0xd89a, %r10
nop
nop
nop
nop
cmp %rdx, %rdx
mov $0x5152535455565758, %r9
movq %r9, (%r10)
nop
nop
xor $3402, %rax
// Store
lea addresses_PSE+0xb98a, %rdx
nop
and %rbp, %rbp
movw $0x5152, (%rdx)
nop
nop
nop
sub $34146, %rdx
// Faulty Load
mov $0x98a, %rdx
nop
nop
nop
nop
xor %r10, %r10
vmovaps (%rdx), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %rax
lea oracles, %rdx
and $0xff, %rax
shlq $12, %rax
mov (%rdx,%rax,1), %rax
pop %rdx
pop %rbx
pop %rbp
pop %rax
pop %r9
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_P', 'congruent': 0}}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_P', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_PSE', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_PSE', 'congruent': 11}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_P', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 8}}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 0}, 'OP': 'STOR'}
{'00': 14}
00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
tests/vice-tests/VIC20/viavarious/via5.asm | PhylumChordata/chips-test | 330 | 177179 | !to "via5.prg", cbm
TESTID = 5
tmp=$fc
addr=$fd
add2=$f9
ERRBUF = $1f00
TMP = $2000 ; measured data on C64 side
DATA = $3000 ; reference data
TESTLEN = $20
NUMTESTS = 18 - 6
TESTSLOC = $1800
DTMP=screenmem
!src "common.asm"
* = TESTSLOC
;------------------------------------------
; before: --
; in the loop:
; [Timer A lo | Timer A hi | Timer A latch lo | Timer A latch hi] = loop counter
; read [Timer A lo | Timer A hi | IRQ Flags]
!zone { ; A
.test ldx #0
.l1 stx viabase+$4 ; Timer A lo
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$4 ; Timer A lo
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; B
.test ldx #0
.l1 stx viabase+$4 ; Timer A lo
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$5 ; Timer A hi
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; C
.test ldx #0
.l1 stx viabase+$5 ; Timer A hi
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$4 ; Timer A lo
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; D
.test ldx #0
.l1 stx viabase+$5 ; Timer A hi
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$5 ; Timer A hi
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; E
.test ldx #0
.l1 stx viabase+$4 ; Timer A lo
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$d ; IRQ Flags / ACK
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; F
.test ldx #0
.l1 stx viabase+$5 ; Timer A hi
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$d ; IRQ Flags / ACK
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
;----------------------------------------
!zone { ; G
.test ldx #0
.l1 stx viabase+$6 ; Timer A lo
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$6 ; Timer A lo
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; H
.test ldx #0
.l1 stx viabase+$6 ; Timer A lo
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$7 ; Timer A hi
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; I
.test ldx #0
.l1 stx viabase+$7 ; Timer A hi
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$6 ; Timer A lo
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; J
.test ldx #0
.l1 stx viabase+$7 ; Timer A hi
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$7 ; Timer A hi
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; K
.test ldx #0
.l1 stx viabase+$6 ; Timer A lo
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$d ; IRQ Flags / ACK
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
!zone { ; L
.test ldx #0
.l1 stx viabase+$7 ; Timer A hi
;lda #$11
;sta $dc0e ; start timer A continuous, force reload
lda viabase+$d ; IRQ Flags / ACK
sta DTMP,x
inx
bne .l1
rts
* = .test+TESTLEN
}
* = DATA
!bin "via5ref.bin", NUMTESTS * $0100, 2
|
programs/oeis/079/A079904.asm | jmorken/loda | 1 | 6763 | ; A079904: Triangle read by rows: T(n, k) = n*k, 0<=k<=n.
; 0,0,1,0,2,4,0,3,6,9,0,4,8,12,16,0,5,10,15,20,25,0,6,12,18,24,30,36,0,7,14,21,28,35,42,49,0,8,16,24,32,40,48,56,64,0,9,18,27,36,45,54,63,72,81,0,10,20,30,40,50,60,70,80,90,100,0,11,22,33,44,55,66,77,88,99,110,121
mov $2,$0
lpb $2
mov $0,$3
add $1,1
sub $2,1
add $0,$2
trn $2,$1
lpe
mul $0,$1
mov $1,$0
|
libsrc/_DEVELOPMENT/math/float/math32/lm32/c/sdcc/ldexp_callee.asm | jpoikela/z88dk | 640 | 97038 |
SECTION code_fp_math32
PUBLIC _ldexp_callee
EXTERN cm32_sdcc_ldexp_callee
defc _ldexp_callee = cm32_sdcc_ldexp_callee
|
scripts/RedsHouse1F.asm | AmateurPanda92/pokemon-rby-dx | 9 | 92471 | RedsHouse1F_Script:
jp EnableAutoTextBoxDrawing
RedsHouse1F_TextPointers:
dw RedsHouse1FText1
dw RedsHouse1FText2
RedsHouse1FText1: ; Mom
TX_ASM
ld a, [wd72e]
bit 3, a
jr nz, .heal ; if player has received a Pokémon from Oak, heal team
ld hl, MomWakeUpText
call PrintText
jr .done
.heal
call MomHealPokemon
.done
jp TextScriptEnd
MomWakeUpText:
TX_FAR _MomWakeUpText
db "@"
MomHealPokemon:
ld hl, MomHealText1
call PrintText
call GBFadeOutToWhite
call ReloadMapData
predef HealParty
ld a, MUSIC_PKMN_HEALED
ld [wNewSoundID], a
call PlaySound
.next
ld a, [wChannelSoundIDs]
cp MUSIC_PKMN_HEALED
jr z, .next
ld a, [wMapMusicSoundID]
ld [wNewSoundID], a
call PlaySound
call GBFadeInFromWhite
ld hl, MomHealText2
jp PrintText
MomHealText1:
TX_FAR _MomHealText1
db "@"
MomHealText2:
TX_FAR _MomHealText2
db "@"
RedsHouse1FText2: ; TV
TX_ASM
ld a, [wSpriteStateData1 + 9]
cp SPRITE_FACING_UP
ld hl, TVWrongSideText
jr nz, .notUp
ld hl, StandByMeText
.notUp
call PrintText
jp TextScriptEnd
StandByMeText:
TX_FAR _StandByMeText
db "@"
TVWrongSideText:
TX_FAR _TVWrongSideText
db "@"
|
programs/oeis/314/A314040.asm | neoneye/loda | 22 | 103023 | ; A314040: Coordination sequence Gal.4.133.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; 1,5,11,15,21,25,31,36,41,47,51,57,61,67,72,77,83,87,93,97,103,108,113,119,123,129,133,139,144,149,155,159,165,169,175,180,185,191,195,201,205,211,216,221,227,231,237,241,247,252
mul $0,6
mov $2,1
lpb $0
trn $0,$2
sub $2,1
add $0,$2
sub $0,1
add $2,13
lpe
add $0,1
|
src/main/antlr/ChiLexer.g4 | marad/chi-compiler-kotlin | 0 | 6750 | lexer grammar ChiLexer;
fragment DIGIT : [0-9] ;
fragment LETTER : [a-zA-Z] ;
VAL : 'val';
VAR : 'var';
FN : 'fn';
IF : 'if';
ELSE : 'else';
AS : 'as';
ARROW : '->' ;
COLON : ':' ;
LPAREN : '(' ;
RPAREN : ')' ;
LBRACE : '{' ;
RBRACE : '}' ;
COMMA : ',' ;
DB_QUOTE : '"' -> pushMode(STRING_READING) ;
EQUALS : '=' ;
// Arithmetic operators
ADD_SUB : '+' | '-' ;
MOD : '%' ;
MUL_DIV : '*' | '/' ;
// Logic operators
NOT : '!' ;
AND : '&&' ;
OR : '||' ;
// Comparison operators
COMP_OP : IS_EQ | NOT_EQ | LT | LEQ | GT | GEQ ;
IS_EQ : '==' ;
NOT_EQ : '!=' ;
LT : '<' ;
LEQ : '<=' ;
GT : '>' ;
GEQ : '>=' ;
TRUE : 'true' ;
FALSE : 'false' ;
NUMBER : DIGIT+ ('.' DIGIT+)? ;
ID : LETTER (LETTER | DIGIT | '-' | '_')* ;
NEWLINE : ('\r'? '\n' | '\r')+ -> skip;
WHITESPACE : [ \t\r\n]+ -> skip ;
SINGLE_LINE_COMMENT : '//' ~[\r\n]* -> skip ;
MULTI_LINE_COMMENT : '/*' .*? '*/' -> skip ;
mode STRING_READING;
CLOSE_STRING : '"' -> popMode;
STRING_TEXT : ~('\\' | '"' )+ ;
STRING_ESCAPE
: '\\' ('r' | 'n' | '"')
;
|
libsrc/msx/gen_ldirmv.asm | andydansby/z88dk-mk2 | 1 | 164781 | <filename>libsrc/msx/gen_ldirmv.asm
;
; z88dk library: Generic VDP support code
;
; LIDRMV
;
;
; $Id: gen_ldirmv.asm,v 1.1 2010/06/30 13:21:38 stefano Exp $
;
XLIB LIDRMV
LIB SETRD
INCLUDE "msx/vdp.inc"
LIDRMV:
call SETRD
ex (sp),hl
ex (sp),hl
loop:
in a,(VDP_DATAIN)
ld (de),a
inc de
dec bc
ld a,b
or c
jr nz,loop
ret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.