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
apps/old/crack4.asm
yosswi414/HariboteOS_USB
0
243733
[BITS 32] GLOBAL HariMain HariMain: CLI ; prohibits interrupt so that the cpu executes HLT forever fin: HLT JMP fin
tools/ayacc/src/actions_file.adb
svn2github/matreshka
24
6410
<filename>tools/ayacc/src/actions_file.adb -- $Header: /dc/uc/self/arcadia/ayacc/src/RCS/actions_file_body.a,v 1.2 1993/05/31 22:36:35 self Exp self $ -- $Header: /dc/uc/self/arcadia/ayacc/src/RCS/actions_file_body.a,v 1.2 1993/05/31 22:36:35 self Exp self $ -- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- The primary authors of ayacc were <NAME> and <NAME>. -- Enhancements were made by <NAME>. -- -- Send requests for ayacc information to <EMAIL> -- Send bug reports for ayacc to <EMAIL> -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- Module : actions_file_body.ada -- Component of : ayacc -- Version : 1.2 -- Date : 11/21/86 12:28:04 -- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxactions_file_body.ada -- $Header: /dc/uc/self/arcadia/ayacc/src/RCS/actions_file_body.a,v 1.2 1993/05/31 22:36:35 self Exp self $ -- $Log: actions_file_body.a,v $ -- Revision 1.2 1993/05/31 22:36:35 self -- added exception handler when opening files -- -- Revision 1.1 1993/05/31 22:13:57 self -- Initial revision -- --Revision 1.1 88/08/08 14:54:53 arcadia --Initial revision -- --Revision 1.1 88/08/08 12:04:56 arcadia --Initial revision --Revision 0.1 86/04/01 15:29:59 ada -- This version fixes some minor bugs with empty grammars -- and $$ expansion. It also uses vads5.1b enhancements -- such as pragma inline. -- with Ayacc_File_Names; use Ayacc_File_Names; package body Actions_File is SCCS_ID : constant String := "@(#) actions_file_body.ada, Version 1.2"; -- The maximum length of the text that an action can expand into. Maximum_Action_Length : constant Count := 1000; The_File : File_Type; procedure Open(Mode: in File_Mode) is begin if Mode = Read_File then Open(The_File, In_File, Get_Actions_File_Name); else Create(The_File, Out_File, Get_Actions_File_Name); --RJS Set_Line_Length(The_File, To => Maximum_Action_Length); end if; exception when Name_Error | Use_Error => Put_Line("Ayacc: Error Opening """ & Get_Actions_File_Name & """."); raise; end Open; procedure Close is begin Close(The_File); end Close; procedure Delete is begin Delete(The_File); end Delete; procedure Read_Line(S: out String; Last: out Natural) is begin Get_Line(The_File, S, Last); end; procedure Write(S: in String) is begin Put(The_File, S); end; procedure Write(C: in Character) is begin Put(The_File, C); end; procedure Writeln is begin New_Line(The_File); end; function Is_End_of_File return Boolean is begin return End_of_File(The_File); end Is_End_of_File; procedure Initialize is begin Open(Write_File); end Initialize; procedure Finish is begin Close; end Finish; end Actions_File;
_build/dispatcher/jmp_ippsPRNGen_4ec85935.asm
zyktrcn/ippcp
1
97709
<reponame>zyktrcn/ippcp extern m7_ippsPRNGen:function extern n8_ippsPRNGen:function extern y8_ippsPRNGen:function extern e9_ippsPRNGen:function extern l9_ippsPRNGen:function extern n0_ippsPRNGen:function extern k0_ippsPRNGen:function extern ippcpJumpIndexForMergedLibs extern ippcpSafeInit:function segment .data align 8 dq .Lin_ippsPRNGen .Larraddr_ippsPRNGen: dq m7_ippsPRNGen dq n8_ippsPRNGen dq y8_ippsPRNGen dq e9_ippsPRNGen dq l9_ippsPRNGen dq n0_ippsPRNGen dq k0_ippsPRNGen segment .text global ippsPRNGen:function (ippsPRNGen.LEndippsPRNGen - ippsPRNGen) .Lin_ippsPRNGen: db 0xf3, 0x0f, 0x1e, 0xfa call ippcpSafeInit wrt ..plt align 16 ippsPRNGen: db 0xf3, 0x0f, 0x1e, 0xfa mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc] movsxd rax, dword [rax] lea r11, [rel .Larraddr_ippsPRNGen] mov r11, qword [r11+rax*8] jmp r11 .LEndippsPRNGen:
source/jni/u2/glenz/vidnrm.asm
Falken42/SecondReality
9
95826
;256 color normal routines ;routines ending in "1" are vector drawers: ; DS:SI preserved ; OUT 3C4,02h required ; DS=CS & ES=vram required ALIGN 4 nrpset PROC FAR ;requires: OUT 3C4,2 ;DS:SI preserved, CX preserved! shl bx,1 mov di,ds:rows[bx] mov bx,3 and bx,dx sar dx,2 add di,dx mov al,ds:middledot[bx] mov dx,3c5h out dx,al mov al,ds:color1 mov es:[di],al ret nrpset ENDP nrhline PROC FAR ;requires: OUT 3C4,2 ;DS:SI must be preserved! ;(ax,bx)-(dx,bx) cmp ax,dx jl nrhi1 xchg ax,dx nrhi1: cmp ax,0 jnl nrhi2 cmp dx,0 jl nrhi0 xor ax,ax nrhi2: cmp dx,ds:wmaxx jng nrhi21 cmp ax,ds:wmaxx jg nrhi0 mov dx,ds:wmaxx nrhi21: mov di,ax sar di,2 mov cx,dx sar cx,2 sub cx,di shl bx,1 add di,ds:rows[bx] mov bp,3 and bp,ax mov bh,ds:leftside[bp] mov bp,3 and bp,dx mov bl,ds:rightside[bp] mov dx,3c5h ;(di..si,bx) cmp cx,0 je nrhi30 ;left side mov al,bh out dx,al mov al,ds:color1 stosb dec cx mov ah,al ;middle jcxz nrhi33 mov al,0fh out dx,al mov al,ah test di,1 jz nrhi32 stosb dec cx nrhi32: shr cx,1 rep stosw adc cx,cx rep stosb nrhi33: ;right side mov al,bl out dx,al mov al,ah mov es:[di],al nrhi0: ret nrhi30: ;end and beg in same byte mov al,bl and al,bh out dx,al mov al,ds:color1 mov es:[di],al ret nrhline ENDP ;line variables - shared - also in vidtwe.asm ;xdif dw 0 ;ydif dw 0 ;xabs dw 0 ;yabs dw 0 ;xsgn dw 0 ;ysgn dw 0 ;xtmp dw 0 ;ytmp dw 0 ;tmplnx dw 0 ;tmplny dw 0 nrpsetc PROC NEAR ;(dx,bx)=(color), es must be 0a000h ;uses nothing push ax push bx push cx push dx mov ch,al mov cl,dl shl bx,1 mov bx,cs:rows[bx] sar dx,1 sar dx,1 add bx,dx and cl,3 mov ax,102h mov dx,03c4h shl ah,cl out dx,ax mov al,cs:color1 mov es:[bx],al pop dx pop cx pop bx pop ax ret nrpsetc ENDP nrlineto PROC FAR ;draw line from (cx,ax) to (dx,bx) with color (color) ;requires ds=cs, es=vram, changes: ax push cx push si push di push bp push dx push bx mov ds:tmplnx,cx mov ds:tmplny,ax ;set insider point as begin of line cmp dx,ds:wmaxx ja nrlt4 cmp bx,wmaxy ja nrlt4 jmp nrlt5 ;dx,bx is inside, no changes nrlt4: ;dx,bx outside, swap xchg bx,ds:tmplny xchg dx,ds:tmplnx ;check with new bx,dx cmp dx,ds:wmaxx ja nrlt6 cmp bx,wmaxy ja nrlt6 jmp nrlt5 ;dx,bx is inside nrlt6: ;both ends outside! Cut 'em here, not ready yet nrlt5: mov ds:xtmp,dx mov ds:ytmp,bx ;calc differencies xdif,ydif (+-) & abs difs, xabs,yabs (+) ;and signs xsgn,ysgn (-1/0/1) xor cx,cx mov ax,ds:tmplnx sub ax,dx mov ds:xdif,ax or ax,ax je nrlt1 inc cx test ax,32768 jz nrlt1 neg ax dec cx dec cx nrlt1: mov ds:xabs,ax mov ds:xsgn,cx xor cx,cx mov ax,ds:tmplny sub ax,bx mov ds:ydif,ax or ax,ax je nrlt2 inc cx test ax,32768 jz nrlt2 neg ax dec cx dec cx nrlt2: mov ds:yabs,ax mov ds:ysgn,cx ;which is bigger? cmp ax,ds:xabs ja nrlt3 ;xbigger ;calc addl/h (si,di) jne nrlt9 ;1/1 addition, 45 degree curve cmp ax,0 jne nrlt15 mov dx,cs:tmplnx mov bx,ds:tmplny call nrpsetc jmp nrlt10 nrlt15: mov di,ds:ysgn mov si,65535 jmp nrlt10 nrlt9: mov dx,ax ;dx=yabs xor ax,ax div ds:xabs ;ax=lowadd mov si,ax mov di,ds:ysgn nrlt10: mov ax,32767 mov bp,ds:xsgn mov cx,ds:xabs inc cx mov dx,ds:xtmp mov bx,ds:ytmp nrlt7: call nrpsetc add dx,bp ;xsgn add ax,si ;yaddl jnc nrlt8 add bx,di ;ysgn nrlt8: loop nrlt7 jmp nrlt0 nrlt3: ;ybigger mov dx,ds:xabs xor ax,ax div ds:yabs ;ax=lowadd mov si,ax mov di,ds:xsgn nrlt12: mov ax,32767 mov bp,ds:ysgn mov cx,ds:yabs inc cx mov dx,ds:xtmp mov bx,ds:ytmp nrlt13: call nrpsetc add bx,bp ;ysgn add ax,si ;xaddl jnc nrlt14 add dx,di ;xsgn nrlt14: loop nrlt13 nrlt0: pop bx pop dx mov ds:tmplnx,dx mov ds:tmplny,bx pop bp pop di pop si pop cx ret nrlineto ENDP nrhlinegroup PROC FAR ;requires: OUT 3C4,2 mov dx,3c4h mov al,2 out dx,al mov bx,gs:[si] add si,2 dec bx push bx nrhg92: pop bx inc bx push bx mov ax,gs:[si] add si,2 cmp ax,-32767 jne nrhg91 pop bx ret nrhg91: mov dx,ax mov ax,gs:[si] add si,2 cmp ax,dx jl nrhg1 xchg ax,dx nrhg1: cmp ax,ds:wminx jnl nrhg2 cmp dx,ds:wminx jl nrhg92 mov ax,ds:wminx nrhg2: cmp dx,ds:wmaxx jng nrhg21 cmp ax,ds:wmaxx jg nrhg92 mov dx,ds:wmaxx nrhg21: mov di,ax mov cx,dx sub cx,ax shl bx,1 add di,ds:rows[bx] mov al,cs:color1 mov ah,al cmp cx,8 jl nrhg22 mov dx,ax shl eax,16 mov ax,dx mov dx,cx mov cx,4 sub cx,di and cx,3 sub dx,cx rep stosb mov cx,dx shr cx,2 rep stosd mov cx,dx and cx,3 rep stosb jmp nrhg92 nrhg22: shr cx,1 rep stosw adc cx,cx rep stosb jmp nrhg92 nrhlinegroup ENDP ALIGN 2 bpmultable LABEL WORD dw 0 cc=1 REPT 255 dw (16383)/cc cc=cc+1 ENDM public _dimtable _dimtable db 256 dup(1) ALIGN 2 tmpax dw 0 nrthlinegroup PROC NEAR ;requires: OUT 3C4,2 mov dx,3c4h mov al,2 out dx,al mov bx,gs:[si] add si,2 dec bx jmp tnrg93 tnrg92: pop bx add si,8 tnrg93: inc bx push bx mov dx,gs:[si] ;left cmp dx,-32767 jne tnrg91 pop bx ret tnrg91: mov ax,gs:[si+2] ;right cmp ax,dx jl tnrg1 xchg ax,dx mov cx,gs:[si+4] xchg cx,gs:[si+6] mov gs:[si+4],cx tnrg1: cmp ax,ds:wminx jnl tnrg2 cmp dx,ds:wminx jl tnrg92 mov ax,ds:wminx tnrg2: cmp dx,ds:wmaxx jng tnrg21 cmp ax,ds:wmaxx jg tnrg92 mov dx,ds:wmaxx tnrg21: mov ds:tmpax,ax mov cx,dx sub cx,ax jcxz tnrg92 shl bx,1 mov di,ds:rows[bx] mov bp,cx ;count shl bp,1 mov bx,word ptr cs:bpmultable[bp] shr bp,1 mov ah,gs:[si+4] ;endx sub ah,gs:[si+6] ;startx xor al,al imul bx shld dx,ax,2 ;dx=y, eaxh=x mov cl,dh mov ah,dl xor al,al rol eax,16 ;xadd mov ah,gs:[si+5] ;endy sub ah,gs:[si+7] ;starty xor al,al imul bx shld dx,ax,2 mov ch,dh mov dh,dl ;yadd xor dl,dl rol edx,16 mov dx,cx cmp dl,80h adc dh,-1 ;x/yaddhi push si push ds mov ax,fs mov ds,ax shl bp,4 mov bx,cs:tmpax shl bx,4 add bx,OFFSET bas256 add bp,bx mov ax,bx mov byte ptr cs:[bp],0c3h ;ret push bp movzx ebx,word ptr gs:[si+6] ;startxy/zero ylow xor ecx,ecx ;zero xlow call ax pop bx mov byte ptr cs:[bx],066h ;start of add ecx,eax pop ds pop si jmp tnrg92 ;....Exx..H....L.... ;ax xadd - tmp ;bx ylow y x ;cx xlow - - ;dx yadd yah xah ;si - - - ;di - distbase ;bp - - - ALIGN 16 bas256: cc=0 REPT 256 add ecx,eax ;@0 mov al,ds:[bx] ;@3 adc ebx,edx ;@5 adc bh,0 ;@8 db 26h,88h,85h ;@B ;mov es:[di+XXX],al dw cc ;@E ;XXX cc=cc+1 ;@10 ENDM add ecx,eax nrthlinegroup ENDP
oeis/112/A112045.asm
neoneye/loda-programs
11
7137
<reponame>neoneye/loda-programs ; A112045: Positions of primes (A000040) among nonsquares A000037. ; Submitted by <NAME>(s2) ; 1,2,3,5,8,10,13,15,19,24,26,31,35,37,41,46,52,54,59,63,65,71,74,80,88,91,93,97,99,103,116,120,126,128,137,139,145,151,155,160,166,168,178,180,183,185,197,209,212,214,218,224,226,236,241,247,253,255,261 lpb $0 lpb $0 div $0,45 add $0,4 mul $0,2 lpe mov $2,-2 gcd $2,$0 add $0,1 mul $2,$0 mul $0,$2 sub $2,8 add $0,$2 div $0,2 lpe seq $0,40 ; The prime numbers. seq $0,122800 ; A P_4-stuttered arithmetic progression with a(n+1)=a(n) if n is square, a(n+1)=a(n)+2 otherwise. div $0,2
oap-template/src/main/antlr4/TemplateGrammar.g4
oaplatform/oap-core
9
7322
parser grammar TemplateGrammar; options { language=Java; tokenVocab=TemplateLexer; superClass = TemplateGrammarAdaptor; } @header { package oap.template; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; } @parser::members { public TemplateGrammar(TokenStream input, Map<String, List<Method>> builtInFunction, ErrorStrategy errorStrategy) { this(input); this.builtInFunction = builtInFunction; this.errorStrategy = errorStrategy; } } template[TemplateType parentType, Map<String,String> aliases] returns [AstRoot rootAst] : elements[parentType, aliases] { $rootAst = new AstRoot($parentType); $rootAst.addChildren($elements.list); } EOF ; elements[TemplateType parentType, Map<String,String> aliases] returns [ArrayList<Ast> list = new ArrayList<>()] : (element[parentType, aliases] { $list.add($element.ast); })* ; element[TemplateType parentType, Map<String,String> aliases] returns [Ast ast] : t=text { $ast = new AstText($t.text); } | comment { $ast = new AstText($comment.text.substring(1));} | expression[aliases] { var lexerExp = new TemplateLexerExpression( CharStreams.fromString( $expression.content ) ); var grammarExp = new TemplateGrammarExpression( new BufferedTokenStream( lexerExp ), builtInFunction, errorStrategy ); if( errorStrategy == ErrorStrategy.ERROR ) { lexerExp.addErrorListener( ThrowingErrorListener.INSTANCE ); grammarExp.addErrorListener( ThrowingErrorListener.INSTANCE ); } try { $ast = new AstExpression(grammarExp.expression( $parentType ).ast.top, $expression.content); } catch ( Exception e ) { throw new TemplateException( $expression.content, e ); } } ; text : TEXT+ ; comment : STARTESCEXPR expressionContent RBRACE; expression[Map<String,String> aliases] returns [String content] : STARTEXPR expressionContent RBRACE { $content = $expressionContent.text; var alias = aliases.get( $content ); if( alias != null ) $content = alias; }; expressionContent : (EXPRESSION|LBRACE|RBRACE)+ ;
stress/diff_car_stress.adb
yannickmoy/SPARKNaCl
76
8393
<reponame>yannickmoy/SPARKNaCl with SPARKNaCl.Tests; procedure Diff_Car_Stress is begin SPARKNaCl.Tests.Diff_Car_Stress; end Diff_Car_Stress;
Levels/Bump level.applescript
bsmith96/Qlab-Scripts
1
4132
-- @description Bump cue level -- @author <NAME> -- @link bensmithsound.uk -- @version 1.4 -- @testedmacos 10.14.6 -- @testedqlab 4.6.10 -- @about Leaves the cue master, and bumps the individual channels (which are not -inf) +6dB -- @separateprocess TRUE -- @changelog -- v1.4 + avoids duplicating bumps to ganged channels more efficiently -- v1.3 + no longer errors when no gang was assigned -- v1.2 + removes gangs temporarily, to avoid duplicate bumps -- v1.1 + allows assignment of UDVs from the script calling this one -- USER DEFINED VARIABLES ----------------- try -- if global variables are given when this script is called by another, use those variables variableCueListName on error set variableCueListName to "Other scripts & utilities" end try try bumpLevel on error set bumpLevel to 6 end try ---------- END OF USER DEFINED VARIABLES -- -- VARIABLES FROM QLAB NOTES -------------- tell application id "com.figure53.Qlab.4" to tell front workspace set audioChannelCount to notes of (first cue of (first cue list whose q name is variableCueListName) whose q name is "Output channel count") as integer -- total number of Qlab output set minAudioLevel to notes of (first cue of (first cue list whose q name is variableCueListName) whose q name is "Min audio level") as integer -- audio level which is -inf end tell ------------------ END OF QLAB VARIABLES -- ---- RUN SCRIPT --------------------------- tell application id "com.figure53.Qlab.4" to tell front workspace set selectedCues to (selected as list) set cueTypes to {"Audio", "Fade", "Video", "Mic"} repeat with eachCue in selectedCues if (q type of eachCue) is in cueTypes then set allGangs to {} repeat with eachChannel from 1 to audioChannelCount as integer set oldLevel to getLevel eachCue row 0 column eachChannel set newLevel to (oldLevel + bumpLevel) if oldLevel is not minAudioLevel then set eachGang to getGang eachCue row 0 column eachChannel if eachGang is missing value then -- change unganged values setLevel eachCue row 0 column eachChannel db newLevel else if eachGang is not missing value and eachGang is not in allGangs then -- only change ganged values if they haven't already been changed setLevel eachCue row 0 column eachChannel db newLevel set end of allGangs to eachGang end if end if end repeat end if end repeat end tell
include/spacelib2/lib/graphics.asm
backwardspy/spacelib2
0
90353
.filenamespace sl .namespace gfx { .label grid_width = 40 .label grid_height = 25 .label character_size = 8 .label screen_width = grid_width * character_size .label screen_height = grid_height * character_size .label black = $0 .label white = $1 .label red = $2 .label cyan = $3 .label violet = $4 .label green = $5 .label blue = $6 .label yellow = $7 .label orange = $8 .label brown = $9 .label light_red = $a .label dark_grey = $b .label grey = $c .label light_green = $d .label light_blue = $e .label light_grey = $f .macro @sl_gfx_fill(addr, value) { lda #value sl_gfx_fill_from_ac(addr) } .macro @sl_gfx_fill_from_ac(addr) { ldx #0 loop: sta addr+$0000, x sta addr+$0100, x sta addr+$0200, x sta addr+$02e8, x inx bne loop } .macro @sl_gfx_set_background_colour(colour) { lda #colour sta background_colour } .macro @sl_gfx_set_border_colour(colour) { lda #colour sta border_colour } .macro @sl_gfx_wait_for_raster(line) { !loop: lda raster_line cmp #line - 1 bne !loop- !loop: lda raster_line cmp #line bne !loop- } }
org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1a.als
Kaixi26/org.alloytools.alloy
527
1946
<filename>org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1a.als module tour/addressBook1a ----- Page 6 sig Name, Addr { } sig Book { addr: Name -> lone Addr } pred show { } // This command generates an instance similar to Fig 2.1 run show for 3 but 1 Book
all.agda
hazelgrove/hazelnat-myth-
1
5791
<filename>all.agda open import Nat open import Prelude open import List open import contexts open import core open import lemmas-general open import lemmas-env open import lemmas-progress open import results-checks open import decidability open import completeness open import preservation open import progress open import finality open import eval-checks
src/shaders/h264/mc/scoreboard_update.asm
tizenorg/platform.upstream.libva-intel-driver
0
169645
/* * Scoreboard update function for decoding kernels * Copyright © <2010>, Intel Corporation. * * This program is licensed under the terms and conditions of the * Eclipse Public License (EPL), version 1.0. The full text of the EPL is at * http://www.opensource.org/licenses/eclipse-1.0.php. * */ // // Module name: scoreboard_update.asm // // Scoreboard update function for decoding kernels // // This module is used by decoding kernels to send message to scoreboard to update the // "complete" status, thus the dependency of the MB can be cleared. // // $Revision: 6 $ // $Date: 10/16/06 5:19p $ // mov (8) MSGHDRY1<1>:ud 0x00000000:ud // Initialize message header payload with 0 // Compose M0.5:ud information add (1) MSGHDRY1.10<1>:uw r0.20:ub 0x0200:uw // Message length = 1 DWORD and (1) MSGHDRY1.11<1>:uw M05_STORE<0;1,0>:uw SB_MASK*4:uw // Retrieve stored value and wrap around scoreboard or (1) MSGHDRY1.0<1>:ud M05_STORE<0;1,0>:uw 0xc0000000:ud // Set "Completed" bits #ifndef BSDRESET_ENABLE #ifdef INTER_KERNEL mov (1) gREG_WRITE_COMMIT_Y<1>:ud gREG_WRITE_COMMIT_Y<0;1,0>:ud // Make sure Y write is committed mov (1) gREG_WRITE_COMMIT_UV<1>:ud gREG_WRITE_COMMIT_UV<0;1,0>:ud // Make sure U/V write is committed #else mov (1) REG_WRITE_COMMIT_Y<1>:ud REG_WRITE_COMMIT_Y<0;1,0>:ud // Make sure Y write is committed mov (1) REG_WRITE_COMMIT_UV<1>:ud REG_WRITE_COMMIT_UV<0;1,0>:ud // Make sure U/V write is committed #endif // INTER_KERNEL #endif // BSDRESET_ENABLE send (8) NULLREG MSGHDRY1 null:ud MSG_GW FWDMSGDSC // End of scoreboard_update
generateSFA/src/main/antlr4/generateSFA/InvariantLexer.g4
microsoft/aragog
5
1881
lexer grammar InvariantLexer; FILTER : 'FILTER' ; GROUPBY : 'GROUPBY' ; MAP : 'MAP' ; TILDA : '~' ; SHUFFLE : 'SHUFFLE' ; CHOICE : 'CHOICE' ; NOT : 'NOT' ; ANY : 'ANY' ; fragment DIGIT: [0-9]; fragment DIGITS: DIGIT+; fragment HEXDIGIT: [0-9a-fA-F]; // Only lower case 'x' and 'b' count for hex + bin numbers. Otherwise it's an identifier. HEX_NUMBER: ('0x' HEXDIGIT+) | ('x\'' HEXDIGIT+ '\''); BIN_NUMBER: ('0b' [01]+) | ('b\'' [01]+ '\''); // ------------------------- // Punctuation COLON : ':' ; COMMA : ',' ; SEMI : ';' ; LPAREN : '(' ; RPAREN : ')' ; LBRACE : '[' ; RBRACE : ']' ; DOT : '.' ; DOUBLE_QUOTE : '"' ; VARIABLE_PRE : '$' ; TIME : 'TIME'; QUESTION : '?' ; STAR : '*' ; DIVIDE : '/' ; PLUS : '+' ; MINUS : '-' ; BANG : '!' ; AT : '@' ; OR : '||' ; AND : '&&' ; EQUALS : '==' ; NOT_EQUAL : '!=' ; LT : '<' ; GT : '>' ; LE : '<=' ; GE : '>=' ; INT_NUMBER: MINUS? DIGITS; DOUBLE_QUOTED_TEXT: ( DOUBLE_QUOTE (('\\' .)? .)*? DOUBLE_QUOTE )+ ; // ------------------------- // Identifiers fragment LETTER_WHEN_UNQUOTED: DIGIT | LETTER_WHEN_UNQUOTED_NO_DIGIT | DOT; fragment LETTER_WHEN_UNQUOTED_NO_DIGIT: [a-zA-Z_$\u0080-\uffff]; VARIABLE: VARIABLE_PRE IDENTIFIER ; IDENTIFIER: LETTER_WHEN_UNQUOTED+ ; WHITESPACE: [ \t\f\r\n] -> channel(HIDDEN); // Ignore whitespaces.
oeis/166/A166637.asm
neoneye/loda-programs
11
95813
; A166637: Totally multiplicative sequence with a(p) = 7*(p-1) for prime p. ; Submitted by <NAME> ; 1,7,14,49,28,98,42,343,196,196,70,686,84,294,392,2401,112,1372,126,1372,588,490,154,4802,784,588,2744,2058,196,2744,210,16807,980,784,1176,9604,252,882,1176,9604,280,4116,294,3430,5488,1078,322,33614,1764,5488,1568,4116,364,19208,1960,14406,1764,1372,406,19208,420,1470,8232,117649,2352,6860,462,5488,2156,8232,490,67228,504,1764,10976,6174,2940,8232,546,67228,38416,1960,574,28812,3136,2058,2744,24010,616,38416,3528,7546,2940,2254,3528,235298,672,12348,13720,38416 add $0,1 mov $1,1 mov $2,2 mov $4,1 lpb $0 mul $1,$4 mov $3,$0 lpb $3 mov $4,$0 mod $4,$2 add $2,1 cmp $4,0 cmp $4,0 sub $3,$4 lpe div $0,$2 mov $4,$2 mov $5,$2 lpb $5 add $4,6 sub $5,1 lpe sub $4,7 lpe gcd $0,$1
byte_package.adb
python36/vibecrypt
0
20271
<reponame>python36/vibecrypt package body byte_package is procedure to_byte (in_dword : in dword; b1, b2, b3, b4 : out byte) is begin b4 := byte(in_dword and 16#ff#); b3 := byte(dword_shift_right(in_dword, 8) and 16#ff#); b2 := byte(dword_shift_right(in_dword, 16) and 16#ff#); b1 := byte(dword_shift_right(in_dword, 24)); end to_byte; function to_dword (b1, b2, b3, b4 : byte) return dword is begin return dword_shift_left(dword(b1), 24) or dword_shift_left(dword(b2), 16) or dword_shift_left(dword(b3), 8) or dword(b4); end; function dword_shift_left (value : dword; amount : integer := 1) return dword is begin return dword(Interfaces.Shift_Left( Value => Interfaces.Unsigned_32(value), Amount => amount)); end; function dword_shift_right (value : dword; amount : integer := 1) return dword is begin return dword(Interfaces.Shift_Right( Value => Interfaces.Unsigned_32(value), Amount => amount)); end; procedure increment (e : in out earth) is begin e := e + 1; end increment; end byte_package;
tp_01_07/ej1_7.asm
mjFer/TDIII-UTN-FRBA-TPS-2014
2
88023
<reponame>mjFer/TDIII-UTN-FRBA-TPS-2014<filename>tp_01_07/ej1_7.asm ; Trabajo Practico 1 - EJ 5 ; ; ; ; Alumno: <NAME> ; ; Legajo: 1403734 ; ; Curso: r5055 ; ; **************************************************************************************; ;******************************************************************************** ;* Macros * ;******************************************************************************** %define PML4_BASE 0xA000 ;ubicacion de la Page Map Level 4 %define PDPT_BASE PML4_BASE + 0x1000 ;ubicacion de la Page Directory Pointer Table %define PD_BASE PDPT_BASE + 0x1000 ;ubicacion de la Page Directory Table %define PT_BASE PD_BASE + 0x1000 ;ubicacion de la Page Table %define PT_ENTRY_0 PT_BASE + 0x1000 ;primer pagina %define PT_ENTRY_1 PT_ENTRY_0 + 0x1000 ;segunda pagina %define VIDEO_BASE 0x200000 %define BREAKPOINT xchg bx, bx ;******************************************************************************** ;* Macros Video * ;******************************************************************************** %define VIDEO_BLINK 10000000b ;BLINK %define VIDEO_B_C_B 00010000b ;BACKGROUND COLOR BLUE %define VIDEO_B_C_G 00100000b ;BACKGROUND COLOR GREEN %define VIDEO_B_C_R 01000000b ;BACKGROUND COLOR RED %define VIDEO_F_C_R 00001000b ;FOREGROUND COLOR RED %define VIDEO_F_C_G 00000100b ;FOREGROUND COLOR GREEN %define VIDEO_F_C_B 00000010b ;FOREGROUND COLOR BLUE %define VIDEO_UNDERLINE 00000001b ;UNDERLINE BITS 16 [ORG KERNEL_MEMORY] ALIGN 4096 jmp Inicio gdt: db 0,0,0,0,0,0,0,0 ;dejar vacio un descriptor cs_sel_64 equ $-gdt db 0xFF ;Bits 7-0 del limite (no usado en 64 bits). db 0xFF ;Bits 15-8 del limite (no usado en 64 bits). db 0 ;Bits 7-0 de la base (no usado en 64 bits). db 0 ;Bits 15-8 de la base (no usado en 64 bits). db 0 ;Bits 23-16 de la base (no usado en 64 bits). db 0x9A ;Byte de derechos de acceso: ;Bit 7=1: Segmento Presente. ;Bits 6,5=00: Nivel de Privilegio cero. ;Bit 4=1: Segmento de codigo o datos. ;Bit 3=1: Descriptor correspondiente a codigo. ;Bit 2=0: Segmento no conforme. ;Bit 1=1: El segmento de codigo se puede leer. ;Bit 0=0: El segmento no fue accedido. db 0xAF ;Bit 7=1: Granularidad (no usado en 64 bits). ;Bit 6,5=01: Segmento de 64 bits (en modo largo). ;Bit 4=0: No usado. ;Bits 3-0=1111: Bits 19-16 del limite (no usados ;en modo largo). db 0 ;Bits 31-24 de la base (no usado en 64 bits). cs_sel_32 equ $-gdt db 0xFF ;Bits 7-0 del limite. db 0xFF ;Bits 15-8 del limite. db 00h ;Bits 7-0 de la base. db 00h ;Bits 15-8 de la base. db 00h ;Bits 23-16 de la base. db 0x9A ;Byte de derechos de acceso: ;Bit 7=1: Segmento Presente. ;Bits 6,5=00: Nivel de Privilegio cero. ;Bit 4=1: Segmento de codigo o datos. ;Bit 3=1: Descriptor correspondiente a codigo. ;Bit 2=0: Segmento no conforme. ;Bit 1=1: El segmento de codigo se puede leer. ;Bit 0=0: El segmento no fue accedido. db 0xCF ;Bit 7=1: Granularidad. ;Bit 6,5=10: Segmento de 32 bits (en modo largo). (EN LA PRESENTACION ESTA MAL) ;Bit 4=0: No usado. ;Bits 3-0=1111: Bits 19-16 del limite. db 0 ;Bits 31-24 de la base. ds_sel equ $-gdt db 0FFh ;Bits 7-0 del limite (no usado en 64 bits). db 0FFh ;Bits 15-8 del limite (no usado en 64 bits). db 0 ;Bits 7-0 de la base (no usado en 64 bits). db 0 ;Bits 15-8 de la base (no usado en 64 bits). db 0 ;Bits 23-16 de la base (no usado en 64 bits). db 92h ;Byte de derechos de acceso: ;Bit 7=1: Segmento Presente. ;Bits 6,5=00: Nivel de Privilegio cero. ;Bit 4=1: Segmento de codigo o datos. ;Bit 3=0: Descriptor correspondiente a datos. ;Bit 2=0: Offset <= Limite. ;Bit 1=1: El segmento de datos se puede escribir. ;Bit 0=0: El segmento no fue accedido. db 0CFh ;Bit 7=0: Granularidad (no usado en 64 bits). ;Bit 6,5=10: Segmento de 32 bits. ;Bit 4=0: No usado. ;Bits 3-0=1111: Bits 19-16 del limite (no usados ;en modo largo). db 0 ;Bits 31-24 de la base (no usado en 64 bits). long_gdt equ $-gdt ;longitud gdt valor_gdtr: dw long_gdt-1 dd gdt idt: times 32 dq 0,0 ;16 bytes por compuerta. dw int_0 ;Bits 15-0 del offset. dw cs_sel_64 ;Selector del segmento de codigo. db 0 ;Cantidad de palabras que ocupan los parametros. db 8Eh ;Compuerta de interrupcion de 64 bits. dw 0 ;Bits 31-16 del offset. dd 0 ;Bits 63-32 del offset. dd 0 ;Reservado. dw int9_keyboardHandler ;Bits 15-0 del offset. dw cs_sel_64 ;Selector del segmento de codigo. db 0 ;Cantidad de palabras que ocupan los parametros. db 8Eh ;Compuerta de interrupcion de 64 bits. dw 0 ;Bits 31-16 del offset. dd 0 ;Bits 63-32 del offset. dd 0 ;Reservado. %assign i 0 %rep 30 ; Compuerta de interrupcion de 16 bytes correspondiente a INT i. dw int_%+i ;Bits 15-0 del offset. dw cs_sel_64 ;Selector del segmento de codigo. db 0 ;Cantidad de palabras que ocupan los parametros. db 8Eh ;Compuerta de interrupcion de 64 bits. dw 0 ;Bits 31-16 del offset. dd 0 ;Bits 63-32 del offset. dd 0 ;Reservado. %assign i i+1 %endrep idtsize equ $-idt idtr: dw idtsize-1 dd idt pila: times 100 db 0 texto: db "UTN-2014-TDIII-HelloWorld-MarceloJFernandez", 00h Inicio: cli lgdt [valor_gdtr] ;cargo la gdt ;habilito gateA20 call Verificar_Gate_A20 mov eax,cr0 or al,1 mov cr0,eax jmp cs_sel_32:ModoProt_Legacy BITS 32 ModoProt_Legacy: mov ax,ds_sel ;cargo el descriptor de datos mov ds,ax ;cargo ds con el segundo descriptor mov ss,ax ;cargo ss con el descriptor de datos (para la pila) mov eax,pila + 100 ;seteo la direccion de la pila +100 por que se carga de forma inversa mov esp,eax ;reprogramo el pic call Pic_Reprograming mov AL, 11111101b ;desabilito todas las interrupciones del PIC1 ;11111100b http://www.brokenthorn.com/Resources/OSDevPic.html out 21h,al mov AL, 0xFF ;desabilito todas las interrupciones del PIC2 ?????????????????????????? out 0xA1,al lidt [idtr] ;Comprueba si PAE esta como spec en el micro mov eax,1 CPUID and edx,1000000b cmp edx,1000000b jnz NO_PAE ;Comprueba si LME esta como spec en el micro mov eax,0x80000001 CPUID and edx,0x20000000 ;bit 29 cmp edx,0x20000000 jnz NO_LME ;INICIO Creacion de paginas mov dword [PML4_BASE],PDPT_BASE + 0x11 ;si no anda ver que puede estar aca el problema mov dword [PML4_BASE + 4], 0 mov dword [PDPT_BASE],PD_BASE + 0x11 mov dword [PDPT_BASE + 4], 0 mov dword [PD_BASE],PT_BASE + 0x11 mov dword [PD_BASE + 4], 0 ;Aca arrancamos a crear las paginas con un loop mov ecx, 512 ;voy a crear 20 paginas mov eax, 01000h + 0x01 mov edi, PT_BASE + 8 pageloop: mov dword [edi],eax mov dword [edi + 4],0 add edi, 8 add eax, 1000h loop pageloop mov dword [PT_BASE],0b8000h + 0x01 mov dword [PT_BASE + 4], 0 ;FIN CREACION PAGINAS mov eax,PML4_BASE mov cr3,eax mov eax,cr4 ;leo el registro CR4 or eax,00100000b ;or flag de PAE mov cr4,eax ;Seteo CR4 mov ecx,0x0C0000080 ;seteo para leer EFER de la MSR rdmsr ;pedido de lectura a MSR or eax, 0x00000100 ;Seteo LME (Long mode enable) wrmsr ;seteo en la MSR el registro EFER mov eax,cr0 ;seteo el bit de paginacion or eax,80000000h mov cr0,eax jmp cs_sel_64:modo_largo [bits 64] modo_largo: sti ;LLamo a un Clear Screen call clrScr ;llamo a la rutina de print mov edi,texto mov esi,10 ; esi (segundo argumento) char columna mov edx,2 ; edx (tercer argumento) char fila mov ecx,111b ; ECX (cuarto arguemto) char color call Print ;pruebo de escribir en una direccion superior al primer megabyte mov edi,0x100000 ;me posiciono en el primer megabyte mov word [edi],0xA0BA0; ;escribo basura XD haceNada: hlt jmp haceNada NO_PAE: ;aunque es al pedo para el debugging me caeria aca si no tuviese pae hlt NO_LME: ;aunque es al pedo para el debugging me caeria aca si no tuviese pae hlt %include "include/utils.asm" %include "include/isr.asm" %include "include/gateA20.asm"
.emacs.d/elpa/ada-mode-5.3.1/gps_source/ada_analyzer.adb
caqg/linux-home
0
603
------------------------------------------------------------------------------ -- G P S -- -- -- -- Copyright (C) 2001-2017, AdaCore -- -- -- -- This 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. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. You should have received a copy of the GNU -- -- General Public License distributed with this software; see file -- -- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy -- -- of the license. -- ------------------------------------------------------------------------------ with Ada.Characters.Handling; use Ada.Characters.Handling; with GNAT.Regpat; use GNAT.Regpat; with Generic_Stack; with Indent_Stack; with String_Utils; use String_Utils; with GNATCOLL.Traces; use GNATCOLL.Traces; with GNATCOLL.Utils; use GNATCOLL.Utils; with UTF8_Utils; use UTF8_Utils; package body Ada_Analyzer is Me : constant Trace_Handle := Create ("LANGUAGE.ADA_ANALYZER", On); use Indent_Stack.Stack; ----------------- -- Local types -- ----------------- type Token_Type is ( -- Token name Token type Class(es) Tok_Integer_Literal, -- numeric lit Literal, Lit_Or_Name Tok_String_Literal, -- string lit Literal. Lit_Or_Name Tok_Char_Literal, -- char lit Name, Literal. Lit_Or_Name Tok_Operator_Symbol, -- op symbol Name, Literal, Lit_Or_Name, Desig Tok_Identifier, -- identifer Name, Lit_Or_Name, Desig Tok_Double_Asterisk, -- ** Tok_Minus, -- - Binary_Addop, Unary_Addop Tok_Plus, -- + Binary_Addop, Unary_Addop Tok_Asterisk, -- * Mulop Tok_Slash, -- / Mulop Tok_Dot, -- . Namext Tok_Apostrophe, -- ' Namext Tok_Right_Paren, -- ) Sterm Tok_Comma, -- , Sterm Tok_Less, -- < Relop, Sterm Tok_Equal, -- = Relop, Sterm Tok_Greater, -- > Relop, Sterm Tok_Not_Equal, -- /= Relop, Sterm Tok_Greater_Equal, -- >= Relop, Sterm Tok_Less_Equal, -- <= Relop, Sterm Tok_Box, -- <> Relop, Eterm, Sterm Tok_Colon_Equal, -- := Eterm, Sterm Tok_Abstract, -- ABSTRACT Eterm, Sterm Tok_Access, -- ACCESS Eterm, Sterm Tok_Aliased, -- ALIASED Eterm, Sterm Tok_All, -- ALL Eterm, Sterm Tok_Array, -- ARRAY Eterm, Sterm Tok_At, -- AT Eterm, Sterm Tok_Mod, -- MOD Mulop Tok_Rem, -- REM Mulop Tok_And, -- AND Logop, Sterm Tok_Delta, -- DELTA Atkwd, Sterm, Consk Tok_Digits, -- DIGITS Atkwd, Sterm, Consk Tok_Range, -- RANGE Atkwd, Sterm, Consk Tok_Abs, -- ABS Tok_New, -- NEW Tok_Null, -- NULL Tok_Others, -- OTHERS Tok_In, -- IN Relop, Sterm Tok_Not, -- NOT Relop, Sterm Tok_Or, -- OR Logop, Sterm Tok_Xor, -- XOR Logop, Sterm Tok_Body, -- BODY Eterm, Sterm Tok_Constant, -- CONSTANT Eterm, Sterm Tok_Limited, -- LIMITED Eterm, Sterm Tok_Of, -- OF Eterm, Sterm Tok_Out, -- OUT Eterm, Sterm Tok_Renames, -- RENAMES Eterm, Sterm Tok_Reverse, -- REVERSE Eterm, Sterm Tok_Some, -- SOME Eterm, Sterm Tok_Tagged, -- TAGGED Eterm, Sterm Tok_Case, -- CASE Eterm, Sterm, After_SM Tok_Delay, -- DELAY Eterm, Sterm, After_SM Tok_Accept, -- ACCEPT Eterm, Sterm, After_SM Tok_Elsif, -- ELSIF Eterm, Sterm, After_SM Tok_End, -- END Eterm, Sterm, After_SM Tok_Exit, -- EXIT Eterm, Sterm, After_SM Tok_Goto, -- GOTO Eterm, Sterm, After_SM Tok_If, -- IF Eterm, Sterm, After_SM Tok_Pragma, -- PRAGMA Eterm, Sterm, After_SM Tok_Raise, -- RAISE Eterm, Sterm, After_SM Tok_Requeue, -- REQUEUE Eterm, Sterm, After_SM Tok_Return, -- RETURN Eterm, Sterm, After_SM Tok_Terminate, -- TERMINATE Eterm, Sterm, After_SM Tok_Until, -- UNTIL Eterm, Sterm, After_SM Tok_When, -- WHEN Eterm, Sterm, After_SM Tok_For, -- FOR Eterm, Sterm, After_SM, Labeled_Stmt Tok_While, -- WHILE Eterm, Sterm, After_SM, Labeled_Stmt Tok_Separate, -- SEPARATE Eterm, Sterm, Cunit, After_SM Tok_Entry, -- ENTRY Eterm, Sterm, Declk, Deckn, After_SM Tok_Protected, -- PROTECTED Eterm, Sterm, Declk, Deckn, After_SM Tok_Task, -- TASK Eterm, Sterm, Declk, Deckn, After_SM Tok_Type, -- TYPE Eterm, Sterm, Declk, Deckn, After_SM Tok_Subtype, -- SUBTYPE Eterm, Sterm, Declk, Deckn, After_SM Tok_Overriding, -- OVERRIDING Eterm, Sterm, Declk, Declk, After_SM Tok_Synchronized, -- SYNCHRONIZED Eterm, Sterm, Declk, Deckn, After_SM Tok_Use, -- USE Eterm, Sterm, Declk, Deckn, After_SM Tok_Generic, -- GENERIC Eterm, Sterm, Cunit, Declk, After_SM Tok_Function, -- FUNCTION Eterm, Sterm, Cunit, Declk, After_SM Tok_Package, -- PACKAGE Eterm, Sterm, Cunit, Declk, After_SM Tok_Procedure, -- PROCEDURE Eterm, Sterm, Cunit, Declk, After_SM Tok_Do, -- DO Eterm, Sterm Tok_Is, -- IS Eterm, Sterm Tok_Interface, -- INTERFACE Eterm, Sterm Tok_Record, -- RECORD Eterm, Sterm Tok_Then, -- THEN Eterm, Sterm Tok_Abort, -- ABORT Eterm, Sterm, After_SM Tok_Else, -- ELSE Eterm, Sterm, After_SM Tok_Exception, -- EXCEPTION Eterm, Sterm, After_SM Tok_Select, -- SELECT Eterm, Sterm, After_SM Tok_Begin, -- BEGIN Eterm, Sterm, After_SM, Labeled_Stmt Tok_Declare, -- DECLARE Eterm, Sterm, After_SM, Labeled_Stmt Tok_Loop, -- LOOP Eterm, Sterm, After_SM, Labeled_Stmt Tok_Private, -- PRIVATE Eterm, Sterm, Cunit, After_SM Tok_With, -- WITH Eterm, Sterm, Cunit, After_SM Tok_Semicolon, -- ; Eterm, Sterm, Cterm Tok_Left_Paren, -- ( Namext, Consk Tok_Ampersand, -- & Binary_Addop Tok_Vertical_Bar, -- | Cterm, Sterm, Chtok Tok_Less_Less, -- << Eterm, Sterm, After_SM Tok_Greater_Greater, -- >> Eterm, Sterm Tok_Pound, -- # sign, used by the preprocessor Tok_Left_Square_Bracket, -- '[' used in wide character encoding Tok_Right_Square_Bracket, -- ']' used in wide character encoding Tok_Colon, -- : Eterm, Sterm Tok_Arrow, -- => Sterm, Cterm, Chtok Tok_Dot_Dot, -- .. Sterm, Chtok No_Token); -- No_Token is used for initializing Token values to indicate that -- no value has been set yet. type Token_Set is array (Token_Type) of Boolean; pragma Pack (Token_Set); subtype Reserved_Token_Type is Token_Type range Tok_Abstract .. Tok_With; subtype Token_Class_Literal is Token_Type range Tok_Integer_Literal .. Tok_Operator_Symbol; -- Literal subtype Token_Class_Declk is Token_Type range Tok_Entry .. Tok_Procedure; -- Keywords which start a declaration subtype Token_Class_No_Cont is Token_Type range Tok_Generic .. Tok_Colon; -- Do not allow a following continuation line Is_Operator : constant Token_Set := (Tok_Double_Asterisk | Tok_Minus | Tok_Plus | Tok_Asterisk | Tok_Slash | Tok_Less | Tok_Equal | Tok_Greater | Tok_Not_Equal | Tok_Greater_Equal | Tok_Less_Equal | Tok_Ampersand => True, others => False); Is_Extended_Operator : constant Token_Set := (Tok_Double_Asterisk .. Tok_Slash | Tok_Comma .. Tok_Colon_Equal | Tok_Semicolon | Tok_Ampersand .. Tok_Greater_Greater | Tok_Colon .. Tok_Dot_Dot => True, others => False); Max_Identifier : constant := 256; -- Maximum length of an identifier type Variable_Kind_Type is (Unknown_Kind, Parameter_Kind, Discriminant_Kind); type Extended_Token is record Token : Token_Type := No_Token; -- Enclosing token In_Declaration : Boolean := False; -- Are we inside a declarative part ? In_Entity_Profile : Boolean := True; -- Are we in a definition? -- (e.g. [procedure bla] is -- [type T is record] null; end record; -- etc... Extra_Indent : Boolean := False; -- Used for various kinds of constructs, when detecting different -- ways of indenting code (only used internally). -- For a Tok_Record, set to True if the keyword "record" was found on -- its own line. -- For a Tok_Case, set to True if 'when' constructs should be indented -- an extra level, as for the RM style. Type_Declaration : Boolean := False; -- Is it a type declaration ? Package_Declaration : Boolean := False; -- Is it a package declaration ? Protected_Declaration : Boolean := False; -- Is this a protected declaration ? -- ??? It would be nice to merge the fields Declaration, -- Type_Declaration and Package_Declaration at some point. Identifier : String (1 .. Max_Identifier); -- Name of the enclosing token -- The actual name is Identifier (1 .. Ident_Len) Ident_Len : Natural := 0; -- Actual length of Indentifier Profile_Start : Natural := 0; -- Position in the buffer where the profile of the current subprogram -- starts. Profile_End : Natural := 0; -- Position in the buffer where the profile of the current subprogram -- ends. Align_Colon : Natural := 0; -- The column on which to align declarations Colon_Col : Natural := 0; -- The column where the last ':' was found. -- Only relevant for Tok_Colon tokens Sloc : Source_Location; -- Source location for this entity Sloc_Name : Source_Location; -- Source location for the name of this entity, if relevant Visibility : Construct_Visibility := Visibility_Public; -- Is the token public or private ? Visibility_Section : Construct_Visibility := Visibility_Public; -- Are we on the public or on the private section of the token ? Variable_Kind : Variable_Kind_Type := Unknown_Kind; -- If the token is a variable, hold wether this is actually a variable, -- a discriminant or a parameter Type_Definition_Section : Boolean := False; -- Are we currently processing the type definition of the token ? Is_In_Type_Definition : Boolean := False; -- Is this token found in the type definition section of its parent ? Attributes : Construct_Attribute_Map := No_Attribute; -- Defines the attributes that have been found for the given token Is_Generic_Param : Boolean := False; -- Is this token a generic parameter? end record; -- Extended information for a token package Token_Stack is new Generic_Stack (Extended_Token); use Token_Stack; type Construct_Type is (Conditional, Type_Declaration, Function_Call, Aggregate); -- Type used to differentiate different constructs to refine indentation package Construct_Stack is new Generic_Stack (Construct_Type); use Construct_Stack; ---------------------- -- Local procedures -- ---------------------- function Get_Token (Str : String; Prev_Token : Token_Type) return Token_Type; -- Return a token_Type given a string. -- For efficiency, S is assumed to start at index 1. -- Prev_Token is the previous token scanned, if any. This is needed -- to e.g. differenciate pragma Interface vs interface keyword. function Is_Library_Level (Stack : Token_Stack.Simple_Stack) return Boolean; -- Return True if the current scope in Stack is a library level package --------------- -- Get_Token -- --------------- function Get_Token (Str : String; Prev_Token : Token_Type) return Token_Type is S : String (Str'Range); begin pragma Assert (S'First = 1); -- First convert Str to lower case for the token parser below for K in Str'Range loop S (K) := To_Lower (Str (K)); end loop; if S'Length = 0 then return No_Token; elsif S'Length = 1 then if Is_Control (S (S'First)) then return No_Token; else return Tok_Identifier; end if; end if; -- Use a case statement instead of a loop for efficiency case S (1) is when 'a' => case S (2) is when 'b' => if S (3 .. S'Last) = "ort" then return Tok_Abort; elsif S (3 .. S'Last) = "s" then return Tok_Abs; elsif S (3 .. S'Last) = "stract" then return Tok_Abstract; end if; when 'c' => if S (3 .. S'Last) = "cept" then return Tok_Accept; elsif S (3 .. S'Last) = "cess" then return Tok_Access; end if; when 'l' => if S (3 .. S'Last) = "l" then return Tok_All; elsif S (3 .. S'Last) = "iased" then return Tok_Aliased; end if; when 'n' => if S (3 .. S'Last) = "d" then return Tok_And; end if; when 'r' => if S (3 .. S'Last) = "ray" then return Tok_Array; end if; when 't' => if S'Length = 2 then return Tok_At; end if; when others => return Tok_Identifier; end case; when 'b' => if S (2 .. S'Last) = "egin" then return Tok_Begin; elsif S (2 .. S'Last) = "ody" then return Tok_Body; end if; when 'c' => if S (2 .. S'Last) = "ase" then return Tok_Case; elsif S (2 .. S'Last) = "onstant" then return Tok_Constant; end if; when 'd' => if S (2) = 'e' then if S (3 .. S'Last) = "clare" then return Tok_Declare; elsif S (3 .. S'Last) = "lay" then return Tok_Delay; elsif S (3 .. S'Last) = "lta" then return Tok_Delta; end if; elsif S (2 .. S'Last) = "igits" then return Tok_Digits; elsif S (2 .. S'Last) = "o" then return Tok_Do; end if; when 'e' => if S (2 .. S'Last) = "lse" then return Tok_Else; elsif S (2 .. S'Last) = "lsif" then return Tok_Elsif; elsif S (2 .. S'Last) = "nd" then return Tok_End; elsif S (2 .. S'Last) = "ntry" then return Tok_Entry; elsif S (2 .. S'Last) = "xception" then return Tok_Exception; elsif S (2 .. S'Last) = "xit" then return Tok_Exit; end if; when 'f' => if S (2 .. S'Last) = "or" then return Tok_For; elsif S (2 .. S'Last) = "unction" then return Tok_Function; end if; when 'g' => if S (2 .. S'Last) = "eneric" then return Tok_Generic; elsif S (2 .. S'Last) = "oto" then return Tok_Goto; end if; when 'i' => if S (2 .. S'Last) = "f" then return Tok_If; elsif S (2 .. S'Last) = "n" then return Tok_In; elsif S (2 .. S'Last) = "nterface" then if Prev_Token = Tok_Pragma then return Tok_Identifier; else return Tok_Interface; end if; elsif S (2 .. S'Last) = "s" then return Tok_Is; end if; when 'l' => if S (2 .. S'Last) = "imited" then return Tok_Limited; elsif S (2 .. S'Last) = "oop" then return Tok_Loop; end if; when 'm' => if S (2 .. S'Last) = "od" then return Tok_Mod; end if; when 'n' => if S (2 .. S'Last) = "ew" then return Tok_New; elsif S (2 .. S'Last) = "ot" then return Tok_Not; elsif S (2 .. S'Last) = "ull" then return Tok_Null; end if; when 'o' => if S (2 .. S'Last) = "thers" then return Tok_Others; elsif S (2 .. S'Last) = "ut" then return Tok_Out; elsif S (2 .. S'Last) = "f" then return Tok_Of; elsif S (2 .. S'Last) = "r" then return Tok_Or; elsif S (2 .. S'Last) = "verriding" then return Tok_Overriding; end if; when 'p' => if S (2) = 'r' then if S (3 .. S'Last) = "agma" then return Tok_Pragma; elsif S (3 .. S'Last) = "ivate" then return Tok_Private; elsif S (3 .. S'Last) = "ocedure" then return Tok_Procedure; elsif S (3 .. S'Last) = "otected" then return Tok_Protected; end if; elsif S (2 .. S'Last) = "ackage" then return Tok_Package; end if; when 'r' => if S (2) = 'a' then if S (3 .. S'Last) = "ise" then return Tok_Raise; elsif S (3 .. S'Last) = "nge" then return Tok_Range; end if; elsif S (2) = 'e' then if S (3 .. S'Last) = "cord" then return Tok_Record; elsif S (3 .. S'Last) = "m" then return Tok_Rem; elsif S (3 .. S'Last) = "names" then return Tok_Renames; elsif S (3 .. S'Last) = "queue" then return Tok_Requeue; elsif S (3 .. S'Last) = "turn" then return Tok_Return; elsif S (3 .. S'Last) = "verse" then return Tok_Reverse; end if; end if; when 's' => if S (2 .. S'Last) = "elect" then return Tok_Select; elsif S (2 .. S'Last) = "eparate" then return Tok_Separate; elsif S (2 .. S'Last) = "ome" then if Prev_Token = Tok_For then return Tok_Some; else return Tok_Identifier; end if; elsif S (2 .. S'Last) = "ubtype" then return Tok_Subtype; elsif S (2 .. S'Last) = "ynchronized" then return Tok_Synchronized; end if; when 't' => if S (2 .. S'Last) = "agged" then return Tok_Tagged; elsif S (2 .. S'Last) = "ask" then return Tok_Task; elsif S (2 .. S'Last) = "erminate" then return Tok_Terminate; elsif S (2 .. S'Last) = "hen" then return Tok_Then; elsif S (2 .. S'Last) = "ype" then return Tok_Type; end if; when 'u' => if S (2 .. S'Last) = "ntil" then return Tok_Until; elsif S (2 .. S'Last) = "se" then return Tok_Use; end if; when 'w' => if S (2 .. S'Last) = "hen" then return Tok_When; elsif S (2 .. S'Last) = "hile" then return Tok_While; elsif S (2 .. S'Last) = "ith" then return Tok_With; end if; when 'x' => if S (2 .. S'Last) = "or" then return Tok_Xor; end if; when others => return Tok_Identifier; end case; return Tok_Identifier; end Get_Token; ---------------------- -- Is_Library_Level -- ---------------------- function Is_Library_Level (Stack : Token_Stack.Simple_Stack) return Boolean is Result : Boolean := True; function Check_Token (Token : Extended_Token) return Boolean; function Check_Token (Token : Extended_Token) return Boolean is begin if Token.Token /= No_Token and then Token.Token /= Tok_Package and then Token.Token /= Tok_Generic then Result := False; return False; end if; return True; end Check_Token; begin Traverse_Stack (Stack, Check_Token'Access); return Result; end Is_Library_Level; ------------------------ -- Analyze_Ada_Source -- ------------------------ SPARK_Keywords : constant Pattern_Matcher := Compile ("^(a(bs|ll|nd|ss(ert|ume))|check|derives|e(lse|nd)|" & "f(or|rom|unction)|global|" & "h(ide|old)|i(n|s)|in(herit|itializes|variant)|" & "main_program|n(ot|ull)|o(r|wn|thers)|post|pre|some|" & "a(ccept|re_interchangeable|s|ssume)|const|div|" & "element|fi(nish|rst)|for_(all|some)|goal|" & "last|may_be_(deduced|deduced_from|" & "replaced_by)|no(n(first|last)|t_in)|o(dd|ut)|" & "p(ending|red|roof)|r(ange|e(al|quires|turn|m))|s(ave|" & "e(quence|t)|ome|qr|t(art|rict_subset_of)|" & "u(bset_of|cc))|t(hen|ype)|update|var|where|xor|" & "fld_.*|upf_.*)$"); -- Regular expression for SPARK keywords procedure Analyze_Ada_Source (Buffer : UTF8_String; Symbols : GNATCOLL.Symbols.Symbol_Table_Access; Indent_Params : Indent_Parameters; Format : Boolean := True; From, To : Natural := 0; Replace : Replace_Text_Callback := null; Constructs : Construct_List_Access := null; Callback : Entity_Callback := null; Indent_Offset : Natural := 0; Case_Exceptions : Casing_Exceptions := No_Casing_Exception; Is_Optional_Keyword : access function (S : String) return Boolean := null) is --------------- -- Constants -- --------------- None : constant := -1; Default_Extended : Extended_Token; pragma Warnings (Off, Default_Extended); -- Use default values to initialize this pseudo constant Indent_Level : Natural renames Indent_Params.Indent_Level; Indent_Continue : Natural renames Indent_Params.Indent_Continue; Indent_Decl : Natural renames Indent_Params.Indent_Decl; Indent_With : constant := 5; Indent_Use : constant := 4; Indent_When : constant := 5; Indent_Comments : Boolean renames Indent_Params.Indent_Comments; Stick_Comments : Boolean renames Indent_Params.Stick_Comments; Stop_On_Blank_Line : constant Boolean := True; Indent_Record : Natural renames Indent_Params.Indent_Record; Indent_Case_Extra : Indent_Style renames Indent_Params.Indent_Case_Extra; Indent_Conditional : Natural renames Indent_Params.Indent_Conditional; Reserved_Casing : Casing_Type renames Indent_Params.Reserved_Casing; Ident_Casing : Casing_Type renames Indent_Params.Ident_Casing; Use_Tabs : Boolean renames Indent_Params.Use_Tabs; Format_Operators : constant Boolean := Format and then Indent_Params.Format_Operators; Align_On_Colons : constant Boolean := Format and then Indent_Params.Align_On_Colons; Align_On_Arrows : constant Boolean := Format and then Indent_Params.Align_On_Arrows; Align_Decl_On_Colon : constant Boolean := Format and then Indent_Params.Align_Decl_On_Colon; Buffer_Last : constant Natural := Buffer'Last; --------------- -- Variables -- --------------- Line_Count : Integer := 1; Str : String (1 .. 1024); Str_Len : Natural := 0; Current : Natural; Prec : Natural := Buffer'First; Start_Of_Line : Natural; Prev_Line : Natural; Num_Spaces : Integer := 0; Continuation_Val : Integer := 0; Indent_Done : Boolean := False; Num_Parens : Integer := 0; Index_Ident : Natural; In_Generic : Boolean := False; Aspect_Clause : Boolean := False; -- True when the current construct is an Ada 2012 aspect clause -- Consider merging with Subprogram_Aspect ??? Aspect_Clause_Sloc : Source_Location; -- source location of start of the current aspect clause, when -- Aspect_Clause is True. type In_Declaration_Kind is (No_Decl, Subprogram_Decl, Subprogram_Aspect, Type_Decl); In_Declaration : In_Declaration_Kind := No_Decl; -- Identifies when we are in a declaration Syntax_Error : Boolean := False; -- Not used for now, but may be useful in the future pragma Unreferenced (Syntax_Error); Comments_Skipped : Boolean := False; Token : Token_Type; Prev_Token : Token_Type := No_Token; Prev_Prev_Token : Token_Type := No_Token; Tokens : Token_Stack.Simple_Stack; Paren_Stack : Construct_Stack.Simple_Stack; Indents : Indent_Stack.Stack.Simple_Stack; Top_Token : Token_Stack.Generic_Type_Access; Casing : Casing_Type := Unchanged; Terminated : Boolean := False; End_Reached : Boolean := False; Last_Replace_Line : Natural := 0; Padding : Integer := 0; Paren_In_Middle : Boolean := False; Is_Parameter : Boolean := False; -- This variable is true if the identifiers picked are parameters, false -- otherwise. Is_Discriminant : Boolean := False; -- This variable is true if the identifiers picked are parameters, false -- otherwise. Right_Assignment : Boolean := False; -- When this is true, we are in a left assignment section procedure Handle_Word_Token (Reserved : Token_Type; Temp : out Extended_Token; Do_Pop : out Integer; Do_Push : out Boolean; Finish : out Boolean); -- Handle a reserved word and computes a token out of it. Results -- reads as follows: -- Temp - the token created -- Do_Pop - number of tokens to be popped out of the token list after -- intendation -- Do_Push - does temp needs to be pushed to the token list after -- indentation? -- Finish - should the analysis be terminated? procedure Handle_Word_Indent (Reserved : Token_Type; Temp : in out Extended_Token); -- Performs indentation after a call to Handle_Word_Token, and before -- tokens are pushed or popped. procedure Finish_Aspect_Clause (P, Line : Natural; Done : out Boolean); -- We are at the end of an aspect clause, so pop the stack, -- call corresponding callbacks. -- Done is set to True if processing should stop after this call. -- P points to the first character in Buffer after the aspect clause. -- Line is the current line. procedure Next_Word (P : in out Natural; L : in out Natural; Terminated : out Boolean; End_Reached : out Boolean); -- Starting at Buffer (P), find the location of the next word -- and set P accordingly. -- Formatting of operators is performed by this procedure. -- The following variables are accessed read-only: -- Buffer, Tokens, Num_Spaces, Indent_Continue -- The following variables are read and modified: -- New_Buffer, Num_Parens, Line_Count, Indents, Indent_Done, -- Prev_Token. -- If the end of the buffer has been reached, set End_Reached to True. -- If parsing should be terminated, set Terminated to True. function End_Of_Word (P : Natural) return Natural; -- Return the end of the word pointed by P function End_Of_Identifier (P : Natural) return Natural; -- Starting from P, scan for the end of the identifier. -- P should be at the first non word character, which means that -- if the identifier does not contain any dot, P - 1 will be returned. procedure Look_For_End_Of_Data_Declaration (Sloc : in out Source_Location); -- Search the first ; character, or the first closing parenthesis, -- skipping nested ones. Intended to go at the end of a variable or -- parameter declaration. procedure Look_For (Sloc : in out Source_Location; Char : Character); -- Search Char in Buffer starting from Sloc. -- Sloc is updated to the first occurrence of Char in Buffer, or -- Buffer_Last if not found. function Look_For (Index : Natural; S : String) return Boolean; -- Return True if Buffer (Index) contains the word S procedure New_Line (Count : in out Natural); pragma Inline (New_Line); -- Increment Count and poll if needed (e.g for graphic events) procedure Do_Indent (Prec : Natural; Line_Count : Natural; Num_Spaces : Integer; Continuation : Boolean := False); -- Perform indentation by inserting spaces in the buffer. -- If Continuation is True, Indent_Continue extra spaces are added. procedure Indent_Function_Return (Prec : Natural); -- Perform special indentation for function return/rename statements function Is_Continuation_Line (Token : Token_Type; Prev_Token : Token_Type; Prev_Prev_Token : Token_Type) return Boolean; -- Return True if we are indenting a continuation line procedure Compute_Indentation (Token : Token_Type; Prev_Token : Token_Type; Prev_Prev_Token : Token_Type; Prec : Natural; Line_Count : Natural; Num_Spaces : Integer); -- Compute proper indentation, taking into account various cases -- of simple/continuation/declaration/... lines. function Next_Char (P : Natural) return Natural; -- Return the next char in buffer. P is the current character pragma Inline (Next_Char); function Prev_Char (P : Natural) return Natural; -- Return the previous char in buffer. P is the current character pragma Inline (Prev_Char); function Compute_Alignment (P : Natural; Stop_On_Blank_Line : Boolean := False; Skip_First_Line : Boolean := True; Align_On : Token_Type := Tok_Colon) return Natural; -- Compute the column number for an alignment on Align_On, starting at P -- Align_On can take one of the following values: -- - Tok_Colon -- - Tok_Arrow -- - Tok_Colon_Equal (not supported yet) procedure Replace_Text (First : Natural; Last : Natural; Line : Natural; Str : String); -- Wrapper for Replace.all, taking (From, To) into account function Call_Callback (Entity : Language_Entity; Sloc_Start : Source_Location; Sloc_End : Source_Location; Partial_Entity : Boolean) return Boolean; -- Call Callback and take into account Aspect_Clause/Aspect_Clause_Sloc -- if needed. -------------------- -- Stack Routines -- -------------------- procedure Pop (Stack : in out Token_Stack.Simple_Stack; Value : out Extended_Token); -- Pop Value on top of Stack procedure Pop (Stack : in out Token_Stack.Simple_Stack); -- Pop Value on top of Stack. Ignore returned value --------------- -- Next_Char -- --------------- function Next_Char (P : Natural) return Natural is begin return UTF8_Next_Char (Buffer, P); end Next_Char; --------------- -- Prev_Char -- --------------- function Prev_Char (P : Natural) return Natural is begin return UTF8_Prev_Char (Buffer, P); end Prev_Char; --------------- -- Do_Indent -- --------------- procedure Do_Indent (Prec : Natural; Line_Count : Natural; Num_Spaces : Integer; Continuation : Boolean := False) is Start : Natural; Indentation : Integer; Index : Natural; begin if Indent_Done or not Format then return; end if; Paren_In_Middle := False; if Prec > Buffer_Last then -- In this case, we've parsed the entire buffer, so just compute -- from the last offset Start := Line_Start (Buffer, Buffer'Last); else Start := Line_Start (Buffer, Prec); end if; Index := Start; loop -- Manual unrolling for efficiency exit when Buffer (Index) /= ' ' and then Buffer (Index) /= ASCII.HT; Index := Index + 1; exit when Buffer (Index) /= ' ' and then Buffer (Index) /= ASCII.HT; Index := Index + 1; exit when Buffer (Index) /= ' ' and then Buffer (Index) /= ASCII.HT; Index := Index + 1; end loop; if Top (Indents).Level = None then Indentation := Num_Spaces + Indent_Offset; else Indentation := Top (Indents).Level; end if; if Continuation then Continuation_Val := Continuation_Val + Indent_Continue; Indentation := Indentation + Continuation_Val; else Continuation_Val := 0; end if; Replace_Text (Start, Index, Line_Count, Blank_Slice (Indentation, Use_Tabs, Tab_Width)); Indent_Done := True; end Do_Indent; ---------------------------- -- Indent_Function_Return -- ---------------------------- procedure Indent_Function_Return (Prec : Natural) is Top_Token : constant Token_Stack.Generic_Type_Access := Top (Tokens); begin -- function A -- return B; -- from Indent_Continue -- function A (....) -- return B; -- function A -- (...) -- return B; if Top_Token.Profile_Start = 0 then Do_Indent (Prec, Line_Count, Num_Spaces + Indent_Continue); else Do_Indent (Prec, Line_Count, Top_Token.Profile_Start - Line_Start (Buffer, Top_Token.Profile_Start) + 1); end if; end Indent_Function_Return; ----------------------- -- Compute_Alignment -- ----------------------- function Compute_Alignment (P : Natural; Stop_On_Blank_Line : Boolean := False; Skip_First_Line : Boolean := True; Align_On : Token_Type := Tok_Colon) return Natural is Alignment : Natural := 0; New_Align : Natural; Found_Align : Boolean := False; J : Natural; Non_Blank : Natural := 0; Length_Ident : Natural := 0; Local_Num_Parens : Natural := 0; begin if Align_On /= Tok_Colon and then Align_On /= Tok_Arrow -- and then Align_On /= Tok_Colon_Equal ??? not supported yet then return 0; end if; if Skip_First_Line then J := Next_Line (Buffer, P); else J := P; end if; Main_Loop : loop exit Main_Loop when J >= Buffer'Last; if Non_Blank = 0 then if not Is_Blank (Buffer (J)) then Non_Blank := J; Length_Ident := 1; end if; else Length_Ident := Length_Ident + 1; end if; exit Main_Loop when Look_For (J, "begin") or else Look_For (J, "case") or else Look_For (J, "end") or else Look_For (J, "package") or else Look_For (J, "protected") or else Look_For (J, "task") or else Look_For (J, "type"); case Buffer (J) is when '"' => if Buffer (J - 1) /= ''' then J := J + 1; Skip_To_Char (Buffer, J, '"'); end if; when '-' => if Buffer (J + 1) = '-' then -- Skip comment J := Next_Line (Buffer, J) - 1; Found_Align := False; Non_Blank := 0; end if; when '(' => if Buffer (J - 1) /= ''' or else Buffer (J + 1) /= ''' then Local_Num_Parens := Local_Num_Parens + 1; end if; when ')' => if Buffer (J - 1) /= ''' then exit Main_Loop when Local_Num_Parens = 0; Local_Num_Parens := Local_Num_Parens - 1; end if; when ':' => if Align_On = Tok_Colon and then Local_Num_Parens = 0 and then Buffer (J - 1) /= ''' and then not Found_Align then Found_Align := True; New_Align := Length_Ident; if Format_Operators and then not Is_Blank (Buffer (J - 1)) then New_Align := New_Align + 1; end if; Alignment := Natural'Max (Alignment, New_Align); end if; when '=' => if Align_On = Tok_Arrow and then Buffer (J + 1) = '>' and then Local_Num_Parens = 0 and then not Found_Align then Found_Align := True; New_Align := Length_Ident + 1; if Format_Operators and then not Is_Blank (Buffer (J - 1)) then -- ??? Format_Operators may add more than a single -- blank inside the expression. New_Align := New_Align + 1; end if; Alignment := Natural'Max (Alignment, New_Align); end if; when ASCII.LF => exit Main_Loop when Stop_On_Blank_Line and then Non_Blank = 0; Found_Align := False; Non_Blank := 0; when others => null; end case; J := Next_Char (J); end loop Main_Loop; return Alignment; end Compute_Alignment; -------------------------- -- Is_Continuation_Line -- -------------------------- function Is_Continuation_Line (Token : Token_Type; Prev_Token : Token_Type; Prev_Prev_Token : Token_Type) return Boolean is Top_Tok : constant Token_Type := Top (Tokens).Token; begin if Aspect_Clause then return True; end if; if Prev_Token = Tok_Is and then In_Generic then return True; end if; if Top_Tok = No_Token then return False; end if; -- Special case for variable (Tok_Colon) or type (only case when -- Tok_Is is passed to this subprogram) declarations. -- In these cases, and if the Indent_Decl preference is set to 0 -- then this is not a continuation line, e.g: -- Var -- : Integer; -- type T -- is new Integer; -- Note that we reuse Indent_Decl for now to avoid introducing -- a new preference. if (Top_Tok = Tok_Colon and then Token = Tok_Colon) or else Token = Tok_Is then return Indent_Decl /= 0; end if; return (Token not in Reserved_Token_Type and then Prev_Token not in Token_Class_No_Cont and then (Prev_Token /= Tok_Arrow or else (not Top (Tokens).In_Declaration and then Top_Tok not in Tok_Case | Tok_When | Tok_Select | Tok_Exception))) or else (Prev_Token = Tok_Is and then (Token in Tok_New | Tok_Access | Tok_Separate | Tok_Abstract or else (Top_Tok = Tok_Subtype and then Token /= Tok_Subtype))) or else Token in Tok_Array | Tok_Of or else (Token = Tok_Not and then (Prev_Token in Tok_And | Tok_Or | Tok_Then | Tok_Else)) or else (Prev_Token = Tok_With and then (Token = Tok_String_Literal or else Token = Tok_Private or else Top_Tok = Tok_Procedure or else Top_Tok = Tok_Function)) or else Prev_Token in Tok_Colon_Equal | Tok_Access | Tok_Of or else (Prev_Token = Tok_Protected and then Prev_Prev_Token = Tok_Access) or else (Prev_Token = Tok_When and then Token = Tok_Others) or else (Prev_Token = Tok_Exit and then Token = Tok_When) or else (Prev_Token = Tok_Null and then Token = Tok_Record) or else (Prev_Prev_Token = Tok_And and then Prev_Token = Tok_Then and then Num_Parens = 0) or else (Prev_Prev_Token = Tok_Or and then Prev_Token = Tok_Else and then Num_Parens = 0) or else (Token = Tok_With and then (Prev_Prev_Token = Tok_Raise or else Top_Tok = Tok_Colon)) or else (Top_Tok = Tok_Type and then (Token = Tok_Null or else Token = Tok_Tagged)) or else (Token = Tok_When and then Top_Tok = Tok_Entry); end Is_Continuation_Line; ------------------------- -- Compute_Indentation -- ------------------------- procedure Compute_Indentation (Token : Token_Type; Prev_Token : Token_Type; Prev_Prev_Token : Token_Type; Prec : Natural; Line_Count : Natural; Num_Spaces : Integer) is Top_Tok : constant Token_Type := Top (Tokens).Token; begin if Indent_Done or not Format then return; end if; if (Prev_Token = Tok_Vertical_Bar or else Prev_Token = Tok_Or) and then Top_Tok = Tok_When then -- Indent multiple-line when statements specially: -- case Foo is -- when A | -- B => -- from Indent_When Do_Indent (Prec, Line_Count, Num_Spaces - Indent_Level + Indent_When); elsif Prev_Token = Tok_Comma and then (Num_Parens = 0 or else Token /= Tok_When) then if Top_Tok = Tok_Declare or else Top_Tok = Tok_Identifier or else Top_Tok = Tok_Record or else Top_Tok = Tok_Case or else Top_Tok = Tok_When then -- Inside a declare block, indent broken lines specially -- declare -- A, -- B : Integer; -- from Indent_Decl Do_Indent (Prec, Line_Count, Num_Spaces + Indent_Decl); elsif Top_Tok = Tok_With then -- Indent continuation lines in with clauses: -- with Package1, -- Package2; -- from Indent_With Do_Indent (Prec, Line_Count, Num_Spaces + Indent_With); elsif Top_Tok = Tok_Use then -- Ditto for use clauses: -- use Package1, -- Package2; -- from Indent_Use Do_Indent (Prec, Line_Count, Num_Spaces + Indent_Use); elsif Num_Parens = 0 then if Continuation_Val > 0 then declare Tmp_Index : Natural := Prec + 1; begin Skip_Blanks (Buffer, Tmp_Index); if Look_For (Tmp_Index, "=>") then -- May happen with aspects: -- procedure G with -- Pre => F, -- Post => F; Continuation_Val := Continuation_Val - Indent_Continue; end if; end; end if; Do_Indent (Prec, Line_Count, Num_Spaces, Continuation => True); else -- Default case, simply use Num_Spaces Do_Indent (Prec, Line_Count, Num_Spaces); end if; elsif Top (Tokens).Colon_Col /= 0 and then Continuation_Val = 0 and then Num_Parens = 0 and then (Prev_Token = Tok_Colon_Equal or else Prev_Token = Tok_Renames or else Is_Operator (Prev_Token) or else Is_Operator (Token)) then Continuation_Val := Top (Tokens).Colon_Col + 4 - Indent_Continue; Do_Indent (Prec, Line_Count, Num_Spaces, Continuation => True); elsif Prev_Token = Tok_Ampersand or else Token = Tok_Ampersand then if Continuation_Val > 0 then Continuation_Val := Continuation_Val - Indent_Continue; end if; Do_Indent (Prec, Line_Count, Num_Spaces, Continuation => True); Continuation_Val := 0; elsif Is_Continuation_Line (Token, Prev_Token, Prev_Prev_Token) then Do_Indent (Prec, Line_Count, Num_Spaces, Continuation => True); if Is_Operator (Token) then Continuation_Val := 0; end if; elsif Num_Parens > 0 and then (Token in Tok_When | Tok_Vertical_Bar or else Prev_Token = Tok_Arrow or else (Prev_Token = Tok_Then and then Prev_Prev_Token /= Tok_And) or else (Prev_Token = Tok_Else and then Prev_Prev_Token /= Tok_Or)) then -- Handle a bit better Ada 2012 conditional expressions if Token in Tok_When | Tok_Vertical_Bar then Continuation_Val := Indent_Level - Indent_Continue; else Continuation_Val := Continuation_Val + Indent_Level - Indent_Continue; end if; Do_Indent (Prec, Line_Count, Num_Spaces, Continuation => True); else Do_Indent (Prec, Line_Count, Num_Spaces); end if; end Compute_Indentation; ----------------- -- End_Of_Word -- ----------------- function End_Of_Word (P : Natural) return Natural is Cur : Natural; begin if P >= Buffer_Last then return Buffer_Last; end if; Cur := Next_Char (P); while Cur <= Buffer_Last and then Is_Entity_Letter (UTF8_Get_Char (Buffer (Cur .. Buffer_Last))) loop Cur := Next_Char (Cur); end loop; if Cur > Buffer_Last then return Buffer_Last; else return Cur - 1; end if; end End_Of_Word; ----------------------- -- End_Of_Identifier -- ----------------------- function End_Of_Identifier (P : Natural) return Natural is Tmp : Natural := P; Prev : Natural := P - 1; Start : Natural; New_Lines : Natural; Last_Dot : Natural; begin -- Do not try to go past '.' and line breaks when reformatting, -- this is causing too much trouble for no gain. -- Getting full identifiers is only useful when parsing, not -- when reformatting. if Format then return P - 1; end if; loop New_Lines := 0; while Tmp < Buffer_Last and then Is_Blank (Buffer (Tmp)) loop if Buffer (Tmp) = ASCII.LF then New_Lines := New_Lines + 1; end if; Tmp := Tmp + 1; end loop; if Tmp >= Buffer_Last or else Buffer (Tmp) /= '.' or else Buffer (Tmp + 1) = '.' then return Prev; end if; Last_Dot := Tmp; while Tmp < Buffer_Last loop Tmp := Tmp + 1; if Buffer (Tmp) = ASCII.LF then Compute_Indentation (Token, Prev_Token, Prev_Prev_Token, Tmp - 1, Line_Count, Num_Spaces); New_Lines := New_Lines + 1; end if; exit when not Is_Blank (Buffer (Tmp)); end loop; if Buffer (Tmp) = '"' then -- Case of an operator, e.g System."=", will be handled -- separately for proper highlighting. return Prev; elsif not Is_Entity_Letter (UTF8_Get_Char (Buffer (Tmp .. Buffer_Last))) then return Last_Dot; else Start := Tmp; Tmp := End_Of_Word (Tmp); if Buffer (Start .. Tmp) = "all" -- constructions like sth.procedure often reflect incomplete -- statements, e.g.: -- -- use Ada. -- procedure P is -- -- retreiving these here improve the general tree balance in -- case of incomplete constructs. or else Buffer (Start .. Tmp) = "procedure" or else Buffer (Start .. Tmp) = "function" or else Buffer (Start .. Tmp) = "package" then return Prev; end if; end if; Line_Count := Line_Count + New_Lines; Prev := Tmp; Tmp := Tmp + 1; end loop; end End_Of_Identifier; -------------------------------------- -- Look_For_End_Of_Data_Declaration -- -------------------------------------- procedure Look_For_End_Of_Data_Declaration (Sloc : in out Source_Location) is C : Character; In_Comments : Boolean := False; Paren_Depth : Integer := 0; begin for J in Sloc.Index .. Buffer_Last loop C := Buffer (J); if not In_Comments and then Paren_Depth = 0 and then (C = ';' or else C = ')') then Sloc.Index := J; return; elsif C = '-' and then Buffer (J - 1) = '-' then In_Comments := True; elsif C = ASCII.LF then In_Comments := False; Sloc.Line := Sloc.Line + 1; Sloc.Column := 1; elsif C = '(' then Paren_Depth := Paren_Depth + 1; Sloc.Column := Sloc.Column + 1; elsif C = ')' then Paren_Depth := Paren_Depth - 1; Sloc.Column := Sloc.Column + 1; elsif C /= ASCII.CR then Sloc.Column := Sloc.Column + 1; end if; end loop; end Look_For_End_Of_Data_Declaration; -------------- -- Look_For -- -------------- procedure Look_For (Sloc : in out Source_Location; Char : Character) is C : Character; In_Comments : Boolean := False; begin for J in Sloc.Index .. Buffer_Last loop C := Buffer (J); if not In_Comments and then C = Char then Sloc.Index := J; return; elsif C = '-' and then Buffer (J - 1) = '-' then In_Comments := True; elsif C = ASCII.LF then In_Comments := False; Sloc.Line := Sloc.Line + 1; Sloc.Column := 1; elsif C /= ASCII.CR then Sloc.Column := Sloc.Column + 1; end if; end loop; end Look_For; function Look_For (Index : Natural; S : String) return Boolean is begin return Is_Blank (Buffer (Index - 1)) and then Index + S'Length < Buffer'Last and then To_Lower (Buffer (Index .. Index + S'Length - 1)) = S and then (Buffer (Index + S'Length) = ';' or else Buffer (Index + S'Length) = '-' or else Is_Blank (Buffer (Index + S'Length))); end Look_For; -------------- -- New_Line -- -------------- procedure New_Line (Count : in out Natural) is begin Count := Count + 1; end New_Line; --------- -- Pop -- --------- procedure Pop (Stack : in out Token_Stack.Simple_Stack; Value : out Extended_Token) is Column : Natural; Info : Construct_Access; begin -- Never pop the initial value if Top (Stack).Token = No_Token then Value := Top (Stack).all; return; end if; Token_Stack.Pop (Stack, Value); Top_Token := Token_Stack.Top (Stack); -- Tok_Record will be taken into account by Tok_Type if needed. -- Build next entry of Constructs if Value.Token = Tok_Colon and then Constructs /= null then -- If we are on a Tok_Colon, then we want to assign attibutes to -- all the data that are related to this declaration. declare Current : Construct_Access := Constructs.Current; begin while Current /= null and then Current.Category in Data_Category and then Current.Sloc_Start.Index <= Prec and then Current.Sloc_End.Index >= Prec loop Current.Attributes := Value.Attributes; Current := Current.Prev; end loop; end; elsif Value.Token /= Tok_Record and then Value.Token /= Tok_When and then Value.Token /= Tok_Generic and then Constructs /= null then Column := Prec - Line_Start (Buffer, Prec) + 1; Info := Constructs.Current; Constructs.Current := new Construct_Information; if Constructs.First = null then Constructs.First := Constructs.Current; else Constructs.Current.Prev := Info; Constructs.Current.Next := Info.Next; Info.Next := Constructs.Current; end if; Constructs.Last := Constructs.Current; Constructs.Size := Constructs.Size + 1; Constructs.Current.Visibility := Value.Visibility; Constructs.Current.Attributes := Value.Attributes; Constructs.Current.Is_Generic_Spec := Value.Is_Generic_Param; if Value.Attributes (Ada_Tagged_Attribute) then Constructs.Current.Category := Cat_Class; elsif Value.Attributes (Ada_Record_Attribute) then if Value.Token = Tok_Case then -- A case statement inside a record Constructs.Current.Category := Cat_Case_Inside_Record; else Constructs.Current.Category := Cat_Structure; end if; else case Value.Token is when Tok_Package => Constructs.Current.Category := Cat_Package; when Tok_Procedure => Constructs.Current.Category := Cat_Procedure; when Tok_Function => Constructs.Current.Category := Cat_Function; when Tok_Task => Constructs.Current.Category := Cat_Task; when Tok_Protected => Constructs.Current.Category := Cat_Protected; when Tok_Entry => Constructs.Current.Category := Cat_Entry; when Tok_Type => Constructs.Current.Category := Cat_Type; when Tok_Subtype => Constructs.Current.Category := Cat_Subtype; when Tok_For => Constructs.Current.Category := Cat_Representation_Clause; when Tok_Identifier => if Is_Library_Level (Stack) then Constructs.Current.Category := Cat_Variable; elsif Value.Variable_Kind = Parameter_Kind then Constructs.Current.Category := Cat_Parameter; elsif Value.Variable_Kind = Discriminant_Kind then Constructs.Current.Category := Cat_Discriminant; elsif Value.Is_In_Type_Definition then if Top (Stack).Type_Declaration or else Top (Stack).Protected_Declaration or else Top (Stack).Attributes (Ada_Record_Attribute) then Constructs.Current.Category := Cat_Field; else Constructs.Current.Category := Cat_Literal; end if; else Constructs.Current.Category := Cat_Local_Variable; end if; when Tok_With => Constructs.Current.Category := Cat_With; when Tok_Use => Constructs.Current.Category := Cat_Use; when Tok_Loop => Constructs.Current.Category := Cat_Loop_Statement; when Tok_Then => Constructs.Current.Category := Cat_If_Statement; when Tok_Case => Constructs.Current.Category := Cat_Case_Statement; when Tok_Select => Constructs.Current.Category := Cat_Select_Statement; when Tok_Accept | Tok_Do => Constructs.Current.Category := Cat_Accept_Statement; when Tok_Declare => Constructs.Current.Category := Cat_Declare_Block; when Tok_Begin => Constructs.Current.Category := Cat_Simple_Block; when Tok_Return => Constructs.Current.Category := Cat_Return_Block; when Tok_Exception => Constructs.Current.Category := Cat_Exception_Handler; when Tok_Pragma => Constructs.Current.Category := Cat_Pragma; when Tok_Arrow => Constructs.Current.Category := Cat_Aspect; when others => Constructs.Current.Category := Cat_Unknown; end case; end if; if Value.Ident_Len > 0 then Constructs.Current.Name := Symbols.Find (Value.Identifier (1 .. Value.Ident_Len)); Constructs.Current.Sloc_Entity := Value.Sloc_Name; end if; if Value.Profile_Start /= 0 then Constructs.Current.Profile := new String' (Buffer (Value.Profile_Start .. Value.Profile_End)); end if; Constructs.Current.Sloc_Start := Value.Sloc; if Comments_Skipped then Constructs.Current.Sloc_End := (Prev_Line, Column, Prec); else Constructs.Current.Sloc_End := (Line_Count, Column, Prec); end if; case Constructs.Current.Category is when Cat_Parameter | Cat_Discriminant => -- Adjust the Sloc_End to the next semicolon for enclosing -- entities and variable declarations, or next closing -- parenthesis Look_For_End_Of_Data_Declaration (Constructs.Current.Sloc_End); when Cat_Variable | Cat_Local_Variable | Cat_Field | Cat_Declare_Block | Cat_Simple_Block | Cat_Type | Cat_Subtype | Namespace_Category | Subprogram_Category | Cat_Pragma => -- Adjust the Sloc_End to the next semicolon for enclosing -- entities and variable declarations. In case if loops, -- adjust the end of the source location to the end of the -- identifier. if Prev_Token /= Tok_For then Look_For (Constructs.Current.Sloc_End, ';'); else Constructs.Current.Sloc_End.Column := Constructs.Current.Sloc_End.Column + Value.Ident_Len - 1; Constructs.Current.Sloc_End.Index := Constructs.Current.Sloc_End.Index + Value.Ident_Len - 1; end if; when others => null; end case; Constructs.Current.Is_Declaration := In_Declaration in Subprogram_Decl .. Subprogram_Aspect or else Value.Type_Declaration or else Value.Package_Declaration or else Value.Protected_Declaration; end if; end Pop; procedure Pop (Stack : in out Token_Stack.Simple_Stack) is Value : Extended_Token; begin Pop (Stack, Value); end Pop; -------------------------- -- Finish_Aspect_Clause -- -------------------------- procedure Finish_Aspect_Clause (P, Line : Natural; Done : out Boolean) is Prec_Saved : constant Natural := Prec; begin Aspect_Clause := False; Done := False; -- Pop aspect clause -- Set Prec so that Pop will use the proper index/column Prec := Prev_Char (P); Pop (Tokens); if Callback /= null then Start_Of_Line := Line_Start (Buffer, Prec); Done := Callback (Aspect_Text, Aspect_Clause_Sloc, (Line, Prec - Start_Of_Line + 1, Prec), False); end if; Prec := Prec_Saved; end Finish_Aspect_Clause; ----------------------- -- Handle_Word_Token -- ----------------------- procedure Handle_Word_Token (Reserved : Token_Type; Temp : out Extended_Token; Do_Pop : out Integer; Do_Push : out Boolean; Finish : out Boolean) is Top_Token : Token_Stack.Generic_Type_Access; Start_Of_Line : Natural; Index_Next : Natural; Tmp_Index : Natural; procedure Adjust_Block_Column; -- Adjust status column of declare block to take into -- account a label at start of the line by using the first -- non blank character on the line. ------------------------- -- Adjust_Block_Column -- ------------------------- procedure Adjust_Block_Column is begin if Prev_Token = Tok_Colon then Tmp_Index := Start_Of_Line; Skip_Blanks (Buffer, Tmp_Index); Temp.Sloc.Column := Tmp_Index - Start_Of_Line + 1; Temp.Sloc.Index := Tmp_Index; end if; end Adjust_Block_Column; begin Do_Push := False; Do_Pop := 0; Finish := False; if Reserved = Tok_Is and then Aspect_Clause then Finish_Aspect_Clause (Prec, Line_Count, Done => Finish); if Finish then return; end if; end if; Top_Token := Top (Tokens); Temp := (others => <>); Temp.Token := Reserved; Start_Of_Line := Line_Start (Buffer, Prec); Temp.Sloc.Line := Line_Count; Temp.Sloc.Column := Prec - Start_Of_Line + 1; Temp.Sloc.Index := Prec; Temp.Visibility := Top_Token.Visibility_Section; if Callback /= null then Finish := Call_Callback (Keyword_Text, Temp.Sloc, (Line_Count, Current - Start_Of_Line + 1, Current), False); if Finish then return; end if; end if; -- Computes Tok_Token.Type_Att if not Right_Assignment then case Reserved is when Tok_Abstract => Top_Token.Attributes (Ada_Abstract_Attribute) := True; when Tok_Access => Top_Token.Attributes (Ada_Access_Attribute) := True; when Tok_Aliased => Top_Token.Attributes (Ada_Aliased_Attribute) := True; when Tok_Array => Top_Token.Attributes (Ada_Array_Attribute) := True; when Tok_Colon_Equal => Top_Token.Attributes (Ada_Assign_Attribute) := True; when Tok_Constant => Top_Token.Attributes (Ada_Constant_Attribute) := True; when Tok_Delta => Top_Token.Attributes (Ada_Delta_Attribute) := True; when Tok_Digits => Top_Token.Attributes (Ada_Digits_Attribute) := True; when Tok_Range => Top_Token.Attributes (Ada_Range_Attribute) := True; when Tok_Mod => Top_Token.Attributes (Ada_Mod_Attribute) := True; when Tok_New => Top_Token.Attributes (Ada_New_Attribute) := True; when Tok_Not => Top_Token.Attributes (Ada_Not_Attribute) := True; when Tok_Null => Top_Token.Attributes (Ada_Null_Attribute) := True; when Tok_Out => Top_Token.Attributes (Ada_Out_Attribute) := True; when Tok_Tagged => Top_Token.Attributes (Ada_Tagged_Attribute) := True; when Tok_In => Top_Token.Attributes (Ada_In_Attribute) := True; when Tok_Interface => Top_Token.Attributes (Ada_Interface_Attribute) := True; when Tok_Record => if Prev_Token /= Tok_Null or else Prev_Prev_Token = Tok_Is then -- Do not take aggregates like (null record) as a record -- definition but we still want "is null record" to be -- properly reported as record type. Top_Token.Attributes (Ada_Record_Attribute) := True; end if; when Tok_Renames => Top_Token.Attributes (Ada_Renames_Attribute) := True; when others => null; end case; end if; -- Computes the end of the profile case Top_Token.Token is when Tok_Procedure | Tok_Function | Tok_Entry => if Reserved = Tok_Is then Top_Token.In_Entity_Profile := False; end if; when Tok_Type => if Reserved = Tok_Record then Top_Token.In_Entity_Profile := False; -- type N is new O with record ... -- type N is new O with null record ... if Prev_Token = Tok_With or (Prev_Prev_Token = Tok_With and Prev_Token = Tok_Null) then Top_Token.Attributes (Ada_Tagged_Attribute) := True; end if; -- type N is new O with private; elsif Prev_Token = Tok_With and Reserved = Tok_Private then Top_Token.Attributes (Ada_Tagged_Attribute) := True; end if; when others => null; end case; -- Note: the order of the following conditions is important if Reserved = Tok_Body then if Top_Token.Token = Tok_Package then Top_Token.Package_Declaration := False; elsif Top_Token.Token = Tok_Protected then Top_Token.Protected_Declaration := False; end if; elsif Prev_Token /= Tok_End and then Reserved = Tok_Case and then Num_Parens = 0 then Temp.Visibility_Section := Top_Token.Visibility_Section; -- If the case is in a type declaration (e.g. protected), then -- mark itself as a type declaration so we will extract the -- corresponding fields. if Top_Token.Type_Declaration then Temp.Type_Declaration := True; end if; -- If the case is in a record, then mark itself as a record so we -- will extract the corresponding fields. if Top_Token.Attributes (Ada_Record_Attribute) then Temp.Attributes (Ada_Record_Attribute) := True; end if; Do_Push := True; elsif Prev_Token /= Tok_End and then ((Reserved = Tok_If and then Num_Parens = 0) or else Reserved = Tok_For or else Reserved = Tok_While or else Reserved = Tok_Accept) then Do_Push := True; elsif Reserved = Tok_Renames then if not Top_Token.In_Declaration and then (Top_Token.Token = Tok_Function or else Top_Token.Token = Tok_Procedure or else Top_Token.Token = Tok_Package) then -- Terminate current subprogram declaration, e.g: -- procedure ... renames ...; Do_Pop := Do_Pop + 1; end if; elsif Prev_Token = Tok_Is and then Top_Token.Token /= Tok_Type and then (Top_Token.Token not in Tok_Task | Tok_Protected or else Reserved = Tok_Separate) and then Top_Token.Token /= Tok_Subtype and then (Reserved = Tok_New or else Reserved = Tok_In or else Reserved = Tok_Abstract or else Reserved = Tok_Separate or else (Reserved = Tok_Null and then not In_Generic and then Top_Token.Token = Tok_Procedure)) then In_Declaration := Subprogram_Decl; elsif Reserved = Tok_Pragma then Num_Parens := 0; Do_Push := True; elsif Reserved = Tok_Function or else Reserved = Tok_Procedure or else Reserved = Tok_Package or else Reserved = Tok_Task or else Reserved = Tok_Protected or else Reserved = Tok_Entry then if not In_Generic and then (Top_Token.Token = Tok_With or else Top_Token.Token = Tok_Use) then -- In this case, we're probably parsing code in the process -- of being written, and the use or with clause is not finished -- yet. Close the construct anyway, so that the tree stays -- correctly balanced. Do_Pop := Do_Pop + 1; end if; if Reserved = Tok_Package then Temp.Package_Declaration := True; elsif Reserved = Tok_Protected then Temp.Protected_Declaration := True; elsif (Top_Token.Token = Tok_Type and then (Prev_Token /= Tok_Access or else Prev_Prev_Token = Tok_Is)) or else (Prev_Token /= Tok_Access and then Prev_Token /= Tok_Protected and then Prev_Token /= Tok_Constant) then -- take into account the following: -- type P is access procedure; -- -- and ignore the following cases: -- type P is array () of access procedure; -- procedure P (X : access procedure); In_Declaration := Subprogram_Decl; Num_Parens := 0; end if; if Prev_Token = Tok_Overriding or else (Token = Tok_Package and then Prev_Token = Tok_Private) or else (Token in Tok_Procedure | Tok_Function and then Prev_Token = Tok_With) then -- Adjust column of subprogram to take into account possible -- [not] overriding at start of the line by using the -- first non blank character on the line. -- Ditto for "private package xxx is" and "with procedure xx" Tmp_Index := Start_Of_Line; Skip_Blanks (Buffer, Tmp_Index); Temp.Sloc.Column := Tmp_Index - Start_Of_Line + 1; Temp.Sloc.Index := Tmp_Index; end if; if Prev_Token = Tok_Access or else Prev_Token = Tok_Protected then -- Ada 2005 anonymous access subprogram parameter: -- procedure P (F : access [protected] procedure); null; elsif Top_Token.Token = Tok_Type then null; else if not Top_Token.In_Declaration and then (Top_Token.Token = Tok_Function or else Top_Token.Token = Tok_Procedure) then -- There was a function declaration, e.g: -- -- procedure xxx (); -- procedure ... Do_Pop := Do_Pop + 1; end if; if Top_Token.Token = Tok_Generic and then Prev_Token /= Tok_With then -- Pops the temporary generic token and replace it by -- the actual subprogram or package Temp.Sloc := Top_Token.Sloc; Temp.Attributes (Ada_Generic_Attribute) := True; Do_Pop := Do_Pop + 1; end if; Do_Push := True; end if; elsif Reserved = Tok_End or else (Reserved = Tok_Elsif and then Num_Parens = 0) or else (Reserved = Tok_Null and then Prev_Token = Tok_Is and then not In_Generic and then Top_Token.Token = Tok_Procedure) then -- unindent after end of elsif, e.g: -- -- if xxx then -- xxx -- elsif xxx then -- xxx -- end if; if Reserved = Tok_End then case Top_Token.Token is when Tok_When | Tok_Exception => -- End of subprogram Do_Pop := Do_Pop + 1; when others => null; end case; Do_Pop := Do_Pop + 1; elsif Top_Token.Token = Tok_Then and then Reserved = Tok_Elsif then Top_Token.Token := Tok_If; end if; elsif Reserved = Tok_With then if not In_Generic then if Top_Token.Token = Tok_With or else Top_Token.Token = Tok_Use then -- Incomplete clause, pops to preserve tree balance Do_Pop := Do_Pop + 1; end if; if Top_Token.Token = No_Token then Do_Push := True; end if; end if; if Prev_Prev_Token not in Tok_Raise | Tok_Left_Paren -- Exclude Tok_Raise: raise CE with "string"; -- Ditto for Tok_Left_Paren: X := (Parent with Field => null); and then ((Top_Token.Token in Tok_Type | Tok_Subtype | Tok_Function | Tok_Procedure | Tok_Colon and then Num_Parens = 0) or else (Top_Token.Token in Tok_Task | Tok_Protected and then (Prev_Prev_Token in Tok_Protected | Tok_Task | Tok_Type or else Prev_Token = Tok_Right_Paren)) or else (Top_Token.Token = No_Token and then Prev_Token not in Tok_Semicolon | Tok_Limited | Tok_Private | No_Token)) then -- Recognize aspect clauses, even in the case of a partial -- buffer. But do not confuse with a 'with' clause. Tmp_Index := Current + 1; Skip_Blanks (Buffer, Tmp_Index); if not Look_For (Tmp_Index, "record") and then not Look_For (Tmp_Index, "null") and then not Look_For (Tmp_Index, "private") then Aspect_Clause := True; Aspect_Clause_Sloc := (Line_Count, Current + 1 - Start_Of_Line + 1, Current + 1); Do_Push := True; Temp.Token := Tok_Arrow; -- Arrow is used for aspects Temp.Sloc := Aspect_Clause_Sloc; end if; end if; elsif Reserved = Tok_Use and then (Top_Token.Token = No_Token or else (Top_Token.Token /= Tok_For and then Top_Token.Token /= Tok_Record)) then if Top_Token.Token = Tok_With or else Top_Token.Token = Tok_Use then -- Incomplete clause, pops to preserve tree balance Do_Pop := Do_Pop + 1; end if; Do_Push := True; elsif Reserved = Tok_Is or else Reserved = Tok_Declare or else Reserved = Tok_Begin or else Reserved = Tok_Do or else (Prev_Token /= Tok_Or and then Reserved = Tok_Else and then Num_Parens = 0) or else (Prev_Token /= Tok_And and then Reserved = Tok_Then and then Num_Parens = 0) or else (Prev_Token /= Tok_End and then Reserved = Tok_Select) or else (Reserved = Tok_Or and then (Top_Token.Token = Tok_Select or else Top_Token.Token = Tok_When)) or else (Prev_Token /= Tok_End and then Reserved = Tok_Loop) or else (Prev_Token /= Tok_End and then Prev_Token /= Tok_Null and then Reserved = Tok_Record) or else ((Top_Token.Token = Tok_Exception or else Top_Token.Token = Tok_Case or else Top_Token.Token = Tok_Select) and then Reserved = Tok_When and then Prev_Token /= Tok_Exit and then Prev_Prev_Token /= Tok_Exit) or else (Top_Token.In_Declaration and then Reserved = Tok_Private and then (Prev_Token /= Tok_Is or else Top_Token.Token = Tok_Package) and then Prev_Token /= Tok_Limited and then Prev_Token /= Tok_With) then if Reserved = Tok_Do then if Top_Token.Token = Tok_Accept then Top_Token.Token := Tok_Do; else -- Extended return statement: -- return X : xxx do -- ... -- end; Temp.Token := Tok_Return; Do_Push := True; end if; end if; if Reserved = Tok_Select then Do_Push := True; elsif Top_Token.Token = Tok_If and then Reserved = Tok_Then then -- Notify that we're past the 'if' condition Top_Token.Token := Tok_Then; elsif Reserved = Tok_Loop then if Top_Token.Token = Tok_While or else Top_Token.Token = Tok_For then -- Replace token since this is a loop construct -- but keep the original source location. Top_Token.Token := Tok_Loop; else Do_Push := True; end if; elsif Reserved = Tok_Declare then if Align_On_Colons then Temp.Align_Colon := Compute_Alignment (Prec, Stop_On_Blank_Line => Stop_On_Blank_Line); end if; Temp.In_Declaration := True; Adjust_Block_Column; Do_Push := True; elsif Reserved = Tok_Is then case Top_Token.Token is when Tok_Case | Tok_When | Tok_Type | Tok_Subtype => Top_Token.Type_Definition_Section := True; when Tok_Task | Tok_Protected => if Top_Token.Token = Tok_Protected then Top_Token.Type_Definition_Section := True; end if; if Align_On_Colons then Top_Token.Align_Colon := Compute_Alignment (Prec, Stop_On_Blank_Line => Stop_On_Blank_Line); end if; Top_Token.In_Declaration := True; when others => if Top_Token.Token = Tok_Function then Index_Next := Current + 1; -- Skip blanks on current line while Index_Next < Buffer'Last and then Buffer (Index_Next) /= ASCII.LF and then (Buffer (Index_Next) = ' ' or else Buffer (Index_Next) = ASCII.HT) loop Index_Next := Index_Next + 1; end loop; end if; if Align_On_Colons then Top_Token.Align_Colon := Compute_Alignment (Prec, Stop_On_Blank_Line => Stop_On_Blank_Line); end if; Top_Token.In_Declaration := True; end case; elsif Reserved = Tok_Begin then if Top_Token.In_Declaration then Num_Spaces := Num_Spaces - Indent_Level; Top_Token.Align_Colon := 0; Top_Token.In_Declaration := False; else Adjust_Block_Column; Do_Push := True; end if; elsif Reserved = Tok_Record then -- Is "record" the first keyword on the line ? -- If True, we are in a case like: -- type A is -- record -- from Indent_Record -- null; -- end record; if Top_Token.Token = Tok_Type then Top_Token.Attributes (Ada_Record_Attribute) := True; Temp.Attributes (Ada_Record_Attribute) := True; Temp.Type_Definition_Section := Top_Token.Type_Definition_Section; end if; Do_Push := True; elsif Reserved = Tok_Else or else (Top_Token.Token = Tok_Select and then Reserved = Tok_Then) or else (Reserved = Tok_When and then Num_Parens = 0) or else Reserved = Tok_Or or else Reserved = Tok_Private then if (Reserved = Tok_Or or else Reserved = Tok_Else) and then Top_Token.Token = Tok_When then Do_Pop := Do_Pop + 1; Top_Token := Top (Tokens); end if; if Reserved = Tok_Private then Top_Token.Visibility_Section := Visibility_Private; end if; if Reserved = Tok_When then Do_Push := True; end if; end if; elsif (Reserved = Tok_Type and then Prev_Token /= Tok_With -- with type and then Prev_Token /= Tok_Use -- use type and then (Prev_Prev_Token /= Tok_Use or Prev_Token /= Tok_All)) -- use all type or else Reserved = Tok_Subtype then -- Entering a type declaration/definition if Prev_Token = Tok_Task -- task type or else Prev_Token = Tok_Protected -- protected type then Top_Token.Type_Declaration := True; else Do_Push := True; end if; In_Declaration := Type_Decl; elsif Reserved = Tok_Exception then if Top_Token.Token /= Tok_Colon then Do_Push := True; end if; elsif Reserved = Tok_Generic then Temp.In_Declaration := True; Do_Push := True; end if; exception when Token_Stack.Stack_Empty => Syntax_Error := True; end Handle_Word_Token; ------------------------ -- Handle_Word_Indent -- ------------------------ procedure Handle_Word_Indent (Reserved : Token_Type; Temp : in out Extended_Token) is Top_Token : Token_Stack.Generic_Type_Access := Top (Tokens); Start_Of_Line : Natural; Index_Next : Natural; Tmp_Index : Natural; begin Top_Token := Top (Tokens); Start_Of_Line := Line_Start (Buffer, Prec); -- Note: the order of the following conditions is important if Prev_Token /= Tok_End and then Reserved = Tok_Case then if Align_On_Colons and then Top_Token.Token = Tok_Record then Temp.Align_Colon := Compute_Alignment (Prec, Stop_On_Blank_Line => Stop_On_Blank_Line); end if; Do_Indent (Prec, Line_Count, Num_Spaces); if Prev_Token /= Tok_Left_Paren and then Indent_Case_Extra = RM_Style then Temp.Extra_Indent := True; Num_Spaces := Num_Spaces + Indent_Level; end if; elsif Reserved = Tok_Abort then if Top_Token.Token = Tok_Select and then Prev_Token = Tok_Then then -- Temporarily unindent if we have a 'then abort' construct, -- with 'abort' on its own line, e.g: -- select -- Foo; -- then -- abort -- Bar; Do_Indent (Prec, Line_Count, Num_Spaces - Indent_Level, Continuation => True); end if; elsif Reserved = Tok_Renames then if In_Declaration = Subprogram_Decl then -- function A (....) -- renames B; Indent_Function_Return (Prec); end if; elsif Prev_Token = Tok_Is and then not In_Generic and then Top_Token.Token /= Tok_Type and then (Top_Token.Token not in Tok_Task | Tok_Protected or else Reserved = Tok_Separate) and then Top_Token.Token /= Tok_Subtype and then (Reserved = Tok_New or else Reserved = Tok_In or else Reserved = Tok_Abstract or else Reserved = Tok_Separate or else (Reserved = Tok_Null and then not In_Generic and then Top_Token.Token = Tok_Procedure)) then -- Handle indentation of e.g. -- -- function Abstract_Func -- return String -- is abstract; if Top_Token.Token = Tok_Function and then Reserved /= Tok_New and then (Reserved = Tok_Abstract or else Reserved = Tok_Separate or else Start_Of_Line /= Line_Start (Buffer, Top_Token.Sloc.Index)) then Indent_Function_Return (Prec); Num_Spaces := Num_Spaces + Indent_Level; end if; -- Unindent since this is a declaration, e.g: -- package ... is new ...; -- function ... is abstract; -- function ... is separate; -- procedure ... is null; -- Or a Gnatdist main procedure declaration : -- procedure ... is in ...; Num_Spaces := Num_Spaces - Indent_Level; if Num_Spaces < 0 then Num_Spaces := 0; Syntax_Error := True; end if; elsif (Reserved in Tok_Function | Tok_Procedure | Tok_Protected and then Top_Token.Token /= Tok_Type) or else (Reserved in Tok_Package | Tok_Task | Tok_Entry and then Prev_Token /= Tok_Is) then if In_Generic and then Prev_Token not in Tok_With | Tok_Access then -- unindent after a generic declaration, e.g: -- -- generic -- with procedure xxx; -- with function xxx; -- with package xxx; -- package xxx is Num_Spaces := Num_Spaces - Indent_Level; if Num_Spaces < 0 then Num_Spaces := 0; Syntax_Error := True; end if; end if; elsif Reserved = Tok_Return and then In_Declaration = Subprogram_Decl then Indent_Function_Return (Prec); elsif Reserved = Tok_End or else (Reserved = Tok_Elsif and then Num_Parens = 0) or else (Reserved = Tok_Null and then not In_Generic and then Prev_Token = Tok_Is and then Top_Token.Token = Tok_Procedure) then -- unindent after end of elsif, e.g: -- -- if xxx then -- xxx -- elsif xxx then -- xxx -- end if; if Reserved = Tok_End then case Top_Token.Token is when Tok_When | Tok_Exception => -- Undo additional level of indentation, as in: -- ... -- exception -- when others => -- null; -- end; Num_Spaces := Num_Spaces - Indent_Level; when Tok_Case => if Top_Token.Extra_Indent then Num_Spaces := Num_Spaces - Indent_Level; end if; when Tok_Record => -- If the "record" keyword was on its own line if Top_Token.Extra_Indent then Do_Indent (Prec, Line_Count, Num_Spaces - Indent_Level); Num_Spaces := Num_Spaces - Indent_Record; end if; when others => null; end case; end if; Num_Spaces := Num_Spaces - Indent_Level; if Num_Spaces < 0 then Num_Spaces := 0; Syntax_Error := True; end if; elsif (Reserved = Tok_Is and then Num_Parens = 0 and then not In_Generic) or else Reserved in Tok_Declare | Tok_Begin | Tok_Do or else (Prev_Token /= Tok_Or and then Reserved = Tok_Else and then Num_Parens = 0) or else (Prev_Token /= Tok_And and then Reserved = Tok_Then and then Num_Parens = 0) or else (Prev_Token /= Tok_End and then Reserved = Tok_Select) or else (Reserved = Tok_Or and then (Top_Token.Token = Tok_Select or else Top_Token.Token = Tok_When)) or else (Prev_Token /= Tok_End and then Reserved = Tok_Loop) or else (Prev_Token /= Tok_End and then Prev_Token /= Tok_Null and then Reserved = Tok_Record) or else ((Top_Token.Token = Tok_Exception or else Top_Token.Token = Tok_Case or else Top_Token.Token = Tok_Select) and then Reserved = Tok_When and then Prev_Token /= Tok_Exit and then Prev_Prev_Token /= Tok_Exit) or else (Top_Token.In_Declaration and then Reserved = Tok_Private and then (Prev_Token /= Tok_Is or else Top_Token.Token = Tok_Package) and then Prev_Token /= Tok_Limited and then Prev_Token /= Tok_With) then -- unindent for this reserved word, and then indent again, e.g: -- -- procedure xxx is -- ... -- begin <-- -- ... if Reserved = Tok_Declare then if Align_On_Colons then Temp.Align_Colon := Compute_Alignment (Prec, Stop_On_Blank_Line => Stop_On_Blank_Line); end if; if Prev_Token = Tok_Colon then -- Adjust status column of declare block to take into -- account a label at start of the line by using the first -- non blank character on the line. Tmp_Index := Start_Of_Line; Skip_Blanks (Buffer, Tmp_Index); Temp.Sloc.Column := Tmp_Index - Start_Of_Line + 1; Temp.Sloc.Index := Tmp_Index; end if; elsif Reserved = Tok_Is then if not In_Generic then case Top_Token.Token is when Tok_Case | Tok_When | Tok_Type | Tok_Subtype => null; when Tok_Task | Tok_Protected => if Align_On_Colons then Top_Token.Align_Colon := Compute_Alignment (Prec, Stop_On_Blank_Line => Stop_On_Blank_Line); end if; when others => if Top_Token.Token = Tok_Function then Index_Next := Current + 1; -- Skip blanks on current line while Index_Next < Buffer'Last and then Buffer (Index_Next) /= ASCII.LF and then (Buffer (Index_Next) = ' ' or else Buffer (Index_Next) = ASCII.HT) loop Index_Next := Index_Next + 1; end loop; end if; if Align_On_Colons then Top_Token.Align_Colon := Compute_Alignment (Prec, Stop_On_Blank_Line => Stop_On_Blank_Line); end if; end case; end if; elsif Reserved = Tok_Begin then if Top_Token.In_Declaration then Num_Spaces := Num_Spaces - Indent_Level; Top_Token.Align_Colon := 0; Top_Token.In_Declaration := False; end if; elsif Reserved = Tok_Record then -- Is "record" the first keyword on the line ? -- If True, we are in a case like: -- type A is -- record -- from Indent_Record -- null; -- end record; if not Indent_Done then Temp.Extra_Indent := True; Num_Spaces := Num_Spaces + Indent_Record; Do_Indent (Prec, Line_Count, Num_Spaces); end if; if Top_Token.Token = Tok_Type then Num_Spaces := Num_Spaces + Indent_Level; if Align_On_Colons then Temp.Align_Colon := Compute_Alignment (Prec, Stop_On_Blank_Line => Stop_On_Blank_Line); end if; end if; elsif Reserved = Tok_Else or else (Top_Token.Token = Tok_Select and then Reserved = Tok_Then) or else (Reserved = Tok_When and then Num_Parens = 0) or else Reserved = Tok_Or or else Reserved = Tok_Private then if (Reserved = Tok_Or or else Reserved = Tok_Else) and then Top_Token.Token = Tok_When and then (Next (Tokens) = null or else Next (Tokens).Token /= Tok_Case) then Num_Spaces := Num_Spaces - Indent_Level; end if; if Reserved /= Tok_When or else Top_Token.Token /= Tok_Select then Num_Spaces := Num_Spaces - Indent_Level; end if; if Reserved = Tok_When then if Top_Token.Token = Tok_Case then if Indent_Case_Extra = Automatic and then not Top_Token.Extra_Indent and then Prec - Start_Of_Line > Num_Spaces then Top_Token.Extra_Indent := True; Num_Spaces := Num_Spaces + Indent_Level; end if; end if; end if; end if; if Num_Spaces < 0 then Num_Spaces := 0; Syntax_Error := True; end if; if Top_Token.Token /= Tok_Type and then Top_Token.Token /= Tok_Subtype and then (Token /= Tok_Is or else In_Generic or else Top_Token.Token /= Tok_Function or else not (Look_For (Index_Next, "abstract") or else Look_For (Index_Next, "separate"))) -- 'is abstract|separate' will be indented when handling -- 'abstract|separate' for functions then Do_Indent (Prec, Line_Count, Num_Spaces); Num_Spaces := Num_Spaces + Indent_Level; end if; elsif Reserved = Tok_Or or else Reserved = Tok_And or else Reserved = Tok_Xor then -- "and then", "or else", "and", "or" and "xor" should get an -- extra indentation on line start, e.g: -- if ... -- and then ... if Top (Indents).Level = None then if Continuation_Val > 0 then if Top (Tokens).Colon_Col = 0 then Continuation_Val := Continuation_Val - Indent_Continue; else Continuation_Val := Continuation_Val + Indent_Continue; end if; end if; Do_Indent (Prec, Line_Count, Num_Spaces, Continuation => True); else Do_Indent (Prec, Line_Count, Num_Spaces); end if; elsif Reserved = Tok_Generic then -- Indent before a generic entity, e.g: -- -- generic -- type ...; Do_Indent (Prec, Line_Count, Num_Spaces); Num_Spaces := Num_Spaces + Indent_Level; elsif Reserved = Tok_Exception then if Top_Token.Token /= Tok_Colon then Num_Spaces := Num_Spaces - Indent_Level; Do_Indent (Prec, Line_Count, Num_Spaces); Num_Spaces := Num_Spaces + 2 * Indent_Level; end if; end if; exception when Token_Stack.Stack_Empty => Syntax_Error := True; end Handle_Word_Indent; --------------- -- Next_Word -- --------------- procedure Next_Word (P : in out Natural; L : in out Natural; Terminated : out Boolean; End_Reached : out Boolean) is Comma : String := ", "; Spaces : String := " "; End_Of_Line : Natural; Start_Of_Line : Natural; Long : Natural; First : Natural; Last : Natural; Offs : Natural; Align : Natural; Adjust : Natural; Insert_Spaces : Boolean; Char : Character; Prev_Prev_Token : Token_Type := No_Token; Prev3_Token : Token_Type; Local_Top_Token : Token_Stack.Generic_Type_Access; Tmp : Boolean; Token_Found : Boolean; Recompute_Align : Boolean; procedure Close_Parenthesis; -- Current buffer contents is a closed parenthesis, -- reset stacks and states accordingly. procedure Handle_Arrow; -- Current buffer contents is an arrow colon, handle it. -- In particular, align arrows in statements. procedure Handle_Colon; -- Current buffer contents is a colon, handle it. -- In particular, align colons in declarations. procedure Handle_Two_Chars (Second_Char : Character); -- Handle a two char operator, whose second char is Second_Char procedure Preprocessor_Directive; -- Handle preprocessor directive. -- Assume that Buffer (P) = '#' procedure Skip_Blank_Lines; -- Skip empty lines procedure Skip_Comments; -- Skip comment & blank lines procedure Pop_And_Set_Local (Stack : in out Token_Stack.Simple_Stack); -- Pops the last element of the stack and set Local_Top_Token -- to the top element, null if the stack is empty. ----------------------- -- Close_Parenthesis -- ----------------------- procedure Close_Parenthesis is begin if not Is_Empty (Paren_Stack) then Pop (Paren_Stack); end if; if Is_Empty (Indents) or else Top (Indents).Level = None then -- Syntax error null; else if not Indent_Done then -- Adjust indentation level for closing parenthesis at the -- beginning of a line, e.g: -- -- (x, -- y -- ); <- Top (Indents).Level := Top (Indents).Level - 1; Do_Indent (P, L, Num_Spaces); Continuation_Val := Top (Indents).Continuation_Val; end if; Num_Parens := Num_Parens - 1; Pop (Indents); Local_Top_Token := Top (Tokens); if Num_Parens = 0 then Is_Parameter := False; Is_Discriminant := False; Right_Assignment := False; Paren_In_Middle := False; if Local_Top_Token.Token in Token_Class_Declk and then Local_Top_Token.Profile_End = 0 and then In_Declaration = Subprogram_Decl then Local_Top_Token.Profile_End := P; Local_Top_Token.Align_Colon := 0; end if; end if; end if; end Close_Parenthesis; ------------------ -- Handle_Colon -- ------------------ procedure Handle_Colon is Align_Colon : Natural := 0; Non_Blank : Natural; Offset_Align : Natural; First_Paren : Natural; Colon_Token : Token_Stack.Generic_Type_Access; Char : Character; begin Prev_Token := Tok_Colon; Non_Blank := Start_Of_Line; Is_Parameter := False; Is_Discriminant := False; if Format then Skip_Blanks (Buffer, Non_Blank); end if; if Local_Top_Token.In_Declaration and then Local_Top_Token.Token = Tok_Identifier then Pop_And_Set_Local (Tokens); declare Val : Extended_Token; begin -- Create a dummy token to separate variables -- declaration from their type. Val.Token := Tok_Colon; case In_Declaration is when Subprogram_Decl => Val.Variable_Kind := Parameter_Kind; when Type_Decl => Val.Variable_Kind := Discriminant_Kind; when others => null; end case; if Align_Decl_On_Colon then Val.Colon_Col := P - Non_Blank; end if; Push (Tokens, Val); Colon_Token := Top (Tokens); end; end if; if P > Buffer'First and then P < Buffer'Last and then Buffer (Prev_Char (P)) in '0' .. '9' then Char := Buffer (Next_Char (P)); if Char in '0' .. '9' or else Char = ';' then -- Special case 16:12: obsolete format (equivalent to -- 16#12#), e.g: -- X : Integer := 16:12:; Insert_Spaces := False; end if; end if; -- Auto align colons in declarations (parameters, variables, ...) if Local_Top_Token.Align_Colon = 0 or else Num_Parens > 1 then return; end if; Align_Colon := Local_Top_Token.Align_Colon; if Format_Operators then if Buffer (Next_Char (P)) = ' ' or else Last - 1 = End_Of_Line then Long := 2; else Long := 3; end if; if Buffer (Prev_Char (P)) = ' ' then Offs := 2; Long := Long - 1; else Align_Colon := Align_Colon - 1; end if; else Offs := 2; Long := 1; end if; if Num_Parens /= 0 then -- Handle properly alignment of first parameter in the -- following case: -- -- procedure F (X : Integer; <-- -- Foo : Integer); First_Paren := Non_Blank; while First_Paren < P and then Buffer (First_Paren) /= '(' loop First_Paren := First_Paren + 1; end loop; if Buffer (First_Paren) = '(' then Align_Colon := Align_Colon + First_Paren - Non_Blank + 1; end if; end if; -- In case Align_Colon is too small, avoid truncating non blank -- characters by never using a negative offset. Offset_Align := Integer'Max (0, Align_Colon - (P - Non_Blank + 1)); if Align_Decl_On_Colon and then Colon_Token /= null then Colon_Token.Colon_Col := Colon_Token.Colon_Col + Offset_Align; end if; Replace_Text (First, Last, L, (1 .. Offset_Align => ' ') & Spaces (Offs .. Offs + Long - 1)); Insert_Spaces := False; end Handle_Colon; ------------------ -- Handle_Arrow -- ------------------ procedure Handle_Arrow is Align_Arrow : Natural := Top (Indents).Align_Arrow; Non_Blank : Natural; Offset_Align : Natural; J : Natural; First_Paren : Natural; Next_Tok : Token_Stack.Generic_Type_Access; begin if Num_Parens > 0 and then Analyze_Ada_Source.Prev_Prev_Token in Tok_When | Tok_Dot_Dot then -- Handle case expression: -- (case X is -- when 1 -- => Compute_Indentation (Tok_Arrow, Prev_Token, Prev_Prev_Token, P, L, Num_Spaces); else Do_Indent (P, L, Num_Spaces); end if; Prev_Token := Tok_Arrow; Next_Tok := Next (Tokens); if (Local_Top_Token.Token = Tok_When and then (Next_Tok = null or else Next_Tok.Token /= Tok_Select)) or else Local_Top_Token.Token = Tok_For then Pop_And_Set_Local (Tokens); end if; Handle_Two_Chars ('>'); if Align_Arrow = 0 then return; end if; if not Is_Blank (Buffer (P - 2)) then Align_Arrow := Align_Arrow - 1; end if; Non_Blank := Start_Of_Line; Skip_Blanks (Buffer, Non_Blank); -- Handle properly alignment of first parameter in the -- following case: -- -- Foo (X => 1, <-- -- Foo => 2); First_Paren := 0; J := Non_Blank; while J < P - 1 loop if Buffer (J) = '(' and then (Buffer (J - 1) /= ''' or else Buffer (J + 1) /= ''') and then First_Paren = 0 then First_Paren := J; end if; if Buffer (J) = ')' and then (Buffer (J - 1) /= ''' or else Buffer (J + 1) /= ''') then First_Paren := 0; end if; J := J + 1; end loop; if First_Paren /= 0 and then Buffer (First_Paren) = '(' then Align_Arrow := Align_Arrow + First_Paren - Non_Blank + 1; end if; -- In case Align_Arrow is too small, avoid truncating non blank -- characters by never using a negative offset. Offset_Align := Integer'Max (0, Align_Arrow - (P - Non_Blank + 1)); Replace_Text (First, Last, L, (1 .. Offset_Align => ' ') & Spaces (Offs .. Offs + Long - 1)); Insert_Spaces := False; end Handle_Arrow; ---------------------- -- Handle_Two_Chars -- ---------------------- procedure Handle_Two_Chars (Second_Char : Character) is Prev_Tmp : constant Integer := Prev_Char (P); begin Last := P + 2; if Prev_Tmp < Buffer'First or else Is_Blank (Buffer (Prev_Tmp)) then Offs := 2; Long := 2; else Long := 3; end if; P := Next_Char (P); if P < Buffer_Last and then not Is_Blank (Buffer (Next_Char (P))) then Long := Long + 1; end if; Spaces (3) := Second_Char; end Handle_Two_Chars; ---------------------- -- Skip_Blank_Lines -- ---------------------- procedure Skip_Blank_Lines is begin if P > Buffer_Last or else (Buffer (P) /= ASCII.LF and then Buffer (P) /= ASCII.CR) then return; end if; while P < Buffer_Last and then (Buffer (P) = ASCII.LF or else Buffer (P) = ASCII.CR) loop if Buffer (P) = ASCII.LF then New_Line (L); Indent_Done := False; end if; P := Next_Char (P); end loop; if P < Buffer_Last then Start_Of_Line := P; End_Of_Line := Line_End (Buffer, Start_Of_Line); end if; end Skip_Blank_Lines; ------------------- -- Skip_Comments -- ------------------- procedure Skip_Comments is Prev_Start_Line : Natural; Last : Natural; Ref_Indent : Natural; Success : Boolean; Entity : Language_Entity; First_Indent : Boolean := True; begin Ref_Indent := Integer'Max (Num_Spaces, 0); if not Indent_Done and then Stick_Comments and then (Prev_Token = Tok_Is or else Prev_Token = Tok_Record) and then Start_Of_Line > Buffer'First + 2 and then Buffer (Start_Of_Line - 2) /= ASCII.LF then Ref_Indent := Integer'Max (Ref_Indent - Indent_Level, 0); end if; while P < Buffer_Last and then Buffer (P) = '-' and then Buffer (P + 1) = '-' loop Prev_Start_Line := Start_Of_Line; Prev_Line := L; First := P; Comments_Skipped := True; -- If we do not indent here, then automatic indentation -- won't work for comments right after 'is' and 'begin', -- e.g: -- procedure Foo is -- begin -- -- comment if Indent_Comments then if First_Indent and then not Indent_Done and then ((Prev_Token in Reserved_Token_Type and then Prev_Token not in Token_Class_No_Cont) or else (Prev_Token = Tok_Right_Paren and then Top (Tokens).Token /= No_Token) or else (Num_Parens > 0 and then Continuation_Val /= 0)) then -- Add simple handling of comment and continuation lines if Num_Parens > 0 then Continuation_Val := Continuation_Val - Indent_Continue; end if; Do_Indent (P, L, Ref_Indent, Continuation => True); Ref_Indent := Integer'Max (Ref_Indent + Continuation_Val, 0); Continuation_Val := 0; else Do_Indent (P, L, Ref_Indent); end if; First_Indent := False; end if; -- Keep track of the indentation of the first comment line, -- in case we're doing incremental reformatting: in this case, -- we want to follow the indentation (possibly manual) of this -- first line. if Ref_Indent = Num_Spaces and then To /= 0 and then L not in From .. To then Ref_Indent := Integer'Max (P - Start_Of_Line - Indent_Offset, 0); end if; Next_Line (Buffer, P + 1, P, Success); Last := P; if Success then New_Line (L); Last := Prev_Char (Last); Indent_Done := False; end if; loop -- Skip blank lines -- ??? need to handle ASCII.CR as well, although we now -- only use LF separators internally in GPS. while P < Buffer_Last and then Buffer (P) = ASCII.LF loop Ref_Indent := Integer'Max (Num_Spaces, 0); New_Line (L); P := P + 1; end loop; Start_Of_Line := P; if P /= Buffer_Last then while Buffer (P) = ' ' or else Buffer (P) = ASCII.HT loop P := P + 1; if P = Buffer_Last then exit; end if; end loop; end if; exit when P = Buffer_Last or else Buffer (P) /= ASCII.LF; end loop; End_Of_Line := Line_End (Buffer, P); Padding := 0; if Indent_Comments and then Buffer (P) = ASCII.LF then -- Indent last buffer line before exiting, to position -- the cursor at the right location pragma Assert (P = Buffer_Last); Do_Indent (P, L, Ref_Indent); end if; if Callback /= null then if First + 2 <= Buffer_Last and then Buffer (First + 2) = '#' then Entity := Annotated_Comment_Text; else Entity := Comment_Text; end if; if Entity = Annotated_Comment_Text and then Replace = null then -- Recognize and handle SPARK reserved words when parsing -- constructs. declare Prev_Sloc : Source_Location; Line : constant Natural := Prev_Line - 1; Col : constant Natural := First + 2 - Prev_Start_Line + 1; function Is_SPARK_Keyword (S : String) return Boolean; -- Callback for Analyze_Ada_Source to recognize SPARK -- keywords. function Local_Callback (Entity : Language_Entity; Sloc_Start : Source_Location; Sloc_End : Source_Location; Partial_Entity : Boolean) return Boolean; -- Wrapper around Callback function Adjust (Loc : Source_Location) return Source_Location; -- Adjust Loc taking Line, Col and Offset into account ---------------------- -- Is_SPARK_Keyword -- ---------------------- function Is_SPARK_Keyword (S : String) return Boolean is begin return Match (SPARK_Keywords, S); end Is_SPARK_Keyword; ------------ -- Adjust -- ------------ function Adjust (Loc : Source_Location) return Source_Location is begin return (Loc.Line + Line, Loc.Column + Col, Loc.Index); end Adjust; -------------------- -- Local_Callback -- -------------------- function Local_Callback (Entity : Language_Entity; Sloc_Start : Source_Location; Sloc_End : Source_Location; Partial_Entity : Boolean) return Boolean is Ignore : Boolean; pragma Unreferenced (Ignore); Sloc1 : constant Source_Location := Adjust (Sloc_Start); Sloc2 : constant Source_Location := Adjust (Sloc_End); begin if Entity = Keyword_Text and then Is_SPARK_Keyword (Buffer (Sloc_Start.Index .. Sloc_End.Index)) then Ignore := Callback (Annotated_Comment_Text, Prev_Sloc, (Sloc1.Line, Sloc1.Column - 1, Sloc1.Index - 1), Partial_Entity); Prev_Sloc := (Sloc2.Line, Sloc2.Column + 1, Sloc2.Index + 1); return Callback (Annotated_Keyword_Text, Sloc1, Sloc2, Partial_Entity); else return False; end if; end Local_Callback; begin Prev_Sloc := (Prev_Line, First - Prev_Start_Line + 1, First); -- Call Analyze_Ada_Source recursively on the SPARK -- annotations to highlight keywords. Analyze_Ada_Source (Buffer (First + 3 .. Last - 1), Symbols, Indent_Params => Indent_Params, Format => Format, Replace => null, Constructs => null, Callback => Local_Callback'Unrestricted_Access, Indent_Offset => Indent_Offset, Case_Exceptions => Case_Exceptions, Is_Optional_Keyword => Is_SPARK_Keyword'Access); if Prev_Sloc.Index <= Last then if Callback (Entity, Prev_Sloc, (Prev_Line, Last - Prev_Start_Line + 1, Last), False) then Terminated := True; return; end if; end if; end; else if Call_Callback (Entity, (Prev_Line, First - Prev_Start_Line + 1, First), (Prev_Line, Last - Prev_Start_Line + 1, Last), False) then Terminated := True; return; end if; end if; end if; if P = Buffer_Last then -- In this case, the comment goes until the end of the -- buffer. There's nothing more to be analyzed, so -- put P beyond the last analyzed element. P := P + 1; end if; end loop; if P > Buffer_Last then End_Reached := True; end if; end Skip_Comments; ---------------------------- -- Preprocessor_Directive -- ---------------------------- procedure Preprocessor_Directive is begin -- Skip line while P < Buffer'Last and then Buffer (P + 1) /= ASCII.LF loop P := P + 1; end loop; -- Mark this line as indented, so that the current indentation is -- kept. Indent_Done := True; end Preprocessor_Directive; ----------------------- -- Pop_And_Set_Local -- ----------------------- procedure Pop_And_Set_Local (Stack : in out Token_Stack.Simple_Stack) is begin Pop (Stack); if not Is_Empty (Stack) then Local_Top_Token := Top (Stack); else Local_Top_Token := null; end if; end Pop_And_Set_Local; begin -- Next_Word Start_Of_Line := Line_Start (Buffer, P); End_Of_Line := Line_End (Buffer, Start_Of_Line); Terminated := False; End_Reached := False; loop declare L1, L2 : Natural; begin L1 := L; Skip_Blank_Lines; Skip_Comments; L2 := L; -- If we have blank lines and/or comment line we need to -- recompute the alignment for the next block of code. Recompute_Align := L2 > L1 + 1; end; if (End_Reached and then Buffer (Buffer_Last) /= ASCII.LF) or else Terminated then return; end if; exit when P > Buffer_Last or else Is_Entity_Letter (UTF8_Get_Char (Buffer (P .. Buffer_Last))); -- WARNING: any call to Pop (Token) during the case statement -- below should be followed by a recomputation of Top_Token. -- See e.g. Handle_Arrow where this is done. -- Only if Top_Token is not accessed further down this procedure -- can the recomputation be omitted. Local_Top_Token := Top (Tokens); if Align_On_Colons and then Recompute_Align then Local_Top_Token.Align_Colon := Compute_Alignment (P, Stop_On_Blank_Line => True, Skip_First_Line => False); end if; Prev3_Token := Prev_Prev_Token; Prev_Prev_Token := Prev_Token; Token_Found := True; case Buffer (P) is when '#' => First := P; Prev_Token := Tok_Pound; if (P = Buffer'First or else not Is_Alphanumeric (Buffer (P - 1))) and then P < Buffer'Last and then (Is_Letter (Buffer (P + 1)) or else Buffer (P + 1) = ' ') then Preprocessor_Directive; end if; when '[' => First := P; Prev_Token := Tok_Left_Square_Bracket; when ']' => First := P; Prev_Token := Tok_Right_Square_Bracket; when '(' => First := P; Prev_Token := Tok_Left_Paren; if Num_Parens = 0 then if In_Declaration = Subprogram_Decl and then (Top_Token = null or else not Top_Token.Attributes (Ada_New_Attribute)) then Is_Parameter := True; elsif In_Declaration = Type_Decl then Is_Discriminant := True; elsif Prev_Prev_Token = Tok_Is and then Local_Top_Token.Token = Tok_Function then -- This is an expression function so we won't have -- and 'end function', unindent accordingly. Num_Spaces := Num_Spaces - Indent_Level; -- ??? The code below is not quite right: ideally we -- want to register the end of the expression function -- at the semicolon. Pop_And_Set_Local (Tokens); end if; end if; if not Is_Empty (Paren_Stack) then Push (Paren_Stack, Top (Paren_Stack).all); elsif Local_Top_Token.Token = Tok_Type then Push (Paren_Stack, Type_Declaration); elsif Prev_Prev_Token = Tok_Return then Push (Paren_Stack, Aggregate); elsif Prev_Prev_Token in Reserved_Token_Type then Push (Paren_Stack, Conditional); elsif Prev_Prev_Token = Tok_Identifier then Push (Paren_Stack, Function_Call); else Push (Paren_Stack, Aggregate); end if; if Continuation_Val > Indent_Continue and then Top (Indents).Level /= None then Continuation_Val := 0; end if; if P > Buffer'First then Char := Buffer (Prev_Char (P)); else Char := ' '; end if; if Indent_Done then Adjust := Indent_Continue + Continuation_Val; Paren_In_Middle := True; -- If Prev_Prev_Token is an operator, it means that -- spaces have already been inserted. if Format_Operators and then not Is_Blank (Char) and then Char /= '(' and then Char /= ''' and then not Is_Extended_Operator (Prev_Prev_Token) then Spaces (2) := Buffer (P); Replace_Text (P, P + 1, L, Spaces (1 .. 2)); end if; else -- Indent with extra spaces if the '(' is the first -- non blank character on the line if Prev_Prev_Token = Tok_Comma then Adjust := 1; else Adjust := Indent_Continue + 1; end if; if Prev_Prev_Token = Tok_Comma or else Prev_Prev_Token = Tok_Ampersand then Do_Indent (P, L, Num_Spaces); else if Prev_Prev_Token = Tok_Colon_Equal and then Local_Top_Token.Colon_Col /= 0 and then Continuation_Val = 0 then Continuation_Val := Top (Tokens).Colon_Col + 4 - Indent_Continue; end if; Adjust := Adjust + Continuation_Val; Tmp := Paren_In_Middle; Do_Indent (P, L, Num_Spaces, Continuation => Prev_Prev_Token = Tok_Apostrophe or else Prev_Prev_Token = Tok_Arrow or else not Paren_In_Middle or else Prev_Prev_Token in Reserved_Token_Type); Paren_In_Middle := Tmp; end if; end if; Num_Parens := Num_Parens + 1; Align := 0; if Num_Parens = 1 and then Local_Top_Token.Token in Token_Class_Declk and then Local_Top_Token.Profile_Start = 0 and then not Local_Top_Token.Attributes (Ada_New_Attribute) then if In_Declaration = Subprogram_Decl then Local_Top_Token.Profile_Start := P; end if; if Align_On_Colons then Local_Top_Token.Align_Colon := Compute_Alignment (P + 1, Skip_First_Line => False); end if; else if Align_On_Arrows then Align := Compute_Alignment (P + 1, Skip_First_Line => False, Align_On => Tok_Arrow); end if; end if; -- Indent on the left parenthesis for subprogram & type -- declarations, and for subprogram calls/aggregates with no -- nested parenthesis except on the same line and for -- arrows+paren as in: -- X := (Foo => (Y, -- Z)); -- In other cases (complex subprogram call), -- indent as for continuation lines. declare Level, Tmp_Index, Val : Integer; begin if Top (Paren_Stack).all = Conditional then Level := P - Start_Of_Line + Padding + Indent_Conditional; else -- ../test/ada-gps/ada_gps_bug_006.adb -- The_TV := E (Query, (Def_Restriction.Traffic_Volume, Tmp_Index := P + 1; while Tmp_Index <= Buffer'Last and then Buffer (Tmp_Index) = ' ' loop Tmp_Index := Tmp_Index + 1; end loop; Level := Tmp_Index - Start_Of_Line + Padding; end if; Val := Top (Indents).Continuation_Val; Push (Indents, (Level, Align, L, Continuation_Val)); -- If Align_Decl_On_Colon is set and Colon_Col is set -- then ignore Val and continue indenting based on -- the current Continuation_Val since the saved value -- does not take Colon_Col into account. if Local_Top_Token.Colon_Col /= 0 then if Continuation_Val > 0 then Continuation_Val := Continuation_Val - Indent_Continue; end if; else Continuation_Val := Val; end if; end; when ')' => if (Local_Top_Token.Token = Tok_Colon or else Local_Top_Token.Token = Tok_Identifier) and then (Local_Top_Token.Variable_Kind in Parameter_Kind .. Discriminant_Kind or else (Local_Top_Token.Is_In_Type_Definition and then not Local_Top_Token.Attributes (Ada_Record_Attribute) and then not Local_Top_Token.Type_Declaration)) then if Local_Top_Token.Token = Tok_Identifier and then not (Local_Top_Token.Is_In_Type_Definition and then not Local_Top_Token.Attributes (Ada_Record_Attribute) and then not Local_Top_Token.Type_Declaration) then -- This handles cases where we have a family entry. -- For example: -- entry E (Integer); -- here Integer is a type, so we don't want it in the -- constructs. But is has already been pushed. The -- code below disactivate its addition to the -- constructs Local_Top_Token.Token := Tok_Colon; end if; Pop_And_Set_Local (Tokens); end if; First := P; Prev_Token := Tok_Right_Paren; Close_Parenthesis; when '"' => declare Len : Natural; Entity : Language_Entity; begin First := P; while P < End_Of_Line loop P := Next_Char (P); exit when Buffer (P) = '"'; end loop; if Buffer (P) /= '"' then -- Syntax error: the string was not terminated -- Try to recover properly, and in particular, try -- to reset the parentheses stack. if Num_Parens > 0 then Close_Parenthesis; end if; end if; if (Local_Top_Token.Token in Token_Class_Declk and then Local_Top_Token.Ident_Len = 0) or else Prev_Token in Tok_End | Tok_Dot or else Local_Top_Token.Token = Tok_With then -- This is an operator symbol, e.g function ">=" (...) -- Or we're parsing a GNAT Project file and this is -- a dependency declaration (with "bla.gpr") if Prev_Token not in Tok_End | Tok_Dot then Len := P - First + 1; Local_Top_Token.Identifier (1 .. Len) := Buffer (First .. P); Local_Top_Token.Ident_Len := Len; Local_Top_Token.Sloc_Name.Line := L; Local_Top_Token.Sloc_Name.Column := First - Start_Of_Line + 1; Local_Top_Token.Sloc_Name.Index := First; end if; Prev_Token := Tok_Operator_Symbol; Entity := Block_Text; else Prev_Token := Tok_String_Literal; Entity := String_Text; end if; Compute_Indentation (Prev_Token, Prev_Prev_Token, Prev3_Token, P, L, Num_Spaces); if Callback /= null then if Call_Callback (Entity, (L, First - Start_Of_Line + 1, First), (L, P - Start_Of_Line + 1, P), False) then Terminated := True; return; end if; end if; end; when '&' | '+' | '-' | '*' | '/' | ':' | '<' | '>' | '=' | '|' | '.' => Spaces (2) := Buffer (P); Spaces (3) := ' '; First := P; Last := P + 1; Offs := 1; case Buffer (P) is when '+' | '-' => if Buffer (P) = '-' then Prev_Token := Tok_Minus; else Prev_Token := Tok_Plus; end if; if Prev_Prev_Token = Tok_Identifier and then (P <= Buffer'First + 1 or else To_Upper (Buffer (P - 1)) /= 'E' or else (Buffer (P - 2) /= '#' and then Buffer (P - 2) not in '0' .. '9')) and then (P = Buffer'Last or else (Buffer (P + 1) /= '"' and then Buffer (P + 1) /= '(')) then Insert_Spaces := True; else Insert_Spaces := False; end if; when '&' | '|' => if Buffer (P) = '&' then Prev_Token := Tok_Ampersand; else Prev_Token := Tok_Vertical_Bar; end if; Insert_Spaces := True; when '/' | ':' => Insert_Spaces := True; if P < Buffer'Last and then Buffer (P + 1) = '=' then if Buffer (P) = ':' and then Local_Top_Token.Token = Tok_Colon then Right_Assignment := True; Local_Top_Token.Attributes (Ada_Assign_Attribute) := True; if Local_Top_Token.Variable_Kind in Parameter_Kind .. Discriminant_Kind then Pop_And_Set_Local (Tokens); end if; end if; Handle_Two_Chars ('='); if Buffer (P) = '/' then Prev_Token := Tok_Not_Equal; else Prev_Token := Tok_Colon_Equal; end if; elsif Buffer (P) = '/' then Prev_Token := Tok_Slash; else Handle_Colon; end if; when '*' => declare Prev_Tmp : constant Integer := Prev_Char (P); begin Insert_Spaces := Prev_Tmp >= Buffer'First and then Buffer (Prev_Tmp) /= '*'; end; if P < Buffer'Last and then Buffer (Next_Char (P)) = '*' then Handle_Two_Chars ('*'); Prev_Token := Tok_Double_Asterisk; else Prev_Token := Tok_Asterisk; end if; when '.' => declare Next_Tmp : constant Natural := Next_Char (P); begin Insert_Spaces := Next_Tmp <= Buffer'Last and then Buffer (Next_Tmp) = '.'; end; if Insert_Spaces then Handle_Two_Chars ('.'); Prev_Token := Tok_Dot_Dot; else Prev_Token := Tok_Dot; end if; when '<' => declare Next_Tmp : constant Natural := Next_Char (P); begin if Next_Tmp <= Buffer'Last then case Buffer (Next_Tmp) is when '=' => Insert_Spaces := True; Prev_Token := Tok_Less_Equal; Handle_Two_Chars ('='); when '<' => Prev_Token := Tok_Less_Less; Insert_Spaces := False; Handle_Two_Chars ('<'); when '>' => Prev_Token := Tok_Box; Insert_Spaces := False; Handle_Two_Chars ('>'); when others => Prev_Token := Tok_Less; Insert_Spaces := True; end case; else Prev_Token := Tok_Less; Insert_Spaces := True; end if; end; when '>' => declare Next_Tmp : constant Natural := Next_Char (P); begin if Next_Tmp <= Buffer'Last then case Buffer (Next_Tmp) is when '=' => Insert_Spaces := True; Prev_Token := Tok_Greater_Equal; Handle_Two_Chars ('='); when '>' => Prev_Token := Tok_Greater_Greater; Insert_Spaces := False; Handle_Two_Chars ('>'); when others => Prev_Token := Tok_Greater; Insert_Spaces := True; end case; else Prev_Token := Tok_Greater; Insert_Spaces := True; end if; end; when '=' => Insert_Spaces := True; if P + 1 <= Buffer'Last and then Buffer (P + 1) = '>' then Handle_Arrow; else Prev_Token := Tok_Equal; end if; when others => null; end case; if Spaces (3) = ' ' then if P + 1 > Buffer'Last or else Is_Blank (Buffer (P + 1)) or else Last - 1 = End_Of_Line then Long := 2; else Long := 3; end if; end if; if P > Buffer'First and then Is_Blank (Buffer (P - 1)) then Offs := 2; Long := Long - 1; end if; if (Num_Parens = 0 or else Prev_Token in Tok_Ampersand | Tok_Vertical_Bar or else Prev_Prev_Token in Tok_Arrow | Tok_Then | Tok_Else) and then Local_Top_Token.Token /= Tok_When then -- If we're not inside parens or if we're in a -- conditional expression, then handle continuation -- lines here. Otherwise, continuation lines are already -- handled separately. Compute_Indentation (Prev_Token, Prev_Prev_Token, Prev3_Token, P, L, Num_Spaces); else Do_Indent (P, L, Num_Spaces); end if; if Format_Operators and then Insert_Spaces then Replace_Text (First, Last, L, Spaces (Offs .. Offs + Long - 1)); end if; when ',' | ';' => First := P; if Buffer (P) = ';' then Prev_Token := Tok_Semicolon; Right_Assignment := False; if Aspect_Clause then Finish_Aspect_Clause (P, L, Done => Terminated); Local_Top_Token := Top (Tokens); if Terminated then return; end if; end if; if Local_Top_Token.Token = Tok_Colon then Pop_And_Set_Local (Tokens); elsif Num_Parens = 0 then if In_Declaration /= No_Decl or else (Local_Top_Token.Token = Tok_Task and then In_Declaration = Type_Decl) or else Local_Top_Token.Token = Tok_Subtype or else Local_Top_Token.Token = Tok_For then -- subprogram spec or type decl or repr. clause, -- e.g: -- procedure xxx (...); -- type ... is ...; -- for ... use ...; Pop_And_Set_Local (Tokens); In_Declaration := No_Decl; elsif Local_Top_Token.Token = Tok_With or else Local_Top_Token.Token = Tok_Use or else Local_Top_Token.Token = Tok_Identifier or else Local_Top_Token.Token = Tok_Type or else Local_Top_Token.Token = Tok_Accept or else Local_Top_Token.Token = Tok_Pragma then Pop_And_Set_Local (Tokens); end if; end if; if In_Declaration = Subprogram_Decl and then not (Top_Token /= null and then Top_Token.Attributes (Ada_New_Attribute)) then Is_Parameter := True; elsif In_Declaration = Type_Decl then Is_Discriminant := True; end if; else Prev_Token := Tok_Comma; if Local_Top_Token.In_Declaration and then Local_Top_Token.Token = Tok_Identifier then Pop_And_Set_Local (Tokens); elsif Local_Top_Token.Token = Tok_With or else Local_Top_Token.Token = Tok_Use then declare Val : Extended_Token; begin -- Create a separate entry for each with clause: -- with a, b; -- will get two entries: one for a, one for b. Val.Token := Local_Top_Token.Token; Pop_And_Set_Local (Tokens); Val.Sloc.Line := L; Val.Sloc.Column := Prec - Line_Start (Buffer, Prec) + 2; Val.Sloc.Index := Prec + 1; Val.Ident_Len := 0; Push (Tokens, Val); end; end if; end if; if Format_Operators and then P /= End_Of_Line then Char := Buffer (P + 1); if Char /= ' ' then Do_Indent (P, L, Num_Spaces); Comma (1) := Buffer (P); Replace_Text (P, P + 1, L, Comma (1 .. 2)); end if; end if; when ''' => -- Apostrophe. This can either be the start of a character -- literal, an isolated apostrophe used in a qualified -- expression or an attribute. We treat it as a character -- literal if it does not follow a right parenthesis, -- identifier, the keyword ALL or a literal. This means that -- we correctly treat constructs like: -- A := Character'('A'); First := P; if Prev_Token = Tok_Identifier or else Prev_Token = Tok_Right_Paren or else Prev_Token = Tok_All or else Prev_Token in Token_Class_Literal or else P = End_Of_Line then Prev_Token := Tok_Apostrophe; else if P = End_Of_Line - 1 then P := P + 1; else P := P + 2; end if; while P < End_Of_Line and then Buffer (P) /= ''' loop P := Next_Char (P); end loop; Prev_Token := Tok_Char_Literal; if Callback /= null then if Call_Callback (Character_Text, (L, First - Start_Of_Line + 1, First), (L, P - Start_Of_Line + 1, P), False) then Terminated := True; Comments_Skipped := False; return; end if; end if; end if; when others => Token_Found := False; end case; if Buffer (P) /= ' ' and then not Is_Control (Buffer (P)) then Comments_Skipped := False; end if; if Token_Found and then (Prev_Token in Tok_Double_Asterisk .. Tok_Colon_Equal or else Prev_Token in Tok_Semicolon .. Tok_Dot_Dot) then if Callback /= null then if Call_Callback (Operator_Text, (L, First - Start_Of_Line + 1, First), (L, P - Start_Of_Line + 1, P), False) then Terminated := True; Comments_Skipped := False; return; end if; end if; end if; P := Next_Char (P); end loop; Comments_Skipped := False; Terminated := False; end Next_Word; ------------------ -- Replace_Text -- ------------------ procedure Replace_Text (First : Natural; Last : Natural; Line : Natural; Str : String) is Start : Natural; begin if Replace /= null and then (To = 0 or else Line in From .. To) then if Last_Replace_Line /= Line then Last_Replace_Line := Line; Padding := 0; end if; Start := Line_Start (Buffer, First); Replace (Line, Padding + First - Start + 1, Padding + Last - Start + 1, Str); Padding := Padding + Str'Length - (Last - First); end if; end Replace_Text; ------------------- -- Call_Callback -- ------------------- function Call_Callback (Entity : Language_Entity; Sloc_Start : Source_Location; Sloc_End : Source_Location; Partial_Entity : Boolean) return Boolean is Ignore : Boolean; pragma Unreferenced (Ignore); Ent : Language_Entity := Entity; begin if Aspect_Clause then case Entity is when Keyword_Text => Ent := Aspect_Keyword_Text; when Comment_Text | Annotated_Comment_Text => Ent := Aspect_Comment_Text; when others => -- Highlight everything else with Aspect_Text, -- which will be done next time Call_Callback is called. return False; end case; Ignore := Callback (Aspect_Text, Aspect_Clause_Sloc, (Sloc_Start.Line, Sloc_Start.Column - 1, Sloc_Start.Index - 1), Partial_Entity); Aspect_Clause_Sloc := (Sloc_End.Line, Sloc_End.Column + 1, Sloc_End.Index + 1); end if; return Callback (Ent, Sloc_Start, Sloc_End, Partial_Entity); end Call_Callback; begin -- Analyze_Ada_Source if Buffer'Length = 0 then return; end if; -- Push a dummy token so that stack will never be empty Push (Tokens, Default_Extended); -- Push a dummy indentation so that stack will never be empty Push (Indents, (None, 0, 0, 0)); Next_Word (Prec, Line_Count, Terminated, End_Reached); -- If there is only one character in the buffer and the end of the -- buffer has been reached, enter the main loop anyway. Otherwise, -- the on-the-fly auto-casing will not work when adding a space after -- single character identifier. if (End_Reached and then Buffer_Last > 1 and then Buffer (Buffer_Last) /= ASCII.LF) or else Terminated then Clear (Paren_Stack); Clear (Tokens); Clear (Indents); return; end if; Current := End_Of_Word (Prec); Main_Loop : loop Str_Len := Current - Prec + 1; Str (1 .. Str_Len) := Buffer (Prec .. Current); Token := Get_Token (Str (1 .. Str_Len), Prev_Token); if Token = Tok_Identifier then -- Handle dotted names, e.g Foo.Bar.X Prev_Line := Line_Count; if Current < Buffer_Last then Index_Ident := End_Of_Identifier (Current + 1); if Index_Ident /= Current then -- We have a dotted name, update indexes Str_Len := Index_Ident - Prec + 1; Str (Current - Prec + 2 .. Index_Ident - Prec + 1) := Buffer (Current + 1 .. Index_Ident); Current := Index_Ident; end if; end if; Top_Token := Top (Tokens); Start_Of_Line := Line_Start (Buffer, Prec); if Top_Token.Ident_Len = 0 and then (Top_Token.Token in Token_Class_Declk or else Top_Token.Token = Tok_With or else Top_Token.Token = Tok_Pragma) then -- Store enclosing entity name Top_Token.Identifier (1 .. Str_Len) := Buffer (Prec .. Current); Top_Token.Ident_Len := Str_Len; Top_Token.Sloc_Name.Line := Prev_Line; Top_Token.Sloc_Name.Column := Prec - Start_Of_Line + 1; Top_Token.Sloc_Name.Index := Prec; end if; if (Top_Token.In_Declaration or else (Top_Token.Token = Tok_For and then Prev_Token = Tok_For) or else Top_Token.Type_Declaration or else (Top_Token.Attributes (Ada_Record_Attribute) and then (Top_Token.Token = Tok_Case or else Prev_Token /= Tok_Arrow)) or else Is_Parameter or else Is_Discriminant or else (Top_Token.Type_Definition_Section and then Top_Token.Token = Tok_Type and then Top_Token.Attributes = No_Attribute)) and then (Num_Parens = 0 or else Is_Parameter or else Is_Discriminant or else Top_Token.Type_Definition_Section) and then (Prev_Token not in Reserved_Token_Type or else Prev_Token = Tok_Declare or else Prev_Token = Tok_Private or else Prev_Token = Tok_Record or else Prev_Token = Tok_Generic or else Prev_Token = Tok_For or else (Prev_Token = Tok_Is and then not In_Generic)) and then Prev_Token /= Tok_Dot and then Prev_Token /= Tok_Apostrophe and then not Aspect_Clause then -- This is a variable, a field declaration or a enumeration -- literal declare Val : Extended_Token; begin Val.Token := Tok_Identifier; Val.Sloc.Line := Prev_Line; Val.Sloc.Column := Prec - Start_Of_Line + 1; Val.Sloc.Index := Prec; Val.Identifier (1 .. Str_Len) := Str (1 .. Str_Len); Val.Ident_Len := Str_Len; Val.Sloc_Name := Val.Sloc; Val.In_Declaration := True; Val.Visibility := Top_Token.Visibility_Section; if Is_Parameter then Val.Variable_Kind := Parameter_Kind; elsif Is_Discriminant then Val.Variable_Kind := Discriminant_Kind; end if; Val.Is_In_Type_Definition := Top_Token.Type_Definition_Section; Val.Is_Generic_Param := In_Generic; Push (Tokens, Val); if Prev_Token = Tok_For then Pop (Tokens); end if; end; end if; declare Entity : Language_Entity; begin Entity := Identifier_Text; Casing := Ident_Casing; if Is_Digit (Str (1)) or else (Prev_Token = Tok_Pound and then Is_Hexadecimal_Digit (Str (1))) then -- Recognize simple cases of numeric values -- ??? recognizing more cases would require changing -- Next_Word parsing. Entity := Number_Text; elsif Is_Optional_Keyword /= null and then Is_Optional_Keyword (Str (1 .. Str_Len)) then Entity := Keyword_Text; Casing := Reserved_Casing; -- Try to differentiate type identifiers and block identifiers -- from others in declarations. elsif ((Prev_Token = Tok_In or else Prev_Token = Tok_Access or else Prev_Token = Tok_Aliased or else Prev_Token = Tok_Constant) and then (Prev_Prev_Token = Tok_Colon or else Prev_Prev_Token = Tok_Null or else Prev_Prev_Token = Tok_Is)) or else (Prev_Token = Tok_All and then Prev_Prev_Token = Tok_Access) or else (Prev_Token = Tok_Is and then Prev_Prev_Token = Tok_Identifier and then Top_Token.Type_Declaration) or else (Prev_Token = Tok_Out and then (Prev_Prev_Token = Tok_Colon or else Prev_Prev_Token = Tok_In)) or else Prev_Token = Tok_Colon or else (In_Declaration = Subprogram_Decl and then Prev_Token = Tok_Return) then Entity := Type_Text; elsif (Prev_Token = Tok_Type and then Prev_Prev_Token /= Tok_Use) or else Prev_Token = Tok_Subtype or else Prev_Token = Tok_End or else Prev_Token = Tok_Procedure or else Prev_Token = Tok_Function or else Prev_Token = Tok_Task or else Prev_Token = Tok_Body or else Prev_Token = Tok_Entry or else Prev_Token = Tok_Accept or else Prev_Token = Tok_Package or else (Prev_Token = Tok_Renames and then Prev_Prev_Token = Tok_Right_Paren) or else (Current + 8 <= Buffer_Last and then Buffer (Current + 2) = ':' and then (Look_For (Current + 4, "begin") or else Look_For (Current + 4, "declare"))) then Entity := Block_Text; end if; if Prev_Token = Tok_Apostrophe and then To_Upper (Str (1 .. Str_Len)) = "CLASS" and then Top_Token.In_Entity_Profile then Top_Token.Attributes (Ada_Class_Attribute) := True; end if; if Callback /= null then exit Main_Loop when Call_Callback (Entity, (Prev_Line, Prec - Start_Of_Line + 1, Prec), (Line_Count, Current - Line_Start (Buffer, Current) + 1, Current), False); end if; end; elsif Prev_Token = Tok_Apostrophe and then (Token = Tok_Delta or else Token = Tok_Digits or else Token = Tok_Mod or else Token = Tok_Range or else Token = Tok_Access) then -- This token should not be considered as a reserved word Casing := Ident_Casing; if Callback /= null then Start_Of_Line := Line_Start (Buffer, Prec); exit Main_Loop when Call_Callback (Identifier_Text, (Line_Count, Prec - Start_Of_Line + 1, Prec), (Line_Count, Current - Start_Of_Line + 1, Current), False); end if; elsif Token = No_Token then Casing := Unchanged; else -- We have a reserved word Casing := Reserved_Casing; declare Temp : aliased Extended_Token; Do_Push : Boolean; Do_Pop : Integer; Do_Finish : Boolean; begin Handle_Word_Token (Token, Temp, Do_Pop, Do_Push, Do_Finish); exit Main_Loop when Do_Finish; Handle_Word_Indent (Token, Temp); for J in 1 .. Do_Pop loop Pop (Tokens); end loop; -- Handles In_Generic if not In_Generic and then Token = Tok_Generic then In_Generic := True; elsif In_Generic and then Prev_Token not in Tok_With | Tok_Access | Tok_Protected and then Token in Tok_Function | Tok_Procedure | Tok_Package then In_Generic := False; end if; if Do_Push then Temp.Is_Generic_Param := In_Generic; Push (Tokens, Temp); else null; end if; -- Computes In_Declaration -- ??? There is still some computation of this done in -- Handle_Word_Token. It would be nice to have all of it here. if Token = Tok_Body or else Token = Tok_Renames or else (Token = Tok_Is and then not In_Generic) then In_Declaration := No_Decl; elsif In_Declaration = Subprogram_Decl and then Token = Tok_With then In_Declaration := Subprogram_Aspect; end if; end; end if; if Indent_Params.Casing_Policy /= Disabled and then Prev_Token /= Tok_Pound -- Disable casing for based literal (so if a word is preceded by -- a pound sign). then case Casing is when Unchanged => null; when Upper | Lower | Mixed | Smart_Mixed => -- We do not want to case some as this is a new keyword in -- Ada 2012 but for upward compatibility issue GNAT does not -- forbid some as identifier. Without context it is not -- possible to determine if some is used as identifier or as -- keyword, so to avoid upsetting users we never change -- casing of some. if To_Lower (Str (1 .. Str_Len)) /= "some" then Replace_Text (Prec, Current + 1, Line_Count, Set_Case (Case_Exceptions, Str (1 .. Str_Len), Casing)); end if; end case; end if; -- 'is' is handled specially, so nothing is needed here except -- for type declarations, e.g: -- type T -- is ... if Token /= Tok_Is or else (Top_Token /= null and then Top_Token.Token = Tok_Type) then Compute_Indentation (Token, Prev_Token, Prev_Prev_Token, Current, Line_Count, Num_Spaces); end if; Prec := Current + 1; Prev_Prev_Token := Prev_Token; Prev_Token := Token; exit Main_Loop when Prec > Buffer_Last; Next_Word (Prec, Line_Count, Terminated, End_Reached); exit Main_Loop when Terminated or else (End_Reached and then Buffer (Buffer_Last) /= ASCII.LF); Current := End_Of_Word (Prec); end loop Main_Loop; -- Try to register partial constructs, friendlier Prec := Integer'Min (Prec, Buffer'Last); if Constructs /= null then while Top (Tokens).Token /= No_Token loop Pop (Tokens); end loop; end if; Clear (Paren_Stack); Clear (Tokens); Clear (Indents); exception when E : others => Trace (Me, E); raise; end Analyze_Ada_Source; end Ada_Analyzer;
Transynther/x86/_processed/NONE/_zr_/i9-9900K_12_0xca.log_21829_470.asm
ljhsiun2/medusa
9
13066
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r13 push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0xcc21, %r11 nop nop nop cmp $32811, %r12 movl $0x61626364, (%r11) nop nop nop nop xor %r11, %r11 lea addresses_A_ht+0x19621, %rsi lea addresses_WT_ht+0x7ad7, %rdi nop nop nop sub $37507, %r12 mov $60, %rcx rep movsw cmp %rcx, %rcx lea addresses_WC_ht+0x1821, %r12 nop nop nop nop inc %r10 mov $0x6162636465666768, %r13 movq %r13, %xmm4 vmovups %ymm4, (%r12) nop sub $22312, %r12 lea addresses_normal_ht+0x1e629, %r11 nop nop nop nop add $52114, %rsi movb $0x61, (%r11) nop nop and %r11, %r11 lea addresses_normal_ht+0x17921, %rsi lea addresses_A_ht+0x60b1, %rdi nop nop dec %rdx mov $89, %rcx rep movsb nop nop nop and %rdx, %rdx lea addresses_WT_ht+0x62e7, %rsi lea addresses_WT_ht+0x1c21, %rdi nop add %r12, %r12 mov $65, %rcx rep movsw nop nop xor %rdx, %rdx lea addresses_A_ht+0x14130, %r10 nop nop nop nop nop cmp %rsi, %rsi mov $0x6162636465666768, %r11 movq %r11, (%r10) nop nop nop inc %r10 lea addresses_A_ht+0x1ae21, %rdi sub %rcx, %rcx mov $0x6162636465666768, %r10 movq %r10, %xmm7 and $0xffffffffffffffc0, %rdi vmovaps %ymm7, (%rdi) nop nop sub %r12, %r12 lea addresses_WT_ht+0x6ce1, %r10 nop nop nop nop and $23288, %rsi mov $0x6162636465666768, %rdx movq %rdx, (%r10) nop and %r12, %r12 lea addresses_WT_ht+0x25e6, %rsi lea addresses_A_ht+0x22f4, %rdi nop nop nop nop nop sub %rdx, %rdx mov $10, %rcx rep movsw nop nop nop nop nop add $58926, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %r13 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r15 push %r8 push %r9 push %rbp push %rsi // Faulty Load lea addresses_A+0x7c21, %rbp add %r10, %r10 mov (%rbp), %r9d lea oracles, %rsi and $0xff, %r9 shlq $12, %r9 mov (%rsi,%r9,1), %r9 pop %rsi pop %rbp pop %r9 pop %r8 pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_A_ht', 'same': True, 'AVXalign': True, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 0}} {'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 */
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/discr13.adb
best08618/asylo
7
23169
<reponame>best08618/asylo -- { dg-do compile } with Discr12_Pkg; use Discr12_Pkg; procedure Discr13 is function F1 return Integer is begin return Dummy (1); end F1; protected type Poe (D3 : Integer := F1) is entry E (D3 .. F1); -- F1 evaluated function Is_Ok (D3 : Integer; E_First : Integer; E_Last : Integer) return Boolean; end Poe; protected body Poe is entry E (for I in D3 .. F1) when True is begin null; end E; function Is_Ok (D3 : Integer; E_First : Integer; E_Last : Integer) return Boolean is begin return False; end Is_Ok; end Poe; begin null; end;
obj/b__main.ads
SKNZ/BezierToSTL
0
11596
pragma Ada_95; with System; package ada_main is pragma Warnings (Off); gnat_argc : Integer; gnat_argv : System.Address; gnat_envp : System.Address; pragma Import (C, gnat_argc); pragma Import (C, gnat_argv); pragma Import (C, gnat_envp); gnat_exit_status : Integer; pragma Import (C, gnat_exit_status); GNAT_Version : constant String := "GNAT Version: 5.3.0" & ASCII.NUL; pragma Export (C, GNAT_Version, "__gnat_version"); Ada_Main_Program_Name : constant String := "_ada_main" & ASCII.NUL; pragma Export (C, Ada_Main_Program_Name, "__gnat_ada_main_program_name"); procedure adainit; pragma Export (C, adainit, "adainit"); procedure adafinal; pragma Export (C, adafinal, "adafinal"); function main (argc : Integer; argv : System.Address; envp : System.Address) return Integer; pragma Export (C, main, "main"); type Version_32 is mod 2 ** 32; u00001 : constant Version_32 := 16#eaeed2ac#; pragma Export (C, u00001, "mainB"); u00002 : constant Version_32 := 16#fbff4c67#; pragma Export (C, u00002, "system__standard_libraryB"); u00003 : constant Version_32 := 16#1ec6fd90#; pragma Export (C, u00003, "system__standard_libraryS"); u00004 : constant Version_32 := 16#3ffc8e18#; pragma Export (C, u00004, "adaS"); u00005 : constant Version_32 := 16#9b14b3ac#; pragma Export (C, u00005, "ada__command_lineB"); u00006 : constant Version_32 := 16#d59e21a4#; pragma Export (C, u00006, "ada__command_lineS"); u00007 : constant Version_32 := 16#1d274481#; pragma Export (C, u00007, "systemS"); u00008 : constant Version_32 := 16#b19b6653#; pragma Export (C, u00008, "system__secondary_stackB"); u00009 : constant Version_32 := 16#b6468be8#; pragma Export (C, u00009, "system__secondary_stackS"); u00010 : constant Version_32 := 16#b01dad17#; pragma Export (C, u00010, "system__parametersB"); u00011 : constant Version_32 := 16#630d49fe#; pragma Export (C, u00011, "system__parametersS"); u00012 : constant Version_32 := 16#a207fefe#; pragma Export (C, u00012, "system__soft_linksB"); u00013 : constant Version_32 := 16#467d9556#; pragma Export (C, u00013, "system__soft_linksS"); u00014 : constant Version_32 := 16#2c143749#; pragma Export (C, u00014, "ada__exceptionsB"); u00015 : constant Version_32 := 16#f4f0cce8#; pragma Export (C, u00015, "ada__exceptionsS"); u00016 : constant Version_32 := 16#a46739c0#; pragma Export (C, u00016, "ada__exceptions__last_chance_handlerB"); u00017 : constant Version_32 := 16#3aac8c92#; pragma Export (C, u00017, "ada__exceptions__last_chance_handlerS"); u00018 : constant Version_32 := 16#393398c1#; pragma Export (C, u00018, "system__exception_tableB"); u00019 : constant Version_32 := 16#b33e2294#; pragma Export (C, u00019, "system__exception_tableS"); u00020 : constant Version_32 := 16#ce4af020#; pragma Export (C, u00020, "system__exceptionsB"); u00021 : constant Version_32 := 16#75442977#; pragma Export (C, u00021, "system__exceptionsS"); u00022 : constant Version_32 := 16#37d758f1#; pragma Export (C, u00022, "system__exceptions__machineS"); u00023 : constant Version_32 := 16#b895431d#; pragma Export (C, u00023, "system__exceptions_debugB"); u00024 : constant Version_32 := 16#aec55d3f#; pragma Export (C, u00024, "system__exceptions_debugS"); u00025 : constant Version_32 := 16#570325c8#; pragma Export (C, u00025, "system__img_intB"); u00026 : constant Version_32 := 16#1ffca443#; pragma Export (C, u00026, "system__img_intS"); u00027 : constant Version_32 := 16#39a03df9#; pragma Export (C, u00027, "system__storage_elementsB"); u00028 : constant Version_32 := 16#30e40e85#; pragma Export (C, u00028, "system__storage_elementsS"); u00029 : constant Version_32 := 16#b98c3e16#; pragma Export (C, u00029, "system__tracebackB"); u00030 : constant Version_32 := 16#831a9d5a#; pragma Export (C, u00030, "system__tracebackS"); u00031 : constant Version_32 := 16#9ed49525#; pragma Export (C, u00031, "system__traceback_entriesB"); u00032 : constant Version_32 := 16#1d7cb2f1#; pragma Export (C, u00032, "system__traceback_entriesS"); u00033 : constant Version_32 := 16#8c33a517#; pragma Export (C, u00033, "system__wch_conB"); u00034 : constant Version_32 := 16#065a6653#; pragma Export (C, u00034, "system__wch_conS"); u00035 : constant Version_32 := 16#9721e840#; pragma Export (C, u00035, "system__wch_stwB"); u00036 : constant Version_32 := 16#2b4b4a52#; pragma Export (C, u00036, "system__wch_stwS"); u00037 : constant Version_32 := 16#92b797cb#; pragma Export (C, u00037, "system__wch_cnvB"); u00038 : constant Version_32 := 16#09eddca0#; pragma Export (C, u00038, "system__wch_cnvS"); u00039 : constant Version_32 := 16#6033a23f#; pragma Export (C, u00039, "interfacesS"); u00040 : constant Version_32 := 16#ece6fdb6#; pragma Export (C, u00040, "system__wch_jisB"); u00041 : constant Version_32 := 16#899dc581#; pragma Export (C, u00041, "system__wch_jisS"); u00042 : constant Version_32 := 16#41837d1e#; pragma Export (C, u00042, "system__stack_checkingB"); u00043 : constant Version_32 := 16#93982f69#; pragma Export (C, u00043, "system__stack_checkingS"); u00044 : constant Version_32 := 16#12c8cd7d#; pragma Export (C, u00044, "ada__tagsB"); u00045 : constant Version_32 := 16#ce72c228#; pragma Export (C, u00045, "ada__tagsS"); u00046 : constant Version_32 := 16#c3335bfd#; pragma Export (C, u00046, "system__htableB"); u00047 : constant Version_32 := 16#99e5f76b#; pragma Export (C, u00047, "system__htableS"); u00048 : constant Version_32 := 16#089f5cd0#; pragma Export (C, u00048, "system__string_hashB"); u00049 : constant Version_32 := 16#3bbb9c15#; pragma Export (C, u00049, "system__string_hashS"); u00050 : constant Version_32 := 16#807fe041#; pragma Export (C, u00050, "system__unsigned_typesS"); u00051 : constant Version_32 := 16#06052bd0#; pragma Export (C, u00051, "system__val_lluB"); u00052 : constant Version_32 := 16#fa8db733#; pragma Export (C, u00052, "system__val_lluS"); u00053 : constant Version_32 := 16#27b600b2#; pragma Export (C, u00053, "system__val_utilB"); u00054 : constant Version_32 := 16#b187f27f#; pragma Export (C, u00054, "system__val_utilS"); u00055 : constant Version_32 := 16#d1060688#; pragma Export (C, u00055, "system__case_utilB"); u00056 : constant Version_32 := 16#392e2d56#; pragma Export (C, u00056, "system__case_utilS"); u00057 : constant Version_32 := 16#28f088c2#; pragma Export (C, u00057, "ada__text_ioB"); u00058 : constant Version_32 := 16#f372c8ac#; pragma Export (C, u00058, "ada__text_ioS"); u00059 : constant Version_32 := 16#10558b11#; pragma Export (C, u00059, "ada__streamsB"); u00060 : constant Version_32 := 16#2e6701ab#; pragma Export (C, u00060, "ada__streamsS"); u00061 : constant Version_32 := 16#db5c917c#; pragma Export (C, u00061, "ada__io_exceptionsS"); u00062 : constant Version_32 := 16#84a27f0d#; pragma Export (C, u00062, "interfaces__c_streamsB"); u00063 : constant Version_32 := 16#8bb5f2c0#; pragma Export (C, u00063, "interfaces__c_streamsS"); u00064 : constant Version_32 := 16#6db6928f#; pragma Export (C, u00064, "system__crtlS"); u00065 : constant Version_32 := 16#431faf3c#; pragma Export (C, u00065, "system__file_ioB"); u00066 : constant Version_32 := 16#ba56a5e4#; pragma Export (C, u00066, "system__file_ioS"); u00067 : constant Version_32 := 16#b7ab275c#; pragma Export (C, u00067, "ada__finalizationB"); u00068 : constant Version_32 := 16#19f764ca#; pragma Export (C, u00068, "ada__finalizationS"); u00069 : constant Version_32 := 16#95817ed8#; pragma Export (C, u00069, "system__finalization_rootB"); u00070 : constant Version_32 := 16#52d53711#; pragma Export (C, u00070, "system__finalization_rootS"); u00071 : constant Version_32 := 16#769e25e6#; pragma Export (C, u00071, "interfaces__cB"); u00072 : constant Version_32 := 16#4a38bedb#; pragma Export (C, u00072, "interfaces__cS"); u00073 : constant Version_32 := 16#07e6ee66#; pragma Export (C, u00073, "system__os_libB"); u00074 : constant Version_32 := 16#d7b69782#; pragma Export (C, u00074, "system__os_libS"); u00075 : constant Version_32 := 16#1a817b8e#; pragma Export (C, u00075, "system__stringsB"); u00076 : constant Version_32 := 16#639855e7#; pragma Export (C, u00076, "system__stringsS"); u00077 : constant Version_32 := 16#e0b8de29#; pragma Export (C, u00077, "system__file_control_blockS"); u00078 : constant Version_32 := 16#0758d1fc#; pragma Export (C, u00078, "courbesS"); u00079 : constant Version_32 := 16#d8cedace#; pragma Export (C, u00079, "mathB"); u00080 : constant Version_32 := 16#70dc6f09#; pragma Export (C, u00080, "mathS"); u00081 : constant Version_32 := 16#5e7381e4#; pragma Export (C, u00081, "vecteursB"); u00082 : constant Version_32 := 16#adaf9663#; pragma Export (C, u00082, "vecteursS"); u00083 : constant Version_32 := 16#608e2cd1#; pragma Export (C, u00083, "system__concat_5B"); u00084 : constant Version_32 := 16#9a7907af#; pragma Export (C, u00084, "system__concat_5S"); u00085 : constant Version_32 := 16#932a4690#; pragma Export (C, u00085, "system__concat_4B"); u00086 : constant Version_32 := 16#63436fa1#; pragma Export (C, u00086, "system__concat_4S"); u00087 : constant Version_32 := 16#2b70b149#; pragma Export (C, u00087, "system__concat_3B"); u00088 : constant Version_32 := 16#16571824#; pragma Export (C, u00088, "system__concat_3S"); u00089 : constant Version_32 := 16#fd83e873#; pragma Export (C, u00089, "system__concat_2B"); u00090 : constant Version_32 := 16#1f879351#; pragma Export (C, u00090, "system__concat_2S"); u00091 : constant Version_32 := 16#46899fd1#; pragma Export (C, u00091, "system__concat_7B"); u00092 : constant Version_32 := 16#e1e01f9e#; pragma Export (C, u00092, "system__concat_7S"); u00093 : constant Version_32 := 16#a83b7c85#; pragma Export (C, u00093, "system__concat_6B"); u00094 : constant Version_32 := 16#cfe06933#; pragma Export (C, u00094, "system__concat_6S"); u00095 : constant Version_32 := 16#f0df9003#; pragma Export (C, u00095, "system__img_realB"); u00096 : constant Version_32 := 16#da8f1563#; pragma Export (C, u00096, "system__img_realS"); u00097 : constant Version_32 := 16#19b0ff72#; pragma Export (C, u00097, "system__fat_llfS"); u00098 : constant Version_32 := 16#1b28662b#; pragma Export (C, u00098, "system__float_controlB"); u00099 : constant Version_32 := 16#fddb07bd#; pragma Export (C, u00099, "system__float_controlS"); u00100 : constant Version_32 := 16#f1f88835#; pragma Export (C, u00100, "system__img_lluB"); u00101 : constant Version_32 := 16#c9b6e082#; pragma Export (C, u00101, "system__img_lluS"); u00102 : constant Version_32 := 16#eef535cd#; pragma Export (C, u00102, "system__img_unsB"); u00103 : constant Version_32 := 16#1f8bdcb6#; pragma Export (C, u00103, "system__img_unsS"); u00104 : constant Version_32 := 16#4d5722f6#; pragma Export (C, u00104, "system__powten_tableS"); u00105 : constant Version_32 := 16#08ec0c09#; pragma Export (C, u00105, "liste_generiqueB"); u00106 : constant Version_32 := 16#97c69cab#; pragma Export (C, u00106, "liste_generiqueS"); u00107 : constant Version_32 := 16#ab2d7ed8#; pragma Export (C, u00107, "courbes__droitesB"); u00108 : constant Version_32 := 16#cf757770#; pragma Export (C, u00108, "courbes__droitesS"); u00109 : constant Version_32 := 16#6d4d969a#; pragma Export (C, u00109, "system__storage_poolsB"); u00110 : constant Version_32 := 16#e87cc305#; pragma Export (C, u00110, "system__storage_poolsS"); u00111 : constant Version_32 := 16#d8628a63#; pragma Export (C, u00111, "normalisationB"); u00112 : constant Version_32 := 16#7121c556#; pragma Export (C, u00112, "normalisationS"); u00113 : constant Version_32 := 16#7aa6c482#; pragma Export (C, u00113, "parser_svgB"); u00114 : constant Version_32 := 16#b3ea5ce2#; pragma Export (C, u00114, "parser_svgS"); u00115 : constant Version_32 := 16#12c24a43#; pragma Export (C, u00115, "ada__charactersS"); u00116 : constant Version_32 := 16#8f637df8#; pragma Export (C, u00116, "ada__characters__handlingB"); u00117 : constant Version_32 := 16#3b3f6154#; pragma Export (C, u00117, "ada__characters__handlingS"); u00118 : constant Version_32 := 16#4b7bb96a#; pragma Export (C, u00118, "ada__characters__latin_1S"); u00119 : constant Version_32 := 16#af50e98f#; pragma Export (C, u00119, "ada__stringsS"); u00120 : constant Version_32 := 16#e2ea8656#; pragma Export (C, u00120, "ada__strings__mapsB"); u00121 : constant Version_32 := 16#1e526bec#; pragma Export (C, u00121, "ada__strings__mapsS"); u00122 : constant Version_32 := 16#a87ab9e2#; pragma Export (C, u00122, "system__bit_opsB"); u00123 : constant Version_32 := 16#0765e3a3#; pragma Export (C, u00123, "system__bit_opsS"); u00124 : constant Version_32 := 16#92f05f13#; pragma Export (C, u00124, "ada__strings__maps__constantsS"); u00125 : constant Version_32 := 16#e18a47a0#; pragma Export (C, u00125, "ada__float_text_ioB"); u00126 : constant Version_32 := 16#e61b3c6c#; pragma Export (C, u00126, "ada__float_text_ioS"); u00127 : constant Version_32 := 16#d5f9759f#; pragma Export (C, u00127, "ada__text_io__float_auxB"); u00128 : constant Version_32 := 16#f854caf5#; pragma Export (C, u00128, "ada__text_io__float_auxS"); u00129 : constant Version_32 := 16#181dc502#; pragma Export (C, u00129, "ada__text_io__generic_auxB"); u00130 : constant Version_32 := 16#a6c327d3#; pragma Export (C, u00130, "ada__text_io__generic_auxS"); u00131 : constant Version_32 := 16#faa9a7b2#; pragma Export (C, u00131, "system__val_realB"); u00132 : constant Version_32 := 16#e30e3390#; pragma Export (C, u00132, "system__val_realS"); u00133 : constant Version_32 := 16#0be1b996#; pragma Export (C, u00133, "system__exn_llfB"); u00134 : constant Version_32 := 16#9ca35a6e#; pragma Export (C, u00134, "system__exn_llfS"); u00135 : constant Version_32 := 16#45525895#; pragma Export (C, u00135, "system__fat_fltS"); u00136 : constant Version_32 := 16#e5480ede#; pragma Export (C, u00136, "ada__strings__fixedB"); u00137 : constant Version_32 := 16#a86b22b3#; pragma Export (C, u00137, "ada__strings__fixedS"); u00138 : constant Version_32 := 16#3bc8a117#; pragma Export (C, u00138, "ada__strings__searchB"); u00139 : constant Version_32 := 16#c1ab8667#; pragma Export (C, u00139, "ada__strings__searchS"); u00140 : constant Version_32 := 16#f78329ae#; pragma Export (C, u00140, "ada__strings__unboundedB"); u00141 : constant Version_32 := 16#e303cf90#; pragma Export (C, u00141, "ada__strings__unboundedS"); u00142 : constant Version_32 := 16#5b9edcc4#; pragma Export (C, u00142, "system__compare_array_unsigned_8B"); u00143 : constant Version_32 := 16#b424350c#; pragma Export (C, u00143, "system__compare_array_unsigned_8S"); u00144 : constant Version_32 := 16#5f72f755#; pragma Export (C, u00144, "system__address_operationsB"); u00145 : constant Version_32 := 16#0e2bfab2#; pragma Export (C, u00145, "system__address_operationsS"); u00146 : constant Version_32 := 16#6a859064#; pragma Export (C, u00146, "system__storage_pools__subpoolsB"); u00147 : constant Version_32 := 16#e3b008dc#; pragma Export (C, u00147, "system__storage_pools__subpoolsS"); u00148 : constant Version_32 := 16#57a37a42#; pragma Export (C, u00148, "system__address_imageB"); u00149 : constant Version_32 := 16#bccbd9bb#; pragma Export (C, u00149, "system__address_imageS"); u00150 : constant Version_32 := 16#b5b2aca1#; pragma Export (C, u00150, "system__finalization_mastersB"); u00151 : constant Version_32 := 16#69316dc1#; pragma Export (C, u00151, "system__finalization_mastersS"); u00152 : constant Version_32 := 16#7268f812#; pragma Export (C, u00152, "system__img_boolB"); u00153 : constant Version_32 := 16#e8fe356a#; pragma Export (C, u00153, "system__img_boolS"); u00154 : constant Version_32 := 16#d7aac20c#; pragma Export (C, u00154, "system__ioB"); u00155 : constant Version_32 := 16#8365b3ce#; pragma Export (C, u00155, "system__ioS"); u00156 : constant Version_32 := 16#63f11652#; pragma Export (C, u00156, "system__storage_pools__subpools__finalizationB"); u00157 : constant Version_32 := 16#fe2f4b3a#; pragma Export (C, u00157, "system__storage_pools__subpools__finalizationS"); u00158 : constant Version_32 := 16#afc64758#; pragma Export (C, u00158, "system__atomic_countersB"); u00159 : constant Version_32 := 16#d05bd04b#; pragma Export (C, u00159, "system__atomic_countersS"); u00160 : constant Version_32 := 16#f4e1c091#; pragma Export (C, u00160, "system__stream_attributesB"); u00161 : constant Version_32 := 16#221dd20d#; pragma Export (C, u00161, "system__stream_attributesS"); u00162 : constant Version_32 := 16#f08789ae#; pragma Export (C, u00162, "ada__text_io__enumeration_auxB"); u00163 : constant Version_32 := 16#52f1e0af#; pragma Export (C, u00163, "ada__text_io__enumeration_auxS"); u00164 : constant Version_32 := 16#d0432c8d#; pragma Export (C, u00164, "system__img_enum_newB"); u00165 : constant Version_32 := 16#7c6b4241#; pragma Export (C, u00165, "system__img_enum_newS"); u00166 : constant Version_32 := 16#4b37b589#; pragma Export (C, u00166, "system__val_enumB"); u00167 : constant Version_32 := 16#a63d0614#; pragma Export (C, u00167, "system__val_enumS"); u00168 : constant Version_32 := 16#2261c2e2#; pragma Export (C, u00168, "stlB"); u00169 : constant Version_32 := 16#96280b15#; pragma Export (C, u00169, "stlS"); u00170 : constant Version_32 := 16#84ad4a42#; pragma Export (C, u00170, "ada__numericsS"); u00171 : constant Version_32 := 16#03e83d1c#; pragma Export (C, u00171, "ada__numerics__elementary_functionsB"); u00172 : constant Version_32 := 16#00443200#; pragma Export (C, u00172, "ada__numerics__elementary_functionsS"); u00173 : constant Version_32 := 16#3e0cf54d#; pragma Export (C, u00173, "ada__numerics__auxB"); u00174 : constant Version_32 := 16#9f6e24ed#; pragma Export (C, u00174, "ada__numerics__auxS"); u00175 : constant Version_32 := 16#129c3f4f#; pragma Export (C, u00175, "system__machine_codeS"); u00176 : constant Version_32 := 16#9d39c675#; pragma Export (C, u00176, "system__memoryB"); u00177 : constant Version_32 := 16#445a22b5#; pragma Export (C, u00177, "system__memoryS"); -- BEGIN ELABORATION ORDER -- ada%s -- ada.characters%s -- ada.characters.handling%s -- ada.characters.latin_1%s -- ada.command_line%s -- interfaces%s -- system%s -- system.address_operations%s -- system.address_operations%b -- system.atomic_counters%s -- system.atomic_counters%b -- system.case_util%s -- system.case_util%b -- system.exn_llf%s -- system.exn_llf%b -- system.float_control%s -- system.float_control%b -- system.htable%s -- system.img_bool%s -- system.img_bool%b -- system.img_enum_new%s -- system.img_enum_new%b -- system.img_int%s -- system.img_int%b -- system.img_real%s -- system.io%s -- system.io%b -- system.machine_code%s -- system.parameters%s -- system.parameters%b -- system.crtl%s -- interfaces.c_streams%s -- interfaces.c_streams%b -- system.powten_table%s -- system.standard_library%s -- system.exceptions_debug%s -- system.exceptions_debug%b -- system.storage_elements%s -- system.storage_elements%b -- system.stack_checking%s -- system.stack_checking%b -- system.string_hash%s -- system.string_hash%b -- system.htable%b -- system.strings%s -- system.strings%b -- system.os_lib%s -- system.traceback_entries%s -- system.traceback_entries%b -- ada.exceptions%s -- system.soft_links%s -- system.unsigned_types%s -- system.fat_flt%s -- system.fat_llf%s -- system.img_llu%s -- system.img_llu%b -- system.img_uns%s -- system.img_uns%b -- system.img_real%b -- system.val_enum%s -- system.val_llu%s -- system.val_real%s -- system.val_util%s -- system.val_util%b -- system.val_real%b -- system.val_llu%b -- system.val_enum%b -- system.wch_con%s -- system.wch_con%b -- system.wch_cnv%s -- system.wch_jis%s -- system.wch_jis%b -- system.wch_cnv%b -- system.wch_stw%s -- system.wch_stw%b -- ada.exceptions.last_chance_handler%s -- ada.exceptions.last_chance_handler%b -- system.address_image%s -- system.bit_ops%s -- system.bit_ops%b -- system.compare_array_unsigned_8%s -- system.compare_array_unsigned_8%b -- system.concat_2%s -- system.concat_2%b -- system.concat_3%s -- system.concat_3%b -- system.concat_4%s -- system.concat_4%b -- system.concat_5%s -- system.concat_5%b -- system.concat_6%s -- system.concat_6%b -- system.concat_7%s -- system.concat_7%b -- system.exception_table%s -- system.exception_table%b -- ada.io_exceptions%s -- ada.numerics%s -- ada.numerics.aux%s -- ada.numerics.aux%b -- ada.numerics.elementary_functions%s -- ada.numerics.elementary_functions%b -- ada.strings%s -- ada.strings.maps%s -- ada.strings.fixed%s -- ada.strings.maps.constants%s -- ada.strings.search%s -- ada.strings.search%b -- ada.tags%s -- ada.streams%s -- ada.streams%b -- interfaces.c%s -- system.exceptions%s -- system.exceptions%b -- system.exceptions.machine%s -- system.file_control_block%s -- system.file_io%s -- system.finalization_root%s -- system.finalization_root%b -- ada.finalization%s -- ada.finalization%b -- system.storage_pools%s -- system.storage_pools%b -- system.finalization_masters%s -- system.storage_pools.subpools%s -- system.storage_pools.subpools.finalization%s -- system.storage_pools.subpools.finalization%b -- system.stream_attributes%s -- system.stream_attributes%b -- system.memory%s -- system.memory%b -- system.standard_library%b -- system.secondary_stack%s -- system.storage_pools.subpools%b -- system.finalization_masters%b -- system.file_io%b -- interfaces.c%b -- ada.tags%b -- ada.strings.fixed%b -- ada.strings.maps%b -- system.soft_links%b -- system.os_lib%b -- ada.command_line%b -- ada.characters.handling%b -- system.secondary_stack%b -- system.address_image%b -- ada.strings.unbounded%s -- ada.strings.unbounded%b -- system.traceback%s -- ada.exceptions%b -- system.traceback%b -- ada.text_io%s -- ada.text_io%b -- ada.text_io.enumeration_aux%s -- ada.text_io.float_aux%s -- ada.float_text_io%s -- ada.float_text_io%b -- ada.text_io.generic_aux%s -- ada.text_io.generic_aux%b -- ada.text_io.float_aux%b -- ada.text_io.enumeration_aux%b -- liste_generique%s -- liste_generique%b -- vecteurs%s -- vecteurs%b -- math%s -- math%b -- courbes%s -- courbes.droites%s -- courbes.droites%b -- normalisation%s -- normalisation%b -- parser_svg%s -- parser_svg%b -- stl%s -- stl%b -- main%b -- END ELABORATION ORDER end ada_main;
example/example.asm
master-g/childhood
1
82068
<filename>example/example.asm<gh_stars>1-10 ; freemco NES Corelib Example 00: Skeleton Project (NROM) ;==============================================================================; ; The skeleton project targets NROM, as the examples are meant to be small. ; Whether or not that's NROM-128 or NROM-256 is up to the example. ; Other examples may need to use a different mapper. ; This skeleton project makes a few assumptions that you might have to change ; when developing for other mappers. ;==============================================================================; ; iNES header (NROM-128) .include "NROM-128.asm" ; defines .include "nes.inc" ; NES hardware defines .include "ram.inc" ; program RAM defines ;==============================================================================; ; program code ; .org $8000 ; starting point for NROM-256 .org $C000 ; starting point for NROM-128 .include "sound.asm" ;==============================================================================; ; NMI NMI: ; save registers pha ; 1) push A txa pha ; 2) push X tya pha ; 3) push Y ; "proper" NMI code belongs here. lda #$00 sta OAM_ADDR ; set the low byte (00) of the RAM address lda #$02 sta OAM_DMA ; set the high byte (02) of the RAM address, start the transfer ; At the same time that we strobe bit 0, we initialize the ring counter ; so we're hitting two birds with one stone here ReadJoyStick: lda #$01 ; While the strobe bit is set, buttons will be continuously reloaded. ; This means that reading from JOYSTICK1 will only return the state of the ; first button: button A. sta JOYSTICK1 sta buttons lsr a ; now A is 0 ; By storing 0 into JOYSTICK1, the strobe bit is cleared and the reloading stops. ; This allows all 8 buttons (newly reloaded) to be read from JOYSTICK1. sta JOYSTICK1 ReadJoyStickLoop: lda JOYSTICK1 lsr a ; bit0 -> Carry rol buttons ; Carry -> bit0; bit 7 -> Carry bcc ReadJoyStickLoop CheckButtonLeft: lda buttons and #PAD_LEFT beq CheckButtonRight ldx #$00 MoveLeftLoop: lda $0203, x sec sbc #$01 sta $0203, x inx inx inx inx cpx #$10 bne MoveLeftLoop CheckButtonRight: lda buttons and #PAD_RIGHT beq CheckButtonSelect ldx #$00 MoveRightLoop: lda $0203, x clc adc #$01 sta $0203, x inx inx inx inx cpx #$10 bne MoveRightLoop CheckButtonSelect: lda buttons and #PAD_SELECT beq CheckButtonEnd ldx #$00 ChangePaletteLoop: lda $0202, x clc adc #$01 cmp #$04 bne SelectPalette lda #$00 SelectPalette: sta $0202, x inx inx inx inx cpx #$10 bne ChangePaletteLoop CheckButtonEnd: ; This is the PPU clean up section ; so rendering the next frame starts properly lda #%10010000 ; enable NMI, sprites, background from Pattern Table 0 and 1 sta PPU_CTRL lda #%00011110 ; enable sprites, background, no clipping on left side sta PPU_MASK lda #$00 ; tell PPU there is no background scrolling sta PPU_SCROLL sta PPU_SCROLL NMI_end: ; restore registers pla ; 3) pull Y tay pla ; 2) pull X tax pla ; 1) pull A rti ;==============================================================================; ; IRQ ; The IRQ is rarely used in simple mapper situations (such as NROM), but IRQs ; can be toggled via the NES's APU. The skeleton example does not use it. IRQ: rti ;==============================================================================; ; Reset ; Handles NES initialization Reset: sei ; disable IRQs cld ; clear decimal mode ldx #$40 stx APU_FRAMECOUNT ; disable APU frame IRQ ldx #$FF txs ; set up stack at $01FF inx ; (X is now $00) stx PPU_CTRL ; disable NMIs stx PPU_MASK ; disable rendering stx APU_DMC_FREQ ; disable DMC IRQs ; if you're using a mapper, you should probably initialize it here. bit PPU_STATUS ; wait for 1st vblank @waitVBLANK1: bit PPU_STATUS bpl @waitVBLANK1 @clearRAM lda #$00 sta $0000, x sta $0100, x sta $0400, x sta $0500, x sta $0600, x sta $0700, x lda #$FE sta $0300, x inx bne @clearRAM ; at this point, you can start setting up your program. ; after setting up your program, wait for the 2nd vblank @waitVBLANK2: bit PPU_STATUS bpl @waitVBLANK2 ; perform final commands (setting up PPU) LoadPalettes: lda PPU_STATUS ; read PPU status to reset the high/low latch lda #$3F sta PPU_ADDR ; write the high byte of $3F00 address lda #$00 sta PPU_ADDR ; write the low byte of $3F00 address ; PPU_DATA is now ready to accept data ldx #$00 ; start out at 0 LoadPaletteLoop: lda palette, x ; load data from address (palette + the value in x) ; 1st time through loop it will load palette+0 ; 2nd time through loop it will load palette+1 ; 3rd time through loop it will load palette+2 ; etc sta PPU_DATA ; write to PPU inx ; X = X + 1 cpx #$20 ; Compare X to hex $10, decimal 16 bne LoadPaletteLoop LoadSprites: ldx #$00 ; start at 0 LoadSpritesLoop: lda sprites, x ; load data from address (sprites + x) sta $0200, x ; store into RAM address ($200 + x) inx cpx #$10 bne LoadSpritesLoop LoadBackground: lda PPU_STATUS ; read PPU status to reset the high/low latch lda #$20 sta PPU_ADDR lda #$00 sta PPU_ADDR ldx #$00 LoadBackgroundLoop: lda background, x sta PPU_DATA inx cpx #$80 bne LoadBackgroundLoop LoadAttribute: lda PPU_STATUS lda #$23 sta PPU_ADDR lda #$C0 sta PPU_ADDR ldx #$00 LoadAttributeLoop: lda attribute, x sta PPU_DATA inx cpx #$10 bne LoadAttributeLoop lda #%10010000 ; enable NMI ; sprites from Pattern Table 0 ; background from Pattern Table 1 sta PPU_CTRL lda #%00011110 ; enable sprites, background, no clipping on left side sta PPU_MASK ; and then run your program's main loop. MainLoop: jmp MainLoop ;==============================================================================; ; background palette .org $E000 palette: ; background palette .db $22,$29,$1A,$0F .db $22,$36,$17,$0F .db $22,$30,$21,$0F .db $22,$27,$17,$0F ; sprite palette .db $22,$16,$27,$18 ; mario .db $22,$30,$27,$19 ; luigi .db $22,$37,$27,$16 ; fire .db $22,$1A,$30,$27 ; bowser sprites: ; vert tile attr horiz .db $80, $32, $00, $80 ; sprite 0 .db $80, $33, $00, $88 ; sprite 1 .db $88, $34, $00, $80 ; sprite 2 .db $88, $35, $00, $88 ; sprite 3 background: .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;row 1 .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;all sky .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;row 2 .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;all sky .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;row 1 .db $24,$24,$24,$24,$24,$24,$24,$24,$36,$37,$24,$24,$24,$24,$24,$24 ;;all sky .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;row 2 .db $24,$24,$24,$24,$24,$24,$24,$35,$25,$25,$38,$24,$24,$24,$24,$24 ;;all sky .db $24,$24,$24,$24,$45,$45,$24,$24,$45,$45,$45,$45,$45,$45,$24,$24 ;;row 3 .db $24,$24,$24,$24,$24,$24,$24,$39,$3A,$3B,$3C,$24,$53,$54,$24,$24 ;;some brick tops .db $24,$24,$24,$24,$47,$47,$24,$24,$47,$47,$47,$47,$47,$47,$24,$24 ;;row 4 .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$55,$56,$24,$24 ;;brick bottoms .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;row 1 .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;all sky .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;row 2 .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24 ;;all sky attribute: .db %00000000, %00000000, %00000000, %00000000, %00000000, %10000000, %10100000, %00000000 .db %00000000, %00000010, %00000101, %00000001, %00000000, %00001000, %00001010, %00000011 .db $24,$24,$24,$24, $47,$47,$24,$24 ,$47,$47,$47,$47, $47,$47,$24,$24 .db $24,$24,$24,$24 ,$24,$24,$24,$24, $24,$24,$24,$24, $55,$56,$24,$24 ;==============================================================================; ; Vectors .org $FFFA .dw NMI .dw Reset .dw IRQ ;==============================================================================; ; CHR-ROM (if needed) .incbin "mario.chr"
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0x48.log_21829_2149.asm
ljhsiun2/medusa
9
20604
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x18484, %rsi lea addresses_normal_ht+0x1db3a, %rdi nop nop nop nop cmp $10706, %rbp mov $73, %rcx rep movsb xor $20016, %r9 lea addresses_WT_ht+0x1dbc4, %rsi lea addresses_WT_ht+0x6d20, %rdi nop xor $53273, %r15 mov $63, %rcx rep movsw nop add %rsi, %rsi lea addresses_A_ht+0x2244, %r15 nop cmp %r14, %r14 movups (%r15), %xmm4 vpextrq $1, %xmm4, %rcx nop and %rsi, %rsi lea addresses_WC_ht+0xbf20, %rdi nop cmp $65015, %r9 mov (%rdi), %rbp nop and %rdi, %rdi lea addresses_WC_ht+0xed94, %rsi lea addresses_WC_ht+0x2814, %rdi nop nop nop nop nop sub $16676, %rdx mov $38, %rcx rep movsl nop nop nop nop nop add $35991, %r9 lea addresses_A_ht+0x7814, %r9 nop add $12458, %rdi movw $0x6162, (%r9) inc %rbp lea addresses_WC_ht+0x4614, %rbp nop nop nop nop nop xor %rdx, %rdx and $0xffffffffffffffc0, %rbp movntdqa (%rbp), %xmm1 vpextrq $0, %xmm1, %rdi inc %r9 lea addresses_WC_ht+0x16914, %rdx sub %rcx, %rcx movl $0x61626364, (%rdx) nop nop nop nop add $46186, %rdx lea addresses_WC_ht+0x16f94, %rsi lea addresses_UC_ht+0xc814, %rdi and $7030, %r9 mov $36, %rcx rep movsq nop inc %rsi lea addresses_UC_ht+0x1d1d4, %rcx nop nop nop nop sub %rdx, %rdx movl $0x61626364, (%rcx) nop add %rbp, %rbp lea addresses_WT_ht+0xe694, %r14 cmp $30591, %rbp mov (%r14), %r15w nop sub %rdi, %rdi lea addresses_UC_ht+0x10014, %rsi lea addresses_A_ht+0x6a94, %rdi nop nop cmp %r9, %r9 mov $75, %rcx rep movsq nop nop nop xor %rbp, %rbp lea addresses_normal_ht+0x7568, %rbp nop nop nop nop sub $11767, %r15 mov $0x6162636465666768, %rdx movq %rdx, %xmm5 movups %xmm5, (%rbp) nop nop add $56766, %rdi lea addresses_WT_ht+0x6a14, %rsi lea addresses_UC_ht+0x7a84, %rdi clflush (%rdi) add %r14, %r14 mov $75, %rcx rep movsq nop nop nop nop inc %rcx lea addresses_UC_ht+0x1dcd0, %rsi lea addresses_A_ht+0x1ae30, %rdi nop sub %r9, %r9 mov $57, %rcx rep movsb nop nop and $47682, %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r15 pop %r14 ret .global s_faulty_load s_faulty_load: push %r15 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi // Store lea addresses_RW+0x197ca, %rbp nop nop nop nop add $60063, %rsi mov $0x5152535455565758, %r15 movq %r15, (%rbp) nop nop nop nop nop xor $25934, %rbx // Store lea addresses_UC+0x10014, %r15 nop nop nop nop cmp %rdi, %rdi mov $0x5152535455565758, %rsi movq %rsi, %xmm6 movntdq %xmm6, (%r15) and %rbp, %rbp // Store lea addresses_normal+0x2414, %rdi nop nop nop nop inc %rax movb $0x51, (%rdi) nop nop add %rax, %rax // Faulty Load lea addresses_UC+0x10014, %rax add $47734, %rcx mov (%rax), %r15 lea oracles, %rbp and $0xff, %r15 shlq $12, %r15 mov (%rbp,%r15,1), %r15 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r15 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': True}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 10, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 9, 'size': 16, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 1, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
oeis/142/A142195.asm
neoneye/loda-programs
11
8608
; A142195: Primes congruent to 31 mod 40. ; Submitted by <NAME> ; 31,71,151,191,271,311,431,631,751,911,991,1031,1151,1231,1471,1511,1831,1871,1951,2111,2311,2351,2551,2591,2671,2711,2791,3191,3271,3391,3511,3631,3671,3911,4111,4231,4271,4391,4591,4751,4831,4871,4951,5231,5351,5431,5471,5591,5711,5791,6151,6271,6311,6551,6791,6871,6911,6991,7151,7351,7591,7951,8111,8191,8231,8311,8431,8831,8951,9151,9311,9391,9431,9511,9551,9631,9791,9871,10111,10151,10271,10391,10631,10711,10831,11071,11311,11351,11471,11551,11831,12071,12391,12511,12671,12791,12911,13151 mov $2,$0 pow $2,2 lpb $2 add $1,30 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,10 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 sub $2,1 lpe mov $0,$1 add $0,31
src/fltk-widgets-buttons-enter.adb
micahwelf/FLTK-Ada
1
7482
with Interfaces.C, System; use type System.Address; package body FLTK.Widgets.Buttons.Enter is procedure return_button_set_draw_hook (W, D : in System.Address); pragma Import (C, return_button_set_draw_hook, "return_button_set_draw_hook"); pragma Inline (return_button_set_draw_hook); procedure return_button_set_handle_hook (W, H : in System.Address); pragma Import (C, return_button_set_handle_hook, "return_button_set_handle_hook"); pragma Inline (return_button_set_handle_hook); function new_fl_return_button (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) return System.Address; pragma Import (C, new_fl_return_button, "new_fl_return_button"); pragma Inline (new_fl_return_button); procedure free_fl_return_button (B : in System.Address); pragma Import (C, free_fl_return_button, "free_fl_return_button"); pragma Inline (free_fl_return_button); procedure fl_return_button_draw (W : in System.Address); pragma Import (C, fl_return_button_draw, "fl_return_button_draw"); pragma Inline (fl_return_button_draw); function fl_return_button_handle (W : in System.Address; E : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_return_button_handle, "fl_return_button_handle"); pragma Inline (fl_return_button_handle); procedure Finalize (This : in out Enter_Button) is begin if This.Void_Ptr /= System.Null_Address and then This in Enter_Button'Class then free_fl_return_button (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; Finalize (Button (This)); end Finalize; package body Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Enter_Button is begin return This : Enter_Button do This.Void_Ptr := new_fl_return_button (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.To_C (Text)); fl_widget_set_user_data (This.Void_Ptr, Widget_Convert.To_Address (This'Unchecked_Access)); return_button_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); return_button_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); end return; end Create; end Forge; procedure Draw (This : in out Enter_Button) is begin fl_return_button_draw (This.Void_Ptr); end Draw; function Handle (This : in out Enter_Button; Event : in Event_Kind) return Event_Outcome is begin return Event_Outcome'Val (fl_return_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); end Handle; end FLTK.Widgets.Buttons.Enter;
Control/Monad/Free.agda
oisdk/agda-playground
6
4071
<filename>Control/Monad/Free.agda {-# OPTIONS --allow-unsolved-metas #-} module Control.Monad.Free where open import Prelude data Free (F : Type a → Type a) (A : Type a) : Type (ℓsuc a) where lift : F A → Free F A return : A → Free F A _>>=_ : Free F B → (B → Free F A) → Free F A >>=-idˡ : isSet A → (f : B → Free F A) (x : B) → (return x >>= f) ≡ f x >>=-idʳ : isSet A → (x : Free F A) → (x >>= return) ≡ x >>=-assoc : isSet A → (xs : Free F C) (f : C → Free F B) (g : B → Free F A) → ((xs >>= f) >>= g) ≡ (xs >>= (λ x → f x >>= g)) trunc : isSet A → isSet (Free F A) data FreeF (F : Type a → Type a) (P : ∀ {T} → Free F T → Type b) (A : Type a) : Type (ℓsuc a ℓ⊔ b) where liftF : F A → FreeF F P A returnF : A → FreeF F P A bindF : (xs : Free F B) (P⟨xs⟩ : P xs) (k : B → Free F A) (P⟨∘k⟩ : ∀ x → P (k x)) → FreeF F P A private variable F : Type a → Type a G : Type b → Type b p : Level P : ∀ {T} → Free F T → Type p ⟪_⟫ : FreeF F P A → Free F A ⟪ liftF x ⟫ = lift x ⟪ returnF x ⟫ = return x ⟪ bindF xs P⟨xs⟩ k P⟨∘k⟩ ⟫ = xs >>= k Alg : (F : Type a → Type a) (P : ∀ {T} → Free F T → Type b) → Type _ Alg F P = ∀ {A} → (xs : FreeF F P A) → P ⟪ xs ⟫ record Coherent {a p} {F : Type a → Type a} {P : ∀ {T} → Free F T → Type p} (ψ : Alg F P) : Type (ℓsuc a ℓ⊔ p) where field c-set : ∀ {T} → isSet T → ∀ xs → isSet (P {T = T} xs) -- possibly needs to be isSet T → isSet (P {T = T} xs) c->>=idˡ : ∀ (isb : isSet B) (f : A → Free F B) Pf x → ψ (bindF (return x) (ψ (returnF x)) f Pf) ≡[ i ≔ P (>>=-idˡ isb f x i) ]≡ Pf x c->>=idʳ : ∀ (isa : isSet A) (x : Free F A) Px → ψ (bindF x Px return (λ y → ψ (returnF y))) ≡[ i ≔ P (>>=-idʳ isa x i) ]≡ Px c->>=assoc : ∀ (isa : isSet A) (xs : Free F C) Pxs (f : C → Free F B) Pf (g : B → Free F A) Pg → ψ (bindF (xs >>= f) (ψ (bindF xs Pxs f Pf)) g Pg) ≡[ i ≔ P (>>=-assoc isa xs f g i) ]≡ ψ (bindF xs Pxs (λ x → f x >>= g) λ x → ψ (bindF (f x) (Pf x) g Pg)) open Coherent public Ψ : (F : Type a → Type a) (P : ∀ {T} → Free F T → Type p) → Type _ Ψ F P = Σ (Alg F P) Coherent infixr 1 Ψ syntax Ψ F (λ v → e) = Ψ[ v ⦂ F * ] ⇒ e Φ : (Type a → Type a) → Type b → Type _ Φ A B = Ψ A (λ _ → B) ⟦_⟧ : Ψ F P → (xs : Free F A) → P xs ⟦ alg ⟧ (lift x) = alg .fst (liftF x) ⟦ alg ⟧ (return x) = alg .fst (returnF x) ⟦ alg ⟧ (xs >>= k) = alg .fst (bindF xs (⟦ alg ⟧ xs) k (⟦ alg ⟧ ∘ k)) ⟦ alg ⟧ (>>=-idˡ iss f k i) = alg .snd .c->>=idˡ iss f (⟦ alg ⟧ ∘ f) k i ⟦ alg ⟧ (>>=-idʳ iss xs i) = alg .snd .c->>=idʳ iss xs (⟦ alg ⟧ xs) i ⟦ alg ⟧ (>>=-assoc iss xs f g i) = alg .snd .c->>=assoc iss xs (⟦ alg ⟧ xs) f (⟦ alg ⟧ ∘ f) g (⟦ alg ⟧ ∘ g) i ⟦ alg ⟧ (trunc AIsSet xs ys p q i j) = isOfHLevel→isOfHLevelDep 2 (alg .snd .c-set AIsSet) (⟦ alg ⟧ xs) (⟦ alg ⟧ ys) (cong ⟦ alg ⟧ p) (cong ⟦ alg ⟧ q) (trunc AIsSet xs ys p q) i j prop-coh : {alg : Alg F P} → (∀ {T} → isSet T → ∀ xs → isProp (P {T} xs)) → Coherent alg prop-coh P-isProp .c-set TIsSet xs = isProp→isSet (P-isProp TIsSet xs) prop-coh {P = P} P-isProp .c->>=idˡ iss f Pf x = toPathP (P-isProp iss (f x) (transp (λ i → P (>>=-idˡ iss f x i)) i0 _) _) prop-coh {P = P} P-isProp .c->>=idʳ iss x Px = toPathP (P-isProp iss x (transp (λ i → P (>>=-idʳ iss x i)) i0 _) _) prop-coh {P = P} P-isProp .c->>=assoc iss xs Pxs f Pf g Pg = toPathP (P-isProp iss (xs >>= (λ x → f x >>= g)) (transp (λ i → P (>>=-assoc iss xs f g i)) i0 _) _) -- infix 4 _⊜_ -- record AnEquality (F : Type a → Type a) (A : Type a) : Type (ℓsuc a) where -- constructor _⊜_ -- field lhs rhs : Free F A -- open AnEquality public -- EqualityProof-Alg : (F : Type a → Type a) (P : ∀ {A} → Free F A → AnEquality G A) → Type _ -- EqualityProof-Alg F P = Alg F (λ xs → let Pxs = P xs in lhs Pxs ≡ rhs Pxs) -- eq-coh : {P : ∀ {A} → Free F A → AnEquality G A} {alg : EqualityProof-Alg F P} → Coherent alg -- eq-coh {P = P} = prop-coh λ xs → let Pxs = P xs in trunc (lhs Pxs) (rhs Pxs) open import Algebra module _ {F : Type a → Type a} where freeMonad : SetMonad a (ℓsuc a) freeMonad .SetMonad.𝐹 = Free F freeMonad .SetMonad.isSetMonad .IsSetMonad._>>=_ = _>>=_ freeMonad .SetMonad.isSetMonad .IsSetMonad.return = return freeMonad .SetMonad.isSetMonad .IsSetMonad.>>=-idˡ = >>=-idˡ freeMonad .SetMonad.isSetMonad .IsSetMonad.>>=-idʳ = >>=-idʳ freeMonad .SetMonad.isSetMonad .IsSetMonad.>>=-assoc = >>=-assoc freeMonad .SetMonad.isSetMonad .IsSetMonad.trunc = trunc module _ {ℓ} (mon : SetMonad ℓ ℓ) where module F = SetMonad mon open F using (𝐹) module _ {G : Type ℓ → Type ℓ} (h : ∀ {T} → G T → 𝐹 T) where ⟦_⟧′ : Free G A → 𝐹 A ⟦ lift x ⟧′ = h x ⟦ return x ⟧′ = F.return x ⟦ xs >>= k ⟧′ = ⟦ xs ⟧′ F.>>= λ x → ⟦ k x ⟧′ ⟦ >>=-idˡ iss f x i ⟧′ = F.>>=-idˡ iss (⟦_⟧′ ∘ f) x i ⟦ >>=-idʳ iss xs i ⟧′ = F.>>=-idʳ iss ⟦ xs ⟧′ i ⟦ >>=-assoc iss xs f g i ⟧′ = F.>>=-assoc iss ⟦ xs ⟧′ (⟦_⟧′ ∘ f) (⟦_⟧′ ∘ g) i ⟦ trunc iss xs ys p q i j ⟧′ = isOfHLevel→isOfHLevelDep 2 (λ xs → F.trunc iss) ⟦ xs ⟧′ ⟦ ys ⟧′ (cong ⟦_⟧′ p) (cong ⟦_⟧′ q) (trunc iss xs ys p q) i j module _ (hom : SetMonadHomomorphism freeMonad {F = G} ⟶ mon) where module Hom = SetMonadHomomorphism_⟶_ hom open Hom using (f) uniq-alg : (inv : ∀ {A : Type _} → (x : G A) → f (lift x) ≡ h x) → Ψ[ xs ⦂ G * ] ⇒ ⟦ xs ⟧′ ≡ f xs uniq-alg inv .snd = prop-coh λ iss xs → F.trunc iss _ _ uniq-alg inv .fst (liftF x) = sym (inv x) uniq-alg inv .fst (returnF x) = sym (Hom.return-homo x) uniq-alg inv .fst (bindF xs P⟨xs⟩ k P⟨∘k⟩) = cong₂ F._>>=_ P⟨xs⟩ (funExt P⟨∘k⟩) ; Hom.>>=-homo xs k uniq : (inv : ∀ {A : Type _} → (x : G A) → f (lift x) ≡ h x) → (xs : Free G A) → ⟦ xs ⟧′ ≡ f xs uniq inv = ⟦ uniq-alg inv ⟧ open import Cubical.Foundations.HLevels using (isSetΠ) module _ {ℓ} (fun : Functor ℓ ℓ) where open Functor fun using (map; 𝐹) module _ {B : Type ℓ} (BIsSet : isSet B) where cata-alg : (𝐹 B → B) → Ψ 𝐹 λ {T} _ → (T → B) → B cata-alg ϕ .fst (liftF x) h = ϕ (map h x) cata-alg ϕ .fst (returnF x) h = h x cata-alg ϕ .fst (bindF _ P⟨xs⟩ _ P⟨∘k⟩) h = P⟨xs⟩ (flip P⟨∘k⟩ h) cata-alg ϕ .snd .c-set _ _ = isSetΠ λ _ → BIsSet cata-alg ϕ .snd .c->>=idˡ isb f Pf x = refl cata-alg ϕ .snd .c->>=idʳ isa x Px = refl cata-alg ϕ .snd .c->>=assoc isa xs Pxs f Pf g Pg = refl cata : (A → B) → (𝐹 B → B) → Free 𝐹 A → B cata h ϕ xs = ⟦ cata-alg ϕ ⟧ xs h _>>_ : Free F A → Free F B → Free F B xs >> ys = xs >>= const ys
Application2.2.asm
abdalmoez/applications-on-gnusim-8085
0
242670
;<Add 2 numbers 16bits> LHLD number1 XCHG LHLD number2 MVI C,00 DAD D JNC AHEAD INR C AHEAD: SHLD result MOV A,C STA carry HLT number1: db 255,70 number2: db 255,200 result: db 0,0 carry: db 0
examples/UnSized/SelfRef.agda
agda/ooAgda
23
14787
<filename>examples/UnSized/SelfRef.agda module UnSized.SelfRef where open import Data.Unit.Base open import Data.Product open import Data.String.Base open import Data.Sum using (_⊎_) renaming (inj₁ to inl; inj₂ to inr) open import Size --open import SimpleCell open import SizedIO.Object open import SizedIO.IOObject open import SizedIO.ConsoleObject -- open import PrimTypeHelpersSmall open import UnSizedIO.Base hiding (main) open import UnSizedIO.Console hiding (main) open import NativeIO --open import SimpleCell -- Object Alpha data AlphaMethod A : Set where print : AlphaMethod A set : A → AlphaMethod A m1 : AlphaMethod A m2 : AlphaMethod A AlphaResponses : {A : Set} (c : AlphaMethod A) → Set AlphaResponses _ = ⊤ alphaI : (A : Set) → Interface Method (alphaI A) = AlphaMethod A Result (alphaI A) m = AlphaResponses m alphaC : (i : Size) → Set alphaC i = ConsoleObject i (alphaI String) -- -- Self Referential: method 'm1' calls method 'm2' -- {- -- {-# NON_TERMINATING #-} alphaO : ∀{i} (s : String) → alphaC i method (alphaO s) print = exec (putStrLn s) >> return (_ , alphaO s) method (alphaO s) (set x) = return (_ , alphaO x) -- force (method (alphaO s) m1) = exec (putStrLn s) λ _ → -- method (alphaO s) m2 >>= λ{ (_ , c₀) → -- return (_ , c₀) } method (alphaO s) m1 = exec1 (putStrLn s) >> method (alphaO s) m2 >>= λ{ (_ , c₀) → return (_ , c₀) } method (alphaO s) m2 = return (_ , alphaO (s ++ "->m2")) program : String → IOConsole ∞ Unit program arg = let c₀ = alphaO ("start̄\n====\n\n") in method c₀ m1 >>= λ{ (_ , c₁) → --- ===> m1 called, but m2 prints out text method c₁ print >>= λ{ (_ , c₂) → exec1 (putStrLn "\n\n====\nend") }} main : NativeIO Unit main = translateIOConsole (program "") -}
src/Similarity/Weak/Up-to.agda
nad/up-to
0
10318
<filename>src/Similarity/Weak/Up-to.agda ------------------------------------------------------------------------ -- An up-to technique for weak similarity ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Labelled-transition-system module Similarity.Weak.Up-to {ℓ} (lts : LTS ℓ) where open import Logical-equivalence using (_⇔_) open import Prelude open import Prelude.Size open import Equational-reasoning open import Expansion lts using (Expansion) open import Relation open import Similarity.Weak lts import Similarity.Weak.Equational-reasoning-instances import Up-to open LTS lts ------------------------------------------------------------------------ -- The general up-to machinery, instantiated with the StepC container open Up-to StepC public ------------------------------------------------------------------------ -- An example -- Up to expansion to the left and weak similarity to the right. -- -- This is a generalisation of the non-symmetric up-to technique -- presented by <NAME> Sangiorgi in Section 6.5.2.4 of "Enhancements -- of the bisimulation proof method". Up-to-expansion-and-weak-similarity : Trans₂ ℓ Proc Up-to-expansion-and-weak-similarity R = Expansion ∞ ⊙ R ⊙ Weak-similarity ∞ -- The relation transformer is monotone. up-to-expansion-and-weak-similarity-monotone : Monotone Up-to-expansion-and-weak-similarity up-to-expansion-and-weak-similarity-monotone R⊆S = Σ-map id (Σ-map id (Σ-map id (Σ-map R⊆S id))) -- The relation transformer is size-preserving. up-to-expansion-and-weak-similarity-size-preserving : Size-preserving Up-to-expansion-and-weak-similarity up-to-expansion-and-weak-similarity-size-preserving = _⇔_.from (monotone→⇔ up-to-expansion-and-weak-similarity-monotone) (λ where {x = p , q} (r , p≳r , s , r≼s , s≼q) → p ∼⟨ p≳r ⟩ r ∼′⟨ r≼s ⟩ ≼: s ∼⟨ s≼q ⟩■ q)
bb-runtimes/examples/monitor/p5566/ethdrv.adb
JCGobbi/Nucleo-STM32G474RE
0
23437
<reponame>JCGobbi/Nucleo-STM32G474RE<filename>bb-runtimes/examples/monitor/p5566/ethdrv.adb<gh_stars>0 ------------------------------------------------------------------------------ -- -- -- GNAT EXAMPLE -- -- -- -- Copyright (C) 2013, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Ethernet driver with Clkdrv; with System; use System; with System.Storage_Elements; with Netcfg; use Netcfg; with Netutils; use Netutils; with System.Machine_Code; use System.Machine_Code; with Dumps; use Dumps; with Ada.Text_IO; use Ada.Text_IO; -- with Netproto; package body Ethdrv is FEC_EIR : Unsigned_32; for FEC_EIR'Address use System'To_Address (16#fff4_c004#); pragma Import (Ada, FEC_EIR); pragma Volatile (FEC_EIR); EIR_RXF : constant := 16#0200_0000#; EIR_RXB : constant := 16#0100_0000#; FEC_RDAR : Unsigned_32; for FEC_RDAR'Address use System'To_Address (16#fff4_c010#); pragma Import (Ada, FEC_RDAR); pragma Volatile (FEC_RDAR); FEC_TDAR : Unsigned_32; for FEC_TDAR'Address use System'To_Address (16#fff4_c014#); pragma Import (Ada, FEC_TDAR); pragma Volatile (FEC_TDAR); FEC_ECR : Unsigned_32; for FEC_ECR'Address use System'To_Address (16#fff4_c024#); pragma Import (Ada, FEC_ECR); pragma Volatile (FEC_ECR); FEC_MMFR : Unsigned_32; for FEC_MMFR'Address use System'To_Address (16#fff4_c040#); pragma Import (Ada, FEC_MMFR); pragma Volatile (FEC_MMFR); FEC_MSCR : Unsigned_32; for FEC_MSCR'Address use System'To_Address (16#fff4_c044#); pragma Import (Ada, FEC_MSCR); pragma Volatile (FEC_MSCR); FEC_RCR : Unsigned_32; for FEC_RCR'Address use System'To_Address (16#fff4_c084#); pragma Import (Ada, FEC_RCR); pragma Volatile (FEC_RCR); FEC_TCR : Unsigned_32; for FEC_TCR'Address use System'To_Address (16#fff4_c0c4#); pragma Import (Ada, FEC_TCR); pragma Volatile (FEC_TCR); FEC_PALR : Unsigned_32; for FEC_PALR'Address use System'To_Address (16#fff4_c0e4#); pragma Import (Ada, FEC_PALR); pragma Volatile (FEC_PALR); FEC_PAUR : Unsigned_32; for FEC_PAUR'Address use System'To_Address (16#fff4_c0e8#); pragma Import (Ada, FEC_PAUR); pragma Volatile (FEC_PAUR); FEC_OPD : Unsigned_32; for FEC_OPD'Address use System'To_Address (16#fff4_c0ec#); pragma Import (Ada, FEC_OPD); pragma Volatile (FEC_OPD); FEC_IAUR : Unsigned_32; for FEC_IAUR'Address use System'To_Address (16#fff4_c118#); pragma Import (Ada, FEC_IAUR); pragma Volatile (FEC_IAUR); FEC_IALR : Unsigned_32; for FEC_IALR'Address use System'To_Address (16#fff4_c11c#); pragma Import (Ada, FEC_IALR); pragma Volatile (FEC_IALR); FEC_GAUR : Unsigned_32; for FEC_GAUR'Address use System'To_Address (16#fff4_c120#); pragma Import (Ada, FEC_GAUR); pragma Volatile (FEC_GAUR); FEC_GALR : Unsigned_32; for FEC_GALR'Address use System'To_Address (16#fff4_c124#); pragma Import (Ada, FEC_GALR); pragma Volatile (FEC_GALR); FEC_TFWR : Unsigned_32; for FEC_TFWR'Address use System'To_Address (16#fff4_c144#); pragma Import (Ada, FEC_TFWR); pragma Volatile (FEC_TFWR); FEC_ERDSR : Address; for FEC_ERDSR'Address use System'To_Address (16#fff4_c180#); pragma Import (Ada, FEC_ERDSR); pragma Volatile (FEC_ERDSR); FEC_ETDSR : Address; for FEC_ETDSR'Address use System'To_Address (16#fff4_c184#); pragma Import (Ada, FEC_ETDSR); pragma Volatile (FEC_ETDSR); FEC_EMRBR : Unsigned_32; for FEC_EMRBR'Address use System'To_Address (16#fff4_c188#); pragma Import (Ada, FEC_EMRBR); pragma Volatile (FEC_EMRBR); SIU_PCR : array (0 .. 230) of Unsigned_16; for SIU_PCR'Address use System'To_Address (16#c3f9_0040#); pragma Import (Ada, SIU_PCR); pragma Volatile (SIU_PCR); EBI_MCR : Unsigned_32; for EBI_MCR'Address use System'To_Address (16#c3f8_4000#); pragma Import (Ada, EBI_MCR); pragma Volatile (EBI_MCR); type TRxbd_Type is record Flags : Unsigned_16; Len : Unsigned_16; Buffer : Address; end record; pragma Warnings (Off, "* not referenced"); Flag_E : constant := 2#1000_0000_0000_0000#; Flag_R : constant := 2#1000_0000_0000_0000#; Flag_RO1 : constant := 2#0100_0000_0000_0000#; Flag_TO1 : constant := 2#0100_0000_0000_0000#; Flag_W : constant := 2#0010_0000_0000_0000#; Flag_RO2 : constant := 2#0001_0000_0000_0000#; Flag_TO2 : constant := 2#0001_0000_0000_0000#; Flag_L : constant := 2#0000_1000_0000_0000#; Flag_TC : constant := 2#0000_0100_0000_0000#; Flag_ABC : constant := 2#0000_0010_0000_0000#; Flag_M : constant := 2#0000_0001_0000_0000#; Flag_BC : constant := 2#0000_0000_1000_0000#; Flag_MC : constant := 2#0000_0000_0100_0000#; Flag_LG : constant := 2#0000_0000_0010_0000#; Flag_NO : constant := 2#0000_0000_0001_0000#; Flag_CR : constant := 2#0000_0000_0000_0100#; Flag_OV : constant := 2#0000_0000_0000_0010#; Flag_TR : constant := 2#0000_0000_0000_0001#; pragma Warnings (On, "* not referenced"); subtype Rxbd_Range is Natural range 0 .. 7; type TRxbd_Array is array (Natural range <>) of TRxbd_Type; Rxdesc : TRxbd_Array (Rxbd_Range); for Rxdesc'Alignment use 32; pragma Volatile (Rxdesc); type Netbuf_Array is array (Rxbd_Range) of Netbuf (0 .. 511); Rxbuf : Netbuf_Array; for Rxbuf'Alignment use 32; Rxdesc_Num : Rxbd_Range := 0; subtype Txbd_Range is Natural range 0 .. 3; Txdesc : TRxbd_Array (Txbd_Range); for Txdesc'Alignment use 32; pragma Volatile (Txdesc); Txdesc_Num : Txbd_Range := 0; procedure Cache_Flush (Addr : Address) is begin Asm ("dcbf 0,%0", Inputs => Address'Asm_Input ("r", Addr), Volatile => True); end Cache_Flush; procedure Flush_Packet is use System.Storage_Elements; Addr : Address := Packet (0)'Address; begin while Addr <= Packet (Packet'Last)'Address loop Cache_Flush (Addr); Addr := Addr + 32; end loop; end Flush_Packet; procedure Flush_Rxbuf (N : Rxbd_Range) is use System.Storage_Elements; Addr : Address := Rxbuf (N)'Address; begin while Addr <= Rxbuf (N)(Rxbuf (N)'Last)'Address loop Cache_Flush (Addr); Addr := Addr + 32; end loop; end Flush_Rxbuf; procedure Cache_Disable is Val : Unsigned_32; begin -- Flush for Cset in 0 .. 127 loop for Cway in 0 .. 7 loop Val := Unsigned_32 (Cway * 16#1_000000# + Cset * 16#2_0# + 16#2#); Asm ("mtspr 1016, %0", Inputs => Unsigned_32'Asm_Input ("r", Val), Volatile => True); end loop; end loop; -- Disable Asm ("msync; isync; mtspr 1010, %0", Inputs => Unsigned_32'Asm_Input ("r", 0), Volatile => True); end Cache_Disable; procedure Eth_Init is begin Cache_Disable; -- Reset the chip FEC_ECR := 1; while (FEC_ECR and 3) /= 0 loop null; end loop; SIU_PCR (44) := 2#10_01_11_00_00_00#; -- TX_CLK SIU_PCR (45) := 2#10_01_11_00_00_00#; -- CRS SIU_PCR (46) := 2#10_01_11_00_00_00#; -- TX_ER SIU_PCR (47) := 2#10_01_11_00_00_00#; -- RX_CLK SIU_PCR (48) := 2#10_01_11_00_00_00#; -- TXD0 SIU_PCR (49) := 2#10_01_11_00_00_00#; -- RX_ER SIU_PCR (50) := 2#10_01_11_00_00_00#; -- RXD0 SIU_PCR (51) := 2#10_01_11_00_00_00#; -- TXD3 SIU_PCR (52) := 2#10_01_11_00_00_00#; -- COL SIU_PCR (53) := 2#10_01_11_00_00_00#; -- RX_DV SIU_PCR (54) := 2#10_01_11_00_00_00#; -- TX_EN SIU_PCR (55) := 2#10_01_11_00_00_00#; -- TXD2 SIU_PCR (56) := 2#10_01_11_00_00_00#; -- TXD1 SIU_PCR (57) := 2#10_01_11_00_00_00#; -- RXD1 SIU_PCR (58) := 2#10_01_11_00_00_00#; -- RXD2 SIU_PCR (59) := 2#10_01_11_00_00_00#; -- RXD3 -- Enable FEC_MDC and FEC_MDIO SIU_PCR (72) := 2#10_11_11_00_00_00#; -- MDC SIU_PCR (73) := 2#10_11_11_00_00_00#; -- MDIO EBI_MCR := 16#01#; -- Disable, 16 bits -- Clear events FEC_EIR := 16#ffff_ffff#; -- Set fifo level FEC_TFWR := 3; -- Individual address FEC_PALR := Shift_Left (Unsigned_32 (My_Eth_Addr (1)), 24) or Shift_Left (Unsigned_32 (My_Eth_Addr (2)), 16) or Shift_Left (Unsigned_32 (My_Eth_Addr (3)), 8) or Shift_Left (Unsigned_32 (My_Eth_Addr (4)), 0); FEC_PAUR := Shift_Left (Unsigned_32 (My_Eth_Addr (5)), 24) or Shift_Left (Unsigned_32 (My_Eth_Addr (6)), 16); -- Multicast addresses hash bits FEC_GAUR := 0; FEC_GALR := 0; -- Individual addresses hash bits FEC_IAUR := 0; FEC_IALR := 0; -- FEC_OPD := 100; FEC_RCR := 1518 * 16#1_0000# + 2#100#; -- MII FEC_TCR := 2#100#; -- FDEN FEC_MSCR := 13 * 2#10#; -- 2.5Mhz at 132Mhz -- FEC_FRSR := FEC_EMRBR := Rxbuf (0)'Length; FEC_ERDSR := Rxdesc'Address; FEC_ETDSR := Txdesc'Address; for I in Rxdesc'Range loop Rxdesc (I) := (Flag_E, 0, Rxbuf (I)'Address); if I = Rxdesc'Last then Rxdesc (I).Flags := Flag_E or Flag_W; end if; Cache_Flush (Rxdesc (I)'Address); Flush_Rxbuf (I); end loop; Rxdesc_Num := 0; for I in Txdesc'Range loop Txdesc (I) := (0, 0, Packet'Address); if I = Txdesc'Last then Txdesc (I).Flags := Flag_W; end if; Cache_Flush (Txdesc (I)'Address); end loop; Txdesc_Num := 0; FEC_ECR := 2; FEC_RDAR := 16#01_00_00_00#; if False then for I in 0 .. 7 loop FEC_MMFR := 2#01_10_00001_00000_10_0000000000000000# + Unsigned_32 (I * 16#4_0000#); while (FEC_EIR and 16#80_0000#) = 0 loop null; end loop; FEC_EIR := 16#80_0000#; Put_Line ("Reg" & Image1 (Unsigned_32 (I)) & ": " & Image8 (FEC_MMFR)); end loop; end if; end Eth_Init; procedure Eth_Rcv_Wait (Maxtime : Unsigned_32 := 16#ffffffff#) is Chunk_Len : Natural; Flags : Unsigned_16; Prev_Eir, Eir : Unsigned_32; begin loop if False then Put ("eth rcv: wait "); Put_Hex (Unsigned_8 (Rxdesc_Num)); New_Line; end if; -- Wait until the current descriptor is available FEC_EIR := EIR_RXF or EIR_RXB; Prev_Eir := 0; loop exit when (Rxdesc (Rxdesc_Num).Flags and Flag_E) = 0; Cache_Flush (Rxdesc (Rxdesc_Num)'Address); -- FEC_RDAR := 16#01_00_00_00#; loop if Clkdrv.Get_Clock > Maxtime then Packet_Len := 0; return; end if; Eir := FEC_EIR; exit when (Eir and EIR_RXF) /= 0; if False and then Eir /= Prev_Eir then Put ("EIR: "); Put_Hex (Eir); New_Line; Prev_Eir := Eir; end if; end loop; end loop; -- Copy chunks Packet_Off := 0; loop Flags := Rxdesc (Rxdesc_Num).Flags; if False then Put ("Flags: "); Put_Hex (Flags); Put (" len: "); Put_Hex (Rxdesc (Rxdesc_Num).Len); New_Line; end if; -- Copy chunk Chunk_Len := Natural (Rxdesc (Rxdesc_Num).Len); if (Flags and Flag_L) /= 0 then -- The length of the last buffer is the length of the frame, -- not just the length of the last buffer (15.5.1.2) Chunk_Len := Chunk_Len - Packet_Off; end if; Packet (Packet_Off .. Packet_Off + Chunk_Len - 1) := Rxbuf (Rxdesc_Num)(0 .. Chunk_Len - 1); Packet_Off := Packet_Off + Chunk_Len; Flush_Rxbuf (Rxdesc_Num); -- Check flags Rxdesc (Rxdesc_Num).Flags := (Flags and Flag_W) or Flag_E; Cache_Flush (Rxdesc (Rxdesc_Num)'Address); Rxdesc_Num := (Rxdesc_Num + 1) rem Rxdesc'Length; exit when (Flags and Flag_L) /= 0; -- Wait until the next descriptor is available loop exit when (Rxdesc (Rxdesc_Num).Flags and Flag_E) = 0; Cache_Flush (Rxdesc (Rxdesc_Num)'Address); end loop; end loop; -- Discard invalid packets exit when (Flags and (Flag_CR + Flag_OV + Flag_TR)) = 0; Put ("err rxdesc: "); Put_Hex (Flags); New_Line; end loop; Packet_Len := Packet_Off - 4; -- Remove CRC Packet_Off := 0; end Eth_Rcv_Wait; procedure Eth_Send_Init is begin Packet_Off := 0; end Eth_Send_Init; procedure Eth_Send_Packet is begin -- Put_Line ("Sending"); -- Netproto.Dump_Pkt; Flush_Packet; Txdesc (Txdesc_Num).Len := Unsigned_16 (Packet_Len); Txdesc (Txdesc_Num).Flags := (Txdesc (Txdesc_Num).Flags and Flag_W) or Flag_R + Flag_L + Flag_TC; Cache_Flush (Txdesc (Txdesc_Num)'Address); Txdesc_Num := (Txdesc_Num + 1) rem Txdesc'Length; FEC_TDAR := 16#01_00_00_00#; while (FEC_EIR and 16#800_0000#) = 0 loop null; end loop; FEC_EIR := 16#0c00_0000#; end Eth_Send_Packet; end Ethdrv;
Library/Shell/Dialog/dialogC.asm
steakknife/pcgeos
504
90923
COMMENT @===================================================================== Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: Shell -- Dialog FILE: dialogC.asm AUTHOR: <NAME>, Dec 19, 1997 GLOBAL ROUTINES: Name Description ---- ----------- SHELLREPORTFILEERROR C stub for routine that displays error dialog given FileError and TCHAR *filename REVISION HISTORY: Name Date Description ---- ---- ----------- martin 12/19/97 Initial version DESCRIPTION: Externally callable routines for this module. No global routines for the dialog module of the shell library should appear in any file other than this one. RCS STAMP: $Id: dialogC.asm,v 1.1 97/04/04 19:37:18 newdeal Exp $ =============================================================================@ SetGeosConvention COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SHELLREPORTFILEERROR %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% C DECLARATION: ShellBuffer *ShellBufferOpen(THCAR *filename, FileAccessFlags flags); SYNOPSIS: C Stubs for the shell library buffer module. REVISION HISTORY: Name Date Description ---- ---- ----------- martin 12/16/97 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SHELLREPORTFILEERROR proc far error:FileError, filename:fptr uses ds .enter movdw dsdx, ss:[filename], ax mov ax, ss:[error] call ShellReportFileError .leave ret SHELLREPORTFILEERROR endp SetDefaultConvention
test/interaction/SplitOnHidden.agda
redfish64/autonomic-agda
0
7485
data Nat : Set where zero : Nat suc : Nat → Nat test : ∀{N M : Nat} → Nat → Nat → Nat test N M = {!.N N .M!}
alloy4fun_models/trainstlt/models/4/6qej7WszGSbts2CPB.als
Kaixi26/org.alloytools.alloy
0
1213
open main pred id6qej7WszGSbts2CPB_prop5 { all t : Train | some (t.pos & Exit) implies Train' = Train - t } pred __repair { id6qej7WszGSbts2CPB_prop5 } check __repair { id6qej7WszGSbts2CPB_prop5 <=> prop5o }
day03/src/main.adb
jwarwick/aoc_2020
3
28074
<reponame>jwarwick/aoc_2020 -- AOC 2020, Day 3 with Ada.Text_IO; use Ada.Text_IO; with Day; use Day; procedure main is f : constant Forest := load_map("input.txt"); slope : constant Natural := 3; begin put_line("Part 1: " & Natural'Image(trees_hit(f, slope))); put_line("Part 2: " & Natural'Image(many_trees_hit(f))); end main;
oeis/038/A038470.asm
neoneye/loda-programs
11
15342
; A038470: Sums of 2 distinct powers of 4. ; Submitted by <NAME> ; 5,17,20,65,68,80,257,260,272,320,1025,1028,1040,1088,1280,4097,4100,4112,4160,4352,5120,16385,16388,16400,16448,16640,17408,20480,65537,65540,65552,65600,65792,66560,69632,81920,262145,262148,262160 seq $0,48645 ; Integers with one or two 1-bits in their binary expansion. seq $0,71162 ; Simple rewriting of binary expansion of n resulting A014486-codes for rooted binary trees with height equal to number of internal vertices. (Binary trees where at each internal vertex at least the other child is leaf). div $0,2 mul $0,3 add $0,2
bootloader/bit16/print_string.asm
mstniy/cerius
2
679
<gh_stars>1-10 [bits 16] ; Prints the zero-terminated string at bx to the screen. print_string: pusha mov ah, 0x0e pstring_loop: cmp byte [bx], 0 je pstring_loop_end mov al, [bx] int 0x10 add bx, 1 jmp pstring_loop pstring_loop_end: popa ret ; Prints the ascii-encoding character at bl to the screen. print_char: pusha mov ah, 0x0e mov al, bl int 0x10 popa ret ; Prints a new line. print_line: push bx mov bl, 13 ; '\r' call print_char mov bl, 10 ; '\n' call print_char pop bx ret
libsrc/_DEVELOPMENT/arch/ts2068/display/c/sccz80/tshr_saddrpleft_callee.asm
Frodevan/z88dk
640
89508
<filename>libsrc/_DEVELOPMENT/arch/ts2068/display/c/sccz80/tshr_saddrpleft_callee.asm ; void *tshr_saddrpleft(void *saddr, uchar bitmask) SECTION code_clib SECTION code_arch PUBLIC tshr_saddrpleft_callee EXTERN asm_tshr_saddrpleft tshr_saddrpleft_callee: pop af pop hl dec sp pop de push af ld e,d jp asm_tshr_saddrpleft ; SDCC bridge for Classic IF __CLASSIC PUBLIC _tshr_saddrpleft_callee defc _tshr_saddrpleft_callee = tshr_saddrpleft_callee ENDIF
oeis/171/A171881.asm
neoneye/loda-programs
11
1431
<reponame>neoneye/loda-programs ; A171881: Square array, read by antidiagonals, where T(n,k)=n^^k for n>=0, k>=1. ; Submitted by <NAME> ; 0,1,1,2,1,1,3,4,1,1,4,27,16,1,1,5,256,19683,256,1,1,6,3125,4294967296,7625597484987,65536,1,1,7,46656,298023223876953125,340282366920938463463374607431768211456 lpb $0 add $1,1 sub $0,$1 mov $2,$1 sub $2,$0 lpe mov $1,$2 pow $2,$0 pow $1,$2 mov $0,$1
grammars/SQLSelectLexer.g4
hackolade/sql-select-statement-parser
0
3212
lexer grammar SQLSelectLexer; EQUAL_OPERATOR: '='; ASSIGN_OPERATOR: ':='; NULL_SAFE_EQUAL_OPERATOR: '<=>'; GREATER_OR_EQUAL_OPERATOR: '>='; GREATER_THAN_OPERATOR: '>'; LESS_OR_EQUAL_OPERATOR: '<='; LESS_THAN_OPERATOR: '<'; NOT_EQUAL_OPERATOR: '!=' | '<>'; PLUS_OPERATOR: '+'; MINUS_OPERATOR: '-'; MULT_OPERATOR: '*'; DIV_OPERATOR: '/'; MOD_OPERATOR: '%'; LOGICAL_NOT_OPERATOR: '!'; BITWISE_NOT_OPERATOR: '~'; SHIFT_LEFT_OPERATOR: '<<'; SHIFT_RIGHT_OPERATOR: '>>'; LOGICAL_AND_OPERATOR: '&&'; BITWISE_AND_OPERATOR: '&'; BITWISE_XOR_OPERATOR: '^'; LOGICAL_OR_OPERATOR: '||' ; BITWISE_OR_OPERATOR: '|'; DOT_SYMBOL: '.'; COMMA_SYMBOL: ','; SEMICOLON_SYMBOL: ';'; COLON_SYMBOL: ':'; OPEN_PAR_SYMBOL: '('; CLOSE_PAR_SYMBOL: ')'; OPEN_CURLY_SYMBOL: '{'; CLOSE_CURLY_SYMBOL: '}'; UNDERLINE_SYMBOL: '_'; OPEN_BRACKET_SYMBOL: '['; CLOSE_BRACKET_SYMBOL: ']'; JSON_SEPARATOR_SYMBOL: '->' ; JSON_UNQUOTED_SEPARATOR_SYMBOL: '->>' ; AT_SIGN_SYMBOL: '@'; AT_TEXT_SUFFIX: '@' SIMPLE_IDENTIFIER; AT_AT_SIGN_SYMBOL: '@@'; NULL2_SYMBOL: '\\N'; PARAM_MARKER: '?'; CAST_COLON_SYMBOL: '::'; fragment A: [aA]; fragment B: [bB]; fragment C: [cC]; fragment D: [dD]; fragment E: [eE]; fragment F: [fF]; fragment G: [gG]; fragment H: [hH]; fragment I: [iI]; fragment J: [jJ]; fragment K: [kK]; fragment L: [lL]; fragment M: [mM]; fragment N: [nN]; fragment O: [oO]; fragment P: [pP]; fragment Q: [qQ]; fragment R: [rR]; fragment S: [sS]; fragment T: [tT]; fragment U: [uU]; fragment V: [vV]; fragment W: [wW]; fragment X: [xX]; fragment Y: [yY]; fragment Z: [zZ]; fragment DIGIT: [0-9]; fragment DIGITS: DIGIT+; fragment HEXDIGIT: [0-9a-fA-F]; HEX_NUMBER: ('0x' HEXDIGIT+) | ('x\'' HEXDIGIT+ '\''); BIN_NUMBER: ('0b' [01]+) | ('b\'' [01]+ '\''); INT_NUMBER: DIGITS ; DECIMAL_NUMBER: DIGITS? DOT_SYMBOL DIGITS; FLOAT_NUMBER: (DIGITS? DOT_SYMBOL)? DIGITS [eE] (MINUS_OPERATOR | PLUS_OPERATOR)? DIGITS; TINYINT_SYMBOL: T I N Y I N T; SMALLINT_SYMBOL: S M A L L I N T; MEDIUMINT_SYMBOL: M E D I U M I N T; BYTE_INT_SYMBOL: B Y T E I N T; INT_SYMBOL : I N T E G E R | I N T; BIGINT_SYMBOL: B I G I N T; SECOND_SYMBOL: S E C O N D; MINUTE_SYMBOL: M I N U T E; HOUR_SYMBOL : H O U R; DAY_SYMBOL : D A Y; WEEK_SYMBOL : W E E K; MONTH_SYMBOL: M O N T H; QUARTER_SYMBOL: Q U A R T E R; YEAR_SYMBOL : Y E A R; DEFAULT_SYMBOL: D E F A U L T; UNION_SYMBOL: U N I O N; SELECT_SYMBOL: S E L E C T; ALL_SYMBOL: A L L; DISTINCT_SYMBOL: D I S T I N C T; STRAIGHT_JOIN_SYMBOL: S T R A I G H T '_' J O I N; HIGH_PRIORITY_SYMBOL: H I G H '_' P R I O R I T Y; SQL_SMALL_RESULT_SYMBOL: S Q L '_' S M A L L '_' R E S U L T; SQL_BIG_RESULT_SYMBOL: S Q L '_' B I G '_' R E S U L T; SQL_BUFFER_RESULT_SYMBOL: S Q L '_' B U F F E R '_' R E S U L T; SQL_CALC_FOUND_ROWS_SYMBOL: S Q L '_' C A L C '_' F O U N D '_' R O W S; LIMIT_SYMBOL: L I M I T; OFFSET_SYMBOL: O F F S E T; INTO_SYMBOL: I N T O; OUTFILE_SYMBOL: O U T F I L E; DUMPFILE_SYMBOL: D U M P F I L E; PROCEDURE_SYMBOL: P R O C E D U R E; ANALYSE_SYMBOL: A N A L Y S E; HAVING_SYMBOL: H A V I N G; WINDOW_SYMBOL: W I N D O W; AS_SYMBOL: A S; PARTITION_SYMBOL: P A R T I T I O N; BY_SYMBOL: B Y; ROWS_SYMBOL: R O W S; RANGE_SYMBOL: R A N G E; GROUPS_SYMBOL: G R O U P S; UNBOUNDED_SYMBOL: U N B O U N D E D; PRECEDING_SYMBOL: P R E C E D I N G; INTERVAL_SYMBOL: I N T E R V A L; CURRENT_SYMBOL: C U R R E N T; ROW_SYMBOL: R O W; BETWEEN_SYMBOL: B E T W E E N; AND_SYMBOL: A N D; FOLLOWING_SYMBOL: F O L L O W I N G; EXCLUDE_SYMBOL: E X C L U D E; GROUP_SYMBOL: G R O U P; TIES_SYMBOL: T I E S; NO_SYMBOL: N O; OTHERS_SYMBOL: O T H E R S; WITH_SYMBOL: W I T H; WITHOUT_SYMBOL: W I T H O U T; RECURSIVE_SYMBOL: R E C U R S I V E; ROLLUP_SYMBOL: R O L L U P; CUBE_SYMBOL: C U B E; ORDER_SYMBOL: O R D E R; ASC_SYMBOL: A S C; DESC_SYMBOL: D E S C; FROM_SYMBOL: F R O M; DUAL_SYMBOL: D U A L; VALUES_SYMBOL: V A L U E S; TABLE_SYMBOL: T A B L E; SQL_NO_CACHE_SYMBOL: S Q L '_' N O '_' C A C H E; SQL_CACHE_SYMBOL: S Q L '_' C A C H E; MAX_STATEMENT_TIME_SYMBOL: M A X '_' S T A T E M E N T '_' T I M E; FOR_SYMBOL: F O R; OF_SYMBOL: O F; LOCK_SYMBOL: L O C K; IN_SYMBOL: I N; SHARE_SYMBOL: S H A R E; MODE_SYMBOL: M O D E; UPDATE_SYMBOL: U P D A T E; SKIP_SYMBOL: S K I P; LOCKED_SYMBOL: L O C K E D; NOWAIT_SYMBOL: N O W A I T; WHERE_SYMBOL: W H E R E; OJ_SYMBOL: O J; ON_SYMBOL: O N; USING_SYMBOL: U S I N G; NATURAL_SYMBOL: N A T U R A L; INNER_SYMBOL: I N N E R; JOIN_SYMBOL: J O I N; LEFT_SYMBOL: L E F T; RIGHT_SYMBOL: R I G H T; OUTER_SYMBOL: O U T E R; CROSS_SYMBOL: C R O S S; LATERAL_SYMBOL: L A T E R A L; JSON_TABLE_SYMBOL: J S O N '_' T A B L E; COLUMNS_SYMBOL: C O L U M N S; ORDINALITY_SYMBOL: O R D I N A L I T Y; EXISTS_SYMBOL: E X I S T S; PATH_SYMBOL: P A T H; NESTED_SYMBOL: N E S T E D; EMPTY_SYMBOL: E M P T Y; ERROR_SYMBOL: E R R O R; NULL_SYMBOL: N U L L; USE_SYMBOL: U S E; FORCE_SYMBOL: F O R C E; IGNORE_SYMBOL: I G N O R E; KEY_SYMBOL: K E Y; INDEX_SYMBOL: I N D E X; PRIMARY_SYMBOL: P R I M A R Y; IS_SYMBOL: I S; TRUE_SYMBOL: T R U E; FALSE_SYMBOL: F A L S E; UNKNOWN_SYMBOL: U N K N O W N; NOT_SYMBOL: N O T; XOR_SYMBOL: X O R; OR_SYMBOL: O R; ANY_SYMBOL: A N Y; MEMBER_SYMBOL: M E M B E R; SOUNDS_SYMBOL: S O U N D S; LIKE_SYMBOL: L I K E; ESCAPE_SYMBOL: E S C A P E; REGEXP_SYMBOL: R E G E X P; DIV_SYMBOL: D I V; MOD_SYMBOL: M O D; MATCH_SYMBOL: M A T C H; AGAINST_SYMBOL: A G A I N S T; BINARY_SYMBOL: B I N A R Y; CAST_SYMBOL: C A S T; ARRAY_SYMBOL: A R R A Y; CASE_SYMBOL: C A S E; END_SYMBOL: E N D; CONVERT_SYMBOL: C O N V E R T; COLLATE_SYMBOL: C O L L A T E; AVG_SYMBOL: A V G; BIT_AND_SYMBOL: B I T '_' A N D; BIT_OR_SYMBOL: B I T '_' O R; BIT_XOR_SYMBOL: B I T '_' X O R; COUNT_SYMBOL: C O U N T; MIN_SYMBOL: M I N; MAX_SYMBOL: M A X; STD_SYMBOL: S T D; VARIANCE_SYMBOL: V A R I A N C E; STDDEV_SAMP_SYMBOL: S T D D E V '_' S A M P; VAR_SAMP_SYMBOL: V A R '_' S A M P; SUM_SYMBOL: S U M; GROUP_CONCAT_SYMBOL: G R O U P '_' C O N C A T; SEPARATOR_SYMBOL: S E P A R A T O R; GROUPING_SYMBOL: G R O U P I N G; ROW_NUMBER_SYMBOL: R O W '_' N U M B E R; RANK_SYMBOL: R A N K; DENSE_RANK_SYMBOL: D E N S E '_' R A N K; CUME_DIST_SYMBOL: C U M E '_' D I S T; PERCENT_RANK_SYMBOL: P E R C E N T '_' R A N K; NTILE_SYMBOL: N T I L E; LEAD_SYMBOL: L E A D; LAG_SYMBOL: L A G; FIRST_VALUE_SYMBOL: F I R S T '_' V A L U E; LAST_VALUE_SYMBOL: L A S T '_' V A L U E; NTH_VALUE_SYMBOL: N T H '_' V A L U E; FIRST_SYMBOL: F I R S T; LAST_SYMBOL: L A S T; OVER_SYMBOL: O V E R; RESPECT_SYMBOL: R E S P E C T; NULLS_SYMBOL: N U L L S; JSON_ARRAYAGG_SYMBOL: J S O N '_' A R R A Y A G G; JSON_OBJECTAGG_SYMBOL: J S O N '_' O B J E C T A G G; BOOLEAN_SYMBOL: B O O L E A N; LANGUAGE_SYMBOL: L A N G U A G E; QUERY_SYMBOL: Q U E R Y; EXPANSION_SYMBOL: E X P A N S I O N; CHAR_SYMBOL: C H A R A C T E R | C H A R; CURRENT_USER_SYMBOL: C U R R E N T '_' U S E R; DATE_SYMBOL: D A T E; INSERT_SYMBOL: I N S E R T; TIME_SYMBOL: T I M E; TIMESTAMP_SYMBOL: T I M E S T A M P; TIMESTAMP_LTZ_SYMBOL: T I M E S T A M P L T Z | T I M E S T A M P '_' L T Z; TIMESTAMP_NTZ_SYMBOL: T I M E S T A M P N T Z | T I M E S T A M P '_' N T Z; ZONE_SYMBOL: Z O N E; USER_SYMBOL: U S E R; ADDDATE_SYMBOL: A D D D A T E; SUBDATE_SYMBOL: S U B D A T E; CURDATE_SYMBOL: C U R D A T E; CURTIME_SYMBOL: C U R T I M E; DATE_ADD_SYMBOL: D A T E '_' A D D; DATE_SUB_SYMBOL: D A T E '_' S U B; EXTRACT_SYMBOL: E X T R A C T; GET_FORMAT_SYMBOL: G E T '_' F O R M A T; NOW_SYMBOL: N O W; POSITION_SYMBOL: P O S I T I O N; SYSDATE_SYMBOL: S Y S D A T E; TIMESTAMP_ADD_SYMBOL: T I M E S T A M P '_' A D D; TIMESTAMP_DIFF_SYMBOL: T I M E S T A M P '_' D I F F; UTC_DATE_SYMBOL: U T C '_' D A T E; UTC_TIME_SYMBOL: U T C '_' T I M E; UTC_TIMESTAMP_SYMBOL: U T C '_' T I M E S T A M P; ASCII_SYMBOL: A S C I I; CHARSET_SYMBOL: C H A R S E T; COALESCE_SYMBOL: C O A L E S C E; COLLATION_SYMBOL: C O L L A T I O N; DATABASE_SYMBOL: D A T A B A S E; IF_SYMBOL: I F; FORMAT_SYMBOL: F O R M A T; MICROSECOND_SYMBOL: M I C R O S E C O N D; OLD_PASSWORD_SYMBOL: O L D '_' P A S S W O R D; PASSWORD_SYMBOL: P A S S W O R D; REPEAT_SYMBOL: R E P E A T; REPLACE_SYMBOL: R E P L A C E; REVERSE_SYMBOL: R E V E R S E; ROW_COUNT_SYMBOL: R O W '_' C O U N T; TRUNCATE_SYMBOL: T R U N C A T E; WEIGHT_STRING_SYMBOL: W E I G H T '_' S T R I N G; CONTAINS_SYMBOL: C O N T A I N S; GEOMETRYCOLLECTION_SYMBOL: G E O M E T R Y C O L L E C T I O N; LINESTRING_SYMBOL: L I N E S T R I N G; MULTILINESTRING_SYMBOL: M U L T I L I N E S T R I N G; MULTIPOINT_SYMBOL: M U L T I P O I N T; MULTIPOLYGON_SYMBOL: M U L T I P O L Y G O N; POINT_SYMBOL: P O I N T; POLYGON_SYMBOL: P O L Y G O N; LEVEL_SYMBOL: L E V E L; DATETIME_SYMBOL: D A T E T I M E; TRIM_SYMBOL: T R I M; LEADING_SYMBOL: L E A D I N G; TRAILING_SYMBOL: T R A I L I N G; BOTH_SYMBOL: B O T H; STRING_SYMBOL: S T R I N G; SUBSTRING_SYMBOL: S U B S T R I N G; WHEN_SYMBOL: W H E N; THEN_SYMBOL: T H E N; ELSE_SYMBOL: E L S E; SIGNED_SYMBOL: S I G N E D; UNSIGNED_SYMBOL: U N S I G N E D; DECIMAL_SYMBOL: D E C I M A L | D E C; JSON_SYMBOL: J S O N; FLOAT_SYMBOL: F L O A T; FLOAT_SYMBOL_4: F L O A T '4'; FLOAT_SYMBOL_8: F L O A T '8'; SET_SYMBOL: S E T; SECOND_MICROSECOND_SYMBOL: S E C O N D '_' M I C R O S E C O N D; MINUTE_MICROSECOND_SYMBOL: M I N U T E '_' M I C R O S E C O N D; MINUTE_SECOND_SYMBOL: M I N U T E '_' S E C O N D; HOUR_MICROSECOND_SYMBOL: H O U R '_' M I C R O S E C O N D; HOUR_SECOND_SYMBOL: H O U R '_' S E C O N D; HOUR_MINUTE_SYMBOL: H O U R '_' M I N U T E; DAY_MICROSECOND_SYMBOL: D A Y '_' M I C R O S E C O N D; DAY_SECOND_SYMBOL: D A Y '_' S E C O N D; DAY_MINUTE_SYMBOL: D A Y '_' M I N U T E; DAY_HOUR_SYMBOL: D A Y '_' H O U R; YEAR_MONTH_SYMBOL: Y E A R '_' M O N T H; BTREE_SYMBOL: B T R E E; RTREE_SYMBOL: R T R E E; HASH_SYMBOL: H A S H; REAL_SYMBOL: R E A L; DOUBLE_SYMBOL: D O U B L E; PRECISION_SYMBOL: P R E C I S I O N; NUMERIC_SYMBOL: N U M E R I C; NUMBER_SYMBOL: N U M B E R; FIXED_SYMBOL: F I X E D; BIT_SYMBOL: B I T; BOOL_SYMBOL: B O O L; VARYING_SYMBOL: V A R Y I N G; VARCHAR_SYMBOL: V A R C H A R; NATIONAL_SYMBOL: N A T I O N A L; NVARCHAR_SYMBOL: N V A R C H A R; NCHAR_SYMBOL: N C H A R; VARBINARY_SYMBOL: V A R B I N A R Y; TINYBLOB_SYMBOL: T I N Y B L O B; BLOB_SYMBOL: B L O B; MEDIUMBLOB_SYMBOL: M E D I U M B L O B; LONGBLOB_SYMBOL: L O N G B L O B; LONG_SYMBOL: L O N G; TINYTEXT_SYMBOL: T I N Y T E X T; TEXT_SYMBOL: T E X T; MEDIUMTEXT_SYMBOL: M E D I U M T E X T; LONGTEXT_SYMBOL: L O N G T E X T; ENUM_SYMBOL: E N U M; SERIAL_SYMBOL: S E R I A L; GEOMETRY_SYMBOL: G E O M E T R Y; ZEROFILL_SYMBOL: Z E R O F I L L; BYTE_SYMBOL: B Y T E; UNICODE_SYMBOL: U N I C O D E; TERMINATED_SYMBOL: T E R M I N A T E D; OPTIONALLY_SYMBOL: O P T I O N A L L Y; ENCLOSED_SYMBOL: E N C L O S E D; ESCAPED_SYMBOL: E S C A P E D; LINES_SYMBOL: L I N E S; STARTING_SYMBOL: S T A R T I N G; GLOBAL_SYMBOL: G L O B A L; LOCAL_SYMBOL: L O C A L; SESSION_SYMBOL: S E S S I O N; VARIANT_SYMBOL: V A R I A N T; OBJECT_SYMBOL: O B J E C T; GEOGRAPHY_SYMBOL: G E O G R A P H Y; INT1_SYMBOL: I N T '1' -> type(TINYINT_SYMBOL); // Synonym INT2_SYMBOL: I N T '2' -> type(SMALLINT_SYMBOL); // Synonym INT3_SYMBOL: I N T '3' -> type(MEDIUMINT_SYMBOL); // Synonym INT4_SYMBOL: I N T '4' -> type(INT_SYMBOL); // Synonym INT8_SYMBOL: I N T '8' -> type(BIGINT_SYMBOL); // Synonym SQL_TSI_SECOND_SYMBOL: S Q L '_' T S I '_' S E C O N D -> type(SECOND_SYMBOL); // Synonym SQL_TSI_MINUTE_SYMBOL: S Q L '_' T S I '_' M I N U T E -> type(MINUTE_SYMBOL); // Synonym SQL_TSI_HOUR_SYMBOL: S Q L '_' T S I '_' H O U R -> type(HOUR_SYMBOL); // Synonym SQL_TSI_DAY_SYMBOL: S Q L '_' T S I '_' D A Y -> type(DAY_SYMBOL); // Synonym SQL_TSI_WEEK_SYMBOL: S Q L '_' T S I '_' W E E K -> type(WEEK_SYMBOL); // Synonym SQL_TSI_MONTH_SYMBOL: S Q L '_' T S I '_' M O N T H -> type(MONTH_SYMBOL); // Synonym SQL_TSI_QUARTER_SYMBOL: S Q L '_' T S I '_' Q U A R T E R -> type(QUARTER_SYMBOL); // Synonym SQL_TSI_YEAR_SYMBOL: S Q L '_' T S I '_' Y E A R -> type(YEAR_SYMBOL); // Synonym // White space handling WHITESPACE: [ \t\f\r\n] -> channel(HIDDEN); // Ignore whitespaces. // Input not covered elsewhere (unless quoted). INVALID_INPUT: [\u0001-\u0008] // Control codes. | '\u000B' // Line tabulation. | '\u000C' // Form feed. | [\u000E-\u001F] // More control codes. ; // String and text types. // The underscore charset token is used to defined the repertoire of a string, though it conflicts // with normal identifiers, which also can start with an underscore. UNDERSCORE_CHARSET: UNDERLINE_SYMBOL [a-z0-9]+ ; // Identifiers might start with a digit, even though it is discouraged, and may not consist entirely of digits only. // All keywords above are automatically excluded. IDENTIFIER: DIGITS+ [eE] (LETTER_WHEN_UNQUOTED_NO_DIGIT LETTER_WHEN_UNQUOTED*)? // Have to exclude float pattern, as this rule matches more. | DIGITS+ LETTER_WITHOUT_FLOAT_PART LETTER_WHEN_UNQUOTED* | LETTER_WHEN_UNQUOTED_NO_DIGIT LETTER_WHEN_UNQUOTED* // INT_NUMBER matches first if there are only digits. ; NCHAR_TEXT: [nN] SINGLE_QUOTED_TEXT; // MySQL supports automatic concatenation of multiple single and double quoted strings if they follow each other as separate // tokens. This is reflected in the `textLiteral` parser rule. // Here we handle duplication of quotation chars only (which must be replaced by a single char in the target code). fragment BACK_TICK: '`'; fragment SINGLE_QUOTE: '\''; fragment DOUBLE_QUOTE: '"'; BACK_TICK_QUOTED_ID: BACK_TICK .*? BACK_TICK; DOUBLE_QUOTED_TEXT: ( DOUBLE_QUOTE .*? DOUBLE_QUOTE )+ ; SINGLE_QUOTED_TEXT: ( SINGLE_QUOTE .*? SINGLE_QUOTE )+ ; BRACKET_QUOTED_TEXT: ( OPEN_BRACKET_SYMBOL .*? CLOSE_BRACKET_SYMBOL )+ ; // There are 3 types of block comments: // /* ... */ - The standard multi line comment. // /*! ... */ - A comment used to mask code for other clients. In MySQL the content is handled as normal code. // /*!12345 ... */ - Same as the previous one except code is only used when the given number is lower // than the current server version (specifying so the minimum server version the code can run with). VERSION_COMMENT_START: ('/*!' DIGITS) ( .*? '*/' ) -> channel(HIDDEN) ; // inVersionComment is a variable in the base lexer. MYSQL_COMMENT_START: '/*!' -> channel(HIDDEN); VERSION_COMMENT_END: '*/' -> channel(HIDDEN); BLOCK_COMMENT: ( '/**/' | '/*' ~[!] .*? '*/') -> channel(HIDDEN); POUND_COMMENT: '#' ~([\n\r])* -> channel(HIDDEN); DASHDASH_COMMENT: DOUBLE_DASH ([ \t] (~[\n\r])* | LINEBREAK | EOF) -> channel(HIDDEN); fragment DOUBLE_DASH: '--'; fragment LINEBREAK: [\n\r]; fragment SIMPLE_IDENTIFIER: (DIGIT | [a-zA-Z_$] | DOT_SYMBOL)+; fragment ML_COMMENT_HEAD: '/*'; fragment ML_COMMENT_END: '*/'; // As defined in https://dev.mysql.com/doc/refman/8.0/en/identifiers.html. fragment LETTER_WHEN_UNQUOTED: DIGIT | LETTER_WHEN_UNQUOTED_NO_DIGIT; fragment LETTER_WHEN_UNQUOTED_NO_DIGIT: [a-zA-Z_$\u0080-\uffff]; // Any letter but without e/E and digits (which are used to match a decimal number). fragment LETTER_WITHOUT_FLOAT_PART: [a-df-zA-DF-Z_$\u0080-\uffff];
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr3.adb
best08618/asylo
7
19925
<gh_stars>1-10 -- { dg-do run } with Ada.Tags; use Ada.Tags; with Ada.Text_IO; use Ada.Text_IO; procedure aggr3 is package Pkg is type Element is interface; type Event is tagged record V1 : Natural; V2 : Natural; end record; function Create return Event; type D_Event is new Event and Element with null record; function Create return D_Event; end; package body Pkg is function Create return Event is Obj : Event; begin Obj.V1 := 0; return Obj; end; function Create return D_Event is begin return (Event'(Create) with null record); end; end; use Pkg; procedure CW_Test (Obj : Element'Class) is S : Constant String := Expanded_Name (Obj'Tag); begin null; end; begin CW_Test (Create); end;
src/Generic/Lib/Data/Nat.agda
turion/Generic
30
4453
module Generic.Lib.Data.Nat where open import Data.Nat.Base hiding (_⊔_; _^_) public open import Generic.Lib.Decidable instance ℕEq : Eq ℕ ℕEq = viaBase Nat._≟_ where import Data.Nat as Nat foldℕ : ∀ {α} {A : Set α} -> (A -> A) -> A -> ℕ -> A foldℕ f x 0 = x foldℕ f x (suc n) = f (foldℕ f x n)
bb-runtimes/runtimes/zfp-stm32h743/gnat/s-stm32.adb
JCGobbi/Nucleo-STM32H743ZI
0
16751
<filename>bb-runtimes/runtimes/zfp-stm32h743/gnat/s-stm32.adb ------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- Copyright (C) 2012-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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.Unchecked_Conversion; with System.BB.Parameters; with Interfaces; use Interfaces; with Interfaces.STM32; use Interfaces.STM32; with Interfaces.STM32.RCC; use Interfaces.STM32.RCC; package body System.STM32 is package Param renames System.BB.Parameters; HPRE_Presc_Table : constant array (AHB_Prescaler_Enum) of UInt32 := (2, 4, 8, 16, 64, 128, 256, 512); PPRE_Presc_Table : constant array (APB_Prescaler_Enum) of UInt32 := (2, 4, 8, 16); ------------------- -- System_Clocks -- ------------------- function System_Clocks return RCC_System_Clocks is Source : constant SYSCLK_Source := SYSCLK_Source'Val (RCC_Periph.CFGR.SWS); Result : RCC_System_Clocks; begin -- System clock Mux case Source is -- HSE as source when SYSCLK_SRC_HSE => Result.SYSCLK := Param.HSE_Clock; -- HSI as source when SYSCLK_SRC_HSI => Result.SYSCLK := Param.HSI_Clock / (2 ** Natural (RCC_Periph.CR.HSIDIV)); -- HSE as source when SYSCLK_SRC_CSI => Result.SYSCLK := Param.CSI_Clock; -- PLL1 as source when SYSCLK_SRC_PLL => declare Pllm : constant UInt32 := UInt32 (RCC_Periph.PLLCKSELR.DIVM1); -- Get the correct value of Pll M divisor Plln : constant UInt32 := UInt32 (RCC_Periph.PLL1DIVR.DIVN1 + 1); -- Get the correct value of Pll N multiplier Pllp : constant UInt32 := UInt32 (RCC_Periph.PLL1DIVR.DIVR1 + 1); -- Get the correct value of Pll R divisor PLLSRC : constant PLL_Source := PLL_Source'Val (RCC_Periph.PLLCKSELR.PLLSRC); -- Get PLL Source Mux PLLCLK : UInt32; begin case PLLSRC is when PLL_SRC_HSE => -- HSE as source PLLCLK := ((Param.HSE_Clock / Pllm) * Plln) / Pllp; when PLL_SRC_HSI => -- HSI as source PLLCLK := ((Param.HSI_Clock / Pllm) * Plln) / Pllp; when PLL_SRC_CSI => -- CSI as source PLLCLK := ((Param.CSI_Clock / Pllm) * Plln) / Pllp; end case; Result.SYSCLK := PLLCLK; end; end case; declare function To_AHBP is new Ada.Unchecked_Conversion (UInt4, AHB_Prescaler); function To_APBP is new Ada.Unchecked_Conversion (UInt3, APB_Prescaler); -- Get value of AHB1_PRE (D1CPRE prescaler) HPRE1 : constant AHB_Prescaler := To_AHBP (RCC_Periph.D1CFGR.D1CPRE); HPRE1_Div : constant UInt32 := (if HPRE1.Enabled then HPRE_Presc_Table (HPRE1.Value) else 1); -- Get the value of AHB2_PRE (HPRE prescaler) HPRE2 : constant AHB_Prescaler := To_AHBP (RCC_Periph.D1CFGR.HPRE); HPRE2_Div : constant UInt32 := (if HPRE2.Enabled then HPRE_Presc_Table (HPRE2.Value) else 1); -- Get the value of APB1_PRE (D2PPRE1 prescaler) PPRE1 : constant APB_Prescaler := To_APBP (RCC_Periph.D2CFGR.D2PPRE1); PPRE1_Div : constant UInt32 := (if PPRE1.Enabled then PPRE_Presc_Table (PPRE1.Value) else 1); -- Get the value of APB2_PRE (D2PPRE2 prescaler) PPRE2 : constant APB_Prescaler := To_APBP (RCC_Periph.D2CFGR.D2PPRE2); PPRE2_Div : constant UInt32 := (if PPRE2.Enabled then PPRE_Presc_Table (PPRE2.Value) else 1); -- Get the value of APB3_PRE (D1PPRE prescaler) PPRE3 : constant APB_Prescaler := To_APBP (RCC_Periph.D1CFGR.D1PPRE); PPRE3_Div : constant UInt32 := (if PPRE3.Enabled then PPRE_Presc_Table (PPRE3.Value) else 1); -- Get the value of APB4_PRE (D3PPRE prescaler) PPRE4 : constant APB_Prescaler := To_APBP (RCC_Periph.D3CFGR.D3PPRE); PPRE4_Div : constant UInt32 := (if PPRE4.Enabled then PPRE_Presc_Table (PPRE4.Value) else 1); begin Result.HCLK1 := Result.SYSCLK / HPRE1_Div; Result.HCLK2 := Result.HCLK1 / HPRE2_Div; Result.PCLK1 := Result.HCLK2 / PPRE1_Div; Result.PCLK2 := Result.HCLK2 / PPRE2_Div; Result.PCLK3 := Result.HCLK2 / PPRE3_Div; Result.PCLK4 := Result.HCLK2 / PPRE4_Div; -- Timer clocks -- If APB1 (D2PPRE1) and APB2 (D2PPRE2) prescaler (D2PPRE1, D2PPRE2 -- in the RCC_D2CFGR register) are configured to a division factor of -- 1 or 2 with RCC_CFGR.TIMPRE = 0 (or also 4 with RCC_CFGR.TIMPRE -- = 1), then TIMxCLK = PCLKx. -- Otherwise, the timer clock frequencies are set to twice to the -- frequency of the APB domain to which the timers are connected with -- RCC_CFGR.TIMPRE = 0, so TIMxCLK = 2 x PCLKx (or TIMxCLK = -- 4 x PCLKx with RCC_CFGR.TIMPRE = 1). case RCC_Periph.CFGR.TIMPRE is when 0 => -- TIMs 2 .. 7, 12 .. 14 if PPRE1_Div <= 2 then Result.TIMCLK1 := Result.PCLK1; else Result.TIMCLK1 := Result.PCLK1 * 2; end if; -- TIMs TIMs 1, 8, 15 .. 17 if PPRE2_Div <= 2 then Result.TIMCLK2 := Result.PCLK2; else Result.TIMCLK2 := Result.PCLK2 * 2; end if; when 1 => -- TIMs 2 .. 7, 12 .. 14 if PPRE1_Div <= 4 then Result.TIMCLK1 := Result.PCLK1; else Result.TIMCLK1 := Result.PCLK1 * 4; end if; -- TIMs 1, 8, 15 .. 17 if PPRE2_Div <= 4 then Result.TIMCLK2 := Result.PCLK2; else Result.TIMCLK2 := Result.PCLK2 * 4; end if; end case; -- HRTIM clock -- If RCC_CFGR.HRTIMSEL = 0, HRTIM prescaler clock cource is the same -- as timer 2 (TIMCLK1), otherwise it is the CPU clock (HCLK2). case RCC_Periph.CFGR.HRTIMSEL is when 0 => Result.TIMCLK3 := Result.TIMCLK1; when 1 => Result.TIMCLK3 := Result.HCLK1; end case; end; return Result; end System_Clocks; end System.STM32;
smallC/8080/crun.asm
2kranki/SmallC-85
236
14960
<reponame>2kranki/SmallC-85 ; ;***************************************************** ; * ; runtime library for small C compiler * ; * ; c.s - runtime routine for basic C code * ; * ; <NAME> * ; * ;***************************************************** ; cseg ; public ?gchar,?gint,?pchar,?pint public ?sxt public ?or,?and,?xor public ?eq,?ne,?gt,?le,?ge,?lt,?uge,?ult,?ugt,?ule public ?asr,?asl public ?sub,?neg,?com,?lneg,?bool,?mul,?div public ?case,brkend,Xstktop public etext public edata ; ; fetch char from (HL) and sign extend into HL ?gchar: mov a,m ?sxt: mov l,a rlc sbb a mov h,a ret ; fetch int from (HL) ?gint: mov a,m inx h mov h,m mov l,a ret ; store char from HL into (DE) ?pchar: mov a,l stax d ret ; store int from HL into (DE) ?pint: mov a,l stax d inx d mov a,h stax d ret ; "or" HL and DE into HL ?or: mov a,l ora e mov l,a mov a,h ora d mov h,a ret ; "xor" HL and DE into HL ?xor: mov a,l xra e mov l,a mov a,h xra d mov h,a ret ; "and" HL and DE into HL ?and: mov a,l ana e mov l,a mov a,h ana d mov h,a ret ; ;......logical operations: HL set to 0 (false) or 1 (true) ; ; DE == HL ?eq: call ?cmp rz dcx h ret ; DE != HL ?ne: call ?cmp rnz dcx h ret ; DE > HL [signed] ?gt: xchg call ?cmp rc dcx h ret ; DE <= HL [signed] ?le: call ?cmp rz rc dcx h ret ; DE >= HL [signed] ?ge: call ?cmp rnc dcx h ret ; DE < HL [signed] ?lt: call ?cmp rc dcx h ret ; DE >= HL [unsigned] ?uge: call ?ucmp rnc dcx h ret ; DE < HL [unsigned] ?ult: call ?ucmp rc dcx h ret ; DE > HL [unsigned] ?ugt: xchg call ?ucmp rc dcx h ret ; DE <= HL [unsigned] ?ule: call ?ucmp rz rc dcx h ret ; signed compare of DE and HL ; carry is sign of difference [set => DE < HL] ; zero is zero/non-zero ?cmp: mov a,e sub l mov e,a mov a,d sbb h lxi h,1 ;preset true jm ?cmp1 ora e ;resets carry ret ?cmp1: ora e stc ret ; unsigned compare of DE and HL ; carry is sign of difference [set => DE < HL] ; zero is zero/non-zero ?ucmp: mov a,d cmp h jnz ?ucmp1 mov a,e cmp l ?ucmp1: lxi h,1 ;preset true ret ; shift DE right arithmetically by HL, move to HL ?asr: xchg ?asr1: dcr e rm mov a,h ral mov a,h rar mov h,a mov a,l rar mov l,a jmp ?asr1 ; shift DE left arithmetically by HL, move to HL ?asl: xchg ?asl1: dcr e rm dad h jmp ?asl1 ; HL = DE - HL ?sub: mov a,e sub l mov l,a mov a,d sbb h mov h,a ret ; HL = -HL ?neg: call ?com inx h ret ; HL = ~HL ?com: mov a,h cma mov h,a mov a,l cma mov l,a ret ; HL = !HL ?lneg: mov a,h ora l jz ?lneg1 lxi h,0 ret ?lneg1: inx h ret ; HL = !!HL ?bool: call ?lneg jmp ?lneg ; ; HL = DE * HL [signed] ?mul: mov b,h mov c,l lxi h,0 ?mul1: mov a,c rrc jnc ?mul2 dad d ?mul2: xra a mov a,b rar mov b,a mov a,c rar mov c,a ora b rz xra a mov a,e ral mov e,a mov a,d ral mov d,a ora e rz jmp ?mul1 ; HL = DE / HL, DE = DE % HL ?div: mov b,h mov c,l mov a,d xra b push psw mov a,d ora a cm ?deneg mov a,b ora a cm ?bcneg mvi a,16 push psw xchg lxi d,0 ?div1: dad h call ?rdel jz ?div2 call ?cmpbd jm ?div2 mov a,l ori 1 mov l,a mov a,e sub c mov e,a mov a,d sbb b mov d,a ?div2: pop psw dcr a jz ?div3 push psw jmp ?div1 ?div3: pop psw rp call ?deneg xchg call ?deneg xchg ret ; {DE = -DE} ?deneg: mov a,d cma mov d,a mov a,e cma mov e,a inx d ret ; {BC = -BC} ?bcneg: mov a,b cma mov b,a mov a,c cma mov c,a inx b ret ; {DE <r<r 1} ?rdel: mov a,e ral mov e,a mov a,d ral mov d,a ora e ret ; {BC : DE} ?cmpbd: mov a,e sub c mov a,d sbb b ret ; case jump ?case: xchg ;switch value to DE pop h ;get table address ?case1: call ?case4 ;get case value mov a,e cmp c ;equal to switch value ? jnz ?case2 ;no mov a,d cmp b ;equal to switch value ? jnz ?case2 ;no call ?case4 ;get case label jz ?case3 ;end of table, go to default push b ret ;case jump ?case2: call ?case4 ;get case label jnz ?case1 ;next case ?case3: dcx h dcx h dcx h mov d,m dcx h mov e,m xchg pchl ;default jump ?case4: mov c,m inx h mov b,m inx h mov a,c ora b ret ; ; ; Xstktop: lxi h,0 ;return current stack pointer (for sbrk) dad sp ret cseg etext: dseg brkend: dw edata ;current "break" edata: ; ; ; end
orka/src/orka/windows/orka-os.adb
onox/orka
52
3181
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with System; with Ada.Characters.Latin_1; package body Orka.OS is procedure Set_Task_Name (Name : in String) is begin null; end Set_Task_Name; function Monotonic_Clock return Duration is begin raise Program_Error with "BUG: Monotonic_Clock not implemented yet on Windows"; return 0.0; end Monotonic_Clock; function Monotonic_Clock return Time is (Time (Duration'(Monotonic_Clock))); ---------------------------------------------------------------------------- subtype Size_Type is Interfaces.C.unsigned_long; procedure C_Fwrite (Value : String; Size : Size_Type; Count : Size_Type; File : System.Address) with Import, Convention => C, External_Name => "fwrite"; File_Standard_Output : constant System.Address with Import, Convention => C, External_Name => "stdout"; File_Standard_Error : constant System.Address with Import, Convention => C, External_Name => "stderr"; procedure Put_Line (Value : String; Kind : File_Kind := Standard_Output) is package L1 renames Ada.Characters.Latin_1; C_Value : constant String := Value & L1.LF; begin C_Fwrite (C_Value, 1, C_Value'Length, (case Kind is when Standard_Output => File_Standard_Output, when Standard_Error => File_Standard_Error)); end Put_Line; end Orka.OS;
MdePkg/Library/BaseLib/Ia32/ReadEflags.nasm
kokweich/slimbootloader
9
173605
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; ReadEflags.Asm ; ; Abstract: ; ; AsmReadEflags function ; ; Notes: ; ;------------------------------------------------------------------------------ SECTION .text ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmReadEflags ( ; VOID ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmReadEflags) ASM_PFX(AsmReadEflags): pushfd pop eax ret
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_837.asm
ljhsiun2/medusa
9
166630
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r11 push %r15 push %r9 push %rbp push %rbx push %rdi push %rsi // Store lea addresses_WT+0x18011, %r9 nop nop nop nop nop dec %rbx movl $0x51525354, (%r9) cmp $63079, %r11 // Faulty Load lea addresses_WT+0x18011, %r9 nop nop nop nop nop cmp $46689, %rdi vmovups (%r9), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %rbx lea oracles, %r15 and $0xff, %rbx shlq $12, %rbx mov (%r15,%rbx,1), %rbx pop %rsi pop %rdi pop %rbx pop %rbp pop %r9 pop %r15 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
Parser/Grammars/TeuchiUdonParser.g4
akanevrc/TeuchiUdon
5
5074
<reponame>akanevrc/TeuchiUdon parser grammar TeuchiUdonParser; options { language=CSharp; superClass=TeuchiUdonBaseParser; tokenVocab=TeuchiUdonLexer; } @parser::header { #pragma warning disable 3021 } target returns [TargetResult result] : body EOF | EOF ; body returns [BodyResult result] : topStatement+ ; topStatement returns [TopStatementResult result] : varAttr* varBind ';' #VarBindTopStatement | expr ';' #ExprTopStatement ; varAttr returns [VarAttrResult result] : '@public' #PublicVarAttr | '@sync' #SyncVarAttr | '@linear' #LinearVarAttr | '@smooth' #SmoothVarAttr ; varBind returns [VarBindResult result, int tableIndex] : 'mut'? varDecl[true] '=' expr ; varDecl[bool isActual] returns [VarDeclResult result] : '(' ')' #UnitVarDecl | qualifiedVar #SingleVarDecl | '(' qualifiedVar (',' qualifiedVar)* ')' #TupleVarDecl ; qualifiedVar returns [QualifiedVarResult result] : identifier (':' expr)? ; identifier returns [IdentifierResult result] : IDENTIFIER ; statement returns [StatementResult result, int tableIndex] : 'return' #ReturnUnitStatement | 'return' expr #ReturnValueStatement | 'continue' #ContinueUnitStatement | 'continue' expr #ContinueValueStatement | 'break' #BreakUnitStatement | 'break' expr #BreakValueStatement | 'let' varBind #LetBindStatement | expr #ExprStatement ; expr returns [ExprResult result, int tableIndex] : '{' (statement ';')* '}' #UnitBlockExpr | '{' (statement ';')* expr '}' #ValueBlockExpr | '(' expr ')' #ParenExpr | '(' expr (',' expr)+ ')' #TupleExpr | '[|' '|]' #EmptyArrayCtorExpr | '[|' iterExpr '|]' #ArrayCtorExpr | '[' ']' #EmptyListCtorExpr | '[' iterExpr (',' iterExpr)* ']' #ListCtorExpr | literal #LiteralExpr | thisLiteral #ThisLiteralExpr | interpolatedRegularString #InterpolatedRegularStringExpr | identifier #EvalVarExpr | 'typeof' #EvalTypeOfExpr | expr op=('.' | '?.') expr #AccessExpr | expr '.' 'cast' #CastExpr | expr '(' ')' #EvalUnitFuncExpr | expr '(' argExpr ')' #EvalSingleFuncExpr | expr '(' argExpr (',' argExpr)+ ')' #EvalTupleFuncExpr | expr '(' '...' expr ')' #EvalSpreadFuncExpr | expr '[' expr ']' #EvalSingleKeyExpr | expr '[' expr (',' expr)+ ']' #EvalTupleKeyExpr | op=('+' | '-' | '!' | '~') expr #PrefixExpr | expr op=('*' | '/' | '%') expr #MultiplicationExpr | expr op=('+' | '-') expr #AdditionExpr | expr op=('<<' | '>>') expr #ShiftExpr | expr op=('<' | '>' | '<=' | '>=') expr #RelationExpr | expr op=('==' | '!=') expr #EqualityExpr | expr op='&' expr #LogicalAndExpr | expr op='^' expr #LogicalXorExpr | expr op='|' expr #LogicalOrExpr | expr op='&&' expr #ConditionalAndExpr | expr op='||' expr #ConditionalOrExpr | expr op='??' expr #CoalescingExpr | expr '|>' expr #RightPipelineExpr |<assoc=right> expr '<|' expr #LeftPipelineExpr |<assoc=right> expr op='<-' expr #AssignExpr | 'let' varBind 'in' expr #LetInBindExpr |<assoc=right> 'if' isoExpr 'then' statement #IfExpr |<assoc=right> 'if' isoExpr 'then' statement ('elif' isoExpr 'then' statement)+ #IfElifExpr |<assoc=right> 'if' isoExpr 'then' isoExpr 'else' isoExpr #IfElseExpr |<assoc=right> 'if' isoExpr 'then' isoExpr ('elif' isoExpr 'then' isoExpr)+ 'else' isoExpr #IfElifElseExpr |<assoc=right> 'while' isoExpr 'do' expr #WhileExpr |('for' forBind)+ 'do' expr #ForExpr |'loop' expr #LoopExpr | varDecl[false] '->' expr #FuncExpr ; iterExpr returns [IterExprResult result] : isoExpr (',' isoExpr)* #ElementsIterExpr | expr '..' expr #RangeIterExpr | expr '..' expr '..' expr #SteppedRangeIterExpr | '...' expr #SpreadIterExpr ; argExpr returns [ArgExprResult result] : 'ref'? expr ; forBind returns [ForBindResult result, int tableIndex] : 'let' varDecl[true] '<-' forIterExpr #LetForBind | expr '<-' forIterExpr #AssignForBind ; forIterExpr returns [IterExprResult result] : expr '..' expr #RangeForIterExpr | expr '..' expr '..' expr #SteppedRangeForIterExpr | expr #SpreadForIterExpr ; isoExpr returns [IsoExprResult result] : expr ; literal returns [LiteralResult result] : '(' ')' #UnitLiteral | NULL_LITERAL #NullLiteral | BOOL_LITERAL #BoolLiteral | INTEGER_LITERAL #IntegerLiteral | HEX_INTEGER_LITERAL #HexIntegerLiteral | BIN_INTEGER_LITERAL #BinIntegerLiteral | REAL_LITERAL #RealLiteral | CHARACTER_LITERAL #CharacterLiteral | REGULAR_STRING #RegularString | VERBATIUM_STRING #VervatiumString ; thisLiteral returns [ThisResult result] : THIS_LITERAL ; interpolatedRegularString returns [InterpolatedStringResult result] : INTERPOLATED_REGULAR_STRING_START interpolatedRegularStringPart* DOUBLE_QUOTE_INSIDE ; interpolatedRegularStringPart returns [InterpolatedStringPartResult result] : REGULAR_STRING_INSIDE #RegularStringInterpolatedStringPart | isoExpr #ExprInterpolatedStringPart ;
source/receiver/main/ints.ads
reznikmm/gps-tracker
0
27946
-- SPDX-FileCopyrightText: 2021 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Ada.Interrupts.Names; package Ints is protected Signal is entry Wait (RX_Done : out Boolean; RX_Timeout : out Boolean); private Done : Boolean := False; Timeout : Boolean := False; Got : Boolean := False; -- Done or Timeout procedure Handler with Attach_Handler => Ada.Interrupts.Names.GPIO_INTERRUPT; end Signal; end Ints;
vendor/stdlib/src/Data/BoundedVec/Inefficient.agda
isabella232/Lemmachine
56
7866
<reponame>isabella232/Lemmachine<filename>vendor/stdlib/src/Data/BoundedVec/Inefficient.agda ------------------------------------------------------------------------ -- Bounded vectors (inefficient, concrete implementation) ------------------------------------------------------------------------ -- Vectors of a specified maximum length. module Data.BoundedVec.Inefficient where open import Data.Nat open import Data.List ------------------------------------------------------------------------ -- The type infixr 5 _∷_ data BoundedVec (a : Set) : ℕ → Set where [] : ∀ {n} → BoundedVec a n _∷_ : ∀ {n} (x : a) (xs : BoundedVec a n) → BoundedVec a (suc n) ------------------------------------------------------------------------ -- Increasing the bound -- Note that this operation is linear in the length of the list. ↑ : ∀ {a n} → BoundedVec a n → BoundedVec a (suc n) ↑ [] = [] ↑ (x ∷ xs) = x ∷ ↑ xs ------------------------------------------------------------------------ -- Conversions fromList : ∀ {a} → (xs : List a) → BoundedVec a (length xs) fromList [] = [] fromList (x ∷ xs) = x ∷ fromList xs toList : ∀ {a n} → BoundedVec a n → List a toList [] = [] toList (x ∷ xs) = x ∷ toList xs
grammars/EMail.g4
SadraGoudarzdashti/IUSTCompiler
3
6020
/* grammer EMail1 (version 1) @author: <NAME>, (http://webpages.iust.ac.ir/morteza_zakeri/) @date: 20201025 - Compiler generator: ANTRL4.x - Target language(s): Python3.x, -Changelog: -- v1 --- - Reference: Compiler book by Dr. Saeed Parsa (http://parsa.iust.ac.ir/) - Course website: http://parsa.iust.ac.ir/courses/compilers/ - Laboratory website: http://reverse.iust.ac.ir/ */ grammar EMail; start: LocalPart'@'Domain; LocalPart: LocalPartRule+; Domain: LETTER(LETTER|DIGIT|'-')*'.'ListOfDomain; LocalPartRule: LETTER|DIGIT|PrintableCharacters|'.'; LETTER: [A-Za-z]; PrintableCharacters: '!'|'#'|'$'|'%'|'&'|'\''|'*'|'+'|'-'|'/'|'='|'?'|'^'|'_'|'`'|'{'|'}'|'~'; DIGIT: [0-9]; ListOfDomain: 'com'|'org'|'net'|'ir'|'info'|'gov';
source/s-once.adb
ytomino/drake
33
397
with System.Storage_Barriers; with System.Synchronous_Control; package body System.Once is pragma Suppress (All_Checks); Yet : constant := 0; Start : constant := 1; Done : constant := 2; function atomic_load ( ptr : not null access constant Flag; memorder : Integer := Storage_Barriers.ATOMIC_ACQUIRE) return Flag with Import, Convention => Intrinsic, External_Name => "__atomic_load_1"; procedure atomic_store ( ptr : not null access Flag; val : Flag; memorder : Integer := Storage_Barriers.ATOMIC_RELEASE) with Import, Convention => Intrinsic, External_Name => "__atomic_store_1"; function atomic_compare_exchange ( ptr : not null access Flag; expected : not null access Flag; desired : Flag; weak : Boolean := False; success_memorder : Integer := Storage_Barriers.ATOMIC_ACQ_REL; failure_memorder : Integer := Storage_Barriers.ATOMIC_ACQUIRE) return Boolean with Import, Convention => Intrinsic, External_Name => "__atomic_compare_exchange_1"; -- implementation procedure Initialize ( Flag : not null access Once.Flag; Process : not null access procedure) is Expected : aliased Once.Flag := Yet; begin if atomic_compare_exchange (Flag, Expected'Access, Start) then -- succeeded to swap Process.all; atomic_store (Flag, Done); elsif Expected = Start then -- wait until Flag = Done loop Synchronous_Control.Yield; exit when atomic_load (Flag) = Done; end loop; end if; -- Flag = Done end Initialize; end System.Once;
programs/oeis/158/A158136.asm
karttu/loda
1
81366
<reponame>karttu/loda ; A158136: a(n) = 144*n - 1. ; 143,287,431,575,719,863,1007,1151,1295,1439,1583,1727,1871,2015,2159,2303,2447,2591,2735,2879,3023,3167,3311,3455,3599,3743,3887,4031,4175,4319,4463,4607,4751,4895,5039,5183,5327,5471,5615,5759,5903,6047,6191,6335,6479,6623,6767,6911,7055,7199,7343,7487,7631,7775,7919,8063,8207,8351,8495,8639,8783,8927,9071,9215,9359,9503,9647,9791,9935,10079,10223,10367,10511,10655,10799,10943,11087,11231,11375,11519,11663,11807,11951,12095,12239,12383,12527,12671,12815,12959,13103,13247,13391,13535,13679,13823,13967,14111,14255,14399,14543,14687,14831,14975,15119,15263,15407,15551,15695,15839,15983,16127,16271,16415,16559,16703,16847,16991,17135,17279,17423,17567,17711,17855,17999,18143,18287,18431,18575,18719,18863,19007,19151,19295,19439,19583,19727,19871,20015,20159,20303,20447,20591,20735,20879,21023,21167,21311,21455,21599,21743,21887,22031,22175,22319,22463,22607,22751,22895,23039,23183,23327,23471,23615,23759,23903,24047,24191,24335,24479,24623,24767,24911,25055,25199,25343,25487,25631,25775,25919,26063,26207,26351,26495,26639,26783,26927,27071,27215,27359,27503,27647,27791,27935,28079,28223,28367,28511,28655,28799,28943,29087,29231,29375,29519,29663,29807,29951,30095,30239,30383,30527,30671,30815,30959,31103,31247,31391,31535,31679,31823,31967,32111,32255,32399,32543,32687,32831,32975,33119,33263,33407,33551,33695,33839,33983,34127,34271,34415,34559,34703,34847,34991,35135,35279,35423,35567,35711,35855,35999 mov $1,$0 mul $1,144 add $1,143
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_669.asm
ljhsiun2/medusa
9
18248
.global s_prepare_buffers s_prepare_buffers: push %r10 push %rax push %rcx push %rdi push %rsi lea addresses_normal_ht+0xc483, %rsi lea addresses_WT_ht+0xa483, %rdi nop nop cmp %r10, %r10 mov $16, %rcx rep movsl nop nop inc %rax pop %rsi pop %rdi pop %rcx pop %rax pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r15 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi // Store lea addresses_UC+0x18643, %r12 nop add %r9, %r9 mov $0x5152535455565758, %rcx movq %rcx, (%r12) xor $44785, %r9 // Store lea addresses_UC+0xda83, %rcx nop nop nop nop sub $1170, %r14 mov $0x5152535455565758, %r9 movq %r9, %xmm6 vmovups %ymm6, (%rcx) nop nop nop nop nop cmp $37862, %r12 // REPMOV lea addresses_normal+0x6923, %rsi lea addresses_PSE+0x128c3, %rdi nop nop nop nop inc %rbx mov $24, %rcx rep movsl nop nop nop nop sub $6682, %rbx // Store lea addresses_UC+0x6c83, %rsi add %rcx, %rcx movl $0x51525354, (%rsi) nop nop nop sub %r14, %r14 // Store lea addresses_WT+0xa493, %rcx nop nop nop nop nop cmp %r15, %r15 movw $0x5152, (%rcx) nop nop nop nop nop dec %rdi // Store lea addresses_WT+0xae2b, %r12 nop xor $45318, %rcx mov $0x5152535455565758, %r14 movq %r14, (%r12) xor %rbx, %rbx // Store lea addresses_WC+0x1cacf, %r12 nop nop nop nop nop cmp $55053, %r15 mov $0x5152535455565758, %rdi movq %rdi, %xmm6 movups %xmm6, (%r12) nop nop nop nop sub $13825, %r15 // Load lea addresses_WC+0xba43, %rbp nop nop nop add $28385, %r14 mov (%rbp), %si nop nop and $59500, %r15 // Store lea addresses_UC+0x1a4d7, %rsi nop nop inc %r14 mov $0x5152535455565758, %rbx movq %rbx, (%rsi) nop nop nop nop nop xor %rsi, %rsi // Store lea addresses_UC+0x16a63, %r9 nop nop nop nop add $18863, %rdi movl $0x51525354, (%r9) nop nop nop nop nop sub %r14, %r14 // Faulty Load lea addresses_PSE+0x18c83, %rcx nop nop nop nop cmp %rbp, %rbp vmovups (%rcx), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $0, %xmm7, %r12 lea oracles, %r14 and $0xff, %r12 shlq $12, %r12 mov (%r14,%r12,1), %r12 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r15 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 4, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 8, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_normal'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'dst': {'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 3, 'same': False, 'type': 'addresses_WT'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 2, 'same': False, 'type': 'addresses_WT'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6, 'same': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 10, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
asm/spim/csc-201/h1.asm
dindoliboon/archive
4
164265
<gh_stars>1-10 # ========================================================================= # # NAME: # DATE: May 23, 2001 # ASSIGNMENT: Homework #1, CSC-201-01 # OBJECTIVE: Read an integer from the keyboard and double the number. Then # double the result. Finally, subtract the input number from # the quadrupled number. The number should be shown each time # a mathematical operation has been applied. # # ========================================================================= .data .align 2 # ========================================================================= prompt1: .asciiz "Enter a number: " prompt2: .asciiz " Input doubled: " prompt3: .asciiz "Doubled result: " prompt4: .asciiz " Final answer: " newline: .asciiz "\n" # ========================================================================= .text .align 2 main: # ========================================================================= # # $t0 - input number # $t1 - input number * 2 # $t2 - input number * 4 # $t3 - input number * 4 - input number # # ========================================================================= # ::::: OP :::: ARGUMENTS ::::::::::::: COMMENTS :::::::::::::::::::::::::: # ========================================================================= la $a0, prompt1 li $v0, 4 syscall # print "Enter a number: " li $v0, 5 syscall # read number from keyboard move $t0, $v0 # save orginal number # ========================================================================= add $t1, $t0, $t0 # double = input + input la $a0, prompt2 li $v0, 4 syscall # print " Input doubled: " move $a0, $t1 li $v0, 1 syscall # print doubled number la $a0, newline li $v0, 4 syscall # print new line # ========================================================================= add $t2, $t1, $t1 # quadruple = double + double la $a0, prompt3 li $v0, 4 syscall # print "Doubled result: " move $a0, $t2 li $v0, 1 syscall # print doubled number la $a0, newline li $v0, 4 syscall # print new line # ========================================================================= sub $t3, $t2, $t0 # answer = quadruple - input la $a0, prompt4 li $v0, 4 syscall # print " Final answer: " move $a0, $t3 li $v0, 1 syscall # print doubled number la $a0, newline li $v0, 4 syscall # print new line # ========================================================================= li $v0, 10 syscall # exit program # ========================================================================= # :::::::::::::::::::::::::::: END OF PROGRAM! :::::::::::::::::::::::::::: # =========================================================================
main.scpt
chris1111/Icnspack-Builder
65
4594
<filename>main.scpt # Version "1.1" Icnspack-Builder Copyright (c) 2020,chris1111 All right reserved use AppleScript version "2.4" -- Yosemite (10.10) or later use scripting additions -- Properties configuting the droplet shell property appletDropImage : "IMGDocumentIcon" property appletDropName : "Drop your Image files here" property appletSearchName : "Find Image files" property appletSearchImage : "IMGBadge" global appletIsQuitting --on appletFileIsAcceptable(theFile) -- return true --end appletFileIsAcceptable on open dropped_files do shell script "afplay '/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/System/payment_success.aif' &> /dev/null &" do shell script "rm -rf /tmp/Resource" do shell script "rm -rf /tmp/Icon" do shell script "rm -rf /tmp/Resource.zip" do shell script "mkdir -p /Private/tmp/Resource" do shell script "mkdir -p /Private/tmp/Icon" log "theFiles" & dropped_files set countFiles to count of dropped_files try set progress total steps to countFiles set progress completed steps to 0 set progress description to "Processing images with Optimization! Wait…" delay 2 display dialog " Ready to proceed and create the themes. An output ZIP file will be created (Resource.zip)" with icon note buttons {"Ready"} default button {"Ready"} {"Ready"} tell application "Icnspack-Builder" activate end tell set progress additional description to "Ready" set steps to 0 repeat with aFile in dropped_files set steps to steps + 1 set progress completed steps to steps set progress additional description to (name of (info for aFile)) & " (" & steps & "/" & countFiles & ")" delay 0.2 --1.0E-3 end repeat display alert "Files Dropped!" message (countFiles as text) giving up after 1 ## Set use_terminal to true to run the script in a terminal set use_terminal to true ## Set exit_terminal to true to leave the terminal session open after script runs set exit_terminal to true ## Set log_file to a file path to have the output captured set file_list to "" set theFonts to dropped_files repeat with f in theFonts set fposix to the quoted form of the POSIX path of f do shell script "rsync " & fposix & " /tmp/Icon" end repeat set the_command to quoted form of POSIX path of (path to resource "icnspack-Build" in directory "Scripts") repeat with file_path in dropped_files set file_list to file_list & " " & quoted form of POSIX path of file_path end repeat set the_command to the_command & " " & file_list try if log_file is not missing value then set the_command to the_command & " | tee -a " & log_file end if end try try set use_terminal to false end try if not use_terminal then do shell script "afplay '/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/System/Volume Unmount.aif' &> /dev/null &" do shell script the_command set progress additional description to "Build Done!" delay 1 display alert "The images have been transformed into Icons" buttons "Done" default button "Done" giving up after 5 set theAction to button returned of (display dialog " Please select a destination to save the file Resource.zip NOTE: If you have already a Resource.zip in this location, you must move it or rename to save another one otherwise it will be replaced." with icon note buttons {"Save"} default button {"Save"}) {"Save"} if theAction = "Save" then end if tell application "Finder" set sourceFolder to (POSIX file "/Private/tmp/Resource.zip") as alias set DestFolder to choose folder with prompt "Choose destination Location" default location (path to desktop) duplicate sourceFolder to folder DestFolder with replacing end tell delay 0.5 set myFile to "/Private/tmp/Resource.zip" try do shell script "rm -rf " & quoted form of myFile end try end if end try end open
programs/oeis/253/A253944.asm
neoneye/loda
22
95129
; A253944: a(n) = 3*binomial(n+1,7). ; 3,24,108,360,990,2376,5148,10296,19305,34320,58344,95472,151164,232560,348840,511632,735471,1038312,1442100,1973400,2664090,3552120,4682340,6107400,7888725,10097568,12816144,16138848,20173560,25043040,30886416,37860768 add $0,7 bin $0,7 mul $0,3
src/input/input_live.asm
furrtek/GB303
90
90443
<reponame>furrtek/GB303 input_live: call playstop ld a,(JOYP_CURRENT) ;Select ? bit 2,a ret nz ld a,(JOYP_ACTIVE) ;A bit 1,a jr z,+ ld a,(DRUMSMUTE) xor 1 ld (DRUMSMUTE),a call drumsicon +: ld a,(JOYP_ACTIVE) ;A bit 0,a jr z,+ ld a,(LIVE_CURY) ;In pot link matrix ? cp 6 jr z,+ ld a,(LIVE_CURX) or a jr nz,++ call liv_erasepotlinks ;Column 1 ld a,(POTLINK1) call liv_resetlastlink ld a,(LIVE_CURY) ld (POTLINK1),a call liv_drawpotlinks jr + ++: dec a jr nz,++ call liv_erasepotlinks ;Column 2 ld a,(POTLINK2) call liv_resetlastlink ld a,(LIVE_CURY) ld (POTLINK2),a call liv_drawpotlinks jr + ++: dec a jr nz,+ call liv_erasepotlinks ;Column 3 ld a,(POTLINK3) call liv_resetlastlink ld a,(LIVE_CURY) ld (POTLINK3),a call liv_drawpotlinks +: ld a,(JOYP_ACTIVE) ;Right bit 4,a jr z,+ ld a,(JOYP_CURRENT) bit 0,a jr z,++ ld a,(LIVE_CURY) ;A+Right cp 6 jr nz,+ ld a,(LIVE_CURX) ;In dist/osc line or a jr nz,+++ ld a,(DISTTYPE) ;In dist item cp 2 jr z,+ inc a ld (DISTTYPE),a jr + +++: ld a,(OSCTYPEOVD) ;In osc item cp 2 jr z,+ inc a ld (OSCTYPEOVD),a jr + ++: ld a,(LIVE_CURY) ;Right only cp 6 jr z,++ ld a,(LIVE_CURX) ;In pot link matrix cp 2 jr z,+ inc a ld (LIVE_CURX),a call redrawcur_liv jr + ++: ld a,(LIVE_CURX) ;Dist/osc line or a jr nz,+ inc a ld (LIVE_CURX),a call redrawcur_liv +: ld a,(JOYP_ACTIVE) ;Left bit 5,a jr z,+ ld a,(JOYP_CURRENT) bit 0,a jr z,++ ld a,(LIVE_CURY) ;A+Left cp 6 jr nz,+ ld a,(LIVE_CURX) ;In dist/osc line or a jr nz,+++ ld a,(DISTTYPE) ;In dist item or a jr z,+ dec a ld (DISTTYPE),a jr + +++: ld a,(OSCTYPEOVD) ;In osc item or a jr z,+ dec a ld (OSCTYPEOVD),a jr + ++: ld a,(LIVE_CURX) ;Left only or a jr z,+ dec a ld (LIVE_CURX),a call redrawcur_liv +: ld a,(JOYP_ACTIVE) ;Up bit 6,a jr z,+ ld a,(LIVE_CURY) ;Up only or a jr z,+ dec a ld (LIVE_CURY),a call redrawcur_liv +: ld a,(JOYP_ACTIVE) ;Down bit 7,a jr z,+ ld a,(LIVE_CURY) ;Down only cp 6 jr z,+ inc a ld (LIVE_CURY),a cp 6 jr nz,++ ld a,(LIVE_CURX) ;Re-adjust CURX when going to last line (only 2 items instead of 3) cp 2 jr nz,++ ld a,1 ld (LIVE_CURX),a ++: call redrawcur_liv +: ret drumsicon: ld a,(DRUMSMUTE) ld hl,$9800+5 or a ld a,'B'-TXT_INVERT jr z,++ ld a,'B'-TXT_NORMAL ++: di call wait_write ld (hl),a ei ret redrawcur_liv: ;Set previous cur to normal ld a,(LIVE_PREVX) ld c,a sla a ld b,a sla a add b add c ;X*7 ld b,a ld a,(LIVE_PREVY) ;+Y add b ld hl,liv_curlist call liv_curcommon -: di call wait_write ld a,(hl) ei and $3F di call wait_write ldi (hl),a ei dec b jr nz,- ;Set current cursor to inverted ld a,(LIVE_CURX) ld c,a sla a ld b,a sla a add b add c ;X*7 ld b,a ld a,(LIVE_CURY) ;+Y add b ld hl,liv_curlist call liv_curcommon -: di call wait_write ld a,(hl) ei or $40 di call wait_write ldi (hl),a ei dec b jr nz,- ld a,(LIVE_CURX) ld (LIVE_PREVX),a ld a,(LIVE_CURY) ld (LIVE_PREVY),a ret liv_curcommon: ld b,a sla a add b rst 0 inc hl push hl ld hl,$9800 call getline pop de ld a,(de) inc de ld b,0 ld c,a add hl,bc ld a,(de) ld b,a ret liv_curlist: ;Line,start,len .db 4,2,4 .db 5,2,4 .db 6,2,4 .db 7,2,4 .db 8,2,4 .db 9,2,4 .db 11,2,4 .db 4,8,4 .db 5,8,4 .db 6,8,4 .db 7,8,4 .db 8,8,4 .db 9,8,4 .db 11,12,3 .db 4,14,4 .db 5,14,4 .db 6,14,4 .db 7,14,4 .db 8,14,4 .db 9,14,4 ;Last entry unused, handled in code liv_resetlastlink: ld hl,jt_rll rst 0 ld b,a inc hl ldi a,(hl) ld h,(hl) ld l,a ld (hl),b ret jt_rll: .dw 0,CUTOFF .dw 0,RESON .dw 0,BEND .dw 24,SLIDESPEED .dw 20,LFOSPEED .dw 12,LFOAMP
alloy4fun_models/trashltl/models/13/NPdaE7aH5GrGAwreS.als
Kaixi26/org.alloytools.alloy
0
3921
<gh_stars>0 open main pred idNPdaE7aH5GrGAwreS_prop14 { all f:File&Protected&Trash | after f in File&Trash } pred __repair { idNPdaE7aH5GrGAwreS_prop14 } check __repair { idNPdaE7aH5GrGAwreS_prop14 <=> prop14o }
alloy4fun_models/trashltl/models/11/qFDnxv5TRETEFS4sz.als
Kaixi26/org.alloytools.alloy
0
4693
open main pred idqFDnxv5TRETEFS4sz_prop12 { always all f: File | f in Trash or eventually f in Trash } pred __repair { idqFDnxv5TRETEFS4sz_prop12 } check __repair { idqFDnxv5TRETEFS4sz_prop12 <=> prop12o }
oeis/295/A295581.asm
neoneye/loda-programs
11
245031
; A295581: Maximal value of a length-n "minimal cyclically good sequence" in the sense of Cavenagh et al. (2006). ; Submitted by <NAME> ; 3,5,6,8,9,11,13,15,18,21,23,26,29 mov $3,$0 trn $0,6 mul $3,5 lpb $3 add $2,1 sub $3,1 mov $5,$2 div $5,3 add $5,$0 mov $4,$5 div $4,2 cmp $4,0 add $5,$4 lpe mov $0,$5 add $0,3
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/dispatch2_p.ads
best08618/asylo
0
10398
<reponame>best08618/asylo package dispatch2_p is type Object is tagged null record; type Object_Ptr is access all Object'CLASS; -- function Impl_Of (Self : access Object) return Object_Ptr; function Get_Ptr (Self : access Object) return Object_Ptr renames Impl_Of; end;
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_21829_1972.asm
ljhsiun2/medusa
9
246124
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r15 push %rbp push %rdi push %rdx push %rsi lea addresses_WC_ht+0xb3b1, %rdi clflush (%rdi) nop xor $23098, %rbp movb (%rdi), %r15b nop nop nop nop nop inc %rdx lea addresses_WC_ht+0x471d, %r13 nop nop nop nop cmp %r14, %r14 movb $0x61, (%r13) nop nop nop nop nop xor $56795, %rdx lea addresses_UC_ht+0x1a31d, %rdx nop nop nop nop sub %r14, %r14 mov $0x6162636465666768, %r15 movq %r15, %xmm6 and $0xffffffffffffffc0, %rdx movaps %xmm6, (%rdx) nop nop nop nop dec %rdx pop %rsi pop %rdx pop %rdi pop %rbp pop %r15 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r9 push %rcx push %rdi push %rsi // Faulty Load lea addresses_A+0xa31d, %rdi nop nop nop nop nop xor $27416, %r9 movups (%rdi), %xmm0 vpextrq $0, %xmm0, %r13 lea oracles, %rdi and $0xff, %r13 shlq $12, %r13 mov (%rdi,%r13,1), %r13 pop %rsi pop %rdi pop %rcx pop %r9 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': True}} {'35': 21829} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
programs/oeis/040/A040648.asm
neoneye/loda
22
247528
; A040648: Continued fraction for sqrt(674). ; 25,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24,1,50,1,24 gcd $0,262156 mul $0,42 mod $0,13 mov $1,$0 div $1,5 mul $1,20 add $0,$1 mul $0,2 sub $0,6 div $0,2 add $0,1
oeis/181/A181565.asm
neoneye/loda-programs
11
170173
; A181565: a(n) = 3*2^n + 1. ; 4,7,13,25,49,97,193,385,769,1537,3073,6145,12289,24577,49153,98305,196609,393217,786433,1572865,3145729,6291457,12582913,25165825,50331649,100663297,201326593,402653185,805306369,1610612737,3221225473,6442450945,12884901889,25769803777,51539607553,103079215105,206158430209,412316860417,824633720833,1649267441665,3298534883329,6597069766657,13194139533313,26388279066625,52776558133249,105553116266497,211106232532993,422212465065985,844424930131969,1688849860263937,3377699720527873 mov $1,2 pow $1,$0 mul $1,3 add $1,1 mov $0,$1
libpok/ada/arinc653/apex-semaphores.ads
samueltardieu/pok
1
28929
<filename>libpok/ada/arinc653/apex-semaphores.ads<gh_stars>1-10 -- POK header -- -- The following file is a part of the POK project. Any modification should -- be made according to the POK licence. You CANNOT use this file or a part -- of a file for your own project. -- -- For more information on the POK licence, please see our LICENCE FILE -- -- Please follow the coding guidelines described in doc/CODING_GUIDELINES -- -- Copyright (c) 2007-2020 POK team -- --------------------------------------------------------------------------- -- -- -- SEMAPHORE constant and type definitions and management services -- -- -- -- --------------------------------------------------------------------------- with APEX.Processes; package APEX.Semaphores is Max_Number_Of_Semaphores : constant := System_Limit_Number_Of_Semaphores; Max_Semaphore_Value : constant := 32_767; subtype Semaphore_Name_Type is Name_Type; type Semaphore_Id_Type is private; Null_Semaphore_Id : constant Semaphore_Id_Type; type Semaphore_Value_Type is new APEX_Integer range 0 .. Max_Semaphore_Value; type Semaphore_Status_Type is record Current_Value : Semaphore_Value_Type; Maximum_Value : Semaphore_Value_Type; Waiting_Processes : APEX.Processes.Waiting_Range_Type; end record; procedure Create_Semaphore (Semaphore_Name : in Semaphore_Name_Type; Current_Value : in Semaphore_Value_Type; Maximum_Value : in Semaphore_Value_Type; Queuing_Discipline : in Queuing_Discipline_Type; Semaphore_Id : out Semaphore_Id_Type; Return_Code : out Return_Code_Type); procedure Wait_Semaphore (Semaphore_Id : in Semaphore_Id_Type; Time_Out : in System_Time_Type; Return_Code : out Return_Code_Type); procedure Signal_Semaphore (Semaphore_Id : in Semaphore_Id_Type; Return_Code : out Return_Code_Type); procedure Get_Semaphore_Id (Semaphore_Name : in Semaphore_Name_Type; Semaphore_Id : out Semaphore_Id_Type; Return_Code : out Return_Code_Type); procedure Get_Semaphore_Status (Semaphore_Id : in Semaphore_Id_Type; Semaphore_Status : out Semaphore_Status_Type; Return_Code : out Return_Code_Type); private type Semaphore_Id_Type is new APEX_Integer; Null_Semaphore_Id : constant Semaphore_Id_Type := 0; pragma Convention (C, Semaphore_Status_Type); -- POK BINDINGS pragma Import (C, Create_Semaphore, "CREATE_SEMAPHORE"); pragma Import (C, Wait_Semaphore, "WAIT_SEMAPHORE"); pragma Import (C, Signal_Semaphore, "SIGNAL_SEMAPHORE"); pragma Import (C, Get_Semaphore_Id, "GET_SEMAPHORE_ID"); pragma Import (C, Get_Semaphore_Status, "GET_SEMAPHORE_STATUS"); -- END OF POK BINDINGS end APEX.Semaphores;
programs/oeis/181/A181543.asm
jmorken/loda
1
2050
<gh_stars>1-10 ; A181543: Triangle of cubed binomial coefficients, T(n,k) = C(n,k)^3, read by rows. ; 1,1,1,1,8,1,1,27,27,1,1,64,216,64,1,1,125,1000,1000,125,1,1,216,3375,8000,3375,216,1,1,343,9261,42875,42875,9261,343,1,1,512,21952,175616,343000,175616,21952,512,1,1,729,46656,592704,2000376,2000376,592704,46656,729,1,1,1000,91125,1728000,9261000,16003008,9261000,1728000,91125,1000,1,1,1331,166375,4492125,35937000,98611128,98611128,35937000,4492125,166375,1331,1,1,1728,287496,10648000,121287375,496793088,788889024,496793088,121287375,10648000,287496,1728,1,1,2197,474552,23393656,365525875,2131746903,5053029696,5053029696,2131746903,365525875,23393656,474552,2197,1,1,2744,753571,48228544,1003003001,8024024008,27081081027,40424237568,27081081027,8024024008,1003003001,48228544,753571,2744,1,1,3375,1157625,94196375,2543302125,27081081027,125375375125,266468362875,266468362875,125375375125,27081081027,2543302125,94196375,1157625,3375,1,1,4096,1728000,175616000,6028568000,83338924032,513537536512,1497193984000,2131746903000,1497193984000,513537536512,83338924032,6028568000,175616000,1728000,4096,1,1,4913,2515456,314432000,13481272000,236946836672,1895574693376,7355714043392,14366628991000,14366628991000,7355714043392,1895574693376,236946836672,13481272000,314432000,2515456,4913,1,1,5832,3581577,543338496,28652616000,628982226432,6397564590144,32230296244224,83786180275512,114933031928000,83786180275512,32230296244224,6397564590144,628982226432,28652616000,543338496,3581577,5832,1,1,6859,5000211,909853209,58230605376,1572226345152,19973097643968,127932640011072,431772660037368,788325665994152,788325665994152,431772660037368,127932640011072,19973097643968,1572226345152,58230605376,909853209,5000211,6859,1,1,8000,6859000,1481544000,113731651125,3726758744064,58230605376000,465844843008000,1998947500173000,4738245926336000,6306605327953216,4738245926336000,1998947500173000,465844843008000,58230605376000,3726758744064,113731651125,1481544000,6859000,8000,1,1,9261,9261000,2352637000,214384046625,8426150568549,159784781151744,1572226345152000,8426150568549000 cal $0,206735 ; Triangle T(n,k), read by rows, given by (0, 2, -1/2, 1/2, 0, 0, 0, 0, 0, 0, 0, ...) DELTA (1, 0, -1/2, 1/2, 0, 0, 0, 0, 0, 0, 0, ...) where DELTA is the operator defined in A084938. pow $0,3 trn $0,1 mov $1,$0 add $1,1
src/main/antlr4/vtlp/VTLLexer.g4
bkiers/vtl-parser
0
1071
<reponame>bkiers/vtl-parser lexer grammar VTLLexer; tokens { OPAR, CPAR, OBRACK, CBRACK, OBRACE, CBRACE, STRING, INTEGER, ID, REFERENCE, DOT, COMMA, ASSIGN, EQ, NE, AND, OR, K_NULL, ADD, SUB, MUL, DIV, MOD, COLON, FLOAT, RANGE, LT, LE, GT, GE, EXCL, K_LT, K_LE, K_GT, K_GE, K_EQ, K_NE, K_TRUE, K_FALSE, K_AND, K_OR, K_NOT, K_NULL, K_IN, IF, ELSEIF, ELSE, FOREACH, SET, END, BREAK, MACRO_ID, MACRO, STOP, INCLUDE, EVALUATE, PARSE, DEFINE } ESCAPED_CHAR : '\\' . ; START_DIRECTIVE : '#' -> skip, pushMode(DIR_) ; DOLLAR_EXCL_OBRACE : '$' '\\'* '!{' -> pushMode(FRM_) ; DOLLAR_OBRACE : '$' '{' -> pushMode(FRM_) ; DOLLAR_EXCL : '$' '\\'* '!' -> pushMode(VAR_) ; DOLLAR : '$' -> pushMode(VAR_) ; TEXT : . ; // Formal mode mode FRM_; FRM_ID : ID -> type(ID) ; FRM_DOT : '.' -> type(DOT) ; FRM_OBRACK : '[' -> type(OBRACK), pushMode(IDX_) ; FRM_OPAR : '(' -> type(OPAR), pushMode(CODE_) ; FRM_CBRACE : '}' -> type(CBRACE), popMode ; // Directive mode mode DIR_; ESCAPED_BLOCK : '[[' .*? ']]#' -> popMode ; SNGLE_LINE_COMMENT : '#' ~[\r\n]* -> skip , popMode ; VTL_COMMENT_BLOCK : '**' .*? '*#' -> channel(HIDDEN), popMode ; MULTI_LINE_COMMENT : '*' .*? '*#' -> skip, popMode ; DIR_SET : ( 'set' | '{set}' ) SPACES? '(' -> type(SET), popMode, pushMode(CODE_) ; DIR_FOREACH : ( 'foreach' | '{foreach}' ) SPACES? '(' -> type(FOREACH), popMode, pushMode(CODE_) ; DIR_IF : ( 'if' | '{if}' ) SPACES? '(' -> type(IF), popMode, pushMode(CODE_) ; DIR_ELSEIF : ( 'elseif' | '{elseif}' ) SPACES? '(' -> type(ELSEIF), popMode, pushMode(CODE_) ; DIR_ELSE : ( 'else' | '{else}' ) -> type(ELSE), popMode ; DIR_INCLUDE : ( 'include' | '{include}' ) SPACES? '(' -> type(INCLUDE), popMode, pushMode(CODE_) ; DIR_PARSE : ( 'parse' | '{parse}' ) SPACES? '(' -> type(PARSE), popMode, pushMode(CODE_) ; DIR_EVALUATE : ( 'evaluate' | '{evaluate}' ) SPACES? '(' -> type(EVALUATE), popMode, pushMode(CODE_) ; DIR_DEFINE : ( 'define' | '{define}' ) SPACES? '(' -> type(DEFINE), popMode, pushMode(CODE_) ; DIR_STOP : ( 'stop' | '{stop}' ) -> type(STOP), popMode ; DIR_BREAK : ( 'break' | '{break}' ) -> type(BREAK), popMode ; DIR_END : ( 'end' | '{end}' ) -> type(END), popMode ; DIR_MACRO : ( 'macro' | '{macro}' ) SPACES? '(' -> type(MACRO), popMode, pushMode(CODE_) ; DIR_MACRO_CALL : '@' ID SPACES? '(' -> type(MACRO_ID), popMode, pushMode(CODE_) ; DIR_CUSTOM_CODE : ID SPACES? '(' -> type(ID), popMode, pushMode(CODE_) ; DIR_CUSTOM : ID -> type(ID), popMode ; // Variable mode mode VAR_; VAR_DOLLAR : '$' -> type(DOLLAR) ; VAR_DOLLAR_EXCL : '$' '\\'* '!' -> type(DOLLAR_EXCL) ; VAR_DOLLAR_EXCL_OBRACE : '$' '\\'* '!{' -> type(DOLLAR_EXCL_OBRACE), popMode, pushMode(FRM_) ; VAR_DOLLAR_OBRACE : '$' '{' -> type(DOLLAR_OBRACE), popMode, pushMode(FRM_) ; VAR_HASH : '#' -> skip, popMode, pushMode(DIR_) ; VAR_ID : ID -> type(ID) ; VAR_DOT : '.' -> type(DOT) ; VAR_OBRACK : '[' -> type(OBRACK), pushMode(IDX_) ; VAR_OPAR : '(' -> type(OPAR), pushMode(CODE_) ; VAR_TEXT : . -> type(TEXT), popMode ; // Code mode mode CODE_; CODE_K_LT : 'lt' -> type(K_LT) ; CODE_K_LE : 'le' -> type(K_LE) ; CODE_K_GT : 'gt' -> type(K_GT) ; CODE_K_GE : 'ge' -> type(K_GE) ; CODE_K_EQ : 'eq' -> type(K_EQ) ; CODE_K_NE : 'ne' -> type(K_NE) ; CODE_K_TRUE : 'true' -> type(K_TRUE) ; CODE_K_FALSE : 'false' -> type(K_FALSE) ; CODE_K_AND : 'and' -> type(K_AND) ; CODE_K_OR : 'or' -> type(K_OR) ; CODE_K_NOT : 'not' -> type(K_NOT) ; CODE_K_NULL : 'null' -> type(K_NULL) ; CODE_K_IN : 'in' -> type(K_IN) ; CODE_ID : ID -> type(ID) ; CODE_ADD : '+' -> type(ADD) ; CODE_SUB : '-' -> type(SUB) ; CODE_MUL : '*' -> type(MUL) ; CODE_DIV : '/' -> type(DIV) ; CODE_MOD : '%' -> type(MOD) ; CODE_EXCL : '!' -> type(EXCL) ; CODE_OR : '||' -> type(OR) ; CODE_AND : '&&' -> type(AND) ; CODE_ASSIGN : '=' -> type(ASSIGN) ; CODE_EQ : '==' -> type(EQ) ; CODE_NEQ : '!=' -> type(NE) ; CODE_LT : '<' -> type(LT) ; CODE_LE : '<=' -> type(LE) ; CODE_GT : '>' -> type(GT) ; CODE_GE : '>=' -> type(GE) ; CODE_SPACES : SPACES -> skip ; CODE_REFERENCE : '$' ID -> type(REFERENCE) ; CODE_OPAR : '(' -> type(OPAR), pushMode(CODE_) ; CODE_CPAR : ')' -> type(CPAR), popMode ; CODE_COLON : ':' -> type(COLON) ; CODE_RANGE : '..' -> type(RANGE) ; CODE_DOT : '.' -> type(DOT) ; CODE_FLOAT : FLOAT -> type(FLOAT) ; CODE_INTEGER : INTEGER -> type(INTEGER) ; CODE_STRING : STRING -> type(STRING) ; CODE_OBRACK : '[' -> type(OBRACK) ; CODE_CBRACK : ']' -> type(CBRACK) ; CODE_OBRACE : '{' -> type(OBRACE) ; CODE_CBRACE : '}' -> type(CBRACE) ; CODE_COMMA : ',' -> type(COMMA) ; // Index mode mode IDX_; IDX_CBRACK : ']' -> type(CBRACK), popMode ; IDX_REFERENCE : '$' ID -> type(REFERENCE) ; IDX_STRING : STRING -> type(STRING) ; IDX_INTEGER : INTEGER -> type(INTEGER) ; fragment STRING : STRING_DQ | STRING_SQ ; fragment FLOAT : DIGIT* '.' DIGIT+ EXPONENT? | DIGIT+ '.' {this._input.LA(1) != '.'}? EXPONENT? | DIGIT+ EXPONENT ; fragment SPACES : [ \t\r\n]; fragment ID : [a-zA-Z] [a-zA-Z0-9_-]*; fragment STRING_DQ : '"' ( ~["\r\n] | '""' )* '"'; fragment STRING_SQ : '\'' ( ~['\r\n] | '\'\'' )* '\''; fragment INTEGER : DIGIT+; fragment DIGIT : [0-9]; fragment EXPONENT : [eE] [+-]? DIGIT+; // <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
Cubical/Algebra/Group/EilenbergMacLane/Base.agda
thomas-lamiaux/cubical
1
11078
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.Group.EilenbergMacLane.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.GroupoidLaws renaming (assoc to ∙assoc) open import Cubical.Foundations.Path open import Cubical.Foundations.HLevels open import Cubical.Foundations.Univalence open import Cubical.Foundations.Pointed open import Cubical.Foundations.Transport open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Homotopy.Connected open import Cubical.HITs.Truncation as Trunc renaming (rec to trRec; elim to trElim) open import Cubical.HITs.EilenbergMacLane1 hiding (elim) open import Cubical.Algebra.AbGroup.Base open import Cubical.Data.Empty renaming (rec to ⊥-rec) hiding (elim) open import Cubical.HITs.Truncation renaming (elim to trElim ; rec to trRec ; rec2 to trRec2) open import Cubical.Data.Nat hiding (_·_ ; elim) open import Cubical.HITs.Susp open import Cubical.Functions.Morphism open import Cubical.Foundations.Path private variable ℓ ℓ' : Level _* = AbGroup→Group EM-raw : (G : AbGroup ℓ) (n : ℕ) → Type ℓ EM-raw G zero = fst G EM-raw G (suc zero) = EM₁ (G *) EM-raw G (suc (suc n)) = Susp (EM-raw G (suc n)) ptEM-raw : {n : ℕ} {G : AbGroup ℓ} → EM-raw G n ptEM-raw {n = zero} {G = G} = AbGroupStr.0g (snd G) ptEM-raw {n = suc zero} {G = G} = embase ptEM-raw {n = suc (suc n)} {G = G} = north raw-elim : (G : AbGroup ℓ) (n : ℕ) {A : EM-raw G (suc n) → Type ℓ'} → ((x : _) → isOfHLevel (suc n) (A x) ) → A ptEM-raw → (x : _) → A x raw-elim G zero hlev b = elimProp _ hlev b raw-elim G (suc n) hlev b north = b raw-elim G (suc n) {A = A} hlev b south = subst A (merid ptEM-raw) b raw-elim G (suc n) {A = A} hlev b (merid a i) = help a i where help : (a : _) → PathP (λ i → A (merid a i)) b (subst A (merid ptEM-raw) b) help = raw-elim G n (λ _ → isOfHLevelPathP' (suc n) (hlev _) _ _) λ i → transp (λ j → A (merid ptEM-raw (j ∧ i))) (~ i) b EM : (G : AbGroup ℓ) (n : ℕ) → Type ℓ EM G zero = EM-raw G zero EM G (suc zero) = EM-raw G 1 EM G (suc (suc n)) = hLevelTrunc (4 + n) (EM-raw G (suc (suc n))) 0ₖ : {G : AbGroup ℓ} (n : ℕ) → EM G n 0ₖ {G = G} zero = AbGroupStr.0g (snd G) 0ₖ (suc zero) = embase 0ₖ (suc (suc n)) = ∣ ptEM-raw ∣ EM∙ : (G : AbGroup ℓ) (n : ℕ) → Pointed ℓ EM∙ G n = EM G n , (0ₖ n) EM-raw∙ : (G : AbGroup ℓ) (n : ℕ) → Pointed ℓ EM-raw∙ G n = EM-raw G n , ptEM-raw hLevelEM : (G : AbGroup ℓ) (n : ℕ) → isOfHLevel (2 + n) (EM G n) hLevelEM G zero = AbGroupStr.is-set (snd G) hLevelEM G (suc zero) = emsquash hLevelEM G (suc (suc n)) = isOfHLevelTrunc (4 + n) EM-raw→EM : (G : AbGroup ℓ) (n : ℕ) → EM-raw G n → EM G n EM-raw→EM G zero x = x EM-raw→EM G (suc zero) x = x EM-raw→EM G (suc (suc n)) = ∣_∣ elim : {G : AbGroup ℓ} (n : ℕ) {A : EM G n → Type ℓ'} → ((x : _) → isOfHLevel (2 + n) (A x)) → ((x : EM-raw G n) → A (EM-raw→EM G n x)) → (x : _) → A x elim zero hlev hyp x = hyp x elim (suc zero) hlev hyp x = hyp x elim (suc (suc n)) hlev hyp = trElim (λ _ → hlev _) hyp
function/isomorphism/core.agda
HoTT/M-types
27
3914
{-# OPTIONS --without-K #-} module function.isomorphism.core where open import level using (_⊔_) open import equality.core open import equality.groupoid open import equality.reasoning open import function.core open import function.overloading open import sum open import function.extensionality.core open import overloading.core -- isomorphisms record _≅_ {i j}(X : Set i)(Y : Set j) : Set (i ⊔ j) where constructor iso field to : X → Y from : Y → X iso₁ : (x : X) → from (to x) ≡ x iso₂ : (y : Y) → to (from y) ≡ y infix 5 _≅_ ≅-struct-iso : ∀ {i j}{X : Set i}{Y : Set j} → (X ≅ Y) ≅ ( Σ (X → Y) λ f → Σ (Y → X) λ g → ((x : X) → g (f x) ≡ x) × ((y : Y) → f (g y) ≡ y) ) ≅-struct-iso = record { to = λ { (iso f g α β) → f , g , α , β } ; from = λ { (f , g , α , β) → iso f g α β } ; iso₁ = λ _ → refl ; iso₂ = λ _ → refl } refl≅ : ∀ {i}{X : Set i} → X ≅ X refl≅ = iso id id (λ _ → refl) (λ _ → refl) ≡⇒≅ : ∀ {i}{X Y : Set i} → X ≡ Y → X ≅ Y ≡⇒≅ refl = refl≅ sym≅ : ∀ {i j}{X : Set i}{Y : Set j} → X ≅ Y → Y ≅ X sym≅ (iso f g H K) = iso g f K H trans≅ : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k} → X ≅ Y → Y ≅ Z → X ≅ Z trans≅ {X = X}{Z = Z} (iso f g H K) (iso f' g' H' K') = record { to = f' ∘ f ; from = g ∘ g' ; iso₁ = iso₁ ; iso₂ = iso₂ } where abstract iso₁ : (x : X) → g (g' (f' (f x))) ≡ x iso₁ x = ap g (H' (f x)) · H x iso₂ : (z : Z) → f' (f (g (g' z))) ≡ z iso₂ y = ap f' (K (g' y)) · K' y _·≅_ : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k} → X ≅ Y → Y ≅ Z → X ≅ Z _·≅_ = trans≅ infixl 9 _·≅_ module ≅-Reasoning where infix 4 _IsRelatedTo_ infix 2 _∎ infixr 2 _≅⟨_⟩_ infixr 2 _≡⟨_⟩_ infix 1 begin_ data _IsRelatedTo_ {i j}(x : Set i)(y : Set j) : Set (i ⊔ j) where relTo : x ≅ y → x IsRelatedTo y begin_ : ∀ {i j}{X : Set i}{Y : Set j} → X IsRelatedTo Y → X ≅ Y begin relTo p = p _≅⟨_⟩_ : ∀ {i j k} (X : Set i) {Y : Set j}{Z : Set k} → X ≅ Y → Y IsRelatedTo Z → X IsRelatedTo Z _ ≅⟨ p ⟩ relTo q = relTo (trans≅ p q) _≡⟨_⟩_ : ∀ {i j} (X : Set i) {Y : Set i} {Z : Set j} → X ≡ Y → Y IsRelatedTo Z → X IsRelatedTo Z _ ≡⟨ p ⟩ relTo q = relTo (trans≅ (≡⇒≅ p) q) _∎ : ∀ {i} (X : Set i) → X IsRelatedTo X _∎ _ = relTo refl≅ injective : ∀ {i j}{X : Set i}{Y : Set j} → (f : X → Y) → Set _ injective f = ∀ {x x'} → f x ≡ f x' → x ≡ x' retraction : ∀ {i j}{X : Set i}{Y : Set j} → (f : X → Y) → Set _ retraction {X = X}{Y = Y} f = (y : Y) → Σ X λ x → f x ≡ y _↣_ : ∀ {i j} → Set i → Set j → Set _ A ↣ B = Σ (A → B) injective -- composition of injections: _∘i_ : ∀ {i j k}{A : Set i}{B : Set j}{C : Set k} → (B ↣ C) → (A ↣ B) → (A ↣ C) (g , p) ∘i (f , q) = g ∘ f , q ∘ p _↠_ : ∀ {i j} → Set i → Set j → Set _ A ↠ B = Σ (A → B) retraction private module properties {i j}{X : Set i}{Y : Set j} where apply≅ : (X ≅ Y) → X → Y apply≅ = _≅_.to invert≅ : (X ≅ Y) → Y → X invert≅ = _≅_.from instance iso-is-fun : Coercion (X ≅ Y) (X → Y) iso-is-fun = record { coerce = _≅_.to } iso-is-iso : Coercion (X ≅ Y) (X ≅ Y) iso-is-iso = coerce-self _ inj-is-fun : Coercion (X ↣ Y) (X → Y) inj-is-fun = record { coerce = proj₁ } srj-is-fun : Coercion (X ↠ Y) (X → Y) srj-is-fun = record { coerce = proj₁ } private module iso-methods {k}{Source : Set k} ⦃ c : Coercion Source (X ≅ Y) ⦄ where private module with-source (source : Source) where private target = coerce c source open _≅_ target public using () renaming (from to invert) open with-source public open iso-methods public iso⇒inj : (iso : X ≅ Y) → injective (apply iso) iso⇒inj f {x}{x'} q = (iso₁ x) ⁻¹ · ap from q · iso₁ x' where open _≅_ f iso⇒retr : (iso : X ≅ Y) → retraction (apply iso) iso⇒retr f y = from y , iso₂ y where open _≅_ f inj+retr⇒iso : (f : X → Y) → injective f → retraction f → X ≅ Y inj+retr⇒iso f inj-f retr-f = iso f g H K where g : Y → X g y = proj₁ (retr-f y) H : (x : X) → g (f x) ≡ x H x = inj-f (proj₂ (retr-f (f x))) K : (y : Y) → f (g y) ≡ y K y = proj₂ (retr-f y) open properties public
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0.log_21829_1265.asm
ljhsiun2/medusa
9
19733
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r15 push %r8 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0xd104, %rsi lea addresses_A_ht+0x12544, %rdi nop cmp $21065, %r10 mov $87, %rcx rep movsw nop add $48118, %rbp lea addresses_UC_ht+0x14944, %rbx nop nop dec %rcx mov (%rbx), %esi add %rdi, %rdi lea addresses_UC_ht+0x8d44, %rsi lea addresses_normal_ht+0x13258, %rdi nop inc %r8 mov $56, %rcx rep movsq nop nop nop nop nop cmp %r10, %r10 lea addresses_normal_ht+0x6ca4, %rsi lea addresses_D_ht+0x3dc4, %rdi clflush (%rsi) inc %r15 mov $83, %rcx rep movsq nop nop nop nop nop sub $46592, %r15 lea addresses_A_ht+0x147c4, %rdi nop nop nop nop nop xor $29505, %rbp movb (%rdi), %r10b sub $33665, %rcx lea addresses_normal_ht+0xfa44, %rdi nop nop nop nop inc %r10 mov $0x6162636465666768, %rbx movq %rbx, %xmm6 movups %xmm6, (%rdi) nop xor $13085, %r8 lea addresses_normal_ht+0x1544, %rsi lea addresses_normal_ht+0xac04, %rdi nop nop dec %r10 mov $103, %rcx rep movsb nop nop nop sub $8241, %rbx lea addresses_WC_ht+0x15944, %rsi lea addresses_UC_ht+0x66c4, %rdi clflush (%rdi) nop nop nop nop sub $10287, %r8 mov $119, %rcx rep movsq nop nop and %rcx, %rcx lea addresses_UC_ht+0x14c45, %rsi lea addresses_A_ht+0x7734, %rdi clflush (%rsi) nop nop nop nop sub $41736, %rbx mov $53, %rcx rep movsq nop nop nop and %rbx, %rbx lea addresses_WC_ht+0x1a544, %r8 nop nop nop xor $2328, %rbx mov $0x6162636465666768, %r15 movq %r15, %xmm3 and $0xffffffffffffffc0, %r8 movntdq %xmm3, (%r8) nop nop nop nop cmp %rbx, %rbx lea addresses_D_ht+0xab34, %rsi and $51660, %r10 movb (%rsi), %cl nop nop nop nop nop dec %rsi lea addresses_A_ht+0x9944, %rsi lea addresses_A_ht+0x1bc4, %rdi nop nop add %r8, %r8 mov $85, %rcx rep movsl nop nop xor %rcx, %rcx lea addresses_UC_ht+0x8ec4, %r15 clflush (%r15) nop and %rbp, %rbp mov $0x6162636465666768, %rbx movq %rbx, (%r15) nop nop nop nop inc %rbp pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r15 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r8 push %r9 push %rax push %rdi push %rsi // Store lea addresses_WT+0x1c930, %r11 nop nop nop inc %rax movb $0x51, (%r11) nop nop nop nop cmp $61443, %r11 // Faulty Load lea addresses_normal+0x14544, %r9 nop nop nop nop xor $12785, %rdi movb (%r9), %r11b lea oracles, %rax and $0xff, %r11 shlq $12, %r11 mov (%rax,%r11,1), %r11 pop %rsi pop %rdi pop %rax pop %r9 pop %r8 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_WT', 'AVXalign': False, 'size': 1}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 11, 'type': 'addresses_A_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 1, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16}} {'src': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}} {'src': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 10, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16}} {'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
oeis/340/A340781.asm
neoneye/loda-programs
11
94181
; A340781: a(n) = (n - 1)*prime(n + 1) mod prime(n). ; Submitted by <NAME> ; 0,2,4,5,8,7,12,9,2,18,29,7,24,9,37,37,32,41,5,38,47,5,49,6,96,50,1,54,3,67,120,55,64,52,68,59,59,148,61,61,80,48,84,172,88,142,130,188,96,196,67,102,38,67,67,67,112,71,232,118,34,268,248,126,256,276,65,333,136,276,67,209,65,65,296,67,219,308,223,381,160,389,164,65,336,67,239,348,176,356,146,249,368,253,376,67,134,194,195,53 mov $2,$0 add $0,1 mov $1,$0 seq $0,40 ; The prime numbers. sub $1,1 mul $0,$1 seq $2,40 ; The prime numbers. mod $0,$2
parser/Yaml.g4
Luncert/go-cfg
0
5729
grammar Yaml; main: section EOF; section: sectionHeader sectionBody; sectionHeader: '[' sectionName ']'; sectionName: ; sectionBody: entry*; entry: entryName sep entryValue newline; sep: '=' | ':'; newline: '\n'; entryName: ; entryValue: ;
gcc-gcc-7_3_0-release/gcc/ada/s-imgdec.adb
best08618/asylo
7
16208
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . I M G _ D E C -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2015, 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 System.Img_Int; use System.Img_Int; package body System.Img_Dec is ------------------- -- Image_Decimal -- ------------------- procedure Image_Decimal (V : Integer; S : in out String; P : out Natural; Scale : Integer) is pragma Assert (S'First = 1); begin -- Add space at start for non-negative numbers if V >= 0 then S (1) := ' '; P := 1; else P := 0; end if; Set_Image_Decimal (V, S, P, Scale, 1, Integer'Max (1, Scale), 0); end Image_Decimal; ------------------------ -- Set_Decimal_Digits -- ------------------------ procedure Set_Decimal_Digits (Digs : in out String; NDigs : Natural; S : out String; P : in out Natural; Scale : Integer; Fore : Natural; Aft : Natural; Exp : Natural) is Minus : constant Boolean := (Digs (Digs'First) = '-'); -- Set True if input is negative Zero : Boolean := (Digs (Digs'First + 1) = '0'); -- Set True if input is exactly zero (only case when a leading zero -- is permitted in the input string given to this procedure). This -- flag can get set later if rounding causes the value to become zero. FD : Natural := 2; -- First digit position of digits remaining to be processed LD : Natural := NDigs; -- Last digit position of digits remaining to be processed ND : Natural := NDigs - 1; -- Number of digits remaining to be processed (LD - FD + 1) Digits_Before_Point : Integer := ND - Scale; -- Number of digits before decimal point in the input value. This -- value can be negative if the input value is less than 0.1, so -- it is an indication of the current exponent. Digits_Before_Point -- is adjusted if the rounding step generates an extra digit. Digits_After_Point : constant Natural := Integer'Max (1, Aft); -- Digit positions after decimal point in result string Expon : Integer; -- Integer value of exponent procedure Round (N : Integer); -- Round the number in Digs. N is the position of the last digit to be -- retained in the rounded position (rounding is based on Digs (N + 1) -- FD, LD, ND are reset as necessary if required. Note that if the -- result value rounds up (e.g. 9.99 => 10.0), an extra digit can be -- placed in the sign position as a result of the rounding, this is -- the case in which FD is adjusted. The call to Round has no effect -- if N is outside the range FD .. LD. procedure Set (C : Character); pragma Inline (Set); -- Sets character C in output buffer procedure Set_Blanks_And_Sign (N : Integer); -- Sets leading blanks and minus sign if needed. N is the number of -- positions to be filled (a minus sign is output even if N is zero -- or negative, For a positive value, if N is non-positive, then -- a leading blank is filled. procedure Set_Digits (S, E : Natural); pragma Inline (Set_Digits); -- Set digits S through E from Digs, no effect if S > E procedure Set_Zeroes (N : Integer); pragma Inline (Set_Zeroes); -- Set N zeroes, no effect if N is negative ----------- -- Round -- ----------- procedure Round (N : Integer) is D : Character; begin -- Nothing to do if rounding past the last digit we have if N >= LD then return; -- Cases of rounding before the initial digit elsif N < FD then -- The result is zero, unless we are rounding just before -- the first digit, and the first digit is five or more. if N = 1 and then Digs (Digs'First + 1) >= '5' then Digs (Digs'First) := '1'; else Digs (Digs'First) := '0'; Zero := True; end if; Digits_Before_Point := Digits_Before_Point + 1; FD := 1; LD := 1; ND := 1; -- Normal case of rounding an existing digit else LD := N; ND := LD - 1; if Digs (N + 1) >= '5' then for J in reverse 2 .. N loop D := Character'Succ (Digs (J)); if D <= '9' then Digs (J) := D; return; else Digs (J) := '0'; end if; end loop; -- Here the rounding overflows into the sign position. That's -- OK, because we already captured the value of the sign and -- we are in any case destroying the value in the Digs buffer Digs (Digs'First) := '1'; FD := 1; ND := ND + 1; Digits_Before_Point := Digits_Before_Point + 1; end if; end if; end Round; --------- -- Set -- --------- procedure Set (C : Character) is begin P := P + 1; S (P) := C; end Set; ------------------------- -- Set_Blanks_And_Sign -- ------------------------- procedure Set_Blanks_And_Sign (N : Integer) is W : Integer := N; begin if Minus then W := W - 1; for J in 1 .. W loop Set (' '); end loop; Set ('-'); else for J in 1 .. W loop Set (' '); end loop; end if; end Set_Blanks_And_Sign; ---------------- -- Set_Digits -- ---------------- procedure Set_Digits (S, E : Natural) is begin for J in S .. E loop Set (Digs (J)); end loop; end Set_Digits; ---------------- -- Set_Zeroes -- ---------------- procedure Set_Zeroes (N : Integer) is begin for J in 1 .. N loop Set ('0'); end loop; end Set_Zeroes; -- Start of processing for Set_Decimal_Digits begin -- Case of exponent given if Exp > 0 then Set_Blanks_And_Sign (Fore - 1); Round (Digits_After_Point + 2); Set (Digs (FD)); FD := FD + 1; ND := ND - 1; Set ('.'); if ND >= Digits_After_Point then Set_Digits (FD, FD + Digits_After_Point - 1); else Set_Digits (FD, LD); Set_Zeroes (Digits_After_Point - ND); end if; -- Calculate exponent. The number of digits before the decimal point -- in the input is Digits_Before_Point, and the number of digits -- before the decimal point in the output is 1, so we can get the -- exponent as the difference between these two values. The one -- exception is for the value zero, which by convention has an -- exponent of +0. Expon := (if Zero then 0 else Digits_Before_Point - 1); Set ('E'); ND := 0; if Expon >= 0 then Set ('+'); Set_Image_Integer (Expon, Digs, ND); else Set ('-'); Set_Image_Integer (-Expon, Digs, ND); end if; Set_Zeroes (Exp - ND - 1); Set_Digits (1, ND); return; -- Case of no exponent given. To make these cases clear, we use -- examples. For all the examples, we assume Fore = 2, Aft = 3. -- A P in the example input string is an implied zero position, -- not included in the input string. else -- Round at correct position -- Input: 4PP => unchanged -- Input: 400.03 => unchanged -- Input 3.4567 => 3.457 -- Input: 9.9999 => 10.000 -- Input: 0.PPP5 => 0.001 -- Input: 0.PPP4 => 0 -- Input: 0.00003 => 0 Round (LD - (Scale - Digits_After_Point)); -- No digits before point in input -- Input: .123 Output: 0.123 -- Input: .PP3 Output: 0.003 if Digits_Before_Point <= 0 then Set_Blanks_And_Sign (Fore - 1); Set ('0'); Set ('.'); declare DA : Natural := Digits_After_Point; -- Digits remaining to output after point LZ : constant Integer := Integer'Min (DA, -Digits_Before_Point); -- Number of leading zeroes after point. Note: there used to be -- a Max of this result with zero, but that's redundant, since -- we know DA is positive, and because of the test above, we -- know that -Digits_Before_Point >= 0. begin Set_Zeroes (LZ); DA := DA - LZ; if DA < ND then -- Note: it is definitely possible for the above condition -- to be True, for example: -- V => 1234, Scale => 5, Fore => 0, After => 1, Exp => 0 -- but in this case DA = 0, ND = 1, FD = 1, FD + DA-1 = 0 -- so the arguments in the call are (1, 0) meaning that no -- digits are output. -- No obvious example exists where the following call to -- Set_Digits actually outputs some digits, but we lack a -- proof that no such example exists. -- So it is safer to retain this call, even though as a -- result it is hard (or perhaps impossible) to create a -- coverage test for the inlined code of the call. Set_Digits (FD, FD + DA - 1); else Set_Digits (FD, LD); Set_Zeroes (DA - ND); end if; end; -- At least one digit before point in input else -- Less digits in input than are needed before point -- Input: 1PP Output: 100.000 if ND < Digits_Before_Point then -- Special case, if the input is the single digit 0, then we -- do not want 000.000, but instead 0.000. if ND = 1 and then Digs (FD) = '0' then Set_Blanks_And_Sign (Fore - 1); Set ('0'); -- Normal case where we need to output scaling zeroes else Set_Blanks_And_Sign (Fore - Digits_Before_Point); Set_Digits (FD, LD); Set_Zeroes (Digits_Before_Point - ND); end if; -- Set period and zeroes after the period Set ('.'); Set_Zeroes (Digits_After_Point); -- Input has full amount of digits before decimal point else Set_Blanks_And_Sign (Fore - Digits_Before_Point); Set_Digits (FD, FD + Digits_Before_Point - 1); Set ('.'); Set_Digits (FD + Digits_Before_Point, LD); Set_Zeroes (Digits_After_Point - (ND - Digits_Before_Point)); end if; end if; end if; end Set_Decimal_Digits; ----------------------- -- Set_Image_Decimal -- ----------------------- procedure Set_Image_Decimal (V : Integer; S : in out String; P : in out Natural; Scale : Integer; Fore : Natural; Aft : Natural; Exp : Natural) is Digs : String := Integer'Image (V); -- Sign and digits of decimal value begin Set_Decimal_Digits (Digs, Digs'Length, S, P, Scale, Fore, Aft, Exp); end Set_Image_Decimal; end System.Img_Dec;
non_regression/other_x86_macosx_4.s.asm
LRGH/plasmasm
1
101690
.macosx_version_min 10, 12 .section __TEXT,__text,regular,pure_instructions .align 4, 0x90 .globl _md5_init_ctx _md5_init_ctx: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax movl $1732584193, (%eax) movl $-271733879, 4(%eax) movl $-1732584194, 8(%eax) movl $271733878, 12(%eax) movl $0, 20(%eax) movl $0, 16(%eax) movl $0, 24(%eax) popl %ebp ret # ---------------------- .align 4, 0x90 .globl _md5_read_ctx _md5_read_ctx: pushl %ebp movl %esp, %ebp pushl %eax movl 12(%ebp), %eax movl 8(%ebp), %ecx movl (%ecx), %edx movl %edx, -4(%ebp) movl %edx, (%eax) movl 4(%ecx), %edx movl %edx, -4(%ebp) movl %edx, 4(%eax) movl 8(%ecx), %edx movl %edx, -4(%ebp) movl %edx, 8(%eax) movl 12(%ecx), %ecx movl %ecx, -4(%ebp) movl %ecx, 12(%eax) addl $4, %esp popl %ebp ret # ---------------------- .align 4, 0x90 .globl _md5_finish_ctx _md5_finish_ctx: pushl %ebp movl %esp, %ebp pushl %ebx pushl %edi pushl %esi subl $28, %esp call L2$pb L2$pb: popl %eax movl %eax, -20(%ebp) movl 8(%ebp), %edi movl 24(%edi), %ecx cmpl $56, %ecx movl $16, %edx movl $32, %ebx cmovb %edx, %ebx movl 16(%edi), %edx addl %ecx, %edx movl %edx, 16(%edi) jae LBB2_2 incl 20(%edi) LBB2_2: leal 0(,%edx,8), %eax leal 28(%edi), %esi movl %eax, 20(%edi,%ebx,4) movl 20(%edi), %eax shldl $3, %edx, %eax movl %eax, 24(%edi,%ebx,4) leal 28(%edi,%ecx), %eax leal -8(,%ebx,4), %edx subl %ecx, %edx movl %edx, 8(%esp) movl -20(%ebp), %ecx leal _fillbuf-L2$pb(%ecx), %ecx movl %ecx, 4(%esp) movl %eax, (%esp) call _memcpy shll $2, %ebx movl %edi, 8(%esp) movl %ebx, 4(%esp) movl %esi, (%esp) call _md5_process_block movl (%edi), %ecx movl %ecx, -16(%ebp) movl 12(%ebp), %eax movl %ecx, (%eax) movl 4(%edi), %ecx movl %ecx, -16(%ebp) movl %ecx, 4(%eax) movl 8(%edi), %ecx movl %ecx, -16(%ebp) movl %ecx, 8(%eax) movl 12(%edi), %ecx movl %ecx, -16(%ebp) movl %ecx, 12(%eax) addl $28, %esp popl %esi popl %edi popl %ebx popl %ebp ret # ---------------------- .align 4, 0x90 .globl _md5_process_block _md5_process_block: pushl %ebp movl %esp, %ebp pushl %ebx pushl %edi pushl %esi subl $88, %esp movl 16(%ebp), %edi movl 12(%ebp), %eax movl %eax, %ecx andl $-4, %ecx addl 8(%ebp), %ecx movl %ecx, -100(%ebp) movl (%edi), %edx movl %edx, -92(%ebp) movl 4(%edi), %esi addl 16(%edi), %eax movl 8(%edi), %ebx movl 12(%edi), %edx movl %eax, 16(%edi) sbbl %eax, %eax andl $1, %eax addl %eax, 20(%edi) movl %ecx, %eax movl 8(%ebp), %ecx jmp LBB3_2 .align 4, 0x90 LBB3_1: movl %ecx, -16(%ebp) movl %ebx, -96(%ebp) movl %edx, -24(%ebp) movl %esi, -20(%ebp) movl %ebx, %eax xorl %edx, %eax andl %esi, %eax xorl %edx, %eax addl -92(%ebp), %eax movl (%ecx), %edx movl %edx, -84(%ebp) movl 4(%ecx), %edi movl %edi, -36(%ebp) leal -680876936(%edx,%eax), %edx roll $7, %edx addl %esi, %edx movl %esi, %eax xorl %ebx, %eax andl %edx, %eax xorl %ebx, %eax movl -24(%ebp), %ecx leal (%ecx,%edi), %ecx leal -389564586(%eax,%ecx), %esi roll $12, %esi addl %edx, %esi movl %edx, %eax xorl -20(%ebp), %eax andl %esi, %eax xorl -20(%ebp), %eax movl -16(%ebp), %ecx movl 8(%ecx), %ecx movl %ecx, -28(%ebp) leal (%ebx,%ecx), %ecx leal 606105819(%eax,%ecx), %ecx roll $17, %ecx addl %esi, %ecx movl %esi, %eax xorl %edx, %eax andl %ecx, %eax xorl %edx, %eax movl -16(%ebp), %edi movl 12(%edi), %ebx movl %ebx, -48(%ebp) movl -20(%ebp), %edi leal (%edi,%ebx), %edi leal -1044525330(%eax,%edi), %eax roll $22, %eax addl %ecx, %eax movl %ecx, %edi xorl %esi, %edi andl %eax, %edi xorl %esi, %edi movl -16(%ebp), %ebx movl 16(%ebx), %ebx movl %ebx, -32(%ebp) addl %ebx, %edx leal -176418897(%edi,%edx), %edx roll $7, %edx addl %eax, %edx movl %eax, %edi xorl %ecx, %edi andl %edx, %edi xorl %ecx, %edi movl -16(%ebp), %ebx movl 20(%ebx), %ebx movl %ebx, -60(%ebp) addl %ebx, %esi leal 1200080426(%edi,%esi), %esi roll $12, %esi addl %edx, %esi movl %edx, %edi xorl %eax, %edi andl %esi, %edi xorl %eax, %edi movl -16(%ebp), %ebx movl 24(%ebx), %ebx movl %ebx, -44(%ebp) addl %ebx, %ecx leal -1473231341(%edi,%ecx), %ecx roll $17, %ecx addl %esi, %ecx movl %esi, %edi xorl %edx, %edi andl %ecx, %edi xorl %edx, %edi movl -16(%ebp), %ebx movl 28(%ebx), %ebx movl %ebx, -72(%ebp) addl %ebx, %eax leal -45705983(%edi,%eax), %eax roll $22, %eax addl %ecx, %eax movl %ecx, %edi xorl %esi, %edi andl %eax, %edi xorl %esi, %edi movl -16(%ebp), %ebx movl 32(%ebx), %ebx movl %ebx, -56(%ebp) addl %ebx, %edx leal 1770035416(%edi,%edx), %edx roll $7, %edx addl %eax, %edx movl %eax, %edi xorl %ecx, %edi andl %edx, %edi xorl %ecx, %edi movl -16(%ebp), %ebx movl 36(%ebx), %ebx movl %ebx, -40(%ebp) addl %ebx, %esi leal -1958414417(%edi,%esi), %esi roll $12, %esi addl %edx, %esi movl %edx, %edi xorl %eax, %edi andl %esi, %edi xorl %eax, %edi movl -16(%ebp), %ebx movl 40(%ebx), %ebx movl %ebx, -68(%ebp) addl %ebx, %ecx leal -42063(%edi,%ecx), %ecx roll $17, %ecx addl %esi, %ecx movl %esi, %edi xorl %edx, %edi andl %ecx, %edi xorl %edx, %edi movl -16(%ebp), %ebx movl 44(%ebx), %ebx movl %ebx, -52(%ebp) addl %ebx, %eax leal -1990404162(%edi,%eax), %eax roll $22, %eax addl %ecx, %eax movl %ecx, %edi xorl %esi, %edi andl %eax, %edi xorl %esi, %edi movl -16(%ebp), %ebx movl 48(%ebx), %ebx movl %ebx, -76(%ebp) addl %ebx, %edx leal 1804603682(%edi,%edx), %edi roll $7, %edi addl %eax, %edi movl %eax, %edx xorl %ecx, %edx andl %edi, %edx xorl %ecx, %edx movl -16(%ebp), %ebx movl 52(%ebx), %ebx movl %ebx, -64(%ebp) addl %ebx, %esi leal -40341101(%edx,%esi), %esi roll $12, %esi addl %edi, %esi movl %edi, %ebx xorl %eax, %ebx andl %esi, %ebx xorl %eax, %ebx movl -16(%ebp), %edx movl 56(%edx), %edx movl %edx, -80(%ebp) addl %edx, %ecx leal -1502002290(%ebx,%ecx), %ebx roll $17, %ebx addl %esi, %ebx movl %esi, %ecx xorl %edi, %ecx andl %ebx, %ecx xorl %edi, %ecx movl -16(%ebp), %edx movl 60(%edx), %edx movl %edx, -88(%ebp) addl %edx, %eax leal 1236535329(%ecx,%eax), %eax roll $22, %eax addl %ebx, %eax movl %eax, %ecx xorl %ebx, %ecx andl %esi, %ecx xorl %ebx, %ecx addl -36(%ebp), %edi leal -165796510(%ecx,%edi), %edi roll $5, %edi addl %eax, %edi movl %edi, %ecx xorl %eax, %ecx andl %ebx, %ecx xorl %eax, %ecx addl -44(%ebp), %esi leal -1069501632(%ecx,%esi), %esi roll $9, %esi addl %edi, %esi movl %esi, %ecx xorl %edi, %ecx andl %eax, %ecx xorl %edi, %ecx addl -52(%ebp), %ebx leal 643717713(%ecx,%ebx), %ebx roll $14, %ebx addl %esi, %ebx movl %ebx, %ecx xorl %esi, %ecx andl %edi, %ecx xorl %esi, %ecx addl -84(%ebp), %eax leal -373897302(%ecx,%eax), %eax roll $20, %eax addl %ebx, %eax movl %eax, %ecx xorl %ebx, %ecx andl %esi, %ecx xorl %ebx, %ecx addl -60(%ebp), %edi leal -701558691(%ecx,%edi), %edi roll $5, %edi addl %eax, %edi movl %edi, %ecx xorl %eax, %ecx andl %ebx, %ecx xorl %eax, %ecx addl -68(%ebp), %esi leal 38016083(%ecx,%esi), %esi roll $9, %esi addl %edi, %esi movl %esi, %ecx xorl %edi, %ecx andl %eax, %ecx xorl %edi, %ecx addl %edx, %ebx leal -660478335(%ecx,%ebx), %ebx roll $14, %ebx addl %esi, %ebx movl %ebx, %ecx xorl %esi, %ecx andl %edi, %ecx xorl %esi, %ecx addl -32(%ebp), %eax leal -405537848(%ecx,%eax), %eax roll $20, %eax addl %ebx, %eax movl %eax, %ecx xorl %ebx, %ecx andl %esi, %ecx xorl %ebx, %ecx addl -40(%ebp), %edi leal 568446438(%ecx,%edi), %edi roll $5, %edi addl %eax, %edi movl %edi, %ecx xorl %eax, %ecx andl %ebx, %ecx xorl %eax, %ecx addl -80(%ebp), %esi leal -1019803690(%ecx,%esi), %esi roll $9, %esi addl %edi, %esi movl %esi, %ecx xorl %edi, %ecx andl %eax, %ecx xorl %edi, %ecx addl -48(%ebp), %ebx leal -187363961(%ecx,%ebx), %ebx roll $14, %ebx addl %esi, %ebx movl %ebx, %ecx xorl %esi, %ecx andl %edi, %ecx xorl %esi, %ecx addl -56(%ebp), %eax leal 1163531501(%ecx,%eax), %eax roll $20, %eax addl %ebx, %eax movl %eax, %ecx xorl %ebx, %ecx andl %esi, %ecx xorl %ebx, %ecx addl -64(%ebp), %edi leal -1444681467(%ecx,%edi), %edi roll $5, %edi addl %eax, %edi movl %edi, %ecx xorl %eax, %ecx andl %ebx, %ecx xorl %eax, %ecx addl -28(%ebp), %esi leal -51403784(%ecx,%esi), %esi roll $9, %esi addl %edi, %esi movl %esi, %ecx xorl %edi, %ecx andl %eax, %ecx xorl %edi, %ecx addl -72(%ebp), %ebx leal 1735328473(%ecx,%ebx), %edx roll $14, %edx addl %esi, %edx movl %edx, %ebx xorl %esi, %ebx movl %ebx, %ecx andl %edi, %ecx xorl %esi, %ecx addl -76(%ebp), %eax leal -1926607734(%ecx,%eax), %eax roll $20, %eax addl %edx, %eax xorl %eax, %ebx addl -60(%ebp), %edi leal -378558(%ebx,%edi), %ecx roll $4, %ecx addl %eax, %ecx movl %eax, %edi xorl %edx, %edi xorl %ecx, %edi addl -56(%ebp), %esi leal -2022574463(%edi,%esi), %esi roll $11, %esi addl %ecx, %esi movl %ecx, %edi xorl %eax, %edi xorl %esi, %edi addl -52(%ebp), %edx leal 1839030562(%edi,%edx), %edi roll $16, %edi addl %esi, %edi movl %esi, %edx xorl %ecx, %edx xorl %edi, %edx addl -80(%ebp), %eax leal -35309556(%edx,%eax), %ebx roll $23, %ebx addl %edi, %ebx movl %edi, %eax xorl %esi, %eax xorl %ebx, %eax addl -36(%ebp), %ecx leal -1530992060(%eax,%ecx), %eax roll $4, %eax addl %ebx, %eax movl %ebx, %ecx xorl %edi, %ecx xorl %eax, %ecx addl -32(%ebp), %esi leal 1272893353(%ecx,%esi), %esi roll $11, %esi addl %eax, %esi movl %eax, %ecx xorl %ebx, %ecx xorl %esi, %ecx addl -72(%ebp), %edi leal -155497632(%ecx,%edi), %edi roll $16, %edi addl %esi, %edi movl %esi, %ecx xorl %eax, %ecx xorl %edi, %ecx addl -68(%ebp), %ebx leal -1094730640(%ecx,%ebx), %ebx roll $23, %ebx addl %edi, %ebx movl %edi, %ecx xorl %esi, %ecx xorl %ebx, %ecx addl -64(%ebp), %eax leal 681279174(%ecx,%eax), %eax roll $4, %eax addl %ebx, %eax movl %ebx, %ecx xorl %edi, %ecx xorl %eax, %ecx movl -84(%ebp), %edx addl %edx, %esi leal -358537222(%ecx,%esi), %esi roll $11, %esi addl %eax, %esi movl %eax, %ecx xorl %ebx, %ecx xorl %esi, %ecx addl -48(%ebp), %edi leal -722521979(%ecx,%edi), %edi roll $16, %edi addl %esi, %edi movl %esi, %ecx xorl %eax, %ecx xorl %edi, %ecx addl -44(%ebp), %ebx leal 76029189(%ecx,%ebx), %ebx roll $23, %ebx addl %edi, %ebx movl %edi, %ecx xorl %esi, %ecx xorl %ebx, %ecx addl -40(%ebp), %eax leal -640364487(%ecx,%eax), %eax roll $4, %eax addl %ebx, %eax movl %ebx, %ecx xorl %edi, %ecx xorl %eax, %ecx addl -76(%ebp), %esi leal -421815835(%ecx,%esi), %esi roll $11, %esi addl %eax, %esi movl %eax, %ecx xorl %ebx, %ecx xorl %esi, %ecx addl -88(%ebp), %edi leal 530742520(%ecx,%edi), %edi roll $16, %edi addl %esi, %edi movl %esi, %ecx xorl %eax, %ecx xorl %edi, %ecx addl -28(%ebp), %ebx leal -995338651(%ecx,%ebx), %ecx addl %edx, %eax roll $23, %ecx addl %edi, %ecx movl -72(%ebp), %edx addl %esi, %edx notl %esi orl %ecx, %esi xorl %edi, %esi leal -198630844(%esi,%eax), %esi roll $6, %esi addl %ecx, %esi movl -80(%ebp), %ebx addl %edi, %ebx notl %edi orl %esi, %edi xorl %ecx, %edi leal 1126891415(%edi,%edx), %eax roll $10, %eax addl %esi, %eax movl -60(%ebp), %edx addl %ecx, %edx notl %ecx orl %eax, %ecx xorl %esi, %ecx leal -1416354905(%ecx,%ebx), %ecx roll $15, %ecx addl %eax, %ecx movl -76(%ebp), %edi addl %esi, %edi notl %esi orl %ecx, %esi xorl %eax, %esi leal -57434055(%esi,%edx), %edx roll $21, %edx addl %ecx, %edx movl -48(%ebp), %esi addl %eax, %esi notl %eax orl %edx, %eax xorl %ecx, %eax leal 1700485571(%eax,%edi), %eax roll $6, %eax addl %edx, %eax movl -68(%ebp), %edi addl %ecx, %edi notl %ecx orl %eax, %ecx xorl %edx, %ecx leal -1894986606(%ecx,%esi), %ecx roll $10, %ecx addl %eax, %ecx movl -36(%ebp), %esi addl %edx, %esi notl %edx orl %ecx, %edx xorl %eax, %edx leal -1051523(%edx,%edi), %edx roll $15, %edx addl %ecx, %edx movl -56(%ebp), %edi addl %eax, %edi notl %eax orl %edx, %eax xorl %ecx, %eax leal -2054922799(%eax,%esi), %eax roll $21, %eax addl %edx, %eax movl -88(%ebp), %ebx addl %ecx, %ebx notl %ecx orl %eax, %ecx xorl %edx, %ecx leal 1873313359(%ecx,%edi), %ecx roll $6, %ecx addl %eax, %ecx movl -44(%ebp), %esi addl %edx, %esi notl %edx orl %ecx, %edx xorl %eax, %edx leal -30611744(%edx,%ebx), %edx roll $10, %edx addl %ecx, %edx movl -64(%ebp), %edi addl %eax, %edi notl %eax orl %edx, %eax xorl %ecx, %eax leal -1560198380(%eax,%esi), %esi roll $15, %esi addl %edx, %esi movl -32(%ebp), %eax addl %ecx, %eax notl %ecx orl %esi, %ecx xorl %edx, %ecx leal 1309151649(%ecx,%edi), %ecx roll $21, %ecx addl %esi, %ecx movl -52(%ebp), %edi addl %edx, %edi notl %edx orl %ecx, %edx xorl %esi, %edx leal -145523070(%edx,%eax), %eax roll $6, %eax addl %ecx, %eax movl -28(%ebp), %ebx addl %esi, %ebx notl %esi orl %eax, %esi xorl %ecx, %esi leal -1120210379(%esi,%edi), %edx movl -20(%ebp), %esi roll $10, %edx addl %eax, %edx movl -40(%ebp), %edi addl %ecx, %edi notl %ecx orl %edx, %ecx xorl %eax, %ecx leal 718787259(%ecx,%ebx), %ecx roll $15, %ecx addl %edx, %ecx addl %eax, -92(%ebp) notl %eax orl %ecx, %eax xorl %edx, %eax leal -343485551(%eax,%edi), %eax roll $21, %eax addl %ecx, %esi addl %eax, %esi movl -100(%ebp), %eax movl -96(%ebp), %edi addl %ecx, %edi movl %edi, %ebx movl -16(%ebp), %ecx addl %edx, -24(%ebp) movl -24(%ebp), %edx addl $64, %ecx LBB3_2: cmpl %eax, %ecx jb LBB3_1 movl 16(%ebp), %eax movl -92(%ebp), %ecx movl %ecx, (%eax) movl %esi, 4(%eax) movl %ebx, 8(%eax) movl %edx, 12(%eax) addl $88, %esp popl %esi popl %edi popl %ebx popl %ebp ret # ---------------------- .align 4, 0x90 .globl _md5_stream _md5_stream: pushl %ebp movl %esp, %ebp pushl %ebx pushl %edi pushl %esi subl $172, %esp movl $32840, (%esp) call _malloc movl %eax, %esi movl $1, %eax testl %esi, %esi je LBB4_12 movl 8(%ebp), %edi movl $1732584193, -168(%ebp) movl $-271733879, -164(%ebp) movl $-1732584194, -160(%ebp) movl $271733878, -156(%ebp) movl $0, -148(%ebp) movl $0, -152(%ebp) movl $0, -144(%ebp) jmp LBB4_2 .align 4, 0x90 LBB4_7: leal -168(%ebp), %eax movl %eax, 8(%esp) movl %esi, (%esp) movl $32768, 4(%esp) call _md5_process_block LBB4_2: xorl %ebx, %ebx LBB4_3: leal (%esi,%ebx), %eax movl $32768, %ecx subl %ebx, %ecx movl %edi, 12(%esp) movl %ecx, 8(%esp) movl %eax, (%esp) movl $1, 4(%esp) call _fread addl %eax, %ebx cmpl $32768, %ebx je LBB4_7 movswl 12(%edi), %ecx testl %eax, %eax je LBB4_5 testb $32, %cl je LBB4_3 jmp LBB4_9 LBB4_5: testb $64, %cl jne LBB4_6 LBB4_9: testl %ebx, %ebx leal -168(%ebp), %edi je LBB4_11 movl %edi, 8(%esp) movl %ebx, 4(%esp) movl %esi, (%esp) call _md5_process_bytes LBB4_11: movl 12(%ebp), %eax movl %eax, 4(%esp) movl %edi, (%esp) call _md5_finish_ctx movl %esi, (%esp) call _free xorl %eax, %eax jmp LBB4_12 LBB4_6: movl %esi, (%esp) call _free movl $1, %eax LBB4_12: addl $172, %esp popl %esi popl %edi popl %ebx popl %ebp ret # ---------------------- .align 4, 0x90 .globl _md5_process_bytes _md5_process_bytes: pushl %ebp movl %esp, %ebp pushl %ebx pushl %edi pushl %esi subl $28, %esp movl 16(%ebp), %ebx movl 12(%ebp), %eax movl 8(%ebp), %ecx movl 24(%ebx), %esi testl %esi, %esi je LBB5_4 movl %ebx, %edi movl $128, %ebx subl %esi, %ebx cmpl %eax, %ebx cmova %eax, %ebx leal 28(%edi,%esi), %eax movl %ecx, 4(%esp) movl %eax, (%esp) movl %ebx, 8(%esp) call _memcpy movl 24(%edi), %eax addl %ebx, %eax movl %eax, 24(%edi) cmpl $65, %eax jb LBB5_3 leal 28(%edi), %ecx movl %ecx, -16(%ebp) andl $-64, %eax movl %edi, 8(%esp) movl %eax, 4(%esp) movl %ecx, (%esp) call _md5_process_block movl 24(%edi), %eax andl $63, %eax movl %eax, 24(%edi) addl %ebx, %esi andl $-64, %esi movl -16(%ebp), %ecx addl %ecx, %esi movl %eax, 8(%esp) movl %esi, 4(%esp) movl %ecx, (%esp) call _memcpy LBB5_3: movl 8(%ebp), %eax movl %eax, %ecx addl %ebx, %ecx movl 12(%ebp), %eax subl %ebx, %eax movl %edi, %ebx LBB5_4: cmpl $64, %eax jb LBB5_10 testb $3, %cl je LBB5_15 movl $64, %edi cmpl $65, %eax jb LBB5_11 leal 28(%ebx), %ebx leal -65(%eax), %edx andl $-64, %edx movl %edx, -24(%ebp) leal 64(%edx), %edx movl %edx, -28(%ebp) movl %ecx, %esi movl %ecx, -16(%ebp) movl %eax, %edi movl %eax, -20(%ebp) .align 4, 0x90 LBB5_8: movsd 56(%esi), %xmm0 movsd %xmm0, 56(%ebx) movsd 48(%esi), %xmm0 movsd %xmm0, 48(%ebx) movsd 40(%esi), %xmm0 movsd %xmm0, 40(%ebx) movsd 32(%esi), %xmm0 movsd %xmm0, 32(%ebx) movsd 24(%esi), %xmm0 movsd %xmm0, 24(%ebx) movsd 16(%esi), %xmm0 movsd %xmm0, 16(%ebx) movsd (%esi), %xmm0 movsd 8(%esi), %xmm1 movsd %xmm1, 8(%ebx) movsd %xmm0, (%ebx) movl 16(%ebp), %eax movl %eax, 8(%esp) movl %ebx, (%esp) movl $64, 4(%esp) call _md5_process_block addl $64, %esi addl $-64, %edi cmpl $64, %edi ja LBB5_8 movl -20(%ebp), %eax addl $-64, %eax subl -24(%ebp), %eax movl -16(%ebp), %ecx addl -28(%ebp), %ecx movl 16(%ebp), %ebx jmp LBB5_10 LBB5_15: movl %eax, %esi andl $-64, %esi movl %ebx, 8(%esp) movl %esi, 4(%esp) movl %ecx, (%esp) movl %ecx, -16(%ebp) movl %eax, %edi call _md5_process_block movl %edi, %eax movl -16(%ebp), %ecx addl %esi, %ecx andl $63, %eax LBB5_10: testl %eax, %eax movl %eax, %edi je LBB5_14 LBB5_11: movl 24(%ebx), %esi leal 28(%ebx,%esi), %eax movl %edi, 8(%esp) movl %ecx, 4(%esp) movl %eax, (%esp) call _memcpy addl %edi, %esi cmpl $64, %esi jb LBB5_13 leal 28(%ebx), %edi movl %ebx, 8(%esp) movl %edi, (%esp) movl $64, 4(%esp) call _md5_process_block addl $-64, %esi leal 92(%ebx), %eax movl %esi, 8(%esp) movl %eax, 4(%esp) movl %edi, (%esp) call _memcpy LBB5_13: movl %esi, 24(%ebx) LBB5_14: addl $28, %esp popl %esi popl %edi popl %ebx popl %ebp ret # ---------------------- .align 4, 0x90 .globl _md5_buffer _md5_buffer: pushl %ebp movl %esp, %ebp pushl %edi pushl %esi subl $176, %esp movl 16(%ebp), %esi movl 8(%ebp), %eax movl 12(%ebp), %ecx movl $1732584193, -168(%ebp) movl $-271733879, -164(%ebp) movl $-1732584194, -160(%ebp) movl $271733878, -156(%ebp) movl $0, -148(%ebp) movl $0, -152(%ebp) movl $0, -144(%ebp) leal -168(%ebp), %edi movl %edi, 8(%esp) movl %ecx, 4(%esp) movl %eax, (%esp) call _md5_process_bytes movl %esi, 4(%esp) movl %edi, (%esp) call _md5_finish_ctx addl $176, %esp popl %esi popl %edi popl %ebp ret # ---------------------- .section __TEXT,__const _fillbuf: .asciz "\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" # ---------------------- .subsections_via_symbols
chap18/ex25/fma_shuffle_tpt.asm
JamesType/optimization-manual
374
103552
; ; Copyright (C) 2021 by Intel Corporation ; ; Permission to use, copy, modify, and/or distribute this software for any ; purpose with or without fee is hereby granted. ; ; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH ; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, ; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR ; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ; PERFORMANCE OF THIS SOFTWARE. ; ; .globl fma_shuffle_tpt ; void fma_shuffle_tpt(uint64_t loop_cnt); ; On entry: ; rcx = loop_cnt _RDATA SEGMENT READ ALIGN(64) 'DATA' one_vec REAL8 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 shuf_vec DD 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 _RDATA ENDS .code fma_shuffle_tpt PROC public mov rdx, rsp and rsp, -10h sub rsp, 160 vmovaps xmmword ptr[rsp], xmm6 vmovaps xmmword ptr[rsp+16], xmm7 vmovaps xmmword ptr[rsp+32], xmm8 vmovaps xmmword ptr[rsp+48], xmm9 vmovaps xmmword ptr[rsp+64], xmm10 vmovaps xmmword ptr[rsp+80], xmm11 vmovaps xmmword ptr[rsp+96], xmm12 vmovaps xmmword ptr[rsp+112], xmm13 vmovaps xmmword ptr[rsp+128], xmm14 vmovaps xmmword ptr[rsp+144], xmm15 vmovups zmm0, ZMMWORD PTR one_vec vmovups zmm1, ZMMWORD PTR one_vec vmovups zmm2, ZMMWORD PTR one_vec vmovups zmm3, ZMMWORD PTR one_vec vmovups zmm4, ZMMWORD PTR one_vec vmovups zmm5, ZMMWORD PTR one_vec vmovups zmm6, ZMMWORD PTR one_vec vmovups zmm7, ZMMWORD PTR one_vec vmovups zmm8, ZMMWORD PTR one_vec vmovups zmm9, ZMMWORD PTR one_vec vmovups zmm10, ZMMWORD PTR one_vec vmovups zmm11, ZMMWORD PTR one_vec vmovups zmm12, ZMMWORD PTR shuf_vec vmovups zmm13, ZMMWORD PTR shuf_vec vmovups zmm14, ZMMWORD PTR shuf_vec vmovups zmm15, ZMMWORD PTR shuf_vec vmovups zmm16, ZMMWORD PTR shuf_vec vmovups zmm17, ZMMWORD PTR shuf_vec vmovups zmm18, ZMMWORD PTR shuf_vec vmovups zmm19, ZMMWORD PTR shuf_vec vmovups zmm20, ZMMWORD PTR shuf_vec vmovups zmm21, ZMMWORD PTR shuf_vec vmovups zmm22, ZMMWORD PTR shuf_vec vmovups zmm23, ZMMWORD PTR shuf_vec vmovups zmm30, ZMMWORD PTR shuf_vec ; mov rcx, loops loop1: vfmadd231pd zmm0, zmm0, zmm0 vfmadd231pd zmm1, zmm1, zmm1 vfmadd231pd zmm2, zmm2, zmm2 vfmadd231pd zmm3, zmm3, zmm3 vfmadd231pd zmm4, zmm4, zmm4 vfmadd231pd zmm5, zmm5, zmm5 vfmadd231pd zmm6, zmm6, zmm6 vfmadd231pd zmm7, zmm7, zmm7 vfmadd231pd zmm8, zmm8, zmm8 vfmadd231pd zmm9, zmm9, zmm9 vfmadd231pd zmm10, zmm10, zmm10 vfmadd231pd zmm11, zmm11, zmm11 vpermd zmm12, zmm30, zmm30 vpermd zmm13, zmm30, zmm30 vpermd zmm14, zmm30, zmm30 vpermd zmm15, zmm30, zmm30 vpermd zmm16, zmm30, zmm30 vpermd zmm17, zmm30, zmm30 vpermd zmm18, zmm30, zmm30 vpermd zmm19, zmm30, zmm30 vpermd zmm20, zmm30, zmm30 vpermd zmm21, zmm30, zmm30 vpermd zmm22, zmm30, zmm30 vpermd zmm23, zmm30, zmm30 dec rcx jg loop1 vzeroupper vmovaps xmm6, xmmword ptr[rsp] vmovaps xmm7, xmmword ptr[rsp+16] vmovaps xmm8, xmmword ptr[rsp+32] vmovaps xmm9, xmmword ptr[rsp+48] vmovaps xmm10, xmmword ptr[rsp+64] vmovaps xmm11, xmmword ptr[rsp+80] vmovaps xmm12, xmmword ptr[rsp+96] vmovaps xmm13, xmmword ptr[rsp+112] vmovaps xmm14, xmmword ptr[rsp+128] vmovaps xmm15, xmmword ptr[rsp+144] mov rsp, rdx ret fma_shuffle_tpt ENDP end
example-output/SyscallsStubs.x86.nasm
iNoSec2/SysWhispers2
1
242673
<gh_stars>1-10 [SECTION .data] global _NtAccessCheck global _NtWorkerFactoryWorkerReady global _NtAcceptConnectPort global _NtMapUserPhysicalPagesScatter global _NtWaitForSingleObject global _NtCallbackReturn global _NtReadFile global _NtDeviceIoControlFile global _NtWriteFile global _NtRemoveIoCompletion global _NtReleaseSemaphore global _NtReplyWaitReceivePort global _NtReplyPort global _NtSetInformationThread global _NtSetEvent global _NtClose global _NtQueryObject global _NtQueryInformationFile global _NtOpenKey global _NtEnumerateValueKey global _NtFindAtom global _NtQueryDefaultLocale global _NtQueryKey global _NtQueryValueKey global _NtAllocateVirtualMemory global _NtQueryInformationProcess global _NtWaitForMultipleObjects32 global _NtWriteFileGather global _NtCreateKey global _NtFreeVirtualMemory global _NtImpersonateClientOfPort global _NtReleaseMutant global _NtQueryInformationToken global _NtRequestWaitReplyPort global _NtQueryVirtualMemory global _NtOpenThreadToken global _NtQueryInformationThread global _NtOpenProcess global _NtSetInformationFile global _NtMapViewOfSection global _NtAccessCheckAndAuditAlarm global _NtUnmapViewOfSection global _NtReplyWaitReceivePortEx global _NtTerminateProcess global _NtSetEventBoostPriority global _NtReadFileScatter global _NtOpenThreadTokenEx global _NtOpenProcessTokenEx global _NtQueryPerformanceCounter global _NtEnumerateKey global _NtOpenFile global _NtDelayExecution global _NtQueryDirectoryFile global _NtQuerySystemInformation global _NtOpenSection global _NtQueryTimer global _NtFsControlFile global _NtWriteVirtualMemory global _NtCloseObjectAuditAlarm global _NtDuplicateObject global _NtQueryAttributesFile global _NtClearEvent global _NtReadVirtualMemory global _NtOpenEvent global _NtAdjustPrivilegesToken global _NtDuplicateToken global _NtContinue global _NtQueryDefaultUILanguage global _NtQueueApcThread global _NtYieldExecution global _NtAddAtom global _NtCreateEvent global _NtQueryVolumeInformationFile global _NtCreateSection global _NtFlushBuffersFile global _NtApphelpCacheControl global _NtCreateProcessEx global _NtCreateThread global _NtIsProcessInJob global _NtProtectVirtualMemory global _NtQuerySection global _NtResumeThread global _NtTerminateThread global _NtReadRequestData global _NtCreateFile global _NtQueryEvent global _NtWriteRequestData global _NtOpenDirectoryObject global _NtAccessCheckByTypeAndAuditAlarm global _NtWaitForMultipleObjects global _NtSetInformationObject global _NtCancelIoFile global _NtTraceEvent global _NtPowerInformation global _NtSetValueKey global _NtCancelTimer global _NtSetTimer global _NtAccessCheckByType global _NtAccessCheckByTypeResultList global _NtAccessCheckByTypeResultListAndAuditAlarm global _NtAccessCheckByTypeResultListAndAuditAlarmByHandle global _NtAcquireProcessActivityReference global _NtAddAtomEx global _NtAddBootEntry global _NtAddDriverEntry global _NtAdjustGroupsToken global _NtAdjustTokenClaimsAndDeviceGroups global _NtAlertResumeThread global _NtAlertThread global _NtAlertThreadByThreadId global _NtAllocateLocallyUniqueId global _NtAllocateReserveObject global _NtAllocateUserPhysicalPages global _NtAllocateUuids global _NtAllocateVirtualMemoryEx global _NtAlpcAcceptConnectPort global _NtAlpcCancelMessage global _NtAlpcConnectPort global _NtAlpcConnectPortEx global _NtAlpcCreatePort global _NtAlpcCreatePortSection global _NtAlpcCreateResourceReserve global _NtAlpcCreateSectionView global _NtAlpcCreateSecurityContext global _NtAlpcDeletePortSection global _NtAlpcDeleteResourceReserve global _NtAlpcDeleteSectionView global _NtAlpcDeleteSecurityContext global _NtAlpcDisconnectPort global _NtAlpcImpersonateClientContainerOfPort global _NtAlpcImpersonateClientOfPort global _NtAlpcOpenSenderProcess global _NtAlpcOpenSenderThread global _NtAlpcQueryInformation global _NtAlpcQueryInformationMessage global _NtAlpcRevokeSecurityContext global _NtAlpcSendWaitReceivePort global _NtAlpcSetInformation global _NtAreMappedFilesTheSame global _NtAssignProcessToJobObject global _NtAssociateWaitCompletionPacket global _NtCallEnclave global _NtCancelIoFileEx global _NtCancelSynchronousIoFile global _NtCancelTimer2 global _NtCancelWaitCompletionPacket global _NtCommitComplete global _NtCommitEnlistment global _NtCommitRegistryTransaction global _NtCommitTransaction global _NtCompactKeys global _NtCompareObjects global _NtCompareSigningLevels global _NtCompareTokens global _NtCompleteConnectPort global _NtCompressKey global _NtConnectPort global _NtConvertBetweenAuxiliaryCounterAndPerformanceCounter global _NtCreateDebugObject global _NtCreateDirectoryObject global _NtCreateDirectoryObjectEx global _NtCreateEnclave global _NtCreateEnlistment global _NtCreateEventPair global _NtCreateIRTimer global _NtCreateIoCompletion global _NtCreateJobObject global _NtCreateJobSet global _NtCreateKeyTransacted global _NtCreateKeyedEvent global _NtCreateLowBoxToken global _NtCreateMailslotFile global _NtCreateMutant global _NtCreateNamedPipeFile global _NtCreatePagingFile global _NtCreatePartition global _NtCreatePort global _NtCreatePrivateNamespace global _NtCreateProcess global _NtCreateProfile global _NtCreateProfileEx global _NtCreateRegistryTransaction global _NtCreateResourceManager global _NtCreateSemaphore global _NtCreateSymbolicLinkObject global _NtCreateThreadEx global _NtCreateTimer global _NtCreateTimer2 global _NtCreateToken global _NtCreateTokenEx global _NtCreateTransaction global _NtCreateTransactionManager global _NtCreateUserProcess global _NtCreateWaitCompletionPacket global _NtCreateWaitablePort global _NtCreateWnfStateName global _NtCreateWorkerFactory global _NtDebugActiveProcess global _NtDebugContinue global _NtDeleteAtom global _NtDeleteBootEntry global _NtDeleteDriverEntry global _NtDeleteFile global _NtDeleteKey global _NtDeleteObjectAuditAlarm global _NtDeletePrivateNamespace global _NtDeleteValueKey global _NtDeleteWnfStateData global _NtDeleteWnfStateName global _NtDisableLastKnownGood global _NtDisplayString global _NtDrawText global _NtEnableLastKnownGood global _NtEnumerateBootEntries global _NtEnumerateDriverEntries global _NtEnumerateSystemEnvironmentValuesEx global _NtEnumerateTransactionObject global _NtExtendSection global _NtFilterBootOption global _NtFilterToken global _NtFilterTokenEx global _NtFlushBuffersFileEx global _NtFlushInstallUILanguage global _NtFlushInstructionCache global _NtFlushKey global _NtFlushProcessWriteBuffers global _NtFlushVirtualMemory global _NtFlushWriteBuffer global _NtFreeUserPhysicalPages global _NtFreezeRegistry global _NtFreezeTransactions global _NtGetCachedSigningLevel global _NtGetCompleteWnfStateSubscription global _NtGetContextThread global _NtGetCurrentProcessorNumber global _NtGetCurrentProcessorNumberEx global _NtGetDevicePowerState global _NtGetMUIRegistryInfo global _NtGetNextProcess global _NtGetNextThread global _NtGetNlsSectionPtr global _NtGetNotificationResourceManager global _NtGetWriteWatch global _NtImpersonateAnonymousToken global _NtImpersonateThread global _NtInitializeEnclave global _NtInitializeNlsFiles global _NtInitializeRegistry global _NtInitiatePowerAction global _NtIsSystemResumeAutomatic global _NtIsUILanguageComitted global _NtListenPort global _NtLoadDriver global _NtLoadEnclaveData global _NtLoadHotPatch global _NtLoadKey global _NtLoadKey2 global _NtLoadKeyEx global _NtLockFile global _NtLockProductActivationKeys global _NtLockRegistryKey global _NtLockVirtualMemory global _NtMakePermanentObject global _NtMakeTemporaryObject global _NtManagePartition global _NtMapCMFModule global _NtMapUserPhysicalPages global _NtMapViewOfSectionEx global _NtModifyBootEntry global _NtModifyDriverEntry global _NtNotifyChangeDirectoryFile global _NtNotifyChangeDirectoryFileEx global _NtNotifyChangeKey global _NtNotifyChangeMultipleKeys global _NtNotifyChangeSession global _NtOpenEnlistment global _NtOpenEventPair global _NtOpenIoCompletion global _NtOpenJobObject global _NtOpenKeyEx global _NtOpenKeyTransacted global _NtOpenKeyTransactedEx global _NtOpenKeyedEvent global _NtOpenMutant global _NtOpenObjectAuditAlarm global _NtOpenPartition global _NtOpenPrivateNamespace global _NtOpenProcessToken global _NtOpenRegistryTransaction global _NtOpenResourceManager global _NtOpenSemaphore global _NtOpenSession global _NtOpenSymbolicLinkObject global _NtOpenThread global _NtOpenTimer global _NtOpenTransaction global _NtOpenTransactionManager global _NtPlugPlayControl global _NtPrePrepareComplete global _NtPrePrepareEnlistment global _NtPrepareComplete global _NtPrepareEnlistment global _NtPrivilegeCheck global _NtPrivilegeObjectAuditAlarm global _NtPrivilegedServiceAuditAlarm global _NtPropagationComplete global _NtPropagationFailed global _NtPulseEvent global _NtQueryAuxiliaryCounterFrequency global _NtQueryBootEntryOrder global _NtQueryBootOptions global _NtQueryDebugFilterState global _NtQueryDirectoryFileEx global _NtQueryDirectoryObject global _NtQueryDriverEntryOrder global _NtQueryEaFile global _NtQueryFullAttributesFile global _NtQueryInformationAtom global _NtQueryInformationByName global _NtQueryInformationEnlistment global _NtQueryInformationJobObject global _NtQueryInformationPort global _NtQueryInformationResourceManager global _NtQueryInformationTransaction global _NtQueryInformationTransactionManager global _NtQueryInformationWorkerFactory global _NtQueryInstallUILanguage global _NtQueryIntervalProfile global _NtQueryIoCompletion global _NtQueryLicenseValue global _NtQueryMultipleValueKey global _NtQueryMutant global _NtQueryOpenSubKeys global _NtQueryOpenSubKeysEx global _NtQueryPortInformationProcess global _NtQueryQuotaInformationFile global _NtQuerySecurityAttributesToken global _NtQuerySecurityObject global _NtQuerySecurityPolicy global _NtQuerySemaphore global _NtQuerySymbolicLinkObject global _NtQuerySystemEnvironmentValue global _NtQuerySystemEnvironmentValueEx global _NtQuerySystemInformationEx global _NtQueryTimerResolution global _NtQueryWnfStateData global _NtQueryWnfStateNameInformation global _NtQueueApcThreadEx global _NtRaiseException global _NtRaiseHardError global _NtReadOnlyEnlistment global _NtRecoverEnlistment global _NtRecoverResourceManager global _NtRecoverTransactionManager global _NtRegisterProtocolAddressInformation global _NtRegisterThreadTerminatePort global _NtReleaseKeyedEvent global _NtReleaseWorkerFactoryWorker global _NtRemoveIoCompletionEx global _NtRemoveProcessDebug global _NtRenameKey global _NtRenameTransactionManager global _NtReplaceKey global _NtReplacePartitionUnit global _NtReplyWaitReplyPort global _NtRequestPort global _NtResetEvent global _NtResetWriteWatch global _NtRestoreKey global _NtResumeProcess global _NtRevertContainerImpersonation global _NtRollbackComplete global _NtRollbackEnlistment global _NtRollbackRegistryTransaction global _NtRollbackTransaction global _NtRollforwardTransactionManager global _NtSaveKey global _NtSaveKeyEx global _NtSaveMergedKeys global _NtSecureConnectPort global _NtSerializeBoot global _NtSetBootEntryOrder global _NtSetBootOptions global _NtSetCachedSigningLevel global _NtSetCachedSigningLevel2 global _NtSetContextThread global _NtSetDebugFilterState global _NtSetDefaultHardErrorPort global _NtSetDefaultLocale global _NtSetDefaultUILanguage global _NtSetDriverEntryOrder global _NtSetEaFile global _NtSetHighEventPair global _NtSetHighWaitLowEventPair global _NtSetIRTimer global _NtSetInformationDebugObject global _NtSetInformationEnlistment global _NtSetInformationJobObject global _NtSetInformationKey global _NtSetInformationResourceManager global _NtSetInformationSymbolicLink global _NtSetInformationToken global _NtSetInformationTransaction global _NtSetInformationTransactionManager global _NtSetInformationVirtualMemory global _NtSetInformationWorkerFactory global _NtSetIntervalProfile global _NtSetIoCompletion global _NtSetIoCompletionEx global _NtSetLdtEntries global _NtSetLowEventPair global _NtSetLowWaitHighEventPair global _NtSetQuotaInformationFile global _NtSetSecurityObject global _NtSetSystemEnvironmentValue global _NtSetSystemEnvironmentValueEx global _NtSetSystemInformation global _NtSetSystemPowerState global _NtSetSystemTime global _NtSetThreadExecutionState global _NtSetTimer2 global _NtSetTimerEx global _NtSetTimerResolution global _NtSetUuidSeed global _NtSetVolumeInformationFile global _NtSetWnfProcessNotificationEvent global _NtShutdownSystem global _NtShutdownWorkerFactory global _NtSignalAndWaitForSingleObject global _NtSinglePhaseReject global _NtStartProfile global _NtStopProfile global _NtSubscribeWnfStateChange global _NtSuspendProcess global _NtSuspendThread global _NtSystemDebugControl global _NtTerminateEnclave global _NtTerminateJobObject global _NtTestAlert global _NtThawRegistry global _NtThawTransactions global _NtTraceControl global _NtTranslateFilePath global _NtUmsThreadYield global _NtUnloadDriver global _NtUnloadKey global _NtUnloadKey2 global _NtUnloadKeyEx global _NtUnlockFile global _NtUnlockVirtualMemory global _NtUnmapViewOfSectionEx global _NtUnsubscribeWnfStateChange global _NtUpdateWnfStateData global _NtVdmControl global _NtWaitForAlertByThreadId global _NtWaitForDebugEvent global _NtWaitForKeyedEvent global _NtWaitForWorkViaWorkerFactory global _NtWaitHighEventPair global _NtWaitLowEventPair global _NtAcquireCMFViewOwnership global _NtCancelDeviceWakeupRequest global _NtClearAllSavepointsTransaction global _NtClearSavepointTransaction global _NtRollbackSavepointTransaction global _NtSavepointTransaction global _NtSavepointComplete global _NtCreateSectionEx global _NtCreateCrossVmEvent global _NtGetPlugPlayEvent global _NtListTransactions global _NtMarshallTransaction global _NtPullTransaction global _NtReleaseCMFViewOwnership global _NtWaitForWnfNotifications global _NtStartTm global _NtSetInformationProcess global _NtRequestDeviceWakeup global _NtRequestWakeupLatency global _NtQuerySystemTime global _NtManageHotPatch global _NtContinueEx global _RtlCreateUserThread global _WhisperMain extern _SW2_GetSyscallNumber [SECTION .text] BITS 32 _WhisperMain: pop eax ; Remove return address from CALL instruction call _SW2_GetSyscallNumber ; Resolve function hash into syscall number add esp, 4 ; Restore ESP mov ecx, [fs:0c0h] test ecx, ecx jne _wow64 lea edx, [esp+4h] INT 02eh ret _wow64: xor ecx, ecx lea edx, [esp+4h] call dword [fs:0c0h] ret _NtAccessCheck: push 0FA40F4F9h call _WhisperMain _NtWorkerFactoryWorkerReady: push 011A63B35h call _WhisperMain _NtAcceptConnectPort: push 064F17B62h call _WhisperMain _NtMapUserPhysicalPagesScatter: push 0238A0D17h call _WhisperMain _NtWaitForSingleObject: push 0009E3E33h call _WhisperMain _NtCallbackReturn: push 0168C371Ah call _WhisperMain _NtReadFile: push 0C544CDF1h call _WhisperMain _NtDeviceIoControlFile: push 022342AD2h call _WhisperMain _NtWriteFile: push 0E97AEB1Fh call _WhisperMain _NtRemoveIoCompletion: push 0088E0821h call _WhisperMain _NtReleaseSemaphore: push 034A10CFCh call _WhisperMain _NtReplyWaitReceivePort: push 0ACFE8EA0h call _WhisperMain _NtReplyPort: push 062B0692Eh call _WhisperMain _NtSetInformationThread: push 00A2E4E86h call _WhisperMain _NtSetEvent: push 058924AF4h call _WhisperMain _NtClose: push 00352369Dh call _WhisperMain _NtQueryObject: push 08CA077CCh call _WhisperMain _NtQueryInformationFile: push 0A635B086h call _WhisperMain _NtOpenKey: push 00F1A54C7h call _WhisperMain _NtEnumerateValueKey: push <KEY> call _WhisperMain _NtFindAtom: push 03565D433h call _WhisperMain _NtQueryDefaultLocale: push 0025D728Bh call _WhisperMain _NtQueryKey: push 008172BACh call _WhisperMain _NtQueryValueKey: push 0E15C142Eh call _WhisperMain _NtAllocateVirtualMemory: push 01F88E9E7h call _WhisperMain _NtQueryInformationProcess: push 0D99B2213h call _WhisperMain _NtWaitForMultipleObjects32: push 08E9DAF4Ah call _WhisperMain _NtWriteFileGather: push 02B907B53h call _WhisperMain _NtCreateKey: push <KEY> call _WhisperMain _NtFreeVirtualMemory: push 0099E0519h call _WhisperMain _NtImpersonateClientOfPort: push 060F36F68h call _WhisperMain _NtReleaseMutant: push 02D4A0AD0h call _WhisperMain _NtQueryInformationToken: push <KEY> call _WhisperMain _NtRequestWaitReplyPort: push 0E273D9DCh call _WhisperMain _NtQueryVirtualMemory: push 09514A39Bh call _WhisperMain _NtOpenThreadToken: push 0F8512DEAh call _WhisperMain _NtQueryInformationThread: push 024881E11h call _WhisperMain _NtOpenProcess: push 006AC0521h call _WhisperMain _NtSetInformationFile: push 0CA7AC2ECh call _WhisperMain _NtMapViewOfSection: push 004960E0Bh call _WhisperMain _NtAccessCheckAndAuditAlarm: push 00F2EC371h call _WhisperMain _NtUnmapViewOfSection: push 0568C3591h call _WhisperMain _NtReplyWaitReceivePortEx: push 0A25FEA98h call _WhisperMain _NtTerminateProcess: push 0FE26D5BBh call _WhisperMain _NtSetEventBoostPriority: push 030863C0Ch call _WhisperMain _NtReadFileScatter: push 0159C1D07h call _WhisperMain _NtOpenThreadTokenEx: push 02FBAF2EFh call _WhisperMain _NtOpenProcessTokenEx: push 0791FB957h call _WhisperMain _NtQueryPerformanceCounter: push 037D24B39h call _WhisperMain _NtEnumerateKey: push 0B6AE97F4h call _WhisperMain _NtOpenFile: push 0AD1C2B01h call _WhisperMain _NtDelayExecution: push 0520D529Fh call _WhisperMain _NtQueryDirectoryFile: push 058BBAAE2h call _WhisperMain _NtQuerySystemInformation: push 054CD765Dh call _WhisperMain _NtOpenSection: push 00A9E284Fh call _WhisperMain _NtQueryTimer: push 0179F7F46h call _WhisperMain _NtFsControlFile: push 06AF45662h call _WhisperMain _NtWriteVirtualMemory: push 005953B23h call _WhisperMain _NtCloseObjectAuditAlarm: push 05CDA584Ch call _WhisperMain _NtDuplicateObject: push 03EA1F6FDh call _WhisperMain _NtQueryAttributesFile: push 0DD5DD9FDh call _WhisperMain _NtClearEvent: push 0200B65DAh call _WhisperMain _NtReadVirtualMemory: push 0071473E9h call _WhisperMain _NtOpenEvent: push 030D52978h call _WhisperMain _NtAdjustPrivilegesToken: push 001940B2Dh call _WhisperMain _NtDuplicateToken: push 06DD92558h call _WhisperMain _NtContinue: push 0009CD3D0h call _WhisperMain _NtQueryDefaultUILanguage: push 013C5D178h call _WhisperMain _NtQueueApcThread: push 02E8A0C2Bh call _WhisperMain _NtYieldExecution: push 014B63E33h call _WhisperMain _NtAddAtom: push 022BF272Eh call _WhisperMain _NtCreateEvent: push 0B0B4AF3Fh call _WhisperMain _NtQueryVolumeInformationFile: push 0E5B3BD76h call _WhisperMain _NtCreateSection: push 04EC54C51h call _WhisperMain _NtFlushBuffersFile: push 06CFB5E2Eh call _WhisperMain _NtApphelpCacheControl: push 0FD6DDFBBh call _WhisperMain _NtCreateProcessEx: push 0B998FB42h call _WhisperMain _NtCreateThread: push 0AF8CB334h call _WhisperMain _NtIsProcessInJob: push 05CE54854h call _WhisperMain _NtProtectVirtualMemory: push 00F940311h call _WhisperMain _NtQuerySection: push 002EC25B9h call _WhisperMain _NtResumeThread: push 07D5445CFh call _WhisperMain _NtTerminateThread: push 0228E3037h call _WhisperMain _NtReadRequestData: push 0A23EB14Ch call _WhisperMain _NtCreateFile: push 02A9AE32Eh call _WhisperMain _NtQueryEvent: push 02AB1F0E6h call _WhisperMain _NtWriteRequestData: push 09DC08975h call _WhisperMain _NtOpenDirectoryObject: push 03C802E0Dh call _WhisperMain _NtAccessCheckByTypeAndAuditAlarm: push 0DD42B9D5h call _WhisperMain _NtWaitForMultipleObjects: push 061AD6331h call _WhisperMain _NtSetInformationObject: push 0271915A7h call _WhisperMain _NtCancelIoFile: push 0821B7543h call _WhisperMain _NtTraceEvent: push 0CAED7BD0h call _WhisperMain _NtPowerInformation: push 054C25A5Fh call _WhisperMain _NtSetValueKey: push 01DC11E58h call _WhisperMain _NtCancelTimer: push 001A23302h call _WhisperMain _NtSetTimer: push 005977F7Ch call _WhisperMain _NtAccessCheckByType: push 0D442E30Ah call _WhisperMain _NtAccessCheckByTypeResultList: push 07EA17221h call _WhisperMain _NtAccessCheckByTypeResultListAndAuditAlarm: push 0552A6982h call _WhisperMain _NtAccessCheckByTypeResultListAndAuditAlarmByHandle: push 099B41796h call _WhisperMain _NtAcquireProcessActivityReference: push 01A8958A0h call _WhisperMain _NtAddAtomEx: push 09390C74Ch call _WhisperMain _NtAddBootEntry: push 005951912h call _WhisperMain _NtAddDriverEntry: push 03B67B174h call _WhisperMain _NtAdjustGroupsToken: push 025971314h call _WhisperMain _NtAdjustTokenClaimsAndDeviceGroups: push 007900309h call _WhisperMain _NtAlertResumeThread: push 0A48BA81Ah call _WhisperMain _NtAlertThread: push 01CA4540Bh call _WhisperMain _NtAlertThreadByThreadId: push 0B8A26896h call _WhisperMain _NtAllocateLocallyUniqueId: push 0FFE51B65h call _WhisperMain _NtAllocateReserveObject: push 018B4E6C9h call _WhisperMain _NtAllocateUserPhysicalPages: push 019BF3A24h call _WhisperMain _NtAllocateUuids: push 0338FFDD3h call _WhisperMain _NtAllocateVirtualMemoryEx: push 0C8503B3Ah call _WhisperMain _NtAlpcAcceptConnectPort: push 030B2213Ch call _WhisperMain _NtAlpcCancelMessage: push 073D77E7Ch call _WhisperMain _NtAlpcConnectPort: push 03EB1DDDEh call _WhisperMain _NtAlpcConnectPortEx: push 0636DBF29h call _WhisperMain _NtAlpcCreatePort: push 0194B9F58h call _WhisperMain _NtAlpcCreatePortSection: push 0C4F5DE41h call _WhisperMain _NtAlpcCreateResourceReserve: push 0389F4A77h call _WhisperMain _NtAlpcCreateSectionView: push 02CA81D13h call _WhisperMain _NtAlpcCreateSecurityContext: push 0FA1DE794h call _WhisperMain _NtAlpcDeletePortSection: push 00C982C0Bh call _WhisperMain _NtAlpcDeleteResourceReserve: push 01888F4C3h call _WhisperMain _NtAlpcDeleteSectionView: push 056EC6753h call _WhisperMain _NtAlpcDeleteSecurityContext: push 008B3EDDAh call _WhisperMain _NtAlpcDisconnectPort: push 022B5D93Ah call _WhisperMain _NtAlpcImpersonateClientContainerOfPort: push 02233A722h call _WhisperMain _NtAlpcImpersonateClientOfPort: push 0D836C9DAh call _WhisperMain _NtAlpcOpenSenderProcess: push 0C654C5C9h call _WhisperMain _NtAlpcOpenSenderThread: push 0F85F36EDh call _WhisperMain _NtAlpcQueryInformation: push 0024618CEh call _WhisperMain _NtAlpcQueryInformationMessage: push 0A40091ADh call _WhisperMain _NtAlpcRevokeSecurityContext: push 040998DC8h call _WhisperMain _NtAlpcSendWaitReceivePort: push 022B2A5B8h call _WhisperMain _NtAlpcSetInformation: push 0C897E64Bh call _WhisperMain _NtAreMappedFilesTheSame: push 0D65AEDFDh call _WhisperMain _NtAssignProcessToJobObject: push 0FF2A6100h call _WhisperMain _NtAssociateWaitCompletionPacket: push 007B22910h call _WhisperMain _NtCallEnclave: push 08736BB65h call _WhisperMain _NtCancelIoFileEx: push 0F758392Dh call _WhisperMain _NtCancelSynchronousIoFile: push 0256033EAh call _WhisperMain _NtCancelTimer2: push 003A35E2Dh call _WhisperMain _NtCancelWaitCompletionPacket: push 0BC9C9AC6h call _WhisperMain _NtCommitComplete: push 00C9007FEh call _WhisperMain _NtCommitEnlistment: push 0164B0FC6h call _WhisperMain _NtCommitRegistryTransaction: push 004B43E31h call _WhisperMain _NtCommitTransaction: push 018813A51h call _WhisperMain _NtCompactKeys: push <KEY> call _WhisperMain _NtCompareObjects: push 084648AF6h call _WhisperMain _NtCompareSigningLevels: push 0AEF09E73h call _WhisperMain _NtCompareTokens: push 0F494EC01h call _WhisperMain _NtCompleteConnectPort: push 03A7637F8h call _WhisperMain _NtCompressKey: push 0782E5F8Eh call _WhisperMain _NtConnectPort: push 0A23C9072h call _WhisperMain _NtConvertBetweenAuxiliaryCounterAndPerformanceCounter: push 079468945h call _WhisperMain _NtCreateDebugObject: push 0009E21C3h call _WhisperMain _NtCreateDirectoryObject: push 0FAD436BBh call _WhisperMain _NtCreateDirectoryObjectEx: push 0426E10B4h call _WhisperMain _NtCreateEnclave: push 0CA2FDE86h call _WhisperMain _NtCreateEnlistment: push 00F90ECC7h call _WhisperMain _NtCreateEventPair: push 012B1CCFCh call _WhisperMain _NtCreateIRTimer: push 0178C3F36h call _WhisperMain _NtCreateIoCompletion: push 00E1750D7h call _WhisperMain _NtCreateJobObject: push 0F65B6E57h call _WhisperMain _NtCreateJobSet: push 08740AF1Ch call _WhisperMain _NtCreateKeyTransacted: push 0A69A66C6h call _WhisperMain _NtCreateKeyedEvent: push 068CF755Eh call _WhisperMain _NtCreateLowBoxToken: push 017C73D1Ch call _WhisperMain _NtCreateMailslotFile: push 0E47DC2FEh call _WhisperMain _NtCreateMutant: push 0FDDC08A5h call _WhisperMain _NtCreateNamedPipeFile: push 0ED7AA75Bh call _WhisperMain _NtCreatePagingFile: push 054C36C00h call _WhisperMain _NtCreatePartition: push 0444E255Dh call _WhisperMain _NtCreatePort: push 02EB4CCDAh call _WhisperMain _NtCreatePrivateNamespace: push 009B1CFEBh call _WhisperMain _NtCreateProcess: push 081288EB0h call _WhisperMain _NtCreateProfile: push 06E3E6AA4h call _WhisperMain _NtCreateProfileEx: push 0029AC0C1h call _WhisperMain _NtCreateRegistryTransaction: push 0970FD3DEh call _WhisperMain _NtCreateResourceManager: push 06E52FA4Fh call _WhisperMain _NtCreateSemaphore: push 0FCB62D1Ah call _WhisperMain _NtCreateSymbolicLinkObject: push 083189384h call _WhisperMain _NtCreateThreadEx: push 096A7CC64h call _WhisperMain _NtCreateTimer: push 0E58D8F55h call _WhisperMain _NtCreateTimer2: push 0B0684CA6h call _WhisperMain _NtCreateToken: push 0099F9FBFh call _WhisperMain _NtCreateTokenEx: push 06022A67Ch call _WhisperMain _NtCreateTransaction: push 03CEE2243h call _WhisperMain _NtCreateTransactionManager: push 01BA730FAh call _WhisperMain _NtCreateUserProcess: push 0EC26CFBBh call _WhisperMain _NtCreateWaitCompletionPacket: push 001813F0Ah call _WhisperMain _NtCreateWaitablePort: push 0A97288DFh call _WhisperMain _NtCreateWnfStateName: push 0CED0FB42h call _WhisperMain _NtCreateWorkerFactory: push 0089C140Ah call _WhisperMain _NtDebugActiveProcess: push 0923099ADh call _WhisperMain _NtDebugContinue: push 05D24BC68h call _WhisperMain _NtDeleteAtom: push 0BED35C8Bh call _WhisperMain _NtDeleteBootEntry: push 0336B3BE4h call _WhisperMain _NtDeleteDriverEntry: push 033930B14h call _WhisperMain _NtDeleteFile: push 06EF46592h call _WhisperMain _NtDeleteKey: push 03AEE1D71h call _WhisperMain _NtDeleteObjectAuditAlarm: push 016B57464h call _WhisperMain _NtDeletePrivateNamespace: push 02A88393Fh call _WhisperMain _NtDeleteValueKey: push 036820931h call _WhisperMain _NtDeleteWnfStateData: push 032CE441Ah call _WhisperMain _NtDeleteWnfStateName: push 0A8B02387h call _WhisperMain _NtDisableLastKnownGood: push 0386B35C2h call _WhisperMain _NtDisplayString: push 076E83238h call _WhisperMain _NtDrawText: push 04918735Eh call _WhisperMain _NtEnableLastKnownGood: push 02DBE03F4h call _WhisperMain _NtEnumerateBootEntries: push 02C97BD9Bh call _WhisperMain _NtEnumerateDriverEntries: push 07CDC2D7Fh call _WhisperMain _NtEnumerateSystemEnvironmentValuesEx: push 053AF8FFBh call _WhisperMain _NtEnumerateTransactionObject: push 096B4A608h call _WhisperMain _NtExtendSection: push 00E8A340Fh call _WhisperMain _NtFilterBootOption: push 008A20BCFh call _WhisperMain _NtFilterToken: push <KEY> call _WhisperMain _NtFilterTokenEx: push <KEY> call _WhisperMain _NtFlushBuffersFileEx: push 026D4E08Ah call _WhisperMain _NtFlushInstallUILanguage: push 0A5BAD1A1h call _WhisperMain _NtFlushInstructionCache: push 00DAE4997h call _WhisperMain _NtFlushKey: push 09ED4BF6Eh call _WhisperMain _NtFlushProcessWriteBuffers: push 0D83A3DA2h call _WhisperMain _NtFlushVirtualMemory: push 08713938Fh call _WhisperMain _NtFlushWriteBuffer: push 0A538B5A7h call _WhisperMain _NtFreeUserPhysicalPages: push 0E5BEEE26h call _WhisperMain _NtFreezeRegistry: push 0069B203Bh call _WhisperMain _NtFreezeTransactions: push 04FAA257Dh call _WhisperMain _NtGetCachedSigningLevel: push 076BCA01Eh call _WhisperMain _NtGetCompleteWnfStateSubscription: push 0148F1A13h call _WhisperMain _NtGetContextThread: push 00C9C1E2Dh call _WhisperMain _NtGetCurrentProcessorNumber: push 08E33C8E6h call _WhisperMain _NtGetCurrentProcessorNumberEx: push 05AD599AEh call _WhisperMain _NtGetDevicePowerState: push 0A43BB4B4h call _WhisperMain _NtGetMUIRegistryInfo: push 07ACEA663h call _WhisperMain _NtGetNextProcess: push 00DA3362Ch call _WhisperMain _NtGetNextThread: push 09A3DD48Fh call _WhisperMain _NtGetNlsSectionPtr: push 0FF5DD282h call _WhisperMain _NtGetNotificationResourceManager: push 0EFB2719Eh call _WhisperMain _NtGetWriteWatch: push 08AA31383h call _WhisperMain _NtImpersonateAnonymousToken: push <PASSWORD>22h call _WhisperMain _NtImpersonateThread: push 0FA202799h call _WhisperMain _NtInitializeEnclave: push 02C9310D2h call _WhisperMain _NtInitializeNlsFiles: push 0744F05ACh call _WhisperMain _NtInitializeRegistry: push 034901C3Fh call _WhisperMain _NtInitiatePowerAction: push 0C690DF3Bh call _WhisperMain _NtIsSystemResumeAutomatic: push 0A4A02186h call _WhisperMain _NtIsUILanguageComitted: push 0D5EB91C3h call _WhisperMain _NtListenPort: push 0DCB0DF3Fh call _WhisperMain _NtLoadDriver: push 01C9F4E5Ch call _WhisperMain _NtLoadEnclaveData: push 0074E907Ah call _WhisperMain _NtLoadHotPatch: push 09F721D4Fh call _WhisperMain _NtLoadKey: push 03F1844E5h call _WhisperMain _NtLoadKey2: push <KEY> call _WhisperMain _NtLoadKeyEx: push <KEY> call _WhisperMain _NtLockFile: push 0E17FCDAFh call _WhisperMain _NtLockProductActivationKeys: push 067E66A7Ch call _WhisperMain _NtLockRegistryKey: push <KEY> call _WhisperMain _NtLockVirtualMemory: push 00B981D77h call _WhisperMain _NtMakePermanentObject: push 0243B2EA5h call _WhisperMain _NtMakeTemporaryObject: push 0263B5ED7h call _WhisperMain _NtManagePartition: push 008B1E6EDh call _WhisperMain _NtMapCMFModule: push 03917A320h call _WhisperMain _NtMapUserPhysicalPages: push 01142E82Ch call _WhisperMain _NtMapViewOfSectionEx: push 0BE9CE842h call _WhisperMain _NtModifyBootEntry: push 009941D38h call _WhisperMain _NtModifyDriverEntry: push 071E16D64h call _WhisperMain _NtNotifyChangeDirectoryFile: push 01999E00Dh call _WhisperMain _NtNotifyChangeDirectoryFileEx: push 06B97BFCBh call _WhisperMain _NtNotifyChangeKey: push 0CB12AAE8h call _WhisperMain _NtNotifyChangeMultipleKeys: push 07F837404h call _WhisperMain _NtNotifyChangeSession: push 0E78FE71Dh call _WhisperMain _NtOpenEnlistment: push 0BABADD51h call _WhisperMain _NtOpenEventPair: push 090B047E6h call _WhisperMain _NtOpenIoCompletion: push 00C656AADh call _WhisperMain _NtOpenJobObject: push 0429C0E63h call _WhisperMain _NtOpenKeyEx: push 06BDD9BA6h call _WhisperMain _NtOpenKeyTransacted: push 010CD1A62h call _WhisperMain _NtOpenKeyTransactedEx: push 086AEC878h call _WhisperMain _NtOpenKeyedEvent: push 050CB5D4Ah call _WhisperMain _NtOpenMutant: push 01693FCC5h call _WhisperMain _NtOpenObjectAuditAlarm: push 074B25FF4h call _WhisperMain _NtOpenPartition: push 00ABA2FF1h call _WhisperMain _NtOpenPrivateNamespace: push 0B09231BFh call _WhisperMain _NtOpenProcessToken: push 0079A848Bh call _WhisperMain _NtOpenRegistryTransaction: push 09A319AAFh call _WhisperMain _NtOpenResourceManager: push 0B66CDF77h call _WhisperMain _NtOpenSemaphore: push 0F6A700EFh call _WhisperMain _NtOpenSession: push 00D814956h call _WhisperMain _NtOpenSymbolicLinkObject: push 01904FB1Ah call _WhisperMain _NtOpenThread: push 01A394106h call _WhisperMain _NtOpenTimer: push 0EFDDD16Ch call _WhisperMain _NtOpenTransaction: push 005512406h call _WhisperMain _NtOpenTransactionManager: push 075CB4D46h call _WhisperMain _NtPlugPlayControl: push 03DAA0509h call _WhisperMain _NtPrePrepareComplete: push 02CB80836h call _WhisperMain _NtPrePrepareEnlistment: push 0CBA5EC3Eh call _WhisperMain _NtPrepareComplete: push 036B3A4BCh call _WhisperMain _NtPrepareEnlistment: push 009A70C2Dh call _WhisperMain _NtPrivilegeCheck: push 0369A4D17h call _WhisperMain _NtPrivilegeObjectAuditAlarm: push 0E121E24Fh call _WhisperMain _NtPrivilegedServiceAuditAlarm: push 018BE3C28h call _WhisperMain _NtPropagationComplete: push 0EC50B8DEh call _WhisperMain _NtPropagationFailed: push 03B967B3Dh call _WhisperMain _NtPulseEvent: push 0B83B91A6h call _WhisperMain _NtQueryAuxiliaryCounterFrequency: push 02A98F7CCh call _WhisperMain _NtQueryBootEntryOrder: push 01F8FFB1Dh call _WhisperMain _NtQueryBootOptions: push 03FA93D3Dh call _WhisperMain _NtQueryDebugFilterState: push 032B3381Ch call _WhisperMain _NtQueryDirectoryFileEx: push 06A583A81h call _WhisperMain _NtQueryDirectoryObject: push 01E2038BDh call _WhisperMain _NtQueryDriverEntryOrder: push 0030611A3h call _WhisperMain _NtQueryEaFile: push 068B37000h call _WhisperMain _NtQueryFullAttributesFile: push 05AC5645Eh call _WhisperMain _NtQueryInformationAtom: push 09602B592h call _WhisperMain _NtQueryInformationByName: push 0E70F1F6Ch call _WhisperMain _NtQueryInformationEnlistment: push 0264639ECh call _WhisperMain _NtQueryInformationJobObject: push 0C4592CC5h call _WhisperMain _NtQueryInformationPort: push 0920FB59Ch call _WhisperMain _NtQueryInformationResourceManager: push 00FB2919Eh call _WhisperMain _NtQueryInformationTransaction: push 00C982C0Bh call _WhisperMain _NtQueryInformationTransactionManager: push 0C7A72CDFh call _WhisperMain _NtQueryInformationWorkerFactory: push 002921C16h call _WhisperMain _NtQueryInstallUILanguage: push 017B127EAh call _WhisperMain _NtQueryIntervalProfile: push 0AC3DA4AEh call _WhisperMain _NtQueryIoCompletion: push 0D44FD6DBh call _WhisperMain _NtQueryLicenseValue: push 02C911B3Ah call _WhisperMain _NtQueryMultipleValueKey: push 0AD19D0EAh call _WhisperMain _NtQueryMutant: push 096B0913Bh call _WhisperMain _NtQueryOpenSubKeys: push <KEY> call _WhisperMain _NtQueryOpenSubKeysEx: push <KEY> call _WhisperMain _NtQueryPortInformationProcess: push 05F927806h call _WhisperMain _NtQueryQuotaInformationFile: push 077C5FEE7h call _WhisperMain _NtQuerySecurityAttributesToken: push 07BDE4D76h call _WhisperMain _NtQuerySecurityObject: push 090BFA0F3h call _WhisperMain _NtQuerySecurityPolicy: push 0924491DFh call _WhisperMain _NtQuerySemaphore: push 0FD6197B7h call _WhisperMain _NtQuerySymbolicLinkObject: push 095B8ABF2h call _WhisperMain _NtQuerySystemEnvironmentValue: push 0EEBB8F76h call _WhisperMain _NtQuerySystemEnvironmentValueEx: push 0F7CCB537h call _WhisperMain _NtQuerySystemInformationEx: push 0AC916FCBh call _WhisperMain _NtQueryTimerResolution: push 00E952C59h call _WhisperMain _NtQueryWnfStateData: push 0BE05928Ah call _WhisperMain _NtQueryWnfStateNameInformation: push 084D362C7h call _WhisperMain _NtQueueApcThreadEx: push 0A0A0EE66h call _WhisperMain _NtRaiseException: push 006D2298Fh call _WhisperMain _NtRaiseHardError: push 003911D39h call _WhisperMain _NtReadOnlyEnlistment: push 049C28E91h call _WhisperMain _NtRecoverEnlistment: push 09B359EA3h call _WhisperMain _NtRecoverResourceManager: push 06E35F61Fh call _WhisperMain _NtRecoverTransactionManager: push 0042EDC04h call _WhisperMain _NtRegisterProtocolAddressInformation: push 0163F1CABh call _WhisperMain _NtRegisterThreadTerminatePort: push 0A23783AAh call _WhisperMain _NtReleaseKeyedEvent: push 070C34B44h call _WhisperMain _NtReleaseWorkerFactoryWorker: push 0A4902D8Ah call _WhisperMain _NtRemoveIoCompletionEx: push 09CAECE74h call _WhisperMain _NtRemoveProcessDebug: push 022BCCF36h call _WhisperMain _NtRenameKey: push 0299D0C3Eh call _WhisperMain _NtRenameTransactionManager: push 08E319293h call _WhisperMain _NtReplaceKey: push 0491C78A6h call _WhisperMain _NtReplacePartitionUnit: push 060B16C32h call _WhisperMain _NtReplyWaitReplyPort: push 020B10F6Ah call _WhisperMain _NtRequestPort: push 05AB65B38h call _WhisperMain _NtResetEvent: push 0EB51ECC2h call _WhisperMain _NtResetWriteWatch: push 098D39446h call _WhisperMain _NtRestoreKey: push <KEY> call _WhisperMain _NtResumeProcess: push 0419F7230h call _WhisperMain _NtRevertContainerImpersonation: push 034A21431h call _WhisperMain _NtRollbackComplete: push 068B8741Ah call _WhisperMain _NtRollbackEnlistment: push 09136B2A1h call _WhisperMain _NtRollbackRegistryTransaction: push 070BB5E67h call _WhisperMain _NtRollbackTransaction: push 01CF8004Bh call _WhisperMain _NtRollforwardTransactionManager: push 011C3410Eh call _WhisperMain _NtSaveKey: push <KEY> call _WhisperMain _NtSaveKeyEx: push 0EB6BDED6h call _WhisperMain _NtSaveMergedKeys: push 0D3B4D6C4h call _WhisperMain _NtSecureConnectPort: push 072ED4142h call _WhisperMain _NtSerializeBoot: push 0B0207C61h call _WhisperMain _NtSetBootEntryOrder: push 0CDEFFD41h call _WhisperMain _NtSetBootOptions: push 09F099D9Dh call _WhisperMain _NtSetCachedSigningLevel: push 0CF7DE7A1h call _WhisperMain _NtSetCachedSigningLevel2: push 06EB2EC62h call _WhisperMain _NtSetContextThread: push 04CFC0A5Dh call _WhisperMain _NtSetDebugFilterState: push 0348E382Ch call _WhisperMain _NtSetDefaultHardErrorPort: push 0B8AAB528h call _WhisperMain _NtSetDefaultLocale: push 085A95D9Dh call _WhisperMain _NtSetDefaultUILanguage: push 0AD325030h call _WhisperMain _NtSetDriverEntryOrder: push 00F9C1D01h call _WhisperMain _NtSetEaFile: push 0533D3DE8h call _WhisperMain _NtSetHighEventPair: push 0A6AF463Dh call _WhisperMain _NtSetHighWaitLowEventPair: push 0A6B5AA27h call _WhisperMain _NtSetIRTimer: push 0CD9D38FDh call _WhisperMain _NtSetInformationDebugObject: push 018382487h call _WhisperMain _NtSetInformationEnlistment: push 00B6410F3h call _WhisperMain _NtSetInformationJobObject: push 01A25FA79h call _WhisperMain _NtSetInformationKey: push <KEY> call _WhisperMain _NtSetInformationResourceManager: push 031965B0Ah call _WhisperMain _NtSetInformationSymbolicLink: push 0FAA72212h call _WhisperMain _NtSetInformationToken: push <KEY> call _WhisperMain _NtSetInformationTransaction: push 028823A2Fh call _WhisperMain _NtSetInformationTransactionManager: push 0AB96218Bh call _WhisperMain _NtSetInformationVirtualMemory: push 01B911D1Fh call _WhisperMain _NtSetInformationWorkerFactory: push 08A2290B6h call _WhisperMain _NtSetIntervalProfile: push 02581DD85h call _WhisperMain _NtSetIoCompletion: push 002980237h call _WhisperMain _NtSetIoCompletionEx: push 08CAEC268h call _WhisperMain _NtSetLdtEntries: push 0FB53ECFBh call _WhisperMain _NtSetLowEventPair: push 016B1CAE3h call _WhisperMain _NtSetLowWaitHighEventPair: push 0F2D21640h call _WhisperMain _NtSetQuotaInformationFile: push 09706A793h call _WhisperMain _NtSetSecurityObject: push 016B85055h call _WhisperMain _NtSetSystemEnvironmentValue: push 0C457E39Ch call _WhisperMain _NtSetSystemEnvironmentValueEx: push 037CBF2B6h call _WhisperMain _NtSetSystemInformation: push 0036F07FDh call _WhisperMain _NtSetSystemPowerState: push 06C8F86C2h call _WhisperMain _NtSetSystemTime: push 08725CE82h call _WhisperMain _NtSetThreadExecutionState: push 0923D7C34h call _WhisperMain _NtSetTimer2: push 079929A43h call _WhisperMain _NtSetTimerEx: push 072E8ACBEh call _WhisperMain _NtSetTimerResolution: push 041146399h call _WhisperMain _NtSetUuidSeed: push 0D14ED7D4h call _WhisperMain _NtSetVolumeInformationFile: push 024B1D2A2h call _WhisperMain _NtSetWnfProcessNotificationEvent: push 0999D8030h call _WhisperMain _NtShutdownSystem: push 0D36EC9C1h call _WhisperMain _NtShutdownWorkerFactory: push 0151D1594h call _WhisperMain _NtSignalAndWaitForSingleObject: push 00AB43429h call _WhisperMain _NtSinglePhaseReject: push 0745E2285h call _WhisperMain _NtStartProfile: push 058942A5Ch call _WhisperMain _NtStopProfile: push 08F1B7843h call _WhisperMain _NtSubscribeWnfStateChange: push 036A72F3Ah call _WhisperMain _NtSuspendProcess: push 082C1834Fh call _WhisperMain _NtSuspendThread: push 07CDF2E69h call _WhisperMain _NtSystemDebugControl: push 0D78BF51Dh call _WhisperMain _NtTerminateEnclave: push 04A8B16B2h call _WhisperMain _NtTerminateJobObject: push 0188433DBh call _WhisperMain _NtTestAlert: push 066379875h call _WhisperMain _NtThawRegistry: push 032A03229h call _WhisperMain _NtThawTransactions: push 0F144D313h call _WhisperMain _NtTraceControl: push 00552E3C0h call _WhisperMain _NtTranslateFilePath: push 0873F6C6Bh call _WhisperMain _NtUmsThreadYield: push 03FA60EF3h call _WhisperMain _NtUnloadDriver: push 016B73BE8h call _WhisperMain _NtUnloadKey: push 01A2F63DDh call _WhisperMain _NtUnloadKey2: push 0C7350282h call _WhisperMain _NtUnloadKeyEx: push 099F2AF4Fh call _WhisperMain _NtUnlockFile: push 03298E3D2h call _WhisperMain _NtUnlockVirtualMemory: push 005966B01h call _WhisperMain _NtUnmapViewOfSectionEx: push 09B1D5659h call _WhisperMain _NtUnsubscribeWnfStateChange: push 082400D68h call _WhisperMain _NtUpdateWnfStateData: push 062B9740Eh call _WhisperMain _NtVdmControl: push 05DB24511h call _WhisperMain _NtWaitForAlertByThreadId: push 09AAE3A6Ah call _WhisperMain _NtWaitForDebugEvent: push 03E9BC0E9h call _WhisperMain _NtWaitForKeyedEvent: push 0EB0AEA9Fh call _WhisperMain _NtWaitForWorkViaWorkerFactory: push 0C091CA00h call _WhisperMain _NtWaitHighEventPair: push 0219FDE96h call _WhisperMain _NtWaitLowEventPair: push 0203804A9h call _WhisperMain _NtAcquireCMFViewOwnership: push 0DA4C1D1Ah call _WhisperMain _NtCancelDeviceWakeupRequest: push 073816522h call _WhisperMain _NtClearAllSavepointsTransaction: push 01A0E44C7h call _WhisperMain _NtClearSavepointTransaction: push 0DCB3D223h call _WhisperMain _NtRollbackSavepointTransaction: push 0144F351Ch call _WhisperMain _NtSavepointTransaction: push 04CD76C19h call _WhisperMain _NtSavepointComplete: push 0009AF898h call _WhisperMain _NtCreateSectionEx: push 080953FB3h call _WhisperMain _NtCreateCrossVmEvent: push 01B2074B2h call _WhisperMain _NtGetPlugPlayEvent: push 00E088D1Eh call _WhisperMain _NtListTransactions: push 0B8299EB8h call _WhisperMain _NtMarshallTransaction: push 032A62A0Dh call _WhisperMain _NtPullTransaction: push 0040B2499h call _WhisperMain _NtReleaseCMFViewOwnership: push 034AD2036h call _WhisperMain _NtWaitForWnfNotifications: push 05B896703h call _WhisperMain _NtStartTm: push 0D19DFE2Dh call _WhisperMain _NtSetInformationProcess: push 096288E47h call _WhisperMain _NtRequestDeviceWakeup: push 02EA1223Ch call _WhisperMain _NtRequestWakeupLatency: push 0904BB1E6h call _WhisperMain _NtQuerySystemTime: push 0B6AEC6BBh call _WhisperMain _NtManageHotPatch: push 068A5287Eh call _WhisperMain _NtContinueEx: push 0D34D0411h call _WhisperMain _RtlCreateUserThread: push 0B4AF2B95h call _WhisperMain
examples/floats.adb
ytomino/drake
33
29017
-- Demonstration of the extended units: Ada.Fixed with Ada.Float; procedure floats is subtype T is Long_Long_Float; begin declare -- Infinity and Is_Infinity function Infinity is new Ada.Float.Infinity (T); function Is_Infinity is new Ada.Float.Is_Infinity (T); begin pragma Assert (T'Image (Infinity) = " INF"); pragma Assert (T'Image (-Infinity) = "-INF"); pragma Assert (Is_Infinity (Infinity)); null; end; declare -- NaN and Is_NaN function NaN is new Ada.Float.NaN (T); function Is_NaN is new Ada.Float.Is_NaN (T); begin pragma Assert (T'Image (NaN) = " NAN"); pragma Assert (T'Image (-NaN) = "-NAN"); pragma Assert (not (-NaN < 0.0)); -- comparison of NaN is always False pragma Assert (Is_NaN (NaN)); null; end; declare -- Is_Negative function Is_Negative is new Ada.Float.Is_Negative (T); begin pragma Assert (Is_Negative (-1.0)); pragma Assert (not Is_Negative (0.0)); pragma Assert (not Is_Negative (+1.0)); null; end; declare -- Divide procedure Divide is new Ada.Float.Divide (T, T, T, T); Q, R : T; begin Divide (4.5, 2.0, Q, R); pragma Assert (Q = 2.0 and then R = 0.5); Divide (5.0, 0.5, Q, R); pragma Assert (Q = 10.0 and then R = 0.0); Divide (0.9, 1.0, Q, R); pragma Assert (Q = 0.0 and then R = 0.9); Divide (-0.9, 1.0, Q, R); pragma Assert (Q = 0.0 and then R = -0.9); end; pragma Debug (Ada.Debug.Put ("OK")); end floats;
urule-core/dsl/RuleParser.g4
houshanren/urule
0
2437
grammar RuleParser; import RuleLexer; ruleSet : ruleSetHeader ruleSetBody ; ruleSetHeader : resource* | functionImport* | resource* functionImport* | functionImport* resource* ; ruleSetBody : rules* ; rules : ruleDef | loopRuleDef ; functionImport : 'import' packageDef';'?; packageDef : Identifier | Identifier('.'Identifier)+ | packageDef'.*'; resource : importVariableLibrary | importActionLibrary | importConstantLibrary | importParameterLibrary ; importParameterLibrary : 'importParameterLibrary' STRING ';'?; importVariableLibrary : 'importVariableLibrary' STRING ';'?; importConstantLibrary : 'importConstantLibrary' STRING ';'?; importActionLibrary : 'importActionLibrary' STRING ';'?; functionDef : 'function' Identifier '(' functionParameters? ')' '{' expressionBody '}'';'?; functionParameters : functionParameter (','functionParameter)* ; functionParameter : Datatype Identifier ; ruleDef : ('rule'|'\u89c4\u5219') STRING attribute* left right other? ('end'|'\u7ed3\u675f') ';'? ; loopRuleDef : ('loopRule' | '\u5faa\u73af\u89c4\u5219') STRING attribute* loopTarget loopStart? left right other? loopEnd? ('end'|'\u7ed3\u675f') ';'? ; loopTarget : ('loopTarget' | '\u5faa\u73af\u5bf9\u8c61') complexValue ; loopStart : ('loopStart' | '\u5f00\u59cb\u524d\u52a8\u4f5c') action* ; loopEnd : ('loopEnd' | '\u7ed3\u675f\u540e\u52a8\u4f5c') action*; attribute :loopAttribute | salienceAttribute | effectiveDateAttribute | expiresDateAttribute | enabledAttribute | debugAttribute | activationGroupAttribute | agendaGroupAttribute | autoFocusAttribute | ruleflowGroupAttribute ; loopAttribute : ('loop' | '\u5141\u8bb8\u5faa\u73af\u89e6\u53d1') '=' Boolean ','?; salienceAttribute : ('salience' | '\u4f18\u5148\u7ea7') '=' NUMBER ','?; effectiveDateAttribute : ('effective-date' | '\u751f\u6548\u65f6\u95f4' | '\u751f\u6548\u65e5\u671f') '=' STRING ','?; expiresDateAttribute : ('expires-date' | '\u5931\u6548\u65f6\u95f4' | '\u5931\u6548\u65e5\u671f') '=' STRING ','?; enabledAttribute : ('enabled' | '\u6fc0\u6d3b' | '\u542f\u7528') '=' Boolean ','?; debugAttribute : ('debug' | '\u8c03\u8bd5' | '\u5141\u8bb8\u8c03\u8bd5') '=' Boolean ','?; activationGroupAttribute : ('activation-group' | '\u6fc0\u6d3b\u7ec4') '=' STRING ','? ; agendaGroupAttribute : ('agenda-group' | '\u8bae\u7a0b\u7ec4') '=' STRING ','? ; autoFocusAttribute : ('auto-focus' | '\u81ea\u52a8\u83b7\u53d6\u7126\u70b9') '=' Boolean ','?; ruleflowGroupAttribute : ('ruleflow-group' | '\u89c4\u5219\u6d41\u7ec4') '=' STRING ','?; left : ('if'|'\u5982\u679c') condition? ; condition : leftParen condition rightParen #parenConditions | condition (join condition)+ #multiConditions | conditionLeft op (complexValue|nullValue) #singleCondition | namedConditionSet #singleNamedConditionSet ; namedConditionSet : (refName colon)? refObject leftParen namedCondition rightParen; namedCondition : leftParen namedCondition rightParen #parenNamedConditions | namedCondition (join namedCondition)+ #multiNamedConditions | property op (complexValue|nullValue) #singleNamedConditions ; decisionTableCellCondition : op (complexValue|nullValue) #singleCellCondition | decisionTableCellCondition (join decisionTableCellCondition)+ #multiCellConditions | leftParen decisionTableCellCondition rightParen #parenCellConditions ; refName : Identifier ; refObject : variableCategory | parameterName ; nullValue : 'null'; conditionLeft : (variable|parameter|functionInvoke|methodInvoke|expEval|expAll|expExists|expCollect|commonFunction) (ARITH value)* ; expEval : 'eval'leftParen expressionBody rightParen; expAll : 'all'leftParen (variable|parameter) ',' exprCondition (',' (NUMBER|percent))? rightParen; expExists : 'exist'leftParen (variable|parameter) ',' exprCondition (',' (NUMBER|percent))? rightParen; expCollect : 'collect'leftParen (variable|parameter) (',' exprCondition)? rightParen '.' ( COUNT | property'.'(SUM|AVG|MAX|MIN)) ; commonFunction : Identifier leftParen complexValue(','property)? rightParen ; exprCondition : property op (complexValue|nullValue) | exprCondition (join exprCondition)+ ; expressionBody : .*? ; percent : NUMBER'%'; leftParen : '('; rightParen : ')'; colon : ':'; join : AND | OR ; right : ('then'|'\u90a3\u4e48') action* ; other : ('else'|'\u5426\u5219') action* ; actions : action*; action : assignAction ';'? | outAction ';'? | methodInvoke ';'? | functionInvoke ';'? | commonFunction ';'? ; assignAction : (variable|namedVariable|parameter) '=' complexValue; outAction : 'out''(' complexValue ')'; methodInvoke : beanMethod'('actionParameters?')'; functionInvoke : '@'Identifier'(' actionParameters? ')'; actionParameters : complexValue (',' complexValue)* ; beanMethod : Identifier'.'Identifier ; complexValue : value | variable | namedVariable | constant | variableCategory | parameter | methodInvoke | functionInvoke | commonFunction | leftParen complexValue rightParen | complexValue (ARITH complexValue)+ ; parameter : parameterName'.'Identifier; parameterName : 'parameter'|'\u53c2\u6570' ; constant : constantCategory'.'property; variable : variableCategory'.'property; namedVariable : namedVariableCategory'.'property; property : Identifier('.'Identifier)*; variableCategory : Identifier; namedVariableCategory : '!'Identifier; constantCategory : '$'Identifier; value : STRING | NUMBER | Boolean ; op : GreaterThen | GreaterThenOrEquals | LessThen | LessThenOrEquals | Equals | NotEquals | EndWith | NotEndWith | StartWith | NotStartWith | In | NotIn | Match | NotMatch | EqualsIgnoreCase | NotEqualsIgnoreCase ;
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_21829_1692.asm
ljhsiun2/medusa
9
165356
.global s_prepare_buffers s_prepare_buffers: push %r13 push %rcx push %rdi push %rsi lea addresses_D_ht+0x127a4, %rsi lea addresses_A_ht+0x6764, %rdi clflush (%rdi) nop add %r13, %r13 mov $23, %rcx rep movsb nop nop nop nop nop inc %r13 pop %rsi pop %rdi pop %rcx pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r14 push %r15 push %rax push %rsi // Store lea addresses_WC+0xf042, %r11 nop nop nop nop cmp %r12, %r12 movb $0x51, (%r11) nop nop nop nop xor $61712, %rax // Faulty Load lea addresses_D+0x1afa4, %r11 nop nop nop nop sub $19695, %r10 movb (%r11), %al lea oracles, %r11 and $0xff, %rax shlq $12, %rax mov (%r11,%rax,1), %rax pop %rsi pop %rax pop %r15 pop %r14 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
libsrc/_DEVELOPMENT/stdio/c/sccz80/putchar.asm
meesokim/z88dk
0
20378
<reponame>meesokim/z88dk ; int putchar(int c) INCLUDE "clib_cfg.asm" SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC putchar EXTERN asm_putchar defc putchar = asm_putchar ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC putchar EXTERN putchar_unlocked defc putchar = putchar_unlocked ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
oeis/116/A116487.asm
neoneye/loda-programs
11
103352
<gh_stars>10-100 ; A116487: First digit after decimal point in decimal representation of (1+1/n)^n. ; Submitted by <NAME> ; 0,2,3,4,4,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 add $0,1 mov $1,1 add $1,$0 pow $1,$0 pow $0,$0 mul $1,10 div $1,$0 mov $0,$1 sub $0,20
Task/Hailstone-sequence/Ada/hailstone-sequence-1.ada
LaudateCorpus1/RosettaCodeData
1
10130
with Ada.Text_IO; use Ada.Text_IO; procedure hailstone is type int_arr is array(Positive range <>) of Integer; type int_arr_pt is access all int_arr; function hailstones(num:Integer; pt:int_arr_pt) return Integer is stones : Integer := 1; n : Integer := num; begin if pt /= null then pt(1) := num; end if; while (n/=1) loop stones := stones + 1; if n mod 2 = 0 then n := n/2; else n := (3*n)+1; end if; if pt /= null then pt(stones) := n; end if; end loop; return stones; end hailstones; nmax,stonemax,stones : Integer := 0; list : int_arr_pt; begin stones := hailstones(27,null); list := new int_arr(1..stones); stones := hailstones(27,list); put(" 27: "&Integer'Image(stones)); new_line; for n in 1..4 loop put(Integer'Image(list(n))); end loop; put(" .... "); for n in stones-3..stones loop put(Integer'Image(list(n))); end loop; new_line; for n in 1..100000 loop stones := hailstones(n,null); if stones>stonemax then nmax := n; stonemax := stones; end if; end loop; put_line(Integer'Image(nmax)&" max @ n= "&Integer'Image(stonemax)); end hailstone;
kv-avm-instructions.ads
davidkristola/vole
4
24078
<reponame>davidkristola/vole<filename>kv-avm-instructions.ads with Interfaces; with kv.avm.references; use kv.avm.references; package kv.avm.Instructions is pragma preelaborate; Invalid_Compute_Operation : exception; type operation_type is (Add, Sub, Mul, Div, Modulo, Exp, Eq, Neq, L_t, Lte, G_t, Gte, Shift_Left, Shift_Right, B_And, B_Or, B_Xor, Negate, Op_Pos, Op_Neg); for operation_type'SIZE use 5; subtype Binary_Op_Type is Operation_Type range Add .. B_Xor; subtype Unary_Op_Type is Operation_Type range Negate .. Op_Neg; subtype Compare_Type is Operation_Type range Eq .. Gte; type op_code_type is (terminate_program, halt_actor, stop_frame, no_op, -- format 0 emit, assert, reply, jump, -- format 1 jump_abs, jump_rel, -- format 1b set, fold, -- format 2 branch_abs, branch_rel, branch_neq, -- format 2b peek, trap, new_actor, -- format 3 peek_immediate, -- format 3b compute, -- format 4 Actor_Call, -- format 5a1 reply := args=>actor.message Actor_Send, Actor_Tail_Send, Actor_Tail_Call, -- format 5a2 args=>actor.message (no reply to me) Self_Call, Super_Call, -- format 5b1 reply := args=>message Self_Send, Self_Tail_Send, Self_Tail_Call, Super_Tail_Call); -- format 5b2 args=>message for op_code_type'SIZE use 6; subtype format_0_type is op_code_type range terminate_program .. no_op; subtype format_1_type is op_code_type range emit .. jump; subtype format_1b_type is op_code_type range jump_abs .. jump_rel; subtype format_2_type is op_code_type range set .. fold; subtype format_2b_type is op_code_type range branch_abs .. branch_neq; subtype format_3_type is op_code_type range peek .. new_actor; subtype format_3b_type is op_code_type range peek_immediate .. peek_immediate; subtype format_4_type is op_code_type range compute .. compute; subtype format_5a1_type is op_code_type range Actor_Call .. Actor_Call; subtype format_5a2_type is op_code_type range Actor_Send .. Actor_Tail_Call; subtype format_5b1_type is op_code_type range Self_Call .. Super_Call; subtype format_5b2_type is op_code_type range Self_Send .. Super_Tail_Call; type Instruction_Type(op_code : op_code_type := no_op) is record case op_code is when format_0_type => null; when format_1_type => value : reference_type; when format_1b_type => jump : Interfaces.Unsigned_32; when format_2_type => lhs : reference_type; rhs : reference_type; when format_2b_type => condition : reference_type; target : Interfaces.Unsigned_32; when format_3_type => a : reference_type; x : reference_type; y : reference_type; when format_3b_type => lvalue : reference_type; tuple : reference_type; index : offset_type; when format_4_type => action : operation_type; result : reference_type; left : reference_type; right : reference_type; when format_5a1_type => rply_5a1 : reference_type; args_5a1 : reference_type; actr_5a1 : reference_type; mdef_5a1 : reference_type; when format_5a2_type => args_5a2 : reference_type; actr_5a2 : reference_type; mdef_5a2 : reference_type; when format_5b1_type => rply_5b1 : reference_type; mdef_5b1 : reference_type; args_5b1 : reference_type; when format_5b2_type => mdef_5b2 : reference_type; args_5b2 : reference_type; when others => null; end case; end record; for Instruction_Type use record op_code at 0 range 0 .. 5; value at 2 range 0 .. 15; lhs at 4 range 0 .. 15; rhs at 6 range 0 .. 15; jump at 4 range 0 .. 31; condition at 2 range 0 .. 15; target at 4 range 0 .. 31; a at 2 range 0 .. 15; x at 4 range 0 .. 15; y at 6 range 0 .. 15; lvalue at 2 range 0 .. 15; tuple at 4 range 0 .. 15; index at 6 range 0 .. 15; action at 0 range 6 .. 11; result at 2 range 0 .. 15; left at 4 range 0 .. 15; right at 6 range 0 .. 15; rply_5a1 at 2 range 00 .. 11; args_5a1 at 2 range 12 .. 23; actr_5a1 at 2 range 24 .. 35; mdef_5a1 at 2 range 36 .. 47; args_5a2 at 2 range 0 .. 15; actr_5a2 at 4 range 0 .. 15; mdef_5a2 at 6 range 0 .. 15; rply_5b1 at 2 range 0 .. 15; mdef_5b1 at 4 range 0 .. 15; args_5b1 at 6 range 0 .. 15; mdef_5b2 at 4 range 0 .. 15; args_5b2 at 6 range 0 .. 15; end record; for Instruction_Type'SIZE use 64; function Encode_Operation(Op : Operation_Type) return String; function Decode_Operation(Op_Img : String) return Operation_Type; type Code_Type is array (Interfaces.Unsigned_32 range <>) of Instruction_Type; type Code_Access is access all Code_Type; end kv.avm.Instructions;
solutions/44 - Unique Fashion Party/size-42_speed-43.asm
michaelgundlach/7billionhumans
45
83325
<reponame>michaelgundlach/7billionhumans -- 7 Billion Humans (2087) -- -- 44: Unique Fashion Party -- -- Author: landfillbaby -- Size: 42 -- Speed: 43 -- Speed Tests: 42, 43, 43, 43, 43, 43, 43, 43, 42, 43 pickup s step s step s step s step s step s step s step s step s step s step e step e step e a: step e if se != hole: jump a endif step e if myitem == 6: jump b endif if myitem == 5: jump c endif if myitem == 4: jump d endif if myitem == 3: jump e endif if myitem == 2: jump f endif if myitem == 1: jump g endif jump h b: step e c: step e d: step e e: step e f: step e g: step e h: step n step n i: if s == worker: j: step n jump j endif jump i
oeis/033/A033192.asm
neoneye/loda-programs
11
241212
<gh_stars>10-100 ; A033192: a(n) = binomial(Fibonacci(n) + 1, 2). ; Submitted by <NAME> ; 0,1,1,3,6,15,36,91,231,595,1540,4005,10440,27261,71253,186355,487578,1276003,3339820,8742471,22885995,59912931,156848616,410626153,1075018896,2814412825,7368190921,19290113571,50502074766,132215989335,346145696820,906220783315,2372516138895,6211326801331,16261462918828,42573059776845,111457712887128,291800073181653,763942497430365,2000027404179091,5236139690949090,13708391629580011,35889035134544956,93958713671720703,245987105715037011,644002603205476035,1686020703467896656,4414059506496805201 seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. mov $1,$0 add $1,1 mul $0,$1 div $0,2
programs/oeis/332/A332687.asm
neoneye/loda
22
98575
<reponame>neoneye/loda<gh_stars>10-100 ; A332687: a(n) = Sum_{k=1..n} ceiling(n/prime(k)). ; 1,2,4,6,8,10,13,15,17,19,22,24,27,29,32,35,37,39,42,44,47,50,53,55,58,60,63,65,68,70,74,76,78,81,84,87,90,92,95,98,101,103,107,109,112,115,118,120,123,125,128,131,134,136,139,142,145,148,151,153 sub $0,1 mov $1,$0 max $1,0 seq $1,82186 ; 1 + sum of first n terms of A001221. add $0,$1 add $0,1
src/kernel/kernel.asm
Dudejoe870/FunOS
2
160080
[bits 32] global syscall_test syscall_test: mov eax, 0 int 0x80 ret
source/torrent-connections.adb
reznikmm/torrent
4
435
-- Copyright (c) 2019-2020 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Exceptions; with Ada.Unchecked_Conversion; with Interfaces; with GNAT.SHA1; with Torrent.Downloaders; with Torrent.Handshakes; use Torrent.Handshakes; with Torrent.Logs; package body Torrent.Connections is use type Ada.Streams.Stream_Element; use type Ada.Streams.Stream_Element_Array; use type Ada.Streams.Stream_Element_Offset; subtype Int_Buffer is Ada.Streams.Stream_Element_Array (1 .. 4); function To_Int (Value : Natural) return Int_Buffer; Expire_Loops : constant := 3; -- Protection from lost of requests function Get_Handshake (Self : Connection'Class) return Handshake_Image; function Get_Int (Data : Ada.Streams.Stream_Element_Array; From : Ada.Streams.Stream_Element_Count := 0) return Natural; function Is_Valid_Piece (Self : Connection'Class; Piece : Piece_Index) return Boolean; procedure Send_Message (Self : in out Connection'Class; Data : Ada.Streams.Stream_Element_Array); procedure Send_Have (Self : in out Connection'Class; Piece : Piece_Index); procedure Send_Bitfield (Self : in out Connection'Class; Completed : Piece_Index_Array); procedure Send_Pieces (Self : in out Connection'Class; Limit : Ada.Calendar.Time); procedure Unreserve_Intervals (Self : in out Connection'Class); procedure Close_Connection (Self : in out Connection'Class); ---------------------- -- Close_Connection -- ---------------------- procedure Close_Connection (Self : in out Connection'Class) is begin GNAT.Sockets.Close_Socket (Self.Socket); Self.Closed := True; Self.Unreserve_Intervals; end Close_Connection; --------------- -- Connected -- --------------- function Connected (Self : Connection'Class) return Boolean is begin return not Self.Closed; end Connected; ------------------ -- Do_Handshake -- ------------------ procedure Do_Handshake (Self : in out Connection'Class; Socket : GNAT.Sockets.Socket_Type; Completed : Piece_Index_Array; Inbound : Boolean) is Last : Ada.Streams.Stream_Element_Count; begin Self.Socket := Socket; GNAT.Sockets.Send_Socket (Socket => Self.Socket, Item => Self.Get_Handshake, Last => Last); pragma Assert (Last = Handshake_Image'Last); GNAT.Sockets.Set_Socket_Option (Socket => Self.Socket, Level => GNAT.Sockets.Socket_Level, Option => (GNAT.Sockets.Receive_Timeout, 0.0)); Self.Initialize (Self.My_Peer_Id, Self.Peer, Self.Listener); Self.Sent_Handshake := True; Self.Got_Handshake := Inbound; Self.Send_Bitfield (Completed); Self.Last_Completed := Completed'Last; exception when E : others => pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Raised on Do_Handshake:" & GNAT.Sockets.Image (Self.Peer))); pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (Ada.Exceptions.Exception_Information (E))); Self.Close_Connection; return; end Do_Handshake; ---------------- -- Downloaded -- ---------------- function Downloaded (Self : in out Connection'Class) return Piece_Offset is begin return Result : constant Piece_Offset := Self.Downloaded do Self.Downloaded := Self.Downloaded / 3; end return; end Downloaded; ------------------- -- Get_Handshake -- ------------------- function Get_Handshake (Self : Connection'Class) return Handshake_Image is Result : Handshake_Type; begin Result.Info_Hash := Self.Meta.Info_Hash; Result.Peer_Id := Self.My_Peer_Id; return +Result; end Get_Handshake; ------------- -- Get_Int -- ------------- function Get_Int (Data : Ada.Streams.Stream_Element_Array; From : Ada.Streams.Stream_Element_Count := 0) return Natural is subtype X is Natural; begin return ((X (Data (Data'First + From)) * 256 + X (Data (Data'First + From + 1))) * 256 + X (Data (Data'First + From + 2))) * 256 + X (Data (Data'First + From + 3)); end Get_Int; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Connection'Class; My_Id : SHA1; Peer : GNAT.Sockets.Sock_Addr_Type; Listener : Connection_State_Listener_Access) is begin Self.Peer := Peer; Self.Sent_Handshake := False; Self.Got_Handshake := False; Self.Closed := False; Self.We_Choked := True; Self.He_Choked := True; Self.Choked_Sent := True; Self.We_Intrested := False; Self.He_Intrested := False; Self.My_Peer_Id := My_Id; Self.Last_Request := 0; Self.Last_Completed := 0; Self.Listener := Listener; Self.Downloaded := 0; Self.Current_Piece := (0, Intervals => <>); Self.Piece_Map := (others => False); end Initialize; ------------ -- Insert -- ------------ procedure Insert (List : in out Interval_Vectors.Vector; Value : Interval) is M, N : Natural := 0; Next : Interval := Value; begin if (for some X of List => X.From <= Next.From and X.To >= Next.To) then return; end if; loop M := 0; N := 0; for J in 1 .. List.Last_Index loop if List (J).To + 1 = Next.From then M := J; exit; elsif Next.To + 1 = List (J).From then N := J; exit; end if; end loop; if M > 0 then Next := (List (M).From, Next.To); List.Swap (M, List.Last_Index); List.Delete_Last; elsif N > 0 then Next := (Next.From, List (N).To); List.Swap (N, List.Last_Index); List.Delete_Last; else List.Append (Next); exit; end if; end loop; end Insert; --------------- -- Intrested -- --------------- function Intrested (Self : Connection'Class) return Boolean is begin return not Self.Closed and Self.He_Intrested; end Intrested; -------------------- -- Is_Valid_Piece -- -------------------- function Is_Valid_Piece (Self : Connection'Class; Piece : Piece_Index) return Boolean is begin return Is_Valid_Piece (Self.Meta, Self.Storage.all, Piece); end Is_Valid_Piece; -------------------- -- Is_Valid_Piece -- -------------------- function Is_Valid_Piece (Meta : not null Torrent.Metainfo_Files.Metainfo_File_Access; Storage : in out Torrent.Storages.Storage; Piece : Piece_Index) return Boolean is Context : GNAT.SHA1.Context; From : Ada.Streams.Stream_Element_Offset := Piece_Offset (Piece - 1) * Meta.Piece_Length; Left : Ada.Streams.Stream_Element_Offset; Data : Ada.Streams.Stream_Element_Array (1 .. Max_Interval_Size); Value : SHA1; begin Storage.Start_Reading; -- Block storage if Piece = Meta.Piece_Count then Left := Meta.Last_Piece_Length; else Left := Meta.Piece_Length; end if; while Left > Data'Length loop Storage.Read (From, Data); From := From + Data'Length; Left := Left - Data'Length; GNAT.SHA1.Update (Context, Data); end loop; if Left > 0 then Storage.Read (From, Data (1 .. Left)); GNAT.SHA1.Update (Context, Data (1 .. Left)); end if; Value := GNAT.SHA1.Digest (Context); Storage.Stop_Reading; -- Unblock storage return Meta.Piece_SHA1 (Piece) = Value; end Is_Valid_Piece; ---------- -- Peer -- ---------- function Peer (Self : Connection'Class) return GNAT.Sockets.Sock_Addr_Type is begin return Self.Peer; end Peer; ------------------- -- Send_Bitfield -- ------------------- procedure Send_Bitfield (Self : in out Connection'Class; Completed : Piece_Index_Array) is Length : constant Piece_Offset := Piece_Offset (Self.Piece_Count + 7) / 8; Data : Ada.Streams.Stream_Element_Array (0 .. Length - 1) := (others => 0); -- Zero based Mask : Interfaces.Unsigned_8; begin for X of Completed loop Mask := Interfaces.Shift_Right (128, Natural ((X - 1) mod 8)); Data (Piece_Offset (X - 1) / 8) := Data (Piece_Offset (X - 1) / 8) or Ada.Streams.Stream_Element (Mask); end loop; Self.Send_Message (To_Int (Positive (Length) + 1) & 05 & Data); end Send_Bitfield; --------------- -- Send_Have -- --------------- procedure Send_Have (Self : in out Connection'Class; Piece : Piece_Index) is begin Self.Send_Message ((00, 00, 00, 05, 04) & -- have To_Int (Natural (Piece - 1))); end Send_Have; ------------------ -- Send_Message -- ------------------ procedure Send_Message (Self : in out Connection'Class; Data : Ada.Streams.Stream_Element_Array) is Last : Ada.Streams.Stream_Element_Offset; begin if Self.Closed then return; end if; GNAT.Sockets.Send_Socket (Socket => Self.Socket, Item => Data, Last => Last); pragma Assert (Last = Data'Last); if Data'Length <= 4 then pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Send keepalive " & GNAT.Sockets.Image (Self.Peer))); elsif Data (Data'First + 4) = 6 then pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Send request " & GNAT.Sockets.Image (Self.Peer) & Integer'Image (Get_Int (Data, 5) + 1) & Integer'Image (Get_Int (Data, 9)) & Integer'Image (Get_Int (Data, 13)))); else pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Send " & GNAT.Sockets.Image (Self.Peer) & (Data (Data'First + 4)'Img))); end if; exception when E : GNAT.Sockets.Socket_Error => if GNAT.Sockets.Resolve_Exception (E) in GNAT.Sockets.Resource_Temporarily_Unavailable then GNAT.Sockets.Set_Socket_Option (Socket => Self.Socket, Level => GNAT.Sockets.Socket_Level, Option => (GNAT.Sockets.Receive_Timeout, GNAT.Sockets.Forever)); Self.Send_Message (Data); return; end if; pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Send_Message:" & GNAT.Sockets.Image (Self.Peer))); pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (Ada.Exceptions.Exception_Information (E))); Self.Close_Connection; end Send_Message; ----------------- -- Send_Pieces -- ----------------- procedure Send_Pieces (Self : in out Connection'Class; Limit : Ada.Calendar.Time) is use type Ada.Calendar.Time; Total_Sent : Ada.Streams.Stream_Element_Count := 0; begin -- FIXME check if unchoked while not Self.Requests.Is_Empty loop declare Last : Ada.Streams.Stream_Element_Count; Item : constant Piece_Interval := Self.Requests.Last_Element; Data : Ada.Streams.Stream_Element_Array (Item.Span.From - 4 - 1 - 4 - 4 .. Item.Span.To); begin Self.Storage.Start_Reading; Self.Storage.Read (Offset => Ada.Streams.Stream_Element_Count (Item.Piece - 1) * Self.Meta.Piece_Length + Ada.Streams.Stream_Element_Count (Item.Span.From), Data => Data (Item.Span.From .. Item.Span.To)); Self.Storage.Stop_Reading; Data (Data'First .. Data'First + 3) := -- Message length To_Int (Data'Length - 4); Data (Data'First + 4) := 7; -- piece Data (Data'First + 5 .. Data'First + 8) := To_Int (Positive (Item.Piece) - 1); Data (Data'First + 9 .. Data'First + 12) := To_Int (Natural (Item.Span.From)); exit when Self.Closed; GNAT.Sockets.Set_Socket_Option (Socket => Self.Socket, Level => GNAT.Sockets.Socket_Level, Option => (GNAT.Sockets.Receive_Timeout, Limit - Ada.Calendar.Clock)); GNAT.Sockets.Send_Socket (Socket => Self.Socket, Item => Data, Last => Last); pragma Assert (Last = Data'Last); Total_Sent := Total_Sent + Data'Length; pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Send piece " & GNAT.Sockets.Image (Self.Peer) & Piece_Count'Image (Item.Piece) & Piece_Offset'Image (Item.Span.From))); Self.Requests.Delete_Last; -- FIXME Increment send statistic. end; end loop; Self.Listener.Interval_Sent (Total_Sent); exception when E : GNAT.Sockets.Socket_Error => Self.Listener.Interval_Sent (Total_Sent); if GNAT.Sockets.Resolve_Exception (E) in GNAT.Sockets.Resource_Temporarily_Unavailable then return; end if; pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Send_Pieces:" & GNAT.Sockets.Image (Self.Peer))); pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (Ada.Exceptions.Exception_Information (E))); Self.Close_Connection; end Send_Pieces; ----------- -- Serve -- ----------- procedure Serve (Self : in out Connection'Class; Limit : Ada.Calendar.Time) is use type Ada.Calendar.Time; procedure Check_Intrested; procedure Send_Initial_Requests; function Get_Handshake (Data : Ada.Streams.Stream_Element_Array) return Boolean; function Get_Length (Data : Ada.Streams.Stream_Element_Array) return Ada.Streams.Stream_Element_Offset; procedure Read_Messages (Data : in out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Count); procedure On_Message (Data : Ada.Streams.Stream_Element_Array); procedure Save_Piece (Index : Piece_Index; Offset : Natural; Data : Ada.Streams.Stream_Element_Array); --------------------- -- Check_Intrested -- --------------------- procedure Check_Intrested is begin if not Self.We_Intrested and then Self.Listener.We_Are_Intrested (Self.Piece_Map) then Self.Send_Message ((00, 00, 00, 01, 02)); -- interested Self.We_Intrested := True; end if; end Check_Intrested; ------------------- -- Get_Handshake -- ------------------- function Get_Handshake (Data : Ada.Streams.Stream_Element_Array) return Boolean is function "+" is new Ada.Unchecked_Conversion (Handshake_Image, Handshake_Type); HS : constant Handshake_Type := +Data (1 .. Handshake_Image'Length); begin if HS.Length = Header'Length and then HS.Head = Header and then HS.Info_Hash = Self.Meta.Info_Hash then Self.Got_Handshake := True; Self.Unparsed.Clear; Self.Unparsed.Append (Data (Handshake_Image'Length + 1 .. Data'Last)); return True; else return False; end if; end Get_Handshake; ---------------- -- Get_Length -- ---------------- function Get_Length (Data : Ada.Streams.Stream_Element_Array) return Ada.Streams.Stream_Element_Offset is subtype X is Ada.Streams.Stream_Element_Offset; begin return ((X (Data (Data'First)) * 256 + X (Data (Data'First + 1))) * 256 + X (Data (Data'First + 2))) * 256 + X (Data (Data'First + 3)); end Get_Length; ---------------- -- On_Message -- ---------------- procedure On_Message (Data : Ada.Streams.Stream_Element_Array) is function Get_Int (From : Ada.Streams.Stream_Element_Count := 0) return Natural is (Get_Int (Data, From)); Index : Piece_Index; begin case Data (Data'First) is when 0 => -- choke pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " choke")); Self.We_Choked := True; Self.Unreserve_Intervals; when 1 => -- unchoke pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " unchoke")); Self.We_Choked := False; Send_Initial_Requests; when 2 => -- interested pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " interested")); Self.He_Intrested := True; when 3 => -- not interested pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " not interested")); Self.He_Intrested := False; when 4 => -- have declare Index : constant Piece_Index := Piece_Index (Get_Int (1) + 1); begin if Index in Self.Piece_Map'Range then pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " have" & (Index'Img))); Self.Piece_Map (Index) := True; Check_Intrested; end if; end; when 5 => -- bitfield pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " bitfield")); Index := 1; Each_Byte : for X of Data (Data'First + 1 .. Data'Last) loop declare use type Interfaces.Unsigned_8; Byte : Interfaces.Unsigned_8 := Interfaces.Unsigned_8 (X); begin for J in 1 .. 8 loop if (Byte and 16#80#) /= 0 then Self.Piece_Map (Index) := True; end if; Byte := Interfaces.Shift_Left (Byte, 1); Index := Index + 1; exit Each_Byte when Index > Self.Piece_Count; end loop; end; end loop Each_Byte; Check_Intrested; when 6 => -- request declare Next : Piece_Interval := (Piece => Piece_Count (Get_Int (1) + 1), Span => (From => Piece_Offset (Get_Int (5)), To => Piece_Offset (Get_Int (9)))); begin pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " request" & (Next.Piece'Img) & (Next.Span.From'Img))); if Next.Span.To > Max_Interval_Size then return; else Next.Span.To := Next.Span.From + Next.Span.To - 1; end if; if Next.Piece in Self.Piece_Map'Range and then not Self.He_Choked then Self.Requests.Append (Next); end if; end; when 7 => -- piece declare Index : constant Piece_Index := Piece_Index (Get_Int (1) + 1); Offset : constant Natural := Get_Int (5); begin pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " piece" & (Index'Img) & (Offset'Img))); if Index in Self.Piece_Map'Range and then Data'Length > 9 then Save_Piece (Index, Offset, Data (Data'First + 9 .. Data'Last)); end if; end; when 8 => -- cancel declare Next : Piece_Interval := (Piece => Piece_Count (Get_Int (1) + 1), Span => (From => Piece_Offset (Get_Int (5)), To => Piece_Offset (Get_Int (9)))); Cursor : Natural; begin pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " cancel" & (Next.Piece'Img) & (Next.Span.From'Img))); Next.Span.To := Next.Span.From + Next.Span.To - 1; Cursor := Self.Requests.Find_Index (Next); if Cursor /= 0 then Self.Requests.Swap (Cursor, Self.Requests.Last_Index); Self.Requests.Delete_Last; end if; end; when others => pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (GNAT.Sockets.Image (Self.Peer) & " unkown" & (Data (Data'First)'Img))); end case; end On_Message; ------------------- -- Read_Messages -- ------------------- procedure Read_Messages (Data : in out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Count) is From : Ada.Streams.Stream_Element_Count := Data'First; Length : Ada.Streams.Stream_Element_Count; begin loop exit when Data'Length - From + 1 < 4; Length := Get_Length (Data (From .. Data'Last)); exit when Data'Length - From + 1 < 4 + Length; From := From + 4; if Length > 0 then On_Message (Data (From .. From + Length - 1)); From := From + Length; else Self.Send_Message ((00, 00, 00, 00)); -- keepalive end if; end loop; if From > Data'First then Last := Data'Length - From + 1; Data (1 .. Last) := Data (From .. Data'Last); else Last := Data'Last; end if; end Read_Messages; ---------------- -- Save_Piece -- ---------------- procedure Save_Piece (Index : Piece_Index; Offset : Natural; Data : Ada.Streams.Stream_Element_Array) is procedure Swap (Left, Right : Piece_Interval_Count); ---------- -- Swap -- ---------- procedure Swap (Left, Right : Piece_Interval_Count) is Request : constant Piece_Interval := Self.Pipelined.Request.List (Left); Expire : constant Natural := Self.Pipelined.Expire (Left); begin Self.Pipelined.Request.List (Left) := Self.Pipelined.Request.List (Right); Self.Pipelined.Request.List (Right) := Request; Self.Pipelined.Expire (Left) := Self.Pipelined.Expire (Right); Self.Pipelined.Expire (Right) := Expire; end Swap; Last : Boolean; From : constant Piece_Offset := Piece_Offset (Offset); J : Natural := 1; begin Self.Downloaded := Self.Downloaded + Data'Length; Self.Storage.Write (Offset => Ada.Streams.Stream_Element_Count (Index - 1) * Self.Meta.Piece_Length + Ada.Streams.Stream_Element_Count (Offset), Data => Data); Self.Listener.Interval_Saved (Index, (From, From + Data'Length - 1), Last); if Last then if Self.Is_Valid_Piece (Index) then pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Piece completed" & (Index'Img))); Self.Listener.Piece_Completed (Index, True); Self.Send_Have (Index); else pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Piece FAILED!" & (Index'Img))); Self.Listener.Piece_Completed (Index, False); end if; end if; if Self.Current_Piece.Intervals.Is_Empty then Self.Listener.Reserve_Intervals (Map => Self.Piece_Map, Value => Self.Current_Piece); end if; while J <= Self.Pipelined.Length loop if Self.Pipelined.Request.List (J).Piece = Index and Self.Pipelined.Request.List (J).Span.From = From then if Self.Current_Piece.Intervals.Is_Empty then Swap (J, Self.Pipelined.Length); Self.Pipelined := (Self.Pipelined.Length - 1, Request => (Self.Pipelined.Length - 1, Self.Pipelined.Request.List (1 .. Self.Pipelined.Length - 1)), Expire => Self.Pipelined.Expire (1 .. Self.Pipelined.Length - 1)); else declare Last : constant Interval := Self.Current_Piece.Intervals.Last_Element; begin Self.Current_Piece.Intervals.Delete_Last; Self.Pipelined.Request.List (J) := (Self.Current_Piece.Piece, Last); Self.Pipelined.Expire (J) := Self.Pipelined.Length * Expire_Loops; Self.Send_Message ((00, 00, 00, 13, 06) & To_Int (Natural (Self.Current_Piece.Piece - 1)) & To_Int (Natural (Last.From)) & To_Int (Natural (Last.To - Last.From + 1))); J := J + 1; end; end if; else -- Check if some request was lost Self.Pipelined.Expire (J) := Self.Pipelined.Expire (J) - 1; if Self.Pipelined.Expire (J) = 0 then pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Re-send lost request:")); Self.Pipelined.Expire (J) := Self.Pipelined.Length * Expire_Loops; Self.Send_Message ((00, 00, 00, 13, 06) & To_Int (Natural (Self.Pipelined.Request.List (J).Piece - 1)) & To_Int (Natural (Self.Pipelined.Request.List (J) .Span.From)) & To_Int (Natural (Self.Pipelined.Request.List (J) .Span.To - Self.Pipelined.Request.List (J) .Span.From + 1))); end if; J := J + 1; end if; end loop; end Save_Piece; --------------------------- -- Send_Initial_Requests -- --------------------------- procedure Send_Initial_Requests is Length : Piece_Interval_Count; begin if Self.Current_Piece.Intervals.Is_Empty then Self.Listener.Reserve_Intervals (Map => Self.Piece_Map, Value => Self.Current_Piece); end if; Length := Piece_Interval_Count'Min (Piece_Interval_Count'Last, Self.Current_Piece.Intervals.Last_Index); Self.Pipelined := (Length => Length, Expire => (1 .. Length => Length * Expire_Loops), Request => (Length, others => <>)); for J in 1 .. Length loop declare Last : constant Interval := Self.Current_Piece.Intervals.Last_Element; Index : constant Piece_Index := Self.Current_Piece.Piece; Offset : constant Piece_Offset := Last.From; Length : constant Piece_Offset := Last.To - Offset + 1; begin Self.Send_Message ((00, 00, 00, 13, 06) & To_Int (Natural (Index - 1)) & To_Int (Natural (Offset)) & To_Int (Natural (Length))); Self.Pipelined.Request.List (J) := (Piece => Self.Current_Piece.Piece, Span => (Offset, Last.To)); Self.Current_Piece.Intervals.Delete_Last; end; end loop; end Send_Initial_Requests; Completed : constant Piece_Index_Array := Self.Downloader.Completed; Last : Ada.Streams.Stream_Element_Count := Self.Unparsed.Length; Data : Ada.Streams.Stream_Element_Array (1 .. Max_Interval_Size + 20); begin if Self.Closed then return; end if; if not Self.Choked_Sent then Self.Choked_Sent := True; if Self.He_Choked then Self.Send_Message ((00, 00, 00, 01, 00)); -- choke Self.Requests.Clear; else Self.Send_Message ((00, 00, 00, 01, 01)); -- unchoke end if; end if; for J in Self.Last_Completed + 1 .. Completed'Last loop Self.Send_Have (Completed (J)); end loop; Self.Last_Completed := Completed'Last; Data (1 .. Last) := Self.Unparsed.To_Stream_Element_Array; Self.Unparsed.Clear; loop declare Read : Ada.Streams.Stream_Element_Count; begin if Self.Closed then return; end if; GNAT.Sockets.Receive_Socket (Socket => Self.Socket, Item => Data (Last + 1 .. Data'Last), Last => Read); if Read = Last then pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Closed on Read:" & GNAT.Sockets.Image (Self.Peer))); Self.Close_Connection; return; else Last := Read; end if; exception when E : GNAT.Sockets.Socket_Error => if GNAT.Sockets.Resolve_Exception (E) in GNAT.Sockets.Resource_Temporarily_Unavailable then null; -- Timeout on Read else pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Raised on Read:" & GNAT.Sockets.Image (Self.Peer))); pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (Ada.Exceptions.Exception_Information (E))); Self.Close_Connection; return; end if; end; if Self.Got_Handshake then Read_Messages (Data (1 .. Last), Last); elsif Last >= Handshake_Image'Length and then Get_Handshake (Data (1 .. Last)) then Data (1 .. Last - Handshake_Image'Length) := Data (Handshake_Image'Last + 1 .. Last); Last := Last - Handshake_Image'Length; Read_Messages (Data (1 .. Last), Last); end if; Self.Send_Pieces (Limit); exit when Ada.Calendar.Clock > Limit; end loop; if Last > 0 then Self.Unparsed.Append (Data (1 .. Last)); end if; exception when E : others => pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print ("Raised on Serve:" & GNAT.Sockets.Image (Self.Peer))); pragma Debug (Torrent.Logs.Enabled, Torrent.Logs.Print (Ada.Exceptions.Exception_Information (E))); Self.Close_Connection; return; end Serve; --------------- -- Serve_All -- --------------- procedure Serve_All (Selector : GNAT.Sockets.Selector_Type; Vector : in out Connection_Vectors.Vector; Except : Connection_Access_Array; Limit : Ada.Calendar.Time) is use type Ada.Calendar.Time; Now : Ada.Calendar.Time; Status : GNAT.Sockets.Selector_Status; R_Set : GNAT.Sockets.Socket_Set_Type; W_Set : GNAT.Sockets.Socket_Set_Type; begin loop for C of Vector loop if C.Connected and then not (for some X of Except => X = C) then GNAT.Sockets.Set (R_Set, C.Socket); end if; end loop; Now := Ada.Calendar.Clock; if GNAT.Sockets.Is_Empty (R_Set) or Now >= Limit then return; end if; GNAT.Sockets.Check_Selector (Selector => Selector, R_Socket_Set => R_Set, W_Socket_Set => W_Set, Status => Status, Timeout => Limit - Now); if Status in GNAT.Sockets.Completed then for C of Vector loop if C.Connected and then GNAT.Sockets.Is_Set (R_Set, C.Socket) then GNAT.Sockets.Clear (R_Set, C.Socket); C.Serve (Now); end if; end loop; end if; GNAT.Sockets.Empty (R_Set); end loop; end Serve_All; ------------------ -- Serve_Needed -- ------------------ function Serve_Needed (Self : Connection'Class) return Boolean is begin return not Self.Choked_Sent; end Serve_Needed; ---------------- -- Set_Choked -- ---------------- procedure Set_Choked (Self : in out Connection'Class; Value : Boolean) is begin if Self.He_Choked /= Value then Self.He_Choked := Value; Self.Choked_Sent := not Self.Choked_Sent; end if; end Set_Choked; ------------- -- To_Int -- ------------- function To_Int (Value : Natural) return Int_Buffer is use type Interfaces.Unsigned_32; Result : Int_Buffer; Next : Interfaces.Unsigned_32 := Interfaces.Unsigned_32 (Value); begin for X of reverse Result loop X := Ada.Streams.Stream_Element (Next mod 256); Next := Interfaces.Shift_Right (Next, 8); end loop; return Result; end To_Int; ------------------------- -- Unreserve_Intervals -- ------------------------- procedure Unreserve_Intervals (Self : in out Connection'Class) is Back : Piece_Interval_Array (1 .. Self.Current_Piece.Intervals.Last_Index); begin for J in Back'Range loop Back (J).Piece := Self.Current_Piece.Piece; Back (J).Span := Self.Current_Piece.Intervals (J); end loop; Self.Listener.Unreserve_Intervals (Self.Pipelined.Request.List & Back); Self.Current_Piece := (0, Interval_Vectors.Empty_Vector); Self.Pipelined := (0, Request => (0, others => <>), Expire => <>); end Unreserve_Intervals; end Torrent.Connections;
data/moves/effects_pointers.asm
opiter09/ASM-Machina
1
21503
MoveEffectPointerTable: ; entries correspond to *_EFFECT constants table_width 2, MoveEffectPointerTable dw SleepEffect ; EFFECT_01 dw PoisonEffect ; POISON_SIDE_EFFECT1 dw DrainHPEffect ; DRAIN_HP_EFFECT dw FreezeBurnParalyzeEffect ; BURN_SIDE_EFFECT1 dw FreezeBurnParalyzeEffect ; FREEZE_SIDE_EFFECT dw FreezeBurnParalyzeEffect ; PARALYZE_SIDE_EFFECT1 dw ExplodeEffect ; EXPLODE_EFFECT dw DrainHPEffect ; DREAM_EATER_EFFECT dw NULL ; MIRROR_MOVE_EFFECT dw StatModifierUpEffect ; ATTACK_UP1_EFFECT dw StatModifierUpEffect ; DEFENSE_UP1_EFFECT dw StatModifierUpEffect ; SPEED_UP1_EFFECT dw StatModifierUpEffect ; SPECIAL_UP1_EFFECT dw StatModifierUpEffect ; ACCURACY_UP1_EFFECT dw StatModifierUpEffect ; EVASION_UP1_EFFECT dw PayDayEffect ; PAY_DAY_EFFECT dw NULL ; SWIFT_EFFECT dw StatModifierDownEffect ; ATTACK_DOWN1_EFFECT dw StatModifierDownEffect ; DEFENSE_DOWN1_EFFECT dw StatModifierDownEffect ; SPEED_DOWN1_EFFECT dw StatModifierDownEffect ; SPECIAL_DOWN1_EFFECT dw StatModifierDownEffect ; ACCURACY_DOWN1_EFFECT dw StatModifierDownEffect ; EVASION_DOWN1_EFFECT dw ConversionEffect ; CONVERSION_EFFECT dw HazeEffect ; HAZE_EFFECT dw BideEffect ; BIDE_EFFECT dw ThrashPetalDanceEffect ; THRASH_PETAL_DANCE_EFFECT dw SwitchAndTeleportEffect ; SWITCH_AND_TELEPORT_EFFECT dw TwoToFiveAttacksEffect ; TWO_TO_FIVE_ATTACKS_EFFECT dw TwoToFiveAttacksEffect ; EFFECT_1E dw FlinchSideEffect ; FLINCH_SIDE_EFFECT1 dw SleepEffect ; SLEEP_EFFECT dw PoisonEffect ; POISON_SIDE_EFFECT2 dw FreezeBurnParalyzeEffect ; BURN_SIDE_EFFECT2 dw FreezeBurnParalyzeEffect ; unused effect dw FreezeBurnParalyzeEffect ; PARALYZE_SIDE_EFFECT2 dw FlinchSideEffect ; FLINCH_SIDE_EFFECT2 dw OneHitKOEffect ; OHKO_EFFECT dw ChargeEffect ; CHARGE_EFFECT dw NULL ; SUPER_FANG_EFFECT dw NULL ; SPECIAL_DAMAGE_EFFECT dw TrappingEffect ; TRAPPING_EFFECT dw ChargeEffect ; FLY_EFFECT dw TwoToFiveAttacksEffect ; ATTACK_TWICE_EFFECT dw NULL ; JUMP_KICK_EFFECT dw MistEffect ; MIST_EFFECT dw FocusEnergyEffect ; FOCUS_ENERGY_EFFECT dw RecoilEffect ; RECOIL_EFFECT dw ConfusionEffect ; CONFUSION_EFFECT dw StatModifierUpEffect ; ATTACK_UP2_EFFECT dw StatModifierUpEffect ; DEFENSE_UP2_EFFECT dw StatModifierUpEffect ; SPEED_UP2_EFFECT dw StatModifierUpEffect ; SPECIAL_UP2_EFFECT dw StatModifierUpEffect ; ACCURACY_UP2_EFFECT dw StatModifierUpEffect ; EVASION_UP2_EFFECT dw HealEffect ; HEAL_EFFECT dw TransformEffect ; TRANSFORM_EFFECT dw StatModifierDownEffect ; ATTACK_DOWN2_EFFECT dw StatModifierDownEffect ; DEFENSE_DOWN2_EFFECT dw StatModifierDownEffect ; SPEED_DOWN2_EFFECT dw StatModifierDownEffect ; SPECIAL_DOWN2_EFFECT dw StatModifierDownEffect ; ACCURACY_DOWN2_EFFECT dw StatModifierDownEffect ; EVASION_DOWN2_EFFECT dw ReflectLightScreenEffect ; LIGHT_SCREEN_EFFECT dw ReflectLightScreenEffect ; REFLECT_EFFECT dw PoisonEffect ; POISON_EFFECT dw ParalyzeEffect ; PARALYZE_EFFECT dw StatModifierDownEffect ; ATTACK_DOWN_SIDE_EFFECT dw StatModifierDownEffect ; DEFENSE_DOWN_SIDE_EFFECT dw StatModifierDownEffect ; SPEED_DOWN_SIDE_EFFECT dw StatModifierDownEffect ; SPECIAL_DOWN_SIDE_EFFECT dw StatModifierDownEffect ; unused effect dw StatModifierDownEffect ; unused effect dw StatModifierDownEffect ; unused effect ;dw StatModifierDownEffect ; unused effect dw AmnesiaEffect ; AMNESIA_EFFECT -OEA dw ConfusionSideEffect ; CONFUSION_SIDE_EFFECT dw TwoToFiveAttacksEffect ; TWINEEDLE_EFFECT ;dw NULL ; unused effect dw TriAttackEffect ; TRI_ATTACK_EFFECT -OEA dw SubstituteEffect ; SUBSTITUTE_EFFECT dw HyperBeamEffect ; HYPER_BEAM_EFFECT dw RageEffect ; RAGE_EFFECT dw MimicEffect ; MIMIC_EFFECT dw NULL ; METRONOME_EFFECT dw LeechSeedEffect ; LEECH_SEED_EFFECT dw SplashEffect ; SPLASH_EFFECT dw DisableEffect ; DISABLE_EFFECT assert_table_length NUM_MOVE_EFFECTS
dev/ansi/ansi.asm
minblock/msdos
0
6787
PAGE ,132 TITLE CONDEV FANCY CONSOLE DRIVER ;****************************************************************************** ; Change Log: ; Date Who # Description ; -------- --- --- ------------------------------------------------------ ; 06/01/90 MKS C02 Bug#173. ANSI was permitting you to go one line below ; the bottom of the screen. PROMPT $e[25;3H $e[1B will ; show you. (PYS: badly done. M005) ;****************************************************************************** ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ; ADDRESSES FOR I/O ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;------------------------------------------------------------------------------ ; New functionality in DOS 4.00 ; GHG fix scrolling flashes on Mod 25/30's ; P1767 VIDEO_MODE_TABLE not initialized correctly 10/16/87 J.K. ; D375 /X needs to be supported by ANSI sequence also 12/14/87 J.K. ; D397 /L option for Enforcing number of lines 12/17/87 J.K. ; D479 An option to disable the extended keyboard functions 02/12/88 J.K. ; P4241 AN001 fix be Revised to fix this problem 04/20/88 J.K. ; P4532 Scrolling has a snow for CGA adapter 04/27/88 J.K. ; P4533 In mode Dh, Eh, Fh, 10h and 13h, Scrolling not working 04/27/88 J.K. ; P4766 In mode 11h, and 12h erase display leaves bottom 5 05/24/88 F.G. ;------------------------------------------------------------------------------ INCLUDE DEVSYM.INC INCLUDE ANSI.INC ;equates and structures INCLUDE VECTOR.INC BREAK <ANSI driver code> PUBLIC SWITCH_X ; /X option for extended keyboard redefinition support PUBLIC SWITCH_R ; /R option for using screen readers PUBLIC SCAN_LINES PUBLIC VIDEO_MODE_TABLE PUBLIC VIDEO_TABLE_MAX PUBLIC MAX_VIDEO_TAB_NUM ;P1767 PUBLIC PTRSAV PUBLIC ERR1 PUBLIC ERR2 PUBLIC EXT_16 PUBLIC BRKKY PUBLIC COUT PUBLIC BASE PUBLIC MODE PUBLIC MAXCOL PUBLIC EXIT PUBLIC NO_OPERATION PUBLIC HDWR_FLAG PUBLIC SWITCH_L PUBLIC SWITCH_K PUBLIC SWITCH_S ; M008 /S for screensize option setting. PUBLIC fhavek09 ; M006 PUBLIC CON$READ PUBLIC CON$RDND PUBLIC CON$FLSH PUBLIC CON$WRIT PUBLIC VIDEO PUBLIC CUU PUBLIC CUD PUBLIC CUF PUBLIC CUB PUBLIC CUP PUBLIC ED PUBLIC CPR PUBLIC SM PUBLIC RM PUBLIC SGR PUBLIC DSR PUBLIC KEYASN PUBLIC EXTKEY PUBLIC PSCP PUBLIC PRCP IFDEF JAPAN PUBLIC ROW_ADJ ENDIF CODE SEGMENT PUBLIC BYTE ASSUME CS:CODE,DS:NOTHING,ES:NOTHING ;----------------------------------------------- ; C O N - CONSOLE DEVICE DRIVER EXTRN CON$INIT : NEAR ; ANSI initialization code EXTRN GENERIC_IOCTL : NEAR ; Generic IOCTL code EXTRN REQ_TXT_LENGTH : WORD ; current text length EXTRN GRAPHICS_FLAG : BYTE ; graphics flag ATTRIB EQU CHARDEV+DEVIOCTL+DEV320+ISSPEC+ISCOUT+ISCIN CONDEV: SYSDEV <-1,ATTRIB,STRATEGY,ENTRY,'CON '> ; Matches CON ;-------------------------------------------------------------- ; COMMAND JUMP TABLES CONTBL: DW CON$INIT DW NO_OPERATION DW NO_OPERATION DW NO_OPERATION DW CON$READ DW CON$RDND DW NO_OPERATION DW CON$FLSH DW CON$WRIT DW CON$WRIT DW NO_OPERATION DW NO_OPERATION DW NO_OPERATION DW NO_OPERATION DW NO_OPERATION DW NO_OPERATION DW NO_OPERATION DW NO_OPERATION DW NO_OPERATION DW GENERIC_IOCTL ; generic IOCTL routine offset MAX_CMD EQU ($ - CONTBL)/2 ; size of CONTBL CMDTABL DB 'A' DW CUU ; cursor up DB 'B' DW CUD ; cursor down DB 'C' DW CUF ; cursor forward DB 'D' DW CUB ; cursor back DB 'H' DW CUP ; cursor position DB 'J' DW ED ; erase display DB 'K' DW EL ; erase line DB 'R' DW CPR ; cursor postion report DB 'f' DW CUP ; cursor position DB 'h' DW SM ; set mode DB 'l' DW RM ; reset mode DB 'm' DW SGR ; select graphics rendition DB 'n' DW DSR ; device status report DB 'p' DW KEYASN ; key assignment DB 'q' ; dynamic support of /X option through ansi sequence DW EXTKEY ; esc[0q = reset it. esc[1q = set it DB 's' DW PSCP ; save cursor postion DB 'u' DW PRCP ; restore cursor position IFDEF JAPAN DB 'M' DW DELETE ; delete line DB 'L' DW INSERT ; insert line ENDIF DB 00 GRMODE DB 00,00000000B,00000111B DB 01,11111111B,00001000B DB 04,11111000B,00000001B DB 05,11111111B,10000000B DB 07,11111000B,01110000B DB 08,10001000B,00000000B DB 30,11111000B,00000000B DB 31,11111000B,00000100B DB 32,11111000B,00000010B DB 33,11111000B,00000110B DB 34,11111000B,00000001B DB 35,11111000B,00000101B DB 36,11111000B,00000011B DB 37,11111000B,00000111B DB 40,10001111B,00000000B DB 41,10001111B,01000000B DB 42,10001111B,00100000B DB 43,10001111B,01100000B DB 44,10001111B,00010000B DB 45,10001111B,01010000B DB 46,10001111B,00110000B DB 47,10001111B,01110000B DB 0FFH ;--------------------------------------------------- ; Device entry point PTRSAV DD 0 BUF1: BUF_DATA <> ; Next CON Buffer area STRATP PROC FAR STRATEGY: mov word ptr cs:[PTRSAV],bx mov word ptr cs:[PTRSAV+2],es ret STRATP ENDP ENTRY: push si push ax push cx push dx push di push bp push ds push es push bx ; Check if header link has to be set (Code ported from ; DISPLAY.SYS) lea bx,BUF1 mov di,OFFSET CONDEV ; CON Device header mov CONPTR.DEV_HDRO,di mov CONPTR.DEV_HDRS,cs cld ; all moves forward cmp CONPTR.CON_STRAO, -1 jne L4 ; has been linked to DOS CON cmp CONPTR.CON_STRAS, -1 jne L4 ; has been linked to DOS CON ; next device header : ES:[DI] lds si,dword ptr CONPTR.DEV_HDRO les di,HP.SDEVNEXT L1: ; while pointer to next device header push es ; is not -1 pop ax cmp ax,-1 jne NOT0FFFF ; leave if both offset and segment are cmp di,-1 ; 0FFFFH je L4 NOT0FFFF: push di push si mov cx,8 lea di,NHD.SDEVNAME lea si,HP.SDEVNAME repe cmpsb pop si pop di and cx,cx ; Exit if name is found in linked hd. jnz L3 ; Name is not found ; Name is found in the linked header mov ax,NHD.SDEVSTRAT ; Get the STRATEGY address mov CONPTR.CON_STRAO,ax mov ax,es X1: mov CONPTR.CON_STRAS,ax mov ax,NHD.SDEVINT ; Get the INTERRUPT address mov CONPTR.CON_INTRO,ax mov ax,es X2: mov CONPTR.CON_INTRS,ax jmp SHORT L4 ; Device Name L3: les di,NHD.SDEVNEXT jmp L1 L4: lds bx,cs:[PTRSAV] ; GET PONTER TO I/O PACKET mov cx,word ptr ds:[bx].COUNT mov al,byte ptr ds:[bx].CMD cbw mov si,OFFSET CONTBL add si,ax add si,ax cmp al,MAX_CMD ; not a call for ANSI...chain to lower device ja NO_OPERATION ifdef KOREA ; <MSCH> mov ah, byte ptr ds:[bx].media endif ; KOREA les di,dword ptr ds:[bx].TRANS ; Following code, supplied by Compaq, is the "hit-it-on-the-head" ; approach to solving the problem of resetting the screen length ; after a character set reload. We should try to find a better ; approach. For now this will stay in. - MGD push ax ; SAVE AX mov ax,40H ; GET ROM VAR mov ds,ax ; mov al,ds:[84h] ; GET MAX NUM OF ROWS cmp al,0 ; Q:ZERO jne ENTRY10 ; jmp IF NO mov al,24 ; SET TO 24 ROWS ENTRY10: ; push cs pop ds ASSUME ds:CODE inc al ; BUMP FOR ONE BASED mov byte ptr [REQ_TXT_LENGTH],al ; SET LENGTH TO 40:84H VALUE. *F pop ax ; RESTORE AX jmp word ptr [si] ; GO DO COMMAND ;===================================================== ;= ;= SUBROUTINES SHARED BY MULTIPLE DEVICES ;= ;===================================================== ;---------------------------------------------------------- ; EXIT - ALL ROUTINES RETURN THROUGH THIS PATH BUS$EXIT: ; DEVICE BUSY EXIT mov ah,00000011B jmp SHORT ERR1 NO_OPERATION: call PASS_CONTROL ; Pass control to lower CON jmp SHORT ERR2 ERR$EXIT: mov ah,10000001B ; MARK ERROR RETURN jmp SHORT ERR1 EXITP PROC FAR EXIT: mov ah,00000001B ifdef KOREA INTERIM$EXIT: ; <MSCH> endif ; KOREA ERR1: lds bx,cs:[PTRSAV] mov word ptr [bx].STATUS,ax ; MARK OPERATION COMPLETE ERR2: pop bx pop es pop ds pop bp pop di pop dx pop cx pop ax pop si ret ; RESTORE REGS and RETURN EXITP ENDP ; PASS CONTROL ; This calls the attached device to perform any further ; action on the call! PASS_CONTROL PROC lea si,BUF1 les bx,cs:[PTRSAV] ; pass the request header to the call dword ptr cs:[si].CON_STRAO ; CON strategy routine. call dword ptr cs:[si].CON_INTRO ; interrupt the CON ret PASS_CONTROL ENDP ;----------------------------------------------- ; BREAK KEY HANDLING BRKKY: mov byte ptr cs:ALTAH,3 ; INDICATE BREAK KEY SET INTRET: iret ; WARNING - Variables are very order dependent, be careful ; when adding new ones! - c.p. WRAP DB 0 ; 0 = WRAP, 1 = NO WRAP ASNPTR DW 4 STATE DW S1 MODE DB 3 ;* MAXCOL DB 79 ;* COL DB 0 ROW DB 0 SAVCR DW 0 INQ DB 0 PRMCNT LABEL BYTE PRMCNTW DW 0 KEYCNT DB 0 KEYPTR DW BUF REPORT DB ESC_CHAR,'[00;00R',CR ;CURSOR POSTION REPORT BUFFER ALTAH DB 0 ;Special key handling SAVE_CHAR DW 0 ; Temp storage for char/attr for new scroll code EXT_16 DB 0 ; Extended INT 16h flag SWITCH_X DB OFF ; /X flag SWITCH_L DB OFF ; DCR397; 1= /L flag entered. SWITCH_K DB OFF ; To control EXT_16 fhavek09 DB OFF ; M006 SCAN_LINES DB ? ; flag for available scan lines (VGA) HDWR_FLAG DW 0 ; byte of flags indicating video support SWITCH_S DB OFF ; M008; /S flag SWITCH_R DB OFF ; /R flag for screen readers ifdef KOREA ; REQ_TYPE DB 0 ; EXT_REQ_TYPE DB 0 ; LEADBYTE DB 0 ; TRAILBYTE DB 0 ; ECSPRE DB 0 ; endif ; KOREA ; VIDEO_MODE_TABLE LABEL BYTE ; table containing applicable MODE_TABLE <> ; video modes and corresponding MODE_TABLE <> ; data. MODE_TABLE <> ; this table is initialized at MODE_TABLE <> ; INIT time MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> MODE_TABLE <> ifdef KOREA ; The KOREAN video mode MODE_TABLE <> ; have 4 more than standard MODE_TABLE <> ; VGA card MODE_TABLE <> ; MODE_TABLE <> ; endif ; KOREA ; VIDEO_TABLE_MAX EQU $ ; maximum address for video table MAX_VIDEO_TAB_NUM EQU ($-VIDEO_MODE_TABLE)/TYPE MODE_TABLE ;P1767 Max number of table IFDEF DBCS dbcs_flag DB 0 ; 0=single, 1=lead byte, 2=tail byte ENDIF IFDEF JAPAN new_mode DB 0 ; mode for '>' row_adj DB 0 ; for ESC[>1l ENDIF ;------------------------------------------------------------- ; CHROUT - WRITE OUT CHAR IN AL USING CURRENT ATTRIBUTE ATTRW LABEL WORD ATTR DB 00000111B ; CHARACTER ATTRIBUTE BPAGE DB 0 ; BASE PAGE BASE DW 0b800h SCREEN_SEG DW 00000h chrout: ifdef KOREA ; <MSCH> ; cmp [leadbyte],1 ; Is the previous byte a lead byte? ; KeyW jnz TestDBCSRange ; No, mov byte ptr [leadbyte],0 mov byte ptr [trailbyte],1 ; Mark that this is trail byte of ECS jmp short OUTCHR ; ; ; Note : TestECS routine is hard coded. If you have the different code range, ; you should change some codes below. ; 1990/11/9 This routine is changed to use IsDBCS routines. ; TestDBCSRange: mov byte ptr [trailbyte], 0 ; Mark it as a non trail byte call IsDBCSleadbyte jnz realout ; Jump if one byte code ; ; CMP AL, 0A1H ; ; JB REALOUT ; ; CMP AL, 0FEH ; ; JA REALOUT ; mov byte ptr [leadbyte], 1 ; it as a lead byte mov ah, [col] ; cmp ah, [maxcol] ; jnz outchr ; ; ; ; Decide the position to print the Lead byte which is on the column boundary. ; cmp [wrap],0 ; jz skip1 ; dec [col] ; cmp [ecspre],1 ; jnz oneback1 ; dec [col] ; oneback1: ; call setit1 ; jmp short outchr ; skip1: ; push ax ; call outchr1 ; pop ax ; jmp short outchr ; realout: endif ; KOREA ; cmp al,13 jnz trylf mov [COL],0 ifdef KOREA jmp setit else IFDEF JAPAN jmp setit ELSE jmp short setit ENDIF endif ; KOREA trylf: cmp al,10 jz lf cmp al,7 jnz tryback torom: mov bx,[ATTRW] and bl,7 mov ah,14 int 10h ret5: ret tryback: cmp al,8 jnz outchr cmp [COL],0 jz ret5 dec [COL] jmp short setit outchr: mov bx,[ATTRW] mov cx,1 mov ah,9 int 10h inc [COL] mov al,[COL] cmp al,[MAXCOL] jbe setit cmp [wrap],0 jz outchr1 dec [COL] ifdef KOREA ; ; Set boundary position for DBCS code. ; No lead byte can arrive here. ; cmp [trailbyte],1 jnz onebk dec [col] onebk: call setit1 ; ; We don't need ECSPRE change, because we have enough time to deal with it. ; Wait for another character to change ECSPRE. ; endif ; KOREA ret outchr1: mov [COL],0 lf: inc [ROW] mov ah,30 ; GHG Fix for ROUNDUP/PALACE mov al,MODE ; GHG Fix for ROUNDUP/PALACE cmp al,11H ; GHG Fix for ROUNDUP/PALACE je LF2 ; GHG Fix for ROUNDUP/PALACE cmp al,12H ; GHG Fix for ROUNDUP/PALACE je LF2 ; GHG Fix for ROUNDUP/PALACE cmp GRAPHICS_FLAG,GRAPHICS_MODE jne tmplab1 mov ah,DEFAULT_LENGTH jmp short tmplab2 tmplab1: mov ah,byte ptr [REQ_TXT_LENGTH] tmplab2: LF2: ; GHG Fix for ROUNDUP/PALACE IFDEF JAPAN sub ah,row_adj ENDIF cmp [ROW],AH ; GHG Fix for ROUNDUP/PALACE jb setit dec ah ; GHG Fix for ROUNDUP/PALACE mov [ROW],AH ; GHG Fix for ROUNDUP/PALACE call scroll setit: ifdef KOREA preset: xor al, al cmp [trailbyte],al jz noDBCStrail inc al noDBCStrail: mov [ecspre], al setit1: endif ; KOREA mov dh,row mov dl,col mov bh,[bpage] mov ah,2 int 10h ret ;Writing a LF char through Teletype function to scroll the screen ;has a side effect of changing the color of the cursor when the PROMPT ;setting in PTM P4241 is used. AN001 uses this method to fix the strobing ;problem of the palace machine. The old method of scrolling used to directly ;write into video buffer. The old method has been used by AN001 for ;CGA adater of mode 2 or 3 only. ;To solve P4241, but to maintain the fix of the strobing problem of palace ;machine, we return back to the old logic but the old logic has to be ;Revised for the displays above CGA level. For the adapters above ;CGA display, we don't need to turn off/on the video - this will causes ;a strobing, if you use do this, for Palace machine. ;This logic will be only applied to mode 2 and 3 only. ; Following code is bug fix supplied by Compaq - MGD scroll: ifdef KOREA ; Responsible for ROM mov al, 10 jmp torom else IFDEF JAPAN ; ### if JAPAN ### xor cx,cx cmp GRAPHICS_FLAG,GRAPHICS_MODE jnz scroll10 ; if nor graphic mov dh,DEFAULT_LENGTH xor bh,bh jmp short scroll20 scroll10: mov dh,byte ptr [REQ_TXT_LENGTH] mov bh,[ATTR] scroll20: sub dh,row_adj dec dh mov dl,[MAXCOL] mov ax,0601h ; scroll up int 10h jmp short setit else ; ### if Not JAPAN ### ; Because of screen reader problem, /R switch was added. ; If Switch_R set all line feeds go to torom. Bug #1241- msdos6: cmp SWITCH_R,OFF je is_2or3 ; if off, goto test mode mov al,10 ; if ON send the line feed to the ROM jmp torom ; exit is_2or3: mov al,mode ; get display mode cmp al,4 ;Q: mode less than 4? jc is_text ;Y: perform kludge cmp al,7 ;N: Q: monochrome mode? je is_text ; Y: perform kludge mov al,10 ; send the line feed to the ROM jmp torom ; exit is_text: mov ah,8 ; read char/attr at cursor pos mov bh,[bpage] int 10h mov [save_char],ax ; save char/attribute mov ah,9 ; write char at cursor pos mov bx,[ATTRW] ; use current attribute mov cx,1 int 10h mov al,10 ; send the line feed to the ROM call torom mov ah,3 ; read cursor pos int 10h push dx ; save it mov ah,2 ; set cursor position dec dh ; (to row-1) int 10h mov ax,[save_char] ; retrieve saved char/attr mov bl,ah mov ah,9 ; write it back to the screen mov cx,1 int 10h pop dx ; retrieve new cursor position mov ah,2 ; set cursor position int 10h ret ENDIF ; ### end if Not JAPAN ### endif ; KOREA ;------------------------------------------------------ ; CONSOLE READ ROUTINE CON$READ: jcxz CON$EXIT ifdef KOREA ; mov [req_type], 0 ; mov [ext_req_type], 10h ; test ah, 00000001b ; jz con$loop ; mov [req_type], 0f0h ; ; Get Interim mode mov [ext_req_type], 0f8h ; cmp cx, 1 ; jnz con$ndisp ; ; call chrin ; stosb ; cmp ah, 0f0h ; ; Is this an interim code ? jnz con$exit ; mov ah, 00000101b ; jmp interim$exit ; ; return to DOS with interim flag set con$ndisp: ; call chrin ; cmp ah, 0f0h ; ; Is this an interim code ? jz con$ndisp ; ; Skip the interims stosb ; LOOP CON$NDISP ; JMP EXIT ; endif ; KOREA CON$LOOP: push cx ; SAVE COUNT call CHRIN ; GET CHAR IN AL pop cx stosb ; STORE CHAR AT ES:DI loop CON$LOOP CON$EXIT: jmp EXIT ;--------------------------------------------------------- ; INPUT SINGLE CHAR INTO AL CHRIN: xor ax,ax xchg al,ALTAH ; GET CHARACTER & ZERO ALTAH or al,al jnz KEYRET INAGN: cmp KEYCNT,0 jnz KEY5A ifdef KOREA mov ah, [req_type] else xor ah,AH endif ; KOREA cmp EXT_16,ON ; extended interrupt available? jne tmplab3 ifdef KOREA mov ah, [ext_req_type] else mov ah,10h ; yes..perform extended call endif ; KOREA INT 16h ifdef KOREA cmp ah, 0f0h jz keyret1 ; Breief return for the interim code endif ; KOREA cmp SWITCH_X,OFF ; /X switch used? jne tmplab5 call CHECK_FOR_REMAP ; no....map to normal call tmplab5: call SCAN ; check for redefinition jz tmplab4 ; no redefinition?....and cmp SWITCH_X,ON ; /X switch used? jne tmplab4 call CHECK_FOR_REMAP ; then remap.. or bx,bx ; reset zero flag for jump test in old code jmp short tmplab4 ; extended interrupt not available tmplab3: int 16h ifdef KOREA cmp ah, 0f0h jz keyret1 endif ; KOREA call SCAN ; check for redefinition tmplab4: jnz ALT10 ; IF NO MATCH JUST RETURN IT dec cx dec cx inc bx inc bx cmp al,0 ; check whether keypacket is an extended one jz tmplab7 cmp al,0e0h jnz tmplab6 ifdef KOREA cmp ah, 0f0h jb mschtmp2 cmp ah, 0f2h jbe tmplab7 mschtmp2: endif ; KOREA cmp SWITCH_X,1 jnz tmplab6 tmplab7: dec cx ; adjust pointers inc bx ; appropiately tmplab6: mov KEYCNT,cl mov KEYPTR,bx KEY5A: ; Jmp here to get rest of translation call KEY5 ; GET FIRST KEY FROM TRANSLATION ALT10: or ax,ax ; Check for non-key after BREAK jz INAGN or al,al ; SPECIAL CASE? jnz KEYRET mov ALTAH,ah ; STORE SPECIAL KEY KEYRET: ifdef KOREA mov ah, 0f1h keyret1: endif ; KOREA ret KEY5: mov bx,KEYPTR ; GET A KEY FROM TRANSLATION TABLE mov ax,word ptr [bx] dec KEYCNT inc bx or al,al jnz KEY6 inc bx dec KEYCNT KEY6: mov KEYPTR,bx ret SCAN: mov bx,OFFSET BUF KEYLP: mov cl,byte ptr [bx] xor ch,ch or cx,cx jz NOTFND cmp al,0 ; check whether extended keypacket jz tmplab8 cmp al,0e0h ; extended must be enabled with /x jnz tmplab9 ifdef KOREA ; Jump when Hangeul char cmp ah, 0f0h jb mschtmp1 cmp ah, 0f2h jbe tmplab9 mschtmp1: endif ; KOREA cmp SWITCH_X,ON jnz tmplab9 tmplab8: cmp ax,word ptr [bx+1] ; yes...compare the word jmp short tmplab10 tmplab9: cmp al,byte ptr [bx+1] ; no...compare the byte tmplab10: jz MATCH add bx,cx jmp KEYLP NOTFND: or bx,bx MATCH: ret ;-------------------------------------------------------------- ; KEYBOARD NON DESTRUCTIVE READ, NO WAIT CON$RDND: mov al,[ALTAH] or al,al ifdef KOREA jnz To_RDEXIT else jnz RDEXIT endif ; KOREA cmp [KEYCNT],0 jz RD1 mov bx,[KEYPTR] mov al,byte ptr [bx] ifdef KOREA to_rdexit: jmp rdexit else jmp SHORT RDEXIT endif ; KOREA RD1: ifdef KOREA mov [req_type], 1 mov [ext_req_type], 11H test ah, 00000001b jz rd11 mov [req_type], 0f1h mov [ext_req_type], 0f9H RD11: mov ah, [req_type] cmp ext_16, on jnz tmplab11 mov ah, [ext_req_type] else mov ah,1 cmp EXT_16,ON jnz tmplab11 add ah,10h ; yes....adjust to extended call endif ; KOREA tmplab11: int 16h jz CheckForEvent or ax,ax jnz RD2 ifdef KOREA mov ah, [req_type] and ah, 11111110b else mov ah,0 endif ; KOREA cmp EXT_16,ON ; extended interrupt available? jne tmplab12 ifdef KOREA mov ah, [ext_req_type] and ah, 11111110b else mov ah,10h ; yes..perform extended call endif ; KOREA int 16h cmp SWITCH_X,OFF ; /X switch used? jnz tmplab13 call CHECK_FOR_REMAP ; no....map to normal call jmp short tmplab13 tmplab12: int 16h tmplab13: jmp CON$RDND RD2: ifdef KOREA cmp ah, 0f0h jz rdexit endif ; KOREA call SCAN jz tmplab14 ; if no redefinition cmp EXT_16,ON jnz tmplab14 ; and extended INT16 used cmp SWITCH_X,ON ; and /x used jnz tmplab14 call CHECK_FOR_REMAP ; remap to standard call or bx,bx ; reset zero flag for jump test in old code tmplab14: jnz RDEXIT mov al,byte ptr [bx+2] cmp byte ptr [bx+1],0 jnz RDEXIT mov al,byte ptr [bx+3] RDEXIT: lds bx,[PTRSAV] mov [bx].MEDIA,al EXVEC: jmp EXIT ; M006 - begin CheckForEvent: cmp fhavek09,0 jz CONBUS ; return with busy status if not k09 les bx,[ptrsav] assume es:nothing test es:[bx].status,0400h ; system wait enabled? jz CONBUS ; return with busy status if not ; need to wait for ibm response to request for code ; on how to use the system wait call. mov ax,4100h ; wait on an external event xor bl,bl ; wait for any event int 15h ; call rom for system wait ; M006 - end CONBUS: jmp BUS$EXIT ;-------------------------------------------------------------- ; KEYBOARD FLUSH ROUTINE CON$FLSH: mov [ALTAH],0 ; Clear out holding buffer mov [KEYCNT],0 ifdef KOREA mov ah, 0f3h int 16h ReadNullByte: ; We may have final char mov ah, 0f1h int 16h jz FlushDone mov ah, 0f0h int 16h jmp short ReadNullByte FlushDone: else Flush: mov ah,1 cmp EXT_16,ON ; if extended call available jnz tmplab15 add ah,10h ; then use it tmplab15: int 16h jz FlushDone mov ah,0 cmp EXT_16,ON ; if extended call available jnz tmplab16 add ah,10h ; use it tmplab16: int 16h jmp Flush FlushDone: endif ; KOREA jmp EXVEC ;---------------------------------------------------------- ; CONSOLE WRITE ROUTINE CON$WRIT: jcxz EXVEC ifdef KOREA test ah, 00000001b jnz con$lp_nac ;OUT CHAR WITHOUT CURSOR ADVANCING endif ; KOREA CON$LP: mov al,es:[di] ; GET CHAR inc di call OUTC ; OUTPUT CHAR loop CON$LP ; REPEAT UNTIL ALL THROUGH jmp EXVEC ifdef KOREA con$lp_nac: mov al, es:[di] inc di call outchr_nac ;OUTPUT CHAR WITHOUT CURSOR MOVE loop con$lp_nac ;REPEAT UNTIL ALL THROUGH jmp exit outchr_nac: push ax push si push di push bp mov ah, 0feh ;OUTPUT CHAR WITHOUT CURSOR ADVANCING mov bl, 7 ;SET FOREGROUND COLOR int 10h ;CALL ROM BIOS pop bp pop di pop si pop ax ret endif COUT: sti push ds push cs pop ds call OUTC pop ds Iret OUTC: push ax push bx push cx push dx push si push di push es push bp mov [BASE],0b800h xchg ax,si ; SAVE CHARACTER TO STUFF mov ax,40h ; POINT TO ROS BIOS mov ds,ax mov ax,ds:[49h] ; AL=MODE, AH=MAX COL dec ah ; ANSI NEEDS 0-79 OR 0-39 mov word ptr cs:[MODE],ax ; SAVE MODE and MAX COL cmp al,7 jnz NOT_BW mov word ptr cs:[BASE],0B000H NOT_BW: mov al,ds:[62H] ; GET ACTIVE PAGE mov cs:[BPAGE],al cbw add ax,ax mov bx,ax mov ax,ds:[bx+50H] ; AL=COL, AH=ROW mov word ptr cs:[COL],ax ; SAVE ROW and COLUMN mov ax,ds:[4EH] ; GET START OF SCREEN SEG mov cl,4 shr ax,cl ; CONVERT TO A SEGMENT push cs pop ds mov [SCREEN_SEG],ax xchg ax,si ; GET BACK CHARACTER IN AL call VIDEO pop bp pop es pop di pop si pop dx pop cx pop bx pop ax ret ;---------------------------------------------------------- ; OUTPUT SINGLE CHAR IN AL TO VIDEO DEVICE VIDEO: mov si,OFFSET STATE jmp [si] S2: cmp al,'[' jz S22 ifdef KOREA cmp al, '$' jnz chk_off mov word ptr [si], offset S8 ret chk_off: cmp al, '(' jnz jmp_S1 mov word ptr [si], offset S10 ret jmp_S1: endif ; KOREA jmp S1 S22: mov word ptr [si],OFFSET S3 xor bx,bx mov word ptr INQ,bx jmp SHORT S3B S3: cmp al,';' jnz S3C S3A: inc PRMCNT S3B: call GETPTR xor ax,ax mov word ptr [bx],ax ; DEFAULT VALUE IS ZERO ret S3C: cmp al,'0' jb S3D cmp al,'9' ja S3D call GETPTR sub al,'0' xchg al,byte ptr [bx] mov ah,10 mul ah ; *10 add byte ptr [bx],al ; movE IN DIGIT ret S3D: cmp al,'=' jz S3ret cmp al,'?' jz S3ret IFDEF JAPAN cmp al,'>' jz s3f ENDIF cmp al,'"' ; BEGIN QUOTED STRING jz S3E cmp al,"'" jnz S7 S3E: mov word ptr [si],OFFSET S4 mov [INQ],al S3ret: ret IFDEF JAPAN s3f: mov new_mode,1 jmp short s3ret ENDIF ; ENTER QUOTED STRINGS S4: cmp al,[INQ] ; CHECK FOR STRING TERMINATOR jnz S4A dec PRMCNT ; TERMINATE STRING mov word ptr [si],OFFSET S3 ret S4A: call GETPTR mov byte ptr [bx],al mov word ptr [si],OFFSET S4 jmp S3A ; LOOK FOR ANSI COMMAND SPECIFIED IN AL PUBLIC S7 S7: mov bx,OFFSET CMDTABL-3 S7A: add bx,3 cmp byte ptr [bx],0 jz S1B cmp byte ptr [bx],al jnz S7A S7B: mov ax,word ptr [bx+1] ; AX = JUMP addRESS mov bx,OFFSET BUF inc bx add bx,ASNPTR ; BX = PTR TO PARM LIST mov DL,byte ptr [bx] xor DH,DH ; DX = FIRST PARAMETER mov cx,dx or cx,cx jnz S7C inc cx ; CX = DX, CX=1 IF DX=0 S7C: jmp ax ; AL = COMMAND S1: cmp al,ESC_CHAR ; ESCAPE SEQUENCE? jnz S1B IFDEF DBCS mov dbcs_flag,0 ENDIF IFDEF JAPAN mov new_mode,0 ENDIF mov word ptr [si],OFFSET S2 ret S1B: ifndef KOREA ; IN KOREA, WE ALREADY handled IFDEF DBCS cmp dbcs_flag,1 jz set_dbcs ; if it was lead byte cmp dbcs_flag,2 jnz @f ; if it was not tail byte mov dbcs_flag,0 ; reset @@: call IsDBCSLeadByte jnz @f ; if this is not lead byte set_dbcs: inc dbcs_flag @@: cmp dbcs_flag,1 jnz @f mov dl,col cmp dl,maxcol jnz @f push ax mov al,' ' call chrout pop ax @@: ENDIF endif ; NOT KOREA call CHROUT S1A: mov word ptr [STATE],OFFSET S1 ret ifdef KOREA S8: cmp al, ')' jnz s1 mov word ptr [si], offset S9 ret S9: cmp al, '1' jnz S1 han_on: mov ah, 0f2h mov al, 08h ; Hangeul input mode on int 16h ret S10: cmp al, '2' jnz S1 han_off: mov ah, 0f2h mov al, 00h int 16h ret endif ; KOREA MOVCUR: ;C02 cmp byte ptr [bx],AH jz SETCUR add byte ptr [bx],al loop MOVCUR SETCUR: mov dx,word ptr COL ;*C05 xor bx,bx mov ah,0fh ;*C05 int 10h ;*C05 mov ah,2 int 16 jmp S1A CUP: IFDEF JAPAN ; ### if JAPAN ### cmp GRAPHICS_FLAG,GRAPHICS_MODE jnz tmplab17 ; if not graphic mode mov ah,DEFAULT_LENGTH jmp short tmplab18 tmplab17: mov ah,byte ptr [REQ_TXT_LENGTH] tmplab18: sub ah,row_adj cmp cl,ah ELSE cmp GRAPHICS_FLAG,GRAPHICS_MODE jnz tmplab17 cmp cl,DEFAULT_LENGTH jmp short tmplab18 tmplab17: cmp cl,byte ptr [REQ_TXT_LENGTH] tmplab18: ENDIF ; ### end if JAPAN ### ja SETCUR mov al,MAXCOL mov ch,byte ptr [bx+1] or ch,CH jz CUP1 dec CH CUP1: cmp al,CH ja CUP2 mov ch,al CUP2: xchg cl,CH dec CH mov word ptr COL,cx jmp SETCUR CUF: mov ah,MAXCOL mov al,1 CUF1: mov bx,OFFSET COL jmp MOVCUR CUB: mov ax,00FFH jmp CUF1 CUU: mov ax,00FFH CUU1: mov bx,OFFSET ROW jmp MOVCUR CUD: cmp GRAPHICS_FLAG,GRAPHICS_MODE jnz tmplab19 mov ah,DEFAULT_LENGTH jmp short tmplab20 tmplab19: mov ah,byte ptr [REQ_TXT_LENGTH] dec ah ; M005; REQ_TXT_LENGTH is not 0 based tmplab20: IFDEF JAPAN sub ah,row_adj ENDIF mov al,1 jmp CUU1 ExtKey: cmp dl, 0 ; DL = previous parameter jne ExtKey_1 mov Switch_X, OFF ; reset it if 0. jmp S1A ExtKey_1: cmp dl, 1 ; 1 ? je SetExtKey jmp S1A ; ignore it SetExtKey: mov Switch_X, ON ; set it if 1. jmp S1A PSCP: mov ax,word ptr COL mov SAVCR,ax jmp SETCUR PRCP: mov ax,SAVCR mov word ptr COL,ax jmp SETCUR SGR: xor cx,cx xchg cl,PRMCNT call GETPTR inc cx SGR1: mov al,byte ptr [bx] push bx mov bx,OFFSET GRMODE SGR2: mov ah,byte ptr [bx] add bx,3 cmp ah,0FFH jz SGR3 cmp ah,al jnz SGR2 mov ax,word ptr [bx-2] and ATTR,al or ATTR,AH SGR3: pop bx inc bx loop SGR1 jmp SETCUR IFDEF JAPAN ; ### if JAPAN ### ED: mov bl,dl ; save function no. mov dh,30 mov al,MODE cmp al,11h je ed20 ; if graphic 640X480 cmp al,12h je ed20 ; if graphic 640X480 cmp GRAPHICS_FLAG,GRAPHICS_MODE jnz ed10 ; if not graphic mode mov dh,DEFAULT_LENGTH jmp short ed20 ed10: mov dh,byte ptr [REQ_TXT_LENGTH] ed20: sub dh,row_adj dec dh ; last row mov dl,MAXCOL xor cx,cx cmp bl,0 jz ed_func0 cmp bl,1 jz ed_func1 mov word ptr COL,cx ; ESC[2J jmp short ed_30 ed_func0: ; ESC[0J push dx mov cx,word ptr COL mov dh,ch mov dl,MAXCOL call erase ; erase to eol pop dx mov ch,ROW cmp ch,dh jz ed_end ; if at bottom inc ch mov cl,0 jmp short ed_30 ed_func1: ; ESC[1J mov dx,word ptr COL mov ch,dh mov cl,0 call erase ; erase from top mov dh,ROW cmp dh,0 jz ed_end dec dh mov dl,MAXCOL xor cx,cx ed_30: call erase ed_end: jmp setcur EL: cmp dl,1 jz el_func1 cmp dl,2 jz el_func2 mov cx,word ptr COL ; ESC[0K mov dh,ch mov dl,MAXCOL jmp short el_10 el_func1: mov dx,word ptr COL ; ESC[1K mov ch,dh mov cl,0 jmp short el_10 el_func2: mov ch,ROW ; ESC[2K mov dh,ch mov cl,0 mov dl,MAXCOL el_10: call erase jmp setcur erase: cmp GRAPHICS_FLAG,GRAPHICS_MODE ; if we are in graphics mode, jnz erase10 xor bh,bh ; then use 0 as attribute jmp short erase20 erase10: mov bh,ATTR ; else use ATTR erase20: mov ax,0600H ; clear int 10h ret else ; ### if Not JAPAN ### ED: xor cx,cx mov word ptr COL,cx mov DH,30 mov al,MODE cmp al,11H je ERASE cmp al,12H je ERASE cmp GRAPHICS_FLAG,GRAPHICS_MODE jnz tmplab21 mov dh,DEFAULT_LENGTH jmp short tmplab22 tmplab21: mov dh,byte ptr [REQ_TXT_LENGTH] tmplab22: ERASE: mov DL,MAXCOL cmp GRAPHICS_FLAG,GRAPHICS_MODE ; if we are in graphics mode, jnz tmplab23 xor bh,bh ; then use 0 as attribute jmp short tmplab24 tmplab23: mov bh,ATTR ; else use ATTR tmplab24: mov ax,0600H int 16 ED3: jmp SETCUR EL: mov cx,word ptr COL mov DH,CH jmp ERASE ENDIF ; ### end if Not JAPAN ### IFDEF JAPAN ; ### if JAPAN ### delete: mov ah,6 ; scroll up jmp short insdel insert: mov ah,7 ; scroll down insdel: mov al,cl ; set scroll number mov COL,0 ; set to top of row mov cx,word ptr COL cmp GRAPHICS_FLAG,GRAPHICS_MODE jnz line10 ; if not graphic mode mov dh,DEFAULT_LENGTH xor bh,bh ; attribute jmp short line20 line10: mov bh,ATTR mov dh,byte ptr [REQ_TXT_LENGTH] line20: sub dh,row_adj dec dh mov dl,MAXCOL int 10h ; scroll jmp setcur ENDIF ; ### end if JAPAN ### BIN2ASC:mov DL,10 inc AL xor ah,AH div dl add ax,'00' ret DSR: mov ah,REQ_CRSR_POS push bx xor bh,bh int 10h pop bx push dx mov al,dh ;REPORT CURRENT CURSOR POSITION call BIN2ASC mov word ptr REPORT+2,ax pop dx mov al,DL call BIN2ASC mov word ptr REPORT+5,ax mov [KEYCNT],9 mov [KEYPTR],OFFSET REPORT CPR: jmp S1A RM: mov cl,1 jmp SHORT SM1 SM: xor cx,cx SM1: mov al,DL IFDEF JAPAN cmp new_mode,1 jz nmode ENDIF cmp al,MODE7 ; if mode isn't (0-6, 13-19) jl tmplab25 ; then skip (cas -- signed?) cmp al,MODE13 jl tmplab26 cmp al,MODE19 jg tmplab26 tmplab25: test HDWR_FLAG,LCD_ACTIVE ; is this the LCD? jz tmplab25a ; skip if not push ds ; WGR yes... push ax ; WGR save mode mov ax,ROM_BIOS mov ds,ax ; WGR get equipment status flag.. mov ax,DS:[EQUIP_FLAG] and ax,INIT_VID_MASK ; WGR clear initial video bits.. or ax,LCD_COLOR_MODE ; WGR .....set bits as color mov ds:[EQUIP_FLAG],ax ; WGR replace updated flag. pop ax ; WGR restore mode. pop ds tmplab25a: mov ah,SET_MODE ; WGR yes....set mode.. int 10H jmp short tmplab27 tmplab26: cmp al,7 ; then if 7, wrap at EOL jnz tmplab27 mov [WRAP],CL ; WGR yes....wrap... tmplab27: jmp CPR IFDEF JAPAN ; ### if JAPAN ### nmode: mov new_mode,0 cmp al,1 jz row_mode ; set row mode cmp al,5 jz cur_mode ; set cursor mode jmp cpr row_mode: mov row_adj,0 jcxz row_mode_ret ; if set mode cmp GRAPHICS_FLAG,GRAPHICS_MODE jnz row_mode10 ; if not graphic mode mov ah,DEFAULT_LENGTH jmp short row_mode20 row_mode10: mov ah,byte ptr [REQ_TXT_LENGTH] row_mode20: dec ah cmp row,ah jb row_mode_30 ; if cursor not at bottom row dec row call scroll row_mode_30: inc row_adj row_mode_ret: jmp cpr cur_mode: push cx mov ah,3 ; get cursor mov bh,bpage int 10h pop ax or ax,ax jz cur_mode10 ; if for cursor off and ch,11011111b ; cursor on jmp short cur_mode20 cur_mode10: or ch,00100000b ; corsor off cur_mode20: mov ah,1 ; set cursor int 10h jmp cpr ENDIF ; ### end if JAPAN ### KEYASN: xor dx,dx xchg DL,PRMCNT ;GET CHARACTER COUNT inc dx inc dx call GETPTR mov ax,word ptr [bx] ;GET CHARACTER TO BE ASSIGNED call SCAN ;LOOK IT UP jnz KEYAS1 mov di,bx ;DELETE OLD DEFINITION sub ASNPTR,cx mov KEYCNT,0 ; This delete code shuffles the ; key definition table all around. ; This will cause all sorts of trouble ; if we are in the middle of expanding ; one of the definitions being shuffled. ; So shut off the expansion. mov si,di add si,cx mov cx,OFFSET BUF+ASNMAX sub cx,si cld push es ; SAVE USER'S ES push CS pop es ; SET UP ES addRESSABILITY rep movsb pop es ; RESTORE ES KEYAS1: call GETPTR cmp DL,3 jb KEYAS3 mov byte ptr [bx-1],DL ; SET LENGTH add ASNPTR,dx ; REMEMBER END OF LIST add bx,dx cmp ASNPTR,ASNMAX ; Too much??? jb KEYAS3 ; No sub bx,dx ; Next three instructions undo the above sub ASNPTR,dx KEYAS3: mov byte ptr [bx-1],00 mov STATE,OFFSET S1 ; RETURN ret GETPTR: mov bx,ASNPTR inc bx add bx,PRMCNTW cmp bx,ASNMAX + 8 jb GET1 dec PRMCNT jmp GETPTR GET1: add bx,OFFSET BUF ret ; CHECK_FOR_REMAP: ; This function esnures that the keypacket ; passed to it in AX is mapped to a standard INT16h call CHECK_FOR_REMAP PROC NEAR cmp al,0e0h ; extended key? jnz tmplab28 ifdef KOREA cmp ah, 0f0h jb mschtmp cmp ah, 0f2h jbe tmplab28 mschtmp: endif ; KOREA or ah,ah ; probably, but check for alpha character jz tmplab28 xor al,al ; if not an alpha, map extended to standard tmplab28: ret CHECK_FOR_REMAP ENDP IFDEF DBCS ; Test if the character is DBCS Lead Byte ; input: AL = character to check ; outpit: ZF = 1 if DBCS Lead Byte public DBCSLeadByteTable DBCSLeadByteTable dd 0 IsDBCSLeadByte proc near push ax push si push ds lds si,cs:DBCSLeadByteTable idlb_check: cmp word ptr [si],0 jz idlb_not ; if end of table cmp al,[si] jb idlb_next ; if below low value cmp al,[si+1] jbe idlb_yes ; if below high value idlb_next: add si,2 ; do next jmp short idlb_check idlb_not: or al,1 ; reset ZF jmp short idlb_end idlb_yes: and al,0 ; set ZF idlb_end: pop ds pop si pop ax ret IsDBCSLeadByte endp ENDIF BUF DB 4,00,72H,16,0 DB ASNMAX+8-5 DUP (?) CODE ENDS END 
BetterTouchTool/BetterTouchTool-Library.applescript
ninjakttty/AppleScripts
3
4339
(* =============================================================================== BetterTouchTool Library =============================================================================== Version: 1.0 Updated: 2/18/20, 3:10:44 PM By: <NAME> PURPOSE: This library provides several useful editor functions for BetterTouchTool. • View the GitHub page for explanations and examples - https://github.com/kevin-funderburg/AppleScripts/tree/master/BetterTouchTool REQUIRED: 1. Mac OS X Yosemite 10.10.5+ 2. Mac Applications • BetterTouchTool - https://folivora.ai/ 3. EXTERNAL OSAX Additions/LIBRARIES/FUNCTIONS • None VERSION HISTORY: 1.0 - Initial version. =============================================================================== *) use AppleScript version "2.4" -- Yosemite (10.10) or later use scripting additions use framework "Foundation" property name : "BetterTouchTool Library" property id : "com.kfunderburg.library.betterTouchToolLibrary" property version : "1.0.0" -- classes, constants, and enums used property NSString : a reference to current application's NSString -- modifier key values property mods : {¬ {name:"cmd", symbol:"⌘", value:1048576}, ¬ {name:"opt", symbol:"⌥", value:524288}, ¬ {name:"ctrl", symbol:"⌃", value:262144}, ¬ {name:"shft", symbol:"⇧", value:131072}, ¬ {name:"fn", symbol:"Fn", value:8388608} ¬ } -- hex values of colors commonly used property _colors : {¬ {name:"black", value:"0.000000, 0.000000, 0.000000, 255.000000"}, ¬ {name:"blue", value:"10.000000, 132.000000, 255.000000, 255.000000"}, ¬ {name:"def_background", value:"75.323769, 75.323769, 75.323769, 255.000000"}, ¬ {name:"red", value:"255.000000, 38.028511, 0.000000, 255.000000"}, ¬ {name:"red_transparent", value:"255.000000, 96.000002, 94.000002, 102.000000"}, ¬ {name:"spring", value:"0.000000, 249.085161, 0.000000, 255.000000"}, ¬ {name:"white", value:"255.000000, 255.000000, 255.000000, 255.000000"}, ¬ {name:"lemon", value:"254.853130, 251.316189, 0.000000, 255.000000"} ¬ } -- value of common BTT actions property _actions : {¬ {name:"AppleScript (async)", value:195}, ¬ {name:"AppleScript (blocking)", value:172}, ¬ {name:"Close currently open Touch Bar group", value:191}, ¬ {name:"Select Menu Item", value:124}, ¬ {name:"Toggle BetterTouchTool Touch Bar", value:188} ¬ } -- @description -- constructor for trigger -- on trigger(_uid) script trigger property class : "trigger" property parent : script "BetterTouchTool Library" property uid : _uid property json : missing value on run if isEmpty(_uid) then set json to getTrigger(copyUUID()) set uid to json's BTTUUID else set json to getTrigger(_uid) end if return me end run -- @description -- get JSON of currently selected trigger -- on copyUUID() try set the clipboard to "" delay 0.1 tell application "System Events" click menu item "Copy Selected Item UUID" of menu 1 of menu item "Edit" of menu bar 1 end tell delay 0.1 if (the clipboard) = "" then error number -1000 return the clipboard on error errMsg number errNum if errNum = -1000 then display notification "Select a trigger and try again" with title ¬ "Error: Invalid selection" subtitle ¬ "A trigger must be selected" sound name "Basso" end if end try set json to its convertJSONToAS:(the clipboard) isPath:false end copyUUID -- @return modifier key value of JSON -- on getModKeys() try return json's BTTRequiredModifierKeys on error log "no BTTRequiredModifierKeys" return 0 end try end getModKeys -- @description -- set the modifier keys required for a trigger -- -- @param _mod - modifier key to add: cmd, opt, ctrl, shft, fn, or clear -- on setModKey(_mod) set modSum to getModKeys() log "modSum before: " & modSum if _mod = "clear" then set modSum to 0 else repeat with m in mods if m's name = _mod then set modSum to modSum + (m's value) exit repeat end if end repeat end if updateTrigger({BTTRequiredModifierKeys:modSum}) end setModKey on radius() script radius property radius : missing value property parent : my trigger on run try set radius to json's BTTTriggerConfig's BTTTouchBarButtonCornerRadius on error set radius to 6 -- default radius end try return me end run -- @description -- decrement radius by 1 -- on decrement() setTo(radius - 1) end decrement -- @description -- increment radius by 1 -- on increment() setTo(radius + 1) end increment -- @description -- set radius to value -- -- @param n - value to set radius to -- on setTo(n) updateConfig({BTTTouchBarButtonCornerRadius:n}) display notification "new corner radius: " & n with title "Set Radius" end setTo -- @description -- apply radius to left, all or right edges of button -- -- @param side - left, right or all -- on apply(side) if side = "left" then set n to 1 else if side = "right" then set n to 2 else if side = "all" then set n to 0 else error "invalid side choice: " & side end if updateConfig({BTTTouchBarApplyCornerRadiusTo:n}) end apply end script run radius end radius on freeSpace() script freeSpace property freeSpace : missing value property parent : my trigger on run try set freeSpace to json's BTTTriggerConfig's BTTTouchBarFreeSpaceAfterButton on error log "No freespace variable in JSON" set freeSpace to 5 -- default free space end try return me end run -- @description -- decrement free space after trigger by 1 -- on increment() setTo(freeSpace + 1) end increment -- @description -- increment free space after trigger by 1 -- on decrement() setTo(freeSpace - 1) end decrement -- @description -- set free space of trigger to desired value -- -- @param n - free space value -- on setTo(n) updateConfig({BTTTouchBarFreeSpaceAfterButton:n}) display notification "new freespace: " & n with title "Set Freespace" end setTo end script run freeSpace end freeSpace on padding() script padding property padding : missing value property parent : my trigger on run try set padding to json's BTTTriggerConfig's BTTTouchBarItemPadding on error set padding to 0 -- default padding end try return me end run -- @description -- increment trigger's padding by 1 -- on increment() setTo(padding + 1) end increment -- @description -- decrement trigger's padding by 1 -- on decrement() setTo(padding - 1) end decrement -- @description -- set trigger's padding to desired value -- -- @param n - padding value -- on setTo(n) updateConfig({BTTTouchBarItemPadding:n}) display notification "new padding: " & n with title "Set Padding" end setTo end script run padding end padding on button() script button property parent : my trigger -- @description -- set color of button's background -- -- @param _color - name of color -- on setColor(clr) updateConfig({BTTTouchBarButtonColor:(getColor(clr))}) end setColor -- @description -- set size of button's icon -- NOTE: heigth and width are set to same value -- -- @param _size - size of icon -- on setIconSize(_size) updateConfig({BTTTouchBarItemIconWidth:_size, BTTTouchBarItemIconHeight:_size}) display notification "new icon size: " & _size with title "Set Icon Size" end setIconSize -- @description -- set placement of trigger in touch bar -- -- @param placement - center, left or right -- on placement(placement) if placement = "center" then set p to 0 else if placement = "left" then set p to 1 else if placement = "right" then set p to 2 else error "invalid placement option: " & placement end if updateConfig({BTTTouchBarItemPlacement:p}) end placement -- @description -- sets a trigger's visibility -- -- @param visibility - true, false, or toggle -- on setVisible(visibility) if visibility = true then set n to 1 else if visibility = false then set n to 0 else if visibility = "toggle" then if json's BTTEnabled2 = 0 then set n to 1 else set n to 0 end if end if updateTrigger({BTTEnabled2:n}) end setVisible on toggleIconOnly() try if json's BTTTriggerConfig's BTTTouchBarOnlyShowIcon then set n to false else set n to true end if on error set n to true end try updateConfig({BTTTouchBarOnlyShowIcon:n}) end toggleIconOnly end script end button on _font() script _font property parent : my trigger -- @description -- set size of trigger's font -- -- @param _size - size of font -- on setSize(_size) updateConfig({BTTTouchBarButtonFontSize:_size}) end setSize -- @description -- set color of trigger's font -- -- @param _color - name of color -- on setColor(clr) updateConfig({BTTTouchBarFontColor:(getColor(clr))}) end setColor end script end _font -- @description -- Set the script of a trigger's AppleScript action -- -- @param _script - AppleScript text to insert -- on setInlineAppleScript(_script) updateTrigger({BTTInlineAppleScript:_script}) end setInlineAppleScript -- @description -- add an action to a trigger -- NOTE: not all actions are included, I've only included ones -- that I use frequently -- -- @param act - action to insert -- on addAction(act) updateTrigger(getAction(act)) end addAction -- @description -- Rename a trigger -- -- @param _name - new name -- on rename(_name) updateTrigger({BTTTouchBarButtonName:_name}) end rename -- @description -- update a trigger's JSON configuration -- -- @param update - AppleScript record to update with -- on updateConfig(update) updateTrigger({BTTTriggerConfig:update}) end updateConfig -- @description -- update trigger's JSON -- -- @param update - AppleScript record to update with -- on updateTrigger(update) tell application "BetterTouchTool" to update_trigger uid json my toJSON(update) end updateTrigger end script run trigger end trigger -- @param act - name of action -- @return value of action -- on getAction(act) repeat with a in _actions if a's name = act then return {BTTPredefinedActionType:a's value} end repeat error "Invalid action: " & act end getAction -- @param clr - name of color -- @return hex value of color -- on getColor(clr) repeat with c in _colors if c's name = clr then return c's value end repeat error "Invalid color: " & clr end getColor on updateTBwidget:uid withText:_text iconPath:icPath iconData:icData backgroundColor:bgcolor tell application "BetterTouchTool" to update_touch_bar_widget uid ¬ text _text icon_path icPath icon_data icData background_color getColor(bgcolor) end updateTBwidget:withText:iconPath:iconData:backgroundColor: on refreshWidget(uid) tell application "BetterTouchTool" to refresh_widget uid end refreshWidget on getActiveTBgroup() tell application "BetterTouchTool" to return get_active_touch_bar_group end getActiveTBgroup on triggerAction(act) if isEmpty(act) then error "Invalid action: " & act tell application "BetterTouchTool" to trigger_action my toJSON(my getAction(act)) end triggerAction on getVar(var, _class) if not isEmpty(var) then tell application "BetterTouchTool" if _class = string or _class = text or _class = boolean then set var to get_string_variable var if var = "true" then return true if var = "false" then return false return var else if _class = number or _class = integer or _class = real then return get_number_variable var else error "_class is not a valid class" end if end tell end if error "invalid var: var is empty" end getVar on setVar:var toVal:_val persist:_persist if not isEmpty(var) then tell application "BetterTouchTool" if class of _val = string or class of _val = boolean then if _persist then set _result to set_persistent_string_variable var to _val else set _result to set_string_variable var to _val end if else if class of _val = number or class of _val = integer or class of _val = real then if _persist then set _result to set_persistent_number_variable var to _val else set _result to set_number_variable var to _val end if else error "_class is not a valid class" end if end tell if _result ≠ "success" then error "error: variable " & var & " was not set" end if end setVar:toVal:persist: on executeTrigger(uid) set uid to checkUUID(uid) tell application "BetterTouchTool" to execute_assigned_actions_for_trigger uid end executeTrigger on toggleVar(var) set v to getVar(var, text) if v = "true" then my setVar:var toVal:false persist:true else my setVar:var toVal:true persist:true end if end toggleVar on getTrigger(uid) tell application "BetterTouchTool" to set json to get_trigger uid return my convertJSONToAS:json isPath:false end getTrigger --========================================================== --» Helper Functions --========================================================== -- checks if a value is empty on isEmpty(str) if str is missing value then return true return length of str is 0 end isEmpty -- replace text of string on SearchandReplace(sourceText, replaceThis, withThat) set theString to NSString's stringWithString:sourceText set theString to theString's stringByReplacingOccurrencesOfString:replaceThis withString:withThat return theString as text end SearchandReplace -- pass either a POSIX path to the JSON file, or a JSON string; isPath is a boolean value to tell which on convertJSONToAS:jsonStringOrPath isPath:isPath if isPath then -- read file as data set theData to current application's NSData's dataWithContentsOfFile:jsonStringOrPath else -- it's a string, convert to data set aString to current application's NSString's stringWithString:jsonStringOrPath set theData to aString's dataUsingEncoding:(current application's NSUTF8StringEncoding) end if -- convert to Cocoa object set {theThing, theError} to current application's NSJSONSerialization's JSONObjectWithData:theData options:0 |error|:(reference) if theThing is missing value then error (theError's localizedDescription() as text) number -10000 -- we don't know the class of theThing for coercion, so... set listOfThing to current application's NSArray's arrayWithObject:theThing return item 1 of (theThing as list) end convertJSONToAS:isPath: on toJSON(str) --convert to JSON data set {theData, theError} to current application's NSJSONSerialization's dataWithJSONObject:str options:0 |error|:(reference) if theData is missing value then error (theError's localizedDescription() as text) number -10000 -- convert data to a UTF8 string set someString to current application's NSString's alloc()'s initWithData:theData encoding:(current application's NSUTF8StringEncoding) return someString as text end toJSON
Cubical/HITs/DunceCap/Properties.agda
dan-iel-lee/cubical
0
12800
<reponame>dan-iel-lee/cubical {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.DunceCap.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.HITs.S1 using (S¹; base; decodeEncode) import Cubical.HITs.S1 as S¹ open import Cubical.HITs.MappingCones open import Cubical.HITs.DunceCap.Base -- DunceCone is contractible (easy) Disk : Type₀ Disk = Cone (idfun S¹) isContr-Disk : isContr Disk fst isContr-Disk = hub snd isContr-Disk (inj x) i = spoke x i snd isContr-Disk hub i = hub snd isContr-Disk (spoke x j) i = spoke x (i ∧ j) dunceMap≡id : dunceMap ≡ idfun S¹ dunceMap≡id i base = base dunceMap≡id i (S¹.loop j) = p i j where p : S¹.loop ⁻¹ ∙∙ S¹.loop ∙∙ S¹.loop ≡ S¹.loop p = sym (decodeEncode base (S¹.loop ⁻¹ ∙∙ S¹.loop ∙∙ S¹.loop)) ∙ sym (lUnit S¹.loop) isContr-DunceCone : isContr DunceCone isContr-DunceCone = subst isContr (cong Cone (sym dunceMap≡id)) isContr-Disk -- Dunce is contractible (harder) contrDunce : (d : Dunce) → d ≡ base contrDunce base k = loop k contrDunce (loop i) k = surf k i contrDunce (surf i j) k = hcomp (λ l → λ { (i = i0) → surf k j ; (i = i1) → cube l ; (j = i0) → cube l ; (j = i1) → cube l ; (k = i0) → surf i j ; (k = i1) → base }) (surf (k ∨ i) j) where cube : I → Dunce cube l = hfill (λ i → λ { (k = i0) → loop i ; (k = i1) → base ; (l = i0) → loop (k ∨ i) ; (l = i1) → surf k i }) (inS (loop k)) i isContr-Dunce : isContr Dunce fst isContr-Dunce = base snd isContr-Dunce = sym ∘ contrDunce Dunce≡DunceCone : Dunce ≡ DunceCone Dunce≡DunceCone = ua (isContr→Equiv isContr-Dunce isContr-DunceCone)
AcmeMathLanguage/AcmeMath.g4
marcoparenzan/AcmeMath
1
4910
<reponame>marcoparenzan/AcmeMath grammar AcmeMath; expression : 'true' # boolean | 'false' # boolean | obj # json | arr # json | '?' STRING # jmespath | literal # jumpLiteral | functionCall # call | '(' expression ')' # parenteses | expression '[' expression ']' # subscription | expression '.' IDENTIFIER # attribute | '$' (STRING | IDENTIFIER ('/' IDENTIFIER)*) # getNode | ('-' | '+') expression # sign | expression ('*' | '/' | '%') expression # factor | expression '+' expression # plus | expression '-' expression # minus | expression '^' expression # bitXor | expression ('<' | '>' | '<=' | '>=' | '==' | '!=') expression # comparison | ('!' | 'not') expression # logicNot | expression ('and' | '&&') expression # logicAnd | expression ('or' | '||') expression # logicOr ; obj : '{' pair (',' pair)* '}' | '{' '}' ; pair : STRING ':' expression ; arr : '[' expression (',' expression)* ']' | '[' ']' ; argList : expression (',' expression)* ; functionCall : 'alpha' '(' expression ',' expression ')' # alpha | 'beta' '(' expression ')' # beta | 'gamma' '(' ')' # gamma ; literal : STRING | INTEGER | FLOAT | IDENTIFIER | CONSTANT ; NEWLINE : ( '\r'? '\n' | '\r' | '\f') SPACE? ; IDENTIFIER : [_a-zA-Z][_0-9a-zA-Z]* ; CONSTANT : 'PI' | 'NAN' ; STRING : '"' STRING_CONTENT* '"' | '\'' STRING_CONTENT* '\'' ; fragment STRING_CONTENT : ~[\\\r\n'"] | '\\' [abfnrtv'"\\] | '\\u' HEX HEX HEX HEX ; INTEGER : '0' [xX] HEX+ | DEC+ | '0' [bB] [01]+ ; fragment DEC : [0-9] ; fragment HEX : [0-9a-fA-F] ; FLOAT : DEC? '.' DEC ([eE] [+-] DEC)? | DEC [eE] [+-] DEC ; SKIP_ : (SPACE | COMMENT | LINE_JOINING) -> skip ; fragment SPACE : [ \t]+ ; fragment COMMENT : '#' ~[\r\n]* ; fragment LINE_JOINING : '\\' SPACE? ('\r\n' | [\r\n]) ;
notes/FOT/FOTC/Program/Iter0/PropertiesI.agda
asr/fotc
11
6076
<gh_stars>10-100 ------------------------------------------------------------------------------ -- Properties of the iter₀ function ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.Iter0.PropertiesI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Base.List open import FOTC.Base.PropertiesI open import FOTC.Data.List.PropertiesI open import FOTC.Data.Nat.Type open import FOTC.Data.Nat.List.Type open import FOTC.Program.Iter0.Iter0 open import FOTC.Program.Iter0.PropertiesI ------------------------------------------------------------------------------ {-# TERMINATING #-} iter₀-ListN : ∀ f {n} → N n → (∀ {n} → N n → N (f · n)) → ListN (iter₀ f n) iter₀-ListN f nzero h = subst ListN (sym (iter₀-0 f)) lnnil iter₀-ListN f (nsucc {n} Nn) h = subst ListN (sym prf) (lncons (nsucc Nn) (iter₀-ListN f (h (nsucc Nn)) h)) where prf : iter₀ f (succ₁ n) ≡ succ₁ n ∷ iter₀ f (f · (succ₁ n)) prf = iter₀ f (succ₁ n) ≡⟨ iter₀-eq f (succ₁ n) ⟩ (if (iszero₁ (succ₁ n)) then [] else (succ₁ n ∷ iter₀ f (f · (succ₁ n)))) ≡⟨ ifCong₁ (iszero-S n) ⟩ (if false then [] else (succ₁ n ∷ iter₀ f (f · (succ₁ n)))) ≡⟨ if-false (succ₁ n ∷ iter₀ f (f · (succ₁ n))) ⟩ succ₁ n ∷ iter₀ f (f · (succ₁ n)) ∎
src/Utilities/tokenize-token_vectors.adb
fintatarta/eugen
0
8665
pragma Ada_2012; package body Tokenize.Token_Vectors is --------------- -- To_Vector -- --------------- function To_Vector (X : Token_Array) return Vector is Result : Vector; begin for Tk of X loop Result.Append (To_String (Tk)); end loop; return Result; end To_Vector; end Tokenize.Token_Vectors;
agda/blocked.agda
florence/esterel-calculus
3
6428
module _ where open import utility open import sn-calculus using (all-ready ; bound-ready) open import Data.Product using (∃ ; Σ ; _,_ ; _×_ ; _,′_ ; proj₁ ; proj₂) open import Relation.Binary.PropositionalEquality using (sym ; inspect ; Reveal_·_is_ ; trans) open import Data.Empty open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Context open import Esterel.Environment as Env open import Esterel.Lang.CanFunction using (Canₖ ; module CodeSet ; Canₛ ; Canₛₕ ; Canθₛ ; Canθₛₕ) open import Esterel.Lang.CanFunction.Base using (can-shr-var-irr) open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) renaming (_≟ₛₜ_ to _≟ₛₜₛ_) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) renaming (_≟ₛₜ_ to _≟ₛₜₛₕ_) open import Esterel.Variable.Sequential as SeqVar using (SeqVar ; _ᵥ) open import Esterel.Lang.CanFunction using (Canₖ) open import Data.Product using (_,_) open import Relation.Nullary using (Dec ; yes ; no ; ¬_) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; trans ; sym) import Data.FiniteMap open import Data.List using (List ; [] ; _∷_ ; [_] ; _++_ ; map ; concatMap ; filter) open import Data.List.Any using (Any ; any ; here ; there) open import Data.List.All using (All ; [] ; _∷_) open import Data.OrderedListMap open all-ready open bound-ready data blocked-s : Env → s/l → Set where bbshr-old : ∀{θ s} → (s∈ : Env.isShr∈ s θ) → Env.shr-stats{s} θ s∈ ≡ SharedVar.old → blocked-s θ (shr-ref s) bbshr-new : ∀{θ s} → (s∈ : Env.isShr∈ s θ) → Env.shr-stats{s} θ s∈ ≡ SharedVar.new → blocked-s θ (shr-ref s) -- Note: θ and e are in the opposite order of all-ready definition. -- We directly used Any here as a synonym. Should all-ready be the same? blocked-e : Env → Expr → Set blocked-e θ (plus operators) = Any (blocked-s θ) operators data blocked : Env → Ctrl → Term → Set where bsig-exists : ∀{θ p q A} S S∈ → (sig-stats{S} θ S∈ ≡ Signal.unknown) → ------------------------ blocked θ A (present S ∣⇒ p ∣⇒ q) bpar-both : ∀{θ p q A} → blocked θ A p → blocked θ A q → blocked θ A (p ∥ q) bpar-left : ∀{θ p q A} → blocked θ A p → done q → blocked θ A (p ∥ q) bpar-right : ∀{θ p q A} → done p → blocked θ A q → blocked θ A (p ∥ q) bseq : ∀{θ p q A} → blocked θ A p → blocked θ A (p >> q) bloopˢ : ∀{θ p q A} → blocked θ A p → blocked θ A (loopˢ p q) bsusp : ∀{θ p S A} → blocked θ A p → blocked θ A (suspend p S) btrap : ∀{θ p A} → blocked θ A p → blocked θ A (trap p) bwset : ∀{θ s e} → blocked θ WAIT (s ⇐ e) bwemit : ∀{θ S} → blocked θ WAIT (emit S) bshared : ∀{θ s e p A} → blocked-e θ e → blocked θ A (shared s ≔ e in: p) bsset : ∀{θ s e A} → blocked-e θ e → blocked θ A (s ⇐ e) bvar : ∀{θ x e p A} → blocked-e θ e → blocked θ A (var x ≔ e in: p) bxset : ∀{θ x e A} → blocked-e θ e → blocked θ A (x ≔ e) data manifests-as-non-constructive : Env → Ctrl → Term → Set where mnc : ∀{p θ A} → (blocked-p : blocked θ A p) -- absent rule cannot fire: unknown signals might be emitted at some point → (θS≡unknown→S∈can-p-θ : ∀ S → (S∈Domθ : Signal.unwrap S ∈ fst (Dom θ)) → (θS≡unknown : sig-stats {S} θ S∈Domθ ≡ Signal.unknown) → Signal.unwrap S ∈ Canθₛ (sig θ) 0 p []env) -- readyness rule cannot fire: unready variables might become ready → (θs≡old⊎θs≡new→s∈can-p-θ : ∀ s → (s∈Domθ : SharedVar.unwrap s ∈ snd (Dom θ)) → (θs≡old⊎θs≡new : shr-stats {s} θ s∈Domθ ≡ SharedVar.old ⊎ shr-stats {s} θ s∈Domθ ≡ SharedVar.new) → SharedVar.unwrap s ∈ Canθₛₕ (sig θ) 0 p []env) → manifests-as-non-constructive θ A p halted-blocked-disjoint : ∀ {θ p A} → halted p → blocked θ A p → ⊥ halted-blocked-disjoint hnothin () halted-blocked-disjoint (hexit n) () paused-blocked-disjoint : ∀ {θ A p} → paused p → blocked θ A p → ⊥ paused-blocked-disjoint ppause () paused-blocked-disjoint (pseq p/paused) (bseq p/blocked) = paused-blocked-disjoint p/paused p/blocked paused-blocked-disjoint (ploopˢ p/paused) (bloopˢ p/blocked) = paused-blocked-disjoint p/paused p/blocked paused-blocked-disjoint (ppar p/paused q/paused) (bpar-both p/blocked q/blocked) = paused-blocked-disjoint q/paused q/blocked paused-blocked-disjoint (ppar p/paused q/paused) (bpar-left p/blocked q/done) = paused-blocked-disjoint p/paused p/blocked paused-blocked-disjoint (ppar p/paused q/paused) (bpar-right p/done q/blocked) = paused-blocked-disjoint q/paused q/blocked paused-blocked-disjoint (psuspend p/paused) (bsusp p/blocked) = paused-blocked-disjoint p/paused p/blocked paused-blocked-disjoint (ptrap p/paused) (btrap p/blocked) = paused-blocked-disjoint p/paused p/blocked done-blocked-disjoint : ∀ {θ A p} → done p → blocked θ A p → ⊥ done-blocked-disjoint (dhalted p/halted) p/blocked = halted-blocked-disjoint p/halted p/blocked done-blocked-disjoint (dpaused p/paused) p/blocked = paused-blocked-disjoint p/paused p/blocked -- An expression cannot be both all-ready and blocked-e, i.e. -- all-ready and blocked-e characterize disjoint subsets of e. all-ready-blocked-disjoint : ∀ {e θ} → ¬ (all-ready e θ × blocked-e θ e) all-ready-blocked-disjoint {θ = θ} (aplus (brshr {s = s} s∈ θs≡ready ∷ e/all-ready) , here (bbshr-old {s = .s} s∈' θs≡old)) with trans (sym θs≡ready) (trans (Env.shr-stats-∈-irr {s} {θ} s∈ s∈') θs≡old) ... | () all-ready-blocked-disjoint {θ = θ} (aplus (brshr {s = s} s∈ θs≡ready ∷ e/all-ready) , here (bbshr-new {s = .s} s∈' θs≡new)) with trans (sym θs≡ready) (trans (Env.shr-stats-∈-irr {s} {θ} s∈ s∈') θs≡new) ... | () all-ready-blocked-disjoint {θ = θ} (aplus (px ∷ e/all-ready) , there e/blocked) = all-ready-blocked-disjoint (aplus e/all-ready ,′ e/blocked) -- A subexpression in the hole in a blocked program must be either blocked or done. blocked-⟦⟧e : ∀ {θ p p' E A} → blocked θ A p → p ≐ E ⟦ p' ⟧e → blocked θ A p' ⊎ done p' blocked-⟦⟧e p/blocked dehole = inj₁ p/blocked blocked-⟦⟧e (bseq p/blocked) (deseq p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bloopˢ p/blocked) (deloopˢ p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bsusp p/blocked) (desuspend p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (btrap p/blocked) (detrap p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bpar-both p/blocked q/blocked) (depar₁ p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bpar-left p/blocked q/done) (depar₁ p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bpar-right p/done q/blocked) (depar₁ p≐E⟦p'⟧) = inj₂ (done-⟦⟧e p/done p≐E⟦p'⟧) blocked-⟦⟧e (bpar-both p/blocked q/blocked) (depar₂ q≐E⟦p'⟧) = blocked-⟦⟧e q/blocked q≐E⟦p'⟧ blocked-⟦⟧e (bpar-left p/blocked q/done) (depar₂ q≐E⟦p'⟧) = inj₂ (done-⟦⟧e q/done q≐E⟦p'⟧) blocked-⟦⟧e (bpar-right p/done q/blocked) (depar₂ q≐E⟦p'⟧) = blocked-⟦⟧e q/blocked q≐E⟦p'⟧ blocked-el-dec : ∀ θ l -> Dec (Any (blocked-s θ) l) blocked-el-dec θ [] = no (λ ()) blocked-el-dec θ (num n ∷ l) with blocked-el-dec θ l blocked-el-dec θ (num n ∷ l) | yes p = yes (there p) blocked-el-dec θ (num n ∷ l) | no ¬p = no (λ { (here ()) ; (there x) → ¬p x } ) blocked-el-dec θ (seq-ref x ∷ l) with blocked-el-dec θ l blocked-el-dec θ (seq-ref x ∷ l) | yes p = yes (there p) blocked-el-dec θ (seq-ref x ∷ l) | no ¬p = no (λ { (here ()) ; (there x) → ¬p x }) blocked-el-dec θ (shr-ref s ∷ l) with blocked-el-dec θ l blocked-el-dec θ (shr-ref s ∷ l) | yes p = yes (there p) blocked-el-dec θ (shr-ref s ∷ l) | no ¬p with Env.Shr∈ s θ blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | yes s∈θ with Env.shr-stats{s} θ s∈θ | inspect (Env.shr-stats {s} θ) s∈θ blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | yes s∈θ | SharedVar.ready | Reveal_·_is_.[ eq ] = no (λ { (here (bbshr-old s∈θ₂ eq₂)) → lookup-s-eq θ s s∈θ s∈θ₂ eq eq₂ (λ ()) ; (here (bbshr-new s∈θ₂ eq₂)) → lookup-s-eq θ s s∈θ s∈θ₂ eq eq₂ (λ ()) ; (there x) → ¬p x }) blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | yes s∈θ | SharedVar.new | Reveal_·_is_.[ eq ] = yes (here (bbshr-new s∈θ eq)) blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | yes s∈θ | SharedVar.old | Reveal_·_is_.[ eq ] = yes (here (bbshr-old s∈θ eq)) blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | no ¬s∈θ = no (λ { (here (bbshr-old s∈ x)) → ¬s∈θ s∈ ; (here (bbshr-new s∈ x)) → ¬s∈θ s∈ ; (there x) → ¬p x }) blocked-e-dec : ∀ θ e -> Dec (blocked-e θ e) blocked-e-dec θ (plus l) = blocked-el-dec θ l blocked-dec : ∀ θ A p -> Dec (blocked θ A p) blocked-dec θ A nothin = no (λ ()) blocked-dec θ A pause = no (λ ()) blocked-dec θ A (signl S p) = no (λ ()) blocked-dec θ A (present S ∣⇒ p ∣⇒ q) with Sig∈ S θ blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | yes SigS∈θ with Env.sig-stats{S} θ SigS∈θ | inspect (Env.sig-stats{S} θ) SigS∈θ blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | yes SigS∈θ₁ | Signal.present | Reveal_·_is_.[ eq₁ ] = no (λ { (bsig-exists .S SigS∈θ₂ eq₂) → lookup-S-eq θ S SigS∈θ₁ SigS∈θ₂ eq₁ eq₂ (λ ()) }) blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | yes SigS∈θ₁ | Signal.absent | Reveal_·_is_.[ eq₁ ] = no (λ { (bsig-exists .S SigS∈θ₂ eq₂) → lookup-S-eq θ S SigS∈θ₁ SigS∈θ₂ eq₁ eq₂ (λ ()) } ) blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | yes SigS∈θ | Signal.unknown | Reveal_·_is_.[ eq ] = yes (bsig-exists S SigS∈θ eq) blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | no ¬SigS∈θ = no (λ { (bsig-exists .S S∈ _) → ¬SigS∈θ S∈ }) blocked-dec θ GO (emit S) = no (λ ()) blocked-dec θ WAIT (emit S) = yes bwemit blocked-dec θ A (p ∥ q) with blocked-dec θ A p | blocked-dec θ A q blocked-dec θ A (p ∥ q) | yes blockedp | yes blockedq = yes (bpar-both blockedp blockedq) blocked-dec θ A (p ∥ q) | yes blockedp | no ¬blockedq with done-dec q blocked-dec θ A (p ∥ q) | yes blockedp | no ¬blockedq | yes donep = yes (bpar-left blockedp donep) blocked-dec θ A (p ∥ q) | yes blockedp | no ¬blockedq | no ¬donep = no (λ { (bpar-both _ x) → ¬blockedq x ; (bpar-left _ x) → ¬donep x ; (bpar-right _ x) → ¬blockedq x }) blocked-dec θ A (p ∥ q) | no ¬blockedp | yes blockedq with done-dec p blocked-dec θ A (p ∥ q) | no ¬blockedp | yes blockedq | yes donep = yes (bpar-right donep blockedq) blocked-dec θ A (p ∥ q) | no ¬blockedp | yes blockedq | no ¬donep = no (λ { (bpar-both x _) → ¬blockedp x ; (bpar-left x _) → ¬blockedp x ; (bpar-right x _) → ¬donep x }) blocked-dec θ A (p ∥ q) | no ¬blockedp | no ¬blockedq = no (λ { (bpar-both _ x) → ¬blockedq x ; (bpar-left x _) → ¬blockedp x ; (bpar-right _ x) → ¬blockedq x }) blocked-dec θ A (loop p) = no (λ ()) blocked-dec θ A (p >> q) with blocked-dec θ A p blocked-dec θ A (p >> q) | yes blockedp = yes (bseq blockedp) blocked-dec θ A (p >> q) | no ¬blockedp = no (λ { (bseq x) → ¬blockedp x }) blocked-dec θ A (loopˢ p q) with blocked-dec θ A p blocked-dec θ A (loopˢ p q) | yes blockedp = yes (bloopˢ blockedp) blocked-dec θ A (loopˢ p q) | no ¬blockedp = no (λ { (bloopˢ x) → ¬blockedp x }) blocked-dec θ A (suspend p S) with blocked-dec θ A p blocked-dec θ A (suspend p S) | yes blockedp = yes (bsusp blockedp) blocked-dec θ A (suspend p S) | no ¬blockedp = no (λ { (bsusp x) → ¬blockedp x }) blocked-dec θ A (trap p) with blocked-dec θ A p blocked-dec θ A (trap p) | yes blockedp = yes (btrap blockedp) blocked-dec θ A (trap p) | no ¬blockedp = no (λ { (btrap x) → ¬blockedp x }) blocked-dec θ A (exit x) = no (λ ()) blocked-dec θ A (shared s ≔ e in: p) with blocked-e-dec θ e blocked-dec θ A (shared s ≔ e in: p) | yes blockede = yes (bshared blockede) blocked-dec θ A (shared s ≔ e in: p) | no ¬blockede = no (λ { (bshared x) → ¬blockede x }) blocked-dec θ A (s ⇐ e) with blocked-e-dec θ e blocked-dec θ A (s ⇐ e) | yes p = yes (bsset p) blocked-dec θ GO (s ⇐ e) | no ¬p = no (λ { (bsset x) → ¬p x }) blocked-dec θ WAIT (s ⇐ e) | no ¬p = yes bwset blocked-dec θ A (var x ≔ e in: p) with blocked-e-dec θ e blocked-dec θ A (var x ≔ e in: p₁) | yes p = yes (bvar p) blocked-dec θ A (var x ≔ e in: p) | no ¬p = no (λ { (bvar x₁) → ¬p x₁ }) blocked-dec θ A (x ≔ e) with blocked-e-dec θ e blocked-dec θ A (x ≔ e) | yes p = yes (bxset p) blocked-dec θ A (x ≔ e) | no ¬p = no (λ { (bxset x₁) → ¬p x₁ }) blocked-dec θ A (if x ∣⇒ p ∣⇒ p₁) = no (λ ()) blocked-dec θ A (ρ⟨ θ₁ , A₁ ⟩· p) = no (λ ())
programs/oeis/263/A263390.asm
jmorken/loda
1
172548
; A263390: a(3n) = n, otherwise a(n) = a(floor(2n/3)). ; 0,0,0,1,0,1,2,0,1,3,2,0,4,1,3,5,2,0,6,4,1,7,3,5,8,2,0,9,6,4,10,1,7,11,3,5,12,8,2,13,0,9,14,6,4,15,10,1,16,7,11,17,3,5,18,12,8,19,2,13,20,0,9,21,14,6,22,4,15,23,10,1,24,16,7,25 lpb $0 mov $2,$0 gcd $0,3 add $0,3 mul $0,$2 div $0,6 lpe mov $1,$0 div $1,3
source/slim-messages-aude.ads
reznikmm/slimp
0
23396
-- Copyright (c) 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package Slim.Messages.aude is type Aude_Message is new Message with private; -- Tell the client to enable/disable the audio outputs. procedure Enable_Output (Self : in out Aude_Message); private subtype Byte is Ada.Streams.Stream_Element; type Aude_Message is new Base_Message (Max_8 => 2, Max_16 => 0, Max_32 => 0, Max_64 => 0) with null record; overriding function Read (Data : not null access League.Stream_Element_Vectors.Stream_Element_Vector) return Aude_Message; overriding procedure Write (Self : Aude_Message; Tag : out Message_Tag; Data : out League.Stream_Element_Vectors.Stream_Element_Vector); overriding procedure Visit (Self : not null access Aude_Message; Visiter : in out Slim.Message_Visiters.Visiter'Class); end Slim.Messages.aude;
gcc-gcc-7_3_0-release/gcc/ada/s-auxdec.adb
best08618/asylo
7
4548
<filename>gcc-gcc-7_3_0-release/gcc/ada/s-auxdec.adb ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . A U X _ D E C -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/Or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ pragma Style_Checks (All_Checks); -- Turn off alpha ordering check on subprograms, this unit is laid -- out to correspond to the declarations in the DEC 83 System unit. with System.Soft_Links; package body System.Aux_DEC is package SSL renames System.Soft_Links; ----------------------------------- -- Operations on Largest_Integer -- ----------------------------------- -- It would be nice to replace these with intrinsics, but that does -- not work yet (the back end would be ok, but GNAT itself objects) type LIU is mod 2 ** Largest_Integer'Size; -- Unsigned type of same length as Largest_Integer function To_LI is new Ada.Unchecked_Conversion (LIU, Largest_Integer); function From_LI is new Ada.Unchecked_Conversion (Largest_Integer, LIU); function "not" (Left : Largest_Integer) return Largest_Integer is begin return To_LI (not From_LI (Left)); end "not"; function "and" (Left, Right : Largest_Integer) return Largest_Integer is begin return To_LI (From_LI (Left) and From_LI (Right)); end "and"; function "or" (Left, Right : Largest_Integer) return Largest_Integer is begin return To_LI (From_LI (Left) or From_LI (Right)); end "or"; function "xor" (Left, Right : Largest_Integer) return Largest_Integer is begin return To_LI (From_LI (Left) xor From_LI (Right)); end "xor"; -------------------------------------- -- Arithmetic Operations on Address -- -------------------------------------- -- It would be nice to replace these with intrinsics, but that does -- not work yet (the back end would be ok, but GNAT itself objects) Asiz : constant Integer := Integer (Address'Size) - 1; type SA is range -(2 ** Asiz) .. 2 ** Asiz - 1; -- Signed type of same size as Address function To_A is new Ada.Unchecked_Conversion (SA, Address); function From_A is new Ada.Unchecked_Conversion (Address, SA); function "+" (Left : Address; Right : Integer) return Address is begin return To_A (From_A (Left) + SA (Right)); end "+"; function "+" (Left : Integer; Right : Address) return Address is begin return To_A (SA (Left) + From_A (Right)); end "+"; function "-" (Left : Address; Right : Address) return Integer is pragma Unsuppress (All_Checks); -- Because this can raise Constraint_Error for 64-bit addresses begin return Integer (From_A (Left) - From_A (Right)); end "-"; function "-" (Left : Address; Right : Integer) return Address is begin return To_A (From_A (Left) - SA (Right)); end "-"; ------------------------ -- Fetch_From_Address -- ------------------------ function Fetch_From_Address (A : Address) return Target is type T_Ptr is access all Target; function To_T_Ptr is new Ada.Unchecked_Conversion (Address, T_Ptr); Ptr : constant T_Ptr := To_T_Ptr (A); begin return Ptr.all; end Fetch_From_Address; ----------------------- -- Assign_To_Address -- ----------------------- procedure Assign_To_Address (A : Address; T : Target) is type T_Ptr is access all Target; function To_T_Ptr is new Ada.Unchecked_Conversion (Address, T_Ptr); Ptr : constant T_Ptr := To_T_Ptr (A); begin Ptr.all := T; end Assign_To_Address; --------------------------------- -- Operations on Unsigned_Byte -- --------------------------------- -- It would be nice to replace these with intrinsics, but that does -- not work yet (the back end would be ok, but GNAT itself objects) type BU is mod 2 ** Unsigned_Byte'Size; -- Unsigned type of same length as Unsigned_Byte function To_B is new Ada.Unchecked_Conversion (BU, Unsigned_Byte); function From_B is new Ada.Unchecked_Conversion (Unsigned_Byte, BU); function "not" (Left : Unsigned_Byte) return Unsigned_Byte is begin return To_B (not From_B (Left)); end "not"; function "and" (Left, Right : Unsigned_Byte) return Unsigned_Byte is begin return To_B (From_B (Left) and From_B (Right)); end "and"; function "or" (Left, Right : Unsigned_Byte) return Unsigned_Byte is begin return To_B (From_B (Left) or From_B (Right)); end "or"; function "xor" (Left, Right : Unsigned_Byte) return Unsigned_Byte is begin return To_B (From_B (Left) xor From_B (Right)); end "xor"; --------------------------------- -- Operations on Unsigned_Word -- --------------------------------- -- It would be nice to replace these with intrinsics, but that does -- not work yet (the back end would be ok, but GNAT itself objects) type WU is mod 2 ** Unsigned_Word'Size; -- Unsigned type of same length as Unsigned_Word function To_W is new Ada.Unchecked_Conversion (WU, Unsigned_Word); function From_W is new Ada.Unchecked_Conversion (Unsigned_Word, WU); function "not" (Left : Unsigned_Word) return Unsigned_Word is begin return To_W (not From_W (Left)); end "not"; function "and" (Left, Right : Unsigned_Word) return Unsigned_Word is begin return To_W (From_W (Left) and From_W (Right)); end "and"; function "or" (Left, Right : Unsigned_Word) return Unsigned_Word is begin return To_W (From_W (Left) or From_W (Right)); end "or"; function "xor" (Left, Right : Unsigned_Word) return Unsigned_Word is begin return To_W (From_W (Left) xor From_W (Right)); end "xor"; ------------------------------------- -- Operations on Unsigned_Longword -- ------------------------------------- -- It would be nice to replace these with intrinsics, but that does -- not work yet (the back end would be ok, but GNAT itself objects) type LWU is mod 2 ** Unsigned_Longword'Size; -- Unsigned type of same length as Unsigned_Longword function To_LW is new Ada.Unchecked_Conversion (LWU, Unsigned_Longword); function From_LW is new Ada.Unchecked_Conversion (Unsigned_Longword, LWU); function "not" (Left : Unsigned_Longword) return Unsigned_Longword is begin return To_LW (not From_LW (Left)); end "not"; function "and" (Left, Right : Unsigned_Longword) return Unsigned_Longword is begin return To_LW (From_LW (Left) and From_LW (Right)); end "and"; function "or" (Left, Right : Unsigned_Longword) return Unsigned_Longword is begin return To_LW (From_LW (Left) or From_LW (Right)); end "or"; function "xor" (Left, Right : Unsigned_Longword) return Unsigned_Longword is begin return To_LW (From_LW (Left) xor From_LW (Right)); end "xor"; ------------------------------- -- Operations on Unsigned_32 -- ------------------------------- -- It would be nice to replace these with intrinsics, but that does -- not work yet (the back end would be ok, but GNAT itself objects) type U32 is mod 2 ** Unsigned_32'Size; -- Unsigned type of same length as Unsigned_32 function To_U32 is new Ada.Unchecked_Conversion (U32, Unsigned_32); function From_U32 is new Ada.Unchecked_Conversion (Unsigned_32, U32); function "not" (Left : Unsigned_32) return Unsigned_32 is begin return To_U32 (not From_U32 (Left)); end "not"; function "and" (Left, Right : Unsigned_32) return Unsigned_32 is begin return To_U32 (From_U32 (Left) and From_U32 (Right)); end "and"; function "or" (Left, Right : Unsigned_32) return Unsigned_32 is begin return To_U32 (From_U32 (Left) or From_U32 (Right)); end "or"; function "xor" (Left, Right : Unsigned_32) return Unsigned_32 is begin return To_U32 (From_U32 (Left) xor From_U32 (Right)); end "xor"; ------------------------------------- -- Operations on Unsigned_Quadword -- ------------------------------------- -- It would be nice to replace these with intrinsics, but that does -- not work yet (the back end would be ok, but GNAT itself objects) type QWU is mod 2 ** 64; -- 64 = Unsigned_Quadword'Size -- Unsigned type of same length as Unsigned_Quadword function To_QW is new Ada.Unchecked_Conversion (QWU, Unsigned_Quadword); function From_QW is new Ada.Unchecked_Conversion (Unsigned_Quadword, QWU); function "not" (Left : Unsigned_Quadword) return Unsigned_Quadword is begin return To_QW (not From_QW (Left)); end "not"; function "and" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword is begin return To_QW (From_QW (Left) and From_QW (Right)); end "and"; function "or" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword is begin return To_QW (From_QW (Left) or From_QW (Right)); end "or"; function "xor" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword is begin return To_QW (From_QW (Left) xor From_QW (Right)); end "xor"; ----------------------- -- Clear_Interlocked -- ----------------------- procedure Clear_Interlocked (Bit : in out Boolean; Old_Value : out Boolean) is begin SSL.Lock_Task.all; Old_Value := Bit; Bit := False; SSL.Unlock_Task.all; end Clear_Interlocked; procedure Clear_Interlocked (Bit : in out Boolean; Old_Value : out Boolean; Retry_Count : Natural; Success_Flag : out Boolean) is pragma Warnings (Off, Retry_Count); begin SSL.Lock_Task.all; Old_Value := Bit; Bit := False; Success_Flag := True; SSL.Unlock_Task.all; end Clear_Interlocked; --------------------- -- Set_Interlocked -- --------------------- procedure Set_Interlocked (Bit : in out Boolean; Old_Value : out Boolean) is begin SSL.Lock_Task.all; Old_Value := Bit; Bit := True; SSL.Unlock_Task.all; end Set_Interlocked; procedure Set_Interlocked (Bit : in out Boolean; Old_Value : out Boolean; Retry_Count : Natural; Success_Flag : out Boolean) is pragma Warnings (Off, Retry_Count); begin SSL.Lock_Task.all; Old_Value := Bit; Bit := True; Success_Flag := True; SSL.Unlock_Task.all; end Set_Interlocked; --------------------- -- Add_Interlocked -- --------------------- procedure Add_Interlocked (Addend : Short_Integer; Augend : in out Aligned_Word; Sign : out Integer) is begin SSL.Lock_Task.all; Augend.Value := Augend.Value + Addend; if Augend.Value < 0 then Sign := -1; elsif Augend.Value > 0 then Sign := +1; else Sign := 0; end if; SSL.Unlock_Task.all; end Add_Interlocked; ---------------- -- Add_Atomic -- ---------------- procedure Add_Atomic (To : in out Aligned_Integer; Amount : Integer) is begin SSL.Lock_Task.all; To.Value := To.Value + Amount; SSL.Unlock_Task.all; end Add_Atomic; procedure Add_Atomic (To : in out Aligned_Integer; Amount : Integer; Retry_Count : Natural; Old_Value : out Integer; Success_Flag : out Boolean) is pragma Warnings (Off, Retry_Count); begin SSL.Lock_Task.all; Old_Value := To.Value; To.Value := To.Value + Amount; Success_Flag := True; SSL.Unlock_Task.all; end Add_Atomic; procedure Add_Atomic (To : in out Aligned_Long_Integer; Amount : Long_Integer) is begin SSL.Lock_Task.all; To.Value := To.Value + Amount; SSL.Unlock_Task.all; end Add_Atomic; procedure Add_Atomic (To : in out Aligned_Long_Integer; Amount : Long_Integer; Retry_Count : Natural; Old_Value : out Long_Integer; Success_Flag : out Boolean) is pragma Warnings (Off, Retry_Count); begin SSL.Lock_Task.all; Old_Value := To.Value; To.Value := To.Value + Amount; Success_Flag := True; SSL.Unlock_Task.all; end Add_Atomic; ---------------- -- And_Atomic -- ---------------- type IU is mod 2 ** Integer'Size; type LU is mod 2 ** Long_Integer'Size; function To_IU is new Ada.Unchecked_Conversion (Integer, IU); function From_IU is new Ada.Unchecked_Conversion (IU, Integer); function To_LU is new Ada.Unchecked_Conversion (Long_Integer, LU); function From_LU is new Ada.Unchecked_Conversion (LU, Long_Integer); procedure And_Atomic (To : in out Aligned_Integer; From : Integer) is begin SSL.Lock_Task.all; To.Value := From_IU (To_IU (To.Value) and To_IU (From)); SSL.Unlock_Task.all; end And_Atomic; procedure And_Atomic (To : in out Aligned_Integer; From : Integer; Retry_Count : Natural; Old_Value : out Integer; Success_Flag : out Boolean) is pragma Warnings (Off, Retry_Count); begin SSL.Lock_Task.all; Old_Value := To.Value; To.Value := From_IU (To_IU (To.Value) and To_IU (From)); Success_Flag := True; SSL.Unlock_Task.all; end And_Atomic; procedure And_Atomic (To : in out Aligned_Long_Integer; From : Long_Integer) is begin SSL.Lock_Task.all; To.Value := From_LU (To_LU (To.Value) and To_LU (From)); SSL.Unlock_Task.all; end And_Atomic; procedure And_Atomic (To : in out Aligned_Long_Integer; From : Long_Integer; Retry_Count : Natural; Old_Value : out Long_Integer; Success_Flag : out Boolean) is pragma Warnings (Off, Retry_Count); begin SSL.Lock_Task.all; Old_Value := To.Value; To.Value := From_LU (To_LU (To.Value) and To_LU (From)); Success_Flag := True; SSL.Unlock_Task.all; end And_Atomic; --------------- -- Or_Atomic -- --------------- procedure Or_Atomic (To : in out Aligned_Integer; From : Integer) is begin SSL.Lock_Task.all; To.Value := From_IU (To_IU (To.Value) or To_IU (From)); SSL.Unlock_Task.all; end Or_Atomic; procedure Or_Atomic (To : in out Aligned_Integer; From : Integer; Retry_Count : Natural; Old_Value : out Integer; Success_Flag : out Boolean) is pragma Warnings (Off, Retry_Count); begin SSL.Lock_Task.all; Old_Value := To.Value; To.Value := From_IU (To_IU (To.Value) or To_IU (From)); Success_Flag := True; SSL.Unlock_Task.all; end Or_Atomic; procedure Or_Atomic (To : in out Aligned_Long_Integer; From : Long_Integer) is begin SSL.Lock_Task.all; To.Value := From_LU (To_LU (To.Value) or To_LU (From)); SSL.Unlock_Task.all; end Or_Atomic; procedure Or_Atomic (To : in out Aligned_Long_Integer; From : Long_Integer; Retry_Count : Natural; Old_Value : out Long_Integer; Success_Flag : out Boolean) is pragma Warnings (Off, Retry_Count); begin SSL.Lock_Task.all; Old_Value := To.Value; To.Value := From_LU (To_LU (To.Value) or To_LU (From)); Success_Flag := True; SSL.Unlock_Task.all; end Or_Atomic; ------------------------------------ -- Declarations for Queue Objects -- ------------------------------------ type QR; type QR_Ptr is access QR; type QR is record Forward : QR_Ptr; Backward : QR_Ptr; end record; function To_QR_Ptr is new Ada.Unchecked_Conversion (Address, QR_Ptr); function From_QR_Ptr is new Ada.Unchecked_Conversion (QR_Ptr, Address); ------------ -- Insqhi -- ------------ procedure Insqhi (Item : Address; Header : Address; Status : out Insq_Status) is Hedr : constant QR_Ptr := To_QR_Ptr (Header); Next : constant QR_Ptr := Hedr.Forward; Itm : constant QR_Ptr := To_QR_Ptr (Item); begin SSL.Lock_Task.all; Itm.Forward := Next; Itm.Backward := Hedr; Hedr.Forward := Itm; if Next = null then Status := OK_First; else Next.Backward := Itm; Status := OK_Not_First; end if; SSL.Unlock_Task.all; end Insqhi; ------------ -- Remqhi -- ------------ procedure Remqhi (Header : Address; Item : out Address; Status : out Remq_Status) is Hedr : constant QR_Ptr := To_QR_Ptr (Header); Next : constant QR_Ptr := Hedr.Forward; begin SSL.Lock_Task.all; Item := From_QR_Ptr (Next); if Next = null then Status := Fail_Was_Empty; else Hedr.Forward := To_QR_Ptr (Item).Forward; if Hedr.Forward = null then Status := OK_Empty; else Hedr.Forward.Backward := Hedr; Status := OK_Not_Empty; end if; end if; SSL.Unlock_Task.all; end Remqhi; ------------ -- Insqti -- ------------ procedure Insqti (Item : Address; Header : Address; Status : out Insq_Status) is Hedr : constant QR_Ptr := To_QR_Ptr (Header); Prev : constant QR_Ptr := Hedr.Backward; Itm : constant QR_Ptr := To_QR_Ptr (Item); begin SSL.Lock_Task.all; Itm.Backward := Prev; Itm.Forward := Hedr; Hedr.Backward := Itm; if Prev = null then Status := OK_First; else Prev.Forward := Itm; Status := OK_Not_First; end if; SSL.Unlock_Task.all; end Insqti; ------------ -- Remqti -- ------------ procedure Remqti (Header : Address; Item : out Address; Status : out Remq_Status) is Hedr : constant QR_Ptr := To_QR_Ptr (Header); Prev : constant QR_Ptr := Hedr.Backward; begin SSL.Lock_Task.all; Item := From_QR_Ptr (Prev); if Prev = null then Status := Fail_Was_Empty; else Hedr.Backward := To_QR_Ptr (Item).Backward; if Hedr.Backward = null then Status := OK_Empty; else Hedr.Backward.Forward := Hedr; Status := OK_Not_Empty; end if; end if; SSL.Unlock_Task.all; end Remqti; end System.Aux_DEC;
appendable-coordination.als
experimental-dustbin/alloy-models
9
2389
// We will be dealing with sequences of events and states indexed by time open util/ordering[Time] // Events and states will be ordered/indexed by Time some sig Time { } // An event happens at a point in time and is related to some nodes abstract sig Event { nodes: Node set -> Time } { // All events must happen before we run out of time no nodes.last } // There are 2 events sent/created by nodes: Reset, Register some sig Register extends Event { } some sig Reset extends Event { } some sig Node { } { // The reset event must happen only once one (Reset.nodes[this]) // Register and reset events don't overlap no (Reset.nodes[this] & Register.nodes[this]) // All register events must happen after the one reset event Register.nodes[this] in Reset.nodes[this].nexts // There must be at least one point in time where the node registers. // This means our nodes are "live" some Register.nodes[this] } // The state consists of a set of registered nodes at some point in time some sig State { time: Time, registrants: Node set -> time } // We have 1-1 mapping between State and Time fact { time in State one -> one Time } // The transition relations that specifies what happens to the state at // successive points in time given what events are happening at the // current time. pred transition(t, t': Time) { some (Reset.nodes.t) => { // Reset event clears the registrants at the next point in time no State.registrants.t' } else { // Otherwise there are no reset events at this time so register the nodes State.registrants.t' = State.registrants.t + Register.nodes.t } } fact { no State.registrants.first all t: Time, t': t.next | transition[t, t'] } //check { // Node in State.registrants.last //} for exactly 2 Node, 5 Time, 5 State, 5 Event // Make sure the states are consistent run { Node in State.registrants.last } for exactly 2 Node, 3 Time, 3 State, 3 Event
projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_nxos/CiscoNxos_common.g4
nickgian/batfish
0
6115
<reponame>nickgian/batfish<gh_stars>0 parser grammar CiscoNxos_common; options { tokenVocab = CiscoNxosLexer; } bgp_asn : large = uint32 | high = uint16 PERIOD low = uint16 ; // Shared NX-OS syntax for route-target, redistribution, route leak, etc. both_export_import : BOTH | EXPORT | IMPORT ; cisco_nxos_password : // Lexer mode change required prior to entering this rule PASSWORD_0? text = PASSWORD_0_TEXT | PASSWORD_3 ( text = PASSWORD_3_TEXT | malformed = PASSWORD_3_MALFORMED_TEXT ) | PASSWORD_7 ( PASSWORD_7_TEXT | malformed = PASSWORD_7_MALFORMED_TEXT ) ; class_map_cp_name : // 1-64 characters WORD ; class_map_network_qos_name : // 1-40 characters WORD ; class_map_qos_name : // 1-40 characters WORD ; class_map_queuing_name : // 1-40 characters WORD ; double_quoted_string : DOUBLE_QUOTE text = quoted_text? DOUBLE_QUOTE ; fex_id : // 101-199 uint8 ; // ip or mac access-list generic_access_list_name : // 1-64 characters WORD ; group_name : // 1-32 characters WORD ; hex_uint32 : HEX_UINT32 ; hsrp_name : // 1-250 characters WORD ; interface_address : address = ip_address mask = subnet_mask | iaddress = ip_prefix ; interface_ipv6_address : address6_with_length = ipv6_prefix ; interface_name : prefix = interface_prefix middle = interface_middle? parent_suffix = interface_parent_suffix? first = uint16 ; interface_prefix : ETHERNET | LOOPBACK | MGMT | PORT_CHANNEL | VLAN ; interface_middle : ( uint8 FORWARD_SLASH )+ ; interface_parent_suffix : num = uint16 period = PERIOD ; ip_access_list_name : // 1-64 characters WORD ; ip_address : IP_ADDRESS | SUBNET_MASK ; ip_as_path_access_list_name : // 1-63 characters WORD ; ip_community_list_name : // 1-63 characters WORD ; ip_prefix : IP_PREFIX ; ip_prefix_list_description : // 1-90 chars REMARK_TEXT ; ip_prefix_list_name : // 1-63 chars WORD ; ip_prefix_list_line_number : // 1-4294967294 uint32 ; ipv6_address : IPV6_ADDRESS ; ipv6_prefix : IPV6_PREFIX ; key_chain_name : // 1-63 characters WORD ; line_action : deny = DENY | permit = PERMIT ; literal_standard_community : high = uint16 COLON low = uint16 ; mac_access_list_name : // 1-64 characters WORD ; mac_address_literal : MAC_ADDRESS_LITERAL ; maximum_paths : // 1-64 UINT8 ; md5_string : // 1-15 characters WORD ; monitor_session_id : // 1-32 uint8 ; null_rest_of_line : ~NEWLINE* NEWLINE ; nve_interface_name : NVE first = uint8 ; ospf_area_default_cost : // 0-16777215 uint32 ; ospf_area_id : num = uint32 | ip = ip_address ; ospf_area_range_cost : // 0-16777215 uint32 ; ospf_max_metric_external_lsa : // 1-16777215 uint32 ; ospf_on_startup_wait_period : // 5-86400 uint32 ; ospf_ref_bw_gbps : // 1-4000 uint16 ; ospf_ref_bw_mbps : // 1-4,000,000 uint32 ; policy_map_cp_name : // 1-64 characters WORD ; policy_map_network_qos_name : // 1-40 characters WORD ; policy_map_qos_name : // 1-40 characters WORD ; policy_map_queuing_name : // 1-40 characters WORD ; qos_group : // 0-7 uint8 ; quoted_text : QUOTED_TEXT ; route_distinguisher : // The order of these rules is significant: 1:1 should be parsed as type 0, not type 2. // That string matches both rules with the same number of tokens; ANTLR4 will prefer the first one. hi0 = uint16 COLON lo0 = uint32 | hi1 = ip_address COLON lo1 = uint16 | hi2 = uint32 COLON lo2 = uint16 ; route_distinguisher_or_auto : AUTO | route_distinguisher ; route_map_name : // 1-63 chars WORD ; route_network : address = ip_address mask = subnet_mask | prefix = ip_prefix ; router_eigrp_process_tag : // 1-20 characters WORD ; router_isis_process_tag : // 1-20 characters WORD ; router_ospf_name : // 1-20 characters WORD ; router_ospfv3_name : // 1-20 characters WORD ; router_rip_process_id : // 1-20 characters WORD ; bgp_instance : BGP bgp_asn ; eigrp_instance : EIGRP router_eigrp_process_tag ; isis_instance : ISIS router_isis_process_tag ; ospf_instance : OSPF router_ospf_name ; ospfv3_instance : OSPFV3 router_ospfv3_name ; // The admin distance (static route calls it preference) for a non-local/direct route. protocol_distance : // 1-255 uint8 ; rip_instance : RIP router_rip_process_id ; routing_instance_v4 : DIRECT | bgp_instance | eigrp_instance | isis_instance | LISP | ospf_instance | rip_instance | STATIC ; routing_instance_v6 : DIRECT | bgp_instance | eigrp_instance | isis_instance | LISP | ospfv3_instance | rip_instance | STATIC ; route_target : hi0 = uint16 COLON lo0 = uint32 | hi2 = uint32 COLON lo2 = uint16 ; route_target_or_auto : AUTO | route_target ; standard_community : literal = literal_standard_community | INTERNET | LOCAL_AS | NO_ADVERTISE | NO_EXPORT ; subdomain_name : SUBDOMAIN_NAME ; subnet_mask : SUBNET_MASK ; tcp_port_number : // 0-65535 uint32 ; template_name : // 1-80 chars WORD ; track_object_number : // 1-512 uint16 ; uint8 : UINT8 ; uint16 : UINT8 | UINT16 ; uint32 : UINT8 | UINT16 | UINT32 ; uint8_range_set : ranges += uint8_range ( COMMA ranges += uint8_range )* ; uint8_range : low = uint8 ( DASH high = uint8 )? ; user_name : // 1-32 characters WORD ; user_password : WORD // 1-127 characters ; unreserved_vlan_id : // 1-4094, minus the 128 vlans currently reserved uint16 ; unreserved_vlan_id_range : intervals += unreserved_vlan_id_interval ( COMMA intervals += unreserved_vlan_id_interval )* ; unreserved_vlan_id_interval : low = unreserved_vlan_id ( DASH high = unreserved_vlan_id )? ; vlan_id : // 1-4094 uint16 ; vlan_id_range : intervals += vlan_id_interval ( COMMA intervals += vlan_id_interval )* ; vlan_id_interval : low = vlan_id ( DASH high = vlan_id )? ; vni_number : // 0-16777214 uint32 ; vrf_name : WORD ; vrf_non_default_name : WORD ;