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
|
---|---|---|---|---|
programs/oeis/147/A147845.asm | karttu/loda | 1 | 25353 | ; A147845: Odd positive integers a(n) such that for every odd integer m>=7 there exists a unique representation of the form m=a(p)+2a(q)+4a(r)
; 1,3,17,19,129,131,145,147,1025,1027,1041,1043,1153,1155,1169,1171,8193,8195,8209,8211,8321,8323,8337,8339,9217,9219,9233,9235,9345,9347,9361,9363,65537,65539,65553,65555
add $0,8190
cal $0,32929 ; Numbers whose set of base 8 digits is {1,2}.
sub $0,1
mov $1,$0
sub $1,78536544840
mul $1,2
add $1,1
|
PRU_SPI.asm | kiorpesc/BBB-PRU-SPI | 1 | 86928 | // on am335x, this MUST be run on PRU1
// output pins should be set to mode 0x05 (in proper Command Register location in CortexA8)
// input pins should be set to mode 0x36 (input enabled, pullup enabled, mode 6)
.origin 0
.entrypoint _main
#include "PRU_SPI.hp"
#include "config.hp"
#define DEBUG
// entry point, sets up the PRU memory and begins polling for SPI transactions
_main:
// set memory start into MEM_START register
LDI MEM_START, PRU1_MEMSTART
// set all cs pins high
LDI CS_PINS, 0xFF
LDI r20, 0
SET r20.t28
ledWait:
QBEQ endLEDWait, r20, 0
SUB r20, r20, 1
JMP ledWait
endLEDWait:
CLR CS_PINS, 1
#ifdef DEBUG
LDI r21, 0 // count transactions
_loadBogusData:
LDI TRANS_BUF_START.b0, 0x21 // read command
LDI TRANS_BUF_START.b1, 0x02 // I2C clock
LDI TRANS_BUF_START.b2, 0x44 // junk
LDI TRANS_BUF_START.b3, 0x00 // space
LDI TRANS_TOTAL, 4 // 4 bytes
LDI SPEED_MHZ, 1 // 1MHz
LDI r1.b0, 2 // MODE_2
SET r1.t31 // set ready bit
LDI r3, 0
NOT r3, r3
XOUT SCRATCH_1, r1, 12 // move r1, r2 to scratch pad
_resetCP2120:
// reset CP2120 by setting RESET low for at least 15us
CLR CS_PINS, 7
SET CS_PINS, 1 //LED on
LDI ITER, 5000 // 25us
holdReset:
QBEQ endReset, ITER, 0
SUB ITER, ITER, 1
JMP holdReset
endReset:
SET CS_PINS, 7
CLR CS_PINS, 1 // LED off
#endif
// if ready bit is one, there is a transaction waiting
// this also indicates to the other core that a transaction
// is in progress, preventing the register from being overwritten
poll:
XIN SCRATCH_1, r1, 4
QBBC poll, READY_BIT
////////////////////////////////////////////////////////////
// _spi_setup:
// gets the information from the other PRU core and loads
// it into this PRU's registers and memory to prepare for
// the spi transaction, then selects the correct transaction
// function based on the mode.
////////////////////////////////////////////////////////////
_spi_setup:
// get information from info register and store locally
XIN SCRATCH_1, r1, 4
// R1 now contains the SPI transfer information
MOV MODE_REG, r1.b0 // move the value of mode and deviceID into the mode register
LSR ID_REG, MODE_REG, 2 // put the device id into its own byte
AND MODE_REG, MODE_REG, 0b11 // clear the upper 6 bits of the mode byte
XIN SCRATCH_1, TRANS_BUF_START, TRANS_MAX // load scratch pad data into PRU registers
SBBO TRANS_BUF_START, MEM_START, 0, TRANS_MAX // then store it into PRU memory
QBEQ no_speed, SPEED_MHZ, 0 // prevent accidental infinite loop if speed is set to zero
LDI TEMP_BYTE, PRU_CLOCK_MHZ
LDI ITER, 0 // count subtractions
// this bit takes a bunch of extra cycles, there should be a better way to handle speed
// TODO: define speeds as constants containing the number of cycles to wait
div_by_sub:
QBGE cycles, TEMP_BYTE, 0
SUB TEMP_BYTE, TEMP_BYTE, SPEED_MHZ
ADD ITER, ITER, 1
JMP div_by_sub
cycles:
MOV CYCLES_TO_WAIT, ITER // we have determined how many PRU cycles per clock cycle
SUB CYCLES_TO_WAIT, CYCLES_TO_WAIT, 40 // subtract built-in wait
LSR CYCLES_TO_WAIT, CYCLES_TO_WAIT, 1 // div by 2
QBEQ _mode0, MODE_REG, 0
QBEQ _mode1, MODE_REG, 1
QBEQ _mode2, MODE_REG, 2
QBEQ _mode3, MODE_REG, 3
no_speed:
end_transaction:
LBBO TRANS_BUF_START, MEM_START, 0, TRANS_MAX
XOUT SCRATCH_1, TRANS_BUF_START, TRANS_MAX
LDI r1, 0 // clear setup register
XOUT SCRATCH_1, r1, 4 // write setup register
ADD r21, r21, 1
LDI r20, 0
NOT r20, r20
SBBO r20, MEM_START, 64, 4
JMP poll // wait for a new transaction
////////////////////////////////////////////////////////////
// _byteTransition:
// store the full RX_BYTE into the current byte in memory,
// then move to and load the next byte in memory,
// resetting the iterator to 7 (to handle MSB)
////////////////////////////////////////////////////////////
_byteTransition:
// store the current received byte
SBBO RX_BYTE, MEM_START, TRANS_COUNTER, 1
// get the next transmit byte
ADD TRANS_COUNTER, TRANS_COUNTER, 1 // move to next byte
LBBO TX_BYTE, MEM_START, TRANS_COUNTER, 1 // load next byte
LDI BIT_ITER, 7 // BIT_ITER = 7
JMP RET_ADDR // return
////////////////////////////////////////////////////////////
// _waitLong:
// occurs after all the operations in a normal clock cycle
// when a byteTransition is not occurring.
// this wait adds an additional 9 PRU cycles to the
// short wait
// the code runs right into waitShort, since the short wait
// is still needed after the extra 9 cycles
////////////////////////////////////////////////////////////
_waitLong: // assume we have started with 8 cycles used (in reality, can be 8 or 9, jitter ~5ns)
NOOP
LDI ITER, 2
waitLongLoop:
QBEQ _waitShort, ITER, 0
SUB ITER, ITER, 1
JMP waitLongLoop
// add 9 cycles -> 17 cycles
_waitShort:
LDI ITER, 0 //18
// if clock MHz >= our max clock speed, just return
QBLE waitShortReturn, SPEED_MHZ, MAX_SPEED_MHZ //if MAX_SPEED_MHZ <= SPEED_MHZ, return
waitShortLoop:
QBGE waitShortReturn, CYCLES_TO_WAIT, ITER
ADD ITER, ITER, 3
JMP waitShortLoop
// cycles to wait is cpu_cycles_per_clock - 8
waitShortReturn:
JMP RET_ADDR //20
////////////////////////////////////////////////////////////
// _mode0:
// the logic to handle Mode 0 SPI devices
////////////////////////////////////////////////////////////
_mode0:
////////////////////////////////////////////////////////////
// _mode1:
// the logic to handle Mode 1 SPI devices
////////////////////////////////////////////////////////////
_mode1:
////////////////////////////////////////////////////////////
// _mode2:
// the logic to handle Mode 2 SPI devices
////////////////////////////////////////////////////////////
_mode2:
SET CLOCK_PIN // clock starts high
LDI BIT_ITER, 7
LDI RX_BYTE, 0 // clear the rx buffer byte
LDI TRANS_COUNTER, 0
// load first byte from memory
LBBO TX_BYTE, MEM_START, TRANS_COUNTER, 1
CLR CS_PINS, ID_REG // set CS to low
mode2Loop:
QBEQ _mode2End, TRANS_COUNTER, TRANS_TOTAL // while transaction is not complete
//----------------------------------------------------------CLOCK HIGH----SHIFT EDGE-
SET CLOCK_PIN // set clock high (redundant if first cycle
LSR TEMP_BYTE, TX_BYTE, BIT_ITER // LSR TEMP_BYTE, current_reg, BIT_ITER
QBBS mode2If1, TEMP_BYTE.t0 // if not TEMP_BYTE.t0
CLR MOSI_PIN
JMP mode2EndIf1
mode2If1:
SET MOSI_PIN // else set MOSI_PIN
/// MOSI SHOULD NOW BE VALID
NOOP
mode2EndIf1:
NOOP
NOOP
NOOP
JAL RET_ADDR, _waitLong // WAIT
//----------------------------------------------------------CLOCK LOW----SAMPLE EDGE-
CLR CLOCK_PIN // set clock low
LSL RX_BYTE, RX_BYTE, 1
QBBC mode2EndIf2, MISO_PIN // check input
SET RX_BYTE.t0
mode2EndIf2:
QBLT mode2SameByte, BIT_ITER, 0
JAL RET_ADDR, _byteTransition
JAL RET_ADDR, _waitShort
JMP mode2Loop
mode2SameByte: // else
SUB BIT_ITER, BIT_ITER, 1
JAL RET_ADDR, _waitLong
JMP mode2Loop
_mode2End:
SET CLOCK_PIN
// give sufficient time before CS up (some devices need extra time)
LDI ITER, 0
waitToRelease:
QBEQ mode2Release, ITER, 10
ADD ITER, ITER, 2
NOOP
JMP waitToRelease
mode2Release:
SET CS_PINS, ID_REG
JMP end_transaction
////////////////////////////////////////////////////////////
// _mode3:
// the logic to handle Mode 3 SPI devices
////////////////////////////////////////////////////////////
_mode3:
SET CLOCK_PIN // clock starts high
LDI BIT_ITER, 7
LDI RX_BYTE, 0 // clear the rx buffer byte
LDI TRANS_COUNTER, 0 // no bytes transferred yet
LBBO TX_BYTE, MEM_START, TRANS_COUNTER, 1 // load the first byte
CLR CS_PINS, ID_REG // drop CS
// LOOP
QBEQ _mode3End, TRANS_COUNTER, TRANS_TOTAL
//----------------------------------------------------CLOCK LOW ---
CLR CLOCK_PIN // drop clock
LSR TEMP_BYTE, TX_BYTE, BIT_ITER // prepare data (transition)
// wait
// clock up
// read input
// wait
// end the PRU's operation.
_done:
// Send notification to Host for program completion
//#ifdef AM33XX
// MOV r31.b0, PRU1_ARM_INTERRUPT+16
//#else
// MOV r31.b0, #PRU1_ARM_INTERRUPT
//#endif
HALT
|
javascript/safari-driver/reinstall.scpt | tobli/selenium | 12 | 1326 | <reponame>tobli/selenium<filename>javascript/safari-driver/reinstall.scpt
#!/usr/bin/osascript
(*
Copyright 2012 Software Freedom Conservancy. All Rights Reserved.
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.
*)
(*
This script can be used to quickly re-install the SafariDriver extension
during development.
Requirements:
- The extension must be manually installed before use
- This script must be run from the trunk.
*)
-- Keep this in sync with the name of the extension in the Info.plist
set EXTENSION to "WebDriver"
tell application "System Events"
set ui_elements_enabled to UI elements enabled
end tell
if ui_elements_enabled is false then
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.universalaccess"
display dialog "Please \"Enable access for assistive devices\" " & ¬
"and try again..."
error number -128
end tell
end if
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
tell menu bar 1
-- tell menu "Develop"
tell menu bar item 8
tell menu 1
-- click menu item "Show Extension Builder"
click menu item 7
end tell
end tell
end tell
delay 0.2
-- https://discussions.apple.com/thread/2726674?start=0&tstart=0
-- tell UI element 1 of scroll area 1 of window "Extension Builder"
tell UI element 1 of scroll area 1 of window 1
set found_extension to false
set tc to (count (groups whose its images is not {}))
repeat with i from 1 to tc
if exists (static text 1 of group i) then
set t_name to name of static text 1 of group i
if t_name is EXTENSION then
set found_extension to true
-- click button "Reload" of UI element ("ReloadUninstall" & t_name)
click button 1 of UI element 4
exit repeat
end if
end if
keystroke (character id 31)
delay 0.2
end repeat
if found_extension is false then
display dialog "Was unable to locate the extension \"" & EXTENSION ¬
& "\"" & return & return ¬
& "It must be manually installed before this script may be used."
error number -128
end if
end tell
end tell
end tell
tell application "Safari" to quit
|
nasm/strings/findsubs.asm | codingneverends/assembly | 0 | 17288 | <reponame>codingneverends/assembly<gh_stars>0
;Counting no of substrings
section .data
newline :db 10
space :db ' '
msg1 : db "Enter main String : "
size1 : equ $-msg1
msg1_ : db "Enter sub String : "
size1_ : equ $-msg1_
msg2 : db "No of presence sub string prent in main string is : "
size2 : equ $-msg2
section .bss
mainstring : resb 50
substring : resb 50
temp : resb 1
num : resw 1
count : resb 1
_temp : resb 1
len : resb 1
pos : resb 1
presence : resb 1
outeri : resb 1
imax : resb 1
loopi : resb 1
tempval : resb 1
section .text
global _start
_start :
mov eax, 4
mov ebx, 1
mov ecx, msg1
mov edx, size1
int 80h
mov ebx,mainstring
call readstring
mov eax, 4
mov ebx, 1
mov ecx, msg1_
mov edx, size1_
int 80h
mov ebx,substring
call readstring
mov ebx,mainstring
call strlen
mov dl,byte[len]
mov byte[imax],dl
mov ebx,substring
call strlen
mov al,byte[len]
dec al
mov dl,byte[imax]
add dl,al
mov byte[imax],dl
mov byte[presence],0
mov ebx,mainstring
mov eax,0
mov byte[loopi],0
for :
mov dl,byte[loopi]
cmp dl,byte[imax]
jnb endFor
mov dl,byte[ebx+eax]
cmp dl,0
je endFor
push ebx
push eax
mov ebx,substring
innerFor :
mov dl,byte[ebx]
cmp dl,0
je addendinnerFor
mov byte[tempval],dl
push ebx
mov ebx,mainstring
mov dl,byte[ebx+eax]
pop ebx
inc ebx
inc eax
cmp dl,byte[tempval]
jne endinnerFor
jmp innerFor
addendinnerFor :
inc byte[presence]
endinnerFor :
pop eax
pop ebx
inc eax
inc byte[loopi]
jmp for
endFor :
mov eax, 4
mov ebx, 1
mov ecx, msg2
mov edx, size2
int 80h
mov dl,byte[presence]
movzx ax,dl
mov word[num],ax
call print_num
mov eax, 1
mov ebx, 0
int 80h
readstring :
start_readstring :
push ebx
mov eax, 3
mov ebx, 0
mov ecx, temp
mov edx, 1
int 80h
pop ebx
cmp byte[temp],10
je end_readstring
mov al,byte[temp]
mov byte[ebx],al
inc ebx
jmp start_readstring
end_readstring:
mov byte[ebx],0
ret
printstring :
start_printstring :
mov dl,byte[ebx]
mov byte[temp],dl
cmp byte[temp],0
je end_printstring
push ebx
mov eax,4
mov ebx,1
mov ecx,temp
mov edx,1
int 80h
pop ebx
inc ebx
jmp start_printstring
end_printstring :
mov eax, 4
mov ebx, 1
mov ecx, newline
mov edx, 1
int 80h
ret
strlen :
mov byte[len],0
start_strlen :
mov dl,byte[ebx]
mov byte[temp],dl
cmp byte[temp],0
je end_strlen
inc byte[len]
inc ebx
jmp start_strlen
end_strlen :
ret
print_num:
mov byte[count],0
cmp word[num],0
jne skip___
mov word[temp],30h
mov eax, 4
mov ebx, 1
mov ecx, temp
mov edx, 1
int 80h
skip___ :
extract_no :
cmp word[num], 0
je print_no
inc byte[count]
mov dx, 0
mov ax, word[num]
mov bx, 10
div bx
push dx
mov word[num], ax
jmp extract_no
print_no :
cmp byte[count], 0
je end_print
dec byte[count]
pop dx
mov byte[temp], dl
add byte[temp], 30h
mov eax, 4
mov ebx, 1
mov ecx, temp
mov edx, 1
int 80h
jmp print_no
end_print :
mov eax,4
mov ebx,1
mov ecx,newline
mov edx,1
int 80h
ret |
src/minic.g4 | ajainuary/minic-compiler | 1 | 754 | <gh_stars>1-10
grammar minic;
prog: program + EOF
;
/* Arrow */
arrowExpr : expr #arrowPass
| expr '->' expr #binaryArrow
;
/* Unary + or - */
unaryExpr: OP = ('+'|'-'|'&'|'*'|'!') arrowExpr #unaryOperate
| arrowExpr #unaryPass
;
/* Group all the multiplications and divisions */
multiplicativeExpr: unaryExpr #multiplicativePass
| multiplicativeExpr OP = ('*' | '/' | 'mod') unaryExpr #binaryMultiplicative
;
/* Group all the additions and subtractions but multiply first */
additiveExpr: multiplicativeExpr #additivePass
| additiveExpr OP = ('+' | '-') multiplicativeExpr #binaryAdditive
;
/* Comparison */
comparisonExpr: additiveExpr OP = ('==' | '<=' | '>=' | '<' | '>' | '!=') additiveExpr #binaryComparison
| additiveExpr #comparisonPass
;
/* Boolean */
booleanExpr: comparisonExpr OP = ('and' | 'or') comparisonExpr #binaryBoolean
| comparisonExpr #booleanPass
;
/* Evaluate brackets first then expand the inner expression */
expr: '(' booleanExpr ')' #exprParenthesis
| functionCall #exprCall
| identifier #exprIdentifier
| NUMBER #exprNumber
| LITERAL #exprLiteral
| STRING #exprString
;
/* Assignment */
assign: identifier '=' booleanExpr;
/* Declaration */
declaration: type (identifier|assign) (',' (identifier|assign))*;
type : (PRIMITIVE = ('integer' | 'float' | 'char' | 'bool' | 'void') ('[' booleanExpr? ']')* | 'struct' ID) '*'?;
/* Language Semantics */
statement : booleanExpr ';' #exprStatement
| assign ';' #assignStatement
| declaration ';' #declarationStatement
| returnStatement ';' #retStatement
| structDeclaration ';' #structDeclarationStatement
;
nonControl : declaration #nonControlDeclaration
| assign #nonControlAssign
| structDeclaration #nonControlStructDeclaration
;
/* If - Else */
ifElse : 'if' booleanExpr block ('else' block)?;
ternary : booleanExpr '?' booleanExpr ':' booleanExpr;
control : forStatement | whileStatement | ifElse;
/* for Loop */
forStatement : 'for' '(' nonControl ';' booleanExpr ';' nonControl ')' block;
whileStatement : 'while' '(' booleanExpr ')' block;
program : block | statement | control | functionDeclaration | functionCall | include ;
block : '{' program* '}';
/* Functions */
paramList : declaration (',' declaration)*;
argList : booleanExpr (',' booleanExpr)*;
functionDeclaration : type ID '(' paramList? ')' block;
functionCall : ID '(' argList? ')';
returnStatement : 'return' booleanExpr?;
/* struct */
structDeclaration : 'struct' ID '{' paramList '}';
/* Compiler Directives */
include: '#' 'include' '<' (ID '/')* ID '.h''>';
/*Tokens*/
identifier: ID ('[' (comparisonExpr|ternary) ']' | '.' ID)*;
ID : [a-zA-Z][a-zA-Z0-9_]*;
NUMBER : [0-9.]+;
LITERAL : '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\')?)* '"' | '\'' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\')?)* '\'';
STRING : '"' [a-z][a-zA-Z0-9%]* '"';
COMMENT : '//' ~[\r\n]*->skip;
NS : [ \t\n]+ -> skip; |
grammars/Common.g4 | SeedV/SeedLang | 6 | 7436 | /**
* Copyright 2021-2022 The SeedV Lab.
*
* 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.
*
* SeedPyhton grammar is referred and modified from:
* https://docs.python.org/3.10/reference/grammar.html
*/
grammar Common;
@header {
#pragma warning disable 3021
}
/*
* Parser rules
*/
expressions: expression (COMMA expression)* COMMA?;
expression: disjunction;
disjunction: conjunction (OR conjunction)*;
conjunction: inversion (AND inversion)*;
inversion:
NOT inversion # not
| comparison # comparison_as_inversion;
comparison: bitwise_or (comparison_op bitwise_or)*;
comparison_op:
EQ_EQUAL
| NOT_EQUAL
| LESS_EQUAL
| LESS
| GREATER_EQUAL
| GREATER
| IN;
// TODO: add bitwise parsing rule
bitwise_or: sum;
sum:
sum ADD term # add
| sum SUBTRACT term # subtract
| term # term_as_sum;
term:
term MULTIPLY factor # multiply
| term DIVIDE factor # divide
| term FLOOR_DIVIDE factor # floor_divide
| term MODULO factor # modulo
| factor # factor_as_term;
factor:
ADD factor # positive
| SUBTRACT factor # negative
| primary POWER factor # power
| primary # primary_as_factor;
primary:
primary DOT identifier # attribute
| primary OPEN_BRACK slice_index CLOSE_BRACK # subscript
| primary OPEN_PAREN arguments? CLOSE_PAREN # call
| atom # atom_as_primary;
slice_index:
expression? COLON expression? (COLON expression?)? # slice
| expression # index;
atom:
identifier # identifier_as_atom
| TRUE # true
| FALSE # false
| NONE # none
| NUMBER # number
| STRING+ # strings
| group # group_as_atom
| dict # dict_as_atom
| list # list_as_atom
| tuple # tuple_as_atom;
identifier: NAME;
arguments: expression (COMMA expression)*;
group: OPEN_PAREN expression CLOSE_PAREN;
dict: OPEN_BRACE kvpairs? CLOSE_BRACE;
list: OPEN_BRACK expressions? CLOSE_BRACK;
tuple: OPEN_PAREN expressions? CLOSE_PAREN;
kvpairs: kvpair (COMMA kvpair)*;
kvpair: expression COLON expression;
/*
* Lexer rules
*/
TRUE: 'True';
FALSE: 'False';
NONE: 'None';
AND: 'and';
OR: 'or';
NOT: 'not';
IN: 'in';
EQUAL: '=';
EQ_EQUAL: '==';
NOT_EQUAL: '!=';
LESS_EQUAL: '<=';
LESS: '<';
GREATER_EQUAL: '>=';
GREATER: '>';
ADD: '+';
SUBTRACT: '-';
MULTIPLY: '*';
DIVIDE: '/';
FLOOR_DIVIDE: '//';
POWER: '**';
MODULO: '%';
ADD_ASSIGN: '+=';
SUBTRACT_ASSIGN: '-=';
MULTIPLY_ASSIGN: '*=';
DIVIDE_ASSIGN: '/=';
MODULO_ASSIGN: '%=';
OPEN_PAREN: '(';
CLOSE_PAREN: ')';
OPEN_BRACK: '[';
CLOSE_BRACK: ']';
OPEN_BRACE: '{';
CLOSE_BRACE: '}';
DOT: '.';
COMMA: ',';
COLON: ':';
NAME: ID_START ID_CONTINUE*;
NUMBER: INTEGER | FLOAT_NUMBER;
STRING: SHORT_STRING;
INTEGER: DECIMAL_INTEGER;
DECIMAL_INTEGER: NON_ZERO_DIGIT DIGIT* | '0'+;
FLOAT_NUMBER: POINT_FLOAT | EXPONENT_FLOAT;
NEWLINE: ('\r'? '\n' | '\r' | '\f') SPACES?;
SKIP_: (SPACES | LINE_JOINING) -> skip;
UNKNOWN_CHAR: .;
/*
* Fragments
*/
fragment SHORT_STRING:
'\'' (STRING_ESCAPE_SEQ | ~[\\\r\n\f'])* '\''
| '"' (STRING_ESCAPE_SEQ | ~[\\\r\n\f"])* '"';
fragment STRING_ESCAPE_SEQ: '\\' . | '\\' NEWLINE;
fragment POINT_FLOAT:
INT_PART? FRACTION
| INT_PART DOT;
fragment EXPONENT_FLOAT: (INT_PART | POINT_FLOAT) EXPONENT;
fragment INT_PART: DIGIT+;
fragment FRACTION: DOT DIGIT+;
fragment EXPONENT: [eE] [+-]? DIGIT+;
fragment NON_ZERO_DIGIT: [1-9];
fragment DIGIT: [0-9];
fragment SPACES: [ \t]+;
fragment LINE_JOINING:
'\\' SPACES? ('\r'? '\n' | '\r' | '\f');
fragment ID_START: '_' | [A-Z] | [a-z];
fragment ID_CONTINUE: ID_START | [0-9];
|
src/NF/Sum.agda | yanok/normalize-via-instances | 0 | 7828 | <reponame>yanok/normalize-via-instances
module NF.Sum where
open import NF
open import Data.Sum
open import Relation.Binary.PropositionalEquality
instance
nfInj₁ : {A B : Set}{a : A}{{nfa : NF a}} -> NF {A ⊎ B} (inj₁ a)
Sing.unpack (NF.!! (nfInj₁ {a = a})) = inj₁ (nf a)
Sing.eq (NF.!! (nfInj₁ {{nfa}})) rewrite nf≡ {{nfa}} = refl
{-# INLINE nfInj₁ #-}
nfInj₂ : {A B : Set}{b : B}{{nfb : NF b}} -> NF {A ⊎ B} (inj₂ b)
Sing.unpack (NF.!! (nfInj₂ {b = b})) = inj₂ (nf b)
Sing.eq (NF.!! (nfInj₂ {{nfb}})) rewrite nf≡ {{nfb}} = refl
{-# INLINE nfInj₂ #-} |
alloy4fun_models/trashltl/models/5/bTqLGwhq7ppy5SMsv.als | Kaixi26/org.alloytools.alloy | 0 | 2812 | open main
pred idbTqLGwhq7ppy5SMsv_prop6 {
all f : File-Protected | f not in Trash and after f in Trash => always f in Trash
}
pred __repair { idbTqLGwhq7ppy5SMsv_prop6 }
check __repair { idbTqLGwhq7ppy5SMsv_prop6 <=> prop6o } |
Script-Debugger/Toggle-Minimal-View.applescript | boisy/AppleScripts | 116 | 672 | <gh_stars>100-1000
tell application "Script Debugger"
tell front document
if toolbar visible then
set event log visible to false
set toolbar visible to false
set tab display mode to none
else
set event log visible to true
set toolbar visible to true
set tab display mode to result and variables tab
end if
end tell
end tell
|
Scripts Pack Source Items/Scripts Pack/Miscellaneous/Testing/Multiple Display Workspaces Animation (10.7).applescript | Phorofor/ScriptsPack.macOS | 1 | 2018 | <reponame>Phorofor/ScriptsPack.macOS<filename>Scripts Pack Source Items/Scripts Pack/Miscellaneous/Testing/Multiple Display Workspaces Animation (10.7).applescript
# Scripts Pack - Tweak various preference variables in macOS
# <Phorofor, https://github.com/Phorofor/>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-- Turns off workspaces swoosh animation
-- Disable Multiple Monitors Workspaces Animation
-- information may not be accurate
-- Versions compatible: --
-- Preference Identifier: com.apple.dock
-- Preference Key: workspaces-swoosh-animation-off
-- Preference location: ~/Library/Preferences/com.apple.dock.plist
-- Default value (boolean): NO
display alert "Would you like to turn off the workspaces swipe animation?" message "Turns off swipe animation for other monitors except the main one." buttons {"Cancel", "On", "Off"} default button 2 cancel button 1
if the button returned of the result is "Off" then
-- Turn off animation
do shell script "defaults write com.apple.dock workspaces-swoosh-animation-off -bool YES"
else
do shell script "defaults write com.apple.dock workspaces-swoosh-animation-off -bool NO"
end if
display alert "The Dock needs to be restarted for the changes to take effect, restart now?" buttons {"Cancel", "Restart"} cancel button 1
do shell script "killall Dock"
delay 2
tell application "Dock"
display alert "The Dock has been restarted, your changes should have taken effect."
end tell |
src/tools/Dependency_Graph_Extractor/src/extraction-file_system.adb | selroc/Renaissance-Ada | 1 | 18966 | <reponame>selroc/Renaissance-Ada
with Extraction.Node_Edge_Types;
with Ada.Text_IO;
package body Extraction.File_System is
use type VFS.File_Array_Access;
use type VFS.Filesystem_String;
function All_Relevant_Files (Directory : VFS.Virtual_File) return VFS.File_Array_Access
with Pre => Directory.Is_Directory
-- Only analyse relevant files
-- I.e. remove irrelevant files and directories
-- (e.g. version management related directories and files)
is
Result : VFS.File_Array_Access;
function Is_Hidden (File : VFS.Virtual_File) return Boolean
-- Linux-style hidden files and directories start with a '.'
is
Base_Name : constant String := + File.Base_Name;
begin
return Base_Name (Base_Name'First) = '.';
end Is_Hidden;
procedure Internal (Directory : VFS.Virtual_File) is
Files : VFS.File_Array_Access := Directory.Read_Dir;
begin
for File of Files.all loop
if Is_Hidden (File) then
Ada.Text_IO.Put_Line ("Skipping " & (+File.Full_Name));
else
VFS.Append (Result, File);
if File.Is_Directory then
Internal (File);
end if;
end if;
end loop;
VFS.Unchecked_Free(Files);
end Internal;
begin
Internal (Directory);
return Result;
end All_Relevant_Files;
procedure Extract_Nodes
(Directory : VFS.Virtual_File;
Graph : Graph_Operations.Graph_Context)
-- Add all relevant files in the file system.
-- This enables the finding of "dead files":
-- Files in the archive but no longer compiled / used by any project.
is
Files : VFS.File_Array_Access := All_Relevant_Files (Directory);
begin
Graph.Write_Node(Directory);
if Files /= null then
for File of Files.all loop
Graph.Write_Node (File);
end loop;
end if;
VFS.Unchecked_Free(Files);
end Extract_Nodes;
procedure Extract_Edges
(Directory : VFS.Virtual_File;
Graph : Graph_Operations.Graph_Context)
is
Files : VFS.File_Array_Access := All_Relevant_Files (Directory);
begin
if Files /= null then
for File of Files.all loop
Graph.Write_Edge(File.Get_Parent, File, Node_Edge_Types.Edge_Type_Contains);
end loop;
end if;
VFS.Unchecked_Free(Files);
end Extract_Edges;
end Extraction.File_System;
|
test/sigsub.asm | kspalaiologos/asmbf | 67 | 11941 |
mov r1, $(signed(-3))
mov r2, $(signed(-2))
s06 r1, r2
eq r1, 3
add r1, .0
out r1
mov r1, $(signed(-3))
mov r2, $(signed(2))
s06 r1, r2
eq r1, $(0xB)
add r1, .0
out r1
mov r1, $(signed(3))
mov r2, $(signed(-2))
s06 r1, r2
eq r1, $(0xA)
add r1, .0
out r1
mov r1, $(signed(3))
mov r2, $(signed(2))
s06 r1, r2
eq r1, 2
add r1, .0
out r1
mov r1, $(signed(-2))
mov r2, $(signed(-3))
s06 r1, r2
eq r1, 2
add r1, .0
out r1
mov r1, $(signed(2))
mov r2, $(signed(3))
s06 r1, r2
eq r1, 3
add r1, .0
out r1
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_2014.asm | ljhsiun2/medusa | 9 | 174320 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x1a0d3, %rsi
lea addresses_WC_ht+0xe0d3, %rdi
nop
nop
nop
and %r14, %r14
mov $75, %rcx
rep movsw
nop
nop
nop
nop
xor $62209, %rdx
lea addresses_UC_ht+0x124d3, %r8
nop
cmp %r10, %r10
movl $0x61626364, (%r8)
and %r14, %r14
lea addresses_WC_ht+0x9a4d, %rsi
lea addresses_normal_ht+0x168d3, %rdi
nop
xor $1268, %r11
mov $18, %rcx
rep movsl
nop
add $25468, %rdi
lea addresses_D_ht+0xc8d3, %r8
nop
inc %r10
mov (%r8), %r11w
nop
cmp %rdi, %rdi
lea addresses_WC_ht+0x132d3, %rsi
lea addresses_D_ht+0x2f3, %rdi
nop
nop
nop
nop
xor $4429, %rdx
mov $92, %rcx
rep movsb
and $50921, %r8
lea addresses_WC_ht+0x8153, %rdi
xor $22066, %r10
mov (%rdi), %r8w
nop
nop
nop
nop
nop
and $10956, %r8
lea addresses_D_ht+0x90d3, %rsi
lea addresses_D_ht+0x1953, %rdi
nop
nop
nop
nop
add $45923, %rdx
mov $23, %rcx
rep movsb
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_WC_ht+0x124d3, %r8
nop
nop
sub $36082, %rcx
and $0xffffffffffffffc0, %r8
vmovaps (%r8), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $0, %xmm4, %r14
nop
nop
nop
nop
xor $3097, %r11
lea addresses_WC_ht+0x16ad3, %rsi
lea addresses_D_ht+0x18e2d, %rdi
nop
nop
nop
nop
nop
add %r10, %r10
mov $76, %rcx
rep movsw
nop
nop
nop
dec %r14
lea addresses_normal_ht+0x1e993, %r8
nop
nop
nop
xor $25788, %r11
mov (%r8), %r10d
nop
nop
xor %rsi, %rsi
lea addresses_WC_ht+0x174d3, %rsi
lea addresses_A_ht+0x16043, %rdi
nop
nop
nop
nop
nop
xor %r11, %r11
mov $2, %rcx
rep movsb
nop
nop
nop
cmp $45412, %rdi
lea addresses_WC_ht+0x5dd3, %rdx
nop
nop
nop
and %r11, %r11
mov (%rdx), %rcx
nop
xor $3138, %r10
lea addresses_WT_ht+0x12cd3, %r11
nop
nop
nop
cmp $42229, %r8
mov (%r11), %edi
sub %rdx, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %r9
push %rax
push %rbx
push %rdi
// Load
lea addresses_RW+0x14265, %rax
nop
nop
sub $2259, %rdi
mov (%rax), %ebx
nop
nop
and $34987, %rbx
// Store
lea addresses_D+0xc9e3, %r13
nop
nop
dec %r10
movw $0x5152, (%r13)
nop
nop
inc %rax
// Store
lea addresses_WT+0x1dc93, %rdi
nop
nop
nop
nop
add $59803, %rbx
movb $0x51, (%rdi)
nop
nop
nop
and %rax, %rax
// Faulty Load
lea addresses_WC+0x70d3, %r10
nop
nop
nop
xor $24174, %rdi
mov (%r10), %r14d
lea oracles, %r13
and $0xff, %r14
shlq $12, %r14
mov (%r13,%r14,1), %r14
pop %rdi
pop %rbx
pop %rax
pop %r9
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WC', 'AVXalign': True, 'size': 2, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_RW', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 2}}
[Faulty Load]
{'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_A_ht', 'congruent': 9, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 9}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 32, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': True, 'congruent': 7}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'}
{'38': 21829}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
Library/Text/UI/uiCharFGColor.asm | steakknife/pcgeos | 504 | 5055 | COMMENT @-----------------------------------------------------------------------
Copyright (c) GeoWorks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Text Library
FILE: uiCharFGColorControl.asm
ROUTINES:
Name Description
---- -----------
GLB CharFGColorControlClass Style menu object
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 7/91 Initial version
DESCRIPTION:
This file contains routines to implement CharFGColorControlClass
$Id: uiCharFGColor.asm,v 1.1 97/04/07 11:17:27 newdeal Exp $
-------------------------------------------------------------------------------@
GC_Data union
GCD_dword dword
GCD_optr optr
GC_Data end
GC_NewField struct
GCNF_offset byte
GCNF_size byte
GCNF_data GC_Data
GC_NewField ends
;---------------------------------------------------
TextClassStructures segment resource
CharFGColorControlClass ;declare the class record
TextClassStructures ends
;---------------------------------------------------
if not NO_CONTROLLERS
TextControlCode segment resource
COMMENT @----------------------------------------------------------------------
MESSAGE: CharFGColorControlGetInfo --
MSG_GEN_CONTROL_GET_INFO for CharFGColorControlClass
DESCRIPTION: Return group
PASS:
*ds:si - instance data
es - segment of CharFGColorControlClass
ax - The message
RETURN:
cx:dx - list of children
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 10/31/91 Initial version
------------------------------------------------------------------------------@
CharFGColorControlGetInfo method dynamic CharFGColorControlClass,
MSG_GEN_CONTROL_GET_INFO
; first call our superclass to get the color selector's stuff
pushdw cxdx
mov di, offset CharFGColorControlClass
call ObjCallSuperNoLock
; now fill in a few things
popdw esdi
mov si, offset CFGCC_newFields
mov cx, length CFGCC_newFields
call CopyFieldsToBuildInfo
ret
CharFGColorControlGetInfo endm
CFGCC_newFields GC_NewField \
<offset GCBI_flags, size GCBI_flags,
<GCD_dword mask GCBF_SUSPEND_ON_APPLY>>,
<offset GCBI_initFileKey, size GCBI_initFileKey,
<GCD_dword CFGCC_IniFileKey>>,
<offset GCBI_gcnList, size GCBI_gcnList,
<GCD_dword CFGCC_gcnList>>,
<offset GCBI_gcnCount, size GCBI_gcnCount,
<GCD_dword length CFGCC_gcnList>>,
<offset GCBI_notificationList, size GCBI_notificationList,
<GCD_dword CFGCC_notifyList>>,
<offset GCBI_notificationCount, size GCBI_notificationCount,
<GCD_dword size CFGCC_notifyList>>,
<offset GCBI_controllerName, size GCBI_controllerName,
<GCD_optr CFGCCName>>,
<offset GCBI_features, size GCBI_features,
<GCD_dword CFGCC_DEFAULT_FEATURES>>,
<offset GCBI_toolFeatures, size GCBI_toolFeatures,
<GCD_dword CFGCC_DEFAULT_TOOLBOX_FEATURES>>,
<offset GCBI_helpContext, size GCBI_helpContext,
<GCD_dword CFGCC_helpContext>>
if FULL_EXECUTE_IN_PLACE
ControlInfoXIP segment resource
endif
CFGCC_helpContext char "dbCharClr", 0
CFGCC_IniFileKey char "charFGColor", 0
CFGCC_gcnList GCNListType \
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_TEXT_CHAR_ATTR_CHANGE>,
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_TEXT_FG_COLOR_CHANGE>
CFGCC_notifyList NotificationType \
<MANUFACTURER_ID_GEOWORKS, GWNT_TEXT_CHAR_ATTR_CHANGE>,
<MANUFACTURER_ID_GEOWORKS, GWNT_TEXT_FG_COLOR_CHANGE>
if FULL_EXECUTE_IN_PLACE
ControlInfoXIP ends
endif
COMMENT @----------------------------------------------------------------------
FUNCTION: CopyFieldsToBuildInfo
DESCRIPTION: Copy fields from a table of GC_NewField structures to
a GenControlBuildInfo structure
CALLED BY: INTERNAL
PASS:
esdi - GenControlBuildInfo structure
cs:si - table of GC_NewField structures
cx - table length
RETURN:
none
DESTROYED:
ax, bx, cx, dx, si, si, di, bp, ds, es
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/24/92 Initial version
------------------------------------------------------------------------------@
CopyFieldsToBuildInfo proc near
segmov ds, cs ;ds:si = source
copyLoop:
push cx, si, di
clr ax
lodsb ;ax = offset
add di, ax
clr ax
lodsb
mov_tr cx, ax ;cx = count
rep movsb
pop cx, si, di
add si, size GC_NewField
loop copyLoop
ret
CopyFieldsToBuildInfo endp
COMMENT @----------------------------------------------------------------------
MESSAGE: CharFGColorControlOutputAction -- MSG_GEN_OUTPUT_ACTION
for CharFGColorControlClass
DESCRIPTION: Intercept ColorSelector output that we want
PASS:
*ds:si - instance data
es - segment of CharFGColorControlClass
ax - The message
cx:dx - destination (or travel option)
bp - event
RETURN:
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/24/92 Initial version
------------------------------------------------------------------------------@
CharFGColorControlOutputAction method dynamic CharFGColorControlClass,
MSG_GEN_OUTPUT_ACTION
mov di, offset CharFGColorControlClass
FALL_THRU ColorInterceptAction
CharFGColorControlOutputAction endm
;---
ColorInterceptAction proc far
push cx, si
mov bx, bp
call ObjGetMessageInfo ;ax = message
pop cx, si
cmp ax, MSG_META_COLORED_OBJECT_SET_COLOR
jz handleOurself
cmp ax, MSG_META_COLORED_OBJECT_SET_DRAW_MASK
jz handleOurself
cmp ax, MSG_META_COLORED_OBJECT_SET_PATTERN
jz handleOurself
mov ax, MSG_GEN_OUTPUT_ACTION
GOTO ObjCallSuperNoLock
handleOurself:
; dispatch the event to ourself
mov cx, ds:[LMBH_handle] ;cx:si = dest
call MessageSetDestination
clr di ;no flags
call MessageDispatch
ret
ColorInterceptAction endp
COMMENT @----------------------------------------------------------------------
MESSAGE: CharFGColorControlSetColor -- MSG_META_COLORED_OBJECT_SET_COLOR
for CharFGColorControlClass
DESCRIPTION: Handle a color change
PASS:
*ds:si - instance data
es - segment of CharFGColorControlClass
ax - The message
dxcx - color
RETURN:
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/24/92 Initial version
------------------------------------------------------------------------------@
CharFGColorControlSetColor method dynamic CharFGColorControlClass,
MSG_META_COLORED_OBJECT_SET_COLOR
mov ax, MSG_VIS_TEXT_SET_COLOR
call SendMeta_AX_DXCX_Common
ret
CharFGColorControlSetColor endm
;---
CharFGColorControlSetDrawMask method dynamic CharFGColorControlClass,
MSG_META_COLORED_OBJECT_SET_DRAW_MASK
mov ax, MSG_VIS_TEXT_SET_GRAY_SCREEN
call SendMeta_AX_CX_Common
ret
CharFGColorControlSetDrawMask endm
;---
CharFGColorControlSetPattern method dynamic CharFGColorControlClass,
MSG_META_COLORED_OBJECT_SET_PATTERN
mov ax, MSG_VIS_TEXT_SET_PATTERN
call SendMeta_AX_CX_Common
ret
CharFGColorControlSetPattern endm
COMMENT @----------------------------------------------------------------------
MESSAGE: CharFGColorControlUpdateUI --
MSG_GEN_CONTROL_UPDATE_UI for CharFGColorControlClass
DESCRIPTION: Handle notification of attributes change
PASS:
*ds:si - instance data
es - segment of CharFGColorControlClass
ax - The message
ss:bp - GenControlUpdateUIParams
GCUUIP_manufacturer ManufacturerID
GCUUIP_changeType word
GCUUIP_dataBlock hptr
GCUUIP_toolInteraction optr
GCUUIP_features word
GCUUIP_toolboxFeatures word
GCUUIP_childBlock hptr
RETURN: none
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 11/12/91 Initial version
------------------------------------------------------------------------------@
CharFGColorControlUpdateUI method dynamic CharFGColorControlClass,
MSG_GEN_CONTROL_UPDATE_UI
push ds
mov dx, GWNT_TEXT_FG_COLOR_CHANGE
call GetColorNotifyCommon
je gotColor ;branch if got color
;
; Get text color from VisTextNotifyCharAttrChange
;
mov al, ds:VTNCAC_charAttr.VTCA_grayScreen
movdw dxcx, ds:VTNCAC_charAttr.VTCA_color
mov bx, {word} ds:VTNCAC_charAttr.VTCA_pattern
mov di, ds:VTNCAC_charAttrDiffs.VTCAD_diffs
gotColor:
call UnlockNotifBlock
pop ds
; dxcx - color
; al - SystemDrawMask
; bx - GraphicPattern
; di - VisTextCharAttrFlags
; VTCAF_MULTIPLE_COLORS
; VTCAF_MULTIPLE_GRAY_SCREENS
; VTCAF_MULTIPLE_PATTERNS
call UpdateColorCommon
ret
CharFGColorControlUpdateUI endm
COMMENT @----------------------------------------------------------------------
FUNCTION: UpdateColorCommon
DESCRIPTION: Common code to update a color selector
CALLED BY: INTERNAL
PASS:
*ds:si - controller
ss:bp - GenControlUpdateUIParams
dxcx - color
al - SystemDrawMask
bx - GraphicPattern
di - VisTextCharAttrFlags
VTCAF_MULTIPLE_COLORS
VTCAF_MULTIPLE_GRAY_SCREENS
VTCAF_MULTIPLE_PATTERNS
RETURN:
none
DESTROYED:
ax, bx, cx, dx, si, di
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/24/92 Initial version
------------------------------------------------------------------------------@
UpdateColorCommon proc near uses bp
.enter
push bx ;save hatch
push ax ;save draw mask
; update color
mov bp, di
and bp, mask VTCAF_MULTIPLE_COLORS ;bp = indeterm
mov ax, MSG_COLOR_SELECTOR_UPDATE_COLOR
call ObjCallInstanceNoLock
; update draw mask
pop cx
mov dx, di
and dx, mask VTCAF_MULTIPLE_GRAY_SCREENS
mov ax, MSG_COLOR_SELECTOR_UPDATE_DRAW_MASK
call ObjCallInstanceNoLock
; update hatch
pop cx
mov dx, di
and dx, mask VTCAF_MULTIPLE_PATTERNS
mov ax, MSG_COLOR_SELECTOR_UPDATE_PATTERN
call ObjCallInstanceNoLock
.leave
ret
UpdateColorCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetColorNotifyCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Common routine to get notification data for color
CALLED BY: CharFGColorControlUpdateUI(), CharBGColorControlUpdateUI()
PASS: ss:bp - GenControlUpdateUIParams
GCUUIP_manufacturer ManufacturerID
GCUUIP_changeType word
GCUUIP_dataBlock hptr
GCUUIP_toolInteraction optr
GCUUIP_features word
GCUUIP_toolboxFeatures word
GCUUIP_childBlock hptr
dx - GeoWorksNotificationType to match
NOTE: this notification type must use NotifyColorChange
RETURN: ds - seg addr of notification block
z flag - set if common color notification:
di - VisTextCharAttrFlags
VTCAF_MULTIPLE_COLORS
VTCAF_MULTIPLE_GRAY_SCREENS
-or-
VTCAF_MULTIPLE_BG_COLORS
VTCAF_MULTIPLE_BG_GRAY_SCREENS
-or-
VTPAF_MULTIPLE_BG_COLORS
VTPAF_MULTIPLE_BG_GRAY_SCREENS
-or-
VTPABF_MULTIPLE_BORDER_COLORS
VTPABF_MULTIPLE_BORDER_GRAY_SCREENS
ax - SystemDrawMask
dxcx - color
bx - GraphicPattern
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 2/26/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetColorNotifyCommon proc near
.enter
;
; Get notification data and figure out what type it is
;
mov bx, ss:[bp].GCUUIP_dataBlock ;bx <- notification block
call MemLock
mov ds, ax
clr ax
cmp ss:[bp].GCUUIP_changeType, dx ;common type?
jne done ;branch if not
;
; Get color from NotifyColorChange (common structure)
;
mov al, ds:NCC_grayScreen
movdw dxcx, ds:NCC_color
mov bx, {word} ds:NCC_pattern
mov di, ds:NCC_flags
done:
.leave
ret
GetColorNotifyCommon endp
;---
UnlockNotifBlock proc near uses bx
.enter
mov bx, ss:[bp].GCUUIP_dataBlock ;bx <- notification block
call MemUnlock
.leave
ret
UnlockNotifBlock endp
TextControlCode ends
endif ; not NO_CONTROLLERS
|
drivers/video/ms/8514a/disp/i386/fasttext.asm | npocmaka/Windows-Server-2003 | 17 | 177181 | ;---------------------------Module-Header------------------------------;
; Module Name: fasttext.asm
;
; Copyright (c) 1992-1994 Microsoft Corporation
;-----------------------------------------------------------------------;
;-----------------------------------------------------------------------;
; VOID vFastText(GLYPHPOS * pGlyphPos, ULONG ulGlyphCount, PBYTE pTempBuffer,
; ULONG ulBufDelta, ULONG ulCharInc,
; RECTL * prclText, RECTL * prclOpaque,
; ULONG fDrawFlags, RECTL * prclClip,
; RECTL * prclExtra);
; pGlyphPos -
; ulGlyphCount - # of glyphs to draw. Must never be 0.
; pTempBuffer -
; ulBufDelta -
; ulCharInc -
; prclText -
; prclOpaque -
; fDrawFlags -
; prclClip - array of clipping rectangles
; prclExtra - array of extra rectangles to fill in foreground color
;
; Draws glyphs into a 1bpp buffer using the CPU, so that the hardware
; can later colour-expand to the screen to draw text.
;
;-----------------------------------------------------------------------;
;
; Note: prclClip and prclExtra are null rectangle (yBottom=0) terminated
; arrays.
;
; Note: Assumes the text rectangle has a positive height and width. Will
; not work properly if this is not the case.
;
; Note: The opaquing rectangle is assumed to match the text bounding
; rectangle exactly; prclOpaque is used only to determine whether or
; not opaquing is required.
;
; Note: For maximum performance, we should not bother to draw fully-
; clipped characters to the temp buffer.
;
;-----------------------------------------------------------------------;
.386
.model small,c
assume ds:FLAT,es:FLAT,ss:FLAT
assume fs:nothing,gs:nothing
.xlist
include stdcall.inc ;calling convention cmacros
include i386\strucs.inc
.list
;-----------------------------------------------------------------------;
.data
;-----------------------------------------------------------------------;
; Tables used to branch into glyph-drawing optimizations.
;
; Handles narrow (1-4 bytes wide) glyph drawing, for case where initial byte
; should be MOVed even if it's not aligned (intended for use in drawing the
; first glyph in a string). Table format is:
; Bits 3-2: dest width
; Bit 1 : 1 if don't need last source byte, 0 if do need last source byte
; Bit 0 : 1 if no rotation (aligned), 0 if rotation (non-aligned)
align 4
MovInitialTableNarrow label dword
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd mov_first_1_wide_rotated_need_last ;nonalign, 1 wide, need last
dd mov_first_1_wide_unrotated ;aligned, 1 wide
dd mov_first_1_wide_rotated_no_last ;nonalign, 1 wide, no last
dd mov_first_1_wide_unrotated ;aligned, 1 wide
dd mov_first_2_wide_rotated_need_last ;nonalign, 2 wide, need last
dd mov_first_2_wide_unrotated ;aligned, 2 wide
dd mov_first_2_wide_rotated_no_last ;nonalign, 2 wide, no last
dd mov_first_2_wide_unrotated ;aligned, 2 wide
dd mov_first_3_wide_rotated_need_last ;nonalign, 3 wide, need last
dd mov_first_3_wide_unrotated ;aligned, 3 wide
dd mov_first_3_wide_rotated_no_last ;nonalign, 3 wide, no last
dd mov_first_3_wide_unrotated ;aligned, 3 wide
dd mov_first_4_wide_rotated_need_last ;nonalign, 4 wide, need last
dd mov_first_4_wide_unrotated ;aligned, 4 wide
dd mov_first_4_wide_rotated_no_last ;nonalign, 4 wide, no last
dd mov_first_4_wide_unrotated ;aligned, 4 wide
; Handles narrow (1-4 bytes wide) glyph drawing, for case where initial byte
; ORed if it's not aligned (intended for use in drawing all but the first glyph
; in a string). Table format is:
; Bits 3-2: dest width
; Bit 1 : 1 if don't need last source byte, 0 if do need last source byte
; Bit 0 : 1 if no rotation (aligned), 0 if rotation (non-aligned)
align 4
OrInitialTableNarrow label dword
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd or_first_1_wide_rotated_need_last ;nonalign, 1 wide, need last
dd mov_first_1_wide_unrotated ;aligned, 1 wide
dd or_first_1_wide_rotated_no_last ;nonalign, 1 wide, no last
dd mov_first_1_wide_unrotated ;aligned, 1 wide
dd or_first_2_wide_rotated_need_last ;nonalign, 2 wide, need last
dd mov_first_2_wide_unrotated ;aligned, 2 wide
dd or_first_2_wide_rotated_no_last ;nonalign, 2 wide, no last
dd mov_first_2_wide_unrotated ;aligned, 2 wide
dd or_first_3_wide_rotated_need_last ;nonalign, 3 wide, need last
dd mov_first_3_wide_unrotated ;aligned, 3 wide
dd or_first_3_wide_rotated_no_last ;nonalign, 3 wide, no last
dd mov_first_3_wide_unrotated ;aligned, 3 wide
dd or_first_4_wide_rotated_need_last ;nonalign, 4 wide, need last
dd mov_first_4_wide_unrotated ;aligned, 4 wide
dd or_first_4_wide_rotated_no_last ;nonalign, 4 wide, no last
dd mov_first_4_wide_unrotated ;aligned, 4 wide
; Handles narrow (1-4 bytes wide) glyph drawing, for case where all bytes
; should be ORed (intended for use in drawing potentially overlapping glyphs).
; Table format is:
; Bits 3-2: dest width
; Bit 1 : 1 if don't need last source byte, 0 if do need last source byte
; Bit 0 : 1 if no rotation (aligned), 0 if rotation (non-aligned)
align 4
OrAllTableNarrow label dword
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd exit_fast_text ;0 wide
dd or_all_1_wide_rotated_need_last ;nonalign, 1 wide, need last
dd or_all_1_wide_unrotated ;aligned, 1 wide
dd or_all_1_wide_rotated_no_last ;nonalign, 1 wide, no last
dd or_all_1_wide_unrotated ;aligned, 1 wide
dd or_all_2_wide_rotated_need_last ;nonalign, 2 wide, need last
dd or_all_2_wide_unrotated ;aligned, 2 wide
dd or_all_2_wide_rotated_no_last ;nonalign, 2 wide, no last
dd or_all_2_wide_unrotated ;aligned, 2 wide
dd or_all_3_wide_rotated_need_last ;nonalign, 3 wide, need last
dd or_all_3_wide_unrotated ;aligned, 3 wide
dd or_all_3_wide_rotated_no_last ;nonalign, 3 wide, no last
dd or_all_3_wide_unrotated ;aligned, 3 wide
dd or_all_4_wide_rotated_need_last ;nonalign, 4 wide, need last
dd or_all_4_wide_unrotated ;aligned, 4 wide
dd or_all_4_wide_rotated_no_last ;nonalign, 4 wide, no last
dd or_all_4_wide_unrotated ;aligned, 4 wide
; Handles arbitrarily wide glyph drawing, for case where initial byte should be
; MOVed even if it's not aligned (intended for use in drawing the first glyph
; in a string). Table format is:
; Bit 1 : 1 if don't need last source byte, 0 if do need last source byte
; Bit 0 : 1 if no rotation (aligned), 0 if rotation (non-aligned)
align 4
MovInitialTableWide label dword
dd mov_first_N_wide_rotated_need_last ;nonalign, need last
dd mov_first_N_wide_unrotated ;aligned
dd mov_first_N_wide_rotated_no_last ;nonalign, no last
dd mov_first_N_wide_unrotated ;aligned
; Handles arbitrarily wide glyph drawing, for case where initial byte should be
; ORed if it's not aligned (intended for use in drawing all but the first glyph
; in a string). Table format is:
; Bit 1 : 1 if don't need last source byte, 0 if do need last source byte
; Bit 0 : 1 if no rotation (aligned), 0 if rotation (non-aligned)
align 4
OrInitialTableWide label dword
dd or_first_N_wide_rotated_need_last ;nonalign, need last
dd mov_first_N_wide_unrotated ;aligned
dd or_first_N_wide_rotated_no_last ;nonalign, no last
dd mov_first_N_wide_unrotated ;aligned
; Handles arbitrarily wide glyph drawing, for case where all bytes should
; be ORed (intended for use in drawing potentially overlapping glyphs).
; Table format is:
; Bit 1 : 1 if don't need last source byte, 0 if do need last source byte
; Bit 0 : 1 if no rotation (aligned), 0 if rotation (non-aligned)
align 4
OrAllTableWide label dword
dd or_all_N_wide_rotated_need_last ;nonalign, need last
dd or_all_N_wide_unrotated ;aligned
dd or_all_N_wide_rotated_no_last ;nonalign, no last
dd or_all_N_wide_unrotated ;aligned
; Vectors to entry points for drawing various types of text. '*' means works as
; is but could be acclerated with a custom scanning loop.
align 4
MasterTextTypeTable label dword ;tops aligned overlap fixed pitch
dd draw_nf_ntb_o_to_temp_start ; N N N *
dd draw_f_ntb_o_to_temp_start ; N N Y *
dd draw_nf_ntb_o_to_temp_start ; N Y N
dd draw_f_ntb_o_to_temp_start ; N Y Y
dd draw_nf_tb_no_to_temp_start ; Y N N
dd draw_f_tb_no_to_temp_start ; Y N Y
dd draw_nf_ntb_o_to_temp_start ; Y Y N *
dd draw_f_ntb_o_to_temp_start ; Y Y Y *
;-----------------------------------------------------------------------;
.code
_TEXT$01 SEGMENT DWORD USE32 PUBLIC 'CODE'
ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
;-----------------------------------------------------------------------;
cProc vFastText,40,<\
uses esi edi ebx,\
pGlyphPos:ptr,\
ulGlyphCount:dword,\
pTempBuffer:ptr,\
ulBufDelta:dword,\
ulCharInc:dword,\
prclText:ptr,\
prclOpaque:ptr,\
fDrawFlags:dword,\
prclClip:dword,\
prclExtra:dword>
local ulGlyDelta:dword ;width per scan of source glyph, in bytes
local ulWidthInBytes:dword ;width of glyph, in bytes
local ulTmpWidthInBytes:dword ;working byte-width count
local ulGlyphX:dword ;for fixed-pitch text, maintains the current
; glyph's left-edge X coordinate
local pGlyphLoop:dword ;pointer to glyph-processing loop
local ulTempLeft:dword ;X coordinate on screen of left edge of temp
; buffer
local ulTempTop:dword ;Y coordinate on screen of top edge of temp
; buffer
local ulTmpSrcDelta:dword ;distance from end of one buffer text scan to
; start of next
local ulTmpDstDelta:dword ;distance from end of one screen text scan to
; start of next
local ulYOrigin:dword ;Y origin of text in string (all glyphs are at
; the same Y origin)
local rclClippedBounds[16]:byte ;clipped destination rectangle;
; defined as "byte" due to assembler
; limitations
local pTempBufferSaved:dword
;-----------------------------------------------------------------------;
;-----------------------------------------------------------------------;
; Draws either a fixed or a non-fixed-pitch string to the temporary
; buffer. Assumes this is a horizontal string, so the origins of all glyphs
; are at the same Y coordinate. Draws leftmost glyph entirely with MOVs,
; even if it's not aligned, in order to ensure that the leftmost byte
; gets cleared when we're working with butted characters. For other
; non-aligned glyphs, leftmost byte is ORed, other bytes are MOVed.
;
; Input:
; pGlyphPos = pointer to array of GLYPHPOS structures to draw
; ulGlyphCount = # of glyphs to draw
; ulTempLeft = X coordinate on dest of left edge of temp buffer pointed
; to by pTempBuffer
; pTempBuffer = pointer to first byte (upper left corner) of
; temp buffer into which we're drawing. This should be
; dword-aligned with the destination
; ulBufDelta = destination scan-to-scan offset
; ulCharInc = offset from one glyph to next (fixed-pitch only)
; fDrawFlags = indicate the type of text to be drawn
; Temp buffer zeroed if text doesn't cover every single pixel
;
; Fixed-pitch means equal spacing between glyph positions, not that all
; glyphs butt together or equal spacing between upper left corners.
;-----------------------------------------------------------------------;
mov ebx,prclText
mov eax,[ebx].yTop
mov ulTempTop,eax ;Y screen coordinate of top edge of temp buf
mov eax,[ebx].xLeft
; !!!!!! and eax,not 7
mov ulTempLeft,eax ;X screen coordinate of left edge of temp buf
mov eax,fDrawFlags
jmp MasterTextTypeTable[eax*4]
;-----------------------------------------------------------------------;
; Entry point for fixed-pitch | tops and bottoms aligned | no overlap.
; Sets up to draw first glyph.
;-----------------------------------------------------------------------;
draw_f_tb_no_to_temp_start::
mov ebx,pGlyphPos ;point to the first glyph to draw
mov esi,[ebx].gp_pgdf ;point to glyph def
mov edi,[ebx].gp_x ;dest X coordinate
sub edi,ulTempLeft ;adjust relative to the left of the
; temp buffer (we assume the text is
; right at the top of the text rect
; and hence the buffer)
mov ulGlyphX,edi ;remember where this glyph started
mov esi,[esi].gdf_pgb ;point to glyph bits
mov pGlyphLoop,offset draw_f_tb_no_to_temp_loop
;draw additional characters with this
; loop
jmp short draw_to_temp_start_entry
;-----------------------------------------------------------------------;
; Entry point for non-fixed-pitch | tops and bottoms aligned | no overlap.
; Sets up to draw first glyph.
;-----------------------------------------------------------------------;
draw_nf_tb_no_to_temp_start::
mov ebx,pGlyphPos ;point to the first glyph to draw
mov esi,[ebx].gp_pgdf ;point to glyph def
mov edi,[ebx].gp_x ;dest X coordinate
sub edi,ulTempLeft ;adjust relative to the left of the
; temp buffer
mov esi,[esi].gdf_pgb ;point to glyph bits
mov pGlyphLoop,offset draw_nf_tb_no_to_temp_loop
;draw additional characters with this
; loop
draw_to_temp_start_entry::
add edi,[esi].gb_x ;adjust to position of upper left glyph
; corner in dest
mov ecx,edi
shr edi,3 ;byte offset of first column of glyph
; offset of upper left of glyph in temp
; buffer
add edi,pTempBuffer ;initial dest byte in temp buffer
and ecx,111b ;bit alignment of upper left in temp
;calculate scan-to-scan glyph width
mov ebx,[esi].gb_cx ;glyph width in pixels
lea eax,[ebx+ecx+7]
shr eax,3 ;# of dest bytes per scan
add ebx,7
shr ebx,3 ;# of source bytes per scan
mov edx,ulBufDelta ;width of destination buffer in bytes
cmp eax,4 ;do we have special case code for this
; dest width?
ja short @F ;no, handle as general case
;yes, handle as special case
cmp ebx,eax ;carry if more dest than source bytes
; (last source byte not needed)
rcl eax,1 ;factor last source byte status in
cmp cl,1 ;carry if aligned
rcl eax,1 ;factor in alignment (aligned or not)
mov ebx,[esi].gb_cy ;# of scans in glyph
add esi,gb_aj ;point to the first glyph byte
jmp MovInitialTableNarrow[eax*4]
;branch to draw the first glyph; never
; need to OR first glyph, because
; there's nothing there yet
@@: ;too wide to special case
mov ulWidthInBytes,eax ;# of bytes across dest
cmp ebx,eax ;carry if more dest than source bytes
; (last source byte not needed)
mov eax,0
rcl eax,1 ;factor last source byte status in
cmp cl,1 ;carry if aligned
rcl eax,1 ;factor in alignment (aligned or not)
mov ebx,[esi].gb_cx ;glyph width in pixels
add ebx,7
shr ebx,3 ;glyph width in bytes
mov ulGlyDelta,ebx
mov ebx,[esi].gb_cy ;# of scans in glyph
add esi,gb_aj ;point to the first glyph byte
jmp MovInitialTableWide[eax*4]
;branch to draw the first glyph; never
; need to OR first glyph, because
; there's nothing there yet
;-----------------------------------------------------------------------;
; Entry point for fixed-pitch | tops and bottoms not aligned | overlap.
; Sets up to draw first glyph.
;-----------------------------------------------------------------------;
draw_f_ntb_o_to_temp_start::
mov ebx,pGlyphPos ;point to the first glyph to draw
mov pGlyphLoop,offset draw_f_ntb_o_to_temp_loop
;draw additional characters with this
; loop
mov edi,[ebx].gp_x ;dest X coordinate
mov esi,[ebx].gp_pgdf ;point to glyph def
sub edi,ulTempLeft ;adjust relative to the left of the
; temp buffer
mov ulGlyphX,edi ;remember where this glyph started
mov esi,[esi].gdf_pgb ;point to glyph bits
add edi,[esi].gb_x ;adjust to position of upper left glyph
; corner in dest
mov ecx,edi
shr edi,3 ;byte offset of first column of glyph
; offset of upper left of glyph in temp
; buffer
jmp short draw_to_temp_start_entry2
;-----------------------------------------------------------------------;
; Entry point for non-fixed-pitch | tops and bottoms not aligned | overlap.
; Sets up to draw first glyph.
;-----------------------------------------------------------------------;
draw_nf_ntb_o_to_temp_start::
mov ebx,pGlyphPos ;point to the first glyph to draw
mov pGlyphLoop,offset draw_nf_ntb_o_to_temp_loop
;draw additional characters with this
; loop
mov edi,[ebx].gp_x ;dest X coordinate
mov esi,[ebx].gp_pgdf ;point to glyph def
sub edi,ulTempLeft ;adjust relative to the left of the
; temp buffer
mov esi,[esi].gdf_pgb ;point to glyph bits
add edi,[esi].gb_x ;adjust to position of upper left glyph
; corner in dest
mov ecx,edi
shr edi,3 ;byte offset of first column of glyph
; offset of upper left of glyph in temp
; buffer
draw_to_temp_start_entry2::
mov eax,[ebx].gp_y ;dest origin Y coordinate
sub eax,ulTempTop ;coord of glyph origin in temp buffer
mov ulYOrigin,eax ;remember the Y origin of all glyphs
; (necessary because glyph positions
; after first aren't set for fixed-
; pitch strings)
add eax,[esi].gb_y ;adjust to position of upper left glyph
; corner in dest
mul ulBufDelta ;offset in buffer of top glyph scan
add eax,pTempBuffer ;initial dest byte
add edi,eax
and ecx,111b ;bit alignment of upper left in temp
;calculate scan-to-scan glyph width
mov ebx,[esi].gb_cx ;glyph width in pixels
lea eax,[ebx+ecx+7]
shr eax,3 ;# of dest bytes per scan
add ebx,7
shr ebx,3 ;# of source bytes per scan
mov edx,ulBufDelta ;width of destination buffer in bytes
cmp eax,4 ;do we have special case code for this
; dest width?
ja short @F ;no, handle as general case
;yes, handle as special case
cmp ebx,eax ;carry if more dest than source bytes
; (last source byte not needed)
rcl eax,1 ;factor last source byte status in
cmp cl,1 ;carry if aligned
rcl eax,1 ;factor in alignment (aligned or not)
mov ebx,[esi].gb_cy ;# of scans in glyph
add esi,gb_aj ;point to the first glyph byte
jmp OrAllTableNarrow[eax*4] ;branch to draw the first glyph; OR all
; glyphs, because text may overlap
@@: ;too wide to special case
mov ulWidthInBytes,eax ;# of bytes across dest
cmp ebx,eax ;carry if more dest than source bytes
; (last source byte not needed)
mov eax,0
rcl eax,1 ;factor last source byte status in
cmp cl,1 ;carry if aligned
rcl eax,1 ;factor in alignment (aligned or not)
mov ebx,[esi].gb_cx ;glyph width in pixels
add ebx,7
shr ebx,3 ;glyph width in bytes
mov ulGlyDelta,ebx
mov ebx,[esi].gb_cy ;# of scans in glyph
add esi,gb_aj ;point to the first glyph byte
jmp OrAllTableWide[eax*4] ;branch to draw the first glyph; OR all
; glyphs, because text may overlap
;-----------------------------------------------------------------------;
; Loop to draw all fixed-pitch | tops and bottoms aligned | no overlap
; glyphs after first.
;-----------------------------------------------------------------------;
draw_f_tb_no_to_temp_loop::
dec ulGlyphCount ;any more glyphs to draw?
jz glyphs_are_done ;no, done
mov ebx,pGlyphPos
add ebx,size GLYPHPOS ;point to the next glyph (the one
mov pGlyphPos,ebx ; we're going to draw this time)
mov esi,[ebx].gp_pgdf ;point to glyph def
mov edi,ulGlyphX ;last glyph's dest X start in temp buf
add edi,ulCharInc ;this glyph's dest X start in temp buf
mov ulGlyphX,edi ;remember for next glyph
mov esi,[esi].gdf_pgb ;point to glyph bits
jmp short draw_to_temp_loop_entry
;-----------------------------------------------------------------------;
; Loop to draw all non-fixed-pitch | tops and bottoms aligned | no overlap
; glyphs after first.
;-----------------------------------------------------------------------;
draw_nf_tb_no_to_temp_loop::
dec ulGlyphCount ;any more glyphs to draw?
jz glyphs_are_done ;no, done
mov ebx,pGlyphPos
add ebx,size GLYPHPOS ;point to the next glyph (the one we're
mov pGlyphPos,ebx ; going to draw this time)
mov esi,[ebx].gp_pgdf ;point to glyph def
mov edi,[ebx].gp_x ;dest X coordinate
mov esi,[esi].gdf_pgb ;point to glyph bits
sub edi,ulTempLeft ;adjust relative to the left edge of
; the temp buffer
draw_to_temp_loop_entry::
add edi,[esi].gb_x ;adjust to position of upper left glyph
; corner in dest
mov ecx,edi ;pixel X coordinate in temp buffer
shr edi,3 ;byte offset of first column = dest
; offset of upper left of glyph in temp
; buffer
add edi,pTempBuffer ;initial dest byte
and ecx,111b ;bit alignment of upper left in temp
;calculate scan-to-scan glyph width
mov ebx,[esi].gb_cx ;glyph width in pixels
lea eax,[ebx+ecx+7]
shr eax,3 ;# of dest bytes to copy to per scan
add ebx,7
shr ebx,3 ;# of source bytes to copy from per
; scan
mov edx,ulBufDelta ;width of destination buffer in bytes
cmp eax,4 ;do we have special case code for this
; dest width?
ja short @F ;no, handle as general case
;yes, handle as special case
cmp ebx,eax ;carry if more dest than source bytes
; (last source byte not needed)
rcl eax,1 ;factor last source byte status in
cmp cl,1 ;carry if aligned
rcl eax,1 ;factor in alignment (aligned or not)
mov ebx,[esi].gb_cy ;# of scans in glyph
add esi,gb_aj ;point to the first glyph byte
jmp OrInitialTableNarrow[eax*4] ;branch to draw the first glyph;
; need to OR the 1st byte if
; non-aligned to avoid overwriting
; what's already there
@@: ;too wide to special case
mov ulWidthInBytes,eax ;# of bytes across dest
cmp ebx,eax ;carry if more dest than source bytes
; (last source byte not needed)
mov eax,0
rcl eax,1 ;factor last source byte status in
cmp cl,1 ;carry if aligned
rcl eax,1 ;factor in alignment (aligned or not)
mov ebx,[esi].gb_cx ;glyph width in pixels
add ebx,7
shr ebx,3 ;glyph width in bytes
mov ulGlyDelta,ebx
mov ebx,[esi].gb_cy ;# of scans in glyph
add esi,gb_aj ;point to the first glyph byte
jmp OrInitialTableWide[eax*4] ;branch to draw the next glyph;
; need to OR the 1st byte if
; non-aligned to avoid overwriting
; what's already there
;-----------------------------------------------------------------------;
; Loop to draw all fixed-pitch | tops and bottoms not aligned | overlap
; glyphs after first.
;-----------------------------------------------------------------------;
draw_f_ntb_o_to_temp_loop::
dec ulGlyphCount ;any more glyphs to draw?
jz glyphs_are_done ;no, done
mov ebx,pGlyphPos
add ebx,size GLYPHPOS ;point to the next glyph (the one we're
mov pGlyphPos,ebx ; going to draw this time)
mov esi,[ebx].gp_pgdf ;point to glyph def
mov edi,ulGlyphX ;last glyph's dest X start in temp buf
add edi,ulCharInc ;this glyph's dest X start in temp buf
mov ulGlyphX,edi ;remember for next glyph
mov esi,[esi].gdf_pgb ;point to glyph bits
mov eax,ulYOrigin ;dest Y coordinate
jmp short draw_to_temp_loop_entry2
;-----------------------------------------------------------------------;
; Loop to draw all non-fixed-pitch | tops and bottoms not aligned | overlap
; glyphs after first.
;-----------------------------------------------------------------------;
draw_nf_ntb_o_to_temp_loop::
dec ulGlyphCount ;any more glyphs to draw?
jz glyphs_are_done ;no, done
mov ebx,pGlyphPos
add ebx,size GLYPHPOS ;point to the next glyph (the one we're
mov pGlyphPos,ebx ; going to draw this time)
mov esi,[ebx].gp_pgdf ;point to glyph def
mov edi,[ebx].gp_x ;dest X coordinate
mov esi,[esi].gdf_pgb ;point to glyph bits
sub edi,ulTempLeft ;adjust relative to the left edge of
; the temp buffer
mov eax,[ebx].gp_y ;dest origin Y coordinate
sub eax,ulTempTop ;coord of glyph origin in temp buffer
draw_to_temp_loop_entry2::
add edi,[esi].gb_x ;adjust to position of upper left glyph
; corner in dest
mov ecx,edi ;pixel X coordinate in temp buffer
shr edi,3 ;byte offset of first column = dest
; offset of upper left of glyph in temp
; buffer
add eax,[esi].gb_y ;adjust to position of upper left glyph
; corner in dest
mul ulBufDelta ;offset in buffer of top glyph scan
add eax,pTempBuffer ;initial dest byte
add edi,eax
and ecx,111b ;bit alignment of upper left in temp
;calculate scan-to-scan glyph width
mov ebx,[esi].gb_cx ;glyph width in pixels
lea eax,[ebx+ecx+7]
shr eax,3 ;# of dest bytes to copy to per scan
add ebx,7
shr ebx,3 ;# of source bytes to copy from per
; scan
mov edx,ulBufDelta ;width of destination buffer in bytes
cmp eax,4 ;do we have special case code for this
; dest width?
ja short @F ;no, handle as general case
;yes, handle as special case
cmp ebx,eax ;carry if more dest than source bytes
; (last source byte not needed)
rcl eax,1 ;factor last source byte status in
cmp cl,1 ;carry if aligned
rcl eax,1 ;factor in alignment (aligned or not)
mov ebx,[esi].gb_cy ;# of scans in glyph
add esi,gb_aj ;point to the first glyph byte
jmp OrAllTableNarrow[eax*4] ;branch to draw the next glyph
@@: ;too wide to special case
mov ulWidthInBytes,eax ;# of bytes across dest
cmp ebx,eax ;carry if more dest than source bytes
; (last source byte not needed)
mov eax,0
rcl eax,1 ;factor last source byte status in
cmp cl,1 ;carry if aligned
rcl eax,1 ;factor in alignment (aligned or not)
mov ebx,[esi].gb_cx ;glyph width in pixels
add ebx,7
shr ebx,3 ;glyph width in bytes
mov ulGlyDelta,ebx
mov ebx,[esi].gb_cy ;# of scans in glyph
add esi,gb_aj ;point to the first glyph byte
jmp OrAllTableWide[eax*4] ;branch to draw the next glyph
;-----------------------------------------------------------------------;
; Routines to draw all scans of a single glyph into the temp buffer,
; optimized for the following cases:
;
; 1 to 4 byte-wide destination rectangles for each of:
; No rotation needed
; Rotation needed, same # of source as dest bytes needed
; Rotation needed, one less source than dest bytes needed
;
; Additionally, the three cases are handled for 5 and wider cases by a
; general routine for each case.
;
; If rotation is needed, there are three sorts of routines:
;
; 1) The leftmost byte is MOVed, to initialize the byte. Succeeding bytes are
; MOVed. This is generally used for the leftmost glyph of a string.
; 2) The leftmost byte is ORed into the existing byte. Succeeding bytes are
; MOVed. This is generally used after the leftmost glyph, because this may
; not be the first data written to that byte.
; 3) All bytes are ORed. This is for drawing when characters might overlap.
;
; If rotation is not needed, there are two sorts of routines:
;
; 1) The leftmost byte is MOVed, to initialize the byte. Succeeding bytes are
; MOVed. This is generally used for the leftmost glyph of a string.
; 2) All bytes are ORed. This is for drawing when characters might overlap.
;
; On entry:
; EBX = # of scans to copy
; CL = right rotation
; EDX = ulBufDelta = width per scan of destination buffer, in bytes
; ESI = pointer to first glyph byte
; EDI = pointer to first dest buffer byte
; DF = cleared
; ulGlyDelta = width per scan of source glyph, in bytes (wide case only)
; ulWidthInBytes = width of glyph, in bytes (required only for 5 and
; wider cases)
;
; On exit:
; Any or all of EAX, EBX, ECX, EDX, ESI, and EDI may be trashed.
;-----------------------------------------------------------------------;
; OR first byte, 1 byte wide dest, rotated.
;-----------------------------------------------------------------------;
or_all_1_wide_rotated_need_last::
or_all_1_wide_rotated_no_last::
or_first_1_wide_rotated_need_last::
or_first_1_wide_rotated_no_last::
or_first_1_wide_rotated_loop::
mov ch,[esi]
inc esi
shr ch,cl
or [edi],ch
add edi,edx
dec ebx
jnz or_first_1_wide_rotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 1 byte wide dest, rotated.
;-----------------------------------------------------------------------;
mov_first_1_wide_rotated_need_last::
mov_first_1_wide_rotated_no_last::
mov_first_1_wide_rotated_loop::
mov ch,[esi]
inc esi
shr ch,cl
mov [edi],ch
add edi,edx
dec ebx
jnz mov_first_1_wide_rotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 1 byte wide dest, unrotated.
;-----------------------------------------------------------------------;
mov_first_1_wide_unrotated::
mov_first_1_wide_unrotated_loop::
mov al,[esi]
inc esi
mov [edi],al
add edi,edx
dec ebx
jnz mov_first_1_wide_unrotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 1 byte wide dest, unrotated.
;-----------------------------------------------------------------------;
or_all_1_wide_unrotated::
or_all_1_wide_unrotated_loop::
mov al,[esi]
inc esi
or [edi],al
add edi,edx
dec ebx
jnz or_all_1_wide_unrotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, 2 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
or_first_2_wide_rotated_need_last::
or_first_2_wide_rotated_need_loop::
mov ax,[esi]
add esi,2
ror ax,cl
or [edi],al
mov [edi+1],ah
add edi,edx
dec ebx
jnz or_first_2_wide_rotated_need_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 2 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
or_all_2_wide_rotated_need_last::
or_all_2_wide_rotated_need_loop::
mov ax,[esi]
add esi,2
ror ax,cl
or [edi],ax
add edi,edx
dec ebx
jnz or_all_2_wide_rotated_need_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 2 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
mov_first_2_wide_rotated_need_last::
mov_first_2_wide_rotated_need_loop::
mov ax,[esi]
add esi,2
ror ax,cl
mov [edi],ax
add edi,edx
dec ebx
jnz mov_first_2_wide_rotated_need_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, 2 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
or_first_2_wide_rotated_no_last::
or_first_2_wide_rotated_loop::
sub eax,eax
mov ah,[esi]
inc esi
shr eax,cl
or [edi],ah
mov [edi+1],al
add edi,edx
dec ebx
jnz or_first_2_wide_rotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 2 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
or_all_2_wide_rotated_no_last::
or_all_2_wide_rotated_loop::
sub eax,eax
mov al,[esi]
inc esi
ror ax,cl
or [edi],ax
add edi,edx
dec ebx
jnz or_all_2_wide_rotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 2 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
mov_first_2_wide_rotated_no_last::
mov_first_2_wide_rotated_loop::
sub eax,eax
mov al,[esi]
inc esi
ror ax,cl
mov [edi],ax
add edi,edx
dec ebx
jnz mov_first_2_wide_rotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 2 bytes wide dest, unrotated.
;-----------------------------------------------------------------------;
mov_first_2_wide_unrotated::
mov_first_2_wide_unrotated_loop::
mov ax,[esi]
add esi,2
mov [edi],ax
add edi,edx
dec ebx
jnz mov_first_2_wide_unrotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 2 bytes wide dest, unrotated.
;-----------------------------------------------------------------------;
or_all_2_wide_unrotated::
or_all_2_wide_unrotated_loop::
mov ax,[esi]
add esi,2
or [edi],ax
add edi,edx
dec ebx
jnz or_all_2_wide_unrotated_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, 3 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
or_first_3_wide_rotated_need_last::
@@:
mov al,[esi]
shr al,cl
or [edi],al
mov ax,[esi]
ror ax,cl
mov [edi+1],ah
mov ax,[esi+1]
add esi,3
ror ax,cl
mov [edi+2],ah
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, 3 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
or_all_3_wide_rotated_need_last::
@@:
mov al,[esi]
shr al,cl
or [edi],al
mov ax,[esi]
ror ax,cl
or [edi+1],ah
mov ax,[esi+1]
add esi,3
ror ax,cl
or [edi+2],ah
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 3 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
mov_first_3_wide_rotated_need_last::
@@:
mov al,[esi]
shr al,cl
mov [edi],al
mov ax,[esi]
ror ax,cl
mov [edi+1],ah
mov ax,[esi+1]
add esi,3
ror ax,cl
mov [edi+2],ah
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, 3 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
or_first_3_wide_rotated_no_last::
neg cl
and cl,111b ;convert from right shift to left shift
@@:
sub eax,eax
mov ax,[esi]
add esi,2
xchg ah,al
shl eax,cl
mov [edi+1],ah
mov [edi+2],al
shr eax,16
or [edi],al
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 3 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
or_all_3_wide_rotated_no_last::
neg cl
and cl,111b ;convert from right shift to left shift
@@:
sub eax,eax
mov ax,[esi]
add esi,2
xchg ah,al
shl eax,cl
xchg ah,al
or [edi+1],ax
shr eax,16
or [edi],al
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 3 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
mov_first_3_wide_rotated_no_last::
neg cl
and cl,111b ;convert from right shift to left shift
@@:
sub eax,eax
mov ax,[esi]
add esi,2
xchg ah,al
shl eax,cl
mov [edi+1],ah
mov [edi+2],al
shr eax,16
mov [edi],al
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 3 bytes wide dest, unrotated.
;-----------------------------------------------------------------------;
mov_first_3_wide_unrotated::
@@:
mov ax,[esi]
mov [edi],ax
mov al,[esi+2]
add esi,3
mov [edi+2],al
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 3 bytes wide dest, unrotated.
;-----------------------------------------------------------------------;
or_all_3_wide_unrotated::
@@:
mov ax,[esi]
or [edi],ax
mov al,[esi+2]
add esi,3
or [edi+2],al
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, 4 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
or_first_4_wide_rotated_need_last::
@@:
mov eax,[esi]
add esi,4
xchg ah,al
ror eax,16
xchg ah,al
shr eax,cl
xchg ah,al
mov [edi+2],ax
shr eax,16
mov [edi+1],al
or [edi],ah
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 4 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
or_all_4_wide_rotated_need_last::
@@:
mov eax,[esi]
add esi,4
xchg ah,al
ror eax,16
xchg ah,al
shr eax,cl
xchg ah,al
ror eax,16
xchg al,ah
or [edi],eax
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 4 bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
mov_first_4_wide_rotated_need_last::
@@:
mov eax,[esi]
add esi,4
xchg ah,al
ror eax,16
xchg ah,al
shr eax,cl
xchg ah,al
ror eax,16
xchg ah,al
mov [edi],eax
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, 4 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
or_first_4_wide_rotated_no_last::
@@:
mov ax,[esi]
xchg ah,al
shl eax,16
mov ah,[esi+2]
add esi,3
shr eax,cl
xchg ah,al
mov [edi+2],ax
shr eax,16
mov [edi+1],al
or [edi],ah
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 4 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
or_all_4_wide_rotated_no_last::
@@:
mov ax,[esi]
xchg ah,al
shl eax,16
mov ah,[esi+2]
add esi,3
shr eax,cl
xchg ah,al
ror eax,16
xchg ah,al
or [edi],eax
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 4 bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
mov_first_4_wide_rotated_no_last::
@@:
mov ax,[esi]
xchg ah,al
shl eax,16
mov ah,[esi+2]
add esi,3
shr eax,cl
xchg ah,al
ror eax,16
xchg ah,al
mov [edi],eax
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, 4 bytes wide dest, unrotated.
;-----------------------------------------------------------------------;
mov_first_4_wide_unrotated::
@@:
mov eax,[esi]
add esi,4
mov [edi],eax
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, 4 bytes wide dest, unrotated.
;-----------------------------------------------------------------------;
or_all_4_wide_unrotated::
@@:
mov eax,[esi]
add esi,4
or [edi],eax
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, n bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
or_first_N_wide_rotated_need_last::
mov eax,ulWidthInBytes
mov edx,ulBufDelta
sub edx,eax
mov ulTmpDstDelta,edx
dec eax ;source doesn't advance after first byte, and
; we do the first byte outside the loop
mov edx,ulGlyDelta
sub edx,eax
mov ulTmpSrcDelta,edx
mov ulTmpWidthInBytes,eax
ofNwrnl_scan_loop:
mov al,[esi] ;do the initial, ORed byte separately
shr al,cl
or [edi],al
inc edi
mov edx,ulTmpWidthInBytes
@@:
mov ax,[esi]
inc esi
ror ax,cl
mov [edi],ah
inc edi
dec edx
jnz @B
add esi,ulTmpSrcDelta
add edi,ulTmpDstDelta
dec ebx
jnz ofNwrnl_scan_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, n bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
or_all_N_wide_rotated_need_last::
mov eax,ulWidthInBytes
mov edx,ulBufDelta
sub edx,eax
mov ulTmpDstDelta,edx
dec eax ;source doesn't advance after first byte, and
; we do the first byte outside the loop
mov edx,ulGlyDelta
sub edx,eax
mov ulTmpSrcDelta,edx
mov ulTmpWidthInBytes,eax
oaNwrnl_scan_loop:
mov al,[esi] ;do the initial, ORed byte separately
shr al,cl
or [edi],al
inc edi
mov edx,ulTmpWidthInBytes
@@:
mov ax,[esi]
inc esi
ror ax,cl
or [edi],ah
inc edi
dec edx
jnz @B
add esi,ulTmpSrcDelta
add edi,ulTmpDstDelta
dec ebx
jnz oaNwrnl_scan_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, n bytes wide dest, rotated, need final source byte.
;-----------------------------------------------------------------------;
mov_first_N_wide_rotated_need_last::
mov eax,ulWidthInBytes
mov edx,ulBufDelta
sub edx,eax
mov ulTmpDstDelta,edx
mov eax,ulWidthInBytes
dec eax ;source doesn't advance after first byte, and
; we do the first byte outside the loop
mov edx,ulGlyDelta
sub edx,eax
mov ulTmpSrcDelta,edx
mov ulTmpWidthInBytes,eax
mfNwrnl_scan_loop:
mov al,[esi] ;do the initial byte separately
shr al,cl
mov [edi],al
inc edi
mov edx,ulTmpWidthInBytes
@@:
mov ax,[esi]
inc esi
ror ax,cl
mov [edi],ah
inc edi
dec edx
jnz @B
add esi,ulTmpSrcDelta
add edi,ulTmpDstDelta
dec ebx
jnz mfNwrnl_scan_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR first byte, N bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
or_first_N_wide_rotated_no_last::
mov eax,ulWidthInBytes
dec eax ;one less because we don't advance after the
; last byte
mov edx,ulBufDelta
sub edx,eax
mov ulTmpDstDelta,edx
dec eax ;source doesn't advance after first byte, and
; we do the first & last bytes outside the
; loop; already subtracted 1 above
mov edx,ulGlyDelta
sub edx,eax
mov ulTmpSrcDelta,edx
mov ulTmpWidthInBytes,eax
ofNwr_scan_loop:
mov al,[esi] ;do the initial, ORed byte separately
shr al,cl
or [edi],al
inc edi
mov edx,ulTmpWidthInBytes
@@:
mov ax,[esi]
inc esi
ror ax,cl
mov [edi],ah
inc edi
dec edx
jnz @B
mov ah,[esi] ;do the final byte separately
sub al,al
shr eax,cl
mov [edi],al
add esi,ulTmpSrcDelta
add edi,ulTmpDstDelta
dec ebx
jnz ofNwr_scan_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, N bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
or_all_N_wide_rotated_no_last::
mov eax,ulWidthInBytes
dec eax ;one less because we don't advance after the
; last byte
mov edx,ulBufDelta
sub edx,eax
mov ulTmpDstDelta,edx
dec eax ;source doesn't advance after first byte, and
; we do the first & last bytes outside the
; loop; already subtracted 1 above
mov edx,ulGlyDelta
sub edx,eax
mov ulTmpSrcDelta,edx
mov ulTmpWidthInBytes,eax
oaNwr_scan_loop:
mov al,[esi] ;do the initial, ORed byte separately
shr al,cl
or [edi],al
inc edi
mov edx,ulTmpWidthInBytes
@@:
mov ax,[esi]
inc esi
ror ax,cl
or [edi],ah
inc edi
dec edx
jnz @B
mov ah,[esi] ;do the final byte separately
sub al,al
shr eax,cl
or [edi],al
add esi,ulTmpSrcDelta
add edi,ulTmpDstDelta
dec ebx
jnz oaNwr_scan_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, N bytes wide dest, rotated, don't need final source byte.
;-----------------------------------------------------------------------;
mov_first_N_wide_rotated_no_last::
mov eax,ulWidthInBytes
dec eax ;one less because we don't advance after the
; last byte
mov edx,ulBufDelta
sub edx,eax
mov ulTmpDstDelta,edx
dec eax ;source doesn't advance after first byte, and
; we do the first & last bytes outside the
; loop; already subtracted 1 above
mov edx,ulGlyDelta
sub edx,eax
mov ulTmpSrcDelta,edx
mov ulTmpWidthInBytes,eax
mfNwr_scan_loop:
mov al,[esi] ;do the initial byte separately
shr al,cl
mov [edi],al
inc edi
mov edx,ulTmpWidthInBytes
@@:
mov ax,[esi]
inc esi
ror ax,cl
mov [edi],ah
inc edi
dec edx
jnz @B
mov ah,[esi] ;do the final byte separately
sub al,al
shr eax,cl
mov [edi],al
add esi,ulTmpSrcDelta
add edi,ulTmpDstDelta
dec ebx
jnz mfNwr_scan_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; MOV first byte, N bytes wide dest, unrotated.
;-----------------------------------------------------------------------;
mov_first_N_wide_unrotated::
mov edx,ulBufDelta
mov eax,ulWidthInBytes
sub edx,eax
shr eax,1 ;width in words
jc short odd_width ;there's at least one odd byte
shr eax,1 ;width in dwords
jc short two_odd_bytes ;there's an odd word
;copy width is a dword multiple
@@:
mov ecx,eax
rep movsd ;copy as many dwords as possible
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
odd_width::
shr eax,1 ;width in dwords
jc short three_odd_bytes ;there's an odd word and an odd byte
;there's just an odd byte
inc edx ;because we won't advance after last byte
@@:
mov ecx,eax
rep movsd ;copy as many dwords as possible
mov cl,[esi]
inc esi
mov [edi],cl
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
two_odd_bytes::
add edx,2 ;because we won't advance after last word
@@:
mov ecx,eax
rep movsd ;copy as many dwords as possible
mov cx,[esi]
add esi,2
mov [edi],cx
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
three_odd_bytes::
add edx,3 ;because we won't advance after last word/byte
@@:
mov ecx,eax
rep movsd ;copy as many dwords as possible
mov cx,[esi]
mov [edi],cx
mov cl,[esi+2]
add esi,3
mov [edi+2],cl
add edi,edx
dec ebx
jnz @B
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; OR all bytes, N bytes wide dest, unrotated.
;-----------------------------------------------------------------------;
or_all_N_wide_unrotated::
mov edx,ulBufDelta
mov eax,ulWidthInBytes
sub edx,eax
shr eax,1 ;width in words
jc short or_odd_width ;there's at least one odd byte
shr eax,1 ;width in dwords
jc short or_two_odd_bytes ;there's an odd word
;copy width is a dword multiple
or_no_odd_bytes_loop::
push ebx ;preserve scan count
mov ebx,eax
@@:
mov ecx,[esi]
add esi,4
or [edi],ecx
add edi,4 ;copy as many dwords as possible
dec ebx
jnz @B
add edi,edx
pop ebx ;restore scan count
dec ebx
jnz or_no_odd_bytes_loop
jmp pGlyphLoop
or_odd_width::
shr eax,1 ;width in dwords
jc short or_three_odd_bytes ;there's an odd word and an odd byte
;there's just an odd byte
inc edx ;skip over last byte too
or_one_odd_bytes_loop::
push ebx ;preserve scan count
mov ebx,eax
@@:
mov ecx,[esi]
add esi,4
or [edi],ecx
add edi,4 ;copy as many dwords as possible
dec ebx
jnz @B
mov cl,[esi]
or [edi],cl
inc esi
add edi,edx
pop ebx ;restore scan count
dec ebx
jnz or_one_odd_bytes_loop
jmp pGlyphLoop
or_two_odd_bytes::
add edx,2 ;skip over last 2 bytes too
or_two_odd_bytes_loop::
push ebx ;preserve scan count
mov ebx,eax
@@:
mov ecx,[esi]
add esi,4
or [edi],ecx
add edi,4 ;copy as many dwords as possible
dec ebx
jnz @B
mov cx,[esi]
or [edi],cx
add esi,2
add edi,edx
pop ebx ;restore scan count
dec ebx
jnz or_two_odd_bytes_loop
jmp pGlyphLoop
or_three_odd_bytes::
add edx,3 ;skip over last 3 bytes too
or_three_odd_bytes_loop::
push ebx ;preserve scan count
mov ebx,eax
@@:
mov ecx,[esi]
add esi,4
or [edi],ecx
add edi,4 ;copy as many dwords as possible
dec ebx
jnz @B
mov cx,[esi]
or [edi],cx
mov cl,[esi+2]
or [edi+2],cl
add esi,3
add edi,edx
pop ebx ;restore scan count
dec ebx
jnz or_three_odd_bytes_loop
jmp pGlyphLoop
;-----------------------------------------------------------------------;
; At this point, the text is drawn to the temp buffer.
; Now, draw the extra rectangles to the temp buffer.
;
; Input:
; prclText = pointer to text bounding rectangle
; prclOpaque = pointer to opaquing rectangle, if there is one
; ulTempLeft = X coordinate on dest of left edge of temp buffer pointed
; to by pTempBuffer
; pTempBuffer = pointer to first byte (upper left corner) of
; temp buffer into which we're drawing. This should be
; dword-aligned with the destination
; ulBufDelta = destination scan-to-scan offset
; Text drawn to temp buffer
;
;-----------------------------------------------------------------------;
glyphs_are_done::
mov esi,prclExtra
test esi,esi ;is prclExtra NULL?
jz extra_rects_are_done ;yes
; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
; !!! Should handle prclExtra here and set GCAPS_HORIZSTRIKE !!!
; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;-----------------------------------------------------------------------;
; At this point, the text is drawn to the temp buffer, and any extra
; rectangles (underline, strikeout) are drawn to the temp buffer.
; Now, draw the temp buffer to the screen.
;
; Input:
; prclText = pointer to text bounding rectangle
; prclOpaque = pointer to opaquing rectangle, if there is one
; ulTempLeft = X coordinate on dest of left edge of temp buffer pointed
; to by pTempBuffer
; pTempBuffer = pointer to first byte (upper left corner) of
; temp buffer into which we're drawing. This should be
; dword-aligned with the destination
; ulBufDelta = destination scan-to-scan offset
; Text drawn to temp buffer
;
;-----------------------------------------------------------------------;
extra_rects_are_done::
;-----------------------------------------------------------------------;
; Clip to the clip rectangle, if necessary.
;-----------------------------------------------------------------------;
mov esi,prclText
mov edi,prclClip
test edi,edi ;is there clipping?
jz exit_fast_text ;no
mov ebx,pTempBuffer
mov pTempBufferSaved,ebx
jmp short do_opaque_clip
;-----------------------------------------------------------------------;
; Handle rectangle clipping.
;-----------------------------------------------------------------------;
get_next_clip_rect::
mov esi,prclText
mov edi,prclClip ;make sure edi has prclClip
test edi,edi ;was this null?
jz exit_fast_text ;yep
add edi,size RECTL ;no, next rect
mov prclClip,edi ;don't forget the increment
mov ebx,pTempBufferSaved
mov pTempBuffer,ebx
do_opaque_clip::
mov ebx,[edi].yBottom
test ebx,ebx ;is it a null rectangle?
jz exit_fast_text ;yes
mov ebx,[esi].yBottom
cmp [edi].yBottom,ebx ;is the bottom edge of the text box clipped?
jg short @F ;no
mov ebx,[edi].yBottom ;yes
@@:
mov dword ptr rclClippedBounds.yBottom,ebx ;set the (possibly
; clipped) bottom edge
mov eax,[esi].yTop
cmp [edi].yTop,eax ;is the top edge of the text box clipped?
jle short @F ;no
;yes
sub eax,[edi].yTop
neg eax ;# of scans we just clipped off
mul ulBufDelta ;# of bytes by which to advance through source
add pTempBuffer,eax ;advance in source to account for Y clipping
mov eax,[edi].yTop ;new top edge
@@:
mov dword ptr rclClippedBounds.yTop,eax ;set the (possibly clipped)
; top edge
cmp eax,ebx ;is there a gap between clipped top & bottom?
jnl get_next_clip_rect ;no, fully clipped
mov edx,[esi].xRight
cmp [edi].xRight,edx ;is the right edge of the text box clipped?
jg short @F ;no
mov edx,[edi].xRight ;yes
@@:
mov dword ptr rclClippedBounds.xRight,edx ;set the (possibly
; clipped) right edge
mov eax,[esi].xLeft
cmp [edi].xLeft,eax ;is the left edge of the text box clipped?
jle short @F ;no
;yes
mov ebx,[edi].xLeft ;EBX = new left edge
and eax,not 0111b ;floor the old left edge in its byte
sub ebx,eax
shr ebx,3 ;# of bytes to advance in source
add pTempBuffer,ebx ;advance in source to account for X clipping
mov eax,[edi].xLeft ;new left edge
@@:
mov dword ptr rclClippedBounds.xLeft,eax ;set the (possibly
; clipped) left edge
cmp eax,edx ;is there a gap between clipped left & right?
jnl get_next_clip_rect ;no, fully clipped
lea esi,rclClippedBounds ;this is now the destination rect
;-----------------------------------------------------------------------;
; ESI->destination text rectangle at this point
;-----------------------------------------------------------------------;
exit_fast_text::
cRet vFastText
endProc vFastText
;-----------------------------------------------------------------------;
; VOID vClearMemDword(ULONG * pulBuffer, ULONG ulDwordCount);
;
; Clears ulCount dwords starting at pjBuffer.
;-----------------------------------------------------------------------;
pulBuffer equ [esp+8]
ulDwordCount equ [esp+12]
cProc vClearMemDword,8,<>
push edi
mov edi,pulBuffer
mov ecx,ulDwordCount
sub eax,eax
rep stosd
pop edi
cRet vClearMemDword
endProc vClearMemDword
public draw_f_tb_no_to_temp_start
public draw_nf_tb_no_to_temp_start
public draw_to_temp_start_entry
public draw_f_ntb_o_to_temp_start
public draw_nf_ntb_o_to_temp_start
public draw_to_temp_start_entry2
public draw_f_tb_no_to_temp_loop
public draw_nf_tb_no_to_temp_loop
public draw_to_temp_loop_entry
public draw_f_ntb_o_to_temp_loop
public draw_nf_ntb_o_to_temp_loop
public draw_to_temp_loop_entry2
public or_all_1_wide_rotated_need_last
public or_all_1_wide_rotated_no_last
public or_first_1_wide_rotated_need_last
public or_first_1_wide_rotated_no_last
public or_first_1_wide_rotated_loop
public mov_first_1_wide_rotated_need_last
public mov_first_1_wide_rotated_no_last
public mov_first_1_wide_rotated_loop
public mov_first_1_wide_unrotated
public mov_first_1_wide_unrotated_loop
public or_all_1_wide_unrotated
public or_all_1_wide_unrotated_loop
public or_first_2_wide_rotated_need_last
public or_first_2_wide_rotated_need_loop
public or_all_2_wide_rotated_need_last
public or_all_2_wide_rotated_need_loop
public mov_first_2_wide_rotated_need_last
public mov_first_2_wide_rotated_need_loop
public or_first_2_wide_rotated_no_last
public or_first_2_wide_rotated_loop
public or_all_2_wide_rotated_no_last
public or_all_2_wide_rotated_loop
public mov_first_2_wide_rotated_no_last
public mov_first_2_wide_rotated_loop
public mov_first_2_wide_unrotated
public mov_first_2_wide_unrotated_loop
public or_all_2_wide_unrotated
public or_all_2_wide_unrotated_loop
public or_first_3_wide_rotated_need_last
public or_all_3_wide_rotated_need_last
public mov_first_3_wide_rotated_need_last
public or_first_3_wide_rotated_no_last
public or_all_3_wide_rotated_no_last
public mov_first_3_wide_rotated_no_last
public mov_first_3_wide_unrotated
public or_all_3_wide_unrotated
public or_first_4_wide_rotated_need_last
public or_all_4_wide_rotated_need_last
public mov_first_4_wide_rotated_need_last
public or_first_4_wide_rotated_no_last
public or_all_4_wide_rotated_no_last
public mov_first_4_wide_rotated_no_last
public mov_first_4_wide_unrotated
public or_all_4_wide_unrotated
public or_first_N_wide_rotated_need_last
public or_all_N_wide_rotated_need_last
public mov_first_N_wide_rotated_need_last
public or_first_N_wide_rotated_no_last
public or_all_N_wide_rotated_no_last
public mov_first_N_wide_rotated_no_last
public mov_first_N_wide_unrotated
public odd_width
public two_odd_bytes
public three_odd_bytes
public or_all_N_wide_unrotated
public or_no_odd_bytes_loop
public or_odd_width
public or_one_odd_bytes_loop
public or_two_odd_bytes
public or_two_odd_bytes_loop
public or_three_odd_bytes
public or_three_odd_bytes_loop
public glyphs_are_done
public extra_rects_are_done
public get_next_clip_rect
public do_opaque_clip
_TEXT$01 ends
end
|
ada/stddef_h.ads | simonjwright/VL53L1X | 0 | 29914 | <reponame>simonjwright/VL53L1X
pragma Ada_2012;
pragma Style_Checks (Off);
pragma Warnings ("U");
with Interfaces.C; use Interfaces.C;
with System;
package stddef_h is
-- unsupported macro: NULL __null
-- arg-macro: procedure offsetof (TYPE, MEMBER)
-- __builtin_offsetof (TYPE, MEMBER)
subtype ptrdiff_t is int; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:143
subtype size_t is unsigned; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:209
-- skipped anonymous struct anon_anon_0
type max_align_t is record
uu_max_align_ll : aliased Long_Long_Integer; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:416
uu_max_align_ld : aliased long_double; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:417
end record
with Convention => C_Pass_By_Copy; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:426
subtype nullptr_t is System.Address; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:433
end stddef_h;
|
programs/oeis/227/A227121.asm | karttu/loda | 0 | 27201 | <reponame>karttu/loda
; A227121: Number of n X 2 0,1 arrays indicating 2 X 2 subblocks of some larger (n+1) X 3 binary array having a sum of zero, with rows and columns of the latter in lexicographically nondecreasing order.
; 3,7,13,23,40,68,112,178,273,405,583,817,1118,1498,1970,2548,3247,4083,5073,6235,7588,9152,10948,12998,15325,17953,20907,24213,27898,31990,36518,41512,47003,53023,59605,66783,74592,83068,92248,102170,112873,124397,136783,150073,164310,179538,195802,213148,231623,251275,272153,294307,317788,342648,368940,396718,426037,456953,489523,523805,559858,597742,637518,679248,722995,768823,816797,866983,919448,974260,1031488,1091202,1153473,1218373,1285975,1356353,1429582,1505738,1584898,1667140,1752543,1841187,1933153,2028523,2127380,2229808,2335892,2445718,2559373,2676945,2798523,2924197,3054058,3188198,3326710,3469688,3617227,3769423,3926373,4088175,4254928,4426732,4603688,4785898,4973465,5166493,5365087,5569353,5779398,5995330,6217258,6445292,6679543,6920123,7167145,7420723,7680972,7948008,8221948,8502910,8791013,9086377,9389123,9699373,10017250,10342878,10676382,11017888,11367523,11725415,12091693,12466487,12849928,13242148,13643280,14053458,14472817,14901493,15339623,15787345,16244798,16712122,17189458,17676948,18174735,18682963,19201777,19731323,20271748,20823200,21385828,21959782,22545213,23142273,23751115,24371893,25004762,25649878,26307398,26977480,27660283,28355967,29064693,29786623,30521920,31270748,32033272,32809658,33600073,34404685,35223663,36057177,36905398,37768498,38646650,39540028,40448807,41373163,42313273,43269315,44241468,45229912,46234828,47256398,48294805,49350233,50422867,51512893,52620498,53745870,54889198,56050672,57230483,58428823,59645885,60881863,62136952,63411348,64705248,66018850,67352353,68705957,70079863,71474273,72889390,74325418,75782562,77261028,78761023,80282755
lpb $0,1
sub $0,1
add $1,1
add $4,$1
add $2,$4
add $3,$2
add $3,3
sub $3,$4
lpe
add $3,1
add $3,$4
mov $0,$3
add $0,6
mov $1,$0
sub $1,4
|
public/wintab/wintabx/datapeek.asm | DannyParker0001/Kisak-Strike | 252 | 15712 | include xlibproc.inc
include Wintab.inc
PROC_TEMPLATE WTDataPeek, 8, Wintab, -, 82
|
msp430x2/mspgd-spi-peripheral.adb | ekoeppen/MSP430_Generic_Ada_Drivers | 0 | 14658 | with MSP430_SVD.USCI_A0_SPI_MODE; use MSP430_SVD.USCI_A0_SPI_MODE;
with MSP430_SVD.USCI_B0_SPI_MODE; use MSP430_SVD.USCI_B0_SPI_MODE;
with MSP430_SVD.SPECIAL_FUNCTION; use MSP430_SVD.SPECIAL_FUNCTION;
package body MSPGD.SPI.Peripheral is
procedure Init is
use MSPGD.Clock;
Baud_Rate_Div : constant UInt32 := UInt32 (Clock.Frequency) / Speed;
begin
case Module is
when USCI_A =>
USCI_A0_SPI_MODE_Periph.UCA0CTL1_SPI.UCSWRST := 1;
case Clock.Source is
when ACLK => USCI_A0_SPI_MODE_Periph.UCA0CTL1_SPI.UCSSEL := UCSSEL_1;
when SMCLK => USCI_A0_SPI_MODE_Periph.UCA0CTL1_SPI.UCSSEL := UCSSEL_2;
when others => null;
end case;
USCI_A0_SPI_MODE_Periph.UCA0BR0_SPI := Byte (Baud_Rate_Div mod 256);
USCI_A0_SPI_MODE_Periph.UCA0BR1_SPI := Byte ((Baud_Rate_Div / 256) mod 256);
USCI_A0_SPI_MODE_Periph.UCA0CTL0_SPI := (
UCMSB => 1,
UCMST => 1,
UCSYNC => 1,
UCCKPH => (if Mode = Mode_0 or else Mode = Mode_2 then 1 else 0),
UCCKPL => (if Mode = Mode_1 or else Mode = Mode_3 then 1 else 0),
UCMODE => Ucmode_0,
others => 0
);
USCI_A0_SPI_MODE_Periph.UCA0CTL1_SPI.UCSWRST := 0;
when USCI_B =>
USCI_B0_SPI_MODE_Periph.UCB0CTL1_SPI.UCSWRST := 1;
case Clock.Source is
when ACLK => USCI_B0_SPI_MODE_Periph.UCB0CTL1_SPI.UCSSEL := UCSSEL_1;
when SMCLK => USCI_B0_SPI_MODE_Periph.UCB0CTL1_SPI.UCSSEL := UCSSEL_2;
when others => null;
end case;
USCI_B0_SPI_MODE_Periph.UCB0BR0_SPI := Byte (Baud_Rate_Div mod 256);
USCI_B0_SPI_MODE_Periph.UCB0BR1_SPI := Byte ((Baud_Rate_Div / 256) mod 256);
USCI_B0_SPI_MODE_Periph.UCB0CTL0_SPI := (
UCMSB => 1,
UCMST => 1,
UCSYNC => 1,
UCCKPH => (if Mode = Mode_0 or else Mode = Mode_2 then 1 else 0),
UCCKPL => (if Mode = Mode_1 or else Mode = Mode_3 then 1 else 0),
UCMODE => Ucmode_0,
others => 0
);
USCI_B0_SPI_MODE_Periph.UCB0CTL1_SPI.UCSWRST := 0;
end case;
end Init;
procedure Wait_For_TX_Complete is
begin
case Module is
when USCI_A => while SPECIAL_FUNCTION_Periph.IFG2.UCA0TXIFG = 0 loop null; end loop;
when USCI_B => while SPECIAL_FUNCTION_Periph.IFG2.UCB0TXIFG = 0 loop null; end loop;
end case;
end Wait_For_TX_Complete;
procedure Wait_For_RX_Complete is
begin
case Module is
when USCI_A => while SPECIAL_FUNCTION_Periph.IFG2.UCA0RXIFG = 0 loop null; end loop;
when USCI_B => while SPECIAL_FUNCTION_Periph.IFG2.UCB0RXIFG = 0 loop null; end loop;
end case;
end Wait_For_RX_Complete;
procedure Transfer (Data : in out Unsigned_8) is
begin
Wait_For_TX_Complete;
case Module is
when USCI_A => USCI_A0_SPI_MODE_Periph.UCA0TXBUF_SPI := Byte (Data);
when USCI_B => USCI_B0_SPI_MODE_Periph.UCB0TXBUF_SPI := Byte (Data);
end case;
Wait_For_RX_Complete;
case Module is
when USCI_A => Data := Unsigned_8 (USCI_A0_SPI_MODE_Periph.UCA0RXBUF_SPI);
when USCI_B => Data := Unsigned_8 (USCI_B0_SPI_MODE_Periph.UCB0RXBUF_SPI);
end case;
end Transfer;
procedure Transfer (Data : in out Buffer_Type) is
begin
for I in Data'Range loop
Transfer (Data (I));
end loop;
end Transfer;
procedure Send (Data : in Unsigned_8) is
D : Unsigned_8 := Data;
begin
Transfer (D);
end Send;
procedure Send (Data : in Buffer_Type) is
begin
for D of Data loop
Send (D);
end loop;
end Send;
procedure Receive (Data : out Unsigned_8) is
D : Unsigned_8 := 0;
begin
Transfer (D);
Data := D;
end Receive;
procedure Receive (Data : out Buffer_Type) is
begin
for I in Data'Range loop
Receive (Data (I));
end loop;
end Receive;
end MSPGD.SPI.Peripheral;
|
experiments/test-suite/mutation-based/10/4/fullTree.als | kaiyuanw/AlloyFLCore | 1 | 3387 | <gh_stars>1-10
pred test34 {
some disj Node0, Node1: Node {
Node = Node0 + Node1
left = Node1->Node0 + Node1->Node1
right = Node1->Node1
}
}
run test34 for 3 expect 0
pred test25 {
some disj Node0, Node1: Node {
Node = Node0 + Node1
no left
no right
makeFull[]
}
}
run test25 for 3 expect 1
pred test44 {
some disj Node0, Node1: Node {
Node = Node0 + Node1
left = Node1->Node1
right = Node0->Node1 + Node1->Node0
}
}
run test44 for 3 expect 1
pred test22 {
some disj Node0, Node1, Node2: Node {
Node = Node0 + Node1 + Node2
no left
right = Node0->Node2 + Node1->Node0
Acyclic[]
}
}
run test22 for 3 expect 1
|
programs/oeis/190/A190787.asm | neoneye/loda | 22 | 19365 | <reponame>neoneye/loda
; A190787: Odd powers of 2 and 9 times odd powers of 2, sorted.
; 2,8,18,32,72,128,288,512,1152,2048,4608,8192,18432,32768,73728,131072,294912,524288,1179648,2097152,4718592,8388608,18874368,33554432,75497472,134217728,301989888,536870912,1207959552,2147483648,4831838208,8589934592,19327352832,34359738368,77309411328,137438953472,309237645312
seq $0,27383 ; Number of balanced strings of length n: let d(S) = #(1's) - #(0's), # == count in S, then S is balanced if every substring T of S has -2 <= d(T) <= 2.
div $0,2
add $0,1
pow $0,2
mul $0,2
|
software/hal/boards/pixhawk/hil/hil-i2c.adb | TUM-EI-RCS/StratoX | 12 | 23649 | -- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: <NAME> (<EMAIL>)
with STM32.I2C;
with STM32.Device;
with HAL.I2C;
with HMC5883L.Register;
with Interfaces.Bit_Types; use Interfaces.Bit_Types;
-- @summary
-- Target-specific mapping for HIL of I2C
package body HIL.I2C with
SPARK_Mode => Off
is
ADDR_HMC5883L :constant HAL.I2C.I2C_Address := HMC5883L.Register.HMC5883L_ADDRESS;
procedure initialize is
Config : constant STM32.I2C.I2C_Configuration := (
Clock_Speed => 100_000,
Mode => STM32.I2C.I2C_Mode,
Duty_Cycle => STM32.I2C.DutyCycle_2,
Addressing_Mode => STM32.I2C.Addressing_Mode_7bit,
Own_Address => 16#00#,
General_Call_Enabled => False,
Clock_Stretching_Enabled => False
);
begin
STM32.Device.Reset(STM32.Device.I2C_1);
STM32.I2C.Configure(STM32.Device.I2C_1, Config);
-- is_Init := True;
end initialize;
procedure write (Device : in Device_Type; Data : in Data_Type) is
Status : HAL.I2C.I2C_Status;
begin
case (Device) is
when UNKNOWN => null;
when MAGNETOMETER =>
STM32.I2C.Master_Transmit(STM32.Device.I2C_1, ADDR_HMC5883L, HAL.I2C.I2C_Data( Data ), Status);
end case;
end write;
procedure read (Device : in Device_Type; Data : out Data_Type) is
Data_RX_I2C : HAL.I2C.I2C_Data(1 .. Data'Length);
Status : HAL.I2C.I2C_Status;
begin
case (Device) is
when UNKNOWN => null;
when MAGNETOMETER =>
STM32.I2C.Master_Receive(STM32.Device.I2C_1, ADDR_HMC5883L, Data_RX_I2C, Status);
Data := Data_Type( Data_RX_I2C);
end case;
end read;
procedure transfer (Device : in Device_Type; Data_TX : in Data_Type; Data_RX : out Data_Type) is
Data_RX_I2C : HAL.I2C.I2C_Data(1 .. Data_RX'Length);
Status : HAL.I2C.I2C_Status;
begin
case (Device) is
when UNKNOWN => null;
when MAGNETOMETER =>
STM32.I2C.Mem_Read(STM32.Device.I2C_1, ADDR_HMC5883L, Short( Data_TX(1) ), HAL.I2C.Memory_Size_8b, Data_RX_I2C, Status);
-- STM32.I2C.Master_Transmit(STM32.Device.I2C_1, ADDR_HMC5883L, HAL.I2C.I2C_Data( Data_TX ), Status);
-- STM32.I2C.Master_Receive(STM32.Device.I2C_1, ADDR_HMC5883L, Data_RX_I2C, Status);
Data_RX := Data_Type( Data_RX_I2C);
end case;
end transfer;
end HIL.I2C;
|
IPC/Syntax/Hilbert.agda | mietek/hilbert-gentzen | 29 | 3665 | <gh_stars>10-100
-- Intuitionistic propositional calculus.
-- Hilbert-style formalisation of syntax.
-- Nested terms.
module IPC.Syntax.Hilbert where
open import IPC.Syntax.Common public
-- Derivations.
infix 3 _⊢_
data _⊢_ (Γ : Cx Ty) : Ty → Set where
var : ∀ {A} → A ∈ Γ → Γ ⊢ A
app : ∀ {A B} → Γ ⊢ A ▻ B → Γ ⊢ A → Γ ⊢ B
ci : ∀ {A} → Γ ⊢ A ▻ A
ck : ∀ {A B} → Γ ⊢ A ▻ B ▻ A
cs : ∀ {A B C} → Γ ⊢ (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
cpair : ∀ {A B} → Γ ⊢ A ▻ B ▻ A ∧ B
cfst : ∀ {A B} → Γ ⊢ A ∧ B ▻ A
csnd : ∀ {A B} → Γ ⊢ A ∧ B ▻ B
unit : Γ ⊢ ⊤
cboom : ∀ {C} → Γ ⊢ ⊥ ▻ C
cinl : ∀ {A B} → Γ ⊢ A ▻ A ∨ B
cinr : ∀ {A B} → Γ ⊢ B ▻ A ∨ B
ccase : ∀ {A B C} → Γ ⊢ A ∨ B ▻ (A ▻ C) ▻ (B ▻ C) ▻ C
infix 3 _⊢⋆_
_⊢⋆_ : Cx Ty → Cx Ty → Set
Γ ⊢⋆ ∅ = 𝟙
Γ ⊢⋆ Ξ , A = Γ ⊢⋆ Ξ × Γ ⊢ A
-- Monotonicity with respect to context inclusion.
mono⊢ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ A → Γ′ ⊢ A
mono⊢ η (var i) = var (mono∈ η i)
mono⊢ η (app t u) = app (mono⊢ η t) (mono⊢ η u)
mono⊢ η ci = ci
mono⊢ η ck = ck
mono⊢ η cs = cs
mono⊢ η cpair = cpair
mono⊢ η cfst = cfst
mono⊢ η csnd = csnd
mono⊢ η unit = unit
mono⊢ η cboom = cboom
mono⊢ η cinl = cinl
mono⊢ η cinr = cinr
mono⊢ η ccase = ccase
mono⊢⋆ : ∀ {Γ″ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ Γ″ → Γ′ ⊢⋆ Γ″
mono⊢⋆ {∅} η ∙ = ∙
mono⊢⋆ {Γ″ , A} η (ts , t) = mono⊢⋆ η ts , mono⊢ η t
-- Shorthand for variables.
v₀ : ∀ {A Γ} → Γ , A ⊢ A
v₀ = var i₀
v₁ : ∀ {A B Γ} → Γ , A , B ⊢ A
v₁ = var i₁
v₂ : ∀ {A B C Γ} → Γ , A , B , C ⊢ A
v₂ = var i₂
-- Reflexivity.
refl⊢⋆ : ∀ {Γ} → Γ ⊢⋆ Γ
refl⊢⋆ {∅} = ∙
refl⊢⋆ {Γ , A} = mono⊢⋆ weak⊆ refl⊢⋆ , v₀
-- Deduction theorem.
lam : ∀ {A B Γ} → Γ , A ⊢ B → Γ ⊢ A ▻ B
lam (var top) = ci
lam (var (pop i)) = app ck (var i)
lam (app t u) = app (app cs (lam t)) (lam u)
lam ci = app ck ci
lam ck = app ck ck
lam cs = app ck cs
lam cpair = app ck cpair
lam cfst = app ck cfst
lam csnd = app ck csnd
lam unit = app ck unit
lam cboom = app ck cboom
lam cinl = app ck cinl
lam cinr = app ck cinr
lam ccase = app ck ccase
lam⋆ : ∀ {Ξ Γ A} → Γ ⧺ Ξ ⊢ A → Γ ⊢ Ξ ▻⋯▻ A
lam⋆ {∅} = I
lam⋆ {Ξ , B} = lam⋆ {Ξ} ∘ lam
lam⋆₀ : ∀ {Γ A} → Γ ⊢ A → ∅ ⊢ Γ ▻⋯▻ A
lam⋆₀ {∅} = I
lam⋆₀ {Γ , B} = lam⋆₀ ∘ lam
-- Detachment theorem.
det : ∀ {A B Γ} → Γ ⊢ A ▻ B → Γ , A ⊢ B
det t = app (mono⊢ weak⊆ t) v₀
det⋆ : ∀ {Ξ Γ A} → Γ ⊢ Ξ ▻⋯▻ A → Γ ⧺ Ξ ⊢ A
det⋆ {∅} = I
det⋆ {Ξ , B} = det ∘ det⋆ {Ξ}
det⋆₀ : ∀ {Γ A} → ∅ ⊢ Γ ▻⋯▻ A → Γ ⊢ A
det⋆₀ {∅} = I
det⋆₀ {Γ , B} = det ∘ det⋆₀
-- Cut and multicut.
cut : ∀ {A B Γ} → Γ ⊢ A → Γ , A ⊢ B → Γ ⊢ B
cut t u = app (lam u) t
multicut : ∀ {Ξ A Γ} → Γ ⊢⋆ Ξ → Ξ ⊢ A → Γ ⊢ A
multicut {∅} ∙ u = mono⊢ bot⊆ u
multicut {Ξ , B} (ts , t) u = app (multicut ts (lam u)) t
-- Transitivity.
trans⊢⋆ : ∀ {Γ″ Γ′ Γ} → Γ ⊢⋆ Γ′ → Γ′ ⊢⋆ Γ″ → Γ ⊢⋆ Γ″
trans⊢⋆ {∅} ts ∙ = ∙
trans⊢⋆ {Γ″ , A} ts (us , u) = trans⊢⋆ ts us , multicut ts u
-- Contraction.
ccont : ∀ {A B Γ} → Γ ⊢ (A ▻ A ▻ B) ▻ A ▻ B
ccont = lam (lam (app (app v₁ v₀) v₀))
cont : ∀ {A B Γ} → Γ , A , A ⊢ B → Γ , A ⊢ B
cont t = det (app ccont (lam (lam t)))
-- Exchange, or Schönfinkel’s C combinator.
cexch : ∀ {A B C Γ} → Γ ⊢ (A ▻ B ▻ C) ▻ B ▻ A ▻ C
cexch = lam (lam (lam (app (app v₂ v₀) v₁)))
exch : ∀ {A B C Γ} → Γ , A , B ⊢ C → Γ , B , A ⊢ C
exch t = det (det (app cexch (lam (lam t))))
-- Composition, or Schönfinkel’s B combinator.
ccomp : ∀ {A B C Γ} → Γ ⊢ (B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
ccomp = lam (lam (lam (app v₂ (app v₁ v₀))))
comp : ∀ {A B C Γ} → Γ , B ⊢ C → Γ , A ⊢ B → Γ , A ⊢ C
comp t u = det (app (app ccomp (lam t)) (lam u))
-- Useful theorems in functional form.
pair : ∀ {A B Γ} → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ∧ B
pair t u = app (app cpair t) u
fst : ∀ {A B Γ} → Γ ⊢ A ∧ B → Γ ⊢ A
fst t = app cfst t
snd : ∀ {A B Γ} → Γ ⊢ A ∧ B → Γ ⊢ B
snd t = app csnd t
boom : ∀ {C Γ} → Γ ⊢ ⊥ → Γ ⊢ C
boom t = app cboom t
inl : ∀ {A B Γ} → Γ ⊢ A → Γ ⊢ A ∨ B
inl t = app cinl t
inr : ∀ {A B Γ} → Γ ⊢ B → Γ ⊢ A ∨ B
inr t = app cinr t
case : ∀ {A B C Γ} → Γ ⊢ A ∨ B → Γ , A ⊢ C → Γ , B ⊢ C → Γ ⊢ C
case t u v = app (app (app ccase t) (lam u)) (lam v)
-- Closure under context concatenation.
concat : ∀ {A B Γ} Γ′ → Γ , A ⊢ B → Γ′ ⊢ A → Γ ⧺ Γ′ ⊢ B
concat Γ′ t u = app (mono⊢ (weak⊆⧺₁ Γ′) (lam t)) (mono⊢ weak⊆⧺₂ u)
-- Convertibility.
data _⋙_ {Γ : Cx Ty} : ∀ {A} → Γ ⊢ A → Γ ⊢ A → Set where
refl⋙ : ∀ {A} → {t : Γ ⊢ A}
→ t ⋙ t
trans⋙ : ∀ {A} → {t t′ t″ : Γ ⊢ A}
→ t ⋙ t′ → t′ ⋙ t″
→ t ⋙ t″
sym⋙ : ∀ {A} → {t t′ : Γ ⊢ A}
→ t ⋙ t′
→ t′ ⋙ t
congapp⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ▻ B} → {u u′ : Γ ⊢ A}
→ t ⋙ t′ → u ⋙ u′
→ app t u ⋙ app t′ u′
congi⋙ : ∀ {A} → {t t′ : Γ ⊢ A}
→ t ⋙ t′
→ app ci t ⋙ app ci t′
congk⋙ : ∀ {A B} → {t t′ : Γ ⊢ A} → {u u′ : Γ ⊢ B}
→ t ⋙ t′ → u ⋙ u′
→ app (app ck t) u ⋙ app (app ck t′) u′
congs⋙ : ∀ {A B C} → {t t′ : Γ ⊢ A ▻ B ▻ C} → {u u′ : Γ ⊢ A ▻ B} → {v v′ : Γ ⊢ A}
→ t ⋙ t′ → u ⋙ u′ → v ⋙ v′
→ app (app (app cs t) u) v ⋙ app (app (app cs t′) u′) v′
congpair⋙ : ∀ {A B} → {t t′ : Γ ⊢ A} → {u u′ : Γ ⊢ B}
→ t ⋙ t′ → u ⋙ u′
→ app (app cpair t) u ⋙ app (app cpair t′) u′
congfst⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ∧ B}
→ t ⋙ t′
→ app cfst t ⋙ app cfst t′
congsnd⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ∧ B}
→ t ⋙ t′
→ app csnd t ⋙ app csnd t′
congboom⋙ : ∀ {C} → {t t′ : Γ ⊢ ⊥}
→ t ⋙ t′
→ app (cboom {C = C}) t ⋙ app cboom t′
conginl⋙ : ∀ {A B} → {t t′ : Γ ⊢ A}
→ t ⋙ t′
→ app (cinl {A = A} {B}) t ⋙ app cinl t′
conginr⋙ : ∀ {A B} → {t t′ : Γ ⊢ B}
→ t ⋙ t′
→ app (cinr {A = A} {B}) t ⋙ app cinr t′
congcase⋙ : ∀ {A B C} → {t t′ : Γ ⊢ A ∨ B} → {u u′ : Γ ⊢ A ▻ C} → {v v′ : Γ ⊢ B ▻ C}
→ t ⋙ t′ → u ⋙ u′ → v ⋙ v′
→ app (app (app ccase t) u) v ⋙ app (app (app ccase t′) u′) v′
-- TODO: Verify this.
beta▻ₖ⋙ : ∀ {A B} → {t : Γ ⊢ A} → {u : Γ ⊢ B}
→ app (app ck t) u ⋙ t
-- TODO: Verify this.
beta▻ₛ⋙ : ∀ {A B C} → {t : Γ ⊢ A ▻ B ▻ C} → {u : Γ ⊢ A ▻ B} → {v : Γ ⊢ A}
→ app (app (app cs t) u) v ⋙ app (app t v) (app u v)
-- TODO: What about eta for ▻?
beta∧₁⋙ : ∀ {A B} → {t : Γ ⊢ A} → {u : Γ ⊢ B}
→ app cfst (app (app cpair t) u) ⋙ t
beta∧₂⋙ : ∀ {A B} → {t : Γ ⊢ A} → {u : Γ ⊢ B}
→ app csnd (app (app cpair t) u) ⋙ u
eta∧⋙ : ∀ {A B} → {t : Γ ⊢ A ∧ B}
→ t ⋙ app (app cpair (app cfst t)) (app csnd t)
eta⊤⋙ : ∀ {t : Γ ⊢ ⊤} → t ⋙ unit
-- TODO: Verify this.
beta∨₁⋙ : ∀ {A B C} → {t : Γ ⊢ A} → {u : Γ ⊢ A ▻ C} → {v : Γ ⊢ B ▻ C}
→ app (app (app ccase (app cinl t)) u) v ⋙ app u t
-- TODO: Verify this.
beta∨₂⋙ : ∀ {A B C} → {t : Γ ⊢ B} → {u : Γ ⊢ A ▻ C} → {v : Γ ⊢ B ▻ C}
→ app (app (app ccase (app cinr t)) u) v ⋙ app v t
-- TODO: What about eta and commuting conversions for ∨? What about ⊥?
|
konz/konz3/saskas.adb | balintsoos/LearnAda | 0 | 16889 | with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
use Ada.Text_IO;
procedure Saskas is
subtype Rand1_10 is Integer range 1..10;
package RandomPos is new Ada.Numerics.Discrete_Random(Rand1_10);
seed: RandomPos.Generator;
protected Kiiro is
entry Kiir(mit: String);
end Kiiro;
protected body Kiiro is
entry Kiir(mit: String) when true is
begin
Put_Line(mit);
end Kiir;
end Kiiro;
type KertParcella is array(Integer range <>) of Boolean;
protected Kert is
procedure Ugrik(pos: Integer; elet: in out integer);
procedure Permetez(pos: Integer);
procedure Felszivodik;
private
K: KertParcella(1..10) := (1..10 => false);
end Kert;
protected body Kert is
procedure Ugrik(pos: Integer; elet: in out integer) is
begin
if(K(pos) = true) then
elet := elet -1;
Kiiro.Kiir("Saska: Meghaltam");
end if;
end Ugrik;
procedure Permetez(pos: Integer) is
begin
Felszivodik;
K(pos) := true;
end Permetez;
procedure Felszivodik is
begin
K := (1..10 => false);
end Felszivodik;
end Kert;
task Saska is
end Saska;
task body Saska is
Pozicio: Integer;
Elet: Natural := 1;
begin
while Elet > 0 loop
Pozicio := RandomPos.Random(seed);
Kiiro.Kiir("Saska: Ugrok egyet ide: " & Integer'Image(Pozicio));
Kert.Ugrik(Pozicio,Elet);
delay 1.0;
end loop;
end Saska;
task Kertesz is
end Kertesz;
task body Kertesz is
PermetPos: Integer;
begin
while Saska'Callable loop
PermetPos := RandomPos.Random(seed);
Kiiro.Kiir("Kertesz: Permetezek egyet itt: " & Integer'Image(PermetPos));
Kert.Permetez(PermetPos);
delay 1.0;
end loop;
end Kertesz;
begin
RandomPos.Reset(seed);
end Saskas; |
src/masks_data.asm | NotImplementedLife/rubik | 4 | 86702 | SECTION "Tile masks Paint Data", ROMX
TileMasks0::
; ~ $8000
DB $00 ; brush 1 inactive
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8010
DB $01 ; brush 1 slot 1
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $03
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8020
DB $01 ; brush 1 active ; slot 1
DB $00, $00, $00, $00, $07, $07, $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8030
DB $01 ; brush 1 slot 1
DB $00, $00, $00, $00, $80, $80, $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $ff, $ff
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8040
DB $00 ; brush 1 inactive
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8050
DB $00 ; brush 1 inactive
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8060
DB $02 ; brush 1 slot 1
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $07, $07, $0f, $0f, $1f, $1f
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8070
DB $01 ; brush 1 slot 1
DB $07, $07, $1f, $1f, $3f, $3f, $ff, $ff, $3f, $3f, $1f, $1f, $07, $07, $03, $03
DB $02 ; brush 2 slot 2
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $c0, $c0
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8080
DB $01 ; brush 1 slot 1
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8090
DB $01 ; brush 1 slot 1
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $80A0
DB $01
DB $80, $80, $e0, $e0, $f0, $f0, $fc, $fc, $f8, $f8, $e0, $e0, $c0, $c0, $00, $00
DB $03
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $07, $07, $0f, $0f
DB $00
DB $00 ; brush 4 inactive
; ~ $80B0
DB $03
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $c0, $c0, $e0, $e0
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $80C0
DB $00 ; brush 1 inactive
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $80D0
DB $02
DB $00, $00, $00, $00, $03, $03, $07, $07, $1f, $1f, $3f, $3f, $7f, $7f, $1f, $1f
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $80E0
DB $02
DB $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $80F0
DB $01
DB $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $02
DB $f0, $f0, $f8, $f8, $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8100
DB $01
DB $ff, $ff, $7f, $7f, $3f, $3f, $0f, $0f, $07, $07, $01, $01, $00, $00, $00, $00
DB $02
DB $00, $00, $00, $00, $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8, $f8, $f8
DB $00
DB $00 ; brush 4 inactive
; ~ $8110
DB $01
DB $fe, $fe, $fc, $fc, $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00
DB $03
DB $00, $00, $00, $00, $00, $00, $03, $03, $07, $07, $1f, $1f, $3f, $3f, $3f, $3f
DB $00
DB $00 ; brush 4 inactive
; ~ $8120
DB $03
DB $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8130
DB $03
DB $f8, $f8, $fc, $fc, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8140
DB $03
DB $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $fc, $fc, $f8, $f8
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8150
DB $00 ; brush 1 inactive
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8160
DB $04
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $07, $07, $1f, $1f
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8170
DB $04
DB $07, $07, $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00 ; brush 2 inactive
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8180
DB $04
DB $80, $80, $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $ff, $ff, $ff, $ff, $ff, $ff
DB $02
DB $0f, $0f, $03, $03, $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8190
DB $04
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0
DB $02
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $3f, $3f, $1f, $1f, $07, $07, $03, $03
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $81A0
DB $02
DB $ff, $ff, $ff, $ff, $ff, $ff, $fe, $fe, $fc, $fc, $f1, $f1, $e0, $e0, $80, $80
DB $05
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $07, $07
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $81B0
DB $02
DB $e0, $e0, $c0, $c0, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $05
DB $01, $01, $07, $07, $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $81C0
DB $05
DB $00, $00, $80, $80, $c0, $c0, $f0, $f0, $f8, $f8, $fe, $fe, $ff, $ff, $ff, $ff
DB $03
DB $1f, $1f, $07, $07, $03, $03, $01, $01, $00, $00, $00, $00, $00, $00, $00, $00
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $81D0
DB $05
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $c0, $c0
DB $03
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $7f, $7f, $3f, $3f, $0f, $0f, $07, $07
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $81E0
DB $03
DB $ff, $ff, $ff, $ff, $ff, $ff, $fe, $fe, $fc, $fc, $f0, $f0, $e0, $e0, $80, $80
DB $06
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $07, $07
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $81F0
DB $03
DB $e0, $e0, $c0, $c0, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $06
DB $01, $01, $07, $07, $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8200
DB $06
DB $80, $80, $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8210
DB $06
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0
DB $00
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8220
DB $00
DB $00
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8230
DB $04
DB $3f, $3f, $ff, $ff, $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00
DB $0A
DB $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8240
DB $04
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $7f, $7f
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8250
DB $04
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fe, $fe, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8260
DB $04
DB $f0, $f0, $fd, $fd, $f8, $f8, $e0, $e0, $c0, $c0, $00, $00, $00, $00, $00, $00
DB $07
DB $00, $00, $01, $01, $00, $00, $01, $01, $07, $07, $0f, $0f, $1f, $1f, $7f, $7f
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8270
DB $05
DB $1f, $1f, $3f, $3f, $1f, $1f, $0f, $0f, $03, $03, $01, $01, $00, $00, $00, $00
DB $07
DB $00, $00, $00, $00, $00, $00, $80, $80, $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc
DB $00 ; brush 3 inactive
DB $00 ; brush 4 inactive
; ~ $8280
DB $05
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $3f, $3f
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8290
DB $05
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fe, $fe, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $82A0
DB $03
DB $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $05
DB $e0, $e0, $f8, $f8, $f8, $f8, $e0, $e0, $c0, $c0, $00, $00, $00, $00, $00, $00
DB $08
DB $00, $00, $00, $00, $00, $00, $01, $01, $07, $07, $0f, $0f, $1f, $1f, $7f, $7f
DB $00 ; brush 4 inactive
; ~ $82B0
DB $06
DB $1f, $1f, $3f, $3f, $3f, $3f, $1f, $1f, $07, $07, $03, $03, $01, $01, $00, $00
DB $08
DB $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $c0, $c0, $f0, $f0, $f8, $f8
DB $00
DB $00 ; brush 4 inactive
; ~ $82C0
DB $06
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $7f, $7f
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $82D0
DB $06
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fc, $fc, $f8, $f8
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $82E0
DB $06
DB $f0, $f0, $fc, $fc, $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00
DB $15
DB $00, $00, $00, $00, $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c
DB $00
DB $00 ; brush 4 inactive
; ~ $82F0
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8300
DB $0A
DB $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8310
DB $0A
DB $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $fc, $fc, $fc, $fc
DB $04
DB $3f, $3f, $0f, $0f, $07, $07, $01, $01, $00, $00, $00, $00, $00, $00, $00, $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8320
DB $04
DB $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $07
DB $00, $00, $03, $03, $07, $07, $1f, $1f, $3f, $3f, $3f, $3f, $1f, $1f, $07, $07
DB $0B
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80
DB $00 ; brush 4 inactive
; ~ $8330
DB $07
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8340
DB $07
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8350
DB $05
DB $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $07
DB $00, $00, $80, $80, $e0, $e0, $f0, $f0, $fc, $fc, $f8, $f8, $e0, $e0, $c0, $c0
DB $09
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $07, $07
DB $00 ; brush 4 inactive
; ~ $8360
DB $05
DB $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $08
DB $00, $00, $03, $03, $07, $07, $1f, $1f, $3f, $3f, $1f, $1f, $0f, $0f, $03, $03
DB $09
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $c0, $c0
DB $00 ; brush 4 inactive
; ~ $8370
DB $08
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8380
DB $08
DB $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8390
DB $06
DB $3f, $3f, $0f, $0f, $07, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $08
DB $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8, $f0, $f0, $e0, $e0, $80, $80
DB $14
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $04
DB $00 ; brush 4 inactive
; ~ $83A0
DB $06
DB $f0, $f0, $c0, $c0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $15
DB $01, $01, $03, $03, $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $83B0
DB $15
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $83C0
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $83D0
DB $0A
DB $ff, $ff, $7f, $7f, $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00
DB $0D
DB $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8
DB $00
DB $00 ; brush 4 inactive
; ~ $83E0
DB $0A
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $7c, $7c
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $83F0
DB $07
DB $03, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0B
DB $e0, $e0, $f1, $f1, $f8, $f8, $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $8400
DB $07
DB $ff, $ff, $ff, $ff, $7f, $7f, $3f, $3f, $0f, $0f, $07, $07, $01, $01, $00, $00
DB $0B
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8
DB $00
DB $00 ; brush 4 inactive
; ~ $8410
DB $07
DB $ff, $ff, $fe, $fe, $fc, $fc, $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00
DB $09
DB $00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $07, $07, $1f, $1f, $3f, $3f
DB $00
DB $00 ; brush 4 inactive
; ~ $8420
DB $09
DB $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8430
DB $09
DB $e0, $e0, $f9, $f9, $fc, $fc, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $08
DB $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8440
DB $08
DB $ff, $ff, $ff, $ff, $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00
DB $09
DB $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $8450
DB $08
DB $ff, $ff, $fc, $fc, $f8, $f8, $f0, $f0, $c0, $c0, $80, $80, $00, $00, $00, $00
DB $14
DB $00, $00, $00, $00, $00, $00, $01, $01, $03, $03, $0f, $0f, $1f, $1f, $7f, $7f
DB $00
DB $00 ; brush 4 inactive
; ~ $8460
DB $14
DB $1c, $1c, $3c, $3c, $7c, $7c, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8470
DB $15
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fc, $fc, $f8, $f8
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8480
DB $15
DB $fc, $fc, $f9, $f9, $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00
DB $18
DB $00, $00, $01, $01, $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c
DB $00
DB $00 ; brush 4 inactive
; ~ $8490
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $84A0
DB $0D
DB $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $84B0
DB $0A
DB $3c, $3c, $0c, $0c, $04, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0D
DB $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $84C0
DB $0B
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $3f, $3f, $1f, $1f, $07, $07
DB $0E
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80
DB $00
DB $00 ; brush 4 inactive
; ~ $84D0
DB $0B
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $84E0
DB $09
DB $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00, $00, $00, $00, $00
DB $0C
DB $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8, $fe, $fe, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $84F0
DB $09
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $7f, $7f, $3f, $3f, $0f, $0f
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8500
DB $09
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fc, $fc, $f8, $f8, $f0, $f0, $c0, $c0
DB $13
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $03, $03
DB $00
DB $00 ; brush 4 inactive
; ~ $8510
DB $09
DB $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $13
DB $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c, $fc, $fc, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $8520
DB $14
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8530
DB $14
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $f0, $f0, $e0, $e0, $80, $80
DB $17
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $04
DB $00
DB $00 ; brush 4 inactive
; ~ $8540
DB $15
DB $f0, $f0, $c0, $c0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $18
DB $01, $01, $03, $03, $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $8550
DB $18
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8560
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8570
DB $0D
DB $ff, $ff, $7f, $7f, $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00
DB $10
DB $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8
DB $00
DB $00 ; brush 4 inactive
; ~ $8580
DB $0D
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $7c, $7c
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8590
DB $0B
DB $03, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0E
DB $e0, $e0, $f0, $f0, $f8, $f8, $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $85A0
DB $0B
DB $fc, $fc, $fc, $fc, $7c, $7c, $3c, $3c, $0c, $0c, $04, $04, $00, $00, $00, $00
DB $0E
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8
DB $00
DB $00 ; brush 4 inactive
; ~ $85B0
DB $0C
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $85C0
DB $09
DB $07, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0C
DB $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $85D0
DB $09
DB $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $13
DB $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $85E0
DB $13
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $85F0
DB $14
DB $ff, $ff, $fd, $fd, $f8, $f8, $f0, $f0, $c0, $c0, $80, $80, $00, $00, $00, $00
DB $17
DB $00, $00, $01, $01, $00, $00, $01, $01, $03, $03, $0f, $0f, $1f, $1f, $7f, $7f
DB $00
DB $00 ; brush 4 inactive
; ~ $8600
DB $17
DB $1c, $1c, $3c, $3c, $7c, $7c, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8610
DB $18
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fc, $fc, $f8, $f8
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8620
DB $18
DB $fc, $fc, $f8, $f8, $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00
DB $1B
DB $00, $00, $00, $00, $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c
DB $00
DB $00 ; brush 4 inactive
; ~ $8630
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8640
DB $10
DB $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8650
DB $0D
DB $3c, $3c, $0c, $0c, $04, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $10
DB $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $8660
DB $0E
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $3f, $3f, $1f, $1f, $07, $07
DB $11
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80
DB $00
DB $00 ; brush 4 inactive
; ~ $8670
DB $0E
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8680
DB $0C
DB $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00, $00, $00, $00, $00
DB $0F
DB $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8, $fe, $fe, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $8690
DB $0C
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $7c, $7c, $3c, $3c, $0c, $0c
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $86A0
DB $13
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fc, $fc, $f8, $f8, $f0, $f0, $c0, $c0
DB $16
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $03, $03
DB $00
DB $00 ; brush 4 inactive
; ~ $86B0
DB $13
DB $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $16
DB $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c, $fc, $fc, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $86C0
DB $17
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $86D0
DB $17
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $f0, $f0, $e0, $e0, $80, $80
DB $1A
DB $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $04
DB $00
DB $00 ; brush 4 inactive
; ~ $86E0
DB $18
DB $f0, $f0, $c0, $c0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $1B
DB $01, $01, $03, $03, $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $86F0
DB $1B
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8700
DB $0C
DB $04, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0F
DB $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $8710
DB $13
DB $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $16
DB $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $8720 - $87F0
REPT(14)
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
ENDR
TileMasks1::
; ~ $8800 | $8D00 <-- shared masks
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8810 | $8D10
DB $10
DB $ff, $ff, $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8820 | $8D20
DB $10
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $7c, $7c, $3c, $3c
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8830 | $8D30
DB $0E
DB $03, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $11
DB $e0, $e0, $f0, $f0, $f8, $f8, $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $8840 | $8D40
DB $0E
DB $fc, $fc, $fc, $fc, $7c, $7c, $3c, $3c, $0c, $0c, $04, $04, $00, $00, $00, $00
DB $11
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8
DB $00
DB $00 ; brush 4 inactive
; ~ $8850 | $8D50
DB $0F
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8860 | $8D60
DB $16
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8870 | $8D70
DB $17
DB $ff, $ff, $fc, $fc, $f8, $f8, $f0, $f0, $c0, $c0, $80, $80, $00, $00, $00, $00
DB $1A
DB $00, $00, $00, $00, $00, $00, $01, $01, $03, $03, $0f, $0f, $1f, $1f, $7f, $7f
DB $00
DB $00 ; brush 4 inactive
; ~ $8880 | $8D80
DB $1A
DB $1c, $1c, $3c, $3c, $7c, $7c, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8890 | $8D90
DB $1B
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fc, $fc, $f8, $f8, $f0, $f0
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $88A0 | $8DA0
DB $1B
DB $fc, $fc, $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $88B0 | $8DB0
DB $10
DB $0c, $0c, $04, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $88C0 | $8DC0
DB $11
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $3f, $3f, $1f, $1f, $07, $07, $03, $03
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $88D0 | $8DD0
DB $11
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $88E0 | $8DE0
DB $0F
DB $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00, $00, $00, $00, $00
DB $12
DB $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8, $fe, $fe, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $88F0 | $8DF0
DB $0F
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $7c, $7c, $3c, $3c, $0c, $0c
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8900 | $8E00
DB $16
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $fc, $fc, $f8, $f8, $f0, $f0, $c0, $c0
DB $19
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $03, $03
DB $00
DB $00 ; brush 4 inactive
; ~ $8910 | $8E10
DB $16
DB $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $19
DB $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c, $fc, $fc, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $8920 | $8E20
DB $1A
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8930 | $8E30
DB $1A
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $f0, $f0, $e0, $e0, $80, $80, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8940 | $8E40
DB $1B
DB $c0, $c0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8950 | $8E50
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8960 | $8E60
DB $11
DB $fc, $fc, $7c, $7c, $3c, $3c, $0c, $0c, $04, $04, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8970 | $8E70
DB $12
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $3f, $3f
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8980 | $8E80
DB $0F
DB $04, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $12
DB $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00 ; brush 4 inactive
; ~ $8990 | $8E90
DB $16
DB $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $19
DB $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $89A0 | $8EA0
DB $19
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $f0, $f0
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $89B0 | $8EB0
DB $1A
DB $fc, $fc, $f8, $f8, $f0, $f0, $c0, $c0, $80, $80, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $89C0 | $8EC0
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $89D0 | $8ED0
DB $12
DB $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $89E0 | $8EE0
DB $12
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $7c, $7c, $3c, $3c, $0c, $0c, $04, $04
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $89F0 | $8EF0
DB $19
DB $ff, $ff, $ff, $ff, $ff, $ff, $fc, $fc, $f8, $f8, $f0, $f0, $c0, $c0, $80, $80
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $8A00 | $8F00
DB $19
DB $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00 ; brush 4 inactive
TileMasks0End::
; ~ $8F10 - $9010
REPT(17);
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
ENDR
; ~ $9020
DB $01
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $9030
DB $01
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $f0, $f0
DB $02
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $03
DB $00
DB $00 ; brush 4 inactive
; ~ $9040
DB $02
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $9050
DB $02
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80
DB $03
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $1f, $1f
DB $00
DB $00 ; brush 4 inactive
; ~ $9060
DB $03
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $9070
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $9080
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $9090
DB $01
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $90A0
DB $01
DB $f0, $f0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0
DB $02
DB $03, $03, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
DB $00
DB $00 ; brush 4 inactive
; ~ $90B0
DB $02
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $90C0
DB $02
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80
DB $03
DB $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f, $1f
DB $00
DB $00 ; brush 4 inactive
; ~ $90D0
DB $03
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $90E0
DB $00
DB $00
DB $00
DB $00 ; brush 4 inactive
; ~ $90F0
DB $01
DB $01, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00, $00, $00, $00, $00
DB $04
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $01, $01
DB $00
DB $00 ; brush 4 inactive
; ~ $9100
DB $01
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00, $00, $00
DB $04
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $9110
DB $01
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $00, $00, $00, $00, $00, $00, $00, $00
DB $02
DB $07, $07, $07, $07, $07, $07, $07, $07, $00, $00, $00, $00, $00, $00, $00, $00
DB $04
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $e0, $e0, $e0, $e0
DB $05
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $07, $07, $07, $07
; ~ $9120
DB $02
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00, $00, $00
DB $05
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $9130
DB $02
DB $80, $80, $80, $80, $80, $80, $c0, $c0, $00, $00, $00, $00, $00, $00, $00, $00
DB $03
DB $1f, $1f, $1f, $1f, $1f, $1f, $0f, $0f, $00, $00, $00, $00, $00, $00, $00, $00
DB $05
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $c0, $c0, $c0, $c0
DB $06
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0f, $0f, $0f, $0f
; ~ $9140
DB $03
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00, $00, $00
DB $06
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff, $ff, $ff
DB $00
DB $00 ; brush 4 inactive
; ~ $9150
DB $03
DB $00, $00, $00, $00, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00
DB $06
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $80, $80
DB $00
DB $00
; ~ $9160
DB $04
DB $01, $01, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $00, $00, $00, $00
DB $00
DB $00
DB $00
; ~ $9170
DB $04
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00
DB $00
DB $00
DB $00
; ~ $9180
DB $04
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $00, $00, $00, $00
DB $05
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $00, $00, $00, $00
DB $00
DB $00
; ~ $9190
DB $05
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00
DB $00
DB $00
DB $00
; ~ $91A0
DB $05
DB $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $00, $00, $00, $00
DB $06
DB $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f, $00, $00, $00, $00
DB $00
DB $00
; ~ $91B0
DB $06
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00
DB $00
DB $00
DB $00
; ~ $91C0
DB $06
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00
DB $00
DB $00
DB $00
; ~ $91D0
DB $00
DB $00
DB $00
DB $00
; ~ $91E0
DB $07
DB $03, $03, $03, $03, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
DB $00
DB $00
DB $00
; ~ $91F0
DB $07
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9200
DB $07
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0
DB $08
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
DB $00
DB $00
; ~ $9210
DB $08
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9220
DB $08
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0
DB $09
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
DB $00
DB $00
; ~ $9230
DB $09
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9240
DB $09
DB $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0, $c0
DB $00
DB $00
DB $00
; ~ $9250
DB $00
DB $00
DB $00
DB $00
; ~ $9260
DB $00
DB $00
DB $00
DB $00
; ~ $9270
DB $0D
DB $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8
DB $00
DB $00
DB $00
; ~ $9280
DB $07
DB $07, $07, $07, $07, $07, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0A
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $07, $07, $07, $07, $07, $07
DB $00
DB $00
; ~ $9290
DB $07
DB $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0A
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
; ~ $92A0
DB $07
DB $e0, $e0, $e0, $e0, $e0, $e0, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $08
DB $07, $07, $07, $07, $07, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0A
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $e0, $e0, $e0, $e0, $e0, $e0
DB $0B
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $07, $07, $07, $07, $07, $07
; ~ $92B0
DB $08
DB $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0B
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
; ~ $92C0
DB $08
DB $e0, $e0, $e0, $e0, $e0, $e0, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $09
DB $07, $07, $07, $07, $07, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0B
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $e0, $e0, $e0, $e0, $e0, $e0
DB $0C
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $07, $07, $07, $07, $07, $07
; ~ $92D0
DB $09
DB $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0C
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
; ~ $92E0
DB $09
DB $c0, $c0, $c0, $c0, $e0, $e0, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $0C
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $e0, $e0, $e0, $e0, $e0, $e0
DB $00
DB $00
; ~ $92F0
DB $18
DB $00, $00, $00, $00, $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c
DB $00
DB $00
DB $00
; ~ $9300
DB $00
DB $00
DB $00
DB $00
; ~ $9310
DB $0D
DB $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9320
DB $0D
DB $00, $00, $00, $00, $c0, $c0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0
DB $0A
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
DB $00
DB $00
; ~ $9330
DB $0A
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9340
DB $0A
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0
DB $0B
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
DB $00
DB $00
; ~ $9350
DB $0B
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9360
DB $0B
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0
DB $0C
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
DB $00
DB $00
; ~ $9370
DB $0C
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9380
DB $0C
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0
DB $18
DB $01, $01, $03, $03, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
DB $00
DB $00
; ~ $9390
DB $18
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00
; ~ $93A0
DB $00
DB $00
DB $00
DB $00
; ~ $93B0
DB $0D
DB $ff, $ff, $7f, $7f, $3f, $3f, $1f, $1f, $07, $07, $03, $03, $00, $00, $00, $00
DB $10
DB $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8
DB $00
DB $00
; ~ $93C0
DB $0A
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $00, $00, $00, $00, $00, $00
DB $0D
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $7e, $7e
DB $00
DB $00
; ~ $93D0
DB $0A
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00
DB $0E
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $ff
DB $00
DB $00
; ~ $93E0
DB $0A
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00
DB $0E
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $f8, $f8
DB $00
DB $00
; ~ $93F0
DB $0A
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $00, $00, $00, $00, $00, $00
DB $0B
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $00, $00, $00, $00, $00, $00
DB $00
DB $00
; ~ $9400
DB $0B
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00
DB $00
DB $00
DB $00
; ~ $9410
DB $0B
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $00, $00, $00, $00, $00, $00
DB $0C
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $00, $00, $00, $00, $00, $00
DB $00
DB $00
; ~ $9420
DB $0C
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00
DB $17
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $7f, $7f
DB $00
DB $00
; ~ $9430
DB $0C
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00
DB $17
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $fc, $fc
DB $00
DB $00
; ~ $9440
DB $0C
DB $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $00, $00, $00, $00, $00, $00
DB $18
DB $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $04, $04, $f8, $f8
DB $00
DB $00
; ~ $9450
DB $18
DB $fc, $fc, $f9, $f9, $f0, $f0, $e0, $e0, $80, $80, $00, $00, $00, $00, $00, $00
DB $1B
DB $00, $00, $01, $01, $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c
DB $00
DB $00
; ~ $9460
DB $00
DB $00
DB $00
DB $00
; ~ $9470
DB $10
DB $fe, $fe, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9480
DB $0D
DB $3c, $3c, $0c, $0c, $04, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $10
DB $00, $00, $00, $00, $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
; ~ $9490
DB $0E
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $3f, $3f, $1f, $1f, $07, $07
DB $11
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80
DB $00
DB $00
; ~ $94A0
DB $0E
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00
; ~ $94B0
DB $0F
DB $00, $00, $00, $00, $80, $80, $e0, $e0, $f0, $f0, $f8, $f8, $fe, $fe, $ff, $ff
DB $00
DB $00
DB $00
; ~ $94C0
DB $00
DB $00
DB $00
DB $00
; ~ $94D0
DB $16
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $03, $03
DB $00
DB $00
DB $00
; ~ $94E0
DB $16
DB $00, $00, $00, $00, $04, $04, $1c, $1c, $3c, $3c, $7c, $7c, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00
; ~ $94F0
DB $17
DB $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
; ~ $9500
DB $17
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $f0, $f0, $e0, $e0, $80, $80
DB $1A
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $04
DB $00
DB $00
; ~ $9510
DB $18
DB $f0, $f0, $c0, $c0, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $1B
DB $01, $01, $03, $03, $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
; ~ $9520
DB $1B
DB $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00
; ~ $9530
DB $0F
DB $c0, $c0, $e0, $e0, $f8, $f8, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc, $fc
DB $00
DB $00
DB $00
; ~ $9540
DB $16
DB $0f, $0f, $1f, $1f, $7f, $7f, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
DB $00
DB $00
DB $00
|
oeis/221/A221162.asm | neoneye/loda-programs | 11 | 176985 | <reponame>neoneye/loda-programs
; A221162: Number of n X 2 arrays of occupancy after each element stays put or moves to some horizontal, vertical or antidiagonal neighbor.
; 3,33,352,3721,39254,413908,4363921,46008619,485064009,5113971944,53915979657,568429529006,5992882377940,63182219138721,666122336505939,7022845559348401,74040993741513520,780605056433123273,8229822741910599430,86766005171318101012,914763280993892851249,9644236341208247039355,101677993135037315480153
mul $0,2
lpb $0
mov $2,$0
sub $0,1
seq $2,291015 ; p-INVERT of (1,1,1,1,1,...), where p(S) = (1 - S^3)^2.
add $3,$2
lpe
mov $0,$3
add $0,3
|
software/libsparklemma/src/spark-constrained_array_lemmas.adb | TUM-EI-RCS/StratoX | 12 | 5851 | <filename>software/libsparklemma/src/spark-constrained_array_lemmas.adb
------------------------------------------------------------------------------
-- --
-- SPARK LIBRARY COMPONENTS --
-- --
-- S P A R K . C O N S T R A I N E D _ A R R A Y _ L E M M A S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- SPARK 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. SPARK 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/>. --
-- --
------------------------------------------------------------------------------
-- ??? Do not work yet
with SPARK.Unconstrained_Array_Lemmas;
package body SPARK.Constrained_Array_Lemmas
with SPARK_Mode => Off -- TEST_ON
is
type A_Unconstrained is array (Index_Type range <>) of Element_T;
package Test is new SPARK.Unconstrained_Array_Lemmas
(Index_Type => Index_Type,
Element_T => Element_T,
A => A_Unconstrained,
Less => Less);
procedure Lemma_Transitive_Order (Arr : A) is
Arr_T : constant A_Unconstrained := A_Unconstrained (Arr);
begin
Test.Lemma_Transitive_Order (Arr_T);
end Lemma_Transitive_Order;
end SPARK.Constrained_Array_Lemmas;
|
mc-sema/validator/x86_64/tests/ADC16rr.asm | randolphwong/mcsema | 2 | 165703 | <filename>mc-sema/validator/x86_64/tests/ADC16rr.asm
BITS 64
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; ADC16rr
mov cx, 0xabc
mov dx, 0xdef
;TEST_BEGIN_RECORDING
adc cx, dx
;TEST_END_RECORDING
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_1513.asm | ljhsiun2/medusa | 9 | 80073 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x4c1e, %rax
dec %rdi
mov $0x6162636465666768, %r9
movq %r9, (%rax)
nop
nop
sub $2171, %rax
lea addresses_WC_ht+0x1b39d, %rdi
nop
add %rbx, %rbx
movb $0x61, (%rdi)
nop
nop
nop
nop
nop
and %r9, %r9
lea addresses_WC_ht+0x1ab1e, %rbx
nop
nop
nop
nop
nop
xor %rsi, %rsi
mov (%rbx), %r13d
dec %rsi
lea addresses_WT_ht+0x1e05e, %rsi
nop
nop
nop
nop
and %rax, %rax
movw $0x6162, (%rsi)
xor %rbx, %rbx
lea addresses_WC_ht+0x1bb1e, %rsi
lea addresses_normal_ht+0x8e9e, %rdi
nop
nop
nop
nop
xor %r14, %r14
mov $110, %rcx
rep movsq
nop
nop
nop
nop
sub %r13, %r13
lea addresses_WC_ht+0x1de9e, %r14
nop
nop
nop
xor %rcx, %rcx
vmovups (%r14), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %r9
nop
cmp $40152, %rsi
lea addresses_A_ht+0xb5a, %rcx
nop
nop
nop
nop
sub $22673, %r9
mov $0x6162636465666768, %r14
movq %r14, %xmm3
vmovups %ymm3, (%rcx)
nop
nop
nop
dec %rbx
lea addresses_UC_ht+0x1829e, %rax
clflush (%rax)
nop
nop
nop
nop
and $19072, %rcx
mov (%rax), %ebx
nop
nop
nop
nop
nop
cmp %rdi, %rdi
lea addresses_D_ht+0x1697e, %rsi
lea addresses_UC_ht+0x16f42, %rdi
clflush (%rsi)
add %r14, %r14
mov $107, %rcx
rep movsb
nop
nop
nop
nop
xor $6331, %rdi
lea addresses_D_ht+0x18d36, %rsi
lea addresses_D_ht+0xea9e, %rdi
clflush (%rdi)
sub %r14, %r14
mov $86, %rcx
rep movsb
nop
nop
inc %rbx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %rbp
push %rbx
push %rcx
push %rdx
// Store
lea addresses_normal+0x15e9e, %r10
add %r12, %r12
movb $0x51, (%r10)
nop
nop
nop
nop
and $54539, %rbx
// Store
lea addresses_PSE+0x14e9e, %rbp
nop
nop
nop
nop
sub $44262, %rcx
movb $0x51, (%rbp)
nop
and %rbp, %rbp
// Faulty Load
lea addresses_D+0xf69e, %rcx
sub $158, %r15
vmovups (%rcx), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %r12
lea oracles, %r10
and $0xff, %r12
shlq $12, %r12
mov (%r10,%r12,1), %r12
pop %rdx
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_D', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_D', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 4, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'}
{'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
*/
|
Assembly/fileformats/skills_spells_getName.asm | WildGenie/Ninokuni | 14 | 83957 | ;;----------------------------------------------------------------------------;;
;; Fix the function that gets skills or magic names with new fields.
;; Copyright 2014 <NAME> (aka pleonex)
;;
;; 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.
;;----------------------------------------------------------------------------;;
@SkillLongNameOffset equ 0x3C
@SpellExtraNameSize equ 0x8
@skill_getPtrInit equ 0x0210DC9C
@magic_getPtrInit equ 0x0210DCC4
@skills_getPtr_wr equ 0x0210CBD4
@magic_getPtr_wr equ 0x021062D0
;; ARGUMENTS:
;; R0: Struct pointer with spell / skill info
;; R1: Spell / Skill ID
;; RETURNS:
;; R0: Pointer to the name of the spell / skill
.thumb
.org 0x02121008
.area 0x02121048-.
; "Save" registers
PUSH {R4-R6,LR}
MOV R5, R0
MOV R6, R1
; Get spell / skill ID
LSL R1, R6, #1
ADD R1, R5, R1
LDR R4, =0x4E23C+0x8
LDRSH R1, [R1,R4]
; Check if it's spell or skill
SUB R4, #8
LDR R4, [R5,R4]
CMP R4, #0
BEQ @@isSkill
CMP R4, #1
BEQ @@isSpell
MOV R0, #0
POP {R4-R6,PC}
@@isSkill:
BL @skill_getPtrInit
BLX @skills_getPtr_wr
ADD R0, @SkillLongNameOffset ; Hack
POP {R4-R6,PC}
@@isSpell:
BL @magic_getPtrInit
BLX @magic_getPtr_wr
SUB R0, @SpellExtraNameSize ; Hack
POP {R4-R6,PC}
.pool
.endarea
|
PIM/Projet/src/google_creuse.adb | Hathoute/ENSEEIHT | 1 | 26733 | <filename>PIM/Projet/src/google_creuse.adb
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with System.Multiprocessors; use System.Multiprocessors;
with System.Multiprocessors.Dispatching_Domains; use System.Multiprocessors.Dispatching_Domains;
package body Google_Creuse is
procedure Initialiser(Google: out T_Google) is
begin
Vecteur_Matrice.Initialiser(Google.Matrice_Creuse, Taille);
Google.Addition := (1.0-Alpha)/T_Precision(Taille);
Google.PreVide := Alpha/T_Precision(Taille) + Google.Addition;
end Initialiser;
procedure Creer(Google: in out T_Google; Liens: in LC_Integer_Integer.T_LC) is
TH: TH_Matrice.T_TH;
LCA: TH_Matrice.T_LCA_C.T_LCA;
Vecteur: Vecteur_Matrice.T_Vecteur;
procedure Incrementer(Gauche: Integer; Droit: Integer) is
begin
if not TH_Matrice.Cle_Presente(TH, (Gauche, Droit)) then -- Verifier si il n'existe pas plusieurs liaisons identiques.
TH_Matrice.Enregistrer(TH, (Gauche, Droit), 1.0);
Vecteur_Integer.Modifier(Google.Sortants, Gauche, Vecteur_Integer.Valeur(Google.Sortants, Gauche) + 1);
end if;
end Incrementer;
procedure Calculer_Sortants is
new LC_Integer_Integer.Pour_Chaque(Incrementer);
procedure Populer(Gauche: Integer; Droit: Integer) is
begin
TH_Matrice.Enregistrer(TH, (Droit, Gauche), T_Precision(Alpha)*1.0/T_Precision(Vecteur_Integer.Valeur(Google.Sortants,Gauche)) + Google.Addition);
end Populer;
procedure Populer_Liste is
new LC_Integer_Integer.Pour_Chaque(Populer);
procedure Inserer (Indice: T_Indice; Valeur: T_Precision) is
Valeur_Matrice: T_Matrice_Valeur;
begin
Valeur_Matrice.Indice := Indice;
Valeur_Matrice.Valeur := Valeur;
Vecteur_Matrice.Ajouter(Vecteur, Valeur_Matrice);
end Inserer;
procedure Convertir_Vecteur is
new TH_Matrice.T_LCA_C.Pour_Chaque (Inserer);
function Comparer_Indice(Val1: T_Matrice_Valeur; Val2: T_Matrice_Valeur) return Boolean is
begin
return Val1.Indice.Y > Val2.Indice.Y;
end Comparer_Indice;
procedure Ordonner_Vecteur is
new Vecteur_Matrice.Trier(Comparer_Indice);
procedure Ajouter(Valeur_Matrice: T_Matrice_Valeur) is
begin
Vecteur_Matrice.Ajouter(Google.Matrice_Creuse, Valeur_Matrice);
end Ajouter;
procedure Combiner_Vecteurs is
new Vecteur_Matrice.Pour_Chaque(Ajouter);
begin
TH_Matrice.Initialiser(TH, Taille);
Vecteur_Integer.Initialiser(Google.Sortants, Taille);
for J in 0..Taille-1 loop
Vecteur_Integer.Ajouter(Google.Sortants, 0);
end loop;
Calculer_Sortants(Liens);
TH_Matrice.Vider(TH);
Populer_Liste(Liens);
Vecteur_Matrice.Initialiser(Google.Matrice_Creuse, TH_Matrice.Taille(TH));
for I in 0..Taille-1 loop
LCA := TH_Matrice.LCA(TH, (I, 0));
if TH_Matrice.T_LCA_C.Taille(LCA) /= 0 then
Vecteur_Matrice.Initialiser(Vecteur, TH_Matrice.T_LCA_C.Taille(LCA));
Convertir_Vecteur(LCA);
Ordonner_Vecteur(Vecteur);
Combiner_Vecteurs(Vecteur);
Vecteur_Matrice.Vider(Vecteur);
end if;
end loop;
end Creer;
procedure Calculer_Rangs(Google: in out T_Google; Rangs: out Vecteur_Poids.T_Vecteur) is
Poids: Vecteur_Precision.T_Vecteur;
Poids_Original: Vecteur_Precision.T_Vecteur;
Finished: array (1..4) of Boolean;
Bords: array (1..5) of Integer;
Count: Integer;
Matrice_Val: T_Matrice_Valeur;
task type TT(Id: Integer; CPU_Id: CPU_Range)
with CPU => CPU_Id
is
entry Start(Matrice: Vecteur_Matrice.T_Vecteur; Poids_Original: Vecteur_Precision.T_Vecteur);
end TT;
task body TT is
Matrice_Valeur: T_Matrice_Valeur;
pCount: Integer;
Temp: T_Precision;
begin
loop select
accept Start(Matrice: Vecteur_Matrice.T_Vecteur; Poids_Original: Vecteur_Precision.T_Vecteur) do
Finished(Id) := false;
end Start;
pCount := Bords(Id);
Matrice_Valeur := Vecteur_Matrice.Valeur(Google.Matrice_Creuse, pCount);
for I in Taille*(Id-1)/4..Taille*Id/4-1 loop
Temp := 0.0;
for J in 0..Taille-1 loop
if Matrice_Valeur.Indice.X = I and Matrice_Valeur.Indice.Y = J then
Temp := Temp + Vecteur_Precision.Valeur(Poids_Original, J)*Matrice_Valeur.Valeur;
if Bords(Id+1) = pCount+1 then
Matrice_Valeur.Indice.X := Taille;
else
pCount := pCount + 1;
Matrice_Valeur := Vecteur_Matrice.Valeur(Google.Matrice_Creuse, pCount);
end if;
else
Temp := Temp + Vecteur_Precision.Valeur(Poids_Original, J)*Google.Addition;
null;
end if;
end loop;
Vecteur_Precision.Modifier(Poids, I, Temp);
end loop;
Finished(Id) := true;
or
terminate;
end select; end loop;
end TT;
Task1: TT(1, Not_A_Specific_CPU);
Task2: TT(2, Not_A_Specific_CPU);
Task3: TT(3, Not_A_Specific_CPU);
Task4: TT(4, Not_A_Specific_CPU);
begin
Vecteur_Precision.Initialiser(Poids, Taille);
for I in 0..Taille-1 loop
Vecteur_Precision.Ajouter(Poids, 1.0/T_Precision(Taille));
end loop;
Bords(1) := 0;
Count := 1;
for I in 0..Vecteur_Matrice.Taille(Google.Matrice_Creuse)-1 loop
Matrice_Val := Vecteur_Matrice.Valeur(Google.Matrice_Creuse, I);
while Matrice_Val.Indice.X >= Taille*Count/4 loop
Count := Count + 1;
Bords(Count) := I;
end loop;
end loop;
Count := Count + 1;
Bords(Count) := Vecteur_Matrice.Taille(Google.Matrice_Creuse);
for tmp in 1..MaxIterations loop
Count := 1;
Vecteur_Precision.Copier(Poids_Original, Poids);
for I in 0..Taille-1 loop
if Vecteur_Integer.Valeur(Google.Sortants, I) = 0 then
Vecteur_Precision.Modifier(Poids_Original, I, Vecteur_Precision.Valeur(Poids_Original, I)*Google.PreVide/Google.Addition);
end if;
end loop;
Task1.Start(Google.Matrice_Creuse, Poids_Original);
Task2.Start(Google.Matrice_Creuse, Poids_Original);
Task3.Start(Google.Matrice_Creuse, Poids_Original);
Task4.Start(Google.Matrice_Creuse, Poids_Original);
while not Finished(1) or else not Finished(2) or else not Finished(3) or else not Finished(4) loop
null; -- Attendre le resultat...
end loop;
Vecteur_Precision.Vider(Poids_Original);
end loop;
Put_Line("Fin des itérations");
Vecteur_Poids.Initialiser(Rangs, Taille);
for I in 0..Taille-1 loop
declare
Rank: T_Rank := (Rang => I, Poid => T_Digits(Vecteur_Precision.Valeur(Poids, I)));
begin
Vecteur_Poids.Ajouter(Rangs, Rank);
end;
end loop;
Vecteur_Precision.Vider(Poids);
end Calculer_Rangs;
end Google_Creuse;
|
oeis/286/A286956.asm | neoneye/loda-programs | 11 | 29949 | ; A286956: Main diagonal of A286950.
; Submitted by <NAME>
; 1,0,1,3,4,6,6,8,8,9,10,11,11,13,14,14,16,17,18,19,20,21,23,23,24,25,27,27,28,29,30,31,32,33,34,34,36,37,38,39,39,41,42,43,44,45,46,47,48,49,50,52,52,53,54,55,56,58,58,59,60,61,62,63,64,65,66,67,68,69,69,71,72,73,74,75,76,76,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,93,94,95,96,97,98,99
mov $2,$0
seq $0,10815 ; From Euler's Pentagonal Theorem: coefficient of q^n in Product_{m>=1} (1 - q^m).
add $2,$0
mov $0,$2
|
alloy4fun_models/trashltl/models/5/6NgNZoRoJYR3h6LaZ.als | Kaixi26/org.alloytools.alloy | 0 | 1620 | <filename>alloy4fun_models/trashltl/models/5/6NgNZoRoJYR3h6LaZ.als
open main
pred id6NgNZoRoJYR3h6LaZ_prop6 {
all f:File | f in Trash implies always f in Trash
}
pred __repair { id6NgNZoRoJYR3h6LaZ_prop6 }
check __repair { id6NgNZoRoJYR3h6LaZ_prop6 <=> prop6o } |
src/main/antlr/Lego.g4 | danielGoldsteinCS2021/Lego-Predicate-Logic-Language | 1 | 5825 | grammar Lego;
program: start? EOF;
start: formula | expr ;
formula: expr rel_op expr #rel_opFormula
| unary_conn formula #unary_connFormula
| formula binary_conn formula #binary_connFormula
| quantifier var ':' domain '.' formula #quantifierFormula
| '(' formula ')' #bracketedForumla
;
expr: expr bin_op expr #bin_opExpr
| expr bin_op_lower expr #bin_op_lowerExpr
| number #numberExpr
| var #varExpr
| '(' expr ')' #bracketedExpr
;
rel_op: GT | GTE | EQ | LT | LTE ;
bin_op: MUL
| DIV
| MOD
;
bin_op_lower: ADD // This rule is needed to enforce lower precedence on addition and subtraction
| SUB
;
unary_conn: NOT ;
binary_conn: AND | OR | IMPL | EQUIV ;
quantifier: FORALL | EXISTS ;
domain: '[' number '..' number ']' ;
number: INT | SUB+INT;
var: ID ;
MUL : '*' ;
DIV : '/' ;
ADD : '+' ;
SUB : '-' ;
MOD : '%' ;
GT : '>' ;
GTE : '>=';
EQ : '=' ;
LT : '<' ;
LTE : '<=';
NOT : '!' | N O T ;
AND : '&&' | A N D ;
OR : '||' | O R ;
IMPL: '->' | '=>' | I M P L I E S ;
EQUIV:'<->'| '<=>' | E Q U I V | I F F ;
FORALL: F O R A L L ;
EXISTS: E X I S T S ;
ID : [a-zA-Z][a-zA-Z0-9]* ;
INT : [0-9]+ ;
NEWLINE: '\r'? '\n' ;
WS: [ \r\t\n]+ -> skip ;
fragment A :('a' | 'A') ;
fragment B :('b' | 'B') ;
fragment C :('c' | 'C') ;
fragment D :('d' | 'D') ;
fragment E :('e' | 'E') ;
fragment F :('f' | 'F') ;
fragment G :('g' | 'G') ;
fragment H :('h' | 'H') ;
fragment I :('i' | 'I') ;
fragment J :('j' | 'J') ;
fragment K :('k' | 'K') ;
fragment L :('l' | 'L') ;
fragment M :('m' | 'M') ;
fragment N :('n' | 'N') ;
fragment O :('o' | 'O') ;
fragment P :('p' | 'P') ;
fragment Q :('q' | 'Q') ;
fragment R :('r' | 'R') ;
fragment S :('s' | 'S') ;
fragment T :('t' | 'T') ;
fragment U :('u' | 'U') ;
fragment V :('v' | 'V') ;
fragment W :('w' | 'W') ;
fragment X :('x' | 'X') ;
fragment Y :('y' | 'Y') ;
fragment Z :('z' | 'Z') ; |
source/MicroBenchX.Ipc/IpcTests/sub_float64.asm | clayne/MicroBenchX | 15 | 171782 | <reponame>clayne/MicroBenchX
[BITS 64]
%include "parameters.inc"
extern exit
global sub_float64
section .text
sub_float64:
push rbp
mov rax, ITERATIONS_sub_float64
mov rbx, __float64__(1.0)
mov rcx, __float64__(2.0)
mov rdx, __float64__(3.0)
mov rsi, __float64__(4.0)
mov rdi, __float64__(5.0)
mov r8, __float64__(6.0)
mov r9, __float64__(7.0)
mov r10, __float64__(8.0)
mov r11, __float64__(9.0)
mov r12, __float64__(10.0)
mov r13, __float64__(11.0)
mov r14, __float64__(12.0)
mov r15, __float64__(13.0)
.loop:
sub rbx, rbx
sub rcx, rcx
sub rdx, rdx
sub rsi, rsi
sub rdi, rdi
sub r8, r8
sub r9, r9
sub r10, r10
sub r11, r11
sub r12, r12
sub r13, r13
sub r14, r14
sub r15, r15
dec rax
jnz .loop
.exit:
lea rdi, [rel format]
pop rbp
xor rax, rax
mov rax, ITERATIONS_sub_float64
mov rsi, 15 ; 13 sub + 1 dec + 1 loop
mul rsi
ret
section .data
format: db "%lu", 10, 0 |
alloy4fun_models/trainstlt/models/2/khtBhPh4okGednpek.als | Kaixi26/org.alloytools.alloy | 0 | 1373 | open main
pred idkhtBhPh4okGednpek_prop3 {
no Track
}
pred __repair { idkhtBhPh4okGednpek_prop3 }
check __repair { idkhtBhPh4okGednpek_prop3 <=> prop3o } |
ada/buffers.ads | rtoal/enhanced-dining-philosophers | 0 | 21991 | <filename>ada/buffers.ads
------------------------------------------------------------------------------
-- buffers.ads
--
-- A generic package for bounded, blocking FIFO queues (buffers). It exports
-- a proected type called 'Buffer'. Note that the maximum size of any buffer
-- of this type is taken from a single generic package parameter.
--
-- Generic Parameters:
--
-- Item the desired type of the buffer elements.
-- Size the maximum size of a buffer of type Buffer.
--
-- Entries:
--
-- Write (I) write item I to the buffer.
-- Read (I) read into item I from the buffer.
------------------------------------------------------------------------------
generic
type Item is private;
Size: Positive;
package Buffers is
subtype Index is Integer range 0..Size-1;
type Item_Array is array (Index) of Item;
protected type Buffer is
entry Write (I: Item);
entry Read (I: out Item);
private
Data : Item_Array;
Front : Index := 0; -- index of head (when not empty)
Back : Index := 0; -- index of next free slot
Count : Integer range 0..Size := 0; -- number of items currently in
end Buffer;
end Buffers;
|
QuantitativeAlloy/models/alloy/bayesianNetwork/bayesianNetwork.als | pf7/QAlloy | 0 | 5110 | <reponame>pf7/QAlloy
one sig Unit{ rain : one R }
abstract sig R{
sprinkler : one S,
grass : S set -> one G
}
one sig Rain, NoRain extends R{}
abstract sig S, G{}
one sig On, Off extends S{}
one sig Wet, Dry extends G{}
fact{
//rain
#(Unit.rain :> Rain) = div[2, 10]
//#(Unit.rain :> NoRain) = div[8, 10]
//sprinkler
#(NoRain.sprinkler :> On) = div[4, 10]
//#(NoRain.sprinkler :> Off) = div[6, 10]
#(Rain.sprinkler :> On) = div[1, 100]
//#(Rain.sprinkler :> Off) = div[99, 100]
//grass
one Off.(NoRain.grass) :> Dry
//#(Off.(NoRain.grass) :> Dry) = 1
//#(Off.(NoRain.grass) :> Wet) = 0
#(Off.(Rain.grass) :> Dry) = div[2, 10]
//#(Off.(Rain.grass) :> Wet) = div[8, 10]
#(On.(NoRain.grass) :> Dry) = div[1, 10]
//#(On.(NoRain.grass) :> Wet) = div[9, 10]
#(On.(Rain.grass) :> Dry) = div[1, 100]
//#(On.(Rain.grass) :> Wet) = div[99, 100]
}
|
courses/fundamentals_of_ada/labs/solar_system/000_getting_started/src/main.adb | AdaCore/training_material | 15 | 27288 | -----------------------------------------------------------------------
-- Ada Labs --
-- --
-- Copyright (C) 2008-2019, AdaCore --
-- --
-- Labs is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this program; --
-- if not, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with Display; use Display;
with Display.Basic; use Display.Basic;
with Ada.Real_Time; use Ada.Real_Time;
--with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
procedure Main is
Width : constant := 240.0;
Height : constant := 320.0;
Ball_Radius : constant := 20.0;
X : Float := 0.0;
Y : Float := 0.0;
Speed_X : Float := 2.0;
Speed_Y : Float := 4.0;
Next : Time;
Period : constant Time_Span := Milliseconds (40);
-- reference to the application window
Window : Window_Id;
-- reference to the graphical canvas associated with the application window
Canvas : Canvas_Id;
begin
Window :=
Create_Window
(Width => Integer (Width),
Height => Integer (Height),
Name => "Bouncing ball");
Canvas := Get_Canvas (Window);
Next := Clock + Period;
while not Is_Killed loop
if (abs X) + Ball_Radius >= Width / 2.0 then
Speed_X := -Speed_X;
end if;
if (abs Y) + Ball_Radius >= Height / 2.0 then
Speed_Y := -Speed_Y;
end if;
X := X + Speed_X;
Y := Y + Speed_Y;
Draw_Sphere
(Canvas => Canvas,
Position => (X, Y, 0.0),
Radius => Ball_Radius,
Color => Red);
Swap_Buffers (Window);
delay until Next;
Next := Next + Period;
end loop;
end Main;
|
programs/oeis/033/A033444.asm | neoneye/loda | 22 | 176155 | <gh_stars>10-100
; A033444: Number of edges in 12-partite Turán graph of order n.
; 0,0,1,3,6,10,15,21,28,36,45,55,66,77,89,102,116,131,147,164,182,201,221,242,264,286,309,333,358,384,411,439,468,498,529,561,594,627,661,696,732,769,807,846,886,927,969,1012,1056,1100,1145,1191,1238,1286,1335,1385,1436,1488,1541,1595,1650,1705,1761,1818,1876,1935,1995,2056,2118,2181,2245,2310,2376,2442,2509,2577,2646,2716,2787,2859,2932,3006,3081,3157,3234,3311,3389,3468,3548,3629,3711,3794,3878,3963,4049,4136,4224,4312,4401,4491
mov $2,$0
lpb $2
trn $0,12
sub $2,1
add $1,$2
sub $1,$0
lpe
mov $0,$1
|
Transynther/x86/_processed/AVXALIGN/_ht_zr_un_/i3-7100_9_0x84_notsx.log_21829_2518.asm | ljhsiun2/medusa | 9 | 18583 | <filename>Transynther/x86/_processed/AVXALIGN/_ht_zr_un_/i3-7100_9_0x84_notsx.log_21829_2518.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r8
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x1d47, %rsi
lea addresses_UC_ht+0x1c219, %rdi
nop
nop
inc %r9
mov $127, %rcx
rep movsq
nop
nop
nop
xor %rdi, %rdi
lea addresses_A_ht+0x17947, %rsi
lea addresses_WT_ht+0x17d47, %rdi
nop
inc %r9
mov $0, %rcx
rep movsb
nop
sub $60416, %rbx
lea addresses_normal_ht+0xd547, %rax
nop
and %r8, %r8
movups (%rax), %xmm7
vpextrq $0, %xmm7, %rbx
nop
nop
nop
nop
nop
xor $62717, %rdi
lea addresses_A_ht+0x1e847, %rsi
lea addresses_UC_ht+0x3c47, %rdi
nop
lfence
mov $64, %rcx
rep movsl
nop
nop
nop
nop
nop
sub $42589, %rdi
lea addresses_UC_ht+0x14047, %rsi
nop
nop
nop
xor $56296, %rbx
movw $0x6162, (%rsi)
nop
nop
nop
nop
and $44534, %rbx
lea addresses_WT_ht+0x11d47, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
xor $22119, %rax
mov (%rdi), %r9w
nop
nop
nop
nop
add %r8, %r8
lea addresses_A_ht+0x19047, %rsi
lea addresses_WC_ht+0x18e73, %rdi
nop
nop
nop
nop
cmp $62425, %r12
mov $97, %rcx
rep movsl
nop
add $47320, %rdi
lea addresses_WC_ht+0x98b7, %rsi
lea addresses_D_ht+0x14947, %rdi
sub $53411, %rax
mov $20, %rcx
rep movsw
nop
nop
nop
nop
nop
xor %r9, %r9
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r15
push %r8
push %rbx
push %rdi
push %rdx
// Store
lea addresses_D+0xed47, %r10
xor $54638, %rdi
movl $0x51525354, (%r10)
add %r10, %r10
// Faulty Load
lea addresses_D+0xed47, %r14
nop
nop
nop
nop
nop
and $6145, %r8
vmovntdqa (%r14), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %rbx
lea oracles, %rdi
and $0xff, %rbx
shlq $12, %rbx
mov (%rdi,%rbx,1), %rbx
pop %rdx
pop %rdi
pop %rbx
pop %r8
pop %r15
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_D', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_D', 'same': True, 'size': 32, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_UC_ht', 'same': True, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'a5': 2, '80': 75, 'a6': 2, '49': 11428, '00': 10144, 'ff': 4, '45': 164, '08': 10}
49 49 00 00 49 00 49 00 49 49 49 49 49 49 00 49 00 49 00 49 00 49 49 49 00 00 49 00 00 00 49 49 49 49 00 49 49 49 00 00 49 49 49 49 00 00 49 49 49 49 49 49 49 49 49 49 49 00 49 49 00 00 49 49 49 49 49 49 00 00 00 00 49 49 49 00 49 49 49 49 00 49 00 49 00 00 49 00 49 00 00 00 49 49 49 80 49 00 00 00 49 49 00 49 49 00 00 00 00 00 49 00 00 49 49 00 00 49 49 49 00 00 49 49 00 49 49 00 49 49 49 00 49 49 49 00 49 49 49 49 49 00 49 49 00 49 00 00 49 00 49 49 49 00 00 49 49 00 00 49 00 49 49 00 00 00 80 49 00 49 49 49 00 00 49 49 49 80 00 49 49 00 00 00 49 49 49 00 00 49 49 49 49 49 49 49 00 49 00 49 00 00 49 00 49 00 49 49 49 00 00 49 49 49 49 00 49 49 00 49 49 00 00 00 49 00 49 00 49 49 49 49 49 00 00 49 00 49 49 49 49 00 49 49 00 49 49 49 49 00 49 00 00 49 49 00 00 00 49 49 00 00 49 49 49 00 00 00 00 49 00 00 49 49 49 49 00 00 49 00 49 49 00 00 49 49 49 00 49 49 49 49 00 45 00 49 00 49 00 49 00 00 49 00 00 49 00 49 49 00 00 00 49 00 49 00 49 00 00 49 00 00 49 49 49 49 49 49 00 00 00 00 49 00 49 00 49 49 49 49 49 49 00 00 49 00 49 49 00 49 00 49 49 00 00 49 49 49 49 00 00 49 00 49 00 49 49 00 49 00 49 49 49 49 49 00 00 49 00 00 00 49 49 00 49 49 49 00 00 00 49 49 49 00 00 49 00 00 00 49 00 80 49 00 49 49 49 00 00 00 00 49 00 00 49 49 00 00 49 00 00 49 49 00 00 00 49 49 49 00 00 49 49 00 00 45 00 49 49 00 49 49 49 00 00 49 00 49 00 49 00 49 49 49 49 49 49 00 49 00 00 00 49 49 49 00 49 49 00 49 00 00 49 49 00 49 49 00 49 49 49 00 49 00 00 49 49 00 00 49 49 00 49 00 49 00 00 00 49 00 49 49 00 00 49 00 00 00 00 49 00 49 00 00 00 49 00 00 49 00 49 49 00 49 49 49 00 00 49 49 00 00 49 49 49 49 00 49 49 00 00 00 00 49 49 49 49 49 00 00 49 49 49 00 49 49 00 49 00 49 00 00 00 49 49 00 00 00 00 00 49 49 00 00 49 00 00 00 49 00 49 a5 00 00 00 49 80 00 00 00 00 49 49 49 49 00 49 80 00 49 00 49 00 49 49 00 49 00 49 00 49 49 49 00 00 49 45 00 49 49 00 49 49 49 00 00 49 00 49 00 00 49 49 00 49 49 49 49 49 00 00 00 00 49 49 49 49 00 00 49 49 49 49 49 49 00 00 00 00 49 49 00 49 00 00 49 00 00 00 00 49 00 49 49 00 00 49 49 00 49 49 49 49 49 00 00 49 49 49 00 00 00 00 00 49 00 00 00 49 00 49 49 00 49 00 00 49 00 00 49 00 00 49 00 49 45 49 49 49 00 00 00 49 00 00 00 49 00 49 49 00 00 00 49 00 00 49 49 49 00 49 00 49 49 49 00 49 00 49 49 49 00 49 49 49 49 49 00 49 00 00 00 49 00 45 00 49 49 49 00 00 00 00 00 49 00 00 49 00 00 49 49 00 00 49 49 00 00 00 49 49 00 49 00 00 00 00 00 49 49 00 00 00 49 49 49 00 49 00 49 00 00 00 00 49 49 00 00 49 00 00 00 00 00 00 00 49 00 49 49 00 00 49 49 00 00 00 00 49 49 49 00 49 00 49 00 49 49 00 00 00 49 00 00 00 00 49 49 00 49 49 49 00 00 00 00 49 00 49 00 00 00 49 00 49 00 49 49 49 00 00 00 00 00 49 00 00 49 00 49 00 49 00 49 49 00 00 49 00 00 49 00 49 49 49 00 00 00 00 00 49 49 00 49 00 49 00 00 00 00 49 00 49 00 00 49 49 49 49 49 49 00 00 49 00 00 49 49 49 00 49 49 00 00 49 49 00 00 49 49 49 49 49 49 00 49 49 00 00 00 49 00 00 49 49 49 49 49 00 00 49 49 00 00 49 00 00 00 00 00 00 00 00 49 00 49 00 00 00 49 00 49 00 00 00 00 00 00 00 49
*/
|
alloy4fun_models/trashltl/models/16/TzpvWg7dHuPTqZksK.als | Kaixi26/org.alloytools.alloy | 0 | 5239 | open main
pred idTzpvWg7dHuPTqZksK_prop17 {
always File' = File - Trash
}
pred __repair { idTzpvWg7dHuPTqZksK_prop17 }
check __repair { idTzpvWg7dHuPTqZksK_prop17 <=> prop17o } |
out/euler26.adb | FardaleM/metalang | 22 | 8110 | <reponame>FardaleM/metalang
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C;
use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C;
procedure euler26 is
type stringptr is access all char_array;
procedure PString(s : stringptr) is
begin
String'Write (Text_Streams.Stream (Current_Output), To_Ada(s.all));
end;
procedure PInt(i : in Integer) is
begin
String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left));
end;
type e is Array (Integer range <>) of Integer;
type e_PTR is access e;
function periode(restes : in e_PTR; c : in Integer; d : in Integer; b : in Integer) return Integer is
reste : Integer;
len : Integer;
chiffre : Integer;
a : Integer;
begin
len := c;
a := d;
while a /= 0 loop
chiffre := a / b;
reste := a rem b;
for i in integer range 0..len - 1 loop
if restes(i) = reste
then
return len - i;
end if;
end loop;
restes(len) := reste;
len := len + 1;
a := reste * 10;
end loop;
return 0;
end;
t : e_PTR;
p : Integer;
mi : Integer;
m : Integer;
begin
t := new e (0..999);
for j in integer range 0..999 loop
t(j) := 0;
end loop;
m := 0;
mi := 0;
for i in integer range 1..1000 loop
p := periode(t, 0, 1, i);
if p > m
then
mi := i;
m := p;
end if;
end loop;
PInt(mi);
PString(new char_array'( To_C("" & Character'Val(10))));
PInt(m);
PString(new char_array'( To_C("" & Character'Val(10))));
end;
|
src/opcodes2_song1.6502.asm | mrpopogod/nes-fun | 0 | 19351 | <filename>src/opcodes2_song1.6502.asm
song1_header:
.byte $04 ;4 streams
.byte MUSIC_SQ1 ;which stream
.byte $01 ;status byte (stream enabled)
.byte SQUARE_1 ;which channel
.byte $70 ;initial duty (01)
.byte ve_tgl_1 ;volume envelope
.word song1_square1 ;pointer to stream
.byte $53 ;tempo
.byte MUSIC_SQ2 ;which stream
.byte $01 ;status byte (stream enabled)
.byte SQUARE_2 ;which channel
.byte $B0 ;initial duty (10)
.byte ve_tgl_2 ;volume envelope
.word song1_square2 ;pointer to stream
.byte $53 ;tempo
.byte MUSIC_TRI ;which stream
.byte $01 ;status byte (stream enabled)
.byte TRIANGLE ;which channel
.byte $80 ;initial volume (on)
.byte ve_tgl_2 ;volume envelope
.word song1_tri ;pointer to stream
.byte $53 ;tempo
.byte MUSIC_NOI ;which stream
.byte $00 ;disabled. Our load routine will skip the
; rest of the reads if the status byte is 0.
; We are disabling Noise because we haven't covered it yet.
song1_square1:
.byte eighth
.byte set_loop1_counter, 14 ;repeat 14 times
@loop:
.byte A2, A2, A2, A3, A2, A3, A2, A3
.byte transpose ;the transpose opcode take a 2-byte argument
.word @lookup_table ;which is the address of the lookup table
.byte loop1 ;finite loop (14 times)
.word @loop
.byte loop ;infinite loop
.word song1_square1
@lookup_table:
.byte 2, -1, -1, -1, -1, -1, -2
.byte -1, -1, 0, -1, 8, -8, 8 ;14 entries long, reverse order
song1_square2:
.byte sixteenth
.byte rest ;offset for delay effect
.byte eighth
@loop_point:
.byte rest
.byte A4, C5, B4, C5, A4, C5, B4, C5
.byte A4, C5, B4, C5, A4, C5, B4, C5
.byte A4, C5, B4, C5, A4, C5, B4, C5
.byte A4, C5, B4, C5, A4, C5, B4, C5
.byte Ab4, B4, A4, B4, Ab4, B4, A4, B4
.byte B4, E5, D5, E5, B4, E5, D5, E5
.byte A4, Eb5, C5, Eb5, A4, Eb5, C5, Eb5
.byte A4, D5, Db5, D5, A4, D5, Db5, D5
.byte A4, C5, F5, A5, C6, A5, F5, C5
.byte Gb4, B4, Eb5, Gb5, B5, Gb5, Eb5, B4
.byte F4, Bb4, D5, F5, Gs5, F5, D5, As4
.byte E4, A4, Cs5, E5, A5, E5, sixteenth, Cs5, rest
.byte eighth
.byte Ds4, Gs4, C5, Ds5, Gs5, Ds5, C5, Gs4
.byte sixteenth
.byte G4, Fs4, G4, Fs4, G4, Fs4, G4, Fs4
.byte eighth
.byte G4, B4, D5, G5
.byte loop
.word @loop_point
song1_tri:
.byte eighth
.byte A5, C6, B5, C6, A5, C6, B5, C6 ;triangle data
.byte A5, C6, B5, C6, A5, C6, B5, C6
.byte A5, C6, B5, C6, A5, C6, B5, C6
.byte A5, C6, B5, C6, A5, C6, B5, C6
.byte Ab5, B5, A5, B5, Ab5, B5, A5, B5
.byte B5, E6, D6, E6, B5, E6, D6, E6
.byte A5, Eb6, C6, Eb6, A5, Eb6, C6, Eb6
.byte A5, D6, Db6, D6, A5, D6, Db6, D6
.byte A5, C6, F6, A6, C7, A6, F6, C6
.byte Gb5, B5, Eb6, Gb6, B6, Gb6, Eb6, B5
.byte F5, Bb5, D6, F6, Gs6, F6, D6, As5
.byte E5, A5, Cs6, E6, A6, E6, Cs6, A5
.byte Ds5, Gs5, C6, Ds6, Gs6, Ds6, C6, Gs5
.byte sixteenth
.byte G5, Fs5, G5, Fs5, G5, Fs5, G5, Fs5
.byte G5, B5, D6, G6, B5, D6, B6, D7
.byte loop
.word song1_tri |
programs/oeis/194/A194223.asm | jmorken/loda | 1 | 3480 | ; A194223: a(n) = [sum{(k/6) : 1<=k<=n}], where [ ]=floor, ( )=fractional part.
; 0,0,1,1,2,2,2,3,3,4,5,5,5,5,6,6,7,7,7,8,8,9,10,10,10,10,11,11,12,12,12,13,13,14,15,15,15,15,16,16,17,17,17,18,18,19,20,20,20,20,21,21,22,22,22,23,23,24,25,25,25,25,26,26,27,27,27,28,28,29,30,30,30,30,31,31,32,32,32,33,33,34,35,35,35,35,36,36,37,37,37,38,38,39,40,40,40,40,41,41,42,42,42,43,43,44,45,45,45,45,46,46,47,47,47,48,48,49,50,50,50,50,51,51,52,52,52,53,53,54,55,55,55,55,56,56,57,57,57,58,58,59,60,60,60,60,61,61,62,62,62,63,63,64,65,65,65,65,66,66,67,67,67,68,68,69,70,70,70,70,71,71,72,72,72,73,73,74,75,75,75,75,76,76,77,77,77,78,78,79,80,80,80,80,81,81,82,82,82,83,83,84,85,85,85,85,86,86,87,87,87,88,88,89,90,90,90,90,91,91,92,92,92,93,93,94,95,95,95,95,96,96,97,97,97,98,98,99,100,100,100,100,101,101,102,102,102,103,103,104
add $0,1
cal $0,130484 ; a(n) = Sum_{k=0..n} (k mod 6) (Partial sums of A010875).
div $0,6
mov $1,$0
|
asm/real/disk_load.asm | CtrlTab-Network/CtrlTabOS | 0 | 101198 | <reponame>CtrlTab-Network/CtrlTabOS
disk_load:
push dx ; Store DX on stack so later we can recall
; how many sectors were request to be read ,
; even if it is altered in the meantime
mov ah, 0x02 ; BIOS read sector function
mov al, dh ; Read DH sectors
mov ch, 0x00 ; Select cylinder 0
mov dh, 0x00 ; Select head 0
mov cl, 0x02 ; Start reading from second sector ( i.e.
; after the boot sector )
int 0x13 ; BIOS interrupt
jc disk_error ; Jump if error ( i.e. carry flag set )
pop dx ; Restore DX from the stack
cmp dh, al ; if AL ( sectors read ) != DH ( sectors expected )
jne disk_error ; display error message
ret
disk_error:
mov bx , DISK_ERROR_MSG
call println
jmp $
|
programs/oeis/181/A181475.asm | karttu/loda | 1 | 168809 | <reponame>karttu/loda
; A181475: a(n) = 3*n^4 + 6*n^3 - 3*n + 1.
; 1,7,91,397,1141,2611,5167,9241,15337,24031,35971,51877,72541,98827,131671,172081,221137,279991,349867,432061,527941,638947,766591,912457,1078201,1265551,1476307,1712341,1975597,2268091,2591911,2949217,3342241,3773287,4244731,4759021,5318677,5926291,6584527,7296121,8063881,8890687,9779491,10733317,11755261,12848491,14016247,15261841,16588657,18000151,19499851,21091357,22778341,24564547,26453791,28449961,30557017,32778991,35119987,37584181,40175821,42899227,45758791,48758977,51904321,55199431,58648987,62257741,66030517,69972211,74087791,78382297,82860841,87528607,92390851,97452901,102720157,108198091,113892247,119808241,125951761,132328567,138944491,145805437,152917381,160286371,167918527,175820041,183997177,192456271,201203731,210246037,219589741,229241467,239207911,249495841,260112097,271063591,282357307,294000301,305999701,318362707,331096591,344208697,357706441,371597311,385888867,400588741,415704637,431244331,447215671,463626577,480485041,497799127,515576971,533826781,552556837,571775491,591491167,611712361,632447641,653705647,675495091,697824757,720703501,744140251,768144007,792723841,817888897,843648391,870011611,896987917,924586741,952817587,981690031,1011213721,1041398377,1072253791,1103789827,1136016421,1168943581,1202581387,1236939991,1272029617,1307860561,1344443191,1381787947,1419905341,1458805957,1498500451,1538999551,1580314057,1622454841,1665432847,1709259091,1753944661,1799500717,1845938491,1893269287,1941504481,1990655521,2040733927,2091751291,2143719277,2196649621,2250554131,2305444687,2361333241,2418231817,2476152511,2535107491,2595108997,2656169341,2718300907,2781516151,2845827601,2911247857,2977789591,3045465547,3114288541,3184271461,3255427267,3327768991,3401309737,3476062681,3552041071,3629258227,3707727541,3787462477,3868476571,3950783431,4034396737,4119330241,4205597767,4293213211,4382190541,4472543797,4564287091,4657434607,4752000601,4847999401,4945445407,5044353091,5144736997,5246611741,5349992011,5454892567,5561328241,5669313937,5778864631,5889995371,6002721277,6117057541,6233019427,6350622271,6469881481,6590812537,6713430991,6837752467,6963792661,7091567341,7221092347,7352383591,7485457057,7620328801,7757014951,7895531707,8035895341,8178122197,8322228691,8468231311,8616146617,8765991241,8917781887,9071535331,9227268421,9384998077,9544741291,9706515127,9870336721,10036223281,10204192087,10374260491,10546445917,10720765861,10897237891,11075879647,11256708841,11439743257,11625000751
mov $1,$0
pow $0,2
add $1,$0
bin $1,2
mul $1,6
add $1,1
|
programs/oeis/345/A345504.asm | neoneye/loda | 22 | 81477 | <gh_stars>10-100
; A345504: Numbers that are the sum of nine squares in seven or more ways.
; 57,60,62,63,65,66,68,69,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162
add $0,1
lpb $0
sub $0,1
mul $0,2
lpe
add $0,1
mov $2,$0
div $2,2
min $2,5
add $0,$2
add $0,56
|
src/intel/tools/tests/gen6/and.asm | SoftReaper/Mesa-Renoir-deb | 0 | 5673 | <reponame>SoftReaper/Mesa-Renoir-deb
and(8) g22<1>UD g21<8,8,1>UD g20<8,8,1>UD { align1 1Q };
and.nz.f0.0(8) null<1>UD g24<8,8,1>UD g25<8,8,1>UD { align1 1Q };
and(16) g41<1>UD g39<8,8,1>UD g37<8,8,1>UD { align1 1H };
and.nz.f0.0(16) null<1>UD g45<8,8,1>UD g47<8,8,1>UD { align1 1H };
and(1) g28<1>UD g55<0,1,0>UD 0x0000ffffUD { align1 1N };
and(8) g64<1>.xUD g27<4>.xUD 0x0000ffffUD { align16 1Q };
and(8) g12<1>UD g11<8,8,1>UD 0x00000001UD { align1 1Q };
and(16) g19<1>UD g17<8,8,1>UD 0x00000001UD { align1 1H };
and(8) g16<1>.xUD g4<4>.yUD g3<4>.xUD { align16 1Q };
and(8) g5<1>D g2.4<0,1,0>D -g2.4<0,1,0>D { align1 1Q };
and(16) g6<1>D g2.4<0,1,0>D -g2.4<0,1,0>D { align1 1H };
and(1) g22<1>UD g0<0,1,0>UD 0x000000c0UD { align1 WE_all 1N };
and(8) g12<1>D g1.4<0>D -g1.4<0>D { align16 1Q };
and.nz.f0.0(8) null<1>.xUD g90<4>.xUD g89<4>.xUD { align16 1Q };
and.nz.f0.0(8) null<1>UD g4<0,1,0>UD 0x00000001UD { align1 1Q };
and.nz.f0.0(16) null<1>UD g6<0,1,0>UD 0x00000001UD { align1 1H };
and.z.f0.0(8) null<1>UD g20<8,8,1>UD 0x00000001UD { align1 1Q };
and.z.f0.0(16) null<1>UD g33<8,8,1>UD 0x00000001UD { align1 1H };
and.z.f0.0(8) null<1>.xUD g3<4>.xUD 0x00000001UD { align16 1Q };
|
other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/日本_Ver3/asm/zel_bg3.asm | prismotizm/gigaleak | 0 | 89999 | <reponame>prismotizm/gigaleak
Name: zel_bg3.asm
Type: file
Size: 169035
Last-Modified: '2016-05-13T04:36:32Z'
SHA-1: 63BEC451B638440888B4A2B1E2902796FD871188
Description: null
|
Ada/src/Problem_12.adb | Tim-Tom/project-euler | 0 | 18303 | <filename>Ada/src/Problem_12.adb<gh_stars>0
with Ada.Integer_Text_IO;
with Ada.Text_IO;
with PrimeInstances;
package body Problem_12 is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Integer_Text_IO;
procedure Solve is
-- Since we're building these up sequentially, we can also build up the list of
-- prime factors sequentially. We could probably do this more cheaply by moving up
-- through the numbers instead of down, but it would require a lot more memory just
-- to save us from a loop and division (or require us to generate and store the
-- result for every bynber in our range), so I'm not sure it would end up being a
-- victory. We store factors in two ways. The first is a linked list of factors,
-- basically what the previous number was and what factor we used to get there. The
-- second is a raw list of factors and counts. As a result we end up iterating
-- through a bunch of factors that are probably empty when we generate the count,
-- but it's still blazingly fast. To keep our lists a little smaller instead of
-- generating the sieve for our full triangle numbers, we use the fact that triangle
-- numbers are of the form n*(n-1)/2 and sum up the prime factors of both of them.
package Integer_Primes renames PrimeInstances.Integer_Primes;
sieve : constant Integer_Primes.Sieve := Integer_Primes.Generate_Sieve(15_000);
subtype sieve_index is Positive range sieve'First .. sieve'Last;
type Factor_Array is Array (sieve_index) of Positive;
type Factor_Record is record
arr: Factor_Array;
max_index : sieve_index;
end record;
type Factor_Pointer is record
last: Positive;
idx : sieve_index;
valid : Boolean;
end record;
type Factor_List is Array (1 .. sieve(sieve'Last)) of Factor_Pointer;
function total_factors(factors1, factors2: in Factor_Record) return Positive is
permutations : Positive := 1;
max_prime_index : sieve_index;
begin
if factors1.max_index > factors2.max_index then
max_prime_index := factors1.max_index;
else
max_prime_index := factors2.max_index;
end if;
for index in Factor_Array'First .. max_prime_index loop
permutations := permutations * (factors1.arr(index) + factors2.arr(index) - 1);
end loop;
return permutations;
end total_factors;
procedure generate_factors(num : in Positive; all_factors : in out Factor_List; factors : in out Factor_Record ) is
index : Positive := num;
begin
for prime_index in sieve'First .. factors.max_index loop
factors.arr(prime_index) := 1;
end loop;
factors.max_index := 1;
if all_factors(num).valid = false then
for prime_index in sieve'Range loop
declare
prime : constant Positive := sieve(prime_index);
begin
if num mod prime = 0 then
all_factors(num) := (idx => prime_index, last => num / prime, valid => true);
exit;
end if;
end;
end loop;
end if;
loop
declare
f : Factor_Pointer renames all_factors(index);
begin
factors.arr(f.idx) := factors.arr(f.idx) + 1;
if f.idx > factors.max_index then
factors.max_index := f.idx;
end if;
index := f.last;
exit when index = 1;
end;
end loop;
end generate_factors;
all_factors : Factor_List;
factors1, factors2 : Factor_Record;
even : Boolean := true;
begin
all_factors := (2 => (last => 1, idx => 1, valid => true), others => (last => 1, idx => 1, valid => false));
factors1 := (max_index => 1, arr => (others => 1));
factors2 := (max_index => 1, arr => (others => 1));
for x in 2 .. sieve(sieve'Last) loop
if even then
generate_factors(x / 2, all_factors, factors2);
even := false;
else
generate_factors(x, all_factors, factors1);
even := true;
end if;
if total_factors(factors1, factors2) > 500 then
I_IO.Put(x * (x - 1) / 2);
IO.New_Line;
exit;
end if;
end loop;
end Solve;
end Problem_12;
|
oeis/014/A014293.asm | neoneye/loda-programs | 11 | 167466 | ; A014293: a(n) = n^(n+1)-n+1.
; 1,1,7,79,1021,15621,279931,5764795,134217721,3486784393,99999999991,3138428376711,106993205379061,3937376385699277,155568095557812211,6568408355712890611,295147905179352825841,14063084452067724990993,708235345355337676357615,37589973457545958193355583,2097151999999999999999999981,122694327386105632949003612821,7511413302012830262726227918827,480250763996501976790165756943019,32009658644406818986777955348250601,2220446049250313080847263336181640601,160059109085386090080713531498405298151
mov $2,$0
pow $2,$0
sub $2,1
mul $0,$2
add $0,1
|
src/fltk-menu_items.ads | micahwelf/FLTK-Ada | 1 | 24600 | <gh_stars>1-10
with
FLTK.Widgets;
package FLTK.Menu_Items is
type Menu_Item is new Wrapper with private;
type Menu_Item_Reference (Data : not null access Menu_Item'Class) is limited null record
with Implicit_Dereference => Data;
package Forge is
-- Usually you don't bother with this and just add items
-- to Menus directly using the Add subprograms in that package.
function Create
(Text : in String;
Action : in FLTK.Widgets.Widget_Callback := null;
Shortcut : in Key_Combo := No_Key;
Flags : in Menu_Flag := Flag_Normal)
return Menu_Item;
end Forge;
function Get_Callback
(Item : in Menu_Item)
return FLTK.Widgets.Widget_Callback;
procedure Set_Callback
(Item : in out Menu_Item;
Func : in FLTK.Widgets.Widget_Callback);
procedure Do_Callback
(Item : in out Menu_Item;
Widget : in out FLTK.Widgets.Widget'Class);
function Has_Checkbox
(Item : in Menu_Item)
return Boolean;
function Is_Radio
(Item : in Menu_Item)
return Boolean;
function Get_State
(Item : in Menu_Item)
return Boolean;
procedure Set_State
(Item : in out Menu_Item;
To : in Boolean);
procedure Set_Only
(Item : in out Menu_Item);
function Get_Label
(Item : in Menu_Item)
return String;
procedure Set_Label
(Item : in out Menu_Item;
Text : in String);
function Get_Label_Color
(Item : in Menu_Item)
return Color;
procedure Set_Label_Color
(Item : in out Menu_Item;
To : in Color);
function Get_Label_Font
(Item : in Menu_Item)
return Font_Kind;
procedure Set_Label_Font
(Item : in out Menu_Item;
To : in Font_Kind);
function Get_Label_Size
(Item : in Menu_Item)
return Font_Size;
procedure Set_Label_Size
(Item : in out Menu_Item;
To : in Font_Size);
function Get_Label_Type
(Item : in Menu_Item)
return Label_Kind;
procedure Set_Label_Type
(Item : in out Menu_Item;
To : in Label_Kind);
function Get_Shortcut
(Item : in Menu_Item)
return Key_Combo;
procedure Set_Shortcut
(Item : in out Menu_Item;
To : in Key_Combo);
function Get_Flags
(Item : in Menu_Item)
return Menu_Flag;
procedure Set_Flags
(Item : in out Menu_Item;
To : in Menu_Flag);
procedure Activate
(Item : in out Menu_Item);
procedure Deactivate
(Item : in out Menu_Item);
procedure Show
(Item : in out Menu_Item);
procedure Hide
(Item : in out Menu_Item);
function Is_Active
(Item : in Menu_Item)
return Boolean;
function Is_Visible
(Item : in Menu_Item)
return Boolean;
function Is_Active_And_Visible
(Item : in Menu_Item)
return Boolean;
private
type Menu_Item is new Wrapper with null record;
overriding procedure Finalize
(This : in out Menu_Item);
pragma Inline (Get_Callback);
pragma Inline (Set_Callback);
pragma Inline (Do_Callback);
pragma Inline (Has_Checkbox);
pragma Inline (Is_Radio);
pragma Inline (Get_State);
pragma Inline (Set_State);
pragma Inline (Set_Only);
pragma Inline (Get_Label);
pragma Inline (Set_Label);
pragma Inline (Get_Label_Color);
pragma Inline (Set_Label_Color);
pragma Inline (Get_Label_Font);
pragma Inline (Set_Label_Font);
pragma Inline (Get_Label_Size);
pragma Inline (Set_Label_Size);
pragma Inline (Get_Label_Type);
pragma Inline (Set_Label_Type);
pragma Inline (Get_Shortcut);
pragma Inline (Set_Shortcut);
pragma Inline (Get_Flags);
pragma Inline (Set_Flags);
pragma Inline (Activate);
pragma Inline (Deactivate);
pragma Inline (Show);
pragma Inline (Hide);
pragma Inline (Is_Active);
pragma Inline (Is_Visible);
pragma Inline (Is_Active_And_Visible);
end FLTK.Menu_Items;
|
tools/uaflex/regular_expressions.ads | faelys/gela-asis | 4 | 14543 | <reponame>faelys/gela-asis
------------------------------------------------------------------------------
-- <NAME> A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
with Symbols; use Symbols;
with Positions;
with Automatons;
package Regular_Expressions is
type Expression is private;
function New_Literal (S : Symbol_Set)
return Expression;
function New_Rule (Item : Expression;
Token : Natural)
return Expression;
function New_Alternative (Left : Expression;
Right : Expression)
return Expression;
function New_Sequence (Left : Expression;
Right : Expression)
return Expression;
function New_Iteration (Item : Expression;
Allow_Zero : Boolean := True)
return Expression;
function New_Optional (Item : Expression)
return Expression;
function New_Apply (Item : Expression)
return Expression;
procedure Add_To_DFA
(Result : in out Automatons.DFA;
Item : in Expression;
Starting : in Positive);
Syntax_Error : exception;
private
function Literal_Count (Item : Expression) return Natural;
type Expression_Node;
type Expression is access all Expression_Node;
type Expression_Kind is
(Literal, Alternative, Sequence, Iteration, Optional, Apply);
type Expression_Node (Kind : Expression_Kind) is record
Nullable : Boolean;
case Kind is
when Literal =>
Chars : Symbol_Set;
Token : Natural := 0;
when Alternative | Sequence =>
Left, Right : Expression;
when Iteration =>
Item : Expression;
Allow_Zero : Boolean;
when Optional | Apply =>
Child : Expression;
end case;
end record;
end Regular_Expressions;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the <NAME>, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
programs/oeis/210/A210736.asm | neoneye/loda | 22 | 171021 | ; A210736: Expansion of (1 + sqrt( (1 + 2*x) / (1 - 2*x))) / 2 in powers of x.
; 1,1,1,2,3,6,10,20,35,70,126,252,462,924,1716,3432,6435,12870,24310,48620,92378,184756,352716,705432,1352078,2704156,5200300,10400600,20058300,40116600,77558760,155117520,300540195,601080390,1166803110,2333606220,4537567650,9075135300,17672631900,35345263800,68923264410,137846528820,269128937220,538257874440,1052049481860,2104098963720,4116715363800,8233430727600,16123801841550,32247603683100,63205303218876,126410606437752,247959266474052,495918532948104,973469712824056,1946939425648112,3824345300380220,7648690600760440,15033633249770520,30067266499541040,59132290782430712,118264581564861424,232714176627630544,465428353255261088,916312070471295267,1832624140942590534,3609714217008132870,7219428434016265740,14226520737620288370,28453041475240576740,56093138908331422716,112186277816662845432,221256270138418389602,442512540276836779204,873065282167813104916,1746130564335626209832,3446310324346630677300,6892620648693261354600,13608507434599516007800,27217014869199032015600,53753604366668088230810,107507208733336176461620,212392290424395860814420,424784580848791721628840,839455243105945545123660,1678910486211891090247320,3318776542511877736535400,6637553085023755473070800,13124252690842425594480900,26248505381684851188961800,51913710643776705684835560,103827421287553411369671120,205397724721029574666088520,410795449442059149332177040,812850570172585125274307760,1625701140345170250548615520,3217533506933149454210801550,6435067013866298908421603100,12738806129490428451365214300,25477612258980856902730428600
sub $0,1
mov $1,$0
div $1,2
bin $0,$1
|
libsrc/_DEVELOPMENT/string/c/sdcc_iy/_memupr__callee.asm | jpoikela/z88dk | 640 | 161302 |
; char *_memupr__callee(void *p, size_t n)
SECTION code_clib
SECTION code_string
PUBLIC __memupr__callee
EXTERN asm__memupr
__memupr__callee:
pop af
pop hl
pop bc
push af
jp asm__memupr
|
Transynther/x86/_processed/AVXALIGN/_zr_/i7-7700_9_0xca.log_21829_384.asm | ljhsiun2/medusa | 9 | 167005 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x787c, %rsi
lea addresses_WC_ht+0x183bc, %rdi
nop
nop
sub %r13, %r13
mov $64, %rcx
rep movsq
nop
cmp %r15, %r15
lea addresses_WT_ht+0x383c, %rbx
nop
add %rdx, %rdx
mov $0x6162636465666768, %rdi
movq %rdi, %xmm0
movups %xmm0, (%rbx)
nop
nop
nop
and %rcx, %rcx
lea addresses_A_ht+0x1bebc, %rdi
nop
xor $5027, %rcx
movb (%rdi), %bl
nop
cmp $390, %rdi
lea addresses_WC_ht+0x19e3c, %r13
nop
and $10151, %r15
movups (%r13), %xmm2
vpextrq $1, %xmm2, %rcx
nop
nop
nop
nop
nop
cmp %rbx, %rbx
lea addresses_normal_ht+0x1093c, %r13
nop
nop
nop
nop
xor $8789, %r15
mov (%r13), %esi
nop
nop
nop
add $44283, %r15
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r9
push %rax
push %rcx
push %rdx
// Store
lea addresses_A+0xeaac, %rax
nop
nop
nop
sub $52493, %rdx
mov $0x5152535455565758, %rcx
movq %rcx, %xmm7
vmovups %ymm7, (%rax)
nop
xor %rax, %rax
// Faulty Load
mov $0xffcd200000006bc, %rax
nop
nop
xor %r11, %r11
movb (%rax), %r9b
lea oracles, %r11
and $0xff, %r9
shlq $12, %r9
mov (%r11,%r9,1), %r9
pop %rdx
pop %rcx
pop %rax
pop %r9
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': True, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'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
*/
|
oeis/055/A055099.asm | neoneye/loda-programs | 11 | 23476 | ; A055099: Expansion of g.f.: (1 + x)/(1 - 3*x - 2*x^2).
; Submitted by <NAME>
; 1,4,14,50,178,634,2258,8042,28642,102010,363314,1293962,4608514,16413466,58457426,208199210,741512482,2640935866,9405832562,33499369418,119309773378,424928058970,1513403723666,5390067288938,19197009314146,68371162520314,243507506189234,867264843608330,3088809543203458,11000958316827034,39180494036888018,139543398744318122,496991184306730402,1770060350408827450,6304163419839943154,22452610960337484362,79966159720692339394,284803701082751986906,1014343422689640639506,3612637670234425892330
mov $2,1
mov $4,1
lpb $0
sub $0,1
mul $4,2
mov $3,$4
mov $4,$2
add $2,$3
add $4,$2
lpe
mov $0,$4
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c4/c41107a.ada | best08618/asylo | 7 | 14713 | -- C41107A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT FOR AN ARRAY HAVING BOTH POSITIVE AND NEGATIVE
-- INDEX VALUES, THE PROPER COMPONENT IS SELECTED - A.
-- CHECK THAT FOR AN ARRAY INDEXED WITH AN ENUMERATION TYPE,
-- APPROPRIATE COMPONENTS CAN BE SELECTED - B.
-- CHECK THAT SUBSCRIPT EXPRESSIONS CAN BE OF COMPLEXITY GREATER
-- THAN VARIABLE + - CONSTANT - C.
-- CHECK THAT MULTIPLY DIMENSIONED ARRAYS ARE PROPERLY INDEXED - D.
-- WKB 7/29/81
-- JBG 8/21/83
WITH REPORT;
USE REPORT;
PROCEDURE C41107A IS
TYPE T1 IS ARRAY (INTEGER RANGE -2..2) OF INTEGER;
A : T1 := (1,2,3,4,5);
TYPE COLOR IS (RED,ORANGE,YELLOW,GREEN,BLUE);
TYPE T2 IS ARRAY (COLOR RANGE RED..BLUE) OF INTEGER;
B : T2 := (5,4,3,2,1);
C : STRING (1..7) := "ABCDEFG";
TYPE T4 IS ARRAY (1..4,1..3) OF INTEGER;
D : T4 := (1 => (1,2,3), 2 => (4,5,6), 3 => (7,8,9),
4 => (0,-1,-2));
V1 : INTEGER := IDENT_INT (1);
V2 : INTEGER := IDENT_INT (2);
V3 : INTEGER := IDENT_INT (3);
PROCEDURE P1 (X : IN INTEGER; Y : IN OUT INTEGER;
Z : OUT INTEGER; W : STRING) IS
BEGIN
IF X /= 1 THEN
FAILED ("WRONG VALUE FOR IN PARAMETER - " & W);
END IF;
IF Y /= 4 THEN
FAILED ("WRONG VALUE FOR IN OUT PARAMETER - " & W);
END IF;
Y := 11;
Z := 12;
END P1;
PROCEDURE P2 (X : IN CHARACTER; Y : IN OUT CHARACTER;
Z : OUT CHARACTER) IS
BEGIN
IF X /= 'D' THEN
FAILED ("WRONG VALUE FOR IN PARAMETER - C");
END IF;
IF Y /= 'F' THEN
FAILED ("WRONG VALUE FOR IN OUT PARAMETER - C");
END IF;
Y := 'Y';
Z := 'Z';
END P2;
BEGIN
TEST ("C41107A", "CHECK THAT THE PROPER COMPONENT IS SELECTED " &
"FOR ARRAYS WITH POS AND NEG INDICES, " &
"ENUMERATION INDICES, COMPLEX SUBSCRIPT " &
"EXPRESSIONS, AND MULTIPLE DIMENSIONS");
IF A(IDENT_INT(1)) /= 4 THEN
FAILED ("WRONG VALUE FOR EXPRESSION - A");
END IF;
A(IDENT_INT(-2)) := 10;
IF A /= (10,2,3,4,5) THEN
FAILED ("WRONG TARGET FOR ASSIGNMENT - A");
END IF;
A := (2,1,0,3,4);
P1 (A(-1), A(2), A(-2), "A");
IF A /= (12,1,0,3,11) THEN
FAILED ("WRONG TARGET FOR (IN) OUT PARAMETER - A");
END IF;
IF B(GREEN) /= 2 THEN
FAILED ("WRONG VALUE FOR EXPRESSION - B");
END IF;
B(YELLOW) := 10;
IF B /= (5,4,10,2,1) THEN
FAILED ("WRONG TARGET FOR ASSIGNMENT - B");
END IF;
B := (1,4,2,3,5);
P1 (B(RED), B(ORANGE), B(BLUE), "B");
IF B /= (1,11,2,3,12) THEN
FAILED ("WRONG TARGET FOR (IN) OUT PARAMETER - B");
END IF;
IF C(3..6)(3**2 / 3 * (2-1) - 6 / 3 + 2) /= 'C' THEN
FAILED ("WRONG VALUE FOR EXPRESSION - C");
END IF;
C(3..6)(V3**2 / V1 * (V3-V2) + IDENT_INT(4) - V3 * V2 - V1) := 'W';
IF C /= "ABCDEWG" THEN
FAILED ("WRONG TARGET FOR ASSIGNMENT - C");
END IF;
C := "ABCDEFG";
P2 (C(3..6)(V3+V1), C(3..6)(V3*V2), C(3..6)((V1+V2)*V1));
IF C /= "ABZDEYG" THEN
FAILED ("WRONG TARGET FOR (IN) OUT PARAMETER - C");
END IF;
IF D(IDENT_INT(1),IDENT_INT(3)) /= 3 THEN
FAILED ("WRONG VALUE FOR EXPRESSION - D");
END IF;
D(IDENT_INT(4),IDENT_INT(2)) := 10;
IF D /= ((1,2,3),(4,5,6),(7,8,9),(0,10,-2)) THEN
FAILED ("WRONG TARGET FOR ASSIGNMENT - D");
END IF;
D := (1 => (0,2,3), 2 => (4,5,6), 3 => (7,8,9), 4 => (1,-1,-2));
P1 (D(4,1), D(2,1), D(3,2), "D");
IF D /= ((0,2,3),(11,5,6),(7,12,9),(1,-1,-2)) THEN
FAILED ("WRONG TARGET FOR (IN) OUT PARAMETER - D");
END IF;
RESULT;
END C41107A;
|
Groups/Homomorphisms/Kernel.agda | Smaug123/agdaproofs | 4 | 13787 | {-# OPTIONS --safe --warning=error --without-K #-}
open import Groups.Definition
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Groups.Homomorphisms.Definition
open import Groups.Homomorphisms.Lemmas
open import Groups.Subgroups.Definition
open import Groups.Subgroups.Normal.Definition
open import Groups.Lemmas
module Groups.Homomorphisms.Kernel {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+G_ : A → A → A} {_+H_ : B → B → B} {G : Group S _+G_} {H : Group T _+H_} {f : A → B} (fHom : GroupHom G H f) where
open Setoid T
open Equivalence eq
groupKernelPred : A → Set d
groupKernelPred a = Setoid._∼_ T (f a) (Group.0G H)
groupKernelPredWd : {x y : A} → (Setoid._∼_ S x y) → groupKernelPred x → groupKernelPred y
groupKernelPredWd x=y fx=0 = transitive (GroupHom.wellDefined fHom (Equivalence.symmetric (Setoid.eq S) x=y)) fx=0
groupKernelIsSubgroup : Subgroup G groupKernelPred
Subgroup.closedUnderPlus groupKernelIsSubgroup fg=0 fh=0 = transitive (transitive (GroupHom.groupHom fHom) (Group.+WellDefined H fg=0 fh=0)) (Group.identLeft H)
Subgroup.containsIdentity groupKernelIsSubgroup = imageOfIdentityIsIdentity fHom
Subgroup.closedUnderInverse groupKernelIsSubgroup fg=0 = transitive (homRespectsInverse fHom) (transitive (inverseWellDefined H fg=0) (invIdent H))
Subgroup.isSubset groupKernelIsSubgroup = groupKernelPredWd
groupKernelIsNormalSubgroup : normalSubgroup G groupKernelIsSubgroup
groupKernelIsNormalSubgroup {g} fk=0 = transitive (transitive (transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H reflexive (transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H fk=0 reflexive) (Group.identLeft H)))) (symmetric (GroupHom.groupHom fHom)))) (GroupHom.wellDefined fHom (Group.invRight G {g}))) (imageOfIdentityIsIdentity fHom)
|
src/gl/interface/gl-fixed.ads | Roldak/OpenGLAda | 79 | 3668 | -- part of OpenGLAda, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Types;
private with GL.Low_Level;
-- Fixed function pipeline. Deprecated in OpenGL 3.0.
package GL.Fixed is
pragma Preelaborate;
use GL.Types;
subtype Vertex_Length is Positive range 2 .. 4;
type Client_Side_Capability is (Vertex_Array, Normal_Array, Color_Array,
Index_Array, Texture_Coord_Array,
Edge_Flag_Array, Fog_Coord_Array,
Secondary_Color_Array);
procedure Set_Vertex_Pointer (Length : Vertex_Length; Stride, Offset : Size);
procedure Set_Color_Pointer (Stride, Offset : Size);
procedure Enable (Capability : Client_Side_Capability);
procedure Disable (Capability : Client_Side_Capability);
private
for Client_Side_Capability use (Vertex_Array => 16#8074#,
Normal_Array => 16#8075#,
Color_Array => 16#8076#,
Index_Array => 16#8077#,
Texture_Coord_Array => 16#8078#,
Edge_Flag_Array => 16#8079#,
Fog_Coord_Array => 16#8457#,
Secondary_Color_Array => 16#845E#);
for Client_Side_Capability'Size use Low_Level.Enum'Size;
end GL.Fixed;
|
programs/oeis/115/A115852.asm | karttu/loda | 1 | 179392 | ; A115852: Dihedral D3 elliptical invariant transform on A000045: a[n+1]/a[n]= Phi^4=((1+Sqrt[5])/2)^4.
; 0,0,4,20,156,1024,7140,48620,334084,2287656,15685560,107495424,736823880,5050163160,34614602500,237251310140,1626146516820,11145769206784,76394251284780,523613954825156,3588903524021764
cal $0,244855 ; a(n) = Fibonacci(n)^4-1.
add $0,3
div $0,2
mul $0,2
mov $1,$0
div $1,16
mul $1,4
|
test/Succeed/exec-tc/empty.agda | cruhland/agda | 1,989 | 9853 | module exec-tc.empty where
|
programs/oeis/174/A174239.asm | jmorken/loda | 1 | 96118 | <reponame>jmorken/loda
; A174239: a(n) = (3*n + 1 + (-1)^n*(n+3))/4.
; 1,0,3,1,5,2,7,3,9,4,11,5,13,6,15,7,17,8,19,9,21,10,23,11,25,12,27,13,29,14,31,15,33,16,35,17,37,18,39,19,41,20,43,21,45,22,47,23,49,24,51,25,53,26,55,27,57,28,59,29,61,30,63,31,65,32,67,33,69,34,71,35,73,36,75,37,77,38,79,39,81
add $0,3
dif $0,2
mov $1,$0
sub $1,2
|
regtests/mysql/ado-schemas-mysql-tests.adb | Letractively/ada-ado | 0 | 998 | -----------------------------------------------------------------------
-- schemas Tests -- Test loading of database schema for MySQL
-- Copyright (C) 2009, 2010, 2011, 2012 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with ADO.Drivers;
with ADO.Drivers.Connections;
with ADO.Sessions;
with ADO.Databases;
with ADO.Schemas.Mysql;
with Regtests;
package body ADO.Schemas.Mysql.Tests is
use Util.Tests;
package Caller is new Util.Test_Caller (Test, "ADO.Schemas.MySQL");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ADO.Schemas.Load_Schema",
Test_Load_Schema'Access);
end Add_Tests;
procedure Test_Load_Schema (T : in out Test) is
use type ADO.Drivers.Connections.Driver_Access;
S : constant ADO.Sessions.Session := Regtests.Get_Database;
DB : constant ADO.Databases.Connection'Class := S.Get_Connection;
Dr : constant ADO.Drivers.Connections.Driver_Access := DB.Get_Driver;
Schema : Schema_Definition;
Table : Table_Definition;
begin
T.Assert (Dr /= null, "Database connection has no driver");
if Dr.Get_Driver_Name /= "mysql" then
return;
end if;
ADO.Schemas.Mysql.Load_Schema (DB, Schema);
Table := ADO.Schemas.Find_Table (Schema, "allocate");
T.Assert (Table /= null, "Table schema for test_allocate not found");
Assert_Equals (T, "allocate", Get_Name (Table));
declare
C : Column_Cursor := Get_Columns (Table);
Nb_Columns : Integer := 0;
begin
while Has_Element (C) loop
Nb_Columns := Nb_Columns + 1;
Next (C);
end loop;
Assert_Equals (T, 3, Nb_Columns, "Invalid number of columns");
end;
declare
C : constant Column_Definition := Find_Column (Table, "ID");
begin
T.Assert (C /= null, "Cannot find column 'id' in table schema");
Assert_Equals (T, "ID", Get_Name (C), "Invalid column name");
end;
end Test_Load_Schema;
end ADO.Schemas.Mysql.Tests;
|
alog/src/alog.ads | btmalone/alog | 0 | 616 | ------------------------------------------------------------------------
--
-- Copyright (c) 2018, <NAME> All Rights Reserved.
--
-- 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.
--
------------------------------------------------------------------------
------------------------------------------------------------------------
--
-- Ada support for leveled logs. Based on Google's glog
--
------------------------------------------------------------------------
with GNAT.Source_Info;
with Ada.Containers.Hashed_Maps;
with Ada.Strings.Unbounded.Hash;
package Alog is
package ASU renames Ada.Strings.Unbounded;
-- Four levels of loggging.
type Level is (
INFO,
WARN,
ERROR,
FATAL
);
-- Type representing where things are logged to.
type LogTo is (
NONE,
STDOUT,
FILE,
BOTH
);
---------------------------------------------------------------------
-- Logging
---------------------------------------------------------------------
-- Methods for each log message level.
procedure Info (Msg : String);
procedure Warn (Msg : String);
procedure Error (Msg : String);
procedure Fatal (Msg : String);
procedure Vlog (Lvl : Natural;
Msg : String;
Source : String := GNAT.Source_Info.Source_Location);
---------------------------------------------------------------------
-- Configuration
---------------------------------------------------------------------
-- Set where the logs saved. By default set to BOTH.
procedure Set_LogTo (Output : LogTo);
-- Helper method to you can pass a String representation of LogTo.
procedure Set_LogTo (Output : String);
-- Set what the threshold level of stdout will be.
procedure Set_Stdout_Threshold (Lvl : Level);
-- Helper method to you can pass a String representation of Level.
procedure Set_Stdout_Threshold (Lvl : String);
-- Set where the log files shoudl be saved.
procedure Set_File_Path (Path : String);
-- Set the Vlog Threshold.
procedure Set_Vlog_Threshold (Lvl : Natural);
-- blah
procedure Set_Vlog_Modules (Mods : String);
---------------------------------------------------------------------
-- Statistics
---------------------------------------------------------------------
-- Return the number of lines written to a specified log file.
function Lines (Lvl : Level) return Natural;
private
-- Record of statistics about the log levels.
type Level_Stats is record
Lines : Natural := 0;
end record;
-- Array of level stats for each log level.
type Log_Stats is array (Level) of Level_Stats;
Stats : Log_Stats;
function Program_Name (Cmd : String) return String;
function Program_Time (Time : String) return String;
function Format_Module (Source : String) return String;
procedure Vmodule_Setup (Mods : String);
Files_Created : Boolean := False;
Files_Location_Set : Boolean := False;
function Equivalent_Strings (Left, Right : ASU.Unbounded_String)
return Boolean;
package Module is new Ada.Containers.Hashed_Maps
(Key_Type => ASU.Unbounded_String,
Element_Type => Natural,
Hash => ASU.Hash,
Equivalent_Keys => Equivalent_Strings);
Modules_Map : Module.Map;
end Alog;
|
tools-src/gnu/gcc/gcc/ada/checks.adb | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 4162 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- C H E C K S --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Debug; use Debug;
with Einfo; use Einfo;
with Errout; use Errout;
with Exp_Ch2; use Exp_Ch2;
with Exp_Util; use Exp_Util;
with Elists; use Elists;
with Freeze; use Freeze;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Restrict; use Restrict;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Eval; use Sem_Eval;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sem_Warn; use Sem_Warn;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand; use Stand;
with Tbuild; use Tbuild;
with Ttypes; use Ttypes;
with Urealp; use Urealp;
with Validsw; use Validsw;
package body Checks is
-- General note: many of these routines are concerned with generating
-- checking code to make sure that constraint error is raised at runtime.
-- Clearly this code is only needed if the expander is active, since
-- otherwise we will not be generating code or going into the runtime
-- execution anyway.
-- We therefore disconnect most of these checks if the expander is
-- inactive. This has the additional benefit that we do not need to
-- worry about the tree being messed up by previous errors (since errors
-- turn off expansion anyway).
-- There are a few exceptions to the above rule. For instance routines
-- such as Apply_Scalar_Range_Check that do not insert any code can be
-- safely called even when the Expander is inactive (but Errors_Detected
-- is 0). The benefit of executing this code when expansion is off, is
-- the ability to emit constraint error warning for static expressions
-- even when we are not generating code.
----------------------------
-- Local Subprogram Specs --
----------------------------
procedure Apply_Selected_Length_Checks
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id;
Do_Static : Boolean);
-- This is the subprogram that does all the work for Apply_Length_Check
-- and Apply_Static_Length_Check. Expr, Target_Typ and Source_Typ are as
-- described for the above routines. The Do_Static flag indicates that
-- only a static check is to be done.
procedure Apply_Selected_Range_Checks
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id;
Do_Static : Boolean);
-- This is the subprogram that does all the work for Apply_Range_Check.
-- Expr, Target_Typ and Source_Typ are as described for the above
-- routine. The Do_Static flag indicates that only a static check is
-- to be done.
function Get_Discriminal (E : Entity_Id; Bound : Node_Id) return Node_Id;
-- If a discriminal is used in constraining a prival, Return reference
-- to the discriminal of the protected body (which renames the parameter
-- of the enclosing protected operation). This clumsy transformation is
-- needed because privals are created too late and their actual subtypes
-- are not available when analysing the bodies of the protected operations.
-- To be cleaned up???
function Guard_Access
(Cond : Node_Id;
Loc : Source_Ptr;
Ck_Node : Node_Id)
return Node_Id;
-- In the access type case, guard the test with a test to ensure
-- that the access value is non-null, since the checks do not
-- not apply to null access values.
procedure Install_Static_Check (R_Cno : Node_Id; Loc : Source_Ptr);
-- Called by Apply_{Length,Range}_Checks to rewrite the tree with the
-- Constraint_Error node.
function Selected_Length_Checks
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id;
Warn_Node : Node_Id)
return Check_Result;
-- Like Apply_Selected_Length_Checks, except it doesn't modify
-- anything, just returns a list of nodes as described in the spec of
-- this package for the Range_Check function.
function Selected_Range_Checks
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id;
Warn_Node : Node_Id)
return Check_Result;
-- Like Apply_Selected_Range_Checks, except it doesn't modify anything,
-- just returns a list of nodes as described in the spec of this package
-- for the Range_Check function.
------------------------------
-- Access_Checks_Suppressed --
------------------------------
function Access_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Access_Checks
or else (Present (E) and then Suppress_Access_Checks (E));
end Access_Checks_Suppressed;
-------------------------------------
-- Accessibility_Checks_Suppressed --
-------------------------------------
function Accessibility_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Accessibility_Checks
or else (Present (E) and then Suppress_Accessibility_Checks (E));
end Accessibility_Checks_Suppressed;
-------------------------
-- Append_Range_Checks --
-------------------------
procedure Append_Range_Checks
(Checks : Check_Result;
Stmts : List_Id;
Suppress_Typ : Entity_Id;
Static_Sloc : Source_Ptr;
Flag_Node : Node_Id)
is
Internal_Flag_Node : Node_Id := Flag_Node;
Internal_Static_Sloc : Source_Ptr := Static_Sloc;
Checks_On : constant Boolean :=
(not Index_Checks_Suppressed (Suppress_Typ))
or else
(not Range_Checks_Suppressed (Suppress_Typ));
begin
-- For now we just return if Checks_On is false, however this should
-- be enhanced to check for an always True value in the condition
-- and to generate a compilation warning???
if not Checks_On then
return;
end if;
for J in 1 .. 2 loop
exit when No (Checks (J));
if Nkind (Checks (J)) = N_Raise_Constraint_Error
and then Present (Condition (Checks (J)))
then
if not Has_Dynamic_Range_Check (Internal_Flag_Node) then
Append_To (Stmts, Checks (J));
Set_Has_Dynamic_Range_Check (Internal_Flag_Node);
end if;
else
Append_To
(Stmts, Make_Raise_Constraint_Error (Internal_Static_Sloc));
end if;
end loop;
end Append_Range_Checks;
------------------------
-- Apply_Access_Check --
------------------------
procedure Apply_Access_Check (N : Node_Id) is
P : constant Node_Id := Prefix (N);
begin
if Inside_A_Generic then
return;
end if;
if Is_Entity_Name (P) then
Check_Unset_Reference (P);
end if;
if Is_Entity_Name (P)
and then Access_Checks_Suppressed (Entity (P))
then
return;
elsif Access_Checks_Suppressed (Etype (P)) then
return;
else
Set_Do_Access_Check (N, True);
end if;
end Apply_Access_Check;
-------------------------------
-- Apply_Accessibility_Check --
-------------------------------
procedure Apply_Accessibility_Check (N : Node_Id; Typ : Entity_Id) is
Loc : constant Source_Ptr := Sloc (N);
Param_Ent : constant Entity_Id := Param_Entity (N);
Param_Level : Node_Id;
Type_Level : Node_Id;
begin
if Inside_A_Generic then
return;
-- Only apply the run-time check if the access parameter
-- has an associated extra access level parameter and
-- when the level of the type is less deep than the level
-- of the access parameter.
elsif Present (Param_Ent)
and then Present (Extra_Accessibility (Param_Ent))
and then UI_Gt (Object_Access_Level (N),
Type_Access_Level (Typ))
and then not Accessibility_Checks_Suppressed (Param_Ent)
and then not Accessibility_Checks_Suppressed (Typ)
then
Param_Level :=
New_Occurrence_Of (Extra_Accessibility (Param_Ent), Loc);
Type_Level :=
Make_Integer_Literal (Loc, Type_Access_Level (Typ));
-- Raise Program_Error if the accessibility level of the
-- the access parameter is deeper than the level of the
-- target access type.
Insert_Action (N,
Make_Raise_Program_Error (Loc,
Condition =>
Make_Op_Gt (Loc,
Left_Opnd => Param_Level,
Right_Opnd => Type_Level)));
Analyze_And_Resolve (N);
end if;
end Apply_Accessibility_Check;
---------------------------
-- Apply_Alignment_Check --
---------------------------
procedure Apply_Alignment_Check (E : Entity_Id; N : Node_Id) is
AC : constant Node_Id := Address_Clause (E);
Expr : Node_Id;
Loc : Source_Ptr;
begin
if No (AC) or else Range_Checks_Suppressed (E) then
return;
end if;
Loc := Sloc (AC);
Expr := Expression (AC);
if Nkind (Expr) = N_Unchecked_Type_Conversion then
Expr := Expression (Expr);
elsif Nkind (Expr) = N_Function_Call
and then Is_RTE (Entity (Name (Expr)), RE_To_Address)
then
Expr := First (Parameter_Associations (Expr));
if Nkind (Expr) = N_Parameter_Association then
Expr := Explicit_Actual_Parameter (Expr);
end if;
end if;
-- Here Expr is the address value. See if we know that the
-- value is unacceptable at compile time.
if Compile_Time_Known_Value (Expr)
and then Known_Alignment (E)
then
if Expr_Value (Expr) mod Alignment (E) /= 0 then
Insert_Action (N,
Make_Raise_Program_Error (Loc));
Error_Msg_NE
("?specified address for& not " &
"consistent with alignment", Expr, E);
end if;
-- Here we do not know if the value is acceptable, generate
-- code to raise PE if alignment is inappropriate.
else
-- Skip generation of this code if we don't want elab code
if not Restrictions (No_Elaboration_Code) then
Insert_After_And_Analyze (N,
Make_Raise_Program_Error (Loc,
Condition =>
Make_Op_Ne (Loc,
Left_Opnd =>
Make_Op_Mod (Loc,
Left_Opnd =>
Unchecked_Convert_To
(RTE (RE_Integer_Address),
Duplicate_Subexpr (Expr)),
Right_Opnd =>
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (E, Loc),
Attribute_Name => Name_Alignment)),
Right_Opnd => Make_Integer_Literal (Loc, Uint_0))),
Suppress => All_Checks);
end if;
end if;
return;
end Apply_Alignment_Check;
-------------------------------------
-- Apply_Arithmetic_Overflow_Check --
-------------------------------------
-- This routine is called only if the type is an integer type, and
-- a software arithmetic overflow check must be performed for op
-- (add, subtract, multiply). The check is performed only if
-- Software_Overflow_Checking is enabled and Do_Overflow_Check
-- is set. In this case we expand the operation into a more complex
-- sequence of tests that ensures that overflow is properly caught.
procedure Apply_Arithmetic_Overflow_Check (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Typ : constant Entity_Id := Etype (N);
Rtyp : constant Entity_Id := Root_Type (Typ);
Siz : constant Int := UI_To_Int (Esize (Rtyp));
Dsiz : constant Int := Siz * 2;
Opnod : Node_Id;
Ctyp : Entity_Id;
Opnd : Node_Id;
Cent : RE_Id;
Lo : Uint;
Hi : Uint;
OK : Boolean;
begin
if not Software_Overflow_Checking
or else not Do_Overflow_Check (N)
or else not Expander_Active
then
return;
end if;
-- Nothing to do if the range of the result is known OK
Determine_Range (N, OK, Lo, Hi);
-- Note in the test below that we assume that if a bound of the
-- range is equal to that of the type. That's not quite accurate
-- but we do this for the following reasons:
-- a) The way that Determine_Range works, it will typically report
-- the bounds of the value are the bounds of the type, because
-- it either can't tell anything more precise, or does not think
-- it is worth the effort to be more precise.
-- b) It is very unusual to have a situation in which this would
-- generate an unnecessary overflow check (an example would be
-- a subtype with a range 0 .. Integer'Last - 1 to which the
-- literal value one is added.
-- c) The alternative is a lot of special casing in this routine
-- which would partially duplicate the Determine_Range processing.
if OK
and then Lo > Expr_Value (Type_Low_Bound (Typ))
and then Hi < Expr_Value (Type_High_Bound (Typ))
then
return;
end if;
-- None of the special case optimizations worked, so there is nothing
-- for it but to generate the full general case code:
-- x op y
-- is expanded into
-- Typ (Checktyp (x) op Checktyp (y));
-- where Typ is the type of the original expression, and Checktyp is
-- an integer type of sufficient length to hold the largest possible
-- result.
-- In the case where check type exceeds the size of Long_Long_Integer,
-- we use a different approach, expanding to:
-- typ (xxx_With_Ovflo_Check (Integer_64 (x), Integer (y)))
-- where xxx is Add, Multiply or Subtract as appropriate
-- Find check type if one exists
if Dsiz <= Standard_Integer_Size then
Ctyp := Standard_Integer;
elsif Dsiz <= Standard_Long_Long_Integer_Size then
Ctyp := Standard_Long_Long_Integer;
-- No check type exists, use runtime call
else
if Nkind (N) = N_Op_Add then
Cent := RE_Add_With_Ovflo_Check;
elsif Nkind (N) = N_Op_Multiply then
Cent := RE_Multiply_With_Ovflo_Check;
else
pragma Assert (Nkind (N) = N_Op_Subtract);
Cent := RE_Subtract_With_Ovflo_Check;
end if;
Rewrite (N,
OK_Convert_To (Typ,
Make_Function_Call (Loc,
Name => New_Reference_To (RTE (Cent), Loc),
Parameter_Associations => New_List (
OK_Convert_To (RTE (RE_Integer_64), Left_Opnd (N)),
OK_Convert_To (RTE (RE_Integer_64), Right_Opnd (N))))));
Analyze_And_Resolve (N, Typ);
return;
end if;
-- If we fall through, we have the case where we do the arithmetic in
-- the next higher type and get the check by conversion. In these cases
-- Ctyp is set to the type to be used as the check type.
Opnod := Relocate_Node (N);
Opnd := OK_Convert_To (Ctyp, Left_Opnd (Opnod));
Analyze (Opnd);
Set_Etype (Opnd, Ctyp);
Set_Analyzed (Opnd, True);
Set_Left_Opnd (Opnod, Opnd);
Opnd := OK_Convert_To (Ctyp, Right_Opnd (Opnod));
Analyze (Opnd);
Set_Etype (Opnd, Ctyp);
Set_Analyzed (Opnd, True);
Set_Right_Opnd (Opnod, Opnd);
-- The type of the operation changes to the base type of the check
-- type, and we reset the overflow check indication, since clearly
-- no overflow is possible now that we are using a double length
-- type. We also set the Analyzed flag to avoid a recursive attempt
-- to expand the node.
Set_Etype (Opnod, Base_Type (Ctyp));
Set_Do_Overflow_Check (Opnod, False);
Set_Analyzed (Opnod, True);
-- Now build the outer conversion
Opnd := OK_Convert_To (Typ, Opnod);
Analyze (Opnd);
Set_Etype (Opnd, Typ);
Set_Analyzed (Opnd, True);
Set_Do_Overflow_Check (Opnd, True);
Rewrite (N, Opnd);
end Apply_Arithmetic_Overflow_Check;
----------------------------
-- Apply_Array_Size_Check --
----------------------------
-- Note: Really of course this entre check should be in the backend,
-- and perhaps this is not quite the right value, but it is good
-- enough to catch the normal cases (and the relevant ACVC tests!)
procedure Apply_Array_Size_Check (N : Node_Id; Typ : Entity_Id) is
Loc : constant Source_Ptr := Sloc (N);
Ctyp : constant Entity_Id := Component_Type (Typ);
Ent : constant Entity_Id := Defining_Identifier (N);
Decl : Node_Id;
Lo : Node_Id;
Hi : Node_Id;
Lob : Uint;
Hib : Uint;
Siz : Uint;
Xtyp : Entity_Id;
Indx : Node_Id;
Sizx : Node_Id;
Code : Node_Id;
Static : Boolean := True;
-- Set false if any index subtye bound is non-static
Umark : constant Uintp.Save_Mark := Uintp.Mark;
-- We can throw away all the Uint computations here, since they are
-- done only to generate boolean test results.
Check_Siz : Uint;
-- Size to check against
function Is_Address_Or_Import (Decl : Node_Id) return Boolean;
-- Determines if Decl is an address clause or Import/Interface pragma
-- that references the defining identifier of the current declaration.
--------------------------
-- Is_Address_Or_Import --
--------------------------
function Is_Address_Or_Import (Decl : Node_Id) return Boolean is
begin
if Nkind (Decl) = N_At_Clause then
return Chars (Identifier (Decl)) = Chars (Ent);
elsif Nkind (Decl) = N_Attribute_Definition_Clause then
return
Chars (Decl) = Name_Address
and then
Nkind (Name (Decl)) = N_Identifier
and then
Chars (Name (Decl)) = Chars (Ent);
elsif Nkind (Decl) = N_Pragma then
if (Chars (Decl) = Name_Import
or else
Chars (Decl) = Name_Interface)
and then Present (Pragma_Argument_Associations (Decl))
then
declare
F : constant Node_Id :=
First (Pragma_Argument_Associations (Decl));
begin
return
Present (F)
and then
Present (Next (F))
and then
Nkind (Expression (Next (F))) = N_Identifier
and then
Chars (Expression (Next (F))) = Chars (Ent);
end;
else
return False;
end if;
else
return False;
end if;
end Is_Address_Or_Import;
-- Start of processing for Apply_Array_Size_Check
begin
if not Expander_Active
or else Storage_Checks_Suppressed (Typ)
then
return;
end if;
-- It is pointless to insert this check inside an _init_proc, because
-- that's too late, we have already built the object to be the right
-- size, and if it's too large, too bad!
if Inside_Init_Proc then
return;
end if;
-- Look head for pragma interface/import or address clause applying
-- to this entity. If found, we suppress the check entirely. For now
-- we only look ahead 20 declarations to stop this becoming too slow
-- Note that eventually this whole routine gets moved to gigi.
Decl := N;
for Ctr in 1 .. 20 loop
Next (Decl);
exit when No (Decl);
if Is_Address_Or_Import (Decl) then
return;
end if;
end loop;
-- First step is to calculate the maximum number of elements. For this
-- calculation, we use the actual size of the subtype if it is static,
-- and if a bound of a subtype is non-static, we go to the bound of the
-- base type.
Siz := Uint_1;
Indx := First_Index (Typ);
while Present (Indx) loop
Xtyp := Etype (Indx);
Lo := Type_Low_Bound (Xtyp);
Hi := Type_High_Bound (Xtyp);
-- If any bound raises constraint error, we will never get this
-- far, so there is no need to generate any kind of check.
if Raises_Constraint_Error (Lo)
or else
Raises_Constraint_Error (Hi)
then
Uintp.Release (Umark);
return;
end if;
-- Otherwise get bounds values
if Is_Static_Expression (Lo) then
Lob := Expr_Value (Lo);
else
Lob := Expr_Value (Type_Low_Bound (Base_Type (Xtyp)));
Static := False;
end if;
if Is_Static_Expression (Hi) then
Hib := Expr_Value (Hi);
else
Hib := Expr_Value (Type_High_Bound (Base_Type (Xtyp)));
Static := False;
end if;
Siz := Siz * UI_Max (Hib - Lob + 1, Uint_0);
Next_Index (Indx);
end loop;
-- Compute the limit against which we want to check. For subprograms,
-- where the array will go on the stack, we use 8*2**24, which (in
-- bits) is the size of a 16 megabyte array.
if Is_Subprogram (Scope (Ent)) then
Check_Siz := Uint_2 ** 27;
else
Check_Siz := Uint_2 ** 31;
end if;
-- If we have all static bounds and Siz is too large, then we know we
-- know we have a storage error right now, so generate message
if Static and then Siz >= Check_Siz then
Insert_Action (N,
Make_Raise_Storage_Error (Loc));
Warn_On_Instance := True;
Error_Msg_N ("?Storage_Error will be raised at run-time", N);
Warn_On_Instance := False;
Uintp.Release (Umark);
return;
end if;
-- Case of component size known at compile time. If the array
-- size is definitely in range, then we do not need a check.
if Known_Esize (Ctyp)
and then Siz * Esize (Ctyp) < Check_Siz
then
Uintp.Release (Umark);
return;
end if;
-- Here if a dynamic check is required
-- What we do is to build an expression for the size of the array,
-- which is computed as the 'Size of the array component, times
-- the size of each dimension.
Uintp.Release (Umark);
Sizx :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Ctyp, Loc),
Attribute_Name => Name_Size);
Indx := First_Index (Typ);
for J in 1 .. Number_Dimensions (Typ) loop
if Sloc (Etype (Indx)) = Sloc (N) then
Ensure_Defined (Etype (Indx), N);
end if;
Sizx :=
Make_Op_Multiply (Loc,
Left_Opnd => Sizx,
Right_Opnd =>
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Typ, Loc),
Attribute_Name => Name_Length,
Expressions => New_List (
Make_Integer_Literal (Loc, J))));
Next_Index (Indx);
end loop;
Code :=
Make_Raise_Storage_Error (Loc,
Condition =>
Make_Op_Ge (Loc,
Left_Opnd => Sizx,
Right_Opnd =>
Make_Integer_Literal (Loc, Check_Siz)));
Set_Size_Check_Code (Defining_Identifier (N), Code);
Insert_Action (N, Code);
end Apply_Array_Size_Check;
----------------------------
-- Apply_Constraint_Check --
----------------------------
procedure Apply_Constraint_Check
(N : Node_Id;
Typ : Entity_Id;
No_Sliding : Boolean := False)
is
Desig_Typ : Entity_Id;
begin
if Inside_A_Generic then
return;
elsif Is_Scalar_Type (Typ) then
Apply_Scalar_Range_Check (N, Typ);
elsif Is_Array_Type (Typ) then
-- A useful optimization: an aggregate with only an Others clause
-- always has the right bounds.
if Nkind (N) = N_Aggregate
and then No (Expressions (N))
and then Nkind
(First (Choices (First (Component_Associations (N)))))
= N_Others_Choice
then
return;
end if;
if Is_Constrained (Typ) then
Apply_Length_Check (N, Typ);
if No_Sliding then
Apply_Range_Check (N, Typ);
end if;
else
Apply_Range_Check (N, Typ);
end if;
elsif (Is_Record_Type (Typ)
or else Is_Private_Type (Typ))
and then Has_Discriminants (Base_Type (Typ))
and then Is_Constrained (Typ)
then
Apply_Discriminant_Check (N, Typ);
elsif Is_Access_Type (Typ) then
Desig_Typ := Designated_Type (Typ);
-- No checks necessary if expression statically null
if Nkind (N) = N_Null then
null;
-- No sliding possible on access to arrays
elsif Is_Array_Type (Desig_Typ) then
if Is_Constrained (Desig_Typ) then
Apply_Length_Check (N, Typ);
end if;
Apply_Range_Check (N, Typ);
elsif Has_Discriminants (Base_Type (Desig_Typ))
and then Is_Constrained (Desig_Typ)
then
Apply_Discriminant_Check (N, Typ);
end if;
end if;
end Apply_Constraint_Check;
------------------------------
-- Apply_Discriminant_Check --
------------------------------
procedure Apply_Discriminant_Check
(N : Node_Id;
Typ : Entity_Id;
Lhs : Node_Id := Empty)
is
Loc : constant Source_Ptr := Sloc (N);
Do_Access : constant Boolean := Is_Access_Type (Typ);
S_Typ : Entity_Id := Etype (N);
Cond : Node_Id;
T_Typ : Entity_Id;
function Is_Aliased_Unconstrained_Component return Boolean;
-- It is possible for an aliased component to have a nominal
-- unconstrained subtype (through instantiation). If this is a
-- discriminated component assigned in the expansion of an aggregate
-- in an initialization, the check must be suppressed. This unusual
-- situation requires a predicate of its own (see 7503-008).
----------------------------------------
-- Is_Aliased_Unconstrained_Component --
----------------------------------------
function Is_Aliased_Unconstrained_Component return Boolean is
Comp : Entity_Id;
Pref : Node_Id;
begin
if Nkind (Lhs) /= N_Selected_Component then
return False;
else
Comp := Entity (Selector_Name (Lhs));
Pref := Prefix (Lhs);
end if;
if Ekind (Comp) /= E_Component
or else not Is_Aliased (Comp)
then
return False;
end if;
return not Comes_From_Source (Pref)
and then In_Instance
and then not Is_Constrained (Etype (Comp));
end Is_Aliased_Unconstrained_Component;
-- Start of processing for Apply_Discriminant_Check
begin
if Do_Access then
T_Typ := Designated_Type (Typ);
else
T_Typ := Typ;
end if;
-- Nothing to do if discriminant checks are suppressed or else no code
-- is to be generated
if not Expander_Active
or else Discriminant_Checks_Suppressed (T_Typ)
then
return;
end if;
-- No discriminant checks necessary for access when expression
-- is statically Null. This is not only an optimization, this is
-- fundamental because otherwise discriminant checks may be generated
-- in init procs for types containing an access to a non-frozen yet
-- record, causing a deadly forward reference.
-- Also, if the expression is of an access type whose designated
-- type is incomplete, then the access value must be null and
-- we suppress the check.
if Nkind (N) = N_Null then
return;
elsif Is_Access_Type (S_Typ) then
S_Typ := Designated_Type (S_Typ);
if Ekind (S_Typ) = E_Incomplete_Type then
return;
end if;
end if;
-- If an assignment target is present, then we need to generate
-- the actual subtype if the target is a parameter or aliased
-- object with an unconstrained nominal subtype.
if Present (Lhs)
and then (Present (Param_Entity (Lhs))
or else (not Is_Constrained (T_Typ)
and then Is_Aliased_View (Lhs)
and then not Is_Aliased_Unconstrained_Component))
then
T_Typ := Get_Actual_Subtype (Lhs);
end if;
-- Nothing to do if the type is unconstrained (this is the case
-- where the actual subtype in the RM sense of N is unconstrained
-- and no check is required).
if not Is_Constrained (T_Typ) then
return;
end if;
-- Suppress checks if the subtypes are the same.
-- the check must be preserved in an assignment to a formal, because
-- the constraint is given by the actual.
if Nkind (Original_Node (N)) /= N_Allocator
and then (No (Lhs)
or else not Is_Entity_Name (Lhs)
or else (Ekind (Entity (Lhs)) /= E_In_Out_Parameter
and then Ekind (Entity (Lhs)) /= E_Out_Parameter))
then
if (Etype (N) = Typ
or else (Do_Access and then Designated_Type (Typ) = S_Typ))
and then not Is_Aliased_View (Lhs)
then
return;
end if;
-- We can also eliminate checks on allocators with a subtype mark
-- that coincides with the context type. The context type may be a
-- subtype without a constraint (common case, a generic actual).
elsif Nkind (Original_Node (N)) = N_Allocator
and then Is_Entity_Name (Expression (Original_Node (N)))
then
declare
Alloc_Typ : Entity_Id := Entity (Expression (Original_Node (N)));
begin
if Alloc_Typ = T_Typ
or else (Nkind (Parent (T_Typ)) = N_Subtype_Declaration
and then Is_Entity_Name (
Subtype_Indication (Parent (T_Typ)))
and then Alloc_Typ = Base_Type (T_Typ))
then
return;
end if;
end;
end if;
-- See if we have a case where the types are both constrained, and
-- all the constraints are constants. In this case, we can do the
-- check successfully at compile time.
-- we skip this check for the case where the node is a rewritten`
-- allocator, because it already carries the context subtype, and
-- extracting the discriminants from the aggregate is messy.
if Is_Constrained (S_Typ)
and then Nkind (Original_Node (N)) /= N_Allocator
then
declare
DconT : Elmt_Id;
Discr : Entity_Id;
DconS : Elmt_Id;
ItemS : Node_Id;
ItemT : Node_Id;
begin
-- S_Typ may not have discriminants in the case where it is a
-- private type completed by a default discriminated type. In
-- that case, we need to get the constraints from the
-- underlying_type. If the underlying type is unconstrained (i.e.
-- has no default discriminants) no check is needed.
if Has_Discriminants (S_Typ) then
Discr := First_Discriminant (S_Typ);
DconS := First_Elmt (Discriminant_Constraint (S_Typ));
else
Discr := First_Discriminant (Underlying_Type (S_Typ));
DconS :=
First_Elmt
(Discriminant_Constraint (Underlying_Type (S_Typ)));
if No (DconS) then
return;
end if;
end if;
DconT := First_Elmt (Discriminant_Constraint (T_Typ));
while Present (Discr) loop
ItemS := Node (DconS);
ItemT := Node (DconT);
exit when
not Is_OK_Static_Expression (ItemS)
or else
not Is_OK_Static_Expression (ItemT);
if Expr_Value (ItemS) /= Expr_Value (ItemT) then
if Do_Access then -- needs run-time check.
exit;
else
Apply_Compile_Time_Constraint_Error
(N, "incorrect value for discriminant&?", Ent => Discr);
return;
end if;
end if;
Next_Elmt (DconS);
Next_Elmt (DconT);
Next_Discriminant (Discr);
end loop;
if No (Discr) then
return;
end if;
end;
end if;
-- Here we need a discriminant check. First build the expression
-- for the comparisons of the discriminants:
-- (n.disc1 /= typ.disc1) or else
-- (n.disc2 /= typ.disc2) or else
-- ...
-- (n.discn /= typ.discn)
Cond := Build_Discriminant_Checks (N, T_Typ);
-- If Lhs is set and is a parameter, then the condition is
-- guarded by: lhs'constrained and then (condition built above)
if Present (Param_Entity (Lhs)) then
Cond :=
Make_And_Then (Loc,
Left_Opnd =>
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Param_Entity (Lhs), Loc),
Attribute_Name => Name_Constrained),
Right_Opnd => Cond);
end if;
if Do_Access then
Cond := Guard_Access (Cond, Loc, N);
end if;
Insert_Action (N,
Make_Raise_Constraint_Error (Loc, Condition => Cond));
end Apply_Discriminant_Check;
------------------------
-- Apply_Divide_Check --
------------------------
procedure Apply_Divide_Check (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Typ : constant Entity_Id := Etype (N);
Left : constant Node_Id := Left_Opnd (N);
Right : constant Node_Id := Right_Opnd (N);
LLB : Uint;
Llo : Uint;
Lhi : Uint;
LOK : Boolean;
Rlo : Uint;
Rhi : Uint;
ROK : Boolean;
begin
if Expander_Active
and then Software_Overflow_Checking
then
Determine_Range (Right, ROK, Rlo, Rhi);
-- See if division by zero possible, and if so generate test. This
-- part of the test is not controlled by the -gnato switch.
if Do_Division_Check (N) then
if (not ROK) or else (Rlo <= 0 and then 0 <= Rhi) then
Insert_Action (N,
Make_Raise_Constraint_Error (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd => Duplicate_Subexpr (Right),
Right_Opnd => Make_Integer_Literal (Loc, 0))));
end if;
end if;
-- Test for extremely annoying case of xxx'First divided by -1
if Do_Overflow_Check (N) then
if Nkind (N) = N_Op_Divide
and then Is_Signed_Integer_Type (Typ)
then
Determine_Range (Left, LOK, Llo, Lhi);
LLB := Expr_Value (Type_Low_Bound (Base_Type (Typ)));
if ((not ROK) or else (Rlo <= (-1) and then (-1) <= Rhi))
and then
((not LOK) or else (Llo = LLB))
then
Insert_Action (N,
Make_Raise_Constraint_Error (Loc,
Condition =>
Make_And_Then (Loc,
Make_Op_Eq (Loc,
Left_Opnd => Duplicate_Subexpr (Left),
Right_Opnd => Make_Integer_Literal (Loc, LLB)),
Make_Op_Eq (Loc,
Left_Opnd => Duplicate_Subexpr (Right),
Right_Opnd =>
Make_Integer_Literal (Loc, -1)))));
end if;
end if;
end if;
end if;
end Apply_Divide_Check;
------------------------
-- Apply_Length_Check --
------------------------
procedure Apply_Length_Check
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id := Empty)
is
begin
Apply_Selected_Length_Checks
(Ck_Node, Target_Typ, Source_Typ, Do_Static => False);
end Apply_Length_Check;
-----------------------
-- Apply_Range_Check --
-----------------------
procedure Apply_Range_Check
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id := Empty)
is
begin
Apply_Selected_Range_Checks
(Ck_Node, Target_Typ, Source_Typ, Do_Static => False);
end Apply_Range_Check;
------------------------------
-- Apply_Scalar_Range_Check --
------------------------------
-- Note that Apply_Scalar_Range_Check never turns the Do_Range_Check
-- flag off if it is already set on.
procedure Apply_Scalar_Range_Check
(Expr : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id := Empty;
Fixed_Int : Boolean := False)
is
Parnt : constant Node_Id := Parent (Expr);
S_Typ : Entity_Id;
Arr : Node_Id := Empty; -- initialize to prevent warning
Arr_Typ : Entity_Id := Empty; -- initialize to prevent warning
OK : Boolean;
Is_Subscr_Ref : Boolean;
-- Set true if Expr is a subscript
Is_Unconstrained_Subscr_Ref : Boolean;
-- Set true if Expr is a subscript of an unconstrained array. In this
-- case we do not attempt to do an analysis of the value against the
-- range of the subscript, since we don't know the actual subtype.
Int_Real : Boolean;
-- Set to True if Expr should be regarded as a real value
-- even though the type of Expr might be discrete.
procedure Bad_Value;
-- Procedure called if value is determined to be out of range
procedure Bad_Value is
begin
Apply_Compile_Time_Constraint_Error
(Expr, "value not in range of}?",
Ent => Target_Typ,
Typ => Target_Typ);
end Bad_Value;
begin
if Inside_A_Generic then
return;
-- Return if check obviously not needed. Note that we do not check
-- for the expander being inactive, since this routine does not
-- insert any code, but it does generate useful warnings sometimes,
-- which we would like even if we are in semantics only mode.
elsif Target_Typ = Any_Type
or else not Is_Scalar_Type (Target_Typ)
or else Raises_Constraint_Error (Expr)
then
return;
end if;
-- Now, see if checks are suppressed
Is_Subscr_Ref :=
Is_List_Member (Expr) and then Nkind (Parnt) = N_Indexed_Component;
if Is_Subscr_Ref then
Arr := Prefix (Parnt);
Arr_Typ := Get_Actual_Subtype_If_Available (Arr);
end if;
if not Do_Range_Check (Expr) then
-- Subscript reference. Check for Index_Checks suppressed
if Is_Subscr_Ref then
-- Check array type and its base type
if Index_Checks_Suppressed (Arr_Typ)
or else Suppress_Index_Checks (Base_Type (Arr_Typ))
then
return;
-- Check array itself if it is an entity name
elsif Is_Entity_Name (Arr)
and then Suppress_Index_Checks (Entity (Arr))
then
return;
-- Check expression itself if it is an entity name
elsif Is_Entity_Name (Expr)
and then Suppress_Index_Checks (Entity (Expr))
then
return;
end if;
-- All other cases, check for Range_Checks suppressed
else
-- Check target type and its base type
if Range_Checks_Suppressed (Target_Typ)
or else Suppress_Range_Checks (Base_Type (Target_Typ))
then
return;
-- Check expression itself if it is an entity name
elsif Is_Entity_Name (Expr)
and then Suppress_Range_Checks (Entity (Expr))
then
return;
-- If Expr is part of an assignment statement, then check
-- left side of assignment if it is an entity name.
elsif Nkind (Parnt) = N_Assignment_Statement
and then Is_Entity_Name (Name (Parnt))
and then Suppress_Range_Checks (Entity (Name (Parnt)))
then
return;
end if;
end if;
end if;
-- Now see if we need a check
if No (Source_Typ) then
S_Typ := Etype (Expr);
else
S_Typ := Source_Typ;
end if;
if not Is_Scalar_Type (S_Typ) or else S_Typ = Any_Type then
return;
end if;
Is_Unconstrained_Subscr_Ref :=
Is_Subscr_Ref and then not Is_Constrained (Arr_Typ);
-- Always do a range check if the source type includes infinities
-- and the target type does not include infinities.
if Is_Floating_Point_Type (S_Typ)
and then Has_Infinities (S_Typ)
and then not Has_Infinities (Target_Typ)
then
Enable_Range_Check (Expr);
end if;
-- Return if we know expression is definitely in the range of
-- the target type as determined by Determine_Range. Right now
-- we only do this for discrete types, and not fixed-point or
-- floating-point types.
-- The additional less-precise tests below catch these cases.
-- Note: skip this if we are given a source_typ, since the point
-- of supplying a Source_Typ is to stop us looking at the expression.
-- could sharpen this test to be out parameters only ???
if Is_Discrete_Type (Target_Typ)
and then Is_Discrete_Type (Etype (Expr))
and then not Is_Unconstrained_Subscr_Ref
and then No (Source_Typ)
then
declare
Tlo : constant Node_Id := Type_Low_Bound (Target_Typ);
Thi : constant Node_Id := Type_High_Bound (Target_Typ);
Lo : Uint;
Hi : Uint;
begin
if Compile_Time_Known_Value (Tlo)
and then Compile_Time_Known_Value (Thi)
then
Determine_Range (Expr, OK, Lo, Hi);
if OK then
declare
Lov : constant Uint := Expr_Value (Tlo);
Hiv : constant Uint := Expr_Value (Thi);
begin
if Lo >= Lov and then Hi <= Hiv then
return;
elsif Lov > Hi or else Hiv < Lo then
Bad_Value;
return;
end if;
end;
end if;
end if;
end;
end if;
Int_Real :=
Is_Floating_Point_Type (S_Typ)
or else (Is_Fixed_Point_Type (S_Typ) and then not Fixed_Int);
-- Check if we can determine at compile time whether Expr is in the
-- range of the target type. Note that if S_Typ is within the
-- bounds of Target_Typ then this must be the case. This checks is
-- only meaningful if this is not a conversion between integer and
-- real types.
if not Is_Unconstrained_Subscr_Ref
and then
Is_Discrete_Type (S_Typ) = Is_Discrete_Type (Target_Typ)
and then
(In_Subrange_Of (S_Typ, Target_Typ, Fixed_Int)
or else
Is_In_Range (Expr, Target_Typ, Fixed_Int, Int_Real))
then
return;
elsif Is_Out_Of_Range (Expr, Target_Typ, Fixed_Int, Int_Real) then
Bad_Value;
return;
-- Do not set range checks if they are killed
elsif Nkind (Expr) = N_Unchecked_Type_Conversion
and then Kill_Range_Check (Expr)
then
return;
-- ??? We only need a runtime check if the target type is constrained
-- (the predefined type Float is not for instance).
-- so the following should really be
--
-- elsif Is_Constrained (Target_Typ) then
--
-- but it isn't because certain types do not have the Is_Constrained
-- flag properly set (see 1503-003).
else
Enable_Range_Check (Expr);
return;
end if;
end Apply_Scalar_Range_Check;
----------------------------------
-- Apply_Selected_Length_Checks --
----------------------------------
procedure Apply_Selected_Length_Checks
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id;
Do_Static : Boolean)
is
Cond : Node_Id;
R_Result : Check_Result;
R_Cno : Node_Id;
Loc : constant Source_Ptr := Sloc (Ck_Node);
Checks_On : constant Boolean :=
(not Index_Checks_Suppressed (Target_Typ))
or else
(not Length_Checks_Suppressed (Target_Typ));
begin
if not Expander_Active or else not Checks_On then
return;
end if;
R_Result :=
Selected_Length_Checks (Ck_Node, Target_Typ, Source_Typ, Empty);
for J in 1 .. 2 loop
R_Cno := R_Result (J);
exit when No (R_Cno);
-- A length check may mention an Itype which is attached to a
-- subsequent node. At the top level in a package this can cause
-- an order-of-elaboration problem, so we make sure that the itype
-- is referenced now.
if Ekind (Current_Scope) = E_Package
and then Is_Compilation_Unit (Current_Scope)
then
Ensure_Defined (Target_Typ, Ck_Node);
if Present (Source_Typ) then
Ensure_Defined (Source_Typ, Ck_Node);
elsif Is_Itype (Etype (Ck_Node)) then
Ensure_Defined (Etype (Ck_Node), Ck_Node);
end if;
end if;
-- If the item is a conditional raise of constraint error,
-- then have a look at what check is being performed and
-- ???
if Nkind (R_Cno) = N_Raise_Constraint_Error
and then Present (Condition (R_Cno))
then
Cond := Condition (R_Cno);
if not Has_Dynamic_Length_Check (Ck_Node) then
Insert_Action (Ck_Node, R_Cno);
if not Do_Static then
Set_Has_Dynamic_Length_Check (Ck_Node);
end if;
end if;
-- Output a warning if the condition is known to be True
if Is_Entity_Name (Cond)
and then Entity (Cond) = Standard_True
then
Apply_Compile_Time_Constraint_Error
(Ck_Node, "wrong length for array of}?",
Ent => Target_Typ,
Typ => Target_Typ);
-- If we were only doing a static check, or if checks are not
-- on, then we want to delete the check, since it is not needed.
-- We do this by replacing the if statement by a null statement
elsif Do_Static or else not Checks_On then
Rewrite (R_Cno, Make_Null_Statement (Loc));
end if;
else
Install_Static_Check (R_Cno, Loc);
end if;
end loop;
end Apply_Selected_Length_Checks;
---------------------------------
-- Apply_Selected_Range_Checks --
---------------------------------
procedure Apply_Selected_Range_Checks
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id;
Do_Static : Boolean)
is
Cond : Node_Id;
R_Result : Check_Result;
R_Cno : Node_Id;
Loc : constant Source_Ptr := Sloc (Ck_Node);
Checks_On : constant Boolean :=
(not Index_Checks_Suppressed (Target_Typ))
or else
(not Range_Checks_Suppressed (Target_Typ));
begin
if not Expander_Active or else not Checks_On then
return;
end if;
R_Result :=
Selected_Range_Checks (Ck_Node, Target_Typ, Source_Typ, Empty);
for J in 1 .. 2 loop
R_Cno := R_Result (J);
exit when No (R_Cno);
-- If the item is a conditional raise of constraint error,
-- then have a look at what check is being performed and
-- ???
if Nkind (R_Cno) = N_Raise_Constraint_Error
and then Present (Condition (R_Cno))
then
Cond := Condition (R_Cno);
if not Has_Dynamic_Range_Check (Ck_Node) then
Insert_Action (Ck_Node, R_Cno);
if not Do_Static then
Set_Has_Dynamic_Range_Check (Ck_Node);
end if;
end if;
-- Output a warning if the condition is known to be True
if Is_Entity_Name (Cond)
and then Entity (Cond) = Standard_True
then
-- Since an N_Range is technically not an expression, we
-- have to set one of the bounds to C_E and then just flag
-- the N_Range. The warning message will point to the
-- lower bound and complain about a range, which seems OK.
if Nkind (Ck_Node) = N_Range then
Apply_Compile_Time_Constraint_Error
(Low_Bound (Ck_Node), "static range out of bounds of}?",
Ent => Target_Typ,
Typ => Target_Typ);
Set_Raises_Constraint_Error (Ck_Node);
else
Apply_Compile_Time_Constraint_Error
(Ck_Node, "static value out of range of}?",
Ent => Target_Typ,
Typ => Target_Typ);
end if;
-- If we were only doing a static check, or if checks are not
-- on, then we want to delete the check, since it is not needed.
-- We do this by replacing the if statement by a null statement
elsif Do_Static or else not Checks_On then
Rewrite (R_Cno, Make_Null_Statement (Loc));
end if;
else
Install_Static_Check (R_Cno, Loc);
end if;
end loop;
end Apply_Selected_Range_Checks;
-------------------------------
-- Apply_Static_Length_Check --
-------------------------------
procedure Apply_Static_Length_Check
(Expr : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id := Empty)
is
begin
Apply_Selected_Length_Checks
(Expr, Target_Typ, Source_Typ, Do_Static => True);
end Apply_Static_Length_Check;
-------------------------------------
-- Apply_Subscript_Validity_Checks --
-------------------------------------
procedure Apply_Subscript_Validity_Checks (Expr : Node_Id) is
Sub : Node_Id;
begin
pragma Assert (Nkind (Expr) = N_Indexed_Component);
-- Loop through subscripts
Sub := First (Expressions (Expr));
while Present (Sub) loop
-- Check one subscript. Note that we do not worry about
-- enumeration type with holes, since we will convert the
-- value to a Pos value for the subscript, and that convert
-- will do the necessary validity check.
Ensure_Valid (Sub, Holes_OK => True);
-- Move to next subscript
Sub := Next (Sub);
end loop;
end Apply_Subscript_Validity_Checks;
----------------------------------
-- Apply_Type_Conversion_Checks --
----------------------------------
procedure Apply_Type_Conversion_Checks (N : Node_Id) is
Target_Type : constant Entity_Id := Etype (N);
Target_Base : constant Entity_Id := Base_Type (Target_Type);
Expr : constant Node_Id := Expression (N);
Expr_Type : constant Entity_Id := Etype (Expr);
begin
if Inside_A_Generic then
return;
-- Skip these checks if errors detected, there are some nasty
-- situations of incomplete trees that blow things up.
elsif Errors_Detected > 0 then
return;
-- Scalar type conversions of the form Target_Type (Expr) require
-- two checks:
--
-- - First there is an overflow check to insure that Expr is
-- in the base type of Target_Typ (4.6 (28)),
--
-- - After we know Expr fits into the base type, we must perform a
-- range check to ensure that Expr meets the constraints of the
-- Target_Type.
elsif Is_Scalar_Type (Target_Type) then
declare
Conv_OK : constant Boolean := Conversion_OK (N);
-- If the Conversion_OK flag on the type conversion is set
-- and no floating point type is involved in the type conversion
-- then fixed point values must be read as integral values.
begin
-- Overflow check.
if not Overflow_Checks_Suppressed (Target_Base)
and then not In_Subrange_Of (Expr_Type, Target_Base, Conv_OK)
then
Set_Do_Overflow_Check (N);
end if;
if not Range_Checks_Suppressed (Target_Type)
and then not Range_Checks_Suppressed (Expr_Type)
then
Apply_Scalar_Range_Check
(Expr, Target_Type, Fixed_Int => Conv_OK);
end if;
end;
elsif Comes_From_Source (N)
and then Is_Record_Type (Target_Type)
and then Is_Derived_Type (Target_Type)
and then not Is_Tagged_Type (Target_Type)
and then not Is_Constrained (Target_Type)
and then Present (Girder_Constraint (Target_Type))
then
-- A unconstrained derived type may have inherited discriminants.
-- Build an actual discriminant constraint list using the girder
-- constraint, to verify that the expression of the parent type
-- satisfies the constraints imposed by the (unconstrained!)
-- derived type. This applies to value conversions, not to view
-- conversions of tagged types.
declare
Loc : constant Source_Ptr := Sloc (N);
Cond : Node_Id;
Constraint : Elmt_Id;
Discr_Value : Node_Id;
Discr : Entity_Id;
New_Constraints : Elist_Id := New_Elmt_List;
Old_Constraints : Elist_Id := Discriminant_Constraint (Expr_Type);
begin
Constraint := First_Elmt (Girder_Constraint (Target_Type));
while Present (Constraint) loop
Discr_Value := Node (Constraint);
if Is_Entity_Name (Discr_Value)
and then Ekind (Entity (Discr_Value)) = E_Discriminant
then
Discr := Corresponding_Discriminant (Entity (Discr_Value));
if Present (Discr)
and then Scope (Discr) = Base_Type (Expr_Type)
then
-- Parent is constrained by new discriminant. Obtain
-- Value of original discriminant in expression. If
-- the new discriminant has been used to constrain more
-- than one of the girder ones, this will provide the
-- required consistency check.
Append_Elmt (
Make_Selected_Component (Loc,
Prefix =>
Duplicate_Subexpr (Expr, Name_Req => True),
Selector_Name =>
Make_Identifier (Loc, Chars (Discr))),
New_Constraints);
else
-- Discriminant of more remote ancestor ???
return;
end if;
-- Derived type definition has an explicit value for
-- this girder discriminant.
else
Append_Elmt
(Duplicate_Subexpr (Discr_Value), New_Constraints);
end if;
Next_Elmt (Constraint);
end loop;
-- Use the unconstrained expression type to retrieve the
-- discriminants of the parent, and apply momentarily the
-- discriminant constraint synthesized above.
Set_Discriminant_Constraint (Expr_Type, New_Constraints);
Cond := Build_Discriminant_Checks (Expr, Expr_Type);
Set_Discriminant_Constraint (Expr_Type, Old_Constraints);
Insert_Action (N,
Make_Raise_Constraint_Error (Loc, Condition => Cond));
end;
-- should there be other checks here for array types ???
else
null;
end if;
end Apply_Type_Conversion_Checks;
----------------------------------------------
-- Apply_Universal_Integer_Attribute_Checks --
----------------------------------------------
procedure Apply_Universal_Integer_Attribute_Checks (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Typ : constant Entity_Id := Etype (N);
begin
if Inside_A_Generic then
return;
-- Nothing to do if checks are suppressed
elsif Range_Checks_Suppressed (Typ)
and then Overflow_Checks_Suppressed (Typ)
then
return;
-- Nothing to do if the attribute does not come from source. The
-- internal attributes we generate of this type do not need checks,
-- and furthermore the attempt to check them causes some circular
-- elaboration orders when dealing with packed types.
elsif not Comes_From_Source (N) then
return;
-- Otherwise, replace the attribute node with a type conversion
-- node whose expression is the attribute, retyped to universal
-- integer, and whose subtype mark is the target type. The call
-- to analyze this conversion will set range and overflow checks
-- as required for proper detection of an out of range value.
else
Set_Etype (N, Universal_Integer);
Set_Analyzed (N, True);
Rewrite (N,
Make_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (Typ, Loc),
Expression => Relocate_Node (N)));
Analyze_And_Resolve (N, Typ);
return;
end if;
end Apply_Universal_Integer_Attribute_Checks;
-------------------------------
-- Build_Discriminant_Checks --
-------------------------------
function Build_Discriminant_Checks
(N : Node_Id;
T_Typ : Entity_Id)
return Node_Id
is
Loc : constant Source_Ptr := Sloc (N);
Cond : Node_Id;
Disc : Elmt_Id;
Disc_Ent : Entity_Id;
Dval : Node_Id;
begin
Cond := Empty;
Disc := First_Elmt (Discriminant_Constraint (T_Typ));
-- For a fully private type, use the discriminants of the parent
-- type.
if Is_Private_Type (T_Typ)
and then No (Full_View (T_Typ))
then
Disc_Ent := First_Discriminant (Etype (Base_Type (T_Typ)));
else
Disc_Ent := First_Discriminant (T_Typ);
end if;
while Present (Disc) loop
Dval := Node (Disc);
if Nkind (Dval) = N_Identifier
and then Ekind (Entity (Dval)) = E_Discriminant
then
Dval := New_Occurrence_Of (Discriminal (Entity (Dval)), Loc);
else
Dval := Duplicate_Subexpr (Dval);
end if;
Evolve_Or_Else (Cond,
Make_Op_Ne (Loc,
Left_Opnd =>
Make_Selected_Component (Loc,
Prefix =>
Duplicate_Subexpr (N, Name_Req => True),
Selector_Name =>
Make_Identifier (Loc, Chars (Disc_Ent))),
Right_Opnd => Dval));
Next_Elmt (Disc);
Next_Discriminant (Disc_Ent);
end loop;
return Cond;
end Build_Discriminant_Checks;
-----------------------------------
-- Check_Valid_Lvalue_Subscripts --
-----------------------------------
procedure Check_Valid_Lvalue_Subscripts (Expr : Node_Id) is
begin
-- Skip this if range checks are suppressed
if Range_Checks_Suppressed (Etype (Expr)) then
return;
-- Only do this check for expressions that come from source. We
-- assume that expander generated assignments explicitly include
-- any necessary checks. Note that this is not just an optimization,
-- it avoids infinite recursions!
elsif not Comes_From_Source (Expr) then
return;
-- For a selected component, check the prefix
elsif Nkind (Expr) = N_Selected_Component then
Check_Valid_Lvalue_Subscripts (Prefix (Expr));
return;
-- Case of indexed component
elsif Nkind (Expr) = N_Indexed_Component then
Apply_Subscript_Validity_Checks (Expr);
-- Prefix may itself be or contain an indexed component, and
-- these subscripts need checking as well
Check_Valid_Lvalue_Subscripts (Prefix (Expr));
end if;
end Check_Valid_Lvalue_Subscripts;
---------------------
-- Determine_Range --
---------------------
Cache_Size : constant := 2 ** 10;
type Cache_Index is range 0 .. Cache_Size - 1;
-- Determine size of below cache (power of 2 is more efficient!)
Determine_Range_Cache_N : array (Cache_Index) of Node_Id;
Determine_Range_Cache_Lo : array (Cache_Index) of Uint;
Determine_Range_Cache_Hi : array (Cache_Index) of Uint;
-- The above arrays are used to implement a small direct cache
-- for Determine_Range calls. Because of the way Determine_Range
-- recursively traces subexpressions, and because overflow checking
-- calls the routine on the way up the tree, a quadratic behavior
-- can otherwise be encountered in large expressions. The cache
-- entry for node N is stored in the (N mod Cache_Size) entry, and
-- can be validated by checking the actual node value stored there.
procedure Determine_Range
(N : Node_Id;
OK : out Boolean;
Lo : out Uint;
Hi : out Uint)
is
Typ : constant Entity_Id := Etype (N);
Lo_Left : Uint;
Hi_Left : Uint;
-- Lo and Hi bounds of left operand
Lo_Right : Uint;
Hi_Right : Uint;
-- Lo and Hi bounds of right (or only) operand
Bound : Node_Id;
-- Temp variable used to hold a bound node
Hbound : Uint;
-- High bound of base type of expression
Lor : Uint;
Hir : Uint;
-- Refined values for low and high bounds, after tightening
OK1 : Boolean;
-- Used in lower level calls to indicate if call succeeded
Cindex : Cache_Index;
-- Used to search cache
function OK_Operands return Boolean;
-- Used for binary operators. Determines the ranges of the left and
-- right operands, and if they are both OK, returns True, and puts
-- the results in Lo_Right, Hi_Right, Lo_Left, Hi_Left
-----------------
-- OK_Operands --
-----------------
function OK_Operands return Boolean is
begin
Determine_Range (Left_Opnd (N), OK1, Lo_Left, Hi_Left);
if not OK1 then
return False;
end if;
Determine_Range (Right_Opnd (N), OK1, Lo_Right, Hi_Right);
return OK1;
end OK_Operands;
-- Start of processing for Determine_Range
begin
-- Prevent junk warnings by initializing range variables
Lo := No_Uint;
Hi := No_Uint;
Lor := No_Uint;
Hir := No_Uint;
-- If the type is not discrete, or is undefined, then we can't
-- do anything about determining the range.
if No (Typ) or else not Is_Discrete_Type (Typ)
or else Error_Posted (N)
then
OK := False;
return;
end if;
-- For all other cases, we can determine the range
OK := True;
-- If value is compile time known, then the possible range is the
-- one value that we know this expression definitely has!
if Compile_Time_Known_Value (N) then
Lo := Expr_Value (N);
Hi := Lo;
return;
end if;
-- Return if already in the cache
Cindex := Cache_Index (N mod Cache_Size);
if Determine_Range_Cache_N (Cindex) = N then
Lo := Determine_Range_Cache_Lo (Cindex);
Hi := Determine_Range_Cache_Hi (Cindex);
return;
end if;
-- Otherwise, start by finding the bounds of the type of the
-- expression, the value cannot be outside this range (if it
-- is, then we have an overflow situation, which is a separate
-- check, we are talking here only about the expression value).
-- We use the actual bound unless it is dynamic, in which case
-- use the corresponding base type bound if possible. If we can't
-- get a bound then we figure we can't determine the range (a
-- peculiar case, that perhaps cannot happen, but there is no
-- point in bombing in this optimization circuit.
-- First the low bound
Bound := Type_Low_Bound (Typ);
if Compile_Time_Known_Value (Bound) then
Lo := Expr_Value (Bound);
elsif Compile_Time_Known_Value (Type_Low_Bound (Base_Type (Typ))) then
Lo := Expr_Value (Type_Low_Bound (Base_Type (Typ)));
else
OK := False;
return;
end if;
-- Now the high bound
Bound := Type_High_Bound (Typ);
-- We need the high bound of the base type later on, and this should
-- always be compile time known. Again, it is not clear that this
-- can ever be false, but no point in bombing.
if Compile_Time_Known_Value (Type_High_Bound (Base_Type (Typ))) then
Hbound := Expr_Value (Type_High_Bound (Base_Type (Typ)));
Hi := Hbound;
else
OK := False;
return;
end if;
-- If we have a static subtype, then that may have a tighter bound
-- so use the upper bound of the subtype instead in this case.
if Compile_Time_Known_Value (Bound) then
Hi := Expr_Value (Bound);
end if;
-- We may be able to refine this value in certain situations. If
-- refinement is possible, then Lor and Hir are set to possibly
-- tighter bounds, and OK1 is set to True.
case Nkind (N) is
-- For unary plus, result is limited by range of operand
when N_Op_Plus =>
Determine_Range (Right_Opnd (N), OK1, Lor, Hir);
-- For unary minus, determine range of operand, and negate it
when N_Op_Minus =>
Determine_Range (Right_Opnd (N), OK1, Lo_Right, Hi_Right);
if OK1 then
Lor := -Hi_Right;
Hir := -Lo_Right;
end if;
-- For binary addition, get range of each operand and do the
-- addition to get the result range.
when N_Op_Add =>
if OK_Operands then
Lor := Lo_Left + Lo_Right;
Hir := Hi_Left + Hi_Right;
end if;
-- Division is tricky. The only case we consider is where the
-- right operand is a positive constant, and in this case we
-- simply divide the bounds of the left operand
when N_Op_Divide =>
if OK_Operands then
if Lo_Right = Hi_Right
and then Lo_Right > 0
then
Lor := Lo_Left / Lo_Right;
Hir := Hi_Left / Lo_Right;
else
OK1 := False;
end if;
end if;
-- For binary subtraction, get range of each operand and do
-- the worst case subtraction to get the result range.
when N_Op_Subtract =>
if OK_Operands then
Lor := Lo_Left - Hi_Right;
Hir := Hi_Left - Lo_Right;
end if;
-- For MOD, if right operand is a positive constant, then
-- result must be in the allowable range of mod results.
when N_Op_Mod =>
if OK_Operands then
if Lo_Right = Hi_Right then
if Lo_Right > 0 then
Lor := Uint_0;
Hir := Lo_Right - 1;
elsif Lo_Right < 0 then
Lor := Lo_Right + 1;
Hir := Uint_0;
end if;
else
OK1 := False;
end if;
end if;
-- For REM, if right operand is a positive constant, then
-- result must be in the allowable range of mod results.
when N_Op_Rem =>
if OK_Operands then
if Lo_Right = Hi_Right then
declare
Dval : constant Uint := (abs Lo_Right) - 1;
begin
-- The sign of the result depends on the sign of the
-- dividend (but not on the sign of the divisor, hence
-- the abs operation above).
if Lo_Left < 0 then
Lor := -Dval;
else
Lor := Uint_0;
end if;
if Hi_Left < 0 then
Hir := Uint_0;
else
Hir := Dval;
end if;
end;
else
OK1 := False;
end if;
end if;
-- Attribute reference cases
when N_Attribute_Reference =>
case Attribute_Name (N) is
-- For Pos/Val attributes, we can refine the range using the
-- possible range of values of the attribute expression
when Name_Pos | Name_Val =>
Determine_Range (First (Expressions (N)), OK1, Lor, Hir);
-- For Length attribute, use the bounds of the corresponding
-- index type to refine the range.
when Name_Length =>
declare
Atyp : Entity_Id := Etype (Prefix (N));
Inum : Nat;
Indx : Node_Id;
LL, LU : Uint;
UL, UU : Uint;
begin
if Is_Access_Type (Atyp) then
Atyp := Designated_Type (Atyp);
end if;
-- For string literal, we know exact value
if Ekind (Atyp) = E_String_Literal_Subtype then
OK := True;
Lo := String_Literal_Length (Atyp);
Hi := String_Literal_Length (Atyp);
return;
end if;
-- Otherwise check for expression given
if No (Expressions (N)) then
Inum := 1;
else
Inum :=
UI_To_Int (Expr_Value (First (Expressions (N))));
end if;
Indx := First_Index (Atyp);
for J in 2 .. Inum loop
Indx := Next_Index (Indx);
end loop;
Determine_Range
(Type_Low_Bound (Etype (Indx)), OK1, LL, LU);
if OK1 then
Determine_Range
(Type_High_Bound (Etype (Indx)), OK1, UL, UU);
if OK1 then
-- The maximum value for Length is the biggest
-- possible gap between the values of the bounds.
-- But of course, this value cannot be negative.
Hir := UI_Max (Uint_0, UU - LL);
-- For constrained arrays, the minimum value for
-- Length is taken from the actual value of the
-- bounds, since the index will be exactly of
-- this subtype.
if Is_Constrained (Atyp) then
Lor := UI_Max (Uint_0, UL - LU);
-- For an unconstrained array, the minimum value
-- for length is always zero.
else
Lor := Uint_0;
end if;
end if;
end if;
end;
-- No special handling for other attributes
-- Probably more opportunities exist here ???
when others =>
OK1 := False;
end case;
-- For type conversion from one discrete type to another, we
-- can refine the range using the converted value.
when N_Type_Conversion =>
Determine_Range (Expression (N), OK1, Lor, Hir);
-- Nothing special to do for all other expression kinds
when others =>
OK1 := False;
Lor := No_Uint;
Hir := No_Uint;
end case;
-- At this stage, if OK1 is true, then we know that the actual
-- result of the computed expression is in the range Lor .. Hir.
-- We can use this to restrict the possible range of results.
if OK1 then
-- If the refined value of the low bound is greater than the
-- type high bound, then reset it to the more restrictive
-- value. However, we do NOT do this for the case of a modular
-- type where the possible upper bound on the value is above the
-- base type high bound, because that means the result could wrap.
if Lor > Lo
and then not (Is_Modular_Integer_Type (Typ)
and then Hir > Hbound)
then
Lo := Lor;
end if;
-- Similarly, if the refined value of the high bound is less
-- than the value so far, then reset it to the more restrictive
-- value. Again, we do not do this if the refined low bound is
-- negative for a modular type, since this would wrap.
if Hir < Hi
and then not (Is_Modular_Integer_Type (Typ)
and then Lor < Uint_0)
then
Hi := Hir;
end if;
end if;
-- Set cache entry for future call and we are all done
Determine_Range_Cache_N (Cindex) := N;
Determine_Range_Cache_Lo (Cindex) := Lo;
Determine_Range_Cache_Hi (Cindex) := Hi;
return;
-- If any exception occurs, it means that we have some bug in the compiler
-- possibly triggered by a previous error, or by some unforseen peculiar
-- occurrence. However, this is only an optimization attempt, so there is
-- really no point in crashing the compiler. Instead we just decide, too
-- bad, we can't figure out a range in this case after all.
exception
when others =>
-- Debug flag K disables this behavior (useful for debugging)
if Debug_Flag_K then
raise;
else
OK := False;
Lo := No_Uint;
Hi := No_Uint;
return;
end if;
end Determine_Range;
------------------------------------
-- Discriminant_Checks_Suppressed --
------------------------------------
function Discriminant_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Discriminant_Checks
or else (Present (E) and then Suppress_Discriminant_Checks (E));
end Discriminant_Checks_Suppressed;
--------------------------------
-- Division_Checks_Suppressed --
--------------------------------
function Division_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Division_Checks
or else (Present (E) and then Suppress_Division_Checks (E));
end Division_Checks_Suppressed;
-----------------------------------
-- Elaboration_Checks_Suppressed --
-----------------------------------
function Elaboration_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Elaboration_Checks
or else (Present (E) and then Suppress_Elaboration_Checks (E));
end Elaboration_Checks_Suppressed;
------------------------
-- Enable_Range_Check --
------------------------
procedure Enable_Range_Check (N : Node_Id) is
begin
if Nkind (N) = N_Unchecked_Type_Conversion
and then Kill_Range_Check (N)
then
return;
else
Set_Do_Range_Check (N, True);
end if;
end Enable_Range_Check;
------------------
-- Ensure_Valid --
------------------
procedure Ensure_Valid (Expr : Node_Id; Holes_OK : Boolean := False) is
Typ : constant Entity_Id := Etype (Expr);
begin
-- Ignore call if we are not doing any validity checking
if not Validity_Checks_On then
return;
-- No check required if expression is from the expander, we assume
-- the expander will generate whatever checks are needed. Note that
-- this is not just an optimization, it avoids infinite recursions!
-- Unchecked conversions must be checked, unless they are initialized
-- scalar values, as in a component assignment in an init_proc.
elsif not Comes_From_Source (Expr)
and then (Nkind (Expr) /= N_Unchecked_Type_Conversion
or else Kill_Range_Check (Expr))
then
return;
-- No check required if expression is known to have valid value
elsif Expr_Known_Valid (Expr) then
return;
-- No check required if checks off
elsif Range_Checks_Suppressed (Typ) then
return;
-- Ignore case of enumeration with holes where the flag is set not
-- to worry about holes, since no special validity check is needed
elsif Is_Enumeration_Type (Typ)
and then Has_Non_Standard_Rep (Typ)
and then Holes_OK
then
return;
-- No check required on the left-hand side of an assignment.
elsif Nkind (Parent (Expr)) = N_Assignment_Statement
and then Expr = Name (Parent (Expr))
then
return;
-- An annoying special case. If this is an out parameter of a scalar
-- type, then the value is not going to be accessed, therefore it is
-- inappropriate to do any validity check at the call site.
else
-- Only need to worry about scalar types
if Is_Scalar_Type (Typ) then
declare
P : Node_Id;
N : Node_Id;
E : Entity_Id;
F : Entity_Id;
A : Node_Id;
L : List_Id;
begin
-- Find actual argument (which may be a parameter association)
-- and the parent of the actual argument (the call statement)
N := Expr;
P := Parent (Expr);
if Nkind (P) = N_Parameter_Association then
N := P;
P := Parent (N);
end if;
-- Only need to worry if we are argument of a procedure
-- call since functions don't have out parameters.
if Nkind (P) = N_Procedure_Call_Statement then
L := Parameter_Associations (P);
E := Entity (Name (P));
-- Only need to worry if there are indeed actuals, and
-- if this could be a procedure call, otherwise we cannot
-- get a match (either we are not an argument, or the
-- mode of the formal is not OUT). This test also filters
-- out the generic case.
if Is_Non_Empty_List (L)
and then Is_Subprogram (E)
then
-- This is the loop through parameters, looking to
-- see if there is an OUT parameter for which we are
-- the argument.
F := First_Formal (E);
A := First (L);
while Present (F) loop
if Ekind (F) = E_Out_Parameter and then A = N then
return;
end if;
Next_Formal (F);
Next (A);
end loop;
end if;
end if;
end;
end if;
end if;
-- If we fall through, a validity check is required. Note that it would
-- not be good to set Do_Range_Check, even in contexts where this is
-- permissible, since this flag causes checking against the target type,
-- not the source type in contexts such as assignments
Insert_Valid_Check (Expr);
end Ensure_Valid;
----------------------
-- Expr_Known_Valid --
----------------------
function Expr_Known_Valid (Expr : Node_Id) return Boolean is
Typ : constant Entity_Id := Etype (Expr);
begin
-- Non-scalar types are always consdered valid, since they never
-- give rise to the issues of erroneous or bounded error behavior
-- that are the concern. In formal reference manual terms the
-- notion of validity only applies to scalar types.
if not Is_Scalar_Type (Typ) then
return True;
-- If no validity checking, then everything is considered valid
elsif not Validity_Checks_On then
return True;
-- Floating-point types are considered valid unless floating-point
-- validity checks have been specifically turned on.
elsif Is_Floating_Point_Type (Typ)
and then not Validity_Check_Floating_Point
then
return True;
-- If the expression is the value of an object that is known to
-- be valid, then clearly the expression value itself is valid.
elsif Is_Entity_Name (Expr)
and then Is_Known_Valid (Entity (Expr))
then
return True;
-- If the type is one for which all values are known valid, then
-- we are sure that the value is valid except in the slightly odd
-- case where the expression is a reference to a variable whose size
-- has been explicitly set to a value greater than the object size.
elsif Is_Known_Valid (Typ) then
if Is_Entity_Name (Expr)
and then Ekind (Entity (Expr)) = E_Variable
and then Esize (Entity (Expr)) > Esize (Typ)
then
return False;
else
return True;
end if;
-- Integer and character literals always have valid values, where
-- appropriate these will be range checked in any case.
elsif Nkind (Expr) = N_Integer_Literal
or else
Nkind (Expr) = N_Character_Literal
then
return True;
-- If we have a type conversion or a qualification of a known valid
-- value, then the result will always be valid.
elsif Nkind (Expr) = N_Type_Conversion
or else
Nkind (Expr) = N_Qualified_Expression
then
return Expr_Known_Valid (Expression (Expr));
-- The result of any function call or operator is always considered
-- valid, since we assume the necessary checks are done by the call.
elsif Nkind (Expr) in N_Binary_Op
or else
Nkind (Expr) in N_Unary_Op
or else
Nkind (Expr) = N_Function_Call
then
return True;
-- For all other cases, we do not know the expression is valid
else
return False;
end if;
end Expr_Known_Valid;
---------------------
-- Get_Discriminal --
---------------------
function Get_Discriminal (E : Entity_Id; Bound : Node_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (E);
D : Entity_Id;
Sc : Entity_Id;
begin
-- The entity E is the type of a private component of the protected
-- type, or the type of a renaming of that component within a protected
-- operation of that type.
Sc := Scope (E);
if Ekind (Sc) /= E_Protected_Type then
Sc := Scope (Sc);
if Ekind (Sc) /= E_Protected_Type then
return Bound;
end if;
end if;
D := First_Discriminant (Sc);
while Present (D)
and then Chars (D) /= Chars (Bound)
loop
Next_Discriminant (D);
end loop;
return New_Occurrence_Of (Discriminal (D), Loc);
end Get_Discriminal;
------------------
-- Guard_Access --
------------------
function Guard_Access
(Cond : Node_Id;
Loc : Source_Ptr;
Ck_Node : Node_Id)
return Node_Id
is
begin
if Nkind (Cond) = N_Or_Else then
Set_Paren_Count (Cond, 1);
end if;
if Nkind (Ck_Node) = N_Allocator then
return Cond;
else
return
Make_And_Then (Loc,
Left_Opnd =>
Make_Op_Ne (Loc,
Left_Opnd => Duplicate_Subexpr (Ck_Node),
Right_Opnd => Make_Null (Loc)),
Right_Opnd => Cond);
end if;
end Guard_Access;
-----------------------------
-- Index_Checks_Suppressed --
-----------------------------
function Index_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Index_Checks
or else (Present (E) and then Suppress_Index_Checks (E));
end Index_Checks_Suppressed;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
for J in Determine_Range_Cache_N'Range loop
Determine_Range_Cache_N (J) := Empty;
end loop;
end Initialize;
-------------------------
-- Insert_Range_Checks --
-------------------------
procedure Insert_Range_Checks
(Checks : Check_Result;
Node : Node_Id;
Suppress_Typ : Entity_Id;
Static_Sloc : Source_Ptr := No_Location;
Flag_Node : Node_Id := Empty;
Do_Before : Boolean := False)
is
Internal_Flag_Node : Node_Id := Flag_Node;
Internal_Static_Sloc : Source_Ptr := Static_Sloc;
Check_Node : Node_Id;
Checks_On : constant Boolean :=
(not Index_Checks_Suppressed (Suppress_Typ))
or else
(not Range_Checks_Suppressed (Suppress_Typ));
begin
-- For now we just return if Checks_On is false, however this should
-- be enhanced to check for an always True value in the condition
-- and to generate a compilation warning???
if not Expander_Active or else not Checks_On then
return;
end if;
if Static_Sloc = No_Location then
Internal_Static_Sloc := Sloc (Node);
end if;
if No (Flag_Node) then
Internal_Flag_Node := Node;
end if;
for J in 1 .. 2 loop
exit when No (Checks (J));
if Nkind (Checks (J)) = N_Raise_Constraint_Error
and then Present (Condition (Checks (J)))
then
if not Has_Dynamic_Range_Check (Internal_Flag_Node) then
Check_Node := Checks (J);
Mark_Rewrite_Insertion (Check_Node);
if Do_Before then
Insert_Before_And_Analyze (Node, Check_Node);
else
Insert_After_And_Analyze (Node, Check_Node);
end if;
Set_Has_Dynamic_Range_Check (Internal_Flag_Node);
end if;
else
Check_Node :=
Make_Raise_Constraint_Error (Internal_Static_Sloc);
Mark_Rewrite_Insertion (Check_Node);
if Do_Before then
Insert_Before_And_Analyze (Node, Check_Node);
else
Insert_After_And_Analyze (Node, Check_Node);
end if;
end if;
end loop;
end Insert_Range_Checks;
------------------------
-- Insert_Valid_Check --
------------------------
procedure Insert_Valid_Check (Expr : Node_Id) is
Loc : constant Source_Ptr := Sloc (Expr);
Exp : Node_Id;
begin
-- Do not insert if checks off, or if not checking validity
if Range_Checks_Suppressed (Etype (Expr))
or else (not Validity_Checks_On)
then
return;
end if;
-- If we have a checked conversion, then validity check applies to
-- the expression inside the conversion, not the result, since if
-- the expression inside is valid, then so is the conversion result.
Exp := Expr;
while Nkind (Exp) = N_Type_Conversion loop
Exp := Expression (Exp);
end loop;
-- insert the validity check. Note that we do this with validity
-- checks turned off, to avoid recursion, we do not want validity
-- checks on the validity checking code itself!
Validity_Checks_On := False;
Insert_Action
(Expr,
Make_Raise_Constraint_Error (Loc,
Condition =>
Make_Op_Not (Loc,
Right_Opnd =>
Make_Attribute_Reference (Loc,
Prefix =>
Duplicate_Subexpr (Exp, Name_Req => True),
Attribute_Name => Name_Valid))),
Suppress => All_Checks);
Validity_Checks_On := True;
end Insert_Valid_Check;
--------------------------
-- Install_Static_Check --
--------------------------
procedure Install_Static_Check (R_Cno : Node_Id; Loc : Source_Ptr) is
Stat : constant Boolean := Is_Static_Expression (R_Cno);
Typ : constant Entity_Id := Etype (R_Cno);
begin
Rewrite (R_Cno, Make_Raise_Constraint_Error (Loc));
Set_Analyzed (R_Cno);
Set_Etype (R_Cno, Typ);
Set_Raises_Constraint_Error (R_Cno);
Set_Is_Static_Expression (R_Cno, Stat);
end Install_Static_Check;
------------------------------
-- Length_Checks_Suppressed --
------------------------------
function Length_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Length_Checks
or else (Present (E) and then Suppress_Length_Checks (E));
end Length_Checks_Suppressed;
--------------------------------
-- Overflow_Checks_Suppressed --
--------------------------------
function Overflow_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Overflow_Checks
or else (Present (E) and then Suppress_Overflow_Checks (E));
end Overflow_Checks_Suppressed;
-----------------
-- Range_Check --
-----------------
function Range_Check
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id := Empty;
Warn_Node : Node_Id := Empty)
return Check_Result
is
begin
return Selected_Range_Checks
(Ck_Node, Target_Typ, Source_Typ, Warn_Node);
end Range_Check;
-----------------------------
-- Range_Checks_Suppressed --
-----------------------------
function Range_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
-- Note: for now we always suppress range checks on Vax float types,
-- since Gigi does not know how to generate these checks.
return Scope_Suppress.Range_Checks
or else (Present (E) and then Suppress_Range_Checks (E))
or else Vax_Float (E);
end Range_Checks_Suppressed;
----------------------------
-- Selected_Length_Checks --
----------------------------
function Selected_Length_Checks
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id;
Warn_Node : Node_Id)
return Check_Result
is
Loc : constant Source_Ptr := Sloc (Ck_Node);
S_Typ : Entity_Id;
T_Typ : Entity_Id;
Expr_Actual : Node_Id;
Exptyp : Entity_Id;
Cond : Node_Id := Empty;
Do_Access : Boolean := False;
Wnode : Node_Id := Warn_Node;
Ret_Result : Check_Result := (Empty, Empty);
Num_Checks : Natural := 0;
procedure Add_Check (N : Node_Id);
-- Adds the action given to Ret_Result if N is non-Empty
function Get_E_Length (E : Entity_Id; Indx : Nat) return Node_Id;
function Get_N_Length (N : Node_Id; Indx : Nat) return Node_Id;
function Same_Bounds (L : Node_Id; R : Node_Id) return Boolean;
-- True for equal literals and for nodes that denote the same constant
-- entity, even if its value is not a static constant. This includes the
-- case of a discriminal reference within an init_proc. Removes some
-- obviously superfluous checks.
function Length_E_Cond
(Exptyp : Entity_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id;
-- Returns expression to compute:
-- Typ'Length /= Exptyp'Length
function Length_N_Cond
(Expr : Node_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id;
-- Returns expression to compute:
-- Typ'Length /= Expr'Length
---------------
-- Add_Check --
---------------
procedure Add_Check (N : Node_Id) is
begin
if Present (N) then
-- For now, ignore attempt to place more than 2 checks ???
if Num_Checks = 2 then
return;
end if;
pragma Assert (Num_Checks <= 1);
Num_Checks := Num_Checks + 1;
Ret_Result (Num_Checks) := N;
end if;
end Add_Check;
------------------
-- Get_E_Length --
------------------
function Get_E_Length (E : Entity_Id; Indx : Nat) return Node_Id is
N : Node_Id;
E1 : Entity_Id := E;
Pt : Entity_Id := Scope (Scope (E));
begin
if Ekind (Scope (E)) = E_Record_Type
and then Has_Discriminants (Scope (E))
then
N := Build_Discriminal_Subtype_Of_Component (E);
if Present (N) then
Insert_Action (Ck_Node, N);
E1 := Defining_Identifier (N);
end if;
end if;
if Ekind (E1) = E_String_Literal_Subtype then
return
Make_Integer_Literal (Loc,
Intval => String_Literal_Length (E1));
elsif Ekind (Pt) = E_Protected_Type
and then Has_Discriminants (Pt)
and then Has_Completion (Pt)
and then not Inside_Init_Proc
then
-- If the type whose length is needed is a private component
-- constrained by a discriminant, we must expand the 'Length
-- attribute into an explicit computation, using the discriminal
-- of the current protected operation. This is because the actual
-- type of the prival is constructed after the protected opera-
-- tion has been fully expanded.
declare
Indx_Type : Node_Id;
Lo : Node_Id;
Hi : Node_Id;
Do_Expand : Boolean := False;
begin
Indx_Type := First_Index (E);
for J in 1 .. Indx - 1 loop
Next_Index (Indx_Type);
end loop;
Get_Index_Bounds (Indx_Type, Lo, Hi);
if Nkind (Lo) = N_Identifier
and then Ekind (Entity (Lo)) = E_In_Parameter
then
Lo := Get_Discriminal (E, Lo);
Do_Expand := True;
end if;
if Nkind (Hi) = N_Identifier
and then Ekind (Entity (Hi)) = E_In_Parameter
then
Hi := Get_Discriminal (E, Hi);
Do_Expand := True;
end if;
if Do_Expand then
if not Is_Entity_Name (Lo) then
Lo := Duplicate_Subexpr (Lo);
end if;
if not Is_Entity_Name (Hi) then
Lo := Duplicate_Subexpr (Hi);
end if;
N :=
Make_Op_Add (Loc,
Left_Opnd =>
Make_Op_Subtract (Loc,
Left_Opnd => Hi,
Right_Opnd => Lo),
Right_Opnd => Make_Integer_Literal (Loc, 1));
return N;
else
N :=
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Length,
Prefix =>
New_Occurrence_Of (E1, Loc));
if Indx > 1 then
Set_Expressions (N, New_List (
Make_Integer_Literal (Loc, Indx)));
end if;
return N;
end if;
end;
else
N :=
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Length,
Prefix =>
New_Occurrence_Of (E1, Loc));
if Indx > 1 then
Set_Expressions (N, New_List (
Make_Integer_Literal (Loc, Indx)));
end if;
return N;
end if;
end Get_E_Length;
------------------
-- Get_N_Length --
------------------
function Get_N_Length (N : Node_Id; Indx : Nat) return Node_Id is
begin
return
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Length,
Prefix =>
Duplicate_Subexpr (N, Name_Req => True),
Expressions => New_List (
Make_Integer_Literal (Loc, Indx)));
end Get_N_Length;
-------------------
-- Length_E_Cond --
-------------------
function Length_E_Cond
(Exptyp : Entity_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id
is
begin
return
Make_Op_Ne (Loc,
Left_Opnd => Get_E_Length (Typ, Indx),
Right_Opnd => Get_E_Length (Exptyp, Indx));
end Length_E_Cond;
-------------------
-- Length_N_Cond --
-------------------
function Length_N_Cond
(Expr : Node_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id
is
begin
return
Make_Op_Ne (Loc,
Left_Opnd => Get_E_Length (Typ, Indx),
Right_Opnd => Get_N_Length (Expr, Indx));
end Length_N_Cond;
function Same_Bounds (L : Node_Id; R : Node_Id) return Boolean is
begin
return
(Nkind (L) = N_Integer_Literal
and then Nkind (R) = N_Integer_Literal
and then Intval (L) = Intval (R))
or else
(Is_Entity_Name (L)
and then Ekind (Entity (L)) = E_Constant
and then ((Is_Entity_Name (R)
and then Entity (L) = Entity (R))
or else
(Nkind (R) = N_Type_Conversion
and then Is_Entity_Name (Expression (R))
and then Entity (L) = Entity (Expression (R)))))
or else
(Is_Entity_Name (R)
and then Ekind (Entity (R)) = E_Constant
and then Nkind (L) = N_Type_Conversion
and then Is_Entity_Name (Expression (L))
and then Entity (R) = Entity (Expression (L)))
or else
(Is_Entity_Name (L)
and then Is_Entity_Name (R)
and then Entity (L) = Entity (R)
and then Ekind (Entity (L)) = E_In_Parameter
and then Inside_Init_Proc);
end Same_Bounds;
-- Start of processing for Selected_Length_Checks
begin
if not Expander_Active then
return Ret_Result;
end if;
if Target_Typ = Any_Type
or else Target_Typ = Any_Composite
or else Raises_Constraint_Error (Ck_Node)
then
return Ret_Result;
end if;
if No (Wnode) then
Wnode := Ck_Node;
end if;
T_Typ := Target_Typ;
if No (Source_Typ) then
S_Typ := Etype (Ck_Node);
else
S_Typ := Source_Typ;
end if;
if S_Typ = Any_Type or else S_Typ = Any_Composite then
return Ret_Result;
end if;
if Is_Access_Type (T_Typ) and then Is_Access_Type (S_Typ) then
S_Typ := Designated_Type (S_Typ);
T_Typ := Designated_Type (T_Typ);
Do_Access := True;
-- A simple optimization
if Nkind (Ck_Node) = N_Null then
return Ret_Result;
end if;
end if;
if Is_Array_Type (T_Typ) and then Is_Array_Type (S_Typ) then
if Is_Constrained (T_Typ) then
-- The checking code to be generated will freeze the
-- corresponding array type. However, we must freeze the
-- type now, so that the freeze node does not appear within
-- the generated condional expression, but ahead of it.
Freeze_Before (Ck_Node, T_Typ);
Expr_Actual := Get_Referenced_Object (Ck_Node);
Exptyp := Get_Actual_Subtype (Expr_Actual);
if Is_Access_Type (Exptyp) then
Exptyp := Designated_Type (Exptyp);
end if;
-- String_Literal case. This needs to be handled specially be-
-- cause no index types are available for string literals. The
-- condition is simply:
-- T_Typ'Length = string-literal-length
if Nkind (Expr_Actual) = N_String_Literal then
Cond :=
Make_Op_Ne (Loc,
Left_Opnd => Get_E_Length (T_Typ, 1),
Right_Opnd =>
Make_Integer_Literal (Loc,
Intval =>
String_Literal_Length (Etype (Expr_Actual))));
-- General array case. Here we have a usable actual subtype for
-- the expression, and the condition is built from the two types
-- (Do_Length):
-- T_Typ'Length /= Exptyp'Length or else
-- T_Typ'Length (2) /= Exptyp'Length (2) or else
-- T_Typ'Length (3) /= Exptyp'Length (3) or else
-- ...
elsif Is_Constrained (Exptyp) then
declare
L_Index : Node_Id;
R_Index : Node_Id;
Ndims : Nat := Number_Dimensions (T_Typ);
L_Low : Node_Id;
L_High : Node_Id;
R_Low : Node_Id;
R_High : Node_Id;
L_Length : Uint;
R_Length : Uint;
begin
L_Index := First_Index (T_Typ);
R_Index := First_Index (Exptyp);
for Indx in 1 .. Ndims loop
if not (Nkind (L_Index) = N_Raise_Constraint_Error
or else Nkind (R_Index) = N_Raise_Constraint_Error)
then
Get_Index_Bounds (L_Index, L_Low, L_High);
Get_Index_Bounds (R_Index, R_Low, R_High);
-- Deal with compile time length check. Note that we
-- skip this in the access case, because the access
-- value may be null, so we cannot know statically.
if not Do_Access
and then Compile_Time_Known_Value (L_Low)
and then Compile_Time_Known_Value (L_High)
and then Compile_Time_Known_Value (R_Low)
and then Compile_Time_Known_Value (R_High)
then
if Expr_Value (L_High) >= Expr_Value (L_Low) then
L_Length := Expr_Value (L_High) -
Expr_Value (L_Low) + 1;
else
L_Length := UI_From_Int (0);
end if;
if Expr_Value (R_High) >= Expr_Value (R_Low) then
R_Length := Expr_Value (R_High) -
Expr_Value (R_Low) + 1;
else
R_Length := UI_From_Int (0);
end if;
if L_Length > R_Length then
Add_Check
(Compile_Time_Constraint_Error
(Wnode, "too few elements for}?", T_Typ));
elsif L_Length < R_Length then
Add_Check
(Compile_Time_Constraint_Error
(Wnode, "too many elements for}?", T_Typ));
end if;
-- The comparison for an individual index subtype
-- is omitted if the corresponding index subtypes
-- statically match, since the result is known to
-- be true. Note that this test is worth while even
-- though we do static evaluation, because non-static
-- subtypes can statically match.
elsif not
Subtypes_Statically_Match
(Etype (L_Index), Etype (R_Index))
and then not
(Same_Bounds (L_Low, R_Low)
and then Same_Bounds (L_High, R_High))
then
Evolve_Or_Else
(Cond, Length_E_Cond (Exptyp, T_Typ, Indx));
end if;
Next (L_Index);
Next (R_Index);
end if;
end loop;
end;
-- Handle cases where we do not get a usable actual subtype that
-- is constrained. This happens for example in the function call
-- and explicit dereference cases. In these cases, we have to get
-- the length or range from the expression itself, making sure we
-- do not evaluate it more than once.
-- Here Ck_Node is the original expression, or more properly the
-- result of applying Duplicate_Expr to the original tree,
-- forcing the result to be a name.
else
declare
Ndims : Nat := Number_Dimensions (T_Typ);
begin
-- Build the condition for the explicit dereference case
for Indx in 1 .. Ndims loop
Evolve_Or_Else
(Cond, Length_N_Cond (Ck_Node, T_Typ, Indx));
end loop;
end;
end if;
end if;
end if;
-- Construct the test and insert into the tree
if Present (Cond) then
if Do_Access then
Cond := Guard_Access (Cond, Loc, Ck_Node);
end if;
Add_Check (Make_Raise_Constraint_Error (Loc, Condition => Cond));
end if;
return Ret_Result;
end Selected_Length_Checks;
---------------------------
-- Selected_Range_Checks --
---------------------------
function Selected_Range_Checks
(Ck_Node : Node_Id;
Target_Typ : Entity_Id;
Source_Typ : Entity_Id;
Warn_Node : Node_Id)
return Check_Result
is
Loc : constant Source_Ptr := Sloc (Ck_Node);
S_Typ : Entity_Id;
T_Typ : Entity_Id;
Expr_Actual : Node_Id;
Exptyp : Entity_Id;
Cond : Node_Id := Empty;
Do_Access : Boolean := False;
Wnode : Node_Id := Warn_Node;
Ret_Result : Check_Result := (Empty, Empty);
Num_Checks : Integer := 0;
procedure Add_Check (N : Node_Id);
-- Adds the action given to Ret_Result if N is non-Empty
function Discrete_Range_Cond
(Expr : Node_Id;
Typ : Entity_Id)
return Node_Id;
-- Returns expression to compute:
-- Low_Bound (Expr) < Typ'First
-- or else
-- High_Bound (Expr) > Typ'Last
function Discrete_Expr_Cond
(Expr : Node_Id;
Typ : Entity_Id)
return Node_Id;
-- Returns expression to compute:
-- Expr < Typ'First
-- or else
-- Expr > Typ'Last
function Get_E_First_Or_Last
(E : Entity_Id;
Indx : Nat;
Nam : Name_Id)
return Node_Id;
-- Returns expression to compute:
-- E'First or E'Last
function Get_N_First (N : Node_Id; Indx : Nat) return Node_Id;
function Get_N_Last (N : Node_Id; Indx : Nat) return Node_Id;
-- Returns expression to compute:
-- N'First or N'Last using Duplicate_Subexpr
function Range_E_Cond
(Exptyp : Entity_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id;
-- Returns expression to compute:
-- Exptyp'First < Typ'First or else Exptyp'Last > Typ'Last
function Range_Equal_E_Cond
(Exptyp : Entity_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id;
-- Returns expression to compute:
-- Exptyp'First /= Typ'First or else Exptyp'Last /= Typ'Last
function Range_N_Cond
(Expr : Node_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id;
-- Return expression to compute:
-- Expr'First < Typ'First or else Expr'Last > Typ'Last
---------------
-- Add_Check --
---------------
procedure Add_Check (N : Node_Id) is
begin
if Present (N) then
-- For now, ignore attempt to place more than 2 checks ???
if Num_Checks = 2 then
return;
end if;
pragma Assert (Num_Checks <= 1);
Num_Checks := Num_Checks + 1;
Ret_Result (Num_Checks) := N;
end if;
end Add_Check;
-------------------------
-- Discrete_Expr_Cond --
-------------------------
function Discrete_Expr_Cond
(Expr : Node_Id;
Typ : Entity_Id)
return Node_Id
is
begin
return
Make_Or_Else (Loc,
Left_Opnd =>
Make_Op_Lt (Loc,
Left_Opnd =>
Convert_To (Base_Type (Typ), Duplicate_Subexpr (Expr)),
Right_Opnd =>
Convert_To (Base_Type (Typ),
Get_E_First_Or_Last (Typ, 0, Name_First))),
Right_Opnd =>
Make_Op_Gt (Loc,
Left_Opnd =>
Convert_To (Base_Type (Typ), Duplicate_Subexpr (Expr)),
Right_Opnd =>
Convert_To
(Base_Type (Typ),
Get_E_First_Or_Last (Typ, 0, Name_Last))));
end Discrete_Expr_Cond;
-------------------------
-- Discrete_Range_Cond --
-------------------------
function Discrete_Range_Cond
(Expr : Node_Id;
Typ : Entity_Id)
return Node_Id
is
LB : Node_Id := Low_Bound (Expr);
HB : Node_Id := High_Bound (Expr);
Left_Opnd : Node_Id;
Right_Opnd : Node_Id;
begin
if Nkind (LB) = N_Identifier
and then Ekind (Entity (LB)) = E_Discriminant then
LB := New_Occurrence_Of (Discriminal (Entity (LB)), Loc);
end if;
if Nkind (HB) = N_Identifier
and then Ekind (Entity (HB)) = E_Discriminant then
HB := New_Occurrence_Of (Discriminal (Entity (HB)), Loc);
end if;
Left_Opnd :=
Make_Op_Lt (Loc,
Left_Opnd =>
Convert_To
(Base_Type (Typ), Duplicate_Subexpr (LB)),
Right_Opnd =>
Convert_To
(Base_Type (Typ), Get_E_First_Or_Last (Typ, 0, Name_First)));
if Base_Type (Typ) = Typ then
return Left_Opnd;
elsif Compile_Time_Known_Value (High_Bound (Scalar_Range (Typ)))
and then
Compile_Time_Known_Value (High_Bound (Scalar_Range
(Base_Type (Typ))))
then
if Is_Floating_Point_Type (Typ) then
if Expr_Value_R (High_Bound (Scalar_Range (Typ))) =
Expr_Value_R (High_Bound (Scalar_Range (Base_Type (Typ))))
then
return Left_Opnd;
end if;
else
if Expr_Value (High_Bound (Scalar_Range (Typ))) =
Expr_Value (High_Bound (Scalar_Range (Base_Type (Typ))))
then
return Left_Opnd;
end if;
end if;
end if;
Right_Opnd :=
Make_Op_Gt (Loc,
Left_Opnd =>
Convert_To
(Base_Type (Typ), Duplicate_Subexpr (HB)),
Right_Opnd =>
Convert_To
(Base_Type (Typ),
Get_E_First_Or_Last (Typ, 0, Name_Last)));
return Make_Or_Else (Loc, Left_Opnd, Right_Opnd);
end Discrete_Range_Cond;
-------------------------
-- Get_E_First_Or_Last --
-------------------------
function Get_E_First_Or_Last
(E : Entity_Id;
Indx : Nat;
Nam : Name_Id)
return Node_Id
is
N : Node_Id;
LB : Node_Id;
HB : Node_Id;
Bound : Node_Id;
begin
if Is_Array_Type (E) then
N := First_Index (E);
for J in 2 .. Indx loop
Next_Index (N);
end loop;
else
N := Scalar_Range (E);
end if;
if Nkind (N) = N_Subtype_Indication then
LB := Low_Bound (Range_Expression (Constraint (N)));
HB := High_Bound (Range_Expression (Constraint (N)));
elsif Is_Entity_Name (N) then
LB := Type_Low_Bound (Etype (N));
HB := Type_High_Bound (Etype (N));
else
LB := Low_Bound (N);
HB := High_Bound (N);
end if;
if Nam = Name_First then
Bound := LB;
else
Bound := HB;
end if;
if Nkind (Bound) = N_Identifier
and then Ekind (Entity (Bound)) = E_Discriminant
then
return New_Occurrence_Of (Discriminal (Entity (Bound)), Loc);
elsif Nkind (Bound) = N_Identifier
and then Ekind (Entity (Bound)) = E_In_Parameter
and then not Inside_Init_Proc
then
return Get_Discriminal (E, Bound);
elsif Nkind (Bound) = N_Integer_Literal then
return Make_Integer_Literal (Loc, Intval (Bound));
else
return Duplicate_Subexpr (Bound);
end if;
end Get_E_First_Or_Last;
-----------------
-- Get_N_First --
-----------------
function Get_N_First (N : Node_Id; Indx : Nat) return Node_Id is
begin
return
Make_Attribute_Reference (Loc,
Attribute_Name => Name_First,
Prefix =>
Duplicate_Subexpr (N, Name_Req => True),
Expressions => New_List (
Make_Integer_Literal (Loc, Indx)));
end Get_N_First;
----------------
-- Get_N_Last --
----------------
function Get_N_Last (N : Node_Id; Indx : Nat) return Node_Id is
begin
return
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Last,
Prefix =>
Duplicate_Subexpr (N, Name_Req => True),
Expressions => New_List (
Make_Integer_Literal (Loc, Indx)));
end Get_N_Last;
------------------
-- Range_E_Cond --
------------------
function Range_E_Cond
(Exptyp : Entity_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id
is
begin
return
Make_Or_Else (Loc,
Left_Opnd =>
Make_Op_Lt (Loc,
Left_Opnd => Get_E_First_Or_Last (Exptyp, Indx, Name_First),
Right_Opnd => Get_E_First_Or_Last (Typ, Indx, Name_First)),
Right_Opnd =>
Make_Op_Gt (Loc,
Left_Opnd => Get_E_First_Or_Last (Exptyp, Indx, Name_Last),
Right_Opnd => Get_E_First_Or_Last (Typ, Indx, Name_Last)));
end Range_E_Cond;
------------------------
-- Range_Equal_E_Cond --
------------------------
function Range_Equal_E_Cond
(Exptyp : Entity_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id
is
begin
return
Make_Or_Else (Loc,
Left_Opnd =>
Make_Op_Ne (Loc,
Left_Opnd => Get_E_First_Or_Last (Exptyp, Indx, Name_First),
Right_Opnd => Get_E_First_Or_Last (Typ, Indx, Name_First)),
Right_Opnd =>
Make_Op_Ne (Loc,
Left_Opnd => Get_E_First_Or_Last (Exptyp, Indx, Name_Last),
Right_Opnd => Get_E_First_Or_Last (Typ, Indx, Name_Last)));
end Range_Equal_E_Cond;
------------------
-- Range_N_Cond --
------------------
function Range_N_Cond
(Expr : Node_Id;
Typ : Entity_Id;
Indx : Nat)
return Node_Id
is
begin
return
Make_Or_Else (Loc,
Left_Opnd =>
Make_Op_Lt (Loc,
Left_Opnd => Get_N_First (Expr, Indx),
Right_Opnd => Get_E_First_Or_Last (Typ, Indx, Name_First)),
Right_Opnd =>
Make_Op_Gt (Loc,
Left_Opnd => Get_N_Last (Expr, Indx),
Right_Opnd => Get_E_First_Or_Last (Typ, Indx, Name_Last)));
end Range_N_Cond;
-- Start of processing for Selected_Range_Checks
begin
if not Expander_Active then
return Ret_Result;
end if;
if Target_Typ = Any_Type
or else Target_Typ = Any_Composite
or else Raises_Constraint_Error (Ck_Node)
then
return Ret_Result;
end if;
if No (Wnode) then
Wnode := Ck_Node;
end if;
T_Typ := Target_Typ;
if No (Source_Typ) then
S_Typ := Etype (Ck_Node);
else
S_Typ := Source_Typ;
end if;
if S_Typ = Any_Type or else S_Typ = Any_Composite then
return Ret_Result;
end if;
-- The order of evaluating T_Typ before S_Typ seems to be critical
-- because S_Typ can be derived from Etype (Ck_Node), if it's not passed
-- in, and since Node can be an N_Range node, it might be invalid.
-- Should there be an assert check somewhere for taking the Etype of
-- an N_Range node ???
if Is_Access_Type (T_Typ) and then Is_Access_Type (S_Typ) then
S_Typ := Designated_Type (S_Typ);
T_Typ := Designated_Type (T_Typ);
Do_Access := True;
-- A simple optimization
if Nkind (Ck_Node) = N_Null then
return Ret_Result;
end if;
end if;
-- For an N_Range Node, check for a null range and then if not
-- null generate a range check action.
if Nkind (Ck_Node) = N_Range then
-- There's no point in checking a range against itself
if Ck_Node = Scalar_Range (T_Typ) then
return Ret_Result;
end if;
declare
T_LB : constant Node_Id := Type_Low_Bound (T_Typ);
T_HB : constant Node_Id := Type_High_Bound (T_Typ);
LB : constant Node_Id := Low_Bound (Ck_Node);
HB : constant Node_Id := High_Bound (Ck_Node);
Null_Range : Boolean;
Out_Of_Range_L : Boolean;
Out_Of_Range_H : Boolean;
begin
-- Check for case where everything is static and we can
-- do the check at compile time. This is skipped if we
-- have an access type, since the access value may be null.
-- ??? This code can be improved since you only need to know
-- that the two respective bounds (LB & T_LB or HB & T_HB)
-- are known at compile time to emit pertinent messages.
if Compile_Time_Known_Value (LB)
and then Compile_Time_Known_Value (HB)
and then Compile_Time_Known_Value (T_LB)
and then Compile_Time_Known_Value (T_HB)
and then not Do_Access
then
-- Floating-point case
if Is_Floating_Point_Type (S_Typ) then
Null_Range := Expr_Value_R (HB) < Expr_Value_R (LB);
Out_Of_Range_L :=
(Expr_Value_R (LB) < Expr_Value_R (T_LB))
or else
(Expr_Value_R (LB) > Expr_Value_R (T_HB));
Out_Of_Range_H :=
(Expr_Value_R (HB) > Expr_Value_R (T_HB))
or else
(Expr_Value_R (HB) < Expr_Value_R (T_LB));
-- Fixed or discrete type case
else
Null_Range := Expr_Value (HB) < Expr_Value (LB);
Out_Of_Range_L :=
(Expr_Value (LB) < Expr_Value (T_LB))
or else
(Expr_Value (LB) > Expr_Value (T_HB));
Out_Of_Range_H :=
(Expr_Value (HB) > Expr_Value (T_HB))
or else
(Expr_Value (HB) < Expr_Value (T_LB));
end if;
if not Null_Range then
if Out_Of_Range_L then
if No (Warn_Node) then
Add_Check
(Compile_Time_Constraint_Error
(Low_Bound (Ck_Node),
"static value out of range of}?", T_Typ));
else
Add_Check
(Compile_Time_Constraint_Error
(Wnode,
"static range out of bounds of}?", T_Typ));
end if;
end if;
if Out_Of_Range_H then
if No (Warn_Node) then
Add_Check
(Compile_Time_Constraint_Error
(High_Bound (Ck_Node),
"static value out of range of}?", T_Typ));
else
Add_Check
(Compile_Time_Constraint_Error
(Wnode,
"static range out of bounds of}?", T_Typ));
end if;
end if;
end if;
else
declare
LB : Node_Id := Low_Bound (Ck_Node);
HB : Node_Id := High_Bound (Ck_Node);
begin
-- If either bound is a discriminant and we are within
-- the record declaration, it is a use of the discriminant
-- in a constraint of a component, and nothing can be
-- checked here. The check will be emitted within the
-- init_proc. Before then, the discriminal has no real
-- meaning.
if Nkind (LB) = N_Identifier
and then Ekind (Entity (LB)) = E_Discriminant
then
if Current_Scope = Scope (Entity (LB)) then
return Ret_Result;
else
LB :=
New_Occurrence_Of (Discriminal (Entity (LB)), Loc);
end if;
end if;
if Nkind (HB) = N_Identifier
and then Ekind (Entity (HB)) = E_Discriminant
then
if Current_Scope = Scope (Entity (HB)) then
return Ret_Result;
else
HB :=
New_Occurrence_Of (Discriminal (Entity (HB)), Loc);
end if;
end if;
Cond := Discrete_Range_Cond (Ck_Node, T_Typ);
Set_Paren_Count (Cond, 1);
Cond :=
Make_And_Then (Loc,
Left_Opnd =>
Make_Op_Ge (Loc,
Left_Opnd => Duplicate_Subexpr (HB),
Right_Opnd => Duplicate_Subexpr (LB)),
Right_Opnd => Cond);
end;
end if;
end;
elsif Is_Scalar_Type (S_Typ) then
-- This somewhat duplicates what Apply_Scalar_Range_Check does,
-- except the above simply sets a flag in the node and lets
-- gigi generate the check base on the Etype of the expression.
-- Sometimes, however we want to do a dynamic check against an
-- arbitrary target type, so we do that here.
if Ekind (Base_Type (S_Typ)) /= Ekind (Base_Type (T_Typ)) then
Cond := Discrete_Expr_Cond (Ck_Node, T_Typ);
-- For literals, we can tell if the constraint error will be
-- raised at compile time, so we never need a dynamic check, but
-- if the exception will be raised, then post the usual warning,
-- and replace the literal with a raise constraint error
-- expression. As usual, skip this for access types
elsif Compile_Time_Known_Value (Ck_Node)
and then not Do_Access
then
declare
LB : constant Node_Id := Type_Low_Bound (T_Typ);
UB : constant Node_Id := Type_High_Bound (T_Typ);
Out_Of_Range : Boolean;
Static_Bounds : constant Boolean :=
Compile_Time_Known_Value (LB)
and Compile_Time_Known_Value (UB);
begin
-- Following range tests should use Sem_Eval routine ???
if Static_Bounds then
if Is_Floating_Point_Type (S_Typ) then
Out_Of_Range :=
(Expr_Value_R (Ck_Node) < Expr_Value_R (LB))
or else
(Expr_Value_R (Ck_Node) > Expr_Value_R (UB));
else -- fixed or discrete type
Out_Of_Range :=
Expr_Value (Ck_Node) < Expr_Value (LB)
or else
Expr_Value (Ck_Node) > Expr_Value (UB);
end if;
-- Bounds of the type are static and the literal is
-- out of range so make a warning message.
if Out_Of_Range then
if No (Warn_Node) then
Add_Check
(Compile_Time_Constraint_Error
(Ck_Node,
"static value out of range of}?", T_Typ));
else
Add_Check
(Compile_Time_Constraint_Error
(Wnode,
"static value out of range of}?", T_Typ));
end if;
end if;
else
Cond := Discrete_Expr_Cond (Ck_Node, T_Typ);
end if;
end;
-- Here for the case of a non-static expression, we need a runtime
-- check unless the source type range is guaranteed to be in the
-- range of the target type.
else
if not In_Subrange_Of (S_Typ, T_Typ) then
Cond := Discrete_Expr_Cond (Ck_Node, T_Typ);
end if;
end if;
end if;
if Is_Array_Type (T_Typ) and then Is_Array_Type (S_Typ) then
if Is_Constrained (T_Typ) then
Expr_Actual := Get_Referenced_Object (Ck_Node);
Exptyp := Get_Actual_Subtype (Expr_Actual);
if Is_Access_Type (Exptyp) then
Exptyp := Designated_Type (Exptyp);
end if;
-- String_Literal case. This needs to be handled specially be-
-- cause no index types are available for string literals. The
-- condition is simply:
-- T_Typ'Length = string-literal-length
if Nkind (Expr_Actual) = N_String_Literal then
null;
-- General array case. Here we have a usable actual subtype for
-- the expression, and the condition is built from the two types
-- T_Typ'First < Exptyp'First or else
-- T_Typ'Last > Exptyp'Last or else
-- T_Typ'First(1) < Exptyp'First(1) or else
-- T_Typ'Last(1) > Exptyp'Last(1) or else
-- ...
elsif Is_Constrained (Exptyp) then
declare
L_Index : Node_Id;
R_Index : Node_Id;
Ndims : Nat := Number_Dimensions (T_Typ);
L_Low : Node_Id;
L_High : Node_Id;
R_Low : Node_Id;
R_High : Node_Id;
begin
L_Index := First_Index (T_Typ);
R_Index := First_Index (Exptyp);
for Indx in 1 .. Ndims loop
if not (Nkind (L_Index) = N_Raise_Constraint_Error
or else Nkind (R_Index) = N_Raise_Constraint_Error)
then
Get_Index_Bounds (L_Index, L_Low, L_High);
Get_Index_Bounds (R_Index, R_Low, R_High);
-- Deal with compile time length check. Note that we
-- skip this in the access case, because the access
-- value may be null, so we cannot know statically.
if not
Subtypes_Statically_Match
(Etype (L_Index), Etype (R_Index))
then
-- If the target type is constrained then we
-- have to check for exact equality of bounds
-- (required for qualified expressions).
if Is_Constrained (T_Typ) then
Evolve_Or_Else
(Cond,
Range_Equal_E_Cond (Exptyp, T_Typ, Indx));
else
Evolve_Or_Else
(Cond, Range_E_Cond (Exptyp, T_Typ, Indx));
end if;
end if;
Next (L_Index);
Next (R_Index);
end if;
end loop;
end;
-- Handle cases where we do not get a usable actual subtype that
-- is constrained. This happens for example in the function call
-- and explicit dereference cases. In these cases, we have to get
-- the length or range from the expression itself, making sure we
-- do not evaluate it more than once.
-- Here Ck_Node is the original expression, or more properly the
-- result of applying Duplicate_Expr to the original tree,
-- forcing the result to be a name.
else
declare
Ndims : Nat := Number_Dimensions (T_Typ);
begin
-- Build the condition for the explicit dereference case
for Indx in 1 .. Ndims loop
Evolve_Or_Else
(Cond, Range_N_Cond (Ck_Node, T_Typ, Indx));
end loop;
end;
end if;
else
-- Generate an Action to check that the bounds of the
-- source value are within the constraints imposed by the
-- target type for a conversion to an unconstrained type.
-- Rule is 4.6(38).
if Nkind (Parent (Ck_Node)) = N_Type_Conversion then
declare
Opnd_Index : Node_Id;
Targ_Index : Node_Id;
begin
Opnd_Index
:= First_Index (Get_Actual_Subtype (Ck_Node));
Targ_Index := First_Index (T_Typ);
while Opnd_Index /= Empty loop
if Nkind (Opnd_Index) = N_Range then
if Is_In_Range
(Low_Bound (Opnd_Index), Etype (Targ_Index))
and then
Is_In_Range
(High_Bound (Opnd_Index), Etype (Targ_Index))
then
null;
elsif Is_Out_Of_Range
(Low_Bound (Opnd_Index), Etype (Targ_Index))
or else
Is_Out_Of_Range
(High_Bound (Opnd_Index), Etype (Targ_Index))
then
Add_Check
(Compile_Time_Constraint_Error
(Wnode, "value out of range of}?", T_Typ));
else
Evolve_Or_Else
(Cond,
Discrete_Range_Cond
(Opnd_Index, Etype (Targ_Index)));
end if;
end if;
Next_Index (Opnd_Index);
Next_Index (Targ_Index);
end loop;
end;
end if;
end if;
end if;
-- Construct the test and insert into the tree
if Present (Cond) then
if Do_Access then
Cond := Guard_Access (Cond, Loc, Ck_Node);
end if;
Add_Check (Make_Raise_Constraint_Error (Loc, Condition => Cond));
end if;
return Ret_Result;
end Selected_Range_Checks;
-------------------------------
-- Storage_Checks_Suppressed --
-------------------------------
function Storage_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Storage_Checks
or else (Present (E) and then Suppress_Storage_Checks (E));
end Storage_Checks_Suppressed;
---------------------------
-- Tag_Checks_Suppressed --
---------------------------
function Tag_Checks_Suppressed (E : Entity_Id) return Boolean is
begin
return Scope_Suppress.Tag_Checks
or else (Present (E) and then Suppress_Tag_Checks (E));
end Tag_Checks_Suppressed;
end Checks;
|
test/Succeed/WarningInstanceWithExplicitArg.agda | shlevy/agda | 1,989 | 14466 | <reponame>shlevy/agda
-- Jesper, 2018-11-29: Instances with explicit arguments will never be
-- used, so declaring them should give a warning.
postulate
X : Set
instance _ : Set → X -- this should give a warning
it : {{_ : X}} → X
it {{x}} = x
-- OTOH, this is fine as the instance can be used inside the module
module _ (A : Set) where
postulate instance instX : X
test : X
test = it
-- Andreas, 2020-01-29, issue #4360:
-- Such warnings should also be given for data and record constructors.
record R (A : Set) : Set where
instance constructor r
field
a : A
data D (A : Set) : Set where
instance c : A → D A
|
binary16/fmod.asm | DW0RKiN/Floating-point-Library-for-Z80 | 12 | 101014 | <reponame>DW0RKiN/Floating-point-Library-for-Z80
if not defined @FMOD
include "color_flow_warning.asm"
; Remainder after division.
; In: BC dividend, HL modulus
; Out: HL remainder, HL = BC % HL
; BC % HL = BC - int(BC/HL) * HL = frac(BC/HL) * HL => does not return correct results with larger exponent difference
; Pollutes: AF, BC, DE
@FMOD:
if not defined FMOD
; *****************************************
FMOD ; *
; *****************************************
endif
include "mcmpa.asm"
MCMPA H, L, B, C ; flag: abs(HL) - abs(BC)
JP c, FMOD_BC_GR ; 3:10
LD H, B ; 1:4
LD L, C ; 1:4
RET nz ; 1:11/5
LD L, A ; 1:4
LD A, B ; 1:4
AND SIGN_MASK ; 2:7
LD H, A ; 1:4
RET ; 1:11/5 FPMIN or FMMIN
FMOD_BC_GR:
LD D, B ;
LD E, C ; HL = DE % HL
LD A, H ;
AND EXP_MASK ; 2:7
LD B, A ;
LD A, D ;
AND EXP_MASK ; 2:7
SUB B ;
LD C, A ; C = ( D_Exp - H_exp )
LD A, D ;
SUB C ; 1:4
AND $FF - MANT_MASK_HI ; 2:7
LD B, A ; 1:4 B = D_sign + H_exp
ADD HL, HL ; 1:11
ADD HL, HL ; 1:11
ADD HL, HL ; 1:11
ADD HL, HL ; 1:11
ADD HL, HL ; 1:11
SET 7, H ; 2:8 HL = 0 1mmm mmmm mmm0 0000
EX DE, HL ; 1:4 HL = HL % DE
XOR A ; 1:4
RR H ; 2:8
RR L ; 2:8
RRA ; 1:4
RR H ; 2:8
RR L ; 2:8
RRA ; 1:4
LD H, L ; 1:4
LD L, A ; 1:4 HL = 1 mmmm mmmm mm00 0000
LD A, C ;
LD C, EXP_PLUS_ONE ; 2:7
OR A ;
JP z, FMOD_SAME_EXP ;
FMOD_SUB: ; HL - DE
SBC HL, DE ; 2:15 HL = HL - DE/2
JR nc, FMOD_SUB ; 3:10
FMOD_SHIFT_HL:
SUB C ; 1:4 exp--
ADD HL, HL ; 1:11
JP nc, FMOD_SHIFT_HL ; 3:10
OR A ;
JR z, FMOD_SAME_EXP ; 2:7/12
JP p, FMOD_SUB ;
ADD A, B ;
XOR B ;
JP m, FMOD_UNDERFLOW ;
XOR B ;
LD B, A ;
FMOD_NORM: ; HL = mmmm mmmm mmm0 0000
XOR A ; 1:4
ADD HL, HL ; 1:11 HL = mmmm mmmm mm00 0000
ADC A, A ; 1:4 A = 0000 000m
ADD HL, HL ; 1:11 HL = mmmm mmmm m000 0000
ADC A, A ; 1:4 A = 0000 00mm
OR B ; 1:4 RET with reset carry
LD L, H ; 1:4
LD H, A ; 1:4
RET ; 1:10
FMOD_SAME_EXP:
SLA E ; 2:8
RL D ; 2:8 DE = 1mmm mmmm mmm0 0000
OR A ; 1:4
SBC HL, DE ; 2:15
RET z ; FPMIN
JR nc, FMOD_SHIFT_HL ;
ADD HL, DE ;
JR FMOD_NORM
FMOD_UNDERFLOW:
LD A, B ;
AND SIGN_MASK ;
LD H, A ;
LD L, $00 ;
if color_flow_warning
CALL UNDER_COL_WARNING ; 3:17
endif
if carry_flow_warning
SCF ; 1:4 carry = error
endif
RET ;
endif
|
llvm-gcc-4.2-2.9/gcc/ada/s-gloloc.adb | vidkidz/crossbridge | 1 | 22684 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . G L O B A L _ L O C K S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Soft_Links;
-- used for Lock_Task, Unlock_Task
package body System.Global_Locks is
type String_Access is access String;
Dir_Separator : Character;
pragma Import (C, Dir_Separator, "__gnat_dir_separator");
type Lock_File_Entry is record
Dir : String_Access;
File : String_Access;
end record;
Last_Lock : Lock_Type := Null_Lock;
Lock_Table : array (Lock_Type range 1 .. 15) of Lock_File_Entry;
procedure Lock_File
(Dir : String;
File : String;
Wait : Duration := 0.1;
Retries : Natural := Natural'Last);
-- Create a lock file File in directory Dir. If the file cannot be
-- locked because someone already owns the lock, this procedure
-- waits Wait seconds and retries at most Retries times. If the file
-- still cannot be locked, Lock_Error is raised. The default is to try
-- every second, almost forever (Natural'Last times).
------------------
-- Acquire_Lock --
------------------
procedure Acquire_Lock (Lock : in out Lock_Type) is
begin
Lock_File
(Lock_Table (Lock).Dir.all,
Lock_Table (Lock).File.all);
end Acquire_Lock;
-----------------
-- Create_Lock --
-----------------
procedure Create_Lock (Lock : out Lock_Type; Name : String) is
L : Lock_Type;
begin
System.Soft_Links.Lock_Task.all;
Last_Lock := Last_Lock + 1;
L := Last_Lock;
System.Soft_Links.Unlock_Task.all;
if L > Lock_Table'Last then
raise Lock_Error;
end if;
for J in reverse Name'Range loop
if Name (J) = Dir_Separator then
Lock_Table (L).Dir := new String'(Name (Name'First .. J - 1));
Lock_Table (L).File := new String'(Name (J + 1 .. Name'Last));
exit;
end if;
end loop;
if Lock_Table (L).Dir = null then
Lock_Table (L).Dir := new String'(".");
Lock_Table (L).File := new String'(Name);
end if;
Lock := L;
end Create_Lock;
---------------
-- Lock_File --
---------------
procedure Lock_File
(Dir : String;
File : String;
Wait : Duration := 0.1;
Retries : Natural := Natural'Last)
is
C_Dir : aliased String := Dir & ASCII.NUL;
C_File : aliased String := File & ASCII.NUL;
function Try_Lock (Dir, File : System.Address) return Integer;
pragma Import (C, Try_Lock, "__gnat_try_lock");
begin
for I in 0 .. Retries loop
if Try_Lock (C_Dir'Address, C_File'Address) = 1 then
return;
end if;
exit when I = Retries;
delay Wait;
end loop;
raise Lock_Error;
end Lock_File;
------------------
-- Release_Lock --
------------------
procedure Release_Lock (Lock : in out Lock_Type) is
S : aliased String :=
Lock_Table (Lock).Dir.all & Dir_Separator &
Lock_Table (Lock).File.all & ASCII.NUL;
procedure unlink (A : System.Address);
pragma Import (C, unlink, "unlink");
begin
unlink (S'Address);
end Release_Lock;
end System.Global_Locks;
|
programs/oeis/040/A040195.asm | neoneye/loda | 22 | 18063 | ; A040195: Continued fraction for sqrt(210).
; 14,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28,2,28
mov $1,$0
cmp $0,0
sub $1,$0
gcd $1,2
add $1,5
add $0,$1
mul $0,$1
sub $0,35
mul $0,2
|
source/s-stopoo.ads | ytomino/drake | 33 | 15299 | <gh_stars>10-100
pragma License (Unrestricted);
with Ada.Finalization;
with System.Storage_Elements;
package System.Storage_Pools is
pragma Preelaborate;
type Root_Storage_Pool is
abstract limited new Ada.Finalization.Limited_Controlled with private;
pragma Preelaborable_Initialization (Root_Storage_Pool);
procedure Allocate (
Pool : in out Root_Storage_Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is abstract;
procedure Deallocate (
Pool : in out Root_Storage_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is abstract;
function Storage_Size (Pool : Root_Storage_Pool)
return Storage_Elements.Storage_Count is abstract;
-- to use in System.Finalization_Masters
type Storage_Pool_Access is access all Root_Storage_Pool'Class;
for Storage_Pool_Access'Storage_Size use 0;
private
type Root_Storage_Pool is
abstract limited new Ada.Finalization.Limited_Controlled
with null record;
-- required for allocation with explicit 'Storage_Pool by compiler
-- (s-stopoo.ads)
procedure Allocate_Any (
Pool : in out Root_Storage_Pool'Class;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count);
-- required for deallocation with explicit 'Storage_Pool by compiler
-- (s-stopoo.ads)
procedure Deallocate_Any (
Pool : in out Root_Storage_Pool'Class;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count);
-- required for extra parameter of built-in-place (s-stopoo.ads)
subtype Root_Storage_Pool_Ptr is Storage_Pool_Access;
end System.Storage_Pools;
|
src/Mute/MuteGrammar.g4 | GeirGrusom/daemos | 3 | 1281 | grammar MuteGrammar;
@header {
using System;
using System.Linq;
using Daemos.Mute.Expressions;
}
/*
* Parser Rules
*/
compileUnit returns [ModuleExpression module]
locals [List<VariableExpression> scope]
@init { $scope = new List<VariableExpression>(); }
: moduleStatement ';' (statements += statement)* EOF { $module = new ModuleExpression($moduleStatement.mod, ($statements).Select(x => x.expr), $ctx); }
| moduleStatement ';' EOF { $module = new ModuleExpression($moduleStatement.mod, null, $ctx); }
| EOF { $module = null; }
;
moduleStatement returns [string mod]
: MODULE IDENTIFIER { $mod = $IDENTIFIER.text; }
;
primaryExpression returns [Expression expr]
: literalExpression { $expr = $literalExpression.expr; }
| variableExpression { $expr = $variableExpression.expr; }
| castExpression { $expr = $castExpression.expr; }
| '(' expression ')' { $expr = $expression.expr; }
;
statement returns [Expression expr]
: declaration ';' { $expr = $declaration.expr; }
| using ';' { $expr = $using.expr; }
| expression ';' { $expr = $expression.expr; }
| whileExpression { $expr = $whileExpression.expr; }
| ifExpression { $expr = $ifExpression.expr; }
| tryExpression { $expr = $tryExpression.expr; }
| RETRY ';' { $expr = new RetryExpression($ctx); }
| THROW ';'
;
expression returns [Expression expr]
: assignmentExpression {$expr = $assignmentExpression.expr; }
| '(' innerExpression = expression ')' { $expr = $innerExpression.expr; }
;
assignmentExpression returns [Expression expr]
: lhs = variableExpression ASSIGN rhs = orExpression {
$expr = Assign($lhs.expr, $rhs.expr, $ctx);
}
| operand = orExpression { $expr = $operand.expr; }
;
orExpression returns [Expression expr]
: lhs = orExpression OR rhs = xorExpression { $expr = Or($lhs.expr, $rhs.expr, $ctx); }
| operand = xorExpression { $expr = $operand.expr; }
;
xorExpression returns [Expression expr]
: lhs = xorExpression XOR rhs = andExpression { $expr = Xor($lhs.expr, $rhs.expr, $ctx); }
| operand = andExpression { $expr = $operand.expr; }
;
andExpression returns [Expression expr]
: lhs = andExpression AND rhs = equalityExpression { $expr = And($lhs.expr, $rhs.expr, $ctx); }
| operand = equalityExpression { $expr = $operand.expr; }
;
equalityExpression returns [Expression expr]
: lhs = equalityExpression EQ rhs = comparisonExpression { $expr = Eq($lhs.expr, $rhs.expr, $ctx); }
| operand = comparisonExpression { $expr = $operand.expr; }
;
comparisonExpression returns [Expression expr]
: lhs = comparisonExpression GREATER_THAN rhs = addExpression { $expr = Greater($lhs.expr, $rhs.expr, $ctx); }
| lhs = comparisonExpression GREATER_THAN_OR_EQ rhs = addExpression { $expr = GreaterOrEqual($lhs.expr, $rhs.expr, $ctx); }
| lhs = comparisonExpression LESS_THAN rhs = addExpression { $expr = Less($lhs.expr, $rhs.expr, $ctx); }
| lhs = comparisonExpression LESS_THAN_OR_EQ rhs = addExpression { $expr = LessOrEqual($lhs.expr, $rhs.expr, $ctx); }
| operand = addExpression { $expr = $operand.expr; }
;
addExpression returns [Expression expr]
: lhs = addExpression ADD rhs = mulExpression { $expr = Add($lhs.expr, $rhs.expr, $ctx); }
| lhs = addExpression SUB rhs = mulExpression { $expr = Sub($lhs.expr, $rhs.expr, $ctx); }
| operand = mulExpression { $expr = $operand.expr; }
;
mulExpression returns [Expression expr]
: lhs = mulExpression MUL rhs = withExpression { $expr = Mul($lhs.expr, $rhs.expr, $ctx); }
| lhs = mulExpression DIV rhs = withExpression { $expr = Div($lhs.expr, $rhs.expr, $ctx); }
| lhs = mulExpression MOD rhs = withExpression { $expr = Mod($lhs.expr, $rhs.expr, $ctx); }
| operand = withExpression { $expr = $operand.expr; }
;
withExpression returns [Expression expr]
: lhs = withExpression WITH rhs = objectExpression { $expr = With($lhs.expr, (ObjectExpression)$rhs.expr, $ctx); }
| operand = unaryExpression { $expr = $operand.expr; }
;
unaryExpression returns [Expression expr]
: postfixExpression { $expr = $postfixExpression.expr; }
| NOT operand = unaryExpression { $expr = Not($operand.expr, $ctx); }
| SUB operand = unaryExpression { $expr = Neg($operand.expr, $ctx); }
| ADD operand = unaryExpression { $expr = Add($operand.expr, $ctx); }
| NOT_NULL operand = unaryExpression { $expr = NotNull($operand.expr, $ctx); }
| AWAIT awaitOperand = unaryExpression { $expr = Await($awaitOperand.expr, $ctx); }
| commitTransaction { $expr = $commitTransaction.expr; }
;
postfixExpression returns [Expression expr]
: primaryExpression { $expr = $primaryExpression.expr; }
| lhs = postfixExpression '.' IDENTIFIER { $expr = Member($lhs.expr, $IDENTIFIER.text, $ctx); }
| lhs = postfixExpression '[' expression ']'
| lhs = postfixExpression '(' callList ')' { $expr = Call($lhs.expr, $callList.results, $ctx); }
| lhs = postfixExpression '(' namedCallList ')' { $expr = Call($lhs.expr, $namedCallList.results, $ctx); }
| id = (IDENTIFIER | TIMESPAN_TYPE) '(' callList ')' { $expr = Call($id.text, $callList.results, $ctx); }
| id = (IDENTIFIER | TIMESPAN_TYPE) '(' namedCallList ')' { $expr = Call($id.text, $namedCallList.results, $ctx); }
;
using returns [Expression expr]
: USING namespace += IDENTIFIER ('.' namespace += IDENTIFIER)* ( '{' (members += IDENTIFIER (',' members += IDENTIFIER)*)| all = '*' '}')?
;
commitTransaction returns [Expression expr]
: COMMIT CHILD variableExpression { $expr = CommitTransactionChild($variableExpression.expr, $ctx); } // Creates a new child transaction
| COMMIT variableExpression { $expr = CommitTransaction($variableExpression.expr, $ctx); }// Commits an exisiting transaction
| COMMIT withExpression { $expr = CommitTransaction($withExpression.expr, $ctx); } // Commits an exisiting transaction
;
importExpression returns [Expression expr]
: IMPORT dataType { $expr = Import($dataType.type, $ctx); }
| IMPORT quotedString AS dataType { $expr = Import($dataType.type, $quotedString.value, $ctx); }
| IMPORT singleQuotedString AS dataType { $expr = Import($dataType.type, $singleQuotedString.value, $ctx); }
;
ifExpression returns [ConditionalExpression expr]
: IF '(' condition = expression ')' ifValue = statementBody { $expr = If($condition.expr, $ifValue.expr, $ctx); }
| IF '(' condition = expression ')' ifValue = statementBody ELSE elseValue = statementBody { $expr = If($condition.expr, $ifValue.expr, $elseValue.expr, $ctx); }
| IF '(' condition = expression ')' ifValue = statementBody elseIfExpression { $expr = If($condition.expr, $ifValue.expr, $elseIfExpression.expr, $ctx); }
;
elseIfExpression returns [ConditionalExpression expr]
: ELSEIF '(' condition = expression ')' ifValue = statementBody { $expr = If($condition.expr, $ifValue.expr, $ctx); }
| ELSEIF '(' condition = expression ')' ifValue = statementBody ELSE elseValue = statementBody { $expr = If($condition.expr, $ifValue.expr, $elseValue.expr, $ctx); }
| ELSEIF '(' condition = expression ')' ifValue = statementBody elseIfExpression { $expr = If($condition.expr, $ifValue.expr, $elseIfExpression.expr, $ctx); }
;
objectExpression returns [ObjectExpression expr]
: '{' objectMemberList? '}' { $expr = Object($objectMemberList.members, $ctx); }
;
objectMemberList returns [IEnumerable<ObjectMember> members]
: mem += objectMember (',' mem += objectMember)* { $members = ($mem).Select(x => x.item); }
;
objectMember returns [ObjectMember item]
: IDENTIFIER ':' expression { $item = ObjectMember($IDENTIFIER.text, $expression.expr, $ctx); }
| IDENTIFIER ':' objectExpression { $item = ObjectMember($IDENTIFIER.text, $objectExpression.expr, $ctx); }
;
variableExpression returns [VariableExpression expr]
: IDENTIFIER { $expr = Lookup($IDENTIFIER.text, $ctx); }
;
castExpression returns [Expression expr]
: dataType '!' '(' expression ')' { $expr = Convert($dataType.type, $expression.expr, $ctx); }
;
callList returns [List<Expression> results]
: (args += expression (',' args += expression)*)? { $results = ($args)?.Select(x => x.expr).ToList() ?? new List<Expression>(); }
;
namedCallList returns [List<NamedArgument> results]
: args += namedCallListElement (',' args += namedCallListElement)* { $results = ($args).Select(x => x.expr).ToList(); }
;
namedCallListElement returns [NamedArgument expr]
: IDENTIFIER ':' expression { $expr = new NamedArgument($IDENTIFIER.text, $expression.expr, $ctx); }
;
literalExpression returns [Expression expr]
: 'true' { $expr = ConstantExpression.TrueExpression; }
| 'false' { $expr = ConstantExpression.FalseExpression; }
| NULL { $expr = ConstantExpression.NullExpression; }
| INTEGER { $expr = new ConstantExpression(DataType.NonNullInt, $INTEGER.int, $ctx); }
| THIS { $expr = new VariableExpression("this", false, new DataType(typeof(Daemos.Transaction), false), $ctx); }
| NOW { $expr = new VariableExpression("now", false, new DataType(typeof(DateTime), false), $ctx); }
| EXPIRED { $expr = new VariableExpression("expired", false, new DataType(typeof(DateTime), false), $ctx); }
| DATETIME { $expr = DateTime($DATETIME.text, $ctx); }
| quotedString { $expr = new ConstantExpression(DataType.NonNullString, $quotedString.value, $ctx); }
| singleQuotedString { $expr = new ConstantExpression(DataType.NonNullString, $singleQuotedString.value, $ctx); }
| TRANSACTION_STATE { $expr = TransactionState($TRANSACTION_STATE.text, $ctx); }
;
whileExpression returns [Expression expr]
locals [List<VariableExpression> scope]
@init { $scope = new List<VariableExpression>(); }
: WHILE '(' expression ')' statementBody { $expr = While($expression.expr, $statementBody.expr, $ctx); }
| DO statementBody WHILE '(' expression ')' { $expr = DoWhile($expression.expr, $statementBody.expr, $ctx); }
;
quotedString returns [string value]: QUOTED_STRING { $value = Unescape($QUOTED_STRING.text.Substring(1, $QUOTED_STRING.text.Length - 2), '"'); } ;
singleQuotedString returns [string value]: SINGLE_QUOTED_STRING { $value = Unescape($SINGLE_QUOTED_STRING.text.Substring(1, $SINGLE_QUOTED_STRING.text.Length - 2), '\''); };
tryExpression returns [Expression expr]
locals [List<VariableExpression> scope]
@init { $scope = new List<VariableExpression>(); }
: TRY statementBody { $expr = Try($statementBody.expr, $ctx); }
| TRY statementBody (catches += catchExpression)+ { $expr = Try($statementBody.expr, ($catches).Select(x => x.expr), $ctx); }
| TRY statementBody finallyExpression { $expr = Try($statementBody.expr, $finallyExpression.expr, $ctx); }
| TRY statementBody (catches += catchExpression)+ finallyExpression { $expr = Try($statementBody.expr, ($catches).Select(x => x.expr), $finallyExpression.expr, $ctx); }
;
catchExpression returns [CatchExpression expr]
locals [List<VariableExpression> scope]
@init { $scope = new List<VariableExpression>(); }
: catchVariable statementBody { $expr = Catch($statementBody.expr, $catchVariable.variable, $ctx); }
;
catchVariable returns [VariableExpression variable]
: FAILURE '<' dataType '>' { AddVariable($variable = new VariableExpression("exception", false, $dataType.type, $ctx), $ctx); }
| FAILURE { $variable = null; }
;
finallyExpression returns [Expression expr]
locals [List<VariableExpression> scope]
@init { $scope = new List<VariableExpression>(); }
: FINALLY statementBody { $expr = $statementBody.expr; }
;
declaration returns [VariableDeclarationExpression expr]
: MUTABLE_DECLARE IDENTIFIER ASSIGN expression
{
$expr = Declare($IDENTIFIER.text, true, $expression.expr, $ctx);
}
| MUTABLE_DECLARE IDENTIFIER ':' dataType
{
$expr = Declare($IDENTIFIER.text, true, $dataType.type, $ctx);
}
| IMMUTABLE_DECLARE IDENTIFIER ASSIGN expression
{
$expr = Declare($IDENTIFIER.text, false, $expression.expr, $ctx);
}
| IMMUTABLE_DECLARE IDENTIFIER ':' dataType
{
$expr = Declare($IDENTIFIER.text, false, $dataType.type, $ctx);
}
| IMMUTABLE_DECLARE IDENTIFIER ASSIGN importExpression
{
$expr = Declare($IDENTIFIER.text, false, $importExpression.expr, $ctx);
}
;
functionDeclaration: FUNCTION '(' argumentList ')' expression ';'
| FUNCTION '(' argumentList ')' statementBody ';'
;
argumentList: (args += argument (',' args += argument)*)?;
argument returns [VariableExpression expr] : IDENTIFIER ':' dataType { $expr = new VariableExpression($IDENTIFIER.text, mutable: false, type: $dataType.type, context: $ctx); };
nullable returns [bool result]: NULLABLE? { $result = $NULLABLE.text == "?"; };
statementBody returns [BlockExpression expr]
locals [List<VariableExpression> scope]
@init { $scope = new List<VariableExpression>(); }
: '{' (expressions += statement)* '}' { $expr = new BlockExpression(($expressions).Select(x => x.expr), null, $ctx); } ;
dataType returns [DataType type]
: INT_TYPE nullable { $type = new DataType(typeof(int), $nullable.result); }
| LONG_TYPE nullable { $type = new DataType(typeof(long), $nullable.result); }
| FLOAT_TYPE nullable { $type = new DataType(typeof(double), $nullable.result); }
| STRING_TYPE nullable { $type = new DataType(typeof(string), $nullable.result); }
| BOOL_TYPE nullable { $type = new DataType(typeof(bool), $nullable.result); }
| CURRENCY_TYPE nullable { $type = new DataType(typeof(decimal), $nullable.result); }
| DATETIME_TYPE nullable { $type = new DataType(typeof(DateTime), $nullable.result); }
| TIMESPAN_TYPE nullable { $type = new DataType(typeof(TimeSpan), $nullable.result); }
| TRANSACTION_TYPE nullable { $type = new DataType(typeof(Daemos.Transaction), $nullable.result); }
| IDENTIFIER nullable { $type = new DataType(TypeLookup($ctx.GetText()), $nullable.result); }
;
/*
* Lexer Rules
*/
WS : [ \n\r\t] -> skip;
fragment ESCAPED_QUOTE: '\\"';
fragment QUOTED_STRING_BODY: (ESCAPED_QUOTE | ~('\n'|'\r'))*?;
QUOTED_STRING: '"' QUOTED_STRING_BODY '"';
fragment ESCAPED_SINGLE_QUOTE: '\\\'';
fragment SINGLE_QUOTED_STRING_BODY: (ESCAPED_SINGLE_QUOTE | ~('\n'|'\r'))*?;
SINGLE_QUOTED_STRING: '\'' SINGLE_QUOTED_STRING_BODY '\'';
USING: 'using';
IF: 'if';
ELSEIF: 'else-if';
ELSE: 'else';
MODULE: 'module';
FUNCTION: 'fun';
OR: 'or';
XOR: 'xor';
AND: 'and';
TRY: 'try';
FAILURE: 'catch';
FINALLY: 'finally';
IMPORT: 'import';
AS: 'as';
INCREMENT: '++';
DECREMENT: '--';
ASSIGN: '<-';
ADD: '+';
SUB: '-';
MUL: '*';
DIV: '/';
MOD: '%';
NOT: 'not';
EQ: '=';
NEQ: '!=';
fragment DATETIME_PREFIX: '@';
fragment DATE_YEAR: [0-9][0-9][0-9][0-9];
fragment DATE_MONTH: [0-9][0-9];
fragment DATE_DAY: [0-9][0-9];
fragment DATE_SEPARATOR: '-';
fragment DATETIME_TIME: 'T';
fragment TIME_SEPARATOR: ':';
fragment TIME_HOUR: [0-9][0-9];
fragment TIME_MINUTE: [0-9][0-9];
fragment TIME_SECOND: [0-9][0-9];
fragment TIME_UTC: 'Z';
fragment TIME_OFFSET: [+\-];
fragment TIME_OFFSET_HOUR: [0-9][0-9];
fragment TIME_OFFSET_MINUTE: [0-9][0-9];
DATETIME
: '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'T' TIME_HOUR ':' TIME_MINUTE ':' TIME_SECOND ('+' | '-') TIME_OFFSET_HOUR ':' TIME_OFFSET_MINUTE
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'T' TIME_HOUR ':' TIME_MINUTE ':' TIME_SECOND ('+' | '-') TIME_OFFSET_HOUR
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'T' TIME_HOUR ':' TIME_MINUTE ':' TIME_SECOND 'Z'
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'T' TIME_HOUR ':' TIME_MINUTE ':' TIME_SECOND
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'T' TIME_HOUR ':' TIME_MINUTE ('+' | '-') TIME_OFFSET_HOUR ':' TIME_OFFSET_MINUTE
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'T' TIME_HOUR ':' TIME_MINUTE ('+' | '-') TIME_OFFSET_HOUR
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'T' TIME_HOUR ':' TIME_MINUTE 'Z'
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'T' TIME_HOUR ':' TIME_MINUTE
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY ('+' | '-') TIME_OFFSET_HOUR ':' TIME_OFFSET_MINUTE
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY ('+' | '-') TIME_OFFSET_HOUR
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY 'Z'
| '@' DATE_YEAR '-' DATE_MONTH '-' DATE_DAY ;
// P1Y2M10DT2H30M
//TIMESPAN
// : '@' 'P' [0-9]+ 'Y' [0-9]+ 'M' [0-9]+ 'D' 'T' [0-9]+ 'H' [-9]+ 'M'
EXPIRED: 'expired';
NOW: 'now';
CHILD: 'child';
TRANSACTION_STATE: 'initialize' | 'authorize' | 'complete' | 'cancel' | 'fail';
COMMIT: 'commit';
GREATER_THAN_OR_EQ: '>=';
GREATER_THAN: '>';
LESS_THAN_OR_EQ: '<=';
LESS_THAN: '<';
IMMUTABLE_DECLARE: 'let';
MUTABLE_DECLARE: 'var';
NULLABLE: '?';
NOT_NULL: '!!';
INT_TYPE: 'int';
LONG_TYPE: 'long';
FLOAT_TYPE: 'float';
STRING_TYPE: 'string';
BOOL_TYPE: 'bool';
CURRENCY_TYPE: 'currency';
TRANSACTION_TYPE: 'transaction';
DATETIME_TYPE: 'datetime';
TIMESPAN_TYPE: 'timespan';
THROW: 'throw';
RETRY: 'retry';
NULL: 'null';
DO: 'do';
WHILE: 'while';
AWAIT: 'await';
WITH: 'with';
THIS: 'this';
HEX: '0x' [0-9a-fA-F]+;
BIN: '0b' [01]+;
INTEGER: [0-9]+;
fragment EXPONENT: 'e' '-'? INTEGER;
NUMBER: [0-9]* '.' [0-9]+ EXPONENT?;
fragment ID_HEAD: [a-zA-Z_];
fragment ID_TAIL: [a-zA-Z_0-9];
IDENTIFIER: ID_HEAD ID_TAIL*; |
test/Succeed/fol-theorems/Names.agda | asr/apia | 10 | 8748 | <filename>test/Succeed/fol-theorems/Names.agda
------------------------------------------------------------------------------
-- Testing the translation of function, predicates and variables names
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- From the technical manual of TPTP
-- (http://www.cs.miami.edu/~tptp/TPTP/TR/TPTPTR.shtml)
-- ... variables start with upper case letters, ... predicates and
-- functors either start with lower case and contain alphanumerics and
-- underscore ...
module Names where
infix 4 _≡_
------------------------------------------------------------------------------
-- Testing funny names
postulate
D : Set
_≡_ : D → D → Set
FUN! : D → D -- A funny function name.
PRED! : D → Set -- A funny predicate name.
-- Using a funny function and variable name.
postulate funnyFV : (nx∎ : D) → FUN! nx∎ ≡ nx∎
{-# ATP axiom funnyFV #-}
-- Using a funny predicate name.
postulate funnyP : (n : D) → PRED! n
{-# ATP axiom funnyP #-}
-- We need to have at least one conjecture to generate a TPTP file.
postulate refl : ∀ d → d ≡ d
{-# ATP prove refl #-}
|
main64/kernel/syscalls/syscall.asm | KlausAschenbrenner/KAOS | 1 | 84381 | <filename>main64/kernel/syscalls/syscall.asm
[BITS 64]
[GLOBAL SysCallHandlerAsm]
[EXTERN SysCallHandlerC]
[EXTERN printf_long]
SysCallHandlerAsm:
cli
; Save the General Purpose Registers on the Stack
push rdi
push rsi
push rbp
push rsp
push rbx
push rdx
push rcx
push rax
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
; Call the ISR handler that is implemented in C
mov rdi, rax
mov rsi, rbx
call SysCallHandlerC
; Restore the General Purpose Registers from the Stack
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
; We don't restore the RAX register, because it contains the result of the SysCall (from the function call to "SysCallHandlerC").
; So we just pop the old RAX value into RCX and then pop the old RCX value into RCX
; pop rax
pop rcx
pop rcx
pop rdx
pop rbx
pop rsp
pop rbp
pop rsi
pop rdi
sti
iretq |
ada/src/colors.ads | alkalinin/raytracer | 45 | 30677 | <filename>ada/src/colors.ads
--
-- Raytracer implementation in Ada
-- by <NAME> (github: johnperry-math)
-- 2021
--
-- specification for Colors, both RGB ("Color_Type")
-- and RGBA ("Transparent_Color_Type")
--
-- local packages
with RayTracing_Constants; use RayTracing_Constants;
-- @summary
-- specification for Colors, both RGB ("Color_Type")
-- and RGBA ("Transparent_Color_Type")
package Colors is
type Color_Type is record
Blue, Green, Red: Float15;
end record;
-- RGB channels only; for transparency channel see Color_With_Transparency
White: constant Color_Type := ( 1.0, 1.0, 1.0 );
Grey: constant Color_Type := ( 0.5, 0.5, 0.5 );
Black: constant Color_Type := ( 0.0, 0.0, 0.0 );
Background: constant Color_Type := Black;
Default_Color: constant Color_Type := Black;
type Color_With_Transparency_Type is record
Blue, Green, Red, Alpha: UInt8;
end record;
-- R, G, B, and Alpha (transparency) channels
function Create_Color( Red, Green, Blue: Float15 ) return Color_Type;
function Scale( Color: Color_Type; K: Float15 ) return Color_Type;
-- scales Color by a factor of K, returns result
pragma Inline_Always(Scale);
procedure Scale_Self( Color: in out Color_Type; K: Float15 );
-- scales Color by a factor of K, modifies self
pragma Inline_Always(Scale);
function "*"(First, Second: Color_Type) return Color_Type;
-- componentwise product of First and Second, returns result
pragma Inline_Always("*");
procedure Color_Multiply_Self(First: in out Color_Type; Second: Color_Type);
pragma Inline_Always(Color_Multiply_Self);
function "+"(First, Second: Color_Type) return Color_Type;
-- returns sum of First and Second
pragma Inline_Always("+");
function Legalize(C: Float15) return UInt8;
-- modifies C, expected in the range 0.0 .. 1.0, to the range 0 .. 255,
-- with values less than 0.0 converted to 0, and values greater than 1.0
-- converted to 255
pragma Inline_Always(Legalize);
function To_Drawing_Color(C: Color_Type) return Color_With_Transparency_Type;
-- converts RGB to RGBA with A = 255
pragma Inline_Always(To_Drawing_Color);
end Colors;
|
other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/日本_Ver3/asm/zel_enmy3.asm | prismotizm/gigaleak | 0 | 6579 | <filename>other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/日本_Ver3/asm/zel_enmy3.asm
Name: zel_enmy3.asm
Type: file
Size: 334969
Last-Modified: '2016-05-13T04:36:32Z'
SHA-1: 03E16D840FA79B53D57770236DA6E734C06577EE
Description: null
|
libsrc/_DEVELOPMENT/fcntl/c/sdcc_ix/read_callee.asm | meesokim/z88dk | 0 | 17882 |
; ssize_t read_callee(int fd, void *buf, size_t nbyte)
SECTION code_fcntl
PUBLIC _read_callee, l0_read_callee
EXTERN asm_read
_read_callee:
pop af
pop hl
pop de
pop bc
push af
l0_read_callee:
push ix
call asm_read
pop ix
ret
|
programs/oeis/178/A178890.asm | neoneye/loda | 22 | 87454 | <gh_stars>10-100
; A178890: a(n) = n OR 3n, where OR is bitwise OR.
; 0,3,6,11,12,15,22,23,24,27,30,43,44,47,46,47,48,51,54,59,60,63,86,87,88,91,94,91,92,95,94,95,96,99,102,107,108,111,118,119,120,123,126,171,172,175,174,175,176,179,182,187,188,191,182,183,184,187,190,187,188
mov $1,$0
mul $0,2
seq $1,184617 ; With nonadjacent forms: A184615(n) + A184616(n).
add $0,$1
|
Cubical/Displayed/Record.agda | marcinjangrzybowski/cubical | 301 | 5079 | {-
Generate univalent reflexive graph characterizations for record types from
characterizations of the field types using reflection.
See end of file for an example.
-}
{-# OPTIONS --no-exact-split --safe #-}
module Cubical.Displayed.Record where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Path
open import Cubical.Data.Sigma
open import Cubical.Data.List as List
open import Cubical.Data.Unit
open import Cubical.Data.Bool
open import Cubical.Data.Maybe as Maybe
open import Cubical.Displayed.Base
open import Cubical.Displayed.Properties
open import Cubical.Displayed.Prop
open import Cubical.Displayed.Sigma
open import Cubical.Displayed.Unit
open import Cubical.Displayed.Universe
open import Cubical.Displayed.Auto
import Agda.Builtin.Reflection as R
open import Cubical.Reflection.Base
import Cubical.Reflection.RecordEquiv as RE
{-
`DUAFields`
A collection of DURG characterizations for fields of a record is described by an element of this inductive
family. If you just want to see how to use it, have a look at the end of the file first.
An element of `DUAFields 𝒮-A R _≅R⟨_⟩_ πS 𝒮ᴰ-S πS≅` describes a mapping
- from a structure `R : A → Type _` and notion of structured equivalence `_≅R⟨_⟩_`,
which are meant to be defined as parameterized record types,
- to a DURG `𝒮ᴰ-S`,
the underlying structure of which will be an iterated Σ-type,
- via projections `πS` and `πS≅`.
`𝒮-A`, `R`, and `_≅R⟨_⟩_` are parameters, while `πS`, `𝒮ᴰ-S`, and `πS≅` are indices;
the user builds up the Σ-type representation of the record using the DUAFields constructors.
A DUAFields representation is _total_ when the projections `πS` and `πS≅` are equivalences, in which case we
obtain a DURG on `R` with `_≅R⟨_⟩_` as the notion of structured equivalence---see `𝒮ᴰ-Fields` below.
When `R`, and `_≅R⟨_⟩_` are defined by record types, we can use reflection to automatically generate proofs
`πS` and `πS≅` are equivalences---see `𝒮ᴰ-Record` below.
-}
data DUAFields {ℓA ℓ≅A ℓR ℓ≅R} {A : Type ℓA} (𝒮-A : UARel A ℓ≅A)
(R : A → Type ℓR) (_≅R⟨_⟩_ : {a a' : A} → R a → UARel._≅_ 𝒮-A a a' → R a' → Type ℓ≅R)
: ∀ {ℓS ℓ≅S} {S : A → Type ℓS}
(πS : ∀ {a} → R a → S a) (𝒮ᴰ-S : DUARel 𝒮-A S ℓ≅S)
(πS≅ : ∀ {a} {r : R a} {e} {r' : R a} → r ≅R⟨ e ⟩ r' → DUARel._≅ᴰ⟨_⟩_ 𝒮ᴰ-S (πS r) e (πS r'))
→ Typeω
where
-- `fields:`
-- Base case, no fields yet recorded in `𝒮ᴰ-S`.
fields: : DUAFields 𝒮-A R _≅R⟨_⟩_ (λ _ → tt) (𝒮ᴰ-Unit 𝒮-A) (λ _ → tt)
-- `… data[ πF ∣ 𝒮ᴰ-F ∣ πF≅ ]`
-- Add a new field with a DURG. `πF` should be the name of the field in the structure record `R` and `πF≅`
-- the name of the corresponding field in the equivalence record `_≅R⟨_⟩_`, while `𝒮ᴰ-F` is a DURG for the
-- field's type over `𝒮-A`. Data fields that depend on previous fields of the record are not currently
-- supported.
_data[_∣_∣_] : ∀ {ℓS ℓ≅S} {S : A → Type ℓS}
{πS : ∀ {a} → R a → S a} {𝒮ᴰ-S : DUARel 𝒮-A S ℓ≅S}
{πS≅ : ∀ {a} {r : R a} {e} {r' : R a} → r ≅R⟨ e ⟩ r' → DUARel._≅ᴰ⟨_⟩_ 𝒮ᴰ-S (πS r) e (πS r')}
→ DUAFields 𝒮-A R _≅R⟨_⟩_ πS 𝒮ᴰ-S πS≅
→ ∀ {ℓF ℓ≅F} {F : A → Type ℓF}
(πF : ∀ {a} → (r : R a) → F a)
(𝒮ᴰ-F : DUARel 𝒮-A F ℓ≅F)
(πF≅ : ∀ {a} {r : R a} {e} {r' : R a} (p : r ≅R⟨ e ⟩ r') → DUARel._≅ᴰ⟨_⟩_ 𝒮ᴰ-F (πF r) e (πF r'))
→ DUAFields 𝒮-A R _≅R⟨_⟩_ (λ r → πS r , πF r) (𝒮ᴰ-S ×𝒮ᴰ 𝒮ᴰ-F) (λ p → πS≅ p , πF≅ p)
-- `… prop[ πF ∣ propF ]`
-- Add a new propositional field. `πF` should be the name of the field in the structure record `R`, while
-- propF is a proof that this field is a proposition.
_prop[_∣_] : ∀ {ℓS ℓ≅S} {S : A → Type ℓS}
{πS : ∀ {a} → R a → S a} {𝒮ᴰ-S : DUARel 𝒮-A S ℓ≅S}
{πS≅ : ∀ {a} {r : R a} {e} {r' : R a} → r ≅R⟨ e ⟩ r' → DUARel._≅ᴰ⟨_⟩_ 𝒮ᴰ-S (πS r) e (πS r')}
→ DUAFields 𝒮-A R _≅R⟨_⟩_ πS 𝒮ᴰ-S πS≅
→ ∀ {ℓF} {F : (a : A) → S a → Type ℓF}
(πF : ∀ {a} → (r : R a) → F a (πS r))
(propF : ∀ a s → isProp (F a s))
→ DUAFields 𝒮-A R _≅R⟨_⟩_ (λ r → πS r , πF r) (𝒮ᴰ-subtype 𝒮ᴰ-S propF) (λ p → πS≅ p)
module _ {ℓA ℓ≅A} {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{ℓR ℓ≅R} {R : A → Type ℓR} (_≅R⟨_⟩_ : {a a' : A} → R a → UARel._≅_ 𝒮-A a a' → R a' → Type ℓ≅R)
{ℓS ℓ≅S} {S : A → Type ℓS}
{πS : ∀ {a} → R a → S a} {𝒮ᴰ-S : DUARel 𝒮-A S ℓ≅S}
{πS≅ : ∀ {a} {r : R a} {e} {r' : R a} → r ≅R⟨ e ⟩ r' → DUARel._≅ᴰ⟨_⟩_ 𝒮ᴰ-S (πS r) e (πS r')}
(fs : DUAFields 𝒮-A R _≅R⟨_⟩_ πS 𝒮ᴰ-S πS≅)
where
open UARel 𝒮-A
open DUARel 𝒮ᴰ-S
𝒮ᴰ-Fields :
(e : ∀ a → Iso (R a) (S a))
(e≅ : ∀ a a' (r : R a) p (r' : R a') → Iso (r ≅R⟨ p ⟩ r') ((e a .Iso.fun r ≅ᴰ⟨ p ⟩ e a' .Iso.fun r')))
→ DUARel 𝒮-A R ℓ≅R
DUARel._≅ᴰ⟨_⟩_ (𝒮ᴰ-Fields e e≅) r p r' = r ≅R⟨ p ⟩ r'
DUARel.uaᴰ (𝒮ᴰ-Fields e e≅) r p r' =
isoToEquiv
(compIso
(e≅ _ _ r p r')
(compIso
(equivToIso (uaᴰ (e _ .Iso.fun r) p (e _ .Iso.fun r')))
(invIso (congPathIso λ i → isoToEquiv (e _)))))
module DisplayedRecordMacro where
-- Extract a name from a term
findName : R.Term → R.TC R.Name
findName t =
Maybe.rec
(R.typeError (R.strErr "Not a name: " ∷ R.termErr t ∷ []))
(λ s → s)
(go t)
where
go : R.Term → Maybe (R.TC R.Name)
go (R.meta x _) = just (R.blockOnMeta x)
go (R.def name _) = just (R.returnTC name)
go (R.lam _ (R.abs _ t)) = go t
go t = nothing
-- ℓA ℓ≅A ℓR ℓ≅R A 𝒮-A R _≅R⟨_⟩_
pattern family∷ hole = _ h∷ _ h∷ _ h∷ _ h∷ _ h∷ _ h∷ _ h∷ _ h∷ hole
-- ℓS ℓ≅S S πS 𝒮ᴰ-S πS≅
pattern indices∷ hole = _ h∷ _ h∷ _ h∷ _ h∷ _ h∷ _ h∷ hole
{-
Takes a reflected DUAFields term as input and collects lists of structure field names and equivalence
field names. (These are returned in reverse order.
-}
parseFields : R.Term → R.TC (List R.Name × List R.Name)
parseFields (R.con (quote fields:) _) = R.returnTC ([] , [])
parseFields (R.con (quote _data[_∣_∣_]) (family∷ (indices∷ (fs v∷ ℓF h∷ ℓ≅F h∷ F h∷ πF v∷ 𝒮ᴰ-F v∷ πF≅ v∷ _)))) =
parseFields fs >>= λ (fs , f≅s) →
findName πF >>= λ f →
findName πF≅ >>= λ f≅ →
R.returnTC (f ∷ fs , f≅ ∷ f≅s)
parseFields (R.con (quote _prop[_∣_]) (family∷ (indices∷ (fs v∷ ℓF h∷ F h∷ πF v∷ _)))) =
parseFields fs >>= λ (fs , f≅s) →
findName πF >>= λ f →
R.returnTC (f ∷ fs , f≅s)
parseFields (R.meta x _) = R.blockOnMeta x
parseFields t = R.typeError (R.strErr "Malformed specification: " ∷ R.termErr t ∷ [])
{-
Given a list of record field names (in reverse order), generates a ΣFormat (in the sense of
Cubical.Reflection.RecordEquiv) associating the record fields with the fields of a left-associated
iterated Σ-type
-}
List→LeftAssoc : List R.Name → RE.ΣFormat
List→LeftAssoc [] = RE.unit
List→LeftAssoc (x ∷ xs) = List→LeftAssoc xs RE., RE.leaf x
module _ {ℓA ℓ≅A} {A : Type ℓA} (𝒮-A : UARel A ℓ≅A)
{ℓR ℓ≅R} {R : A → Type ℓR} (≅R : {a a' : A} → R a → UARel._≅_ 𝒮-A a a' → R a' → Type ℓ≅R)
{ℓS ℓ≅S} {S : A → Type ℓS}
{πS : ∀ {a} → R a → S a} {𝒮ᴰ-S : DUARel 𝒮-A S ℓ≅S}
{πS≅ : ∀ {a} {r : R a} {e} {r' : R a} → ≅R r e r' → DUARel._≅ᴰ⟨_⟩_ 𝒮ᴰ-S (πS r) e (πS r')}
where
{-
"𝒮ᴰ-Record ... : DUARel 𝒮-A R ℓ≅R"
Requires that `R` and `_≅R⟨_⟩_` are defined by records and `πS` and `πS≅` are equivalences.
The proofs of equivalence are generated using Cubical.Reflection.RecordEquiv and then
`𝒮ᴰ-Fields` is applied.
-}
𝒮ᴰ-Record : DUAFields 𝒮-A R ≅R πS 𝒮ᴰ-S πS≅ → R.Term → R.TC Unit
𝒮ᴰ-Record fs hole =
R.quoteTC (DUARel 𝒮-A R ℓ≅R) >>= R.checkType hole >>= λ hole →
R.quoteωTC fs >>= λ `fs` →
parseFields `fs` >>= λ (fields , ≅fields) →
R.freshName "fieldsIso" >>= λ fieldsIso →
R.freshName "≅fieldsIso" >>= λ ≅fieldsIso →
R.quoteTC R >>= R.normalise >>= λ `R` →
R.quoteTC {A = {a a' : A} → R a → UARel._≅_ 𝒮-A a a' → R a' → Type ℓ≅R} ≅R >>= R.normalise >>= λ `≅R` →
findName `R` >>= RE.declareRecordIsoΣ' fieldsIso (List→LeftAssoc fields) >>
findName `≅R` >>= RE.declareRecordIsoΣ' ≅fieldsIso (List→LeftAssoc ≅fields) >>
R.unify hole
(R.def (quote 𝒮ᴰ-Fields)
(`≅R` v∷ `fs` v∷
vlam "_" (R.def fieldsIso []) v∷
vlam "a" (vlam "a'" (vlam "r" (vlam "p" (vlam "r'" (R.def ≅fieldsIso []))))) v∷
[]))
macro
𝒮ᴰ-Record = DisplayedRecordMacro.𝒮ᴰ-Record
-- Example
private
module Example where
record Example (A : Type) : Type where
no-eta-equality -- works with or without eta equality
field
dog : A → A → A
cat : A → A → A
mouse : Unit
open Example
record ExampleEquiv {A B : Type} (x : Example A) (e : A ≃ B) (y : Example B) : Type where
no-eta-equality -- works with or without eta equality
field
dogEq : ∀ a a' → e .fst (x .dog a a') ≡ y .dog (e .fst a) (e .fst a')
catEq : ∀ a a' → e .fst (x .cat a a') ≡ y .cat (e .fst a) (e .fst a')
open ExampleEquiv
example : DUARel (𝒮-Univ ℓ-zero) Example ℓ-zero
example =
𝒮ᴰ-Record (𝒮-Univ ℓ-zero) ExampleEquiv
(fields:
data[ dog ∣ autoDUARel _ _ ∣ dogEq ]
data[ cat ∣ autoDUARel _ _ ∣ catEq ]
prop[ mouse ∣ (λ _ _ → isPropUnit) ])
|
oeis/054/A054498.asm | neoneye/loda-programs | 11 | 102231 | ; A054498: Number of symmetric nonnegative integer 8 X 8 matrices with sum of elements equal to 4*n, under action of dihedral group D_4.
; Submitted by <NAME>
; 1,4,16,44,116,260,560,1100,2090,3740,6512,10868,17732,28028,43472,65780,97955,143000,205920,291720,408408,563992,770848,1041352,1394068,1847560,2428960,3165400,4095640,5258440,6708064,8498776,10705189,13401916,16689904,20670100,25477100,31245500,38152400,46374900,56143230,67687620,81304080,97288620,116017980,137868900,163316400,192835500,227019975,266463600,311902656,364073424,423882096,492234864,570239296,659002960,759870760,874187600,1003576640,1149661040,1314388592,1499707088,1707941312
mov $3,$0
mov $5,$0
lpb $3
mov $0,$5
sub $3,1
sub $0,$3
mov $4,$0
add $4,1
mov $9,$0
lpb $4
mov $0,$9
sub $4,1
sub $0,$4
mov $6,$0
mov $8,$0
add $8,1
lpb $8
mov $0,$6
sub $8,1
sub $0,$8
mov $2,$0
seq $2,299338 ; Expansion of 1 / ((1 - x)^7*(1 + x)^6).
add $7,$2
lpe
lpe
lpe
mov $0,$7
add $0,1
|
test/Fail/Issue2684.agda | cruhland/agda | 1,989 | 14232 | -- Andreas, 2017-08-13, issue #2684
-- Better error for abstract constructor.
abstract
data D : Set where
c : D
data E : Set where
c : E
test : D
test = c
-- Expected:
-- Constructor c is abstract, thus, not in scope here
-- when checking that the expression c has type D
|
test/Succeed/strictlypositiveio.agda | shlevy/agda | 2 | 358 | open import Agda.Builtin.IO
open import Agda.Builtin.List
open import Agda.Builtin.Size
open import Agda.Builtin.String
record Thunk (F : Size → Set) (i : Size) : Set where
coinductive
field force : {j : Size< i} → F j
open Thunk public
FilePath = String
-- A directory tree is rooted in the current directory; it comprises:
-- * a list of files in the current directory
-- * an IO action returning a list of subdirectory trees
-- This definition does not typecheck if IO is not marked as strictly positive
data DirectoryTree (i : Size) : Set where
_:<_ : List FilePath → IO (List (Thunk DirectoryTree i)) →
DirectoryTree i
|
ChannelIO/Source/Frameworks/ANTLR/TextBlockParser.g4 | konifar/channel-plugin-ios | 12 | 4107 | parser grammar TextBlockParser;
options { tokenVocab = TextBlockLexer; }
block: (tag | content)* EOF;
tag: LT TAG_NAME (attribute)* GT (tag | content)* LT SLASH TAG_NAME GT;
attribute: TAG_NAME EQUALS STR_BEG attrValue STR_END;
attrValue: (escape | variable | STR_CHAR | STR_ANY | STR_WS)+;
content: (escape | emoji | variable | plain)+;
emoji: EMOJI;
variable: (VAR_BEG | STR_VAR_BEG) VAR_NAME (VAR_BAR variableFallback)? VAR_END;
variableFallback: (escape | VAR_NAME | VAR_UNI | VAR_WS | VAR_ANY)*;
plain: (CHAR | ANY | WS)+;
escape: ESCAPED | STR_ESCAPED | VAR_ESCAPED;
|
code.asm | scarletea/MipsCPU_multi_cycle | 3 | 246019 | <reponame>scarletea/MipsCPU_multi_cycle
# Test File for 7 Instruction, include:
# ADDU/SUBU/LW/SW/ORI/BEQ/JAL
################################################################
### Make sure following Settings :
# Settings -> Memory Configuration -> Compact, Data at address 0
.text
ori $29, $0, 12
ori $2, $0, 0x1234
ori $3, $0, 0x3456
addu $4, $2, $3
subu $6, $3, $4
add $7, $2, $3
sub $8, $3, $4
and $9, $2, $3
or $10, $3, $4
xor $11, $0, $2
nor $12, $13, $1
slt $13, $8, $7
slt $13, $10 , $11
sltu $14, $8, $7
addi $15, $2, 0xf234
addiu $16, $2, 0xf234
andi $17, $2, 0x0004
xori $18, $3, 0x3450
sll $15, $15, 4
srl $16, $16, 4
srlv $15, $15, $17
sllv $16, $16, $17
sw $2, 0($0)
sw $3, 4($0)
sw $4, 4($29)
lw $5, 0($0)
beq $2, $5, _lb2
_lb1:
lw $3, 4($29)
_lb2:
lw $5, 4($0)
beq $3, $5, _lb1
jal F_Test_JAL
F_Test_JAL:
subu $6, $6, $2
sw $6, -4($29)
|
programs/oeis/051/A051503.asm | jmorken/loda | 1 | 677 | ; A051503: a(n) = min { n, floor(100/n) }.
; 1,2,3,4,5,6,7,8,9,10,9,8,7,7,6,6,5,5,5,5,4,4,4,4,4,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
mov $1,$0
add $1,1
mov $3,31
mov $5,15
lpb $0
div $0,$3
add $0,3
add $2,1
add $0,$2
mov $4,4
add $5,$3
mul $5,2
add $5,$0
add $4,$5
div $4,$1
mov $5,$1
trn $5,$4
sub $1,$5
lpe
add $1,1
mul $1,5
sub $1,10
div $1,5
add $1,1
|
Task/Menu/Ada/menu-2.ada | LaudateCorpus1/RosettaCodeData | 1 | 1324 | ./menu2
1 Fee Fie
2 Huff & Puff
3 mirror mirror
4 tick tock
chose (0 to exit) #:2
you chose #:Huff & Puff
1 Fee Fie
2 Huff & Puff
3 mirror mirror
4 tick tock
chose (0 to exit) #:55
Menu selection out of range
1 Fee Fie
2 Huff & Puff
3 mirror mirror
4 tick tock
chose (0 to exit) #:0
Menu selection out of range
[2010-06-09 22:18:25] process terminated successfully (elapsed time: 15.27s)
|
src/Lambda/Delay-monad/Virtual-machine.agda | nad/partiality-monad | 2 | 5886 | <reponame>nad/partiality-monad<filename>src/Lambda/Delay-monad/Virtual-machine.agda
------------------------------------------------------------------------
-- A virtual machine
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
module Lambda.Delay-monad.Virtual-machine where
open import Equality.Propositional
open import Maybe equality-with-J
open import Monad equality-with-J
open import Delay-monad
open import Delay-monad.Monad
open import Lambda.Delay-monad.Interpreter
open import Lambda.Syntax
open import Lambda.Virtual-machine
open Closure Code
mutual
-- A functional semantics for the VM.
exec : ∀ {i} → State → M i Value
exec s with step s
... | continue s′ = laterM (∞exec s′)
... | done v = return v
... | crash = fail
∞exec : ∀ {i} → State → M′ i Value
force (run (∞exec s)) = run (exec s)
|
projects/batfish/src/batfish/grammar/logicblox/LogiQLLexer.g4 | luispedrosa/batfish | 0 | 1314 | lexer grammar LogiQLLexer;
options {
superClass = 'batfish.grammar.BatfishLexer';
}
@header {
package batfish.grammar.logicblox;
}
PREDICATE_SEMANTICS_COMMENT_HEADER
:
'///' -> pushMode(M_PredicateSemantics)
;
ALIAS_ALL
:
'alias_all'
;
BLOCK
:
'block'
;
CLAUSES
:
'clauses'
;
COLON
:
':'
;
COMMA
:
','
;
CONSTRUCTOR
:
'lang:constructor'
;
DOUBLE_LEFT_ARROW
:
'<--'
;
EQUALS
:
'='
;
EXPORT
:
'export'
;
GRAVE
:
'`'
;
LEFT_BRACE
:
'{'
;
LEFT_BRACKET
:
'['
;
LEFT_PAREN
:
'('
;
LINE_COMMENT
:
'//' -> pushMode(M_LineComment), channel(HIDDEN)
;
PERIOD
:
'.'
;
RIGHT_ARROW
:
'->'
;
RIGHT_BRACE
:
'}'
;
RIGHT_BRACKET
:
']'
;
RIGHT_PAREN
:
')'
;
VARIABLE
:
F_LeadingVarChar F_BodyVarChar*
;
WS
:
F_WhitespaceChar+ -> channel (HIDDEN)
;
fragment
F_BodyVarChar
:
[_]
| F_Letter
| F_Digit
;
fragment
F_Digit
:
'0' .. '9'
;
fragment
F_LeadingVarChar
:
'_'
| F_Letter
;
fragment
F_Letter
:
(
'a' .. 'z'
)
|
(
'A' .. 'Z'
)
;
fragment
F_NewlineChar
:
[\r\n]
;
fragment
F_NonNewlineChar
:
~[\r\n]
;
fragment
F_WhitespaceChar
:
[ \t\u000C\r\n]
;
mode M_PredicateSemantics;
M_PredicateSemantics_LINE
:
F_NonNewlineChar+
;
M_PredicatSemantics_NEWLINE
:
F_NewlineChar+ -> popMode
;
mode M_LineComment;
M_LineComment_LINE
:
F_NonNewlineChar* F_NewlineChar+ -> channel (HIDDEN), popMode
;
|
programs/oeis/009/A009117.asm | jmorken/loda | 1 | 28742 | ; A009117: Expansion of e.g.f.: 1/2 + exp(-4*x)/2.
; 1,-2,8,-32,128,-512,2048,-8192,32768,-131072,524288,-2097152,8388608,-33554432,134217728,-536870912,2147483648,-8589934592,34359738368,-137438953472,549755813888,-2199023255552,8796093022208,-35184372088832,140737488355328,-562949953421312,2251799813685248,-9007199254740992
mov $1,109
mov $2,1
lpb $0
sub $0,1
mul $1,$2
mul $1,-2
mov $2,2
lpe
sub $1,3
mul $1,2
sub $1,212
div $1,218
add $1,1
|
asm/getbits.asm | GabrielRavier/Generic-Assembly-Samples | 0 | 179585 | <reponame>GabrielRavier/Generic-Assembly-Samples
global @ASM_getbits@12
segment .text align=16
; Algorithm : /* getbits: get numBits bits from position position */
; unsigned int getbits(unsigned int num, unsigned char position, unsigned int numBits)
; {
; return (num >> (position+1-numBits)) & ~(~0 << numBits);
; }
; Also calling proc is fastcall
%define regNumBits dl
%define result eax
%define number ecx
%define position edx
%define numBits 4
%define temp ecx
%define loTemp cl
%define temp2 edx
@ASM_getbits@12:
mov result, number
sub regNumBits, byte [esp + numBits]
lea temp, [position + 1] ; Discard number
shr result, loTemp
mov temp2, -1 ; Discard position
mov loTemp, byte [esp + numBits]
sal temp2, loTemp
not temp2
and result, temp2
ret 4
|
oeis/077/A077887.asm | neoneye/loda-programs | 11 | 6033 | <reponame>neoneye/loda-programs<filename>oeis/077/A077887.asm
; A077887: Expansion of (1-x)^(-1)/(1+x^2-2*x^3).
; Submitted by <NAME>(s4)
; 1,1,0,2,3,-1,2,8,-3,-3,20,-2,-25,43,22,-92,65,137,-248,-6,523,-489,-534,1536,-443,-2603,3516,1718,-8721,5315,12158,-22756,-1527,47073,-43984,-50126,138131,-37841,-238382,314104,162701,-790867,465508,1116270,-2047241,-185253,4279782,-3909228
add $0,1
lpb $0
sub $0,1
mov $3,$2
add $4,1
add $1,$4
mov $2,$4
mul $2,2
add $3,$2
sub $4,$3
lpe
mov $0,$1
|
programs/oeis/334/A334954.asm | jmorken/loda | 1 | 23820 | ; A334954: a(n) is 1 plus the number of divisors of n.
; 2,3,3,4,3,5,3,5,4,5,3,7,3,5,5,6,3,7,3,7,5,5,3,9,4,5,5,7,3,9,3,7,5,5,5,10,3,5,5,9,3,9,3,7,7,5,3,11,4,7,5,7,3,9,5,9,5,5,3,13,3,5,7,8,5,9,3,7,5,9,3,13,3,5,7,7,5,9,3,11,6,5,3,13,5,5,5,9,3,13,5,7,5,5,5,13,3,7,7,10,3,9,3,9,9,5,3,13,3,9,5,11,3,9,5,7,7,5,5,17,4,5,5,7,5,13,3,9,5,9,3,13,5,5,9,9,3,9,3,13,5,5,5,16,5,5,7,7,3,13,3,9,7,9,5,13,3,5,5,13,5,11,3,7,9,5,3,17,4,9,7,7,3,9,7,11,5,5,3,19,3,9,5,9,5,9,5,7,9,9,3,15,3,5,9,10,3,13,3,13,5,5,5,13,5,5,7,11,5,17,3,7,5,5,5,17,5,5,5,13,5,9,3,13,10,5,3,13,3,9,9,9,3,13,5,7,5,9,3,21,3,7,7,7,7,9,5,9,5,9
mov $6,$0
mov $8,2
lpb $8
clr $0,6
mov $0,$6
sub $8,1
add $0,$8
sub $0,1
lpb $0
mov $1,$0
sub $0,1
add $3,1
div $1,$3
add $5,$1
lpe
mov $1,$5
mov $9,$8
lpb $9
mov $7,$1
sub $9,1
lpe
lpe
lpb $6
mov $6,0
sub $7,$1
lpe
mov $1,$7
add $1,2
|
list-to-string.agda | rfindler/ial | 29 | 6296 | module list-to-string where
open import list
open import string
𝕃-to-string : ∀ {ℓ} {A : Set ℓ} → (f : A → string) → (separator : string) → 𝕃 A → string
𝕃-to-string f sep [] = ""
𝕃-to-string f sep (x1 :: (x2 :: xs)) = (f x1) ^ sep ^ (𝕃-to-string f sep (x2 :: xs))
𝕃-to-string f sep (x1 :: []) = (f x1)
|
Library/Spreadsheet/Spreadsheet/spreadsheetRowColumn.asm | steakknife/pcgeos | 504 | 245214 | <reponame>steakknife/pcgeos
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: spreadsheetColumn.asm
AUTHOR: <NAME>, Aug 27, 1992
ROUTINES:
Name Description
---- -----------
MSG_SPREADSHEET_SET_ROW_HEIGHT
MSG_SPREADSHEET_CHANGE_ROW_HEIGHT
MSG_SPREADSHEET_SET_COLUMN_WIDTH
MSG_SPREADSHEET_CHANGE_COLUMN_WIDTH
INT RecalcRowHeights Recalculate row heights and baseline for
selected rows
INT RecalcRowHeightsInRange Recalculate the row-heights for a range of
rows
INT CalcRowHeight Calculate the row height based on
pointsizes in use
INT FindMaxPointsize Find the maximum pointsize of a row
INT GetColumnsFromParams Get columns to use from message parameters
INT GetRowsFromParams Get rows to use from message parameters
INT GetColumnBestFit Get the best fit for a column
INT CellBestFit Calculate the column width needed for one
cell
REVISION HISTORY:
Name Date Description
---- ---- -----------
Gene 8/27/92 Initial revision
DESCRIPTION:
Routines and method handlers for rows and columns.
$Id: spreadsheetRowColumn.asm,v 1.1 97/04/07 11:13:18 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AttrCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SpreadsheetSetRowHeight
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the row height of the current selection
CALLED BY: MSG_SPREADSHEET_SET_ROW_HEIGHT
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SpreadsheetClass
ax - the method
cx - row height (ROW_HEIGHT_AUTOMATIC or'd for automatic)
dx - SPREADSHEET_ADDRESS_USE_SELECTION or row #
RETURN: none
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
The general rule for the baseline
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 3/10/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SpreadsheetSetRowHeight method dynamic SpreadsheetClass, \
MSG_SPREADSHEET_SET_ROW_HEIGHT
.enter
call SpreadsheetMarkBusy
mov si, di ;ds:si <- ptr to instance data
call GetRowsFromParams ;(ax,cx) <- range of rows
jc done
;
; For each row selected, set the height
;
mov bx, dx
andnf dx, not (ROW_HEIGHT_AUTOMATIC) ;dx <- height
andnf bx, (ROW_HEIGHT_AUTOMATIC) ;bx <- flag
push ax
rowLoop:
call RowSetHeight
inc ax ;ax <- next row
cmp ax, cx ;at end?
jbe rowLoop ;branch while more rows
pop ax
;
; Recalculate the row heights
;
call RecalcRowHeightsInRange
;
; Recalcuate the document size for the view, update the UI,
; and redraw
;
mov ax, mask SNF_CELL_WIDTH_HEIGHT
call UpdateDocUIRedrawAll
done:
call SpreadsheetMarkNotBusy
.leave
ret
SpreadsheetSetRowHeight endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SpreadsheetChangeRowHeight
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change height of a row
CALLED BY: MSG_SPREADSHEET_CHANGE_ROW_HEIGHT
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SpreadsheetClass
ax - the message
cx - change in row height
dx - SPREADSHEET_ADDRESS_USE_SELECTION or row #
RETURN:
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 7/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SpreadsheetChangeRowHeight method dynamic SpreadsheetClass, \
MSG_SPREADSHEET_CHANGE_ROW_HEIGHT
call SpreadsheetMarkBusy
mov si, di ;ds:si <- ptr to spreadsheet
mov bp, cx ;bp <- change in height
call GetRowsFromParams ;(ax,cx) <- range of rows
jc done
;
; For each row, change the height
;
clr bx ;bx <- no baseline
push ax
rowLoop:
call RowGetHeightFar ;dx <- current height
add dx, bp ;dx <- new height
call RowSetHeight
inc ax ;ax <- next row
cmp ax, cx ;at end?
jbe rowLoop
pop ax
;
; Recalculate the row heights
;
call RecalcRowHeightsInRange
;
; Recalculate the document size for the view, update the UI,
; and redraw
;
mov ax, mask SNF_CELL_WIDTH_HEIGHT
call UpdateDocUIRedrawAll
done:
call SpreadsheetMarkNotBusy
ret
SpreadsheetChangeRowHeight endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RecalcRowHeights
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Recalculate row heights and baseline for selected rows
CALLED BY: SpreadsheetSetRowHeight(), SpreadsheetSetPointsize()
PASS: ds:si - ptr to Spreadsheet instance
RETURN: none
DESTROYED: ax, bx, cx, dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 3/22/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RecalcRowHeightsFar proc far
class SpreadsheetClass
.enter
EC < call ECCheckInstancePtr ;>
;
; For each selected row, see if we should recalculate
; the height based on the pointsize change.
;
mov ax, ds:[si].SSI_selected.CR_start.CR_row
mov cx, ds:[si].SSI_selected.CR_end.CR_row
call RecalcRowHeightsInRange
.leave
ret
RecalcRowHeightsFar endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RecalcRowHeightsInRange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Recalculate the row-heights for a range of rows.
CALLED BY: RecalcRowHeights, SpreadsheetInsertSpace
PASS: ds:si = Spreadsheet instance
ax = Top row of range
cx = Bottom row of range
RETURN: nothing
DESTROYED: bx, cx, dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 7/12/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RecalcRowHeightsInRange proc far
uses di
.enter
EC < call ECCheckInstancePtr ;>
sub cx, ax
inc cx ;cx <- # of rows to set
rowLoop:
call RowGetBaseline ;bx <- baseline and flag
test dx, ROW_HEIGHT_AUTOMATIC ;automatic height?
jz manualHeight ;branch if manual
call CalcRowHeight ;calculate row height
ornf bx, ROW_HEIGHT_AUTOMATIC ;bx <- set as automatic
setHeight:
call RowSetHeight
inc ax ;ax <- next row
loop rowLoop
.leave
ret
;
; The row height is marked as manual. We still
; need to calculate the baseline, but the height
; remains unchanged.
;
manualHeight:
push ax
call RowGetHeightFar ;dx <- current row height
push dx
call CalcRowHeight ;bx <- baseline
mov ax, dx ;ax <- calculated height
pop dx ;dx <- current row height
add bx, dx ;bx <- baseline = baseline
sub bx, ax ; + (height - calculated)
pop ax
jns setHeight ;baseline above bottom
; of cell?
clr bx ;if not, Sbaseline = 0
jmp setHeight
RecalcRowHeightsInRange endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CalcRowHeight
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Calculate the row height based on pointsizes in use
CALLED BY: SpreadsheetSetRowHeight()
PASS: ds:si - ptr to Spreadsheet instance data
ax - row #
RETURN: dx - new row height
bx - new baseline offset
DESTROYED: bx, dx, di
PSEUDO CODE/STRATEGY:
row_height = MAX(pointsize) * 1.25
baseline = MAX(pointsize) - 1
NOTE: in order to include pointsize in the optimizations used
for setting attributes on an entire column, this routine will
need to change a fair amount...
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 3/11/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CalcRowHeight proc near
uses ax, cx, es
class SpreadsheetClass
locals local CellLocals
.enter
EC < call ECCheckInstancePtr ;>
mov bx, ax
mov cx, MIN_ROW
mov dx, ds:[si].SSI_maxCol ;(ax,bx,cx,dx) <- range to enum
mov ss:locals.CL_data1, cx ;pass data word #1
clr di ;di <- RangeEnumFlags
mov ss:locals.CL_data2, di ;pass data word #2
mov ss:locals.CL_params.REP_callback.segment, SEGMENT_CS
mov ss:locals.CL_params.REP_callback.offset, offset FindMaxPointsize
call CallRangeEnum ;ax <- max pointsize * 8
;
; See if all cells had data. If not, we need to take into account
; the default pointsize, as that is what empty cells have.
;
cmp ss:locals.CL_data2, dx ;all cells have data?
je noEmptyCells ;branch if all cells filled
mov ax, DEFAULT_STYLE_TOKEN ;ax <- style to get
mov bx, offset CA_pointsize ;bx <- CellAttrs field
call StyleGetAttrByTokenFar ;ax <- pointsize
cmp ax, ss:locals.CL_data1 ;larger than maximum?
ja defaultIsMax ;branch if new maximum
noEmptyCells:
mov ax, ss:locals.CL_data1 ;ax <- (pointsize * 8)
defaultIsMax:
mov dx, ax ;dx <- (pointsize * 8)
mov bx, ax
shr bx, 1
shr bx, 1 ;bx <- (pointsize * 8) / 4
add dx, bx ;dx <- (pointsize * 8) * 1.25
dec ax ;ax <- pointsize - 1
mov bx, ax ;bx <- pointsize - 1
shr dx, 1
shr dx, 1
shr dx, 1 ;dx <- new row height
shr bx, 1
shr bx, 1
shr bx, 1 ;bx <- new baseline
.leave
ret
CalcRowHeight endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FindMaxPointsize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Find the maximum pointsize of a row.
CALLED BY: CalcRowHeight() via RangeEnum()
PASS: (ax,cx) - current cell (r,c)
bx - handle of file
ss:bp - ptr to CellLocals variables
CL_data1 - maximum pointsize
CL_data2 - # of cells called back for
*es:di - ptr to cell data, if any
ds:si - ptr to Spreadsheet instance
carry - set if cell has data
RETURN: carry - set to abort enumeration
CL_data1 - (new) maximum pointsize
CL_data2 - # of cells, updated
DESTROYED: dh
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 3/12/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FindMaxPointsize proc far
uses ax, bx, cx, dx, si, di, ds, es
locals local CellLocals
.enter inherit
EC < ERROR_NC BAD_CALLBACK_FOR_EMPTY_CELL ;>
EC < call ECCheckInstancePtr ;>
mov di, es:[di] ;es:di <- ptr to cell
mov ax, es:[di].CC_attrs ;ax <- style token
segmov es, ss
lea di, ss:locals.CL_cellAttrs ;es:di <- ptr to style buffer
call StyleGetStyleByTokenFar
mov ax, ss:locals.CL_cellAttrs.CA_pointsize
cmp ax, ss:locals.CL_data1 ;larger pointsize?
jbe notBigger
mov ss:locals.CL_data1, ax ;store new maximum pointsize
notBigger:
clc ;carry <- don't abort
.leave
ret
FindMaxPointsize endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SpreadsheetSetColumnWidth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the column width for selected columns
CALLED BY: MSG_SPREADSHEET_SET_COLUMN_WIDTH
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SpreadsheetClass
ax - the method
cx - column width
COLUMN_WIDTH_BEST_FIT - OR'ed for best fit
dx - SPREADSHEET_ADDRESS_USE_SELECTION or row #
RETURN: none
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 3/22/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SpreadsheetSetColumnWidth method dynamic SpreadsheetClass, \
MSG_SPREADSHEET_SET_COLUMN_WIDTH
.enter
call SpreadsheetMarkBusy
mov si, di ;ds:si <- ptr to instance
call GetColumnsFromParams ;(cx,ax) <- columns
jc done
test dx, COLUMN_WIDTH_BEST_FIT
jnz getBestFit
RoundToByte dx ;dx <- round to byte multiple
;
; HACK: if the rounding the new column will give the current column
; width, send out bogus notification with the unrounded column width
; so that when we send out notification with the rounded column
; width, the GCN list mechanism won't ignore it because the new column
; width notification is the same as the current column width
; notification. We want the new column width notification to occur
; because the column width controller is still display the unrounded
; column width that the user just entered - brianc 10/11/94
; dx = new rounded column width
;
mov bx, dx ;bx = new rounded column width
call ColumnGetWidthFar ;dx = current width
xchg bx, dx ;dx = new rounded column width
;bx = current width
cmp bx, dx ;same?
jne columnLoop ;nope, notification will work
call SS_SendNotificationBogusWidth ;else, send bogus notif first
columnLoop:
call ColumnSetWidth
inc cx ;cx <- next column
cmp cx, ax ;end of selection?
jbe columnLoop ;branch while more columns
;
; Recalcuate the document size for the view, update the UI,
; and redraw
;
doneColumns:
mov ax, mask SNF_CELL_WIDTH_HEIGHT
call UpdateDocUIRedrawAll
done:
call SpreadsheetMarkNotBusy
.leave
ret
;
; Find the width of all the strings in the column and set the
; width based on them.
;
getBestFit:
call GetColumnBestFit
cmp dx, 0 ;no data?
je noData ;branch if no data
add dx, 7 ;dx <- always round up
RoundToByte dx ;dx <- round to byte multiple
cmp dx, SS_COLUMN_WIDTH_MAX ;width too large?
jbe widthOK ;branch if OK
mov dx, SS_COLUMN_WIDTH_MAX ;dx <- set to maximum width
widthOK:
call ColumnSetWidth
inc cx ;cx <- next column
cmp cx, ax ;end of selection?
jbe getBestFit
jmp doneColumns
;
; The column had no data -- set the width to the default
;
noData:
mov dx, COLUMN_WIDTH_DEFAULT
jmp widthOK
SpreadsheetSetColumnWidth endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SpreadsheetChangeColumnWidth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make the selected columns wider/narrower
CALLED BY: MSG_SPREADSHEET_CHANGE_COLUMN_WIDTH
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SpreadsheetClass
ax - the method
cx - change in column widths
dx - SPREADSHEET_ADDRESS_USE_SELECTION or column #
RETURN: none
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 3/22/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SpreadsheetChangeColumnWidth method dynamic SpreadsheetClass, \
MSG_SPREADSHEET_CHANGE_COLUMN_WIDTH
.enter
call SpreadsheetMarkBusy
mov bx, cx ;bx <- delta for widths
mov si, di ;ds:si <- ptr to instance
call GetColumnsFromParams ;(cx,ax) <- columns to use
jc done
columnLoop:
;
; bx = Amount to change the column width by.
;
call ColumnGetWidthFar ;dx <- column width
add dx, bx ;dx <- new column width
;
; Make sure that the column isn't too narrow/wide.
;
jns notTooNarrow ;branch if not too negative
clr dx ;new width
notTooNarrow:
cmp dx, SS_COLUMN_WIDTH_MAX ;check for too wide
jbe notTooWide ;branch if not too wide
mov dx, SS_COLUMN_WIDTH_MAX ;new width
notTooWide:
RoundToByte dx ;dx <- round to byte multiple
;
; dx = new column width.
;
call ColumnSetWidth ;set new width
inc cx ;cx <- next column
cmp cx, ax ;end of selection?
jbe columnLoop ;branch while more columns
;
; Recalcuate the document size for the view, update the UI,
; and redraw
;
mov ax, mask SNF_CELL_WIDTH_HEIGHT
call UpdateDocUIRedrawAll
done:
call SpreadsheetMarkNotBusy
.leave
ret
SpreadsheetChangeColumnWidth endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetColumnsFromParams
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get columns to use from message parameters
CALLED BY: UTILITY
PASS: ds:si - ptr to Spreadsheet instance
dx - SPREADSHEET_ADDRESS_USE_SELECTION or column #
RETURN: dx - old cx
cx - start column
ax - end column
carry SET if column range invalid
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 7/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetColumnsFromParams proc near
class SpreadsheetClass
uses bx
.enter
push cx
;
; Assume using the passed column
;
mov cx, dx ;cx <- start column
mov ax, dx ;ax <- end column
cmp ax, SPREADSHEET_ADDRESS_USE_SELECTION
jne done
;
; Use current selection
;
mov cx, ds:[si].SSI_selected.CR_start.CR_column
mov ax, ds:[si].SSI_selected.CR_end.CR_column
done:
pop dx ;dx <- old cx
xchg ax, cx
mov bx, offset SDO_rowCol.CR_column
call CheckMinRowOrColumn
xchg ax, cx
.leave
ret
GetColumnsFromParams endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetRowsFromParams
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get rows to use from message parameters
CALLED BY: UTILITY
PASS: ds:si - ptr to Spreadsheet instance
dx - SPREADSHEET_ADDRESS_USE_SELECTION or row #
RETURN: dx - old cx
ax - start row
cx - end row
carry SET if range invalid
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 7/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetRowsFromParams proc near
class SpreadsheetClass
uses bx
.enter
push cx
;
; Assume using the passed row
;
mov ax, dx ;ax <- start row
mov cx, dx ;cx <- end row
cmp ax, SPREADSHEET_ADDRESS_USE_SELECTION
jne done
;
; Use current selection
;
mov ax, ds:[si].SSI_selected.CR_start.CR_row
mov cx, ds:[si].SSI_selected.CR_end.CR_row
done:
pop dx ;dx <- old cx
mov bx, offset SDO_rowCol.CR_row
call CheckMinRowOrColumn
.leave
ret
GetRowsFromParams endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckMinRowOrColumn
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check the passed pair of rows or columns against the
spreadsheet's minimum
CALLED BY: GetRowsFromParams, GetColumnsFromParams
PASS: (ax, cx) - min, max pair
bx - offset to vardata to check
ds:si - pointer to spreadsheet instance data
RETURN: if range invalid:
carry SET
else:
ax - fixed up if necessary
DESTROYED: bx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 12/ 1/94 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckMinRowOrColumn proc near
class SpreadsheetClass
uses si
.enter
test ds:[si].SSI_flags, mask SF_NONZERO_DOC_ORIGIN
jz checkZero
push ax, bx ; offset to vardata field
mov si, ds:[si].SSI_chunk
mov ax, TEMP_SPREADSHEET_DOC_ORIGIN
call ObjVarFindData
pop ax, si
jnc checkZero
mov bx, ds:[bx][si] ; min row or column
checkMin:
cmp cx, bx
stc
jl done ; entire range is bad
cmp ax, bx
jg done
;
; Beginning of range needs to be moved up
;
mov ax, bx
done:
.leave
ret
checkZero:
clr bx
jmp checkMin
CheckMinRowOrColumn endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetColumnBestFit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the best fit for a column
CALLED BY: SpreadsheetSetColumnWidth()
PASS: ds:si - ptr to Spreadsheet instance
cx - column #
RETURN: dx - best column width
DESTROYED: bx, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 8/27/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetColumnBestFit proc near
uses ax
class SpreadsheetClass
locals local CellLocals
.enter
clr ax
mov bx, ds:[si].SSI_maxRow
mov dx, cx ;(ax,cx),(bx,dx) <- range
call CreateGStateFar
mov ss:locals.CL_gstate, di ;pass GState
mov ss:locals.CL_params.REP_callback.segment, SEGMENT_CS
mov ss:locals.CL_params.REP_callback.offset, offset CellBestFit
clr ss:locals.CL_data1 ;<- maximum width so far
clr di ;di <- RangeEnumFlags
call CallRangeEnum
;
; Return the maximum we found
;
mov dx, ss:locals.CL_data1 ;dx <- maximum width found
call DestroyGStateFar
.leave
ret
GetColumnBestFit endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CellBestFit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Calculate the column width needed for one cell
CALLED BY: GetColumnBestFit() via RangeEnum()
PASS: ss:bp - ptr to CallRangeEnum() local variables
ds:si - ptr to SpreadsheetInstance data
(ax,cx) - cell coordinates (r,c)
carry - set if cell has data
*es:di - ptr to cell data, if any
CL_data1 - maximum width so far
RETURN: carry - set to abort enum
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 8/27/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SizeBadCellType proc near
EC < ERROR ILLEGAL_CELL_TYPE >
NEC < ret >
SizeBadCellType endp
cellSizeRoutines nptr \
SizeTextCell, ;CT_TEXT
SizeConstantCell, ;CT_CONSTANT
SizeFormulaCell, ;CT_FORMULA
SizeBadCellType, ;CT_NAME
SizeBadCellType, ;CT_CHART
SizeBadCellType, ;CT_EMPTY
SizeDisplayFormulaCell ;CT_DISPLAY_FORMULA
CheckHack <(size cellSizeRoutines) eq CellType>
CellBestFit proc far
uses ax, bx, cx, dx, si, di, ds, es
locals local CellLocals
.enter inherit
EC < ERROR_NC BAD_CALLBACK_FOR_EMPTY_CELL ;>
mov bx, ss:locals.CL_gstate ;bx <- GState to draw with
xchg bx, di ;*es:bx <- ptr to cell data
;di <- GState to use
;
; Set up the GState based on the current cell attributes
;
mov bx, es:[bx] ;es:bx <- ptr to cell data
mov dx, es:[bx].CC_attrs ;dx <- cell style attrs
call SetCellGStateAttrsFar ;setup GState, locals correctly
;
; Get a pointer to the cell data and the type
;
mov dx, bx ;es:dx <- ptr to cell data
mov bl, es:[bx].CC_type
cmp bl, CT_EMPTY ;no data?
je done ;branch if empty
clr bh ;bx <- cell type
;
; Get the data in text format
;
call cs:cellSizeRoutines[bx] ;ds:si <- ptr to text
;
; Get the width of the text string, and see if it is a new largest value
;
clr cx ;cx <- text is NULL terminated
call GrTextWidth ;dx <- width
add dx, (CELL_INSET)*2
cmp dx, ss:locals.CL_data1 ;largest so far?
jbe done ;branch if not largest
mov ss:locals.CL_data1, dx ;store new largest
done:
clc ;carry <- don't abort
.leave
ret
CellBestFit endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SizeTextCell
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get text for a text cell for calculating size
CALLED BY: CellBestFit()
PASS: es:dx - ptr to cell data
RETURN: ds:si - ptr text string
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 8/27/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SizeTextCell proc near
.enter
segmov ds, es
mov si, dx ;ds:si <- ptr to cell data
add si, (size CellText) ;ds:si <- ptr to string
.leave
ret
SizeTextCell endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SizeConstantCell
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get text for a constant cell
CALLED BY: CellBestFit()
PASS: es:dx - ptr to cell data
ds:si - ptr to Spreadsheet instance
ss:bp - inherited CellLocals
RETURN: ds:si - ptr to text string
DESTROYED: ax, bx, cx, es
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 8/27/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SizeConstantCell proc near
class SpreadsheetClass
uses di
locals local CellLocals
.enter inherit
mov bx, ds:[si].SSI_cellParams.CFP_file
mov cx, ds:[si].SSI_formatArray
segmov ds, es, ax
mov si, dx
add si, offset CC_current ;ds:si <- ptr to float number
segmov es, ss, ax
lea di, ss:locals.CL_buffer ;es:di <- ptr to the buffer
mov ax, ss:locals.CL_cellAttrs.CA_format
call FloatFormatNumber ;convert to ASCII
segmov ds, ss
mov si, di ;ds:si <- ptr to result string
.leave
ret
SizeConstantCell endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SizeFormulaCell
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get text for a formula cell
CALLED BY: CellBestFit()
PASS: es:dx - ptr to cell data
(ax,cx) - (r,c) of cell
ds:si - ptr to Spreadsheet instance
ss:bp - inherited CellLocals
RETURN: ds:si - ptr to text string
DESTROYED: ax, bx, cx, dx, es
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 8/27/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SizeFormulaCell proc near
uses di, bp
locals local CellLocals
.enter inherit
lea di, ss:locals.CL_buffer ;ss:di <- ptr to dest buffer
mov bp, dx ;dx:bp <- ptr to cell data
mov dx, es
segmov es, ss ;es:di <- ptr to dest buffer
call FormulaCellGetResult
segmov ds, es, si
mov si, di ;ds:si <- ptr to text
.leave
ret
SizeFormulaCell endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SizeDisplayFormulaCell
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get text for a display formula cell
CALLED BY: CellBestFit()
PASS: es:dx - ptr to cell data
(ax,cx) - (r,c) of cell
ds:si - ptr to Spreadsheet instance
ss:bp - inherited CellLocals
RETURN: ds:si - ptr to text string
DESTROYED: ax, bx, cx, dx, es
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 8/27/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SizeDisplayFormulaCell proc near
uses di, bp
locals local CellLocals
.enter inherit
lea di, ss:locals.CL_buffer ;ss:di <- ptr to dest buffer
mov bp, dx ;dx:bp <- ptr to cell data
mov dx, es
segmov es, ss ;es:di <- ptr to dest buffer
call FormulaDisplayCellGetResult
segmov ds, es, si
mov si, di ;ds:si <- ptr to text
.leave
ret
SizeDisplayFormulaCell endp
AttrCode ends
|
src/Equivalence/Erased/Contractible-preimages.agda | nad/equality | 3 | 16082 | <reponame>nad/equality
------------------------------------------------------------------------
-- Equivalences with erased "proofs", defined in terms of partly
-- erased contractible fibres
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Equivalence.Erased.Contractible-preimages
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open Derived-definitions-and-properties eq
open import Prelude
open import Bijection eq using (_↔_)
open import Equivalence eq as Eq using (_≃_; Is-equivalence)
import Equivalence.Contractible-preimages eq as CP
open import Erased.Level-1 eq as Erased
hiding (module []-cong; module []-cong₁; module []-cong₂)
open import Function-universe eq hiding (id; _∘_)
open import H-level eq as H-level
open import H-level.Closure eq
open import Preimage eq as Preimage using (_⁻¹_)
open import Surjection eq using (_↠_; Split-surjective)
private
variable
a b ℓ ℓ₁ ℓ₂ : Level
A B : Type a
c ext k k′ p x y : A
P : A → Type p
f : (x : A) → P x
------------------------------------------------------------------------
-- Some basic types
-- "Preimages" with erased proofs.
infix 5 _⁻¹ᴱ_
_⁻¹ᴱ_ : {A : Type a} {@0 B : Type b} → @0 (A → B) → @0 B → Type (a ⊔ b)
f ⁻¹ᴱ y = ∃ λ x → Erased (f x ≡ y)
-- Contractibility with an erased proof.
Contractibleᴱ : Type ℓ → Type ℓ
Contractibleᴱ A = ∃ λ (x : A) → Erased (∀ y → x ≡ y)
-- The property of being an equivalence (with erased proofs).
Is-equivalenceᴱ : {A : Type a} {B : Type b} → @0 (A → B) → Type (a ⊔ b)
Is-equivalenceᴱ f = ∀ y → Contractibleᴱ (f ⁻¹ᴱ y)
-- Equivalences with erased proofs.
_≃ᴱ_ : Type a → Type b → Type (a ⊔ b)
A ≃ᴱ B = ∃ λ (f : A → B) → Is-equivalenceᴱ f
------------------------------------------------------------------------
-- Some conversion lemmas
-- Conversions between _⁻¹_ and _⁻¹ᴱ_.
⁻¹→⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} {@0 y : B} →
f ⁻¹ y → f ⁻¹ᴱ y
⁻¹→⁻¹ᴱ = Σ-map id [_]→
@0 ⁻¹ᴱ→⁻¹ : f ⁻¹ᴱ x → f ⁻¹ x
⁻¹ᴱ→⁻¹ = Σ-map id erased
@0 ⁻¹≃⁻¹ᴱ : f ⁻¹ y ≃ f ⁻¹ᴱ y
⁻¹≃⁻¹ᴱ {f = f} {y = y} =
(∃ λ x → f x ≡ y) ↝⟨ (∃-cong λ _ → Eq.inverse $ Eq.↔⇒≃ $ erased Erased↔) ⟩□
(∃ λ x → Erased (f x ≡ y)) □
_ : _≃_.to ⁻¹≃⁻¹ᴱ p ≡ ⁻¹→⁻¹ᴱ p
_ = refl _
@0 _ : _≃_.from ⁻¹≃⁻¹ᴱ p ≡ ⁻¹ᴱ→⁻¹ p
_ = refl _
-- Conversions between Contractible and Contractibleᴱ.
Contractible→Contractibleᴱ :
{@0 A : Type a} →
Contractible A → Contractibleᴱ A
Contractible→Contractibleᴱ = Σ-map id [_]→
@0 Contractibleᴱ→Contractible : Contractibleᴱ A → Contractible A
Contractibleᴱ→Contractible = Σ-map id erased
@0 Contractible≃Contractibleᴱ :
Contractible A ≃ Contractibleᴱ A
Contractible≃Contractibleᴱ =
(∃ λ x → ∀ y → x ≡ y) ↝⟨ (∃-cong λ _ → Eq.inverse $ Eq.↔⇒≃ $ erased Erased↔) ⟩□
(∃ λ x → Erased (∀ y → x ≡ y)) □
_ :
_≃_.to Contractible≃Contractibleᴱ c ≡ Contractible→Contractibleᴱ c
_ = refl _
@0 _ :
_≃_.from Contractible≃Contractibleᴱ c ≡ Contractibleᴱ→Contractible c
_ = refl _
-- Conversions between CP.Is-equivalence and Is-equivalenceᴱ.
Is-equivalence→Is-equivalenceᴱ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} →
CP.Is-equivalence f → Is-equivalenceᴱ f
Is-equivalence→Is-equivalenceᴱ eq y =
⁻¹→⁻¹ᴱ (proj₁₀ (eq y))
, [ cong ⁻¹→⁻¹ᴱ ∘ proj₂ (eq y) ∘ ⁻¹ᴱ→⁻¹ ]
@0 Is-equivalenceᴱ→Is-equivalence :
Is-equivalenceᴱ f → CP.Is-equivalence f
Is-equivalenceᴱ→Is-equivalence eq y =
⁻¹ᴱ→⁻¹ (proj₁ (eq y))
, cong ⁻¹ᴱ→⁻¹ ∘ erased (proj₂ (eq y)) ∘ ⁻¹→⁻¹ᴱ
private
-- In an erased context CP.Is-equivalence and Is-equivalenceᴱ are
-- pointwise equivalent (assuming extensionality).
--
-- This lemma is not exported. See Is-equivalence≃Is-equivalenceᴱ
-- below, which computes in a different way.
@0 Is-equivalence≃Is-equivalenceᴱ′ :
{A : Type a} {B : Type b} {f : A → B} →
CP.Is-equivalence f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalenceᴱ f
Is-equivalence≃Is-equivalenceᴱ′ {a = a} {f = f} {k = k} ext =
(∀ y → Contractible (f ⁻¹ y)) ↝⟨ (∀-cong ext′ λ _ → H-level-cong ext 0 ⁻¹≃⁻¹ᴱ) ⟩
(∀ y → Contractible (f ⁻¹ᴱ y)) ↝⟨ (∀-cong ext′ λ _ → from-isomorphism Contractible≃Contractibleᴱ) ⟩□
(∀ y → Contractibleᴱ (f ⁻¹ᴱ y)) □
where
ext′ = lower-extensionality? k a lzero ext
------------------------------------------------------------------------
-- Some type formers are propositional in erased contexts
-- In an erased context Contractibleᴱ is propositional (assuming
-- extensionality).
@0 Contractibleᴱ-propositional :
{A : Type a} →
Extensionality a a →
Is-proposition (Contractibleᴱ A)
Contractibleᴱ-propositional ext =
H-level.respects-surjection
(_≃_.surjection Contractible≃Contractibleᴱ)
1
(Contractible-propositional ext)
-- In an erased context Is-equivalenceᴱ f is a proposition (assuming
-- extensionality).
--
-- See also Is-equivalenceᴱ-propositional-for-Erased below.
@0 Is-equivalenceᴱ-propositional :
{A : Type a} {B : Type b} →
Extensionality (a ⊔ b) (a ⊔ b) →
(f : A → B) → Is-proposition (Is-equivalenceᴱ f)
Is-equivalenceᴱ-propositional ext f =
H-level.respects-surjection
(_≃_.surjection $ Is-equivalence≃Is-equivalenceᴱ′ ext)
1
(CP.propositional ext f)
------------------------------------------------------------------------
-- More conversion lemmas
-- In an erased context CP.Is-equivalence and Is-equivalenceᴱ are
-- pointwise equivalent (assuming extensionality).
@0 Is-equivalence≃Is-equivalenceᴱ :
{A : Type a} {B : Type b} {f : A → B} →
CP.Is-equivalence f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalenceᴱ f
Is-equivalence≃Is-equivalenceᴱ {k = equivalence} ext =
Eq.with-other-function
(Eq.with-other-inverse
(Is-equivalence≃Is-equivalenceᴱ′ ext)
Is-equivalenceᴱ→Is-equivalence
(λ _ → CP.propositional ext _ _ _))
Is-equivalence→Is-equivalenceᴱ
(λ _ → Is-equivalenceᴱ-propositional ext _ _ _)
Is-equivalence≃Is-equivalenceᴱ = Is-equivalence≃Is-equivalenceᴱ′
_ :
_≃_.to (Is-equivalence≃Is-equivalenceᴱ ext) p ≡
Is-equivalence→Is-equivalenceᴱ p
_ = refl _
@0 _ :
_≃_.from (Is-equivalence≃Is-equivalenceᴱ ext) p ≡
Is-equivalenceᴱ→Is-equivalence p
_ = refl _
-- Conversions between CP._≃_ and _≃ᴱ_.
≃→≃ᴱ :
{@0 A : Type a} {@0 B : Type b} →
A CP.≃ B → A ≃ᴱ B
≃→≃ᴱ = Σ-map id Is-equivalence→Is-equivalenceᴱ
@0 ≃ᴱ→≃ : A ≃ᴱ B → A CP.≃ B
≃ᴱ→≃ = Σ-map id Is-equivalenceᴱ→Is-equivalence
-- In an erased context CP._≃_ and _≃ᴱ_ are pointwise equivalent
-- (assuming extensionality).
@0 ≃≃≃ᴱ :
{A : Type a} {B : Type b} →
(A CP.≃ B) ↝[ a ⊔ b ∣ a ⊔ b ] (A ≃ᴱ B)
≃≃≃ᴱ {A = A} {B = B} ext =
A CP.≃ B ↔⟨⟩
(∃ λ f → CP.Is-equivalence f) ↝⟨ (∃-cong λ _ → Is-equivalence≃Is-equivalenceᴱ ext) ⟩
(∃ λ f → Is-equivalenceᴱ f) ↔⟨⟩
A ≃ᴱ B □
_ : _≃_.to (≃≃≃ᴱ ext) p ≡ ≃→≃ᴱ p
_ = refl _
@0 _ : _≃_.from (≃≃≃ᴱ ext) p ≡ ≃ᴱ→≃ p
_ = refl _
-- An isomorphism relating _⁻¹ᴱ_ to _⁻¹_.
Erased-⁻¹ᴱ↔Erased-⁻¹ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} {@0 y : B} →
Erased (f ⁻¹ᴱ y) ↔ Erased (f ⁻¹ y)
Erased-⁻¹ᴱ↔Erased-⁻¹ {f = f} {y = y} =
Erased (∃ λ x → Erased (f x ≡ y)) ↝⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased (Erased (f (erased x) ≡ y))) ↝⟨ (∃-cong λ _ → Erased-Erased↔Erased) ⟩
(∃ λ x → Erased (f (erased x) ≡ y)) ↝⟨ inverse Erased-Σ↔Σ ⟩□
Erased (∃ λ x → f x ≡ y) □
-- An isomorphism relating Contractibleᴱ to Contractible.
Erased-Contractibleᴱ↔Erased-Contractible :
{@0 A : Type a} →
Erased (Contractibleᴱ A) ↔ Erased (Contractible A)
Erased-Contractibleᴱ↔Erased-Contractible =
Erased (∃ λ x → Erased (∀ y → x ≡ y)) ↝⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased (Erased (∀ y → erased x ≡ y))) ↝⟨ (∃-cong λ _ → Erased-Erased↔Erased) ⟩
(∃ λ x → Erased (∀ y → erased x ≡ y)) ↝⟨ inverse Erased-Σ↔Σ ⟩□
Erased (∃ λ x → ∀ y → x ≡ y) □
------------------------------------------------------------------------
-- Some results related to Contractibleᴱ
-- Contractibleᴱ respects split surjections with erased proofs.
Contractibleᴱ-respects-surjection :
{@0 A : Type a} {@0 B : Type b}
(f : A → B) → @0 Split-surjective f →
Contractibleᴱ A → Contractibleᴱ B
Contractibleᴱ-respects-surjection {A = A} {B = B} f s h@(x , _) =
f x
, [ proj₂ (H-level.respects-surjection surj 0
(Contractibleᴱ→Contractible h))
]
where
@0 surj : A ↠ B
surj = record
{ logical-equivalence = record
{ to = f
; from = proj₁ ∘ s
}
; right-inverse-of = proj₂ ∘ s
}
-- "Preimages" (with erased proofs) of an erased function with a
-- quasi-inverse with erased proofs are contractible.
Contractibleᴱ-⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type b}
(@0 f : A → B)
(g : B → A)
(@0 f∘g : ∀ x → f (g x) ≡ x)
(@0 g∘f : ∀ x → g (f x) ≡ x) →
∀ y → Contractibleᴱ (f ⁻¹ᴱ y)
Contractibleᴱ-⁻¹ᴱ {A = A} {B = B} f g f∘g g∘f y =
(g y , [ proj₂ (proj₁ c′) ])
, [ cong ⁻¹→⁻¹ᴱ ∘ proj₂ c′ ∘ ⁻¹ᴱ→⁻¹ ]
where
@0 A↔B : A ↔ B
A↔B = record
{ surjection = record
{ logical-equivalence = record
{ to = f
; from = g
}
; right-inverse-of = f∘g
}
; left-inverse-of = g∘f
}
@0 c′ : Contractible (f ⁻¹ y)
c′ = Preimage.bijection⁻¹-contractible A↔B y
-- If an inhabited type comes with an erased proof of
-- propositionality, then it is contractible (with erased proofs).
inhabited→Is-proposition→Contractibleᴱ :
{@0 A : Type a} →
A → @0 Is-proposition A → Contractibleᴱ A
inhabited→Is-proposition→Contractibleᴱ x prop = (x , [ prop x ])
-- Some closure properties.
Contractibleᴱ-Σ :
{@0 A : Type a} {@0 P : A → Type p} →
Contractibleᴱ A → (∀ x → Contractibleᴱ (P x)) → Contractibleᴱ (Σ A P)
Contractibleᴱ-Σ cA@(a , _) cP =
(a , proj₁₀ (cP a))
, [ proj₂ $ Σ-closure 0 (Contractibleᴱ→Contractible cA)
(Contractibleᴱ→Contractible ∘ cP)
]
Contractibleᴱ-× :
{@0 A : Type a} {@0 B : Type b} →
Contractibleᴱ A → Contractibleᴱ B → Contractibleᴱ (A × B)
Contractibleᴱ-× cA cB = Contractibleᴱ-Σ cA (λ _ → cB)
Contractibleᴱ-Π :
{@0 A : Type a} {@0 P : A → Type p} →
@0 Extensionality a p →
(∀ x → Contractibleᴱ (P x)) → Contractibleᴱ ((x : A) → P x)
Contractibleᴱ-Π ext c =
proj₁₀ ∘ c
, [ proj₂ $ Π-closure ext 0 (Contractibleᴱ→Contractible ∘ c)
]
Contractibleᴱ-↑ :
{@0 A : Type a} →
Contractibleᴱ A → Contractibleᴱ (↑ ℓ A)
Contractibleᴱ-↑ c@(a , _) =
lift a
, [ proj₂ $ ↑-closure 0 (Contractibleᴱ→Contractible c)
]
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for one universe
-- level
module []-cong₁ (ax : []-cong-axiomatisation ℓ) where
open Erased-cong ax ax
open Erased.[]-cong₁ ax
----------------------------------------------------------------------
-- Some results related to _⁻¹ᴱ_
-- The function _⁻¹ᴱ y respects erased extensional equality.
⁻¹ᴱ-respects-extensional-equality :
{@0 B : Type ℓ} {@0 f g : A → B} {@0 y : B} →
@0 (∀ x → f x ≡ g x) → f ⁻¹ᴱ y ≃ g ⁻¹ᴱ y
⁻¹ᴱ-respects-extensional-equality {f = f} {g = g} {y = y} f≡g =
(∃ λ x → Erased (f x ≡ y)) ↝⟨ (∃-cong λ _ → Erased-cong-≃ (≡⇒↝ _ (cong (_≡ _) $ f≡g _))) ⟩□
(∃ λ x → Erased (g x ≡ y)) □
-- An isomorphism relating _⁻¹ᴱ_ to _⁻¹_.
⁻¹ᴱ[]↔⁻¹[] :
{@0 B : Type ℓ} {f : A → Erased B} {@0 y : B} →
f ⁻¹ᴱ [ y ] ↔ f ⁻¹ [ y ]
⁻¹ᴱ[]↔⁻¹[] {f = f} {y = y} =
(∃ λ x → Erased (f x ≡ [ y ])) ↔⟨ (∃-cong λ _ → Erased-cong-≃ (Eq.≃-≡ $ Eq.↔⇒≃ $ inverse $ erased Erased↔)) ⟩
(∃ λ x → Erased (erased (f x) ≡ y)) ↝⟨ (∃-cong λ _ → Erased-≡↔[]≡[]) ⟩□
(∃ λ x → f x ≡ [ y ]) □
-- Erased "commutes" with _⁻¹ᴱ_.
Erased-⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type ℓ} {@0 f : A → B} {@0 y : B} →
Erased (f ⁻¹ᴱ y) ↔ map f ⁻¹ᴱ [ y ]
Erased-⁻¹ᴱ {f = f} {y = y} =
Erased (f ⁻¹ᴱ y) ↝⟨ Erased-⁻¹ᴱ↔Erased-⁻¹ ⟩
Erased (f ⁻¹ y) ↝⟨ Erased-⁻¹ ⟩
map f ⁻¹ [ y ] ↝⟨ inverse ⁻¹ᴱ[]↔⁻¹[] ⟩□
map f ⁻¹ᴱ [ y ] □
----------------------------------------------------------------------
-- Some results related to Contractibleᴱ
-- Erased commutes with Contractibleᴱ.
Erased-Contractibleᴱ↔Contractibleᴱ-Erased :
{@0 A : Type ℓ} →
Erased (Contractibleᴱ A) ↝[ ℓ ∣ ℓ ]ᴱ Contractibleᴱ (Erased A)
Erased-Contractibleᴱ↔Contractibleᴱ-Erased {A = A} ext =
Erased (∃ λ x → Erased ((y : A) → x ≡ y)) ↔⟨ Erased-cong-↔ (∃-cong λ _ → erased Erased↔) ⟩
Erased (∃ λ x → (y : A) → x ≡ y) ↔⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased ((y : A) → erased x ≡ y)) ↝⟨ (∃-cong λ _ →
Erased-cong?
(λ ext → ∀-cong ext λ _ →
from-isomorphism (inverse $ erased Erased↔))
ext) ⟩
(∃ λ x → Erased ((y : A) → Erased (erased x ≡ y))) ↝⟨ (∃-cong λ _ →
Erased-cong?
(λ ext → Π-cong ext (inverse $ erased Erased↔) λ _ →
from-isomorphism Erased-≡↔[]≡[])
ext) ⟩□
(∃ λ x → Erased ((y : Erased A) → x ≡ y)) □
-- An isomorphism relating Contractibleᴱ to Contractible.
Contractibleᴱ-Erased↔Contractible-Erased :
{@0 A : Type ℓ} →
Contractibleᴱ (Erased A) ↝[ ℓ ∣ ℓ ] Contractible (Erased A)
Contractibleᴱ-Erased↔Contractible-Erased {A = A} ext =
Contractibleᴱ (Erased A) ↝⟨ inverse-erased-ext? Erased-Contractibleᴱ↔Contractibleᴱ-Erased ext ⟩
Erased (Contractibleᴱ A) ↔⟨ Erased-Contractibleᴱ↔Erased-Contractible ⟩
Erased (Contractible A) ↝⟨ Erased-H-level↔H-level 0 ext ⟩□
Contractible (Erased A) □
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for two universe
-- levels
module []-cong₂
(ax₁ : []-cong-axiomatisation ℓ₁)
(ax₂ : []-cong-axiomatisation ℓ₂)
where
open Erased-cong ax₁ ax₂
----------------------------------------------------------------------
-- A result related to Contractibleᴱ
-- Contractibleᴱ preserves isomorphisms (assuming extensionality).
Contractibleᴱ-cong :
{A : Type ℓ₁} {B : Type ℓ₂} →
@0 Extensionality? k′ (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) →
A ↔[ k ] B → Contractibleᴱ A ↝[ k′ ] Contractibleᴱ B
Contractibleᴱ-cong {A = A} {B = B} ext A↔B =
(∃ λ (x : A) → Erased ((y : A) → x ≡ y)) ↝⟨ (Σ-cong A≃B′ λ _ →
Erased-cong?
(λ ext → Π-cong ext A≃B′ λ _ →
from-isomorphism $ inverse $ Eq.≃-≡ A≃B′)
ext) ⟩□
(∃ λ (x : B) → Erased ((y : B) → x ≡ y)) □
where
A≃B′ = from-isomorphism A↔B
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for all universe
-- levels
module []-cong (ax : ∀ {ℓ} → []-cong-axiomatisation ℓ) where
private
open module BC₁ {ℓ} =
[]-cong₁ (ax {ℓ = ℓ})
public
open module BC₂ {ℓ₁ ℓ₂} =
[]-cong₂ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂})
public
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/nested_return_test.adb | best08618/asylo | 7 | 13320 | -- { dg-do run }
-- { dg-options "-gnata" }
procedure Nested_Return_Test is
function H (X: integer) return access integer is
Local : aliased integer := (X+1);
begin
case X is
when 3 =>
begin
return Result : access integer do
Result := new integer '(27);
begin
for I in 1 .. 10 loop
result.all := result.all + 10;
end loop;
return;
end;
end return;
end;
when 5 =>
return Result: Access integer do
Result := New Integer'(X*X*X);
end return;
when others =>
return null;
end case;
end;
begin
pragma Assert (H (3).all = 127);
pragma Assert (H (5).all = 125);
null;
end Nested_Return_Test;
|
Library/Spline/UI/uiSmoothness.asm | steakknife/pcgeos | 504 | 161372 | <reponame>steakknife/pcgeos
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: uiSmoothness.asm
AUTHOR: <NAME>
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/ 5/92 Initial version.
DESCRIPTION:
$Id: uiSmoothness.asm,v 1.1 97/04/07 11:09:42 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @----------------------------------------------------------------------
MESSAGE: SplineSmoothnessControlGetInfo --
MSG_GEN_CONTROL_GET_INFO for SplineSmoothnessControlClass
DESCRIPTION: Return group
PASS:
*ds:si - instance data
es - segment of SplineSmoothnessControlClass
ax - The message
cx:dx - GenControlBuildInfo structure to fill in
RETURN:
none
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 10/31/91 Initial version
------------------------------------------------------------------------------@
SplineSmoothnessControlGetInfo method dynamic SplineSmoothnessControlClass,
MSG_GEN_CONTROL_GET_INFO
mov si, offset SSC_dupInfo
call CopyDupInfoCommon
ret
SplineSmoothnessControlGetInfo endm
SSC_dupInfo GenControlBuildInfo <
0, ; GCBI_flags
SSC_initFileKey, ; GCBI_initFileKey
SSC_gcnList, ; GCBI_gcnList
length SSC_gcnList, ; GCBI_gcnCount
SSC_notifyTypeList, ; GCBI_notificationList
length SSC_notifyTypeList, ; GCBI_notificationCount
SmoothnessName, ; GCBI_controllerName
handle SmoothnessUI, ; GCBI_dupBlock
SSC_childList, ; GCBI_childList
length SSC_childList, ; GCBI_childCount
SSC_featuresList, ; GCBI_featuresList
length SSC_featuresList, ; GCBI_featuresCount
SSMC_DEFAULT_FEATURES, ; GCBI_features
handle SmoothnessToolUI, ; GCBI_toolBlock
SSC_toolList, ; GCBI_toolList
length SSC_toolList, ; GCBI_toolCount
SSC_toolFeaturesList, ; GCBI_toolFeaturesList
length SSC_toolFeaturesList, ; GCBI_toolFeaturesCount
SSMC_DEFAULT_TOOLBOX_FEATURES, ; GCBI_toolFeatures
0> ; GCBI_helpContext
SSC_initFileKey char "polyline", 0
SSC_gcnList GCNListType \
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_SPLINE_SMOOTHNESS>
SSC_notifyTypeList NotificationType \
<MANUFACTURER_ID_GEOWORKS, GWNT_SPLINE_SMOOTHNESS>
;---
SSC_childList GenControlChildInfo \
<offset SmoothnessList, SSMC_DEFAULT_FEATURES, <0,1>>
; Careful, this table is in the *opposite* order as the record which
; it corresponds to.
SSC_featuresList GenControlFeaturesInfo \
<offset SmoothnessList, SmoothnessName >
; Tools
SSC_toolList GenControlChildInfo \
<offset SmoothnessToolList, SSMC_DEFAULT_TOOLBOX_FEATURES, <0,1>>
; Careful, this table is in the *opposite* order as the record which
; it corresponds to.
SSC_toolFeaturesList GenControlFeaturesInfo \
<offset SmoothnessToolList, SmoothnessToolName >
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SmoothnessControlUpdateUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION:
PASS: *ds:si = SmoothnessControlClass object
ds:di = SmoothnessControlClass instance data
es = Segment of SmoothnessControlClass.
RETURN:
DESTROYED: ax,cx,dx,bp
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 5/13/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SplineSmoothnessControlUpdateUI method dynamic SplineSmoothnessControlClass,
MSG_GEN_CONTROL_UPDATE_UI
mov bx, bp
locals local SplineControlUpdateUIParams
.enter
mov locals.SCUUIP_params, bx
; ONLY ENABLE UI if mode is ADVANCED_EDIT (or indeterminate),
; and the selection count is nonzero.
; get notification data
mov bx, ss:[bx].GCUUIP_dataBlock
call MemLock
mov ds, ax
mov ch, ds:[SPNB_smoothness]
mov cl, ds:[SPNB_mode]
tst ds:[SPNB_numSelected]
call MemUnlock
jz disable ; disable if none selected.
cmp cl, -1 ; indeterminate
je enable
cmp cl, SM_ADVANCED_EDIT
je enable
disable:
mov ax, MSG_GEN_SET_NOT_ENABLED
jmp callIt
enable:
mov ax, MSG_GEN_SET_ENABLED
callIt:
mov dl, VUM_DELAYED_VIA_UI_QUEUE
mov si, offset SmoothnessList
mov di, offset SmoothnessToolList
call SendToChildAndTool
; Now set the smoothness type
mov cl, ch ; smoothness
clr ch
mov si, offset SmoothnessList
mov di, offset SmoothnessToolList
clr dx
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
call SendToChildAndTool
.leave
ret
SplineSmoothnessControlUpdateUI endm
|
oeis/267/A267846.asm | neoneye/loda-programs | 11 | 240098 | ; A267846: Binary representation of the n-th iteration of the "Rule 227" elementary cellular automaton starting with a single ON (black) cell.
; Submitted by <NAME>
; 1,100,11010,1111010,111111010,11111111010,1111111111010,111111111111010,11111111111111010,1111111111111111010,111111111111111111010,11111111111111111111010,1111111111111111111111010,111111111111111111111111010,11111111111111111111111111010,1111111111111111111111111111010,111111111111111111111111111111010,11111111111111111111111111111111010,1111111111111111111111111111111111010,111111111111111111111111111111111111010,11111111111111111111111111111111111111010
seq $0,267847 ; Decimal representation of the n-th iteration of the "Rule 227" elementary cellular automaton starting with a single ON (black) cell.
seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2.
|
src/Categories/Category/Construction/KaroubiEnvelope.agda | Trebor-Huang/agda-categories | 279 | 3504 | <gh_stars>100-1000
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category; _[_≈_])
-- Karoubi Envelopes. These are the free completions of categories under split idempotents
module Categories.Category.Construction.KaroubiEnvelope {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level
open import Categories.Morphism.Idempotent.Bundles 𝒞
open import Categories.Morphism.Reasoning 𝒞
private
module 𝒞 = Category 𝒞
open 𝒞.HomReasoning
open 𝒞.Equiv
open Idempotent
open Idempotent⇒
KaroubiEnvelope : Category (o ⊔ ℓ ⊔ e) (ℓ ⊔ e) e
KaroubiEnvelope = record
{ Obj = Idempotent
; _⇒_ = Idempotent⇒
; _≈_ = λ f g → 𝒞 [ Idempotent⇒.hom f ≈ Idempotent⇒.hom g ]
; id = id
; _∘_ = _∘_
; assoc = 𝒞.assoc
; sym-assoc = 𝒞.sym-assoc
; identityˡ = λ {I} {J} {f} → absorbˡ f
; identityʳ = λ {I} {J} {f} → absorbʳ f
; identity² = λ {I} → idempotent I
; equiv = record
{ refl = refl
; sym = sym
; trans = trans
}
; ∘-resp-≈ = 𝒞.∘-resp-≈
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.