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/029/A029026.asm
neoneye/loda
22
84784
<filename>programs/oeis/029/A029026.asm ; A029026: Expansion of 1/((1-x)(1-x^2)(1-x^8)(1-x^11)). ; 1,1,2,2,3,3,4,4,6,6,8,9,11,12,14,15,18,19,22,24,27,29,33,35,40,42,47,50,55,58,64,67,74,78,85,90,97,102,110,115,124,130,139,146,156,163,174,181,193,201,213,222,235,244 lpb $0 mov $2,$0 sub $0,2 seq $2,25790 ; Expansion of 1/((1-x)(1-x^8)(1-x^11)). add $1,$2 add $1,$2 lpe div $1,2 add $1,1 mov $0,$1
oeis/349/A349496.asm
neoneye/loda-programs
11
89092
<reponame>neoneye/loda-programs<filename>oeis/349/A349496.asm ; A349496: Numbers of the form 4*t^2-2 (A060626) when t >= 1 is an integer that is not a term in A001542. ; Submitted by <NAME> ; 2,34,62,98,142,194,254,322,398,482,674,782,898,1022,1154,1294,1442,1598,1762,1934,2114,2302,2498,2702,2914,3134,3362,3598,3842,4094,4354,4622,4898,5182,5474,5774,6082,6398,6722,7054,7394,7742,8098,8462,8834,9214,9602,9998,10402 mov $2,$0 add $2,1 lpb $0 div $0,10 add $2,1 lpe add $0,$2 mul $0,27 pow $0,2 sub $0,729 div $0,729 mul $0,4 add $0,2
programs/oeis/056/A056455.asm
neoneye/loda
22
22142
; A056455: Palindromes using exactly four different symbols. ; 0,0,0,0,0,0,24,24,240,240,1560,1560,8400,8400,40824,40824,186480,186480,818520,818520,3498000,3498000,14676024,14676024,60780720,60780720,249401880,249401880,1016542800,1016542800,4123173624,4123173624,16664094960,16664094960 div $0,2 mov $1,4 pow $1,$0 seq $0,210448 ; Total number of different letters summed over all ternary words of length n. sub $1,$0 div $1,6 mul $1,24 mov $0,$1
programs/oeis/140/A140660.asm
karttu/loda
1
175917
; A140660: a(n) = 3*4^n + 1. ; 4,13,49,193,769,3073,12289,49153,196609,786433,3145729,12582913,50331649,201326593,805306369,3221225473,12884901889,51539607553,206158430209,824633720833,3298534883329,13194139533313,52776558133249,211106232532993,844424930131969,3377699720527873 mov $1,4 pow $1,$0 mul $1,3 add $1,1
examples/ppu.asm
Benderx2/FVM
2
87748
<reponame>Benderx2/FVM include 'a32.inc' _start: PUSH _alien PUSH _end_data - _alien PUSH 56 PPU_WRITE PPU_UPDATE VM_EXIT _end_start: _data: _alien: file 't.rgba' _end_data: _bss: _end_bss:
oeis/264/A264980.asm
neoneye/loda-programs
11
103657
<gh_stars>10-100 ; A264980: Base-3 reversal of 2^n: a(n) = A030102(A000079(n)). ; 1,2,4,8,16,64,32,184,352,704,1408,1880,2824,14032,10328,56128,100576,145784,189472,370304,731752,4388248,2924096,11175712,15965704,31930448,63861880,383165344,255439712,1021772344,510875648,2550188248,5619691648,9689861048,17830350904,79068724264,34109913224,192259976368,133338241880,769022821600,1600007648032,2070348404576,3010927408792,17689470033448,11667258088184,67381123364536,129881456655688,178046767382600,254795226420712,447831492758288,1019176772969320,5291510038126336,3253156491715304 seq $0,79 ; Powers of 2: a(n) = 2^n. seq $0,30102 ; Base-3 reversal of n (written in base 10).
src/languages/en_us/CustomParser.g4
panscript/code
0
3862
parser grammar CustomParser; options { tokenVocab=CustomLexer; } import CommonParser;
tptp_v7_0_0_0.g4
ontologyportal/TPTP-ANTLR
0
2530
// created by <NAME> (<EMAIL>) // and <NAME> (<EMAIL>) // #INFO is about sections or where the parse tree has been flattened according to ANTLR idiomatics // #ALT alternative grammar formulation for some parts // #RES where no further restrictions are applied e.g. in the case of defined_functor // any dollar word is allowed instead of only the predefined functors grammar tptp_v7_0_0_0; // #INFO HERE COME THE LEXER RULES fragment Do_char : [\u0020-\u0021\u0023-\u005B\u005D-\u007E] | '\\'["\\]; fragment Sq_char : [\u0020-\u0026\u0028-\u005B\u005D-\u007E] | '\\'['\\]; fragment Sign : [+-]; fragment Exponent : [Ee]; fragment Non_zero_numeric : [1-9]; fragment Numeric : [0-9]; fragment Lower_alpha : [a-z]; fragment Upper_alpha : [A-Z]; fragment Alpha_numeric : Lower_alpha | Upper_alpha | Numeric | '_'; Or: '|'; And: '&'; Iff : '<=>'; Impl : '=>'; If: '<='; Niff: '<~>'; Nor: '~|'; Nand: '~&'; Not: '~'; ForallComb: '!!'; TyForall: '!>'; Infix_inequality : '!='; Infix_equality : '='; Forall: '!'; ExistsComb: '??'; TyExists: '?*'; Exists: '?'; Lambda: '^'; ChoiceComb: '@@+'; Choice: '@+'; DescriptionComb: '@@-'; Description: '@-'; EqComb: '@='; App: '@'; Assignment: ':='; Arrow: '>'; Star: '*'; Plus: '+'; Subtype_sign: '<<'; Gentzen_arrow : '-->'; Real : Signed_real | Unsigned_real; Signed_real : Sign Unsigned_real; Unsigned_real : Decimal_fraction|Decimal_exponent; Rational: Signed_rational | Unsigned_rational; Signed_rational: Sign Unsigned_rational; Unsigned_rational: Decimal '/' Positive_decimal; Integer : Signed_integer | Unsigned_integer; Signed_integer: Sign Unsigned_integer; Unsigned_integer: Decimal; Decimal : '0' | Positive_decimal; Positive_decimal : Non_zero_numeric Numeric*; Decimal_exponent : (Decimal|Decimal_fraction) Exponent Exp_integer; Decimal_fraction : Decimal Dot_decimal; Dot_decimal : '.' Numeric Numeric*; Exp_integer : Signed_exp_integer|Unsigned_exp_integer; Signed_exp_integer : Sign Unsigned_exp_integer; Unsigned_exp_integer : Numeric Numeric*; Dollar_word : '$' Lower_word; Dollar_dollar_word : '$$' Lower_word; Upper_word : Upper_alpha Alpha_numeric*; Lower_word : Lower_alpha Alpha_numeric*; Single_quoted : '\'' Sq_char+ '\''; Distinct_object : '"' Do_char+ '"'; WS : [ \r\t\n]+ -> skip ; Line_comment : '%' ~[\r\n]* -> skip; Block_comment : '/*' .*? '*/' -> skip; //%----Top of Page--------------------------------------------------------------- //%----Rules from here on down are for defining tokens (terminal symbols) of the //%----grammar, assuming they will be recognized by a lexical scanner. //%----A ::- rule defines a token, a ::: rule defines a macro that is not a //%----token. Usual regexp notation is used. Single characters are always placed //%----in []s to disable any special meanings (for uniformity this is done to //%----all characters, not only those with special meanings). // //%----These are tokens that appear in the syntax rules above. No rules //%----defined here because they appear explicitly in the syntax rules, //%----except that <vline>, <star>, <plus> denote "|", "*", "+", respectively. //%----Keywords: fof cnf thf tff include //%----Punctuation: ( ) , . [ ] : //%----Operators: ! ? ~ & | <=> => <= <~> ~| ~& * + //%----Predicates: = != $true $false // //%----For lex/yacc there cannot be spaces on either side of the | here //<comment> ::- <comment_line>|<comment_block> //<comment_line> ::- [%]<printable_char>* //<comment_block> ::: [/][*]<not_star_slash>[*][*]*[/] //<not_star_slash> ::: ([^*]*[*][*]*[^/*])*[^*]* //%----Defined comments are a convention used for annotations that are used as //%----additional input for systems. They look like comments, but start with %$ //%----or /*$. A wily user of the syntax can notice the $ and extract information //%----from the "comment" and pass that on as input to the system. They are //%----analogous to pragmas in programming languages. To extract these separately //%----from regular comments, the rules are: //%---- <defined_comment> ::- <def_comment_line>|<def_comment_block> //%---- <def_comment_line> ::: [%]<dollar><printable_char>* //%---- <def_comment_block> ::: [/][*]<dollar><not_star_slash>[*][*]*[/] //%----A string that matches both <defined_comment> and <comment> should be //%----recognized as <defined_comment>, so put these before <comment>. //%----Defined comments that are in use include: //%---- TO BE ANNOUNCED //%----System comments are a convention used for annotations that may used as //%----additional input to a specific system. They look like comments, but start //%----with %$$ or /*$$. A wily user of the syntax can notice the $$ and extract //%----information from the "comment" and pass that on as input to the system. //%----The specific system for which the information is intended should be //%----identified after the $$, e.g., /*$$Otter 3.3: Demodulator */ //%----To extract these separately from regular comments, the rules are: //%---- <system_comment> ::- <sys_comment_line>|<sys_comment_block> //%---- <sys_comment_line> ::: [%]<dollar><dollar><printable_char>* //%---- <sys_comment_block> ::: [/][*]<dollar><dollar><not_star_slash>[*][*]*[/] //%----A string that matches both <system_comment> and <defined_comment> should //%----be recognized as <system_comment>, so put these before <defined_comment>. // //<single_quoted> ::- <single_quote><sq_char><sq_char>*<single_quote> //%----<single_quoted>s contain visible characters. \ is the escape character for //%----' and \, i.e., \' is not the end of the <single_quoted>. //%----The token does not include the outer quotes, e.g., 'cat' and cat are the //%----same. See <atomic_word> for information about stripping the quotes. // //<distinct_object> ::- <double_quote><do_char>*<double_quote> //%---Space and visible characters upto ~, except " and \ //%----<distinct_object>s contain visible characters. \ is the escape character //%----for " and \, i.e., \" is not the end of the <distinct_object>. //%----<distinct_object>s are different from (but may be equal to) other tokens, //%----e.g., "cat" is different from 'cat' and cat. Distinct objects are always //%----interpreted as themselves, so if they are different they are unequal, //%----e.g., "Apple" != "Microsoft" is implicit. // //<dollar_word> ::- <dollar><lower_word> //<dollar_dollar_word> ::- <dollar><dollar><lower_word> //<upper_word> ::- <upper_alpha><alpha_numeric>* //<lower_word> ::- <lower_alpha><alpha_numeric>* // //%----Tokens used in syntax, and cannot be character classes //<vline> ::- [|] //<star> ::- [*] //<plus> ::- [+] //<arrow> ::- [>] //<less_sign> ::- [<] // //%----Numbers. Signs are made part of the same token here. //<real> ::- (<signed_real>|<unsigned_real>) //<signed_real> ::- <sign><unsigned_real> //<unsigned_real> ::- (<decimal_fraction>|<decimal_exponent>) //<rational> ::- (<signed_rational>|<unsigned_rational>) //<signed_rational> ::- <sign><unsigned_rational> //<unsigned_rational> ::- <decimal><slash><positive_decimal> //<integer> ::- (<signed_integer>|<unsigned_integer>) //<signed_integer> ::- <sign><unsigned_integer> //<unsigned_integer> ::- <decimal> //<decimal> ::- (<zero_numeric>|<positive_decimal>) //<positive_decimal> ::- <non_zero_numeric><numeric>* //<decimal_exponent> ::- (<decimal>|<decimal_fraction>)<exponent><exp_integer> //<decimal_fraction> ::- <decimal><dot_decimal> //<dot_decimal> ::- <dot><numeric><numeric>* //<exp_integer> ::- (<signed_exp_integer>|<unsigned_exp_integer>) //<signed_exp_integer> ::- <sign><unsigned_exp_integer> //<unsigned_exp_integer> ::- <numeric><numeric>* // //%----Character classes //<percentage_sign> ::: [%] //<double_quote> ::: ["] //<do_char> ::: ([\40-\41\43-\133\135-\176]|[\\]["\\]) //<single_quote> ::: ['] //%---Space and visible characters upto ~, except ' and \ //<sq_char> ::: ([\40-\46\50-\133\135-\176]|[\\]['\\]) //<sign> ::: [+-] //<dot> ::: [.] //<exponent> ::: [Ee] //<slash> ::: [/] //<zero_numeric> ::: [0] //<non_zero_numeric> ::: [1-9] //<numeric> ::: [0-9] //<lower_alpha> ::: [a-z] //<upper_alpha> ::: [A-Z] //<alpha_numeric> ::: (<lower_alpha>|<upper_alpha>|<numeric>|[_]) //<dollar> ::: [$] //<printable_char> ::: . //%----<printable_char> is any printable ASCII character, codes 32 (space) to 126 //%----(tilde). <printable_char> does not include tabs, newlines, bells, etc. The //%----use of . does not not exclude tab, so this is a bit loose. //<viewable_char> ::: [.\n] //%----Top of Page--------------------------------------------------------------- // #INFO HERE COMES THE GRAMMAR //%----v7.0.0.0 (TPTP version.internal development number) //%------------------------------------------------------------------------------ //%----README ... this header provides important meta- and usage information //%---- //%----Intended uses of the various parts of the TPTP syntax are explained //%----in the TPTP technical manual, linked from www.tptp.org. //%---- //%----Four kinds of separators are used, to indicate different types of rules: //%---- ::= is used for regular grammar rules, for syntactic parsing. //%---- :== is used for semantic grammar rules. These define specific values //%---- that make semantic sense when more general syntactic rules apply. //%---- ::- is used for rules that produce tokens. //%---- ::: is used for rules that define character classes used in the //%---- construction of tokens. //%---- //%----White space may occur between any two tokens. White space is not specified //%----in the grammar, but there are some restrictions to ensure that the grammar //%----is compatible with standard Prolog: a <TPTP_file> should be readable with //%----read/1. //%---- //%----The syntax of comments is defined by the <comment> rule. Comments may //%----occur between any two tokens, but do not act as white space. Comments //%----will normally be discarded at the lexical level, but may be processed //%----by systems that understand them (e.g., if the system comment convention //%----is followed). //%---- //%----Multiple languages are defined. Depending on your need, you can implement //%----just the one(s) you need. The common rules for atoms, terms, etc, come //%----after the definitions of the languages, and mostly all needed for all the //%----languages. //%----Top of Page--------------------------------------------------------------- //%----Files. Empty file is OK. //<TPTP_file> ::= <TPTP_input>* //<TPTP_input> ::= <annotated_formula> | <include> tptp_file : tptp_input* EOF; tptp_input : annotated_formula | include; //%----Formula records //<annotated_formula> ::= <thf_annotated> | <tfx_annotated> | <tff_annotated> | // <tcf_annotated> | <fof_annotated> | <cnf_annotated> | // <tpi_annotated> //%----Future languages may include ... english | efof | tfof | mathml | ... //<tpi_annotated> ::= tpi(<name>,<formula_role>,<tpi_formula><annotations>). //<tpi_formula> ::= <fof_formula> //<thf_annotated> ::= thf(<name>,<formula_role>,<thf_formula> // <annotations>). //<tfx_annotated> ::= tfx(<name>,<formula_role>,<tfx_formula> // <annotations>). //<tff_annotated> ::= tff(<name>,<formula_role>,<tff_formula> // <annotations>). //<tcf_annotated> ::= tcf(<name>,<formula_role>,<tcf_formula> // <annotations>). //<fof_annotated> ::= fof(<name>,<formula_role>,<fof_formula> // <annotations>). //<cnf_annotated> ::= cnf(<name>,<formula_role>,<cnf_formula> // <annotations>). //<annotations> ::= ,<source><optional_info> | <null> annotated_formula : thf_annotated | tfx_annotated | tff_annotated | tcf_annotated | fof_annotated | cnf_annotated | tpi_annotated; tpi_annotated : 'tpi(' name ',' formula_role ',' tpi_formula annotations? ').'; tpi_formula : fof_formula; thf_annotated : 'thf(' name ',' formula_role ',' thf_formula annotations? ').'; tfx_annotated : 'tfx(' name ',' formula_role ',' tfx_formula annotations? ').'; tff_annotated : 'tff(' name ',' formula_role ',' tff_formula annotations? ').'; tcf_annotated : 'tcf(' name ',' formula_role ',' tcf_formula annotations? ').'; fof_annotated : 'fof(' name ',' formula_role ',' fof_formula annotations? ').'; cnf_annotated : 'cnf(' name ',' formula_role ',' cnf_formula annotations? ').'; annotations : ',' source optional_info?; //%----In derivations the annotated formulae names must be unique, so that //%----parent references (see <inference_record>) are unambiguous. //%----Types for problems. //%----Note: The previous <source_type> from ... //%---- <formula_role> ::= <user_role>-<source> //%----... is now gone. Parsers may choose to be tolerant of it for backwards //%----compatibility. //<formula_role> ::= <lower_word> //<formula_role> :== axiom | hypothesis | definition | assumption | // lemma | theorem | corollary | conjecture | // negated_conjecture | plain | type | // fi_domain | fi_functors | fi_predicates | unknown formula_role : Lower_word; // #RES no restrictions //%----"axiom"s are accepted, without proof. There is no guarantee that the //%----axioms of a problem are consistent. //%----"hypothesis"s are assumed to be true for a particular problem, and are //%----used like "axiom"s. //%----"definition"s are intended to define symbols. They are either universally //%----quantified equations, or universally quantified equivalences with an //%----atomic lefthand side. They can be treated like "axiom"s. //%----"assumption"s can be used like axioms, but must be discharged before a //%----derivation is complete. //%----"lemma"s and "theorem"s have been proven from the "axiom"s. They can be //%----used like "axiom"s in problems, and a problem containing a non-redundant //%----"lemma" or theorem" is ill-formed. They can also appear in derivations. //%----"theorem"s are more important than "lemma"s from the user perspective. //%----"conjecture"s are to be proven from the "axiom"(-like) formulae. A problem //%----is solved only when all "conjecture"s are proven. //%----"negated_conjecture"s are formed from negation of a "conjecture" (usually //%----in a FOF to CNF conversion). //%----"plain"s have no specified user semantics. //%----"fi_domain", "fi_functors", and "fi_predicates" are used to record the //%----domain, interpretation of functors, and interpretation of predicates, for //%----a finite interpretation. //%----"type" defines the type globally for one symbol; treat as $true. //%----"unknown"s have unknown role, and this is an error situation. //%----Top of Page--------------------------------------------------------------- //%----THF formulae. //<thf_formula> ::= <thf_logic_formula> | <thf_sequent> //<thf_logic_formula> ::= <thf_binary_formula> | <thf_unitary_formula> | // <thf_type_formula> | <thf_subtype> //<thf_binary_formula> ::= <thf_binary_pair> | <thf_binary_tuple> | // <thf_binary_type> thf_formula : thf_logic_formula | thf_sequent; thf_logic_formula : thf_binary_formula | thf_unitary_formula | thf_type_formula | thf_subtype; thf_binary_formula : thf_binary_pair | thf_binary_tuple | thf_binary_type; //%----Only some binary connectives can be written without ()s. //%----There's no precedence among binary connectives //<thf_binary_pair> ::= <thf_unitary_formula> <thf_pair_connective> // <thf_unitary_formula> //<thf_binary_tuple> ::= <thf_or_formula> | <thf_and_formula> | // <thf_apply_formula> //<thf_or_formula> ::= <thf_unitary_formula> <vline> <thf_unitary_formula> | // <thf_or_formula> <vline> <thf_unitary_formula> //<thf_and_formula> ::= <thf_unitary_formula> & <thf_unitary_formula> | // <thf_and_formula> & <thf_unitary_formula> //%----@ (denoting apply) is left-associative and lambda is right-associative. //%----^ [X] : ^ [Y] : f @ g (where f is a <thf_apply_formula> and g is a //%----<thf_unitary_formula>) should be parsed as: (^ [X] : (^ [Y] : f)) @ g. //%----That is, g is not in the scope of either lambda. //<thf_apply_formula> ::= <thf_unitary_formula> @ <thf_unitary_formula> | // <thf_apply_formula> @ <thf_unitary_formula> thf_binary_pair : thf_unitary_formula thf_pair_connective thf_unitary_formula; thf_binary_tuple : thf_or_formula | thf_and_formula | thf_apply_formula; thf_or_formula : thf_unitary_formula Or thf_unitary_formula | thf_or_formula Or thf_unitary_formula; thf_and_formula : thf_unitary_formula And thf_unitary_formula | thf_and_formula And thf_unitary_formula; thf_apply_formula : thf_unitary_formula App thf_unitary_formula | thf_apply_formula App thf_unitary_formula; //%----<thf_unitary_formula> are in ()s or do not have a <binary_connective> at //%----the top level. Essentially, any lambda expression that "has enough ()s" to //%----be used inside a larger lambda expression. However, lambda notation might //%----not be used. //<thf_unitary_formula> ::= <thf_quantified_formula> | <thf_unary_formula> | // <thf_atom> | <thf_conditional> | <thf_let> | // <thf_tuple> | (<thf_logic_formula>) thf_unitary_formula : thf_quantified_formula | thf_unary_formula | thf_atom | thf_conditional | thf_let | thf_tuple | '(' thf_logic_formula ')'; //%----All variables must be quantified //<thf_quantified_formula> ::= <thf_quantification> <thf_unitary_formula> //<thf_quantification> ::= <thf_quantifier> [<thf_variable_list>] : //<thf_variable_list> ::= <thf_variable> | <thf_variable>,<thf_variable_list> //<thf_variable> ::= <thf_typed_variable> | <variable> //<thf_typed_variable> ::= <variable> : <thf_top_level_type> thf_quantified_formula : thf_quantification thf_unitary_formula; thf_quantification : thf_quantifier '[' thf_variable_list ']' ':'; thf_variable_list : thf_variable (',' thf_variable)*; // #INFO thf_variable_list flattened //thf_variable_list : thf_variable | thf_variable ',' thf_variable_list; // #ALT flattened to thf_variable_list thf_variable : thf_typed_variable | variable; thf_typed_variable : variable ':' thf_top_level_type; //thf_variable : variable (':' thf_top_level_type)?; // #ALT to thf_variable (more condensed) //%----Unary connectives bind more tightly than binary. The negated formula //%----must be ()ed because a ~ is also a term. //<thf_unary_formula> ::= <thf_unary_connective> (<thf_logic_formula>) //<thf_atom> ::= <thf_function> | <variable> | <defined_term> | // <thf_conn_term> thf_unary_formula : thf_unary_connective '(' thf_logic_formula ')'; thf_atom : thf_function | variable | defined_term | thf_conn_term; //%----Defined terms have TPTP specific interpretations. Note that <thf_atom> //%----allows <defined_type>s as terms, which will fail type checking. The //%----user must take care with this liberal syntax! //<thf_function> ::= <atom> | <functor>(<thf_arguments>) | // <defined_functor>(<thf_arguments>) | // <system_functor>(<thf_arguments>) thf_function : atom | functor '(' thf_arguments ')' | defined_functor '(' thf_arguments ')' | system_functor '(' thf_arguments ')'; // #ALT to thf_function // Splitted rules of <thf_function> to avoid using <atom> here: // We use conditional arguments, i.e. // the atoms are included (= thf_arguments is empty). //thf_function: thf_plain_term | thf_defined_term | thf_system_term; //thf_plain_term : functor ('(' thf_arguments ')')?; //thf_defined_term : defined_functor ('(' thf_arguments ')')?; //thf_system_term : system_functor ('(' thf_arguments ')')?; //%----| <defined_type> | <defined_prop>, but they are captured by <atom> as //%----<defined_constant> as <atomic_defined_word>. //<thf_conn_term> ::= <thf_pair_connective> | <assoc_connective> | // <thf_unary_connective> thf_conn_term : thf_pair_connective | assoc_connective | thf_unary_connective; //%----Note that syntactically this allows (p @ =), but for = the first //%----argument must be known to infer the type of =, so that's not //%----allowed, i.e., only (= @ p). //<thf_conditional> ::= $ite(<thf_logic_formula>,<thf_logic_formula>, // <thf_logic_formula>) thf_conditional : '$ite(' thf_logic_formula ',' thf_logic_formula ',' thf_logic_formula ')'; //%----<thf_let> is about to be changed. Don't trust anything here. //%----The LHS of a term or formula binding must be a non-variable term that //%----is flat with pairwise distinct variable arguments, and the variables in //%----the LHS must be exactly those bound in the universally quantified variable //%----list, in the same order. Let definitions are not recursive: a non-variable //%----symbol introduced in the LHS of a let definition cannot occur in the RHS. //%----If a symbol with the same signature as the one in the LHS of the binding //%----is declared above the let expression (at the top level or in an //%----encompassing let) then it can be used in the RHS of the binding, but it is //%----not accessible in the term or formula of the let expression. Let //%----expressions can be eliminated by a simple definition expansion. //<thf_let> ::= $let(<thf_unitary_formula>,<thf_formula>) //<thf_let> :== $let(<thf_let_defns>,<thf_formula>) //<thf_let_defns> :== <thf_let_defn> | [<thf_let_defn_list>] //<thf_let_defn_list> :== <thf_let_defn> | <thf_let_defn>,<thf_let_defn_list> //<thf_let_defn> :== <thf_let_quantified_defn> | <thf_let_plain_defn> //<thf_let_quantified_defn> :== <thf_quantification> (<thf_let_plain_defn>) //<thf_let_plain_defn> :== <thf_let_defn_LHS> <assignment> <thf_formula> //<thf_let_defn_LHS> :== <constant> | <functor>(<fof_arguments>) | // <thf_tuple> thf_let : '$let(' thf_unitary_formula ',' thf_formula ')'; // TODO nothing since it is about to be changed //%----The <fof_arguments> must all be <variable>s, and the <thf_tuple> may //%----contain only <constant>s and <functor>(<fof_arguments>)s // //%----Arguments recurse back up to formulae (this is the THF world here) //<thf_arguments> ::= <thf_formula_list> thf_arguments : thf_formula_list; //%----A <thf_type_formula> is an assertion that the formula is in this type. //<thf_type_formula> ::= <thf_typeable_formula> : <thf_top_level_type> //<thf_typeable_formula> ::= <thf_atom> | (<thf_logic_formula>) //<thf_subtype> ::= <thf_atom> <subtype_sign> <thf_atom> thf_type_formula : thf_typeable_formula ':' thf_top_level_type; thf_typeable_formula : thf_atom | '(' thf_logic_formula ')'; thf_subtype : thf_atom Subtype_sign thf_atom; //%----In a formula with role 'type', <thf_type_formula> is a global declaration //%----that <constant> is in this thf_top_level_type>, i.e., the rule is ... //<thf_type_formula> :== <constant> : <thf_top_level_type> // #INFO the previous thf_type_formula leads to constant on the left side of the : //thf_type_formula : constant ':' thf_top_level_type; //%----<thf_top_level_type> appears after ":", where a type is being specified //%----for a term or variable. <thf_unitary_type> includes <thf_unitary_formula>, //%----so the syntax allows just about any lambda expression with "enough" //%----parentheses to serve as a type. The expected use of this flexibility is //%----parametric polymorphism in types, expressed with lambda abstraction. //%----Mapping is right-associative: o > o > o means o > (o > o). //%----Xproduct is left-associative: o * o * o means (o * o) * o. //%----Union is left-associative: o + o + o means (o + o) + o. //<thf_top_level_type> ::= <thf_unitary_type> | <thf_mapping_type> | // <thf_apply_type> thf_top_level_type : thf_unitary_type | thf_mapping_type | thf_apply_type; //%----Removed along with adding <thf_binary_type> to <thf_binary_formula>, for //%----TH1 polymorphic types with binary after quantification. //%---- | (<thf_binary_type>) //<thf_unitary_type> ::= <thf_unitary_formula> //<thf_apply_type> ::= <thf_apply_formula> //<thf_binary_type> ::= <thf_mapping_type> | <thf_xprod_type> | // <thf_union_type> //<thf_mapping_type> ::= <thf_unitary_type> <arrow> <thf_unitary_type> | // <thf_unitary_type> <arrow> <thf_mapping_type> //<thf_xprod_type> ::= <thf_unitary_type> <star> <thf_unitary_type> | // <thf_xprod_type> <star> <thf_unitary_type> //<thf_union_type> ::= <thf_unitary_type> <plus> <thf_unitary_type> | // <thf_union_type> <plus> <thf_unitary_type> thf_unitary_type : thf_unitary_formula; thf_apply_type : thf_apply_formula; thf_binary_type : thf_mapping_type | thf_xprod_type | thf_union_type; thf_mapping_type : thf_unitary_type Arrow thf_unitary_type | thf_unitary_type Arrow thf_mapping_type; thf_xprod_type : thf_unitary_type Star thf_unitary_type | thf_xprod_type Star thf_unitary_type; thf_union_type : thf_unitary_type Plus thf_unitary_type | thf_union_type Plus thf_unitary_type; //%----Sequents using the Gentzen arrow //<thf_sequent> ::= <thf_tuple> <gentzen_arrow> <thf_tuple> | // (<thf_sequent>) thf_sequent : thf_tuple Gentzen_arrow thf_tuple | '(' thf_sequent ')'; //%----By convention, []s are used for tuple of statements, {}s for tuples of //%----objects. The convention matches the requirements for <tff_tuple_formula>s //%----and <tff_tuple_term>s. Mixed THF tuples should use []s. //<thf_tuple> ::= [] | [<thf_formula_list>] | // {} | {<thf_formula_list>} //<thf_formula_list> ::= <thf_logic_formula> | // <thf_logic_formula>,<thf_formula_list> thf_tuple : '[]' | '[' thf_formula_list ']' | '{}' | '{' thf_formula_list '}'; thf_formula_list : thf_logic_formula (',' thf_logic_formula)*; //%----New material for modal logic semantics, not integrated yet //<logic_defn_rule> :== <logic_defn_LHS> <assignment> <logic_defn_RHS> //<logic_defn_LHS> :== <logic_defn_value> | <thf_top_level_type> | <name> //<logic_defn_LHS> :== $constants | $quantification | $consequence | // $modalities //logic_defn_rule : logic_defn_lhs Assignment logic_defn_rhs; //logic_defn_lhs : logic_defn_value // TODO dunno why this is there // | thf_function // for constant selection // | thf_top_level_type // for domain selection // | name // for axioms selection // | Dollar_word; // #RES no restrictions //| '$modal' // enables modal logical options //| '$constants' // modal logic: alter constants //| '$quantification' // modal logic: alter quantification //| '$consequence' // modal logic: alter consequence //| '$modalities'; // modal logic: alter modality operators //%----The $constants, $quantification, and $consequence apply to all of the //%----$modalities. Each of these may be specified only once, but not necessarily //%----all in a single annotated formula. //<logic_defn_RHS> :== <logic_defn_value> | <thf_unitary_formula> //<logic_defn_value> :== <defined_constant> //<logic_defn_value> :== $rigid | $flexible | // $constant | $varying | $cumulative | $decreasing | // $local | $global | // $modal_system_K | $modal_system_T | $modal_system_D | // $modal_system_S4 | $modal_system_S5 | // $modal_axiom_K | $modal_axiom_T | $modal_axiom_B | // $modal_axiom_D | $modal_axiom_4 | $modal_axiom_5 //logic_defn_rhs : logic_defn_value // | thf_unitary_formula; // TODO dunno why this is there //logic_defn_value : Dollar_word; // #RES no restrictions // '$rigid' // modal logic: consequence option // | '$flexible' // modal logic: consequence option // | '$constant' // modal logic: quantification option // | '$varying' // modal logic: quantification option // | '$cumulative' // modal logic: quantification option // | '$decreasing' // modal logic: quantification option // | '$local' // modal logic: consequence option // | '$global' // modal logic: consequence option // | '$modal_system_K' // modal logic: Axiom: K // | '$modal_system_T' // modal logic: Axiom: K + T // | '$modal_system_D' // modal logic: Axiom: K + D // | '$modal_system_S4' // modal logic: Axiom K + T + 4 // | '$modal_system_S5' // modal logic: Axiom K + T + 5 // | '$modal_axiom_K' // modal logic: box(s -> t) -> (box s -> box t) // | '$modal_axiom_T' // modal logic: box s -> s // | '$modal_axiom_B' // modal logic: s -> box dia s // | '$modal_axiom_D' // modal logic: box s -> dia s // | '$modal_axiom_4' // modal logic: box s -> box box s // | '$modal_axiom_5' // modal logic: dia s -> box dia s // | '$modal_axiom_CD' // modal logic: dia s -> box s // | '$modal_axiom_BOXM' // modal logic: box (box s -> s) // | '$modal_axiom_C4' // modal logic: box box s -> box s // | '$modal_axiom_C'; // modal logic: dia box s -> box dia s //%----Top of Page--------------------------------------------------------------- //%----TFX formulae //<tfx_formula> ::= <tfx_logic_formula> | <thf_sequent> //<tfx_logic_formula> ::= <thf_logic_formula> //% <tfx_logic_formula> ::= <thf_binary_formula> | <thf_unitary_formula> | //% <tff_typed_atom> | <tff_subtype> tfx_formula : tfx_logic_formula | thf_sequent; tfx_logic_formula : thf_logic_formula; //%----Top of Page--------------------------------------------------------------- //%----TFF formulae. //<tff_formula> ::= <tff_logic_formula> | <tff_typed_atom> | // <tff_sequent> //<tff_logic_formula> ::= <tff_binary_formula> | <tff_unitary_formula> | // <tff_subtype> //<tff_binary_formula> ::= <tff_binary_nonassoc> | <tff_binary_assoc> //<tff_binary_nonassoc> ::= <tff_unitary_formula> <binary_connective> // <tff_unitary_formula> //<tff_binary_assoc> ::= <tff_or_formula> | <tff_and_formula> //<tff_or_formula> ::= <tff_unitary_formula> <vline> <tff_unitary_formula> | // <tff_or_formula> <vline> <tff_unitary_formula> //<tff_and_formula> ::= <tff_unitary_formula> & <tff_unitary_formula> | // <tff_and_formula> & <tff_unitary_formula> //<tff_unitary_formula> ::= <tff_quantified_formula> | <tff_unary_formula> | // <tff_atomic_formula> | <tff_conditional> | // <tff_let> | (<tff_logic_formula>) tff_formula : tff_logic_formula | tff_typed_atom | tff_sequent; tff_logic_formula : tff_binary_formula | tff_unitary_formula | tff_subtype; tff_binary_formula : tff_binary_nonassoc | tff_binary_assoc; tff_binary_nonassoc : tff_unitary_formula binary_connective tff_unitary_formula; tff_binary_assoc : tff_or_formula | tff_and_formula; tff_or_formula : tff_unitary_formula Or tff_unitary_formula | tff_or_formula Or tff_unitary_formula; tff_and_formula : tff_unitary_formula And tff_unitary_formula | tff_and_formula And tff_unitary_formula; tff_unitary_formula : tff_quantified_formula | tff_unary_formula | tff_atomic_formula | tff_conditional | tff_let | '(' tff_logic_formula ')'; //%----All variables must be quantified //<tff_quantified_formula> ::= <fof_quantifier> [<tff_variable_list>] : // <tff_unitary_formula> //<tff_variable_list> ::= <tff_variable> | <tff_variable>,<tff_variable_list> //<tff_variable> ::= <tff_typed_variable> | <variable> //<tff_typed_variable> ::= <variable> : <tff_atomic_type> //<tff_unary_formula> ::= <unary_connective> <tff_unitary_formula> | // <fof_infix_unary> //<tff_atomic_formula> ::= <fof_atomic_formula> tff_quantified_formula : fof_quantifier '[' tff_variable_list ']' ':' tff_unitary_formula; tff_variable_list : tff_variable (',' tff_variable)*; // #INFO tff_variable_list flattened //tff_variable_list : tff_variable | tff_variable ',' tff_variable_list; // # ALT to tff_variable_list tff_variable : tff_typed_variable | variable; // tff_variable : variable (':' tff_atomic_type)?; // #ALT to tff_variable (more condensed) tff_typed_variable : variable ':' tff_atomic_type; tff_unary_formula : unary_connective tff_unitary_formula | fof_infix_unary; tff_atomic_formula : fof_atomic_formula; //<tff_conditional> ::= $ite_f(<tff_logic_formula>,<tff_logic_formula>, // <tff_logic_formula>) //<tff_let> ::= $let_tf(<tff_let_term_defns>,<tff_formula>) | // $let_ff(<tff_let_formula_defns>,<tff_formula>) //%----See the commentary for <thf_let>. //<tff_let_term_defns> ::= <tff_let_term_defn> | [<tff_let_term_list>] //<tff_let_term_list> ::= <tff_let_term_defn> | // <tff_let_term_defn>,<tff_let_term_list> //<tff_let_term_defn> ::= ! [<tff_variable_list>] : <tff_let_term_defn> | // <tff_let_term_binding> //<tff_let_term_binding> ::= <fof_plain_term> = <fof_term> | // (<tff_let_term_binding>) //<tff_let_formula_defns> ::= <tff_let_formula_defn> | [<tff_let_formula_list>] //<tff_let_formula_list> ::= <tff_let_formula_defn> | // <tff_let_formula_defn>,<tff_let_formula_list> //<tff_let_formula_defn> ::= ! [<tff_variable_list>] : <tff_let_formula_defn> | // <tff_let_formula_binding> //<tff_let_formula_binding> ::= <fof_plain_atomic_formula> <=> // <tff_unitary_formula> | (<tff_let_formula_binding>) tff_conditional : '$ite_f(' tff_logic_formula ',' tff_logic_formula ',' tff_logic_formula ')'; tff_let : '$let_tf(' tff_let_term_defns ',' tff_formula ')' | '$let_ff(' tff_let_formula_defns ',' tff_formula ')'; tff_let_term_defns : tff_let_term_defn | '[' tff_let_term_list ']'; tff_let_term_list : tff_let_term_defn (',' tff_let_term_defn)*; tff_let_term_defn : Forall '[' tff_variable_list ']' ':' tff_let_term_defn | tff_let_term_binding; tff_let_term_binding : fof_plain_term Infix_equality fof_term | '(' tff_let_term_binding ')'; tff_let_formula_defns : tff_let_formula_defn | '[' tff_let_formula_list ']'; tff_let_formula_list : tff_let_formula_defn (',' tff_let_formula_defn)*; tff_let_formula_defn : Forall '[' tff_variable_list ']' ':' tff_let_formula_defn | tff_let_formula_binding; tff_let_formula_binding : fof_plain_atomic_formula Iff tff_unitary_formula | '(' tff_let_formula_binding ')'; //<tff_sequent> ::= <tff_formula_tuple> <gentzen_arrow> // <tff_formula_tuple> | (<tff_sequent>) //<tff_formula_tuple> ::= [] | [<tff_formula_tuple_list>] //<tff_formula_tuple_list> ::= <tff_logic_formula> | // <tff_logic_formula>,<tff_formula_tuple_list> tff_sequent : tff_formula_tuple Gentzen_arrow tff_formula_tuple | '(' tff_sequent ')'; tff_formula_tuple : '[]' | '[' tff_formula_tuple_list ']'; tff_formula_tuple_list : tff_logic_formula (',' tff_logic_formula)*; //%----<tff_typed_atom> can appear only at top level //<tff_typed_atom> ::= <untyped_atom> : <tff_top_level_type> | // (<tff_typed_atom>) // //<tff_subtype> ::= <untyped_atom> <subtype_sign> <atom> tff_typed_atom : untyped_atom ':' tff_top_level_type | '(' tff_typed_atom ')'; tff_subtype : untyped_atom Subtype_sign atom; //%----See <thf_top_level_type> for commentary. //<tff_top_level_type> ::= <tff_atomic_type> | <tff_mapping_type> | // <tf1_quantified_type> | (<tff_top_level_type>) //<tf1_quantified_type> ::= !> [<tff_variable_list>] : <tff_monotype> //<tff_monotype> ::= <tff_atomic_type> | (<tff_mapping_type>) //<tff_unitary_type> ::= <tff_atomic_type> | (<tff_xprod_type>) //<tff_atomic_type> ::= <type_constant> | <defined_type> | // <type_functor>(<tff_type_arguments>) | <variable> //<tff_type_arguments> ::= <tff_atomic_type> | // <tff_atomic_type>,<tff_type_arguments> //%----For consistency with <thf_unitary_type> (the analogue in thf), //%----<tff_atomic_type> should also allow (<tff_atomic_type>), but that causes //%----ambiguity. //<tff_mapping_type> ::= <tff_unitary_type> <arrow> <tff_atomic_type> //<tff_xprod_type> ::= <tff_unitary_type> <star> <tff_atomic_type> | // <tff_xprod_type> <star> <tff_atomic_type> tff_top_level_type : tff_atomic_type | tff_mapping_type | tf1_quantified_type | '(' tff_top_level_type ')'; tf1_quantified_type : '!>' '[' tff_variable_list ']' ':' tff_monotype; tff_monotype : tff_atomic_type | '(' tff_mapping_type ')'; tff_unitary_type : tff_atomic_type | '(' tff_xprod_type ')'; tff_atomic_type : type_constant | defined_type | type_functor '(' tff_type_arguments ')' | variable; // tff_atomic_type : defined_type | type_functor ('(' tff_type_arguments ')')? | variable; // #ALT to tff_atomic_type (more condensed) tff_type_arguments : tff_atomic_type (',' tff_atomic_type)*; tff_mapping_type : tff_unitary_type Arrow tff_atomic_type; tff_xprod_type : tff_unitary_type Star tff_atomic_type | tff_xprod_type Star tff_atomic_type; //%----Top of Page--------------------------------------------------------------- //%----TCF formulae. //<tcf_formula> ::= <tcf_logic_formula> | <tff_typed_atom> //<tcf_logic_formula> ::= <tcf_quantified_formula> | <cnf_formula> //<tcf_quantified_formula> ::= ! [<tff_variable_list>] : <cnf_formula> tcf_formula : tcf_logic_formula | tff_typed_atom; tcf_logic_formula : tcf_quantified_formula | cnf_formula; tcf_quantified_formula : Forall '[' tff_variable_list ']' ':' cnf_formula; //%----Top of Page--------------------------------------------------------------- //%----FOF formulae. //<fof_formula> ::= <fof_logic_formula> | <fof_sequent> //<fof_logic_formula> ::= <fof_binary_formula> | <fof_unitary_formula> //%----Future answer variable ideas | <answer_formula> //<fof_binary_formula> ::= <fof_binary_nonassoc> | <fof_binary_assoc> //%----Only some binary connectives are associative //%----There's no precedence among binary connectives //<fof_binary_nonassoc> ::= <fof_unitary_formula> <binary_connective> // <fof_unitary_formula> //%----Associative connectives & and | are in <binary_assoc> //<fof_binary_assoc> ::= <fof_or_formula> | <fof_and_formula> //<fof_or_formula> ::= <fof_unitary_formula> <vline> <fof_unitary_formula> | // <fof_or_formula> <vline> <fof_unitary_formula> //<fof_and_formula> ::= <fof_unitary_formula> & <fof_unitary_formula> | // <fof_and_formula> & <fof_unitary_formula> //%----<fof_unitary_formula> are in ()s or do not have a <binary_connective> at //%----the top level. //<fof_unitary_formula> ::= <fof_quantified_formula> | <fof_unary_formula> | // <fof_atomic_formula> | (<fof_logic_formula>) //%----All variables must be quantified //<fof_quantified_formula> ::= <fof_quantifier> [<fof_variable_list>] : // <fof_unitary_formula> //<fof_variable_list> ::= <variable> | <variable>,<fof_variable_list> //<fof_unary_formula> ::= <unary_connective> <fof_unitary_formula> | // <fof_infix_unary> fof_formula : fof_logic_formula | fof_sequent; fof_logic_formula : fof_binary_formula | fof_unitary_formula; fof_binary_formula : fof_binary_nonassoc | fof_binary_assoc; fof_binary_nonassoc : fof_unitary_formula binary_connective fof_unitary_formula; fof_binary_assoc : fof_or_formula | fof_and_formula; fof_or_formula : fof_unitary_formula Or fof_unitary_formula | fof_or_formula Or fof_unitary_formula; fof_and_formula : fof_unitary_formula And fof_unitary_formula | fof_and_formula And fof_unitary_formula; fof_unitary_formula : fof_quantified_formula | fof_unary_formula | fof_atomic_formula | '(' fof_logic_formula ')'; fof_quantified_formula : fof_quantifier '[' fof_variable_list ']' ':' fof_unitary_formula; fof_variable_list : variable (',' variable)*; fof_unary_formula : unary_connective fof_unitary_formula | fof_infix_unary; //%----<fof_term> != <fof_term> is equivalent to ~ <fof_term> = <fof_term> //<fof_infix_unary> ::= <fof_term> <infix_inequality> <fof_term> //<fof_atomic_formula> ::= <fof_plain_atomic_formula> | // <fof_defined_atomic_formula> | // <fof_system_atomic_formula> //<fof_plain_atomic_formula> ::= <fof_plain_term> //<fof_plain_atomic_formula> :== <proposition> | <predicate>(<fof_arguments>) //<fof_defined_atomic_formula> ::= <fof_defined_plain_formula> | // <fof_defined_infix_formula> //<fof_defined_plain_formula> ::= <fof_defined_plain_term> //<fof_defined_plain_formula> :== <defined_proposition> | // <defined_predicate>(<fof_arguments>) //<fof_defined_infix_formula> ::= <fof_term> <defined_infix_pred> <fof_term> //%----System terms have system specific interpretations //<fof_system_atomic_formula> ::= <fof_system_term> //%----<fof_system_atomic_formula>s are used for evaluable predicates that are //%----available in particular tools. The predicate names are not controlled by //%----the TPTP syntax, so use with due care. Same for <fof_system_term>s. fof_infix_unary : fof_term Infix_inequality fof_term; fof_atomic_formula : fof_plain_atomic_formula | fof_defined_atomic_formula | fof_system_atomic_formula; fof_plain_atomic_formula : fof_plain_term; fof_defined_atomic_formula : fof_defined_plain_formula | fof_defined_infix_formula; fof_defined_plain_formula : fof_defined_term; fof_defined_infix_formula : fof_term defined_infix_pred fof_term; fof_system_atomic_formula : fof_system_term; //%----FOF terms. //<fof_plain_term> ::= <constant> | <functor>(<fof_arguments>) //%----Defined terms have TPTP specific interpretations //<fof_defined_term> ::= <defined_term> | <fof_defined_atomic_term> //<fof_defined_atomic_term> ::= <fof_defined_plain_term> //%----None yet | <defined_infix_term> //%----None yet <defined_infix_term> ::= <fof_term> <defined_infix_func> <fof_term> //%----None yet <defined_infix_func> ::= //<fof_defined_plain_term> ::= <defined_constant> | // <defined_functor>(<fof_arguments>) //%----System terms have system specific interpretations //<fof_system_term> ::= <system_constant> | <system_functor>(<fof_arguments>) fof_plain_term : constant | functor '(' fof_arguments ')'; fof_defined_term : defined_term | fof_defined_atomic_term; fof_defined_atomic_term : fof_defined_plain_term; fof_defined_plain_term : defined_constant | defined_functor '(' fof_arguments ')'; fof_system_term : system_constant | system_functor '(' fof_arguments ')'; // #ALT alternatives for these terms //fof_plain_term: functor ('(' fof_arguments ')')?; // contracted for easier handling //fof_defined_term: defined_functor ('(' fof_arguments ')')?; // contracted for easier handling //fof_system_term: system_functor ('(' fof_arguments ')')?; // contracted for easier handling //%----Arguments recurse back to terms (this is the FOF world here) //<fof_arguments> ::= <fof_term> | <fof_term>,<fof_arguments> //%----These are terms used as arguments. Not the entry point for terms because //%----<fof_plain_term> is also used as <fof_plain_atomic_formula>. The <tff_ //%----options are for only TFF, but are here because <fof_plain_atomic_formula> //%----is used in <fof_atomic_formula>, which is also used as //%----<tff_atomic_formula>. //<fof_term> ::= <fof_function_term> | <variable> | // <tff_conditional_term> | <tff_let_term> | // <tff_tuple_term> //<fof_function_term> ::= <fof_plain_term> | <fof_defined_term> | // <fof_system_term> fof_arguments : fof_term (',' fof_term)*; fof_term : fof_function_term | variable | tff_conditional_term | tff_let_term | tff_tuple_term; fof_function_term : fof_plain_term | fof_defined_term | fof_system_term; //%----Conditional terms should be used by only TFF. //<tff_conditional_term> ::= $ite_t(<tff_logic_formula>,<fof_term>,<fof_term>) //%----Let terms should be used by only TFF. $let_ft is for use when there is //%----a $ite_t in the <fof_term>. See the commentary for $let_tf and $let_ff. //<tff_let_term> ::= $let_ft(<tff_let_formula_defns>,<fof_term>) | // $let_tt(<tff_let_term_defns>,<fof_term>) //%----<tff_tuple_term> uses {}s to disambiguate from tuples of formulae in []s. //<tff_tuple_term> ::= {} | {<fof_arguments>} tff_conditional_term : '$ite_t(' tff_logic_formula ',' fof_term ',' fof_term ')'; tff_let_term : '$let_ft(' tff_let_formula_defns ',' fof_term ')' | '$let_tt(' tff_let_term_defns ',' fof_term ')'; tff_tuple_term : '{}' | '{' fof_arguments '}'; //%----Top of Page--------------------------------------------------------------- //%----This section is the FOFX syntax. Not yet in use. //% <fof_let> ::= := [<fof_let_list>] : <fof_unitary_formula> //% <fof_let_list> ::= <fof_defined_var> | //% <fof_defined_var>,<fof_let_list> //% <fof_defined_var> ::= <variable> := <fof_logic_formula> | //% <variable> :- <fof_term> | (<fof_defined_var>) //% //% <fof_conditional> ::= $ite_f(<fof_logic_formula>,<fof_logic_formula>, //% <fof_logic_formula>) //% //% <fof_conditional_term> ::= $ite_t(<fof_logic_formula>,<fof_term>,<fof_term>) // #INFO not yet in use therefore not implemented //<fof_sequent> ::= <fof_formula_tuple> <gentzen_arrow> // <fof_formula_tuple> | (<fof_sequent>) // //<fof_formula_tuple> ::= [] | [<fof_formula_tuple_list>] //<fof_formula_tuple_list> ::= <fof_logic_formula> | // <fof_logic_formula>,<fof_formula_tuple_list> fof_sequent : fof_formula_tuple Gentzen_arrow fof_formula_tuple | '(' fof_sequent ')'; fof_formula_tuple : '[]' | '[' fof_formula_tuple_list ']'; fof_formula_tuple_list : fof_logic_formula (',' fof_logic_formula)*; //%----Top of Page--------------------------------------------------------------- //%----CNF formulae (variables implicitly universally quantified) //<cnf_formula> ::= <disjunction> | (<disjunction>) //<disjunction> ::= <literal> | <disjunction> <vline> <literal> //<literal> ::= <fof_atomic_formula> | ~ <fof_atomic_formula> | // <fof_infix_unary> cnf_formula : cnf_disjunction | '(' cnf_disjunction ')'; cnf_disjunction : cnf_literal | cnf_disjunction Or cnf_literal; cnf_literal : fof_atomic_formula | Not fof_atomic_formula | fof_infix_unary; //%----Top of Page--------------------------------------------------------------- //%----Connectives - THF //<thf_quantifier> ::= <fof_quantifier> | <th0_quantifier> | // <th1_quantifier> //%----TH0 quantifiers are also available in TH1 //<th1_quantifier> ::= !> | ?* //<th0_quantifier> ::= ^ | @+ | @- //<thf_pair_connective> ::= <infix_equality> | <infix_inequality> | // <binary_connective> | <assignment> //<thf_unary_connective> ::= <unary_connective> | <th1_unary_connective> //<th1_unary_connective> ::= !! | ?? | @@+ | @@- | @= thf_quantifier : fof_quantifier | th0_quantifier | th1_quantifier; th0_quantifier : Lambda | Choice | Description; th1_quantifier : TyForall | TyExists; thf_pair_connective : Infix_equality | Infix_inequality | binary_connective | Assignment ; thf_unary_connective : unary_connective | th1_unary_connective; th1_unary_connective : ForallComb | ExistsComb | ChoiceComb | DescriptionComb | EqComb; //%----Connectives - THF and TFF //<subtype_sign> ::= << // #INFO See Lexer rules //%----Connectives - TFF //% <tff_pair_connective> ::= <binary_connective> | <assignment> tff_pair_connective : binary_connective | Assignment; //%----Connectives - FOF //<fof_quantifier> ::= ! | ? //<binary_connective> ::= <=> | => | <= | <~> | ~<vline> | ~& //<assoc_connective> ::= <vline> | & //<unary_connective> ::= ~ fof_quantifier: Forall | Exists; binary_connective: Iff | Impl | If | Niff | Nor | Nand; assoc_connective : Or | And; unary_connective : Not; //%----The seqent arrow //<gentzen_arrow> ::= --> //<assignment> ::= := // #INFO See Lexer rules for definitions //%----Types for THF and TFF //<type_constant> ::= <type_functor> //<type_functor> ::= <atomic_word> //<defined_type> ::= <atomic_defined_word> //<defined_type> :== $oType | $o | $iType | $i | $tType | // $real | $rat | $int //%----$oType/$o is the Boolean type, i.e., the type of $true and $false. //%----$iType/$i is non-empty type of individuals, which may be finite or //%----infinite. $tType is the type of all types. $real is the type of <real>s. //%----$rat is the type of <rational>s. $int is the type of <signed_integer>s //%----and <unsigned_integer>s. //<system_type> :== <atomic_system_word> type_constant : type_functor; type_functor : atomic_word; // #PREDEF defined_type : Dollar_word; // #RES no restrictions //Defined_type; //Defined_type : '$oType' | '$o' | '$iType' | '$i' | '$tType' | // '$real' | '$rat' | '$int'; // #UNDEF //defined_type : atomic_defined_word; system_type : atomic_system_word; //%----For all language types //<atom> ::= <untyped_atom> | <defined_constant> //<untyped_atom> ::= <constant> | <system_constant> atom : untyped_atom | defined_constant; untyped_atom : constant | system_constant; //<defined_proposition> :== <atomic_defined_word> //<defined_proposition> :== $true | $false //<defined_predicate> :== <atomic_defined_word> //<defined_predicate> :== $distinct | // $less | $lesseq | $greater | $greatereq | // $is_int | $is_rat | // $box_P | $box_i | $box_int | $box | // $dia_P | $dia_i | $dia_int | $dia // #PREDEF defined_proposition : Dollar_word; // #RES // Defined_proposition; // Defined_proposition : '$true' | '$false'; defined_predicate : Dollar_word; // #RES // Defined_predicate; //Defined_predicate : '$distinct' // | '$less' | '$lesseq' | '$greater' | '$greatereq' // | '$is_int' | '$is_rat' // | '$box_P' | '$box_i' | '$box_int' | '$box' // | '$dia_P' | '$dia_i' | '$dia_int' | '$dia'; //# UNDEF // defined_proposition : atomic_defined_word; // defined_predicate : atomic_defined_word; //%----$distinct means that each of it's constant arguments are pairwise !=. It //%----is part of the TFF syntax. It can be used only as a fact, not under any //%----connective. //<defined_infix_pred> ::= <infix_equality> | <assignment> //<infix_equality> ::= = //<infix_inequality> ::= != defined_infix_pred : Infix_equality | Assignment; //# INFO See lexer rules for definitions //<constant> ::= <functor> //<functor> ::= <atomic_word> constant : functor; functor : atomic_word; //<system_constant> ::= <system_functor> //<system_functor> ::= <atomic_system_word> system_constant : system_functor; system_functor : atomic_system_word; //<defined_constant> ::= <defined_functor> //<defined_functor> ::= <atomic_defined_word> //<defined_functor> :== $uminus | $sum | $difference | $product | // $quotient | $quotient_e | $quotient_t | $quotient_f | // $remainder_e | $remainder_t | $remainder_f | // $floor | $ceiling | $truncate | $round | // $to_int | $to_rat | $to_real defined_constant : defined_functor; defined_functor : atomic_defined_word; //<defined_term> ::= <number> | <distinct_object> //<variable> ::= <upper_word> defined_term : number | Distinct_object; variable : Upper_word; //%----Top of Page--------------------------------------------------------------- //%----Formula sources //<source> ::= <general_term> //<source> :== <dag_source> | <internal_source> | // <external_source> | unknown | [<sources>] //%----Alternative sources are recorded like this, thus allowing representation //%----of alternative derivations with shared parts. //<sources> :== <source> | <source>,<sources> //%----Only a <dag_source> can be a <name>, i.e., derived formulae can be //%----identified by a <name> or an <inference_record> //<dag_source> :== <name> | <inference_record> source : dag_source | internal_source | external_source | Lower_word // #RES | 'unknown' | '[' sources ']'; sources : source ( ',' source )*; // #INFO flattened //sources : source | source ',' sources; // #ALT to flattened sources dag_source : name | inference_record; //<inference_record> :== inference(<inference_rule>,<useful_info>, // <inference_parents>) //<inference_rule> :== <atomic_word> inference_record : 'inference(' inference_rule ',' useful_info ',' inference_parents ')'; inference_rule : atomic_word; //%----Examples are deduction | modus_tollens | modus_ponens | rewrite | //% resolution | paramodulation | factorization | //% cnf_conversion | cnf_refutation | ... //%----<inference_parents> can be empty in cases when there is a justification //%----for a tautologous theorem. In case when a tautology is introduced as //%----a leaf, e.g., for splitting, then use an <internal_source>. //<inference_parents> :== [] | [<parent_list>] //<parent_list> :== <parent_info> | <parent_info>,<parent_list> //<parent_info> :== <source><parent_details> //<parent_details> :== :<general_list> | <null> //<internal_source> :== introduced(<intro_type><optional_info>) //<intro_type> :== definition | axiom_of_choice | tautology | assumption inference_parents : '[]' | '[' parent_list ']'; parent_list : parent_info ( ',' parent_info )*; // #INFO flattened //parent_list : parent_info | parent_info ',' parent_list; // #ALT to flattened parent_list parent_info : source parent_details?; // #INFO ? because parent_details may be empty parent_details : ':' general_list; internal_source : 'introduced(' intro_type optional_info? ')'; intro_type : Lower_word; // #RES Intro_type; //Intro_type : 'definition' | 'axiom_of_choice' | 'tautology' | 'assumption'; //%----This should be used to record the symbol being defined, or the function //%----for the axiom of choice //<external_source> :== <file_source> | <theory> | <creator_source> //<file_source> :== file(<file_name><file_info>) //<file_info> :== ,<name> | <null> //<theory> :== theory(<theory_name><optional_info>) //<theory_name> :== equality | ac //%----More theory names may be added in the future. The <optional_info> is //%----used to store, e.g., which axioms of equality have been implicitly used, //%----e.g., theory(equality,[rst]). Standard format still to be decided. //<creator_source> :== creator(<creator_name><optional_info>) //<creator_name> :== <atomic_word> external_source : file_source | theory | creator_source; file_source : 'file(' file_name file_info? ')'; // #INFO ? because file_info may be empty file_info : ',' name; theory : 'theory(' theory_name optional_info? ')'; // #INFO ? because optional_info may be empty theory_name : Lower_word; // #RES Theory_name; //Theory_name : 'equality' | 'ac'; creator_source : 'creator(' creator_name optional_info? ')'; // #INFO ? because optional_info may be empty creator_name : atomic_word; //%----Useful info fields //<optional_info> ::= ,<useful_info> | <null> //<useful_info> ::= <general_list> //<useful_info> :== [] | [<info_items>] //<info_items> :== <info_item> | <info_item>,<info_items> //<info_item> :== <formula_item> | <inference_item> | // <general_function> optional_info : ',' useful_info; useful_info : '[]' | '[' info_items ']' | general_list; info_items : info_item ( ',' info_item )*; // #INFO flattened info_item : formula_item | inference_item | general_function; //%----Useful info for formula records //<formula_item> :== <description_item> | <iquote_item> //<description_item> :== description(<atomic_word>) //<iquote_item> :== iquote(<atomic_word>) //%----<iquote_item>s are used for recording exactly what the system output about //%----the inference step. In the future it is planned to encode this information //%----in standardized forms as <parent_details> in each <inference_record>. //%----Useful info for inference records formula_item : description_item | iquote_item; description_item : 'description(' atomic_word ')'; iquote_item : 'iquote(' atomic_word ')'; //<inference_item> :== <inference_status> | <assumptions_record> | // <new_symbol_record> | <refutation> //<inference_status> :== status(<status_value>) | <inference_info> //%----These are the success status values from the SZS ontology. The most //%----commonly used values are: //%---- thm - Every model of the parent formulae is a model of the inferred //%---- formula. Regular logical consequences. //%---- cth - Every model of the parent formulae is a model of the negation of //%---- the inferred formula. Used for negation of conjectures in FOF to //%---- CNF conversion. //%---- esa - There exists a model of the parent formulae iff there exists a //%---- model of the inferred formula. Used for Skolemization steps. //%----For the full hierarchy see the SZSOntology file distributed with the TPTP. //<status_value> :== suc | unp | sap | esa | sat | fsa | thm | eqv | tac | // wec | eth | tau | wtc | wth | cax | sca | tca | wca | // cup | csp | ecs | csa | cth | ceq | unc | wcc | ect | // fun | uns | wuc | wct | scc | uca | noc //%----<inference_info> is used to record standard information associated with an //%----arbitrary inference rule. The <inference_rule> is the same as the //%----<inference_rule> of the <inference_record>. The <atomic_word> indicates //%----the information being recorded in the <general_list>. The <atomic_word> //%----are (loosely) set by TPTP conventions, and include esplit, sr_split, and //%----discharge. //<inference_info> :== <inference_rule>(<atomic_word>,<general_list>) inference_item : inference_status | assumptions_record | new_symbol_record | refutation; inference_status : 'status(' status_value ')' | inference_info; status_value : Lower_word; // #RES Status_value; //Status_value : 'suc' | 'unp' | 'sap' | 'esa' | 'sat' | 'fsa' | 'thm' | 'eqv' | 'tac' // | 'wec' | 'eth' | 'tau' | 'wtc' | 'wth' | 'cax' | 'sca' | 'tca' | 'wca' // | 'cup' | 'csp' | 'ecs' | 'csa' | 'cth' | 'ceq' | 'unc' | 'wcc' | 'ect' // | 'fun' | 'uns' | 'wuc' | 'wct' | 'scc' | 'uca' | 'noc'; inference_info : inference_rule '(' atomic_word ',' general_list ')'; //%----An <assumptions_record> lists the names of assumptions upon which this //%----inferred formula depends. These must be discharged in a completed proof. //<assumptions_record> :== assumptions([<name_list>]) //%----A <refutation> record names a file in which the inference recorded here //%----is recorded as a proof by refutation. //<refutation> :== refutation(<file_source>) //%----A <new_symbol_record> provides information about a newly introduced symbol. //<new_symbol_record> :== new_symbols(<atomic_word>,[<new_symbol_list>]) //<new_symbol_list> :== <principal_symbol> | // <principal_symbol>,<new_symbol_list> //%----Principal symbols are predicates, functions, variables //<principal_symbol> :== <functor> | <variable> assumptions_record : 'assumptions(' '[' name_list ']' ')'; refutation : 'refutation(' file_source ')'; new_symbol_record : 'new_symbols(' atomic_word ',' '[' new_symbol_list ']' ')'; new_symbol_list : principal_symbol ( ',' principal_symbol )*; // #INFO flattened //new_symbol_list : principal_symbol | principal_symbol ',' new_symbol_list; //#ALT to flattened new_symbol_list principal_symbol : functor | variable; //%----Include directives //<include> ::= include(<file_name><formula_selection>). //<formula_selection> ::= ,[<name_list>] | <null> //<name_list> ::= <name> | <name>,<name_list> include : 'include(' file_name formula_selection? ').'; // #INFO ? because formula_selection may be empty formula_selection : ',' '[' name_list ']'; name_list : name (',' name)*; //%----Non-logical data //<general_term> ::= <general_data> | <general_data>:<general_term> | // <general_list> //<general_data> ::= <atomic_word> | <general_function> | // <variable> | <number> | <distinct_object> | // <formula_data> //<general_function> ::= <atomic_word>(<general_terms>) //%----A <general_data> bind() term is used to record a variable binding in an //%----inference, as an element of the <parent_details> list. //<general_data> :== bind(<variable>,<formula_data>) //<formula_data> ::= $thf(<thf_formula>) | $tff(<tff_formula>) | // $fof(<fof_formula>) | $cnf(<cnf_formula>) | // $fot(<fof_term>) //<general_list> ::= [] | [<general_terms>] //<general_terms> ::= <general_term> | <general_term>,<general_terms> general_term : general_data | general_data ':' general_term | general_list; general_data : atomic_word | general_function | variable | number | Distinct_object | formula_data; general_function : atomic_word '(' general_terms ')'; formula_data : '$thf(' thf_formula ')' | '$tff(' tff_formula ')' | '$fof(' fof_formula ')' | '$cnf(' cnf_formula ')' | '$fot(' fof_term ')'; general_list : '[]' | '[' general_terms ']'; general_terms : general_term (',' general_term)*; // #INFO flattened //general_terms : general_term | general_term ',' general_terms; // #ALT to flattened general_terms //%----General purpose //<name> ::= <atomic_word> | <integer> //%----Integer names are expected to be unsigned //<atomic_word> ::= <lower_word> | <single_quoted> //%----<single_quoted> tokens do not include their outer quotes, therefore the //%----<lower_word> <atomic_word> cat and the <single_quoted> <atomic_word> 'cat' //%----are the same. Quotes must be removed from a <single_quoted> <atomic_word> //%----if doing so produces a <lower_word> <atomic_word>. Note that <numbers>s //%----and <variable>s are not <lower_word>s, so '123' and 123, and 'X' and X, //%----are different. //<atomic_defined_word> ::= <dollar_word> //<atomic_system_word> ::= <dollar_dollar_word> //<number> ::= <integer> | <rational> | <real> //%----Numbers are always interpreted as themselves, and are thus implicitly //%----distinct if they have different values, e.g., 1 != 2 is an implicit axiom. //%----All numbers are base 10 at the moment. //<file_name> ::= <single_quoted> name : atomic_word | Integer; atomic_word : Lower_word | Single_quoted; atomic_defined_word : Dollar_word; atomic_system_word : Dollar_dollar_word; number : Integer | Rational | Real; file_name : Single_quoted; //<null> ::= // TOKEN RULES SEE ABOVE
programs/oeis/047/A047295.asm
karttu/loda
0
179800
; A047295: Numbers that are congruent to {0, 1, 2, 4, 6} mod 7. ; 0,1,2,4,6,7,8,9,11,13,14,15,16,18,20,21,22,23,25,27,28,29,30,32,34,35,36,37,39,41,42,43,44,46,48,49,50,51,53,55,56,57,58,60,62,63,64,65,67,69,70,71,72,74,76,77,78 mov $2,$0 lpb $2,1 trn $2,2 add $1,$2 add $1,$0 sub $0,$0 trn $2,2 sub $1,$2 trn $2,1 lpe
src/libriscv-sim-log.adb
Fabien-Chouteau/libriscv
0
29938
<reponame>Fabien-Chouteau/libriscv<filename>src/libriscv-sim-log.adb ------------------------------------------------------------------------------ -- -- -- Copyright (C) 2019, <NAME> -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body LibRISCV.Sim.Log is ------------- -- Set_Arg -- ------------- function Set_Arg (S : String) return Boolean is function Handle_Item (Item : String) return Boolean is Enable : constant Boolean := Item (Item'First) /= '-'; Substr : constant String := Item ((if not Enable then Item'First + 1 else Item'First) .. Item'Last); begin if Substr = "console" then Console := Enable; elsif Substr = "info" then Info := Enable; elsif Substr = "decode" then Decode := Enable; elsif Substr = "exec" then Exec := Enable; elsif Substr = "except" then Except := Enable; elsif Substr = "mem" then Mem_Access := Enable; elsif Substr = "csr" then CSRs := Enable; elsif Substr = "elf" then Elf := Enable; else Put_Line ("Log topics:"); Put_Line (" - console"); Put_Line (" - info"); Put_Line (" - decode"); Put_Line (" - exec"); Put_Line (" - except"); Put_Line (" - mem"); Put_Line (" - csr"); Put_Line (" - elf"); return False; end if; return True; end Handle_Item; From, To : Integer; begin From := S'First; To := S'First - 1; loop To := To + 1; if To > S'Last or else S (To) = ',' then if To > From then if not Handle_Item (S (From .. To - 1)) then return False; end if; end if; To := To + 1; From := To; end if; exit when To > S'Last; end loop; return True; end Set_Arg; end LibRISCV.Sim.Log;
exe/endsect.asm
DigitalMars/optlink
28
179374
TITLE ENDSECT - Copyright (c) SLR Systems 1994 INCLUDE MACROS INCLUDE IO_STRUC INCLUDE SECTS INCLUDE SECTIONS INCLUDE EXES PUBLIC EXE_OUT_END_OF_SECTION,EO_CV .DATA EXTERNDEF TEMP_RECORD:BYTE EXTERNDEF OVL_PANIC_PARAS:DWORD,OVL_DELTA_PARAS:DWORD,RELOC_CHUNK_COUNT:DWORD,SECTION_NUMBER:DWORD EXTERNDEF CURN_SECTION_GINDEX:DWORD,CV_GTYPE_HASH_LOG:DWORD,CV_INDEX_TABLE:DWORD,DONT_PACK:DWORD EXTERNDEF SECTION_PARAS:DWORD,CURN_OUTFILE_GINDEX:DWORD,LAST_CV_MODULE_GINDEX:DWORD EXTERNDEF CODEVIEW_SECTION_GINDEX:DWORD,GSYM_HASH_LOG:DWORD,SSYM_HASH_LOG:DWORD,NEW_REPT_ADDR:DWORD EXTERNDEF FINAL_HIGH_WATER:DWORD,CURN_OUTFILE_BASE_ADDRESS:DWORD,CV_INDEX_COUNT:DWORD EXTERNDEF CURN_SECTION_FILE_ADDRESS:DWORD,EXEHDR_ADDR:DWORD,EXE_OUT_POSITION:DWORD,OVR_INIT_ADDR:DWORD EXTERNDEF VECTOR_SECTION_FILE_ADDRESS:DWORD,BYTES_SO_FAR:DWORD,CV_HEADER:DWORD,CV_HEADER_LOC:DWORD EXTERNDEF FIRST_SECTION_GINDEX:DWORD EXTERNDEF SECTION_GARRAY:STD_PTR_S,OUTFILE_GARRAY:STD_PTR_S,MDB_GARRAY:STD_PTR_S,EXEPACK_STRUCTURE:SEQ_STRUCT EXTERNDEF EXEHEADER:EXE,REAL_RELOC_STRUCT:SEQ_STRUCT EXTERNDEF OUT_FLUSH_SEGMENT:DWORD,CV_SEGTBL:DWORD,CV_PUBLICS_ALL:DWORD,CV_GLOBALS_ALL:DWORD EXTERNDEF CV_TYPES_ALL:DWORD,CV_STATICS_ALL:DWORD,CV_FILES_ALL:DWORD .CODE PASS2_TEXT EXTERNDEF DO_COMPRESS:PROC,FINAL_HIGH_PARA:PROC,MOVE_EAX_TO_FINAL_HIGH_WATER:PROC,FLUSH_OUTFILE_CLOSE:PROC EXTERNDEF FLUSH_EXESTR:PROC,ZERO_EAX_EDX_FINAL:PROC,DO_EXEHEADER:PROC,MOVE_EAX_TO_EDX_FINAL:PROC,ERR_RET:PROC EXTERNDEF FLUSH_PACK:PROC,ZERO_EAX_FINAL_HIGH_WATER:PROC,MOVE_EXEHDR_TO_FINAL:PROC,RELEASE_BLOCK:PROC EXTERNDEF CV_LINNUMS_ALL:PROC,CV_LIBRARIES:PROC,FLUSH_CV_INDEXES:PROC,CV_MODULE_CHANGE:PROC,ERR_ABORT:PROC EXTERNDEF ALLOW_XREF_MAP:PROC,UNUSE_SYMBOLS:PROC,REPORT_UNDEFINEDS_2:PROC,UNUSE_MDB_PARRAY:PROC EXTERNDEF DO_DERIVATIONS:PROC EXTERNDEF COM_PC_ERR:ABS EXE_OUT_END_OF_SECTION PROC ; ;DEAL WITH END OF A SECTION (SECTION 0 IS MAIN TROUBLE...) ; CALL OUT_FLUSH_SEGMENT ;FLUSHES BUFFERED EXEPACK STUFF MOV EAX,CURN_SECTION_GINDEX MOV ECX,FIRST_SECTION_GINDEX CMP EAX,ECX JZ L5$ CMP CODEVIEW_SECTION_GINDEX,EAX JZ EO_CV ife any_overlays MOV AL,0 JMP ERR_ABORT else if fg_slrpack BITT SLRPACK_FLAG JZ L1$ MOV AX,EXEPACK_STRUCTURE._SEQ_PTR.LW MOV NEW_REPT_ADDR.LW,AX MOV AX,EXEPACK_STRUCTURE._SEQ_PTR.HW MOV NEW_REPT_ADDR.HW,AX OR AX,NEW_REPT_ADDR.LW JZ 1$ CALL DO_COMPRESS L1$: endif CALL FINAL_HIGH_PARA ;NOW DO RELOCS IF ANY ; ;NOW, WRITE # OF PARAS IN IMAGE, AND NUMBER OF RELOC CHUNKS, ; FIXES LEA DI,TEMP_RECORD MOV AX,FINAL_HIGH_WATER.LW MOV DX,FINAL_HIGH_WATER.HW ADD AX,CURN_OUTFILE_BASE_ADDRESS.LW ADC DX,CURN_OUTFILE_BASE_ADDRESS.HW SUB AX,CURN_SECTION_FILE_ADDRESS.LW SBB DX,CURN_SECTION_FILE_ADDRESS.HW CALL SHR_DXAX_4 OR AX,AX .EN CJ JZ 2$ ;EMPTY SECTION... .DS CJ MOV SECTION_PARAS,AX ;FOR .MAP DEC AX ;DON'T COUNT THIS PARAGRAPH SUB AX,OVL_PANIC_PARAS ;OR PANIC PARAGRAPHS STOSW XOR AX,AX XCHG AX,OVL_DELTA_PARAS STOSW ;LOAD OFFSET IN PARAGRAPHS XOR AX,AX XCHG AX,OVL_PANIC_PARAS STOSW ;PANIC # OF PARAS XOR AX,AX XCHG AX,RELOC_CHUNK_COUNT STOSW ; ;WRITE FIRST 8 BYTES OF RELOC STRUCT ; LEA BX,REAL_RELOC_STRUCT._SEQ_TABLE XOR SI,SI MOV CX,DGROUP:[BX]._SEQ_PTR.LW-_SEQ_TABLE JCXZ 19$ MOV DS,DGROUP:[BX] ASSUME DS:NOTHING SYM_CONV_DS ; ;AX IS SMALLER OF 8 AND BYTES LEFT ; MOV AX,8 CMP AX,CX JBE 11$ MOV AX,CX 11$: MOV CX,4 REP MOVSW XCHG AX,CX 19$: PUSHM CX,BX FIXDS LEA SI,TEMP_RECORD MOV CX,10H CALL MOVE_EXEHDR_TO_FINAL POPM BX,SI OR SI,SI JZ 03$ SUB DGROUP:[BX]._SEQ_PTR.LW-_SEQ_TABLE,SI ; ;CX IS NUMBER OF BYTES TO WRITE ; XOR CX,CX XCHG CX,DGROUP:[BX]._SEQ_PTR.LW-_SEQ_TABLE ASSUME DS:NOTHING 01$: MOV DS,DGROUP:[BX] SYM_CONV_DS ; ;IF CX > PAGE_SIZE, WRITE PAGE_SIZE ; PUSHM BX,CX ADD CX,SI CMP CX,PAGE_SIZE JB 02$ MOV CX,PAGE_SIZE 02$: SUB CX,SI PUSHM CX,SI ; ; ; PUSHM CX,DX,AX XCHG AX,CX ADD AX,15 XOR DX,DX CALL SHR_DXAX_4 ADD SECTION_PARAS,AX POPM AX,DX,CX CALL MOVE_DSSI_TO_FINAL_HIGH_WATER POPM SI,AX,CX,BX PUSH AX XOR AX,AX XCHG AX,DGROUP:[BX] CALL RELEASE_BLOCK POP AX ADD SI,AX CMP SI,PAGE_SIZE JNZ 03$ XOR SI,SI INC BX INC BX SUB CX,AX JNZ 01$ 03$: endif L2$: ; ;NOW, IF DOING OVERLAYS, ROUND OUTPUT TO PARAGRAPH BOUNDARY ; if any_overlays BITT DOING_OVERLAYS JZ 21$ CALL FINAL_HIGH_PARA endif L21$: if any_overlays LDS SI,CURN_SECTION SYM_CONV_DS MOV AX,SECTION_PARAS MOV [SI]._SECT_FILE_SIZE,AX endif XOR EAX,EAX MOV ECX,CURN_OUTFILE_GINDEX RESS EXEPACK_SELECTED,AL RESS EXEPACK_BODY,AL if fg_slrpack RESS SLRPACK_FLAG,AL endif MOV DONT_PACK,EAX CONVERT ECX,ECX,OUTFILE_GARRAY ASSUME ECX:PTR OUTFILE_STRUCT DEC [ECX]._OF_SECTIONS ;# OF SECTIONS USING THIS FILE JNZ L25$ ; ;LAST SECTION TO USE THIS FILE, FLUSH AND CLOSE ; CALL FLUSH_OUTFILE_CLOSE XOR EAX,EAX MOV CURN_OUTFILE_GINDEX,EAX RET L25$: ; CALL FLUSH_OUTFILE RET ASSUME ECX:NOTHING L5$: ; ;IF COM, PROBABLY DONE... ; BITT OUTPUT_COM_SYS JNZ L7$ if any_overlays BITT DOING_OVERLAYS JZ 51$ CALL FIX_START_ADDRESS 51$: endif BITT EXEPACK_SELECTED JNZ L8$ ; ;ZERO ANY SPACE BETWEEN END OF RELOCS AND START OF EXE ; MOV EDX,EXEHDR_ADDR MOV EAX,EXE_OUT_POSITION SUB EAX,EDX CALL ZERO_EAX_EDX_FINAL CALL DO_EXEHEADER MOV ECX,EXE._EXE_FIRST_RELOC L6$: PUSHM EDX,ECX,EAX CALL FLUSH_EXESTR ;WRITE MISCELLANEOUS JUNK if any_overlays BITT DOING_OVERLAYS JZ 61$ CALL FINAL_HIGH_PARA ; ;ALLOW SPACE FOR VECTOR AND SECTION STORAGE ; CALL DO_VECSEC_ZERO 61$: endif POPM EAX,ECX,EDX CALL MOVE_EAX_TO_EDX_FINAL JMP L2$ L7$: BITT OUTPUT_COM JZ L75$ ; ;VERIFY START ADDRESS ; CMP EXEHEADER._EXE_REG_CS,0 JNZ L72$ CMP EXEHEADER._EXE_REG_IP,100H JZ L75$ L72$: MOV AX,COM_PC_ERR CALL ERR_RET L75$: JMP L2$ L8$: CALL FLUSH_PACK JMP L6$ EO_CV:: if fg_cv CALL EO_CV_ROUTINE JMP L21$ else RET endif EXE_OUT_END_OF_SECTION ENDP if fg_cv PUBLIC EO_CV_ROUTINE EO_CV_ROUTINE PROC BITT CODEVIEW_FLAG JZ EO_CV9 L81$: CALL CV_MODULE_CHANGE ;FLUSH ANY REMAINING CODEVIEW INFORMATION CMP LAST_CV_MODULE_GINDEX,0 JNZ L81$ if fg_cvpack ; ;RELEASE GSYM_HASH_LOG, CV_GTYPE_HASH_LOG, ETC ; BITT CVPACK_FLAG JZ L3$ XOR EAX,EAX XCHG GSYM_HASH_LOG,EAX OR EAX,EAX JZ L21$ CALL RELEASE_BLOCK L21$: XOR EAX,EAX XCHG SSYM_HASH_LOG,EAX OR EAX,EAX JZ L23$ CALL RELEASE_BLOCK L23$: CALL DO_DERIVATIONS XOR EAX,EAX XCHG CV_GTYPE_HASH_LOG,EAX OR EAX,EAX JZ L22$ CALL RELEASE_BLOCK L22$: L3$: endif CALL CV_PUBLICS_ALL ;OUTPUT GLOBALPUB TABLE SETT DOING_DEBUG ; CALL ALLOW_XREF_MAP ;I'M DONE WITH SYMBOLS, ALLOW XREF TO RUN CALL REPORT_UNDEFINEDS_2 CALL UNUSE_SYMBOLS ;IN FACT, I'M COMPLETELY DONE WITH MAJOR SYMBOL TABLE CALL CV_GLOBALS_ALL ;OUTPUT SSTGLOBALSYM CALL CV_LIBRARIES CALL CV_TYPES_ALL ;OUTPUT SSTGLOBALTYPES CALL CV_STATICS_ALL ;OUTPUT SSTSTATICSYM CALL CV_FILES_ALL ;OUTPUT SSTFILEINDEX CALL UNUSE_MDB_PARRAY CALL CV_SEGTBL ;OUTPUT SEGTBL AND NAMETBL ; ;STORE OFFSET TO INDEXES IN CV_HEADER ; MOV EDX,BYTES_SO_FAR MOV EAX,OFF CV_HEADER MOV CV_HEADER+4,EDX MOV ECX,8 MOV EDX,CV_HEADER_LOC CALL MOVE_EAX_TO_EDX_FINAL ; ;OUTPUT COUNT OF INDEXES ; MOV ECX,CV_INDEX_TABLE BITT CV_4_TYPE JZ EO_CV7 MOV EAX,12*64K+16 ;LENGTH OF THIS STRUCTURE MOV EDX,CV_INDEX_COUNT MOV [ECX],EAX MOV [ECX+4],EDX XOR EAX,EAX MOV [ECX+8],EAX ;LINK TO NEXT DIRECTORY SET MOV [ECX+12],EAX ;UNDEFINED JMP EO_CV8 EO_CV7: MOV EAX,CV_INDEX_COUNT MOV WPTR [ECX],AX EO_CV8: CALL FLUSH_CV_INDEXES EO_CV9: RET EO_CV_ROUTINE ENDP endif if any_overlays DO_VECSEC_ZERO PROC NEAR ; ;WRITE ZEROS WHERE WE WILL BE STORING SECTION OFFSETS AND VECTORS (FILLED IN BY RFLUSH) ; MOV AX,FINAL_HIGH_WATER.LW MOV DX,FINAL_HIGH_WATER.HW MOV VECTOR_SECTION_FILE_ADDRESS.LW,AX MOV VECTOR_SECTION_FILE_ADDRESS.HW,DX MOV BX,AX MOV CX,DX MOV AX,16 MUL EXEHEADER._EXE_HDR_SIZE SUB BX,AX SBB CX,DX MOV EXEHEADER._EXE_VECSEC_ADDR.LW,BX MOV EXEHEADER._EXE_VECSEC_ADDR.HW,CX ; MOV AX,6 ;SECTION #, SEGMENT, OFFSET ; MUL VECTOR_COUNT ; MOV BX,AX ; MOV CX,DX XOR CX,CX XOR BX,BX MOV AX,3 ;PARA OFFSET IN FILE MUL SECTION_NUMBER ADD AX,BX ADC DX,CX ADD AX,5 ;WORD # OF PARAS IN HEADER, 3-BYTE TIME&DATE ADC DX,0 XCHG AX,CX XCHG AX,DX CALL ZERO_AXCX_FINAL_HIGH_WATER RET DO_VECSEC_ZERO ENDP FIX_START_ADDRESS PROC NEAR ; ;FIND SYMBOL REQUESTED BY OVERLAY INIT ; LDS SI,OVR_INIT_ADDR SYM_CONV_DS MOV DX,[SI]._S_FRAME.HW MOV AX,[SI]._S_FRAME.LW MOV BX,[SI]._S_OFFSET.LW AND AL,0F0H SUB BX,AX MOV EXEHEADER._EXE_REG_IP,BX CALL SHR_DXAX_4 MOV EXEHEADER._EXE_REG_CS,AX RET FIX_START_ADDRESS ENDP endif END
libsrc/gfx/wide/w_stencil_add_lineto.asm
Frodevan/z88dk
38
26486
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Trace a relative line in the stencil vectors ; ; <NAME> - 08/10/2009 ; ; ; $Id: w_stencil_add_lineto.asm,v 1.4 2016-04-23 20:37:40 dom Exp $ ; ;; void stencil_add_lineto(int x, int y, unsigned char *stencil) IF !__CPU_INTEL__ SECTION code_graphics PUBLIC stencil_add_lineto PUBLIC _stencil_add_lineto EXTERN w_line EXTERN stencil_add_pixel EXTERN swapgfxbk EXTERN swapgfxbk1 EXTERN stencil_ptr EXTERN __graphics_end .stencil_add_lineto ._stencil_add_lineto push ix ld ix,2 add ix,sp ld l,(ix+2) ;pointer to stencil ld h,(ix+3) ld (stencil_ptr),hl ld l,(ix+6) ;y1 ld h,(ix+7) ld e,(ix+4) ;x1 ld d,(ix+5) call swapgfxbk ld ix,stencil_add_pixel call w_line jp __graphics_end ENDIF
data/tilesets/fuschia_collision.asm
Trap-Master/spacworld97-thingy
0
87298
tilecoll WALL, WALL, WALL, WALL ; 00 tilecoll WALL, WALL, WALL, WALL ; 01 tilecoll WALL, WALL, WALL, WALL ; 02 tilecoll WALL, WALL, WALL, WALL ; 03 tilecoll WALL, WALL, WALL, DOOR ; 04 tilecoll WALL, WALL, WALL, WALL ; 05 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 06 tilecoll HOP_DOWN, HOP_DOWN, WALL, WALL ; 07 tilecoll WALL, WALL, WALL, WALL ; 08 tilecoll WALL, WALL, WALL, WALL ; 09 tilecoll WALL, WALL, WALL, DOOR ; 0a tilecoll TALL_GRASS, TALL_GRASS, TALL_GRASS, TALL_GRASS ; 0b tilecoll WALL, WALL, WALL, WALL ; 0c tilecoll WALL, WALL, WALL, WALL ; 0d tilecoll WALL, WALL, WALL, WALL ; 0e tilecoll WARP_CARPET_LEFT, FLOOR, WARP_CARPET_LEFT, FLOOR ; 0f tilecoll WALL, WALL, WALL, WALL ; 10 tilecoll WALL, WALL, DOOR, WALL ; 11 tilecoll WALL, WALL, WALL, WALL ; 12 tilecoll WALL, WALL, WALL, WALL ; 13 tilecoll WALL, WALL, WALL, WALL ; 14 tilecoll WALL, FLOOR, WALL, WALL ; 15 tilecoll WALL, FLOOR, WALL, FLOOR ; 16 tilecoll FLOOR, FLOOR, WALL, WALL ; 17 tilecoll FLOOR, FLOOR, WALL, WALL ; 18 tilecoll WALL, FLOOR, WALL, FLOOR ; 19 tilecoll WALL, WALL, WALL, WALL ; 1a tilecoll FLOOR, FLOOR, WALL, FLOOR ; 1b tilecoll WALL, FLOOR, WALL, FLOOR ; 1c tilecoll WATER, WATER, WATER, WATER ; 1d tilecoll WATER, WATER, WATER, WATER ; 1e tilecoll WATER, WATER, WATER, WATER ; 1f tilecoll WATER, WATER, WATER, WATER ; 20 tilecoll WATER, WATER, WATER, WATER ; 21 tilecoll WATER, WATER, WATER, WATER ; 22 tilecoll FLOOR, FLOOR, WALL, WALL ; 23 tilecoll WALL, WALL, WALL, WALL ; 24 tilecoll WALL, WALL, WALL, WALL ; 25 tilecoll WALL, FLOOR, WALL, WALL ; 26 tilecoll FLOOR, FLOOR, WALL, FLOOR ; 27 tilecoll WALL, WALL, WALL, WALL ; 28 tilecoll WALL, WALL, WALL, WALL ; 29 tilecoll HOP_DOWN, FLOOR, WALL, FLOOR ; 2a tilecoll FLOOR, FLOOR, WALL, WALL ; 2b tilecoll WALL, WALL, WALL, WALL ; 2c tilecoll WATER, WATER, WATER, WATER ; 2d tilecoll WATER, WATER, WATER, WATER ; 2e tilecoll FLOOR, FLOOR, FLOOR, WALL ; 2f tilecoll FLOOR, FLOOR, FLOOR, WALL ; 30 tilecoll WALL, WALL, WALL, WALL ; 31 tilecoll WALL, CUT_TREE, WALL, FLOOR ; 32 tilecoll WALL, WALL, FLOOR, CUT_TREE ; 33 tilecoll CUT_TREE, FLOOR, WALL, WALL ; 34 tilecoll FLOOR, CUT_TREE, WALL, FLOOR ; 35 tilecoll WALL, WALL, FLOOR, WALL ; 36 tilecoll WALL, WALL, WALL, WALL ; 37 tilecoll FLOOR, FLOOR, WALL, WALL ; 38 tilecoll WALL, WALL, WALL, WALL ; 39 tilecoll WALL, WALL, WALL, WALL ; 3a tilecoll WALL, WALL, WALL, WALL ; 3b tilecoll FLOOR, FLOOR, WALL, WALL ; 3c tilecoll WALL, WALL, WALL, WALL ; 3d tilecoll WALL, FLOOR, WALL, FLOOR ; 3e tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 3f tilecoll FLOOR, HOP_DOWN, FLOOR, WALL ; 40 tilecoll WALL, FLOOR, WALL, FLOOR ; 41 tilecoll HOP_DOWN, WALL, WALL, WALL ; 42 tilecoll WATER, WATER, WATER, WATER ; 43 tilecoll WALL, WALL, WALL, WALL ; 44 tilecoll WALL, WALL, WALL, DOOR ; 45 tilecoll WATER, WATER, WALL, WALL ; 46 tilecoll WALL, FLOOR, WALL, WALL ; 47 tilecoll FLOOR, WALL, FLOOR, WALL ; 48 tilecoll FLOOR, WALL, FLOOR, WALL ; 49 tilecoll FLOOR, FLOOR, FLOOR, WALL ; 4a tilecoll FLOOR, WALL, CUT_TREE, WALL ; 4b tilecoll FLOOR, FLOOR, WALL, FLOOR ; 4c tilecoll FLOOR, WALL, FLOOR, WALL ; 4d tilecoll FLOOR, WALL, CUT_TREE, WALL ; 4e tilecoll HOP_DOWN, FLOOR, FLOOR, FLOOR ; 4f tilecoll WATER, WATER, WALL, WALL ; 50 tilecoll FLOOR, FLOOR, WALL, WALL ; 51 tilecoll FLOOR, FLOOR, WALL, WALL ; 52 tilecoll WALL, WATER, WALL, WALL ; 53 tilecoll WALL, WATER, WALL, WATER ; 54 tilecoll WATER, WATER, WALL, WALL ; 55 tilecoll WALL, WALL, WALL, WALL ; 56 tilecoll WALL, WALL, WALL, WALL ; 57 tilecoll WALL, HOP_LEFT, WALL, HOP_LEFT ; 58 tilecoll HOP_RIGHT, WALL, HOP_RIGHT, WALL ; 59 tilecoll WALL, HOP_DOWN_LEFT, WALL, WALL ; 5a tilecoll HOP_DOWN_RIGHT, WALL, WALL, WALL ; 5b tilecoll WATER, WATER, WALL, WALL ; 5c tilecoll FLOOR, FLOOR, WALL, WALL ; 5d tilecoll FLOOR, FLOOR, WALL, WALL ; 5e tilecoll FLOOR, FLOOR, WALL, WALL ; 5f tilecoll FLOOR, WALL, CUT_TREE, WALL ; 60 tilecoll WALL, FLOOR, WALL, FLOOR ; 61 tilecoll WALL, FLOOR, WALL, FLOOR ; 62 tilecoll FLOOR, FLOOR, WALL, FLOOR ; 63 tilecoll WATER, WATER, WATER, WATER ; 64 tilecoll WATER, WATER, WATER, WATER ; 65 tilecoll WATER, WATER, WATER, WATER ; 66 tilecoll WALL, FLOOR, WALL, FLOOR ; 67 tilecoll WALL, FLOOR, WALL, WALL ; 68 tilecoll FLOOR, FLOOR, WALL, WALL ; 69 tilecoll FLOOR, FLOOR, WALL, WALL ; 6a tilecoll FLOOR, FLOOR, WALL, WALL ; 6b tilecoll WALL, WALL, FLOOR, FLOOR ; 6c tilecoll WALL, FLOOR, WALL, FLOOR ; 6d tilecoll FLOOR, WALL, FLOOR, WALL ; 6e tilecoll FLOOR, FLOOR, WALL, WALL ; 6f tilecoll WALL, WALL, WALL, WALL ; 70 tilecoll WALL, WALL, FLOOR, FLOOR ; 71 tilecoll WALL, WALL, FLOOR, FLOOR ; 72 tilecoll WALL, WALL, FLOOR, FLOOR ; 73 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 74 tilecoll FLOOR, WALL, FLOOR, WALL ; 75 tilecoll WALL, FLOOR, WALL, FLOOR ; 76 tilecoll WATER, WATER, WALL, WALL ; 77 tilecoll WALL, WALL, WALL, WALL ; 78 tilecoll WALL, WALL, WALL, WALL ; 79 tilecoll WALL, WALL, DOOR, WALL ; 7a tilecoll WALL, WALL, WALL, WALL ; 7b tilecoll WALL, WALL, WALL, WALL ; 7c tilecoll WALL, WALL, WALL, WALL ; 7d tilecoll FLOOR, FLOOR, WALL, WALL ; 7e tilecoll WALL, WALL, WALL, WALL ; 7f tilecoll WALL, WALL, WALL, WALL ; 80 tilecoll WALL, FLOOR, WALL, WALL ; 81 tilecoll WALL, WALL, WALL, WALL ; 82 tilecoll WALL, WALL, WALL, WALL ; 83 tilecoll WALL, WALL, WALL, WALL ; 84 tilecoll WALL, WALL, WALL, WALL ; 85 tilecoll WALL, FLOOR, WALL, FLOOR ; 86 tilecoll FLOOR, FLOOR, WALL, FLOOR ; 87 tilecoll WALL, HOP_DOWN, WALL, WALL ; 88 tilecoll FLOOR, HOP_DOWN, FLOOR, WALL ; 89 tilecoll WALL, FLOOR, WALL, FLOOR ; 8a tilecoll FLOOR, FLOOR, WARP_CARPET_DOWN, WARP_CARPET_DOWN ; 8b tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8c tilecoll WARP_CARPET_LEFT, WARP_CARPET_RIGHT, WARP_CARPET_LEFT, WARP_CARPET_RIGHT ; 8d tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8e tilecoll FLOOR, WARP_CARPET_RIGHT, FLOOR, WARP_CARPET_RIGHT ; 8f tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 90 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 91 tilecoll FLOOR, FLOOR, FLOOR, WARP_CARPET_DOWN ; 92 tilecoll FLOOR, FLOOR, WARP_CARPET_DOWN, FLOOR ; 93 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 94 tilecoll FLOOR, FLOOR, WALL, FLOOR ; 95 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 96 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 97 tilecoll WALL, HOP_LEFT, WALL, HOP_LEFT ; 98 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 99 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 9a tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 9b tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 9c tilecoll WALL, WALL, WALL, WALL ; 9d tilecoll FLOOR, WALL, FLOOR, WALL ; 9e tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 9f tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a0 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a1 tilecoll FLOOR, FLOOR, WALL, WALL ; a2 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a3 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a4 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a5 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a6 tilecoll FLOOR, FLOOR, WALL, FLOOR ; a7 tilecoll FLOOR, FLOOR, WALL, WALL ; a8 tilecoll WALL, WALL, WALL, WALL ; a9 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; aa tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ab tilecoll WALL, WALL, WALL, WALL ; ac tilecoll WALL, WALL, WALL, WALL ; ad tilecoll WATER, WATER, WATER, WATER ; ae tilecoll WATER, WATER, WATER, WATER ; af tilecoll WATER, WATER, WATER, WATER ; b0 tilecoll WATER, WATER, WATER, WATER ; b1 tilecoll WATER, WATER, WATER, WATER ; b2 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; b3 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; b4 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; b5 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; b6 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; b7 tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; b8 tilecoll WALL, WALL, WALL, WALL ; b9 tilecoll WALL, WALL, DOOR, WALL ; ba tilecoll WALL, WALL, WALL, WALL ; bb tilecoll WALL, WALL, WALL, WALL ; bc tilecoll WALL, WALL, WALL, WALL ; bd tilecoll WALL, WALL, WALL, WALL ; be tilecoll WALL, WALL, WALL, WALL ; bf
defines/fdc-defs.asm
dougmasten/coco_dev
2
23757
; fdc-defs.asm *pragmapush list ; Save state of list pragma pragma nolist ; Turn off assembly listing and exclude from symbol list ifndef FDC_DEFS ; Load defines only once ; Floppy Disk Controller (Western Digital 1793) FDC_CTRL equ $ff40 ; Floppy disk controller control register (Write Only) ; Bit 7 - Halt flag: 0=disabled, 1=enabled ; Bit 6 - Drive select 3 ; Bit 5 - Density flag: 0=single, 1=double ; Bit 4 - Write precompensation: 0=no precomp, 1=precomp ; Bit 3 - Drive motor enable: 0=motors off, 1=motors on ; Bit 2 - Drive select 2 ; Bit 1 - Drive select 1 ; Bit 0 - Drive select 0 FDC_COMMAND equ $ff48 ; Floppy command register FDC_STATUS equ $ff48 ; Floppy status register FDC_TRACK equ $ff49 ; FDC track register FDC_SECTOR equ $ff4a ; FDC sector register FDC_DATA equ $ff4b ; FDC data register ; FDC control register bits at $ff40 (FDC_CTRL) FDC_CR_HALT equ %10000000 FDC_CR_DRIVE3 equ %01000000 FDC_CR_DENSITY equ %00100000 FDC_CR_WRITE equ %00010000 FDC_CR_MOTOR equ %00001000 FDC_CR_DRIVE2 equ %00000100 FDC_CR_DRIVE1 equ %00000010 FDC_CR_DRIVE0 equ %00000001 ; Command Summary (models 1791, 1792, 1793, 1794) ; Type Command b7 b6 b5 b4 b3 b2 b1 b0 ; I Restore 0 0 0 0 h V r1 r0 ; I Seek 0 0 0 1 h V r1 r0 ; I Step 0 0 1 T h V r1 r0 ; I Step-In 0 1 0 T h V r1 r0 ; I Step-Out 0 1 1 T h V r1 r0 ; II Read Sector 1 0 0 m S E C 0 ; II Write Sector 1 0 1 m S E C a0 ; III Read Address 1 1 0 0 0 E 0 0 ; III Read Track 1 1 1 0 0 E 0 0 ; III Write Track 1 1 1 1 0 E 0 0 ; IV Force Interrupt 1 1 0 1 i3 i2 i1 i0 ; ; Flag Summary ; r1 r0 Stepping Motor Rate ; V Track Number Verify Flag (0: no verify, 1: verify on dest track) ; h Head Load Flag (1: load head at beginning, 0: unload head) ; T Track Update Flag (0: no update, 1: update Track Register) ; a0 Data Address Mark (0: FB, 1: F8 (deleted DAM)) ; C Side Compare Flag (0: disable side compare, 1: enable side comp) ; E 15 ms delay (0: no 15ms delay, 1: 15 ms delay) ; S Side Compare Flag (0: compare for side 0, 1: compare for side 1) ; m Multiple Record Flag (0: single record, 1: multiple records) ; ; i3 i2 i1 i0 Interrupt Condition Flags ; i3-i0 = 0 Terminate with no interrupt (INTRQ) ; i3 = 1 Immediate interrupt, requires a reset ; i2 = 1 Index pulse ; i1 = 1 Ready to not ready transition ; i0 = 1 Not ready to ready transition ; ; Stepping Rate ; r1 r0 Stepping rate ; 0 0 6 ms ; 0 1 12 ms ; 1 0 20 ms ; 1 1 30 ms ; FDC Stepping rate FDC_STEP_6MS equ %00000000 ; 6 ms FDC_STEP_12MS equ %00000001 ; 12 ms FDC_STEP_20MS equ %00000010 ; 20 ms FDC_STEP_30MS equ %00000011 ; 30 ms ; FDC Track Update Flag FDC_UPDATE_TRACK_REG equ %00010000 ; update track register FDC_NO_UPDATE_TRACK_REG equ 0 ; no update ; FDC Head Load Flag FDC_LOAD_HEAD equ %00001000 ; load head at beginning FDC_UNLOAD_LOAD equ 0 ; unload head ; FDC Multiple Record Flag FDC_MULT_RECORDS equ %00010000 ; multiple records FDC_ONE_RECORD equ 0 ; single records ; FDC Commands Type I FDC_CMD_RESTORE equ %00000000 ; Restore (Seek track #0) FDC_CMD_SEEK equ %00010000 ; Seek FDC_CMD_STEP equ %00100000 ; Step FDC_CMD_STEP_IN equ %01000000 ; Step In FDC_CMD_STEP_OUT equ %01100000 ; Step Out ; FDC Commands Type II FDC_CMD_READ_SECTOR equ %10000000 ; Read Sector FDC_CMD_WRITE_SECTOR equ %10100000 ; Write Sector ; FDC Commands Type III FDC_CMD_READ_ADDRESS equ %11000000 ; Read Address FDC_CMD_READ_TRACK equ %11100000 ; Read Track FDC_CMD_WRITE_TRACK equ %11110000 ; Write Track ; FDC Commands Type IV FDC_CMD_FORCE_INTERRUPT equ %11010000 ; Force Interrupt ; FDC Status for Type I Commands FDC_STATUS_NOT_READY equ %10000000 ; Drive is not ready FDC_STATUS_PROTECTED equ %01000000 ; Write protect is activated FDC_STATUS_HEAD_LOADED equ %00100000 ; Head is loaded and engaged FDC_STATUS_SEEK_ERROR equ %00010000 ; Desired track was not verified FDC_STATUS_CRC_ERROR equ %00001000 ; CRC encountered in ID field FDC_STATUS_TRACK_0 equ %00000100 ; Read/Write head is positioned to track #0 FDC_STATUS_INDEX equ %00000010 ; Index mark detected from drive FDC_STATUS_BUSY equ %00000001 ; Command is in progress ; FDC Status for Type II and III Commands FDC_WRITE_FAULT equ %00100000 ; Write fault FDC_RNF equ %00010000 ; Desired track, sector or side was not found FDC_DATA_REQUEST equ %00000010 ; FDC_DEFS equ 1 ; Set flag for defines being loaded endc *pragmapop list ; restore assembly listing to previous state
test/Succeed/Issue2171.agda
cruhland/agda
1,989
587
<filename>test/Succeed/Issue2171.agda postulate id : {t : Set} → t → t _≡_ : {t : Set} → t → t → Set ⊤ : Set record FunctorOp (f : Set → Set) : Set₁ where record FunctorLaws (f : Set → Set) {{op : FunctorOp f}} : Set₁ where -- demand functor laws to access <*>, but promise we won't use them in our definition record ApplyOp (A : Set → Set) {{_ : FunctorOp A}} .{{_ : FunctorLaws A}} : Set₁ where field _<*>_ : ∀ {t₁ t₂} → A (t₁ → t₂) → A t₁ → A t₂ open ApplyOp {{...}} record ApplyLaws₂ (A : Set → Set) {{_ : FunctorOp A}} .{{_ : FunctorLaws A}} {{i : ApplyOp A}} : Set₁ where -- but if we try to do anything in here... -- resolution fails, even though our instance `i` is already resolved and in scope! field blah : ∀ (f : A (⊤ → ⊤)) → (x : A ⊤) → (f <*> x) ≡ x
oeis/120/A120868.asm
neoneye/loda-programs
11
162451
; A120868: a(n) is the number k for which there exists a unique pair (j,k) of positive integers such that (j + k + 1)^2 - 4*k = 5*n^2. ; 1,4,1,5,11,4,11,1,9,19,5,16,29,11,25,4,19,36,11,29,1,20,41,9,31,55,19,44,5,31,59,16,45,76,29,61,11,44,79,25,61,4,41,80,19,59,101,36,79,11,55,101,29,76,1,49,99,20,71,124,41,95,9,64,121,31,89,149,55,116,19,81,145 seq $0,101870 ; Row 3 of A101866. mul $0,2 seq $0,5752 ; a(n) = n^2 + n*floor(n*tau) - floor(n*tau)^2. mul $0,2 div $0,8
other.7z/SFC.7z/SFC/ソースデータ/MarioKart/c-select.asm
prismotizm/gigaleak
0
7635
<filename>other.7z/SFC.7z/SFC/ソースデータ/MarioKart/c-select.asm Name: c-select.asm Type: file Size: 34206 Last-Modified: '1992-06-29T15:00:00Z' SHA-1: 7CC52BC3E454D511A67486203A46813A9A190A40 Description: null
grammar/potassium_parser.g4
validus77/potassium
2
1054
parser grammar potassium_parser; options { tokenVocab = potassium_lexer; } line : statement (NEWLINE) ; statement : assignment # assigmentStantment | function_assignment # functionAssigmentStantment | print # printStatment; assignment : LET ID ASSIGN expression; function_assignment : LET ID LPAREN ID* RPAREN ASSIGN expression; print : PRINT LPAREN expression RPAREN; expression : LPAREN expression RPAREN # parenExpression | left=expression op=(MULT|DIV|MOD) right=expression # binaryOperation | left=expression op=(PLUS|MINUS) right=expression # binaryOperation | NOT expression # logicalUnaryOperation | left=expression op=(AND|OR|EQ|LT|GT) right=expression # logicalBinaryOperation | cond_expresion # condExpression | function_call # funcCallExpression | ID # varReference | INTLIT # intLiteral | FLOATLIT # floatLiteral; cond_expresion : IF LPAREN test_exp=expression RPAREN then_exp=expression #ifCond | IF LPAREN test_exp=expression RPAREN then_exp=expression ELSE else_exp=expression #ifElseCond; function_call: ID LPAREN expression* RPAREN;
Codes/11 Search in array.asm
Tanuj9043/assembly-language
0
89160
SYS_EXIT equ 1 SYS_READ equ 3 SYS_WRITE equ 4 STDIN equ 0 STDOUT equ 1 section .data msg1 db 'Enter number : ' len1 equ $-msg1 msg2 db 'Found at index : ' len2 equ $-msg2 msg3 db 'Not found' len3 equ $-msg3 x db '12', '10', '22', '13', '19', '14', '11', '29', '10', '16' section .bss num resb 2 index resb 4 section .text global _start ;must be declared for linker (ld) _start: ;tell linker entry point mov eax,4 ;system call number (sys_write) mov ebx,1 ;file descriptor (stdout) mov ecx,[x] ;message to write mov edx,2 ;byte int 0x80 ;call kernel mov eax,4 ;system call number (sys_write) mov ebx,1 ;file descriptor (stdout) mov ecx,msg1 ;message to write mov edx,len1 ;message length int 0x80 ;call kernel mov eax,3 ;system call number (sys_read) mov ebx,0 ;file descriptor (stdin) mov ecx,num ;number mov edx,2 ;bytes int 0x80 ;call kernel4 mov eax,10 mov ebx,[num] mov ecx,x lp : dec eax cmp ebx,'11' je found add ecx,2 dec eax jnz lp mov eax,4 ;system call number (sys_write) mov ebx,1 ;file descriptor (stdout) mov ecx,msg3 ;message to write mov edx,len3 ;message length int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel found : mov [index],eax mov eax,4 ;system call number (sys_write) mov ebx,1 ;file descriptor (stdout) mov ecx,msg2 ;message to write mov edx,len2 ;message length int 0x80 ;call kernel mov eax,4 ;system call number (sys_write) mov ebx,1 ;file descriptor (stdout) mov ecx,index ;message to write mov edx,4 ;byte int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel
bb-runtimes/runtimes/zfp-stm32g474/gnat/s-imguns.ads
JCGobbi/Nucleo-STM32G474RE
0
21616
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . I M G _ U N S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2021, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routines for supporting the Image attribute for -- modular integer types up to Unsigned, and also for conversion operations -- required in Text_IO.Modular_IO for such types. with System.Image_U; with System.Unsigned_Types; package System.Img_Uns is pragma Pure; subtype Unsigned is Unsigned_Types.Unsigned; package Impl is new Image_U (Unsigned); procedure Image_Unsigned (V : Unsigned; S : in out String; P : out Natural) renames Impl.Image_Unsigned; procedure Set_Image_Unsigned (V : Unsigned; S : in out String; P : in out Natural) renames Impl.Set_Image_Unsigned; end System.Img_Uns;
FormalAnalyzer/models/apps/ID16.als
Mohannadcse/IoTCOM_BehavioralRuleExtractor
0
899
<filename>FormalAnalyzer/models/apps/ID16.als module app_ID16 open IoTBottomUp as base open cap_location open cap_switch one sig app_ID16 extends IoTApp { theSwitch : one cap_switch, onMode : one cap_location_attr_mode_val, location : one cap_location, offMode : one cap_location_attr_mode_val, } { rules = r } // application rules base class abstract sig r extends Rule {} one sig r0 extends r {}{ triggers = r0_trig no conditions commands = r0_comm } abstract sig r0_trig extends Trigger {} one sig r0_trig0 extends r0_trig {} { capabilities = app_ID16.theSwitch attribute = cap_switch_attr_switch value = cap_switch_attr_switch_val_off } abstract sig r0_comm extends Command {} one sig r0_comm0 extends r0_comm {} { capability = app_ID16.location attribute = cap_location_attr_mode value = app_ID16.offMode } one sig r1 extends r {}{ triggers = r1_trig no conditions commands = r1_comm } abstract sig r1_trig extends Trigger {} one sig r1_trig0 extends r1_trig {} { capabilities = app_ID16.theSwitch attribute = cap_switch_attr_switch value = cap_switch_attr_switch_val_on } abstract sig r1_comm extends Command {} one sig r1_comm0 extends r1_comm {} { capability = app_ID16.location attribute = cap_location_attr_mode value = app_ID16.onMode }
webcommon/javascript2.json/tools/Json.g4
zimmi/netbeans
2
5418
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * * @author <NAME> */ grammar Json; options { language=Java; } @lexer::header { /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2016 Oracle and/or its affiliates. All rights reserved. * * Oracle and Java are registered trademarks of Oracle and/or its affiliates. * Other names may be trademarks of their respective owners. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): * * Portions Copyrighted 2016 Sun Microsystems, Inc. */ package org.netbeans.modules.javascript2.json.parser; } @parser::header { /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2016 Oracle and/or its affiliates. All rights reserved. * * Oracle and Java are registered trademarks of Oracle and/or its affiliates. * Other names may be trademarks of their respective owners. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): * * Portions Copyrighted 2016 Sun Microsystems, Inc. */ package org.netbeans.modules.javascript2.json.parser; } @lexer::members { public static final int WHITESPACES = 1; public static final int COMMENTS = 2; public static final int ERRORS = 3; private static final Recovery[] RECOVERIES = { Recovery.createLineCommentRecovery(), Recovery.createCommentRecovery(), Recovery.createStringRecovery() }; private boolean isCommentSupported; private boolean hasErrorToken; public LexerState getLexerState() { return new LexerState(getState()); } public void setLexerState(LexerState state) { this.setState(state.atnState); } public static final class LexerState { final int atnState; public LexerState(int atnState) { this.atnState = atnState; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final LexerState other = (LexerState) obj; if (this.atnState != other.atnState) { return false; } return true; } @Override public int hashCode() { int hash = 5; hash = 29 * hash + this.atnState; return hash; } } public JsonLexer( final CharStream input, final boolean isCommentSupported) { this(input, isCommentSupported, false); } public JsonLexer( final CharStream input, final boolean isCommentSupported, final boolean hasErrorToken) { this(input); this.isCommentSupported = isCommentSupported; this.hasErrorToken = hasErrorToken; } @Override public void recover(LexerNoViableAltException e) { final CharStream in = e.getInputStream(); final int current = in.index(); final int index = e.getStartIndex(); boolean resolved = false; in.seek(index); for (Recovery r : RECOVERIES) { if (r.canRecover(in)) { getInterpreter().setCharPositionInLine(_tokenStartCharPositionInLine); getInterpreter().setLine(_tokenStartLine); r.recover(in, getInterpreter()); resolved = true; break; } } if (!resolved) { in.seek(current); super.recover(e); } } } json : value?EOF; value : (STRING | NUMBER | TRUE | FALSE | NULL | array | object); object : LBRACE (pair (COMMA pair)*)? RBRACE; pair : key COLON value; key : STRING; array : LBRACKET (value (COMMA value)*)? RBRACKET; COLON : ':'; COMMA : ','; DOT : '.'; PLUS : '+'; MINUS : '-'; LBRACE : '{'; RBRACE : '}'; LBRACKET : '['; RBRACKET : ']'; TRUE : 'true'; FALSE : 'false'; NULL : 'null'; NUMBER : INTEGER FRACTION? EXPONENT?; fragment INTEGER : (MINUS)? (DIGIT_0 | DIGIT_19 DIGIT*); fragment DIGIT_0 : '0'; fragment DIGIT_19 : [1-9]; fragment DIGIT : DIGIT_0 | DIGIT_19; fragment FRACTION : DOT DIGIT+; fragment EXPONENT : ('e'|'E')(PLUS | MINUS)? DIGIT+; STRING : QUOTE (CHAR)* QUOTE; fragment QUOTE : '"'; fragment CHAR : ~[\u0000-\u001F"\\] | CONTROL; fragment CONTROL : '\\' (["\\/bfnrt] | UNICODE); fragment UNICODE : 'u' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT; fragment HEXDIGIT : [0-9a-fA-F]; LINE_COMMENT : '//' .*? '\r'? '\n' {isCommentSupported}? -> channel(COMMENTS); COMMENT : '/*' .*? '*/' {isCommentSupported}? -> channel(COMMENTS); WS : [ \t\r\n]+ -> channel(WHITESPACES); ERROR_COMMENT : '/*' (~'*' | ('*'+ ~'/'))* {hasErrorToken && isCommentSupported}? -> channel(ERRORS); ERROR : . {hasErrorToken}? -> channel(ERRORS);
Task/Determine-if-a-string-is-numeric/Ada/determine-if-a-string-is-numeric-3.ada
LaudateCorpus1/RosettaCodeData
1
27150
with Ada.Text_Io; use Ada.Text_Io; with Numeric_Tests; use Numeric_Tests; procedure Is_Numeric_Test is S1 : String := "152"; S2 : String := "-3.1415926"; S3 : String := "Foo123"; begin Put_Line(S1 & " results in " & Boolean'Image(Is_Numeric(S1))); Put_Line(S2 & " results in " & Boolean'Image(Is_Numeric(S2))); Put_Line(S3 & " results in " & Boolean'Image(Is_Numeric(S3))); end Is_Numeric_Test;
Transynther/x86/_processed/US/_zr_/i7-8650U_0xd2.log_8971_482.asm
ljhsiun2/medusa
9
91402
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0xd0a3, %rsi lea addresses_A_ht+0x191ea, %rdi clflush (%rdi) nop nop nop nop sub $54981, %r11 mov $10, %rcx rep movsl nop xor %rbp, %rbp lea addresses_WC_ht+0x46a2, %r8 add %rsi, %rsi mov (%r8), %bp cmp $12426, %rcx lea addresses_normal_ht+0x1df5a, %rdi nop cmp $56928, %rdx mov (%rdi), %si nop sub %rcx, %rcx lea addresses_D_ht+0xe57a, %rcx nop sub $47471, %rdi mov $0x6162636465666768, %r11 movq %r11, (%rcx) nop dec %r11 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r13 push %r9 push %rbp push %rdx // Store lea addresses_RW+0x1c14a, %r11 nop nop add %rbp, %rbp mov $0x5152535455565758, %r13 movq %r13, %xmm5 movups %xmm5, (%r11) nop nop nop dec %r12 // Load lea addresses_US+0x4ca, %r13 nop nop nop nop and %r10, %r10 mov (%r13), %r12 xor $63837, %r9 // Store lea addresses_UC+0x1459a, %rdx nop nop nop dec %r13 mov $0x5152535455565758, %r9 movq %r9, (%rdx) nop nop dec %rbp // Store mov $0x78442e0000000084, %r9 xor $57660, %rdx mov $0x5152535455565758, %r12 movq %r12, (%r9) dec %rbp // Store lea addresses_A+0xd8ae, %r9 nop nop cmp %rbp, %rbp mov $0x5152535455565758, %rdx movq %rdx, (%r9) nop nop cmp %r9, %r9 // Load mov $0xa5a, %rdx sub %rbp, %rbp mov (%rdx), %r11 sub $49417, %r12 // Faulty Load lea addresses_US+0xda5a, %r13 add $51106, %r11 mov (%r13), %r9 lea oracles, %r12 and $0xff, %r9 shlq $12, %r9 mov (%r12,%r9,1), %r9 pop %rdx pop %rbp pop %r9 pop %r13 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_P', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'00': 8971} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
src/Queue.agda
nad/equality
3
16329
------------------------------------------------------------------------ -- Specifications of output-restricted deques (single-ended queues -- with cons) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Queue {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq open import Prelude open import Bijection eq as Bijection using (_↔_) import Equivalence eq as Eq open import Function-universe eq as F hiding (id; _∘_) open import List eq as L hiding (map) open import Maybe eq open import Surjection eq using (_↠_) private variable a ℓ ℓ₁ ℓ₂ : Level A B : Type a P Q : ∀ {ℓ} → Type ℓ → Type ℓ p q x : A f : A → B xs : List A -- A specification of when (and how) a type constructor implements -- output-restricted deques. record Is-queue -- A family of queue types. (Q : ∀ {ℓ} → Type ℓ → Type ℓ) -- Some operations are only available for carrier types -- satisfying this predicate. (P : ∀ {ℓ} → Type ℓ → Type ℓ) ℓ : Type (lsuc ℓ) where field -- Conversion functions. to-List : {A : Type ℓ} → P A → Q A → List A from-List : {A : Type ℓ} → List A → Q A to-List-from-List : to-List p (from-List xs) ≡ xs -- Enqueues an element. enqueue : {A : Type ℓ} → A → Q A → Q A to-List-enqueue : to-List p (enqueue x q) ≡ to-List p q ++ x ∷ [] -- Dequeues an element, if possible. dequeue : {A : Type ℓ} → P A → Q A → Maybe (A × Q A) to-List-dequeue : ⊎-map id (Σ-map id (to-List p)) (dequeue p q) ≡ _↔_.to List↔Maybe[×List] (to-List p q) -- The "inverse" of the dequeue operation. dequeue⁻¹ : {A : Type ℓ} → Maybe (A × Q A) → Q A to-List-dequeue⁻¹ : to-List p (dequeue⁻¹ x) ≡ _↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id (to-List p)) x) -- This module exports universe-polymorphic queue -- operations/properties. module Is-queue⁺ ⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄ where private module Q {ℓ} = Is-queue (is-queue {ℓ = ℓ}) open Q public -- A split surjection from queues to lists. Queue↠List : P A → Q A ↠ List A Queue↠List p = record { logical-equivalence = record { to = to-List p ; from = from-List } ; right-inverse-of = λ _ → to-List-from-List } -- An empty queue. empty : Q A empty = dequeue⁻¹ nothing to-List-empty : to-List p empty ≡ ([] ⦂ List A) to-List-empty {p = p} = to-List p empty ≡⟨⟩ to-List p (dequeue⁻¹ nothing) ≡⟨ to-List-dequeue⁻¹ ⟩ _↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id (to-List p)) nothing) ≡⟨⟩ [] ∎ -- Adds an element to the front of a queue. cons : A → Q A → Q A cons x q = dequeue⁻¹ (just (x , q)) to-List-cons : to-List p (cons x q) ≡ x ∷ to-List p q to-List-cons {p = p} {x = x} {q = q} = to-List p (cons x q) ≡⟨⟩ to-List p (dequeue⁻¹ (just (x , q))) ≡⟨ to-List-dequeue⁻¹ ⟩ _↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id (to-List p)) (just (x , q))) ≡⟨⟩ x ∷ to-List p q ∎ open Is-queue⁺ public -- A specification of when (and how) a type constructor implements -- output-restricted deques with a map function. record Is-queue-with-map (Q : ∀ {ℓ} → Type ℓ → Type ℓ) ⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄ ℓ₁ ℓ₂ : Type (lsuc (ℓ₁ ⊔ ℓ₂)) where field -- A map function. map : {A : Type ℓ₁} {B : Type ℓ₂} → (A → B) → Q A → Q B to-List-map : {p₁ : P B} {p₂ : P A} → to-List p₁ (map f q) ≡ L.map f (to-List p₂ q) -- This module exports universe-polymorphic queue -- operations/properties. module Is-queue-with-map⁺ ⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄ ⦃ is-queue-with-map : ∀ {ℓ₁ ℓ₂} → Is-queue-with-map Q ℓ₁ ℓ₂ ⦄ where private module Q {ℓ₁ ℓ₂} = Is-queue-with-map (is-queue-with-map {ℓ₁ = ℓ₁} {ℓ₂ = ℓ₂}) open Q public open Is-queue-with-map⁺ public -- A specification of when (and how) a type constructor implements -- output-restricted deques with unique representations. record Is-queue-with-unique-representations (Q : ∀ {ℓ} → Type ℓ → Type ℓ) ⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄ ℓ : Type (lsuc ℓ) where field -- The from-List function is a left inverse of to-List. from-List-to-List : {A : Type ℓ} {p : P A} {q : Q A} → from-List (to-List p q) ≡ q -- This module exports universe-polymorphic queue -- operations/properties. module Is-queue-with-unique-representations⁺ ⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄ ⦃ is-queue-with-unique-representations : ∀ {ℓ} → Is-queue-with-unique-representations Q ℓ ⦄ where private module Q {ℓ} = Is-queue-with-unique-representations (is-queue-with-unique-representations {ℓ = ℓ}) open Q public -- A bijection between queues and lists. Queue↔List : P A → Q A ↔ List A Queue↔List p = record { surjection = Queue↠List p ; left-inverse-of = λ _ → from-List-to-List } -- There is a bijection between equality of two queues and equality -- of the corresponding lists. ≡-for-lists↔≡ : {A : Type a} {p : P A} {q₁ q₂ : Q A} → to-List p q₁ ≡ to-List p q₂ ↔ q₁ ≡ q₂ ≡-for-lists↔≡ {p = p} {q₁ = q₁} {q₂ = q₂} = to-List p q₁ ≡ to-List p q₂ ↔⟨ Eq.≃-≡ $ Eq.↔⇒≃ $ Queue↔List _ ⟩□ q₁ ≡ q₂ □ -- A variant of Queue↔List. Maybe[×Queue]↔List : P A → Maybe (A × Q A) ↔ List A Maybe[×Queue]↔List {A = A} p = Maybe (A × Q A) ↝⟨ F.id ⊎-cong F.id ×-cong Queue↔List p ⟩ Maybe (A × List A) ↝⟨ inverse List↔Maybe[×List] ⟩□ List A □ -- The function dequeue p is an inverse of dequeue⁻¹. Queue↔Maybe[×Queue] : P A → Q A ↔ Maybe (A × Q A) Queue↔Maybe[×Queue] {A = A} p = Bijection.with-other-function (Bijection.with-other-inverse (Q A ↝⟨ Queue↔List p ⟩ List A ↝⟨ inverse (Maybe[×Queue]↔List p) ⟩□ Maybe (A × Q A) □) dequeue⁻¹ (λ x → _↔_.from-to (inverse $ Queue↔List p) ( to-List p (dequeue⁻¹ x) ≡⟨ to-List-dequeue⁻¹ ⟩∎ _↔_.to (Maybe[×Queue]↔List p) x ∎))) (dequeue p) (λ q → _↔_.to-from (Maybe[×Queue]↔List p) ( _↔_.to (Maybe[×Queue]↔List p) (dequeue p q) ≡⟨⟩ _↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id (to-List p)) (dequeue p q)) ≡⟨ cong (_↔_.from List↔Maybe[×List]) to-List-dequeue ⟩ _↔_.from List↔Maybe[×List] (_↔_.to List↔Maybe[×List] (to-List p q)) ≡⟨ _↔_.left-inverse-of List↔Maybe[×List] _ ⟩∎ to-List p q ∎)) _ : {A : Type a} {p : P A} → _↔_.to (Queue↔Maybe[×Queue] p) ≡ dequeue p _ = refl _ _ : {A : Type a} {p : P A} → _↔_.from (Queue↔Maybe[×Queue] p) ≡ dequeue⁻¹ _ = refl _ -- The function from-List can be expressed using enqueue and empty. from-List≡foldl-enqueue-empty : {A : Type a} {xs : List A} → P A → from-List xs ≡ foldl (flip enqueue) empty xs from-List≡foldl-enqueue-empty {A = A} {xs = xs} p = _↔_.to ≡-for-lists↔≡ ( to-List p (from-List xs) ≡⟨ to-List-from-List ⟩ xs ≡⟨⟩ [] ++ xs ≡⟨ cong (_++ _) $ sym to-List-empty ⟩ to-List p empty ++ xs ≡⟨ lemma _ _ ⟩∎ to-List p (foldl (flip enqueue) empty xs) ∎) where lemma : ∀ xs (q : Q A) → to-List p q ++ xs ≡ to-List p (foldl (flip enqueue) q xs) lemma [] q = to-List p q ++ [] ≡⟨ ++-right-identity _ ⟩∎ to-List p q ∎ lemma (x ∷ xs) q = to-List p q ++ x ∷ xs ≡⟨ ++-associative (to-List _ _) _ _ ⟩ (to-List p q ++ x ∷ []) ++ xs ≡⟨ cong (_++ _) $ sym to-List-enqueue ⟩ to-List p (enqueue x q) ++ xs ≡⟨ lemma _ _ ⟩ to-List p (foldl (flip enqueue) (enqueue x q) xs) ≡⟨⟩ to-List p (foldl (flip enqueue) q (x ∷ xs)) ∎ -- A corollary. to-List-foldl-enqueue-empty : {A : Type a} {p : P A} (xs : List A) → to-List p (foldl (flip enqueue) empty xs) ≡ xs to-List-foldl-enqueue-empty {p = p} xs = to-List p (foldl (flip enqueue) empty xs) ≡⟨ cong (to-List p) $ sym $ from-List≡foldl-enqueue-empty p ⟩ to-List p (from-List xs) ≡⟨ to-List-from-List ⟩∎ xs ∎ open Is-queue-with-unique-representations⁺ public instance -- Lists can be seen as queues. List-is-queue : Is-queue List (λ _ → ↑ _ ⊤) ℓ List-is-queue .Is-queue.to-List = λ _ → id List-is-queue .Is-queue.from-List = id List-is-queue .Is-queue.enqueue = λ x xs → xs ++ x ∷ [] List-is-queue .Is-queue.dequeue = λ _ → _↔_.to List↔Maybe[×List] List-is-queue .Is-queue.dequeue⁻¹ = _↔_.from List↔Maybe[×List] List-is-queue .Is-queue.to-List-from-List = refl _ List-is-queue .Is-queue.to-List-enqueue = refl _ List-is-queue .Is-queue.to-List-dequeue {q = []} = refl _ List-is-queue .Is-queue.to-List-dequeue {q = _ ∷ _} = refl _ List-is-queue .Is-queue.to-List-dequeue⁻¹ {x = nothing} = refl _ List-is-queue .Is-queue.to-List-dequeue⁻¹ {x = just _} = refl _ List-is-queue-with-map : Is-queue-with-map List ℓ₁ ℓ₂ List-is-queue-with-map .Is-queue-with-map.map = L.map List-is-queue-with-map .Is-queue-with-map.to-List-map = refl _ List-is-queue-with-unique-representations : Is-queue-with-unique-representations List ℓ List-is-queue-with-unique-representations .Is-queue-with-unique-representations.from-List-to-List = refl _
agda/Text/Greek/SBLGNT.agda
scott-fleischman/GreekGrammar
44
13325
module Text.Greek.SBLGNT where open import Data.List open import Text.Greek.Bible open import Text.Greek.SBLGNT.Matt open import Text.Greek.SBLGNT.Mark open import Text.Greek.SBLGNT.Luke open import Text.Greek.SBLGNT.John open import Text.Greek.SBLGNT.Acts open import Text.Greek.SBLGNT.Rom open import Text.Greek.SBLGNT.1Cor open import Text.Greek.SBLGNT.2Cor open import Text.Greek.SBLGNT.Gal open import Text.Greek.SBLGNT.Eph open import Text.Greek.SBLGNT.Phil open import Text.Greek.SBLGNT.Col open import Text.Greek.SBLGNT.1Thess open import Text.Greek.SBLGNT.2Thess open import Text.Greek.SBLGNT.1Tim open import Text.Greek.SBLGNT.2Tim open import Text.Greek.SBLGNT.Titus open import Text.Greek.SBLGNT.Phlm open import Text.Greek.SBLGNT.Heb open import Text.Greek.SBLGNT.Jas open import Text.Greek.SBLGNT.1Pet open import Text.Greek.SBLGNT.2Pet open import Text.Greek.SBLGNT.1John open import Text.Greek.SBLGNT.2John open import Text.Greek.SBLGNT.3John open import Text.Greek.SBLGNT.Jude open import Text.Greek.SBLGNT.Rev books : List (List (Word)) books = ΚΑΤΑ-ΜΑΘΘΑΙΟΝ ∷ ΚΑΤΑ-ΜΑΡΚΟΝ ∷ ΚΑΤΑ-ΛΟΥΚΑΝ ∷ ΚΑΤΑ-ΙΩΑΝΝΗΝ ∷ ΠΡΑΞΕΙΣ-ΑΠΟΣΤΟΛΩΝ ∷ ΠΡΟΣ-ΡΩΜΑΙΟΥΣ ∷ ΠΡΟΣ-ΚΟΡΙΝΘΙΟΥΣ-Α ∷ ΠΡΟΣ-ΚΟΡΙΝΘΙΟΥΣ-Β ∷ ΠΡΟΣ-ΓΑΛΑΤΑΣ ∷ ΠΡΟΣ-ΕΦΕΣΙΟΥΣ ∷ ΠΡΟΣ-ΦΙΛΙΠΠΗΣΙΟΥΣ ∷ ΠΡΟΣ-ΚΟΛΟΣΣΑΕΙΣ ∷ ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Α ∷ ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Β ∷ ΠΡΟΣ-ΤΙΜΟΘΕΟΝ-Α ∷ ΠΡΟΣ-ΤΙΜΟΘΕΟΝ-Β ∷ ΠΡΟΣ-ΤΙΤΟΝ ∷ ΠΡΟΣ-ΦΙΛΗΜΟΝΑ ∷ ΠΡΟΣ-ΕΒΡΑΙΟΥΣ ∷ ΙΑΚΩΒΟΥ ∷ ΠΕΤΡΟΥ-Α ∷ ΠΕΤΡΟΥ-Β ∷ ΙΩΑΝΝΟΥ-Α ∷ ΙΩΑΝΝΟΥ-Β ∷ ΙΩΑΝΝΟΥ-Γ ∷ ΙΟΥΔΑ ∷ ΑΠΟΚΑΛΥΨΙΣ-ΙΩΑΝΝΟΥ ∷ []
PLC/GCS/TPCs/outros/Ex12.g4
luis1ribeiro/MEI---Majors-Degree
1
1600
<reponame>luis1ribeiro/MEI---Majors-Degree<filename>PLC/GCS/TPCs/outros/Ex12.g4<gh_stars>1-10 /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ grammar Ex12; @members { int tamanho = 0; int totalNumeros = 0; int somaNumeros = 0; int totalPalavras = 0; int agora = 0; int max = -1; } listas: lista+ ; lista: Lista elementos '.' { System.out.println("Tamanho da lista: " + tamanho); System.out.println("Ocorre de numeros: " + totalNumeros); System.out.println("Soma de numeros: " + somaNumeros); System.out.println("O maior número da lista: " + max); if(totalNumeros == totalPalavras) System.out.println("Igual número de palavras e números."); else System.out.println("Erro: Diferente n�mero de palavras e nrs. totalNumeros: " + totalNumeros + ", totalPalavras: " + totalPalavras); totalNumeros = 0; totalPalavras = 0; somaNumeros = 0; agora = 0; max = -1; } ; elementos: elemento {tamanho=1; } (',' elemento {tamanho++;} )* ; elemento: PALAVRA {if($PALAVRA.text.equals("Agora")) agora++; agora = agora%2; totalPalavras++;} | NUM {totalNumeros++; if(agora==1) somaNumeros += $NUM.int; if (max < $NUM.int) max=$NUM.int} ; //Lexer Lista: [lL][iI][sS][tT][aA] ; NUM: ('0'..'9')+ //[0-9]+ ; PALAVRA: [a-zA-Z][a-zA-Z0-9]* ; WS: ('\r'? '\n' | ' ' | '\t')+ -> skip;
src/MJSF/Examples/DynamicDispatch.agda
metaborg/mj.agda
10
9132
module MJSF.Examples.DynamicDispatch where open import Prelude open import Data.Star open import Data.Bool open import Data.List open import Data.Integer open import Data.List.Membership.Propositional open import Data.List.Relation.Unary.Any open import Data.List.Relation.Unary.All hiding (lookup) open import Data.Product hiding (Σ) open import Relation.Binary.PropositionalEquality open import Relation.Nullary.Decidable k : ℕ k = 10 open import MJSF.Syntax k open import ScopesFrames.ScopesFrames k Ty {- class Int { public int x; public int get() { System.out.println("never"); return x; } public int set(Int y) { x = y.x; return this.get(); } } class IntInc extends Int { public int get() { return x + 1; } public int inc(Int y) { Int x = new Int(); x.x = y.x + 1; return set(x); } } class Main { public static void main(String[] args) { Int y = new Int(); y.x = 18; IntInc x = new IntInc(); x.x = 0; // should print 20 because we use the get() of IntInc System.out.println(x.inc(y)); } } -} Root : Scope Root = # 0 Int : Scope Int = # 1 IntInc : Scope IntInc = # 2 -- Main class omitted; main() function is given below, as child scope -- of the root scope. classes : List Ty classes = (cᵗ Root Int ∷ cᵗ Root IntInc ∷ []) Int-methods Int-fields : List Ty Int-fields = {- x -} vᵗ int ∷ [] Int-methods = {- Int.get -} mᵗ [] int ∷ {- Int.set -} mᵗ (ref Int ∷ []) int ∷ [] IntInc-methods IntInc-fields : List Ty IntInc-methods = -- {- IntInc.get -} mᵗ [] int ∷ {- IntInc.inc -} mᵗ (ref Int ∷ []) int ∷ [] IntInc-fields = [] g : Graph -- root scope g zero = classes , [] -- class scope of Int class g (suc zero) = (Int-methods ++ Int-fields) , zero ∷ [] -- class scope of IntInc class g (suc (suc zero)) = (IntInc-methods ++ IntInc-fields) , zero ∷ # 1 ∷ [] -- scope of Int.get method; 3 g (suc (suc (suc zero))) = [] , Int ∷ [] -- scope of Int.set method; 4 g (suc (suc (suc (suc zero)))) = vᵗ (ref Int) ∷ [] , Int ∷ [] -- scope of IntInc.get method; 5 g (suc (suc (suc (suc (suc zero))))) = [] , IntInc ∷ [] -- scope of IntInc.inc method; 6 g (suc (suc (suc (suc (suc (suc zero)))))) = vᵗ (ref Int) ∷ [] , IntInc ∷ [] -- local variable scope of Int.inc method; 7 g (suc (suc (suc (suc (suc (suc (suc zero))))))) = vᵗ (ref Int) ∷ [] , # 6 ∷ [] -- x local variable scope of Main.main method; 8 g (suc (suc (suc (suc (suc (suc (suc (suc zero)))))))) = vᵗ (ref Int) ∷ [] , Root ∷ [] -- y local variable scope of Main.main method; 9 g (suc (suc (suc (suc (suc (suc (suc (suc (suc zero))))))))) = vᵗ (ref IntInc) ∷ [] , # 8 ∷ [] g (suc (suc (suc (suc (suc (suc (suc (suc (suc (suc ())))))))))) open SyntaxG g open UsesGraph g IntImpl : Class Root Int IntImpl = class0 {ms = Int-methods} {fs = Int-fields} -- methods (#m' (meth (# 3) (body ε (var (path ((here refl) ∷ []) (there (there (here refl))))))) ∷ (#m' (meth (# 4) (body ( asgn (path ((here refl) ∷ []) (there (there (here refl)))) (get (var (path [] (here refl))) (path [] (there (there (here refl))))) ◅ ε) (call (this [] (here refl)) (path [] (here refl)) [])))) ∷ []) -- fields ((#v' tt) ∷ []) -- overrides [] IntIncImpl : Class Root IntInc IntIncImpl = class1 {ms = IntInc-methods} {fs = IntInc-fields} -- path to parent (path [] (here refl)) -- methods (#m' (meth (# 6) (body ( loc (# 7) (ref Int) ◅ asgn (path [] (here refl)) (new (path ((here refl) ∷ ((here refl) ∷ ((here refl) ∷ []))) (here refl))) ◅ set (var (path [] (here refl))) (path [] (there (there (here refl)))) (iop Data.Integer._+_ (get (var (path ((here refl) ∷ []) (here refl))) (path [] (there (there (here refl))))) (num (+ 1))) ◅ ε) (call (this (here refl ∷ []) (here refl)) (path (there (here refl) ∷ []) (there (here refl))) ((var (path [] (here refl))) ∷ [])))) ∷ []) -- fields [] -- overrides (#m' (path ((there (here refl)) ∷ []) (here refl) , (meth (# 5) (body ε (iop Data.Integer._+_ (var (path ((here refl) ∷ ((there (here refl)) ∷ [])) (there (there (here refl))))) (num (+ 1)))))) ∷ []) main : Body Root int main = body ( (loc (# 8) (ref Int)) ◅ asgn (path [] (here refl)) (new (path (here refl ∷ []) (here refl))) ◅ set (var (path [] (here refl))) (path [] (there (there (here refl)))) (num (+ 18)) ◅ loc (# 9) (ref IntInc) ◅ asgn (path [] (here refl)) (new (path (here refl ∷ here refl ∷ []) (there (here refl)))) ◅ set (var (path [] (here refl))) (path (there (here refl) ∷ []) (there (there (here refl)))) (num (+ 0)) ◅ ε) (call (var (path [] (here refl))) (path [] (here refl)) (var (path ((here refl) ∷ []) (here refl)) ∷ [])) p : Program Root int p = program classes (#c' (IntImpl , Int , obj Int ⦃ refl ⦄) ∷ (#c' (IntIncImpl , Int , (super ⦃ refl ⦄ (obj Int ⦃ refl ⦄)))) ∷ []) main open import MJSF.Semantics open Semantics _ g open import MJSF.Values open ValuesG _ g test : p ⇓⟨ 100 ⟩ (λ v → v ≡ num (+ 20) ) test = refl
programs/oeis/039/A039966.asm
neoneye/loda
22
91960
<reponame>neoneye/loda ; A039966: a(0) = 1; thereafter a(3n+2) = 0, a(3n) = a(3n+1) = a(n). ; 1,1,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0 mul $0,2 mov $1,2 lpb $0 gcd $1,$0 div $0,3 lpe sub $1,1 mov $0,$1
programs/oeis/027/A027469.asm
karttu/loda
1
171343
; A027469: a(n) = 49*(n-1)*(n-2)/2. ; 49,147,294,490,735,1029,1372,1764,2205,2695,3234,3822,4459,5145,5880,6664,7497,8379,9310,10290,11319,12397,13524,14700,15925,17199,18522,19894,21315,22785,24304,25872,27489,29155,30870,32634,34447,36309,38220,40180,42189,44247,46354,48510,50715,52969,55272,57624,60025,62475,64974,67522,70119,72765,75460,78204,80997,83839,86730,89670,92659,95697,98784,101920,105105,108339,111622,114954,118335,121765,125244,128772,132349,135975,139650,143374,147147,150969,154840,158760,162729,166747,170814,174930,179095,183309,187572,191884,196245,200655,205114,209622,214179,218785,223440,228144,232897,237699,242550,247450,252399,257397,262444,267540,272685,277879,283122,288414,293755,299145,304584,310072,315609,321195,326830,332514,338247,344029,349860,355740,361669,367647,373674,379750,385875,392049,398272,404544,410865,417235,423654,430122,436639,443205,449820,456484,463197,469959,476770,483630,490539,497497,504504,511560,518665,525819,533022,540274,547575,554925,562324,569772,577269,584815,592410,600054,607747,615489,623280,631120,639009,646947,654934,662970,671055,679189,687372,695604,703885,712215,720594,729022,737499,746025,754600,763224,771897,780619,789390,798210,807079,815997,824964,833980,843045,852159,861322,870534,879795,889105,898464,907872,917329,926835,936390,945994,955647,965349,975100,984900,994749,1004647,1014594,1024590,1034635,1044729,1054872,1065064,1075305,1085595,1095934,1106322,1116759,1127245,1137780,1148364,1158997,1169679,1180410,1191190,1202019,1212897,1223824,1234800,1245825,1256899,1268022,1279194,1290415,1301685,1313004,1324372,1335789,1347255,1358770,1370334,1381947,1393609,1405320,1417080,1428889,1440747,1452654,1464610,1476615,1488669,1500772,1512924,1525125,1537375 add $0,2 bin $0,2 mov $1,$0 mul $1,49
src/ewok-alarm.adb
mfkiwl/ewok-kernel-security-OS
65
24852
<gh_stars>10-100 -- -- Copyright 2018 The wookey project team <<EMAIL>> -- - <NAME> -- - <NAME> -- - <NAME> -- - <NAME> -- - <NAME> -- -- 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 ewok.tasks; use ewok.tasks; with ewok.tasks_shared; use ewok.tasks_shared; with ewok.softirq; package body ewok.alarm with spark_mode => off is procedure set_alarm (task_id : in t_real_task_id; ms : in milliseconds; handler : in system_address) is begin if alarm_state(task_id).time = 0 then count_alarms := count_alarms + 1; end if; alarm_state(task_id).time := m4.systick.get_ticks + m4.systick.to_ticks (ms); alarm_state(task_id).handler := handler; end set_alarm; procedure unset_alarm (task_id : in t_real_task_id) is begin if alarm_state(task_id).time > 0 then count_alarms := count_alarms - 1; end if; alarm_state(task_id).time := 0; alarm_state(task_id).handler := 0; end unset_alarm; procedure check_alarm (task_id : in t_real_task_id) is t : constant m4.systick.t_tick := m4.systick.get_ticks; soft_params : ewok.softirq.t_soft_parameters; begin if alarm_state(task_id).time > 0 and t > alarm_state(task_id).time then soft_params := (alarm_state(task_id).handler, unsigned_32 (t), 0, 0); ewok.softirq.push_soft (task_id, soft_params); unset_alarm (task_id); end if; end check_alarm; procedure check_alarms is begin if count_alarms > 0 then for id in config.applications.list'range loop check_alarm (id); end loop; end if; end check_alarms; end ewok.alarm;
assembler/tests/t_olms40/t_olms40.asm
paulscottrobson/RCA-Cosmac-VIP-III
0
96347
<filename>assembler/tests/t_olms40/t_olms40.asm cpu msm5840 page 0 org 0 cla cll clh lai 12 ld a,#12 ; alternate lli 13 ld dpl,#13 ; alternate lhi 14 ld dph,#14 ; alternate l ld a,(dp) ; alternate lm 2 lal ld a,dpl ; alternate lla ld dpl,a ; alternate law ld a,w ; alternate lax ld a,x ; alternate lay ld a,y ; alternate lay ld a,y ; alternate laz ld a,z ; alternate si smi 3 lwa ld w,a ; alternate lxa ld x,a ; alternate lya ld y,a ; alternate lza ld z,a ; alternate lpa ld pp,a ; alternate lti 0efh ld t,0efh ; alternate rth ld a,th ; alternate rtl ld a,tl ; alternate xa xl xch x xm 1 xax ina inc a ; alternate inl inc dpl ; alternate inm inc (dp) ; alternate inw inc w ; alternate inx inc x ; alternate iny inc y ; alternate inz inc z ; alternate dca dec a ; alternate dcl dec dpl ; alternate dcm dec (dp) ; alternate dcw dec w ; alternate dcx dec x ; alternate dcy dec y ; alternate dcz dec z ; alternate dch dec dph ; alternate cao and or eor ral ac acs as ais 7 das cm aws axs ays azs spb 0 bset (pp),0 ; alternate rpb 1 bclr (pp),1 ; alternate smb 2 bset (dp),2 ; alternate rmb 3 bclr (dp),3 ; alternate tab 0 btst a,0 ; alternate tmb 1 btst (dp),1 ; alternate tkb 2 thb 1 ; port H is only 2 bits wide! ti ttm tc sc rc j $ jc $ ja cal 3ffh rt obs otd oa ob op oab opm ia ib ib ik iab ei di et dt ect dct hlt exp nop
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_3056.asm
ljhsiun2/medusa
9
20613
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r9 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x4060, %rdx nop cmp $12999, %r12 movb $0x61, (%rdx) nop nop xor $21034, %r9 lea addresses_WT_ht+0x13960, %rsi lea addresses_D_ht+0x1e6e0, %rdi clflush (%rdi) nop nop xor %rbx, %rbx mov $73, %rcx rep movsw nop nop and %r9, %r9 lea addresses_UC_ht+0x14560, %rsi nop nop nop nop inc %r12 vmovups (%rsi), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %rdi nop nop nop nop nop xor $15645, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r9 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r8 push %rbx push %rcx push %rdi push %rdx // Store lea addresses_UC+0x1c140, %r10 clflush (%r10) add %rdi, %rdi movl $0x51525354, (%r10) nop nop add $47787, %rcx // Store lea addresses_WC+0xdfe8, %r11 nop nop nop nop xor %r8, %r8 movw $0x5152, (%r11) nop nop nop and %rbx, %rbx // Store lea addresses_PSE+0x65b0, %rdi xor %r11, %r11 movw $0x5152, (%rdi) nop nop nop nop nop xor %rdi, %rdi // Faulty Load lea addresses_UC+0x18960, %rdi clflush (%rdi) nop nop nop nop sub %r11, %r11 mov (%rdi), %r10d lea oracles, %rdi and $0xff, %r10 shlq $12, %r10 mov (%rdi,%r10,1), %r10 pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_UC', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WC', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_UC', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'37': 21829} 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 */
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/uppercase.adb
ouankou/rose
488
16088
with Ada.Characters.Handling; function UpperCase (L, R : String) return String is res : String (L'First .. L'Last); begin res := Ada.Characters.Handling.To_Upper (L); return res; end UpperCase;
doc/historic/amos.asm
zedth2/sunyat-c
0
83486
<filename>doc/historic/amos.asm<gh_stars>0 jmp 2 var cnt 26 lod r0 1 mov r1 'a' str FF r1 add r1 1 sub r0 1 cmp r0 0 jgr 4 mov r3 0D mov r4 0A psh r3 psh r4 pop r6 pop r5 str FF r5 str FF r6 lod r7 FE add r7 3 str FF r7 ret
programs/oeis/225/A225000.asm
karttu/loda
1
169401
<gh_stars>1-10 ; A225000: Duplicate of A047211. ; 2,4,7,9,12,14,17,19,22,24,27,29,32,34,37,39,42,44,47,49,52,54,57,59,62,64,67,69,72,74,77,79,82,84,87,89,92,94,97,99,102,104,107,109,112,114,117,119,122,124,127,129,132,134,137,139,142,144,147,149,152,154,157,159,162,164,167,169,172,174,177,179,182,184,187,189,192,194,197,199,202,204,207,209,212,214,217,219,222,224,227,229,232,234,237,239,242,244,247,249 mov $1,$0 mul $1,5 div $1,2 add $1,2
data/pokemon/base_stats/seedot.asm
AtmaBuster/pokeplat-gen2
6
161209
<gh_stars>1-10 db 0 ; species ID placeholder db 40, 40, 50, 30, 30, 30 ; hp atk def spd sat sdf db GRASS, GRASS ; type db 255 ; catch rate db 74 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 15 ; step cycles to hatch INCBIN "gfx/pokemon/seedot/front.dimensions" db GROWTH_MEDIUM_SLOW ; growth rate dn EGG_GROUND, EGG_PLANT ; egg groups db 70 ; happiness ; tm/hm learnset tmhm TOXIC, BULLET_SEED, HIDDEN_POWER, SUNNY_DAY, PROTECT, GIGA_DRAIN, FRUSTRATION, SOLARBEAM, RETURN, DIG, SHADOW_BALL, DOUBLE_TEAM, FACADE, SECRET_POWER, REST, ATTRACT, ENERGY_BALL, ENDURE, EXPLOSION, FLASH, SWORDS_DANCE, CAPTIVATE, SLEEP_TALK, NATURAL_GIFT, GRASS_KNOT, SWAGGER, SUBSTITUTE, ROCK_SMASH, ROLLOUT, SEED_BOMB, SNORE, SPITE, SYNTHESIS ; end
Transynther/x86/_processed/AVXALIGN/_ht_zr_/i7-7700_9_0xca_notsx.log_21829_1623.asm
ljhsiun2/medusa
9
172900
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r14 push %r8 push %rcx push %rdi push %rsi lea addresses_WT_ht+0x3f11, %rsi lea addresses_WC_ht+0x1d8d, %rdi nop nop xor $4409, %r8 mov $71, %rcx rep movsl add $62634, %rsi lea addresses_UC_ht+0xde21, %r14 nop nop nop nop xor %r13, %r13 mov (%r14), %r10d xor %r10, %r10 lea addresses_A_ht+0xdba1, %rsi lea addresses_normal_ht+0x6a21, %rdi nop nop nop add %r12, %r12 mov $65, %rcx rep movsl nop nop nop nop add %rdi, %rdi lea addresses_A_ht+0x11db1, %rcx nop nop nop nop nop sub $36624, %r14 mov $0x6162636465666768, %r12 movq %r12, (%rcx) nop add $24877, %r8 lea addresses_A_ht+0x11c21, %r10 nop nop nop nop dec %rsi movb (%r10), %r8b nop dec %r14 lea addresses_D_ht+0x1ca21, %r12 nop nop nop nop nop mfence movups (%r12), %xmm1 vpextrq $1, %xmm1, %r14 nop nop nop add $11766, %r12 lea addresses_WC_ht+0x15c21, %rcx clflush (%rcx) sub %r10, %r10 movb $0x61, (%rcx) nop add %r8, %r8 lea addresses_WC_ht+0x73b0, %rsi lea addresses_WC_ht+0x142e9, %rdi nop nop nop nop nop xor %r13, %r13 mov $10, %rcx rep movsb nop nop nop nop and %r12, %r12 lea addresses_WC_ht+0x18a21, %rsi lea addresses_D_ht+0x15221, %rdi nop nop nop xor %r8, %r8 mov $76, %rcx rep movsb nop nop nop nop nop add %r10, %r10 lea addresses_UC_ht+0x17821, %rsi lea addresses_WT_ht+0x103a1, %rdi nop nop nop nop nop dec %r10 mov $62, %rcx rep movsw nop nop nop nop and %r13, %r13 lea addresses_D_ht+0xe21, %r14 nop nop nop nop dec %rdi mov (%r14), %r13w add %rcx, %rcx lea addresses_WC_ht+0x6225, %rsi lea addresses_WT_ht+0xf315, %rdi xor %r13, %r13 mov $125, %rcx rep movsl nop nop nop nop lfence lea addresses_UC_ht+0x15621, %r8 nop nop nop xor $56599, %r14 mov $0x6162636465666768, %rsi movq %rsi, %xmm4 vmovups %ymm4, (%r8) nop nop and %r10, %r10 lea addresses_D_ht+0x1d881, %rsi lea addresses_UC_ht+0x18e21, %rdi cmp $12383, %r14 mov $122, %rcx rep movsq nop nop and $34050, %rdi pop %rsi pop %rdi pop %rcx pop %r8 pop %r14 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r8 push %r9 push %rax push %rbx push %rsi // Faulty Load lea addresses_PSE+0x1ee21, %r10 nop nop nop nop nop sub %rsi, %rsi vmovntdqa (%r10), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %rax lea oracles, %rsi and $0xff, %rax shlq $12, %rax mov (%rsi,%rax,1), %rax pop %rsi pop %rbx pop %rax pop %r9 pop %r8 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11, 'same': True, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'dst': {'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 6, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'src': {'congruent': 8, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'00': 11789, '45': 132, '48': 3976, '46': 5932} 48 00 00 00 00 00 00 00 46 00 00 00 00 48 00 00 46 00 00 00 48 46 00 00 46 46 00 48 46 00 46 00 00 48 46 46 00 48 46 00 46 00 00 48 00 48 00 00 46 00 00 46 00 00 46 00 48 46 00 48 48 46 46 00 48 00 00 00 00 48 00 48 46 00 00 00 48 00 46 00 48 46 00 46 00 45 48 00 48 46 00 00 48 00 48 00 48 00 00 48 00 48 46 00 48 46 00 00 00 00 00 00 46 48 48 46 00 00 00 46 00 46 00 46 00 46 00 46 00 00 46 00 00 48 00 00 46 00 00 00 46 00 48 46 00 00 48 46 00 00 48 46 00 46 00 00 46 00 00 46 46 46 00 48 46 48 46 00 48 00 46 48 00 46 00 46 00 46 00 46 00 48 00 46 00 00 46 46 00 00 48 48 00 48 00 00 48 00 46 00 48 46 00 00 46 00 00 46 00 00 46 00 46 46 00 48 46 00 48 48 46 00 00 45 46 00 48 46 00 00 46 46 00 48 00 48 46 00 48 46 00 48 46 00 00 48 46 00 46 00 48 46 00 00 00 46 00 46 48 45 00 48 46 00 48 46 00 48 46 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 48 46 00 00 00 00 00 48 46 00 48 00 48 00 48 00 48 46 48 46 46 00 00 00 48 46 48 46 00 48 00 00 46 00 00 46 00 48 00 00 00 00 46 00 00 46 48 46 00 48 00 00 46 00 46 00 00 46 00 00 00 46 00 48 46 00 00 48 46 46 00 00 00 00 46 00 48 46 00 48 00 48 46 00 48 00 48 46 00 46 00 46 00 46 46 48 46 00 00 48 00 46 48 46 00 48 46 00 00 00 46 00 48 46 00 46 00 00 46 00 48 46 00 00 00 46 00 46 46 00 00 00 00 46 00 00 48 46 00 00 00 00 46 00 00 46 00 48 46 00 46 00 48 00 48 00 48 00 46 00 46 00 00 46 48 48 46 00 48 00 46 00 00 00 00 00 00 00 00 48 46 00 48 46 00 00 48 00 00 00 48 46 00 00 46 46 00 00 46 00 00 48 46 48 46 00 48 46 00 00 46 00 00 46 00 46 00 00 46 00 00 00 00 46 00 48 00 00 48 46 00 46 00 46 00 48 00 46 00 48 00 48 46 48 00 00 00 48 46 48 00 46 00 00 46 00 48 46 00 00 48 46 46 00 00 00 00 00 46 00 48 46 00 00 48 46 00 48 46 00 00 48 46 00 48 46 00 00 46 46 00 48 00 00 00 46 48 46 48 46 00 00 00 00 46 46 00 00 46 00 00 00 48 46 00 00 46 00 46 46 00 48 46 00 48 46 00 48 00 00 46 00 48 46 48 46 00 48 46 00 48 00 00 48 46 00 45 00 00 00 46 00 00 46 00 00 48 46 46 00 00 48 48 00 46 00 00 00 00 46 00 00 48 00 00 00 00 48 00 48 46 48 00 00 46 48 00 00 00 46 00 48 46 00 00 00 00 46 46 00 00 46 00 00 48 46 00 00 48 46 00 46 00 00 00 46 00 00 00 00 46 00 46 00 00 00 00 48 46 00 00 00 46 00 46 00 48 46 00 00 48 46 00 48 46 00 00 48 46 48 00 00 46 00 48 48 46 00 00 00 48 46 00 00 48 46 00 48 46 00 46 00 00 48 00 48 46 46 00 46 00 48 46 46 00 48 00 48 48 00 48 46 48 46 00 00 48 46 00 48 00 00 48 46 00 00 45 00 00 48 00 00 46 00 00 48 46 00 48 00 46 46 00 00 48 46 00 00 48 46 00 00 00 00 00 00 00 00 00 00 46 00 00 48 46 00 46 45 00 00 46 00 00 00 00 46 00 46 00 00 46 48 00 48 46 00 00 46 00 48 46 48 46 00 00 00 46 00 00 48 00 00 46 48 46 46 00 48 46 48 46 00 46 00 00 00 48 46 00 46 00 48 46 00 00 00 48 46 00 48 46 00 48 00 48 46 00 00 46 00 48 00 00 00 00 00 48 00 00 48 46 48 46 00 00 48 46 00 46 00 46 00 00 46 00 46 00 48 00 00 48 46 00 48 46 00 00 00 00 46 00 46 00 00 48 00 00 48 48 46 00 00 00 00 46 00 00 46 00 48 46 00 46 46 00 46 00 48 46 48 46 48 46 00 48 46 00 00 00 00 46 00 48 00 46 48 00 00 00 00 48 00 48 46 00 00 */
modules/errorhandler/bundles/ErrorHandler.Global.AS.asm
vladikcomper/md-modules
9
102223
<filename>modules/errorhandler/bundles/ErrorHandler.Global.AS.asm<gh_stars>1-10 ErrorHandler___global__error_initconsole: label ErrorHandler+$146 ErrorHandler___global__errorhandler_setupvdp: label ErrorHandler+$234 ErrorHandler___global__console_loadpalette: label ErrorHandler+$A1A ErrorHandler___global__console_setposasxy_stack: label ErrorHandler+$A56 ErrorHandler___global__console_setposasxy: label ErrorHandler+$A5C ErrorHandler___global__console_getposasxy: label ErrorHandler+$A88 ErrorHandler___global__console_startnewline: label ErrorHandler+$AAA ErrorHandler___global__console_setbasepattern: label ErrorHandler+$AD2 ErrorHandler___global__console_setwidth: label ErrorHandler+$AE6 ErrorHandler___global__console_writeline_withpattern: label ErrorHandler+$AFC ErrorHandler___global__console_writeline: label ErrorHandler+$AFE ErrorHandler___global__console_write: label ErrorHandler+$B02 ErrorHandler___global__console_writeline_formatted: label ErrorHandler+$BAE ErrorHandler___global__console_write_formatted: label ErrorHandler+$BB2
programs/oeis/120/A120777.asm
jmorken/loda
1
173562
; A120777: One half of denominators of partial sums of a series for sqrt(2). ; 1,4,8,64,128,512,1024,16384,32768,131072,262144,2097152,4194304,16777216,33554432,1073741824,2147483648,8589934592,17179869184,137438953472,274877906944,1099511627776,2199023255552,35184372088832,70368744177664,281474976710656,562949953421312,4503599627370496,9007199254740992 mov $4,7 mov $5,1 add $5,$0 add $4,$5 mov $2,$4 lpb $0 sub $0,1 div $5,2 add $2,$5 lpe mov $1,2 mov $3,1 add $3,$2 sub $3,1 pow $1,$3 sub $1,254 div $1,256 add $1,1
libsrc/_DEVELOPMENT/temp/sp1/zx/c/sdcc_ix/sp1_AddColSpr.asm
jpoikela/z88dk
640
93114
<gh_stars>100-1000 ; uint sp1_AddColSpr(struct sp1_ss *s, void *drawf, uchar type, int graphic, uchar plane) SECTION code_clib SECTION code_temp_sp1 PUBLIC _sp1_AddColSpr EXTERN l0_sp1_AddColSpr_callee _sp1_AddColSpr: exx pop bc pop de exx pop de pop hl pop bc ld a,l pop hl ld h,l ld l,a push hl push bc push hl push de exx push de jp l0_sp1_AddColSpr_callee
AlgProg.agda
polymonyrks/algprog
0
16471
<reponame>polymonyrks/algprog open import Level open import Data.Product open import Relation.Nullary open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong) module AlgProg where -- 1.1 Datatypes private variable l : Level data Bool : Set where false : Bool true : Bool data Char : Set where ca : Char cb : Char cc : Char data Either : Set where bool : Bool → Either char : Char → Either data Both : Set where tuple : Bool × Char → Both not : Bool → Bool not false = true not true = false switch : Both → Both switch (tuple (b , c)) = tuple (not b , c) and : (Bool × Bool) → Bool and (false , _) = false and (true , b) = b cand : Bool → Bool → Bool cand false _ = false cand true b = b curry' : {A B C : Set} → (B → (C → A)) → ((B × C) → A) curry' f (b , c) = f b c data maybe (A : Set l) : Set l where nothing : maybe A just : (x : A) → maybe A -- 1.2 Natural Numbers data Nat : Set where zero' : Nat 1+ : Nat → Nat {-# BUILTIN NATURAL Nat #-} {- plus : Nat × Nat → Nat plus (n , zero') = n plus (n , succ m) = succ (plus (n , m)) mult : Nat × Nat → Nat mult (n , zero') = zero' mult (n , succ m) = plus (n , mult (n , m)) -} _+_ : Nat → Nat → Nat n + 0 = n n + (1+ m) = 1+ (n + m) _*_ : Nat → Nat → Nat n * 0 = 0 n * (1+ m) = n + (n * m) fact : Nat → Nat fact 0 = 1 fact (1+ n) = (1+ n) * (fact n) fib : Nat → Nat fib 0 = 0 fib (1+ 0) = 1 fib (1+ (1+ n)) = (fib n) + (fib (1+ n)) foldn : {A : Set} → A → (A → A) → (Nat → A) foldn c h 0 = c foldn c h (1+ n) = h (foldn c h n) foldn1+is+ : (m n : Nat) → (m + n) ≡ ((foldn m 1+) n) foldn1+is+ m 0 = refl foldn1+is+ m (1+ n) = cong 1+ (foldn1+is+ m n) foldn+is* : (m n : Nat) → m * n ≡ (foldn 0 (λ x → m + x)) n foldn+is* m 0 = refl foldn+is* m (1+ n) = cong (λ x → m + x) (foldn+is* m n) expn : Nat → Nat → Nat expn m = foldn 1 (λ n → m * n) outl : {A B : Set} → (A × B) → A outl (fst , snd) = fst outr : {A B : Set} → (A × B) → B outr (fst , snd) = snd f1 : (Nat × Nat) → Nat × Nat f1 (m , n) = (1+ m , (1+ m) * n) rec-× : {A B C D : Set} → (f : A → B) → (g : C → D) → ((A × C) -> (B × D)) rec-× f g (a , c) = (f a , g c) outrFoldnIsFact : (n : Nat) → (foldn (0 , 1) f1 n) ≡ (n , fact n) outrFoldnIsFact zero' = refl outrFoldnIsFact (1+ n) rewrite (outrFoldnIsFact n) = refl -- 1.3 Lists data listr (A : Set l) : Set l where nil : listr A cons : A → listr A → listr A data listl (A : Set l) : Set l where nil : listl A snoc : listl A → A → listl A snocr : {A : Set} → listr A → A → listr A snocr nil a = cons a nil snocr (cons a0 as) a1 = cons a0 (snocr as a1) convert : {A : Set} → listl A → listr A convert nil = nil convert (snoc xs x) = snocr (convert xs) x _++_ : {A : Set} → listl A → listl A → listl A xs ++ nil = xs xs ++ snoc ys x = snoc (xs ++ ys) x ++-assoc : {A : Set} → (xs ys zs : listl A) → (xs ++ (ys ++ zs)) ≡ ((xs ++ ys) ++ zs) ++-assoc xs ys nil = refl ++-assoc xs ys (snoc zs x) = cong (λ y → snoc y x) (++-assoc xs ys zs) listrF : {A B : Set} → (A → B) → listr A → listr B listrF f nil = nil listrF f (cons x as) = cons (f x) (listrF f as) foldr : {A B : Set} → B → (A → B → B) → (listr A → B) foldr c h nil = c foldr c h (cons a as) = h a (foldr c h as)
Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.ada
LaudateCorpus1/RosettaCodeData
1
27885
<gh_stars>1-10 with Ada.Text_IO; procedure Dogs is Dog : String := "Bernie"; begin Ada.Text_IO.Put_Line ("There is just one dog named " & DOG); end Dogs;
MuNu.agda
nad/codata
1
12217
------------------------------------------------------------------------ -- An investigation of nested fixpoints of the form μX.νY.… in Agda ------------------------------------------------------------------------ module MuNu where open import Codata.Musical.Notation import Codata.Musical.Colist as Colist open import Codata.Musical.Stream open import Data.Digit open import Data.Empty open import Data.List using (List; _∷_; []) open import Data.Product open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (¬_) -- <NAME> discusses (essentially) the type μO. νZ. Z + O -- in his thesis. If Z is read as zero and O as one, then this type -- contains bit sequences of the form (0^⋆1)^⋆0^ω. -- It is interesting to note that currently it is not possible to -- encode this type directly in Agda. One might believe that the -- following definition should work. First we define the inner -- greatest fixpoint: data Z (O : Set) : Set where [0] : ∞ (Z O) → Z O [1] : O → Z O -- Then we define the outer least fixpoint: data O : Set where ↓ : Z O → O -- However, it is still possible to define values of the form (01)^ω: 01^ω : O 01^ω = ↓ ([0] (♯ [1] 01^ω)) -- The reason is the way the termination/productivity checker works: -- it accepts definitions by guarded corecursion as long as the guard -- contains at least one occurrence of ♯_, no matter how the types -- involved are defined. In effect ∞ has global reach. The mistake -- done above was believing that O is defined to be a least fixpoint. -- The type O really corresponds to νZ. μO. Z + O, i.e. (1^⋆0)^ω: data O′ : Set where [0] : ∞ O′ → O′ [1] : O′ → O′ mutual O→O′ : O → O′ O→O′ (↓ z) = ZO→O′ z ZO→O′ : Z O → O′ ZO→O′ ([0] z) = [0] (♯ ZO→O′ (♭ z)) ZO→O′ ([1] o) = [1] (O→O′ o) mutual O′→O : O′ → O O′→O o = ↓ (O′→ZO o) O′→ZO : O′ → Z O O′→ZO ([0] o) = [0] (♯ O′→ZO (♭ o)) O′→ZO ([1] o) = [1] (O′→O o) -- If O had actually encoded the type μO. νZ. Z + O, then we could -- have proved the following theorem: mutual ⟦_⟧O : O → Stream Bit ⟦ ↓ z ⟧O = ⟦ z ⟧Z ⟦_⟧Z : Z O → Stream Bit ⟦ [0] z ⟧Z = 0b ∷ ♯ ⟦ ♭ z ⟧Z ⟦ [1] o ⟧Z = 1b ∷ ♯ ⟦ o ⟧O Theorem : Set Theorem = ∀ o → ¬ (head ⟦ o ⟧O ≡ 0b × head (tail ⟦ o ⟧O) ≡ 1b × tail (tail ⟦ o ⟧O) ≈ ⟦ o ⟧O) -- This would have been unfortunate, though: inconsistency : Theorem → ⊥ inconsistency theorem = theorem 01^ω (refl , refl , proof) where proof : tail (tail ⟦ 01^ω ⟧O) ≈ ⟦ 01^ω ⟧O proof = refl ∷ ♯ (refl ∷ ♯ proof) -- Using the following elimination principle we can prove the theorem: data ⇑ {O} (P : O → Set) : Z O → Set where [0] : ∀ {z} → ∞ (⇑ P (♭ z)) → ⇑ P ([0] z) [1] : ∀ {o} → P o → ⇑ P ([1] o) O-Elim : Set₁ O-Elim = (P : O → Set) → (∀ {z} → ⇑ P z → P (↓ z)) → (o : O) → P o theorem : O-Elim → Theorem theorem O-elim = O-elim P helper where P : O → Set P o = ¬ (head ⟦ o ⟧O ≡ 0b × head (tail ⟦ o ⟧O) ≡ 1b × tail (tail ⟦ o ⟧O) ≈ ⟦ o ⟧O) helper : ∀ {z} → ⇑ P z → P (↓ z) helper ([1] p) (() , eq₂ , eq₃) helper ([0] p) (refl , eq₂ , eq₃) = hlp _ eq₂ (head-cong eq₃) (tail-cong eq₃) (♭ p) where hlp : ∀ z → head ⟦ z ⟧Z ≡ 1b → head (tail ⟦ z ⟧Z) ≡ 0b → tail (tail ⟦ z ⟧Z) ≈ ⟦ z ⟧Z → ⇑ P z → ⊥ hlp .([0] _) () eq₂ eq₃ ([0] p) hlp .([1] _) eq₁ eq₂ eq₃ ([1] p) = p (eq₂ , head-cong eq₃ , tail-cong eq₃) -- Fortunately it appears as if we cannot prove this elimination -- principle. The following code is not accepted by the termination -- checker: {- mutual O-elim : O-Elim O-elim P hyp (↓ z) = hyp (Z-elim P hyp z) Z-elim : (P : O → Set) → (∀ {z} → ⇑ P z → P (↓ z)) → (z : Z O) → ⇑ P z Z-elim P hyp ([0] z) = [0] (♯ Z-elim P hyp (♭ z)) Z-elim P hyp ([1] o) = [1] (O-elim P hyp o) -} -- If hyp were known to be contractive, then the code above would be -- correct (if not accepted by the termination checker). This is not -- the case in theorem above.
tools-src/gnu/gcc/gcc/ada/sem_prag.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
10493
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ P R A G -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- This unit contains the semantic processing for all pragmas, both language -- and implementation defined. For most pragmas, the parser only does the -- most basic job of checking the syntax, so Sem_Prag also contains the code -- to complete the syntax checks. Certain pragmas are handled partially or -- completely by the parser (see Par.Prag for further details). with Atree; use Atree; with Casing; use Casing; with Csets; use Csets; with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Expander; use Expander; with Exp_Dist; use Exp_Dist; with Fname; use Fname; with Hostparm; use Hostparm; with Lib; use Lib; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Output; use Output; with Restrict; use Restrict; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Ch8; use Sem_Ch8; with Sem_Ch13; use Sem_Ch13; with Sem_Disp; use Sem_Disp; with Sem_Elim; use Sem_Elim; with Sem_Eval; use Sem_Eval; with Sem_Intr; use Sem_Intr; with Sem_Mech; use Sem_Mech; with Sem_Res; use Sem_Res; with Sem_Type; use Sem_Type; with Sem_Util; use Sem_Util; with Sem_VFpt; use Sem_VFpt; with Stand; use Stand; with Sinfo; use Sinfo; with Sinfo.CN; use Sinfo.CN; with Sinput; use Sinput; with Snames; use Snames; with Stringt; use Stringt; with Stylesw; use Stylesw; with Targparm; use Targparm; with Tbuild; use Tbuild; with Ttypes; with Uintp; use Uintp; with Urealp; use Urealp; with Validsw; use Validsw; package body Sem_Prag is ---------------------------------------------- -- Common Handling of Import-Export Pragmas -- ---------------------------------------------- -- In the following section, a number of Import_xxx and Export_xxx -- pragmas are defined by GNAT. These are compatible with the DEC -- pragmas of the same name, and all have the following common -- form and processing: -- pragma Export_xxx -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, other optional parameters ]); -- pragma Import_xxx -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, other optional parameters ]); -- EXTERNAL_SYMBOL ::= -- IDENTIFIER -- | static_string_EXPRESSION -- The internal LOCAL_NAME designates the entity that is imported or -- exported, and must refer to an entity in the current declarative -- part (as required by the rules for LOCAL_NAME). -- The external linker name is designated by the External parameter -- if given, or the Internal parameter if not (if there is no External -- parameter, the External parameter is a copy of the Internal name). -- If the External parameter is given as a string, then this string -- is treated as an external name (exactly as though it had been given -- as an External_Name parameter for a normal Import pragma). -- If the External parameter is given as an identifier (or there is no -- External parameter, so that the Internal identifier is used), then -- the external name is the characters of the identifier, translated -- to all upper case letters for OpenVMS versions of GNAT, and to all -- lower case letters for all other versions -- Note: the external name specified or implied by any of these special -- Import_xxx or Export_xxx pragmas override an external or link name -- specified in a previous Import or Export pragma. -- Note: these and all other DEC-compatible GNAT pragmas allow full -- use of named notation, following the standard rules for subprogram -- calls, i.e. parameters can be given in any order if named notation -- is used, and positional and named notation can be mixed, subject to -- the rule that all positional parameters must appear first. -- Note: All these pragmas are implemented exactly following the DEC -- design and implementation and are intended to be fully compatible -- with the use of these pragmas in the DEC Ada compiler. ------------------------------------- -- Local Subprograms and Variables -- ------------------------------------- function Adjust_External_Name_Case (N : Node_Id) return Node_Id; -- This routine is used for possible casing adjustment of an explicit -- external name supplied as a string literal (the node N), according -- to the casing requirement of Opt.External_Name_Casing. If this is -- set to As_Is, then the string literal is returned unchanged, but if -- it is set to Uppercase or Lowercase, then a new string literal with -- appropriate casing is constructed. function Is_Generic_Subprogram (Id : Entity_Id) return Boolean; -- Return True if Id is a generic procedure or a function function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id; -- If Def_Id refers to a renamed subprogram, then the base subprogram -- (the original one, following the renaming chain) is returned. -- Otherwise the entity is returned unchanged. Should be in Einfo??? procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id); -- Place semantic information on the argument of an Elaborate or -- Elaborate_All pragma. Entity name for unit and its parents is -- taken from item in previous with_clause that mentions the unit. Locking_Policy_Sloc : Source_Ptr := No_Location; Queuing_Policy_Sloc : Source_Ptr := No_Location; Task_Dispatching_Policy_Sloc : Source_Ptr := No_Location; -- These global variables remember the location of a previous locking, -- queuing or task dispatching policy pragma, so that appropriate error -- messages can be generated for inconsistent pragmas. Note that it is -- fine that these are global locations, because the check for consistency -- is over the entire program. ------------------------------- -- Adjust_External_Name_Case -- ------------------------------- function Adjust_External_Name_Case (N : Node_Id) return Node_Id is CC : Char_Code; begin -- Adjust case of literal if required if Opt.External_Name_Exp_Casing = As_Is then return N; else -- Copy existing string Start_String; -- Set proper casing for J in 1 .. String_Length (Strval (N)) loop CC := Get_String_Char (Strval (N), J); if Opt.External_Name_Exp_Casing = Uppercase and then CC >= Get_Char_Code ('a') and then CC <= Get_Char_Code ('z') then Store_String_Char (CC - 32); elsif Opt.External_Name_Exp_Casing = Lowercase and then CC >= Get_Char_Code ('A') and then CC <= Get_Char_Code ('Z') then Store_String_Char (CC + 32); else Store_String_Char (CC); end if; end loop; return Make_String_Literal (Sloc (N), Strval => End_String); end if; end Adjust_External_Name_Case; -------------------- -- Analyze_Pragma -- -------------------- procedure Analyze_Pragma (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Prag_Id : Pragma_Id; Pragma_Exit : exception; -- This exception is used to exit pragma processing completely. It -- is used when an error is detected, and in other situations where -- it is known that no further processing is required. Arg_Count : Nat; -- Number of pragma argument associations Arg1 : Node_Id; Arg2 : Node_Id; Arg3 : Node_Id; Arg4 : Node_Id; -- First four pragma arguments (pragma argument association nodes, -- or Empty if the corresponding argument does not exist). procedure Check_Ada_83_Warning; -- Issues a warning message for the current pragma if operating in Ada -- 83 mode (used for language pragmas that are not a standard part of -- Ada 83). This procedure does not raise Error_Pragma. Also notes use -- of 95 pragma. procedure Check_Arg_Count (Required : Nat); -- Check argument count for pragma is equal to given parameter. -- If not, then issue an error message and raise Pragma_Exit. -- Note: all routines whose name is Check_Arg_Is_xxx take an -- argument Arg which can either be a pragma argument association, -- in which case the check is applied to the expression of the -- association or an expression directly. procedure Check_Arg_Is_Identifier (Arg : Node_Id); -- Check the specified argument Arg to make sure that it is an -- identifier. If not give error and raise Pragma_Exit. procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id); -- Check the specified argument Arg to make sure that it is an -- integer literal. If not give error and raise Pragma_Exit. procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id); -- Check the specified argument Arg to make sure that it has the -- proper syntactic form for a local name and meets the semantic -- requirements for a local name. The local name is analyzed as -- part of the processing for this call. In addition, the local -- name is required to represent an entity at the library level. procedure Check_Arg_Is_Local_Name (Arg : Node_Id); -- Check the specified argument Arg to make sure that it has the -- proper syntactic form for a local name and meets the semantic -- requirements for a local name. The local name is analyzed as -- part of the processing for this call. procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id); -- Check the specified argument Arg to make sure that it is a valid -- locking policy name. If not give error and raise Pragma_Exit. procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id); procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3 : Name_Id); -- Check the specified argument Arg to make sure that it is an -- identifier whose name matches either N1 or N2 (or N3 if present). -- If not then give error and raise Pragma_Exit. procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id); -- Check the specified argument Arg to make sure that it is a valid -- queuing policy name. If not give error and raise Pragma_Exit. procedure Check_Arg_Is_Static_Expression (Arg : Node_Id; Typ : Entity_Id); -- Check the specified argument Arg to make sure that it is a static -- expression of the given type (i.e. it will be analyzed and resolved -- using this type, which can be any valid argument to Resolve, e.g. -- Any_Integer is OK). If not, given error and raise Pragma_Exit. procedure Check_Arg_Is_String_Literal (Arg : Node_Id); -- Check the specified argument Arg to make sure that it is a -- string literal. If not give error and raise Pragma_Exit procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id); -- Check the specified argument Arg to make sure that it is a valid -- valid task dispatching policy name. If not give error and raise -- Pragma_Exit. procedure Check_At_Least_N_Arguments (N : Nat); -- Check there are at least N arguments present procedure Check_At_Most_N_Arguments (N : Nat); -- Check there are no more than N arguments present procedure Check_First_Subtype (Arg : Node_Id); -- Checks that Arg, whose expression is an entity name referencing -- a subtype, does not reference a type that is not a first subtype. procedure Check_In_Main_Program; -- Common checks for pragmas that appear within a main program -- (Priority, Main_Storage, Time_Slice). procedure Check_Interrupt_Or_Attach_Handler; -- Common processing for first argument of pragma Interrupt_Handler -- or pragma Attach_Handler. procedure Check_Is_In_Decl_Part_Or_Package_Spec; -- Check that pragma appears in a declarative part, or in a package -- specification, i.e. that it does not occur in a statement sequence -- in a body. procedure Check_No_Identifier (Arg : Node_Id); -- Checks that the given argument does not have an identifier. If -- an identifier is present, then an error message is issued, and -- Pragma_Exit is raised. procedure Check_No_Identifiers; -- Checks that none of the arguments to the pragma has an identifier. -- If any argument has an identifier, then an error message is issued, -- and Pragma_Exit is raised. procedure Check_Non_Overloaded_Function (Arg : Node_Id); -- Check that the given argument is the name of a local function of -- one argument that is not overloaded in the current local scope. procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id); -- Checks if the given argument has an identifier, and if so, requires -- it to match the given identifier name. If there is a non-matching -- identifier, then an error message is given and Error_Pragmas raised. procedure Check_Optional_Identifier (Arg : Node_Id; Id : String); -- Checks if the given argument has an identifier, and if so, requires -- it to match the given identifier name. If there is a non-matching -- identifier, then an error message is given and Error_Pragmas raised. -- In this version of the procedure, the identifier name is given as -- a string with lower case letters. procedure Check_Static_Constraint (Constr : Node_Id); -- Constr is a constraint from an N_Subtype_Indication node from a -- component constraint in an Unchecked_Union type. This routine checks -- that the constraint is static as required by the restrictions for -- Unchecked_Union. procedure Check_Valid_Configuration_Pragma; -- Legality checks for placement of a configuration pragma procedure Check_Valid_Library_Unit_Pragma; -- Legality checks for library unit pragmas. A special case arises for -- pragmas in generic instances that come from copies of the original -- library unit pragmas in the generic templates. In the case of other -- than library level instantiations these can appear in contexts which -- would normally be invalid (they only apply to the original template -- and to library level instantiations), and they are simply ignored, -- which is implemented by rewriting them as null statements. procedure Error_Pragma (Msg : String); pragma No_Return (Error_Pragma); -- Outputs error message for current pragma. The message contains an % -- that will be replaced with the pragma name, and the flag is placed -- on the pragma itself. Pragma_Exit is then raised. procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id); pragma No_Return (Error_Pragma_Arg); -- Outputs error message for current pragma. The message may contain -- a % that will be replaced with the pragma name. The parameter Arg -- may either be a pragma argument association, in which case the flag -- is placed on the expression of this association, or an expression, -- in which case the flag is placed directly on the expression. The -- message is placed using Error_Msg_N, so the message may also contain -- an & insertion character which will reference the given Arg value. -- After placing the message, Pragma_Exit is raised. procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id); pragma No_Return (Error_Pragma_Arg); -- Similar to above form of Error_Pragma_Arg except that two messages -- are provided, the second is a continuation comment starting with \. procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id); pragma No_Return (Error_Pragma_Arg_Ident); -- Outputs error message for current pragma. The message may contain -- a % that will be replaced with the pragma name. The parameter Arg -- must be a pragma argument association with a non-empty identifier -- (i.e. its Chars field must be set), and the error message is placed -- on the identifier. The message is placed using Error_Msg_N so -- the message may also contain an & insertion character which will -- reference the identifier. After placing the message, Pragma_Exit -- is raised. function Find_Lib_Unit_Name return Entity_Id; -- Used for a library unit pragma to find the entity to which the -- library unit pragma applies, returns the entity found. procedure Find_Program_Unit_Name (Id : Node_Id); -- If the pragma is a compilation unit pragma, the id must denote the -- compilation unit in the same compilation, and the pragma must appear -- in the list of preceding or trailing pragmas. If it is a program -- unit pragma that is not a compilation unit pragma, then the -- identifier must be visible. type Name_List is array (Natural range <>) of Name_Id; type Args_List is array (Natural range <>) of Node_Id; procedure Gather_Associations (Names : Name_List; Args : out Args_List); -- This procedure is used to gather the arguments for a pragma that -- permits arbitrary ordering of parameters using the normal rules -- for named and positional parameters. The Names argument is a list -- of Name_Id values that corresponds to the allowed pragma argument -- association identifiers in order. The result returned in Args is -- a list of corresponding expressions that are the pragma arguments. -- Note that this is a list of expressions, not of pragma argument -- associations (Gather_Associations has completely checked all the -- optional identifiers when it returns). An entry in Args is Empty -- on return if the corresponding argument is not present. function Get_Pragma_Arg (Arg : Node_Id) return Node_Id; -- All the routines that check pragma arguments take either a pragma -- argument association (in which case the expression of the argument -- association is checked), or the expression directly. The function -- Get_Pragma_Arg is a utility used to deal with these two cases. If -- Arg is a pragma argument association node, then its expression is -- returned, otherwise Arg is returned unchanged. procedure GNAT_Pragma; -- Called for all GNAT defined pragmas to note the use of the feature, -- and also check the relevant restriction (No_Implementation_Pragmas). function Is_Before_First_Decl (Pragma_Node : Node_Id; Decls : List_Id) return Boolean; -- Return True if Pragma_Node is before the first declarative item in -- Decls where Decls is the list of declarative items. function Is_Configuration_Pragma return Boolean; -- Deterermines if the placement of the current pragma is appropriate -- for a configuration pragma (precedes the current compilation unit) procedure Pragma_Misplaced; -- Issue fatal error message for misplaced pragma procedure Process_Atomic_Shared_Volatile; -- Common processing for pragmas Atomic, Shared, Volatile. Note that -- Shared is an obsolete Ada 83 pragma, treated as being identical -- in effect to pragma Atomic. procedure Process_Convention (C : out Convention_Id; E : out Entity_Id); -- Common procesing for Convention, Interface, Import and Export. -- Checks first two arguments of pragma, and sets the appropriate -- convention value in the specified entity or entities. On return -- C is the convention, E is the referenced entity. procedure Process_Extended_Import_Export_Exception_Pragma (Arg_Internal : Node_Id; Arg_External : Node_Id; Arg_Form : Node_Id; Arg_Code : Node_Id); -- Common processing for the pragmas Import/Export_Exception. -- The three arguments correspond to the three named parameters of -- the pragma. An argument is empty if the corresponding parameter -- is not present in the pragma. procedure Process_Extended_Import_Export_Object_Pragma (Arg_Internal : Node_Id; Arg_External : Node_Id; Arg_Size : Node_Id); -- Common processing for the pragmass Import/Export_Object. -- The three arguments correspond to the three named parameters -- of the pragmas. An argument is empty if the corresponding -- parameter is not present in the pragma. procedure Process_Extended_Import_Export_Internal_Arg (Arg_Internal : Node_Id := Empty); -- Common processing for all extended Import and Export pragmas. The -- argument is the pragma parameter for the Internal argument. If -- Arg_Internal is empty or inappropriate, an error message is posted. -- Otherwise, on normal return, the Entity_Field of Arg_Internal is -- set to identify the referenced entity. procedure Process_Extended_Import_Export_Subprogram_Pragma (Arg_Internal : Node_Id; Arg_External : Node_Id; Arg_Parameter_Types : Node_Id; Arg_Result_Type : Node_Id := Empty; Arg_Mechanism : Node_Id; Arg_Result_Mechanism : Node_Id := Empty; Arg_First_Optional_Parameter : Node_Id := Empty); -- Common processing for all extended Import and Export pragmas -- applying to subprograms. The caller omits any arguments that do -- bnot apply to the pragma in question (for example, Arg_Result_Type -- can be non-Empty only in the Import_Function and Export_Function -- cases). The argument names correspond to the allowed pragma -- association identifiers. procedure Process_Generic_List; -- Common processing for Share_Generic and Inline_Generic procedure Process_Import_Or_Interface; -- Common processing for Import of Interface procedure Process_Inline (Active : Boolean); -- Common processing for Inline and Inline_Always. The parameter -- indicates if the inline pragma is active, i.e. if it should -- actually cause inlining to occur. procedure Process_Interface_Name (Subprogram_Def : Entity_Id; Ext_Arg : Node_Id; Link_Arg : Node_Id); -- Given the last two arguments of pragma Import, pragma Export, or -- pragma Interface_Name, performs validity checks and sets the -- Interface_Name field of the given subprogram entity to the -- appropriate external or link name, depending on the arguments -- given. Ext_Arg is always present, but Link_Arg may be missing. -- Note that Ext_Arg may represent the Link_Name if Link_Arg is -- missing, and appropriate named notation is used for Ext_Arg. -- If neither Ext_Arg nor Link_Arg is present, the interface name -- is set to the default from the subprogram name. procedure Process_Interrupt_Or_Attach_Handler; -- Attach the pragmas to the rep item chain. procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean); -- Common processing for Suppress and Unsuppress. The boolean parameter -- Suppress_Case is True for the Suppress case, and False for the -- Unsuppress case. procedure Set_Exported (E : Entity_Id; Arg : Node_Id); -- This procedure sets the Is_Exported flag for the given entity, -- checking that the entity was not previously imported. Arg is -- the argument that specified the entity. procedure Set_Extended_Import_Export_External_Name (Internal_Ent : Entity_Id; Arg_External : Node_Id); -- Common processing for all extended import export pragmas. The first -- argument, Internal_Ent, is the internal entity, which has already -- been checked for validity by the caller. Arg_External is from the -- Import or Export pragma, and may be null if no External parameter -- was present. If Arg_External is present and is a non-null string -- (a null string is treated as the default), then the Interface_Name -- field of Internal_Ent is set appropriately. procedure Set_Imported (E : Entity_Id); -- This procedure sets the Is_Imported flag for the given entity, -- checking that it is not previously exported or imported. procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id); -- Mech is a parameter passing mechanism (see Import_Function syntax -- for MECHANISM_NAME). This routine checks that the mechanism argument -- has the right form, and if not issues an error message. If the -- argument has the right form then the Mechanism field of Ent is -- set appropriately. -------------------------- -- Check_Ada_83_Warning -- -------------------------- procedure Check_Ada_83_Warning is begin GNAT_Pragma; if Ada_83 and then Comes_From_Source (N) then Error_Msg_N ("(Ada 83) pragma& is non-standard?", N); end if; end Check_Ada_83_Warning; --------------------- -- Check_Arg_Count -- --------------------- procedure Check_Arg_Count (Required : Nat) is begin if Arg_Count /= Required then Error_Pragma ("wrong number of arguments for pragma%"); end if; end Check_Arg_Count; ----------------------------- -- Check_Arg_Is_Identifier -- ----------------------------- procedure Check_Arg_Is_Identifier (Arg : Node_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin if Nkind (Argx) /= N_Identifier then Error_Pragma_Arg ("argument for pragma% must be identifier", Argx); end if; end Check_Arg_Is_Identifier; ---------------------------------- -- Check_Arg_Is_Integer_Literal -- ---------------------------------- procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin if Nkind (Argx) /= N_Integer_Literal then Error_Pragma_Arg ("argument for pragma% must be integer literal", Argx); end if; end Check_Arg_Is_Integer_Literal; ------------------------------------------- -- Check_Arg_Is_Library_Level_Local_Name -- ------------------------------------------- -- LOCAL_NAME ::= -- DIRECT_NAME -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR -- | library_unit_NAME procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id) is begin Check_Arg_Is_Local_Name (Arg); if not Is_Library_Level_Entity (Entity (Expression (Arg))) and then Comes_From_Source (N) then Error_Pragma_Arg ("argument for pragma% must be library level entity", Arg); end if; end Check_Arg_Is_Library_Level_Local_Name; ----------------------------- -- Check_Arg_Is_Local_Name -- ----------------------------- -- LOCAL_NAME ::= -- DIRECT_NAME -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR -- | library_unit_NAME procedure Check_Arg_Is_Local_Name (Arg : Node_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin Analyze (Argx); if Nkind (Argx) not in N_Direct_Name and then (Nkind (Argx) /= N_Attribute_Reference or else Present (Expressions (Argx)) or else Nkind (Prefix (Argx)) /= N_Identifier) and then (not Is_Entity_Name (Argx) or else not Is_Compilation_Unit (Entity (Argx))) then Error_Pragma_Arg ("argument for pragma% must be local name", Argx); end if; if Is_Entity_Name (Argx) and then Scope (Entity (Argx)) /= Current_Scope then Error_Pragma_Arg ("pragma% argument must be in same declarative part", Arg); end if; end Check_Arg_Is_Local_Name; --------------------------------- -- Check_Arg_Is_Locking_Policy -- --------------------------------- procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin Check_Arg_Is_Identifier (Argx); if not Is_Locking_Policy_Name (Chars (Argx)) then Error_Pragma_Arg ("& is not a valid locking policy name", Argx); end if; end Check_Arg_Is_Locking_Policy; ------------------------- -- Check_Arg_Is_One_Of -- ------------------------- procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin Check_Arg_Is_Identifier (Argx); if Chars (Argx) /= N1 and then Chars (Argx) /= N2 then Error_Msg_Name_2 := N1; Error_Msg_Name_3 := N2; Error_Pragma_Arg ("argument for pragma% must be% or%", Argx); end if; end Check_Arg_Is_One_Of; procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3 : Name_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin Check_Arg_Is_Identifier (Argx); if Chars (Argx) /= N1 and then Chars (Argx) /= N2 and then Chars (Argx) /= N3 then Error_Pragma_Arg ("invalid argument for pragma%", Argx); end if; end Check_Arg_Is_One_Of; --------------------------------- -- Check_Arg_Is_Queuing_Policy -- --------------------------------- procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin Check_Arg_Is_Identifier (Argx); if not Is_Queuing_Policy_Name (Chars (Argx)) then Error_Pragma_Arg ("& is not a valid queuing policy name", Argx); end if; end Check_Arg_Is_Queuing_Policy; ------------------------------------ -- Check_Arg_Is_Static_Expression -- ------------------------------------ procedure Check_Arg_Is_Static_Expression (Arg : Node_Id; Typ : Entity_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin Analyze_And_Resolve (Argx, Typ); if Is_OK_Static_Expression (Argx) then return; elsif Etype (Argx) = Any_Type then raise Pragma_Exit; -- An interesting special case, if we have a string literal and -- we are in Ada 83 mode, then we allow it even though it will -- not be flagged as static. This allows the use of Ada 95 -- pragmas like Import in Ada 83 mode. They will of course be -- flagged with warnings as usual, but will not cause errors. elsif Ada_83 and then Nkind (Argx) = N_String_Literal then return; -- Static expression that raises Constraint_Error. This has -- already been flagged, so just exit from pragma processing. elsif Is_Static_Expression (Argx) then raise Pragma_Exit; -- Finally, we have a real error else Error_Pragma_Arg ("argument for pragma% must be a static expression", Argx); end if; end Check_Arg_Is_Static_Expression; --------------------------------- -- Check_Arg_Is_String_Literal -- --------------------------------- procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin if Nkind (Argx) /= N_String_Literal then Error_Pragma_Arg ("argument for pragma% must be string literal", Argx); end if; end Check_Arg_Is_String_Literal; ------------------------------------------ -- Check_Arg_Is_Task_Dispatching_Policy -- ------------------------------------------ procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin Check_Arg_Is_Identifier (Argx); if not Is_Task_Dispatching_Policy_Name (Chars (Argx)) then Error_Pragma_Arg ("& is not a valid task dispatching policy name", Argx); end if; end Check_Arg_Is_Task_Dispatching_Policy; -------------------------------- -- Check_At_Least_N_Arguments -- -------------------------------- procedure Check_At_Least_N_Arguments (N : Nat) is begin if Arg_Count < N then Error_Pragma ("too few arguments for pragma%"); end if; end Check_At_Least_N_Arguments; ------------------------------- -- Check_At_Most_N_Arguments -- ------------------------------- procedure Check_At_Most_N_Arguments (N : Nat) is Arg : Node_Id; begin if Arg_Count > N then Arg := Arg1; for J in 1 .. N loop Next (Arg); Error_Pragma_Arg ("too many arguments for pragma%", Arg); end loop; end if; end Check_At_Most_N_Arguments; ------------------------- -- Check_First_Subtype -- ------------------------- procedure Check_First_Subtype (Arg : Node_Id) is Argx : constant Node_Id := Get_Pragma_Arg (Arg); begin if not Is_First_Subtype (Entity (Argx)) then Error_Pragma_Arg ("pragma% cannot apply to subtype", Argx); end if; end Check_First_Subtype; --------------------------- -- Check_In_Main_Program -- --------------------------- procedure Check_In_Main_Program is P : constant Node_Id := Parent (N); begin -- Must be at in subprogram body if Nkind (P) /= N_Subprogram_Body then Error_Pragma ("% pragma allowed only in subprogram"); -- Otherwise warn if obviously not main program elsif Present (Parameter_Specifications (Specification (P))) or else not Is_Library_Level_Entity (Defining_Entity (P)) then Error_Msg_Name_1 := Chars (N); Error_Msg_N ("?pragma% is only effective in main program", N); end if; end Check_In_Main_Program; --------------------------------------- -- Check_Interrupt_Or_Attach_Handler -- --------------------------------------- procedure Check_Interrupt_Or_Attach_Handler is Arg1_X : constant Node_Id := Expression (Arg1); begin Analyze (Arg1_X); if not Is_Entity_Name (Arg1_X) then Error_Pragma_Arg ("argument of pragma% must be entity name", Arg1); elsif Prag_Id = Pragma_Interrupt_Handler then Check_Restriction (No_Dynamic_Interrupts, N); end if; declare Prot_Proc : Entity_Id := Empty; Prot_Type : Entity_Id; Found : Boolean := False; begin if not Is_Overloaded (Arg1_X) then Prot_Proc := Entity (Arg1_X); else declare It : Interp; Index : Interp_Index; begin Get_First_Interp (Arg1_X, Index, It); while Present (It.Nam) loop Prot_Proc := It.Nam; if Ekind (Prot_Proc) = E_Procedure and then No (First_Formal (Prot_Proc)) then if not Found then Found := True; Set_Entity (Arg1_X, Prot_Proc); Set_Is_Overloaded (Arg1_X, False); else Error_Pragma_Arg ("ambiguous handler name for pragma% ", Arg1); end if; end if; Get_Next_Interp (Index, It); end loop; if not Found then Error_Pragma_Arg ("argument of pragma% must be parameterless procedure", Arg1); else Prot_Proc := Entity (Arg1_X); end if; end; end if; Prot_Type := Scope (Prot_Proc); if Ekind (Prot_Proc) /= E_Procedure or else Ekind (Prot_Type) /= E_Protected_Type then Error_Pragma_Arg ("argument of pragma% must be protected procedure", Arg1); end if; if not Is_Library_Level_Entity (Prot_Type) then Error_Pragma_Arg ("pragma% requires library level entity", Arg1); end if; if Present (First_Formal (Prot_Proc)) then Error_Pragma_Arg ("argument of pragma% must be parameterless procedure", Arg1); end if; if Parent (N) /= Protected_Definition (Parent (Prot_Type)) then Error_Pragma ("pragma% must be in protected definition"); end if; end; end Check_Interrupt_Or_Attach_Handler; ------------------------------------------- -- Check_Is_In_Decl_Part_Or_Package_Spec -- ------------------------------------------- procedure Check_Is_In_Decl_Part_Or_Package_Spec is P : Node_Id; begin P := Parent (N); loop if No (P) then exit; elsif Nkind (P) = N_Handled_Sequence_Of_Statements then exit; elsif Nkind (P) = N_Package_Specification then return; elsif Nkind (P) = N_Block_Statement then return; -- Note: the following tests seem a little peculiar, because -- they test for bodies, but if we were in the statement part -- of the body, we would already have hit the handled statement -- sequence, so the only way we get here is by being in the -- declarative part of the body. elsif Nkind (P) = N_Subprogram_Body or else Nkind (P) = N_Package_Body or else Nkind (P) = N_Task_Body or else Nkind (P) = N_Entry_Body then return; end if; P := Parent (P); end loop; Error_Pragma ("pragma% is not in declarative part or package spec"); end Check_Is_In_Decl_Part_Or_Package_Spec; ------------------------- -- Check_No_Identifier -- ------------------------- procedure Check_No_Identifier (Arg : Node_Id) is begin if Chars (Arg) /= No_Name then Error_Pragma_Arg_Ident ("pragma% does not permit identifier& here", Arg); end if; end Check_No_Identifier; -------------------------- -- Check_No_Identifiers -- -------------------------- procedure Check_No_Identifiers is Arg_Node : Node_Id; begin if Arg_Count > 0 then Arg_Node := Arg1; while Present (Arg_Node) loop Check_No_Identifier (Arg_Node); Next (Arg_Node); end loop; end if; end Check_No_Identifiers; ----------------------------------- -- Check_Non_Overloaded_Function -- ----------------------------------- procedure Check_Non_Overloaded_Function (Arg : Node_Id) is Ent : Entity_Id; begin Check_Arg_Is_Local_Name (Arg); Ent := Entity (Expression (Arg)); if Present (Homonym (Ent)) and then Scope (Homonym (Ent)) = Current_Scope then Error_Pragma_Arg ("argument for pragma% may not be overloaded", Arg); end if; if Ekind (Ent) /= E_Function or else No (First_Formal (Ent)) or else Present (Next_Formal (First_Formal (Ent))) then Error_Pragma_Arg ("argument for pragma% must be function of one argument", Arg); end if; end Check_Non_Overloaded_Function; ------------------------------- -- Check_Optional_Identifier -- ------------------------------- procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is begin if Present (Arg) and then Chars (Arg) /= No_Name then if Chars (Arg) /= Id then Error_Msg_Name_1 := Chars (N); Error_Msg_Name_2 := Id; Error_Msg_N ("pragma% argument expects identifier%", Arg); raise Pragma_Exit; end if; end if; end Check_Optional_Identifier; procedure Check_Optional_Identifier (Arg : Node_Id; Id : String) is begin Name_Buffer (1 .. Id'Length) := Id; Name_Len := Id'Length; Check_Optional_Identifier (Arg, Name_Find); end Check_Optional_Identifier; ----------------------------- -- Check_Static_Constraint -- ----------------------------- -- Note: for convenience in writing this procedure, in addition to -- the officially (i.e. by spec) allowed argument which is always -- a constraint, it also allows ranges and discriminant associations. procedure Check_Static_Constraint (Constr : Node_Id) is -------------------- -- Require_Static -- -------------------- procedure Require_Static (E : Node_Id); -- Require given expression to be static expression procedure Require_Static (E : Node_Id) is begin if not Is_OK_Static_Expression (E) then Error_Msg_N ("non-static constraint not allowed in Unchecked_Union", E); raise Pragma_Exit; end if; end Require_Static; -- Start of processing for Check_Static_Constraint begin case Nkind (Constr) is when N_Discriminant_Association => Require_Static (Expression (Constr)); when N_Range => Require_Static (Low_Bound (Constr)); Require_Static (High_Bound (Constr)); when N_Attribute_Reference => Require_Static (Type_Low_Bound (Etype (Prefix (Constr)))); Require_Static (Type_High_Bound (Etype (Prefix (Constr)))); when N_Range_Constraint => Check_Static_Constraint (Range_Expression (Constr)); when N_Index_Or_Discriminant_Constraint => declare IDC : Entity_Id := First (Constraints (Constr)); begin while Present (IDC) loop Check_Static_Constraint (IDC); Next (IDC); end loop; end; when others => null; end case; end Check_Static_Constraint; -------------------------------------- -- Check_Valid_Configuration_Pragma -- -------------------------------------- -- A configuration pragma must appear in the context clause of -- a compilation unit, at the start of the list (i.e. only other -- pragmas may precede it). procedure Check_Valid_Configuration_Pragma is begin if not Is_Configuration_Pragma then Error_Pragma ("incorrect placement for configuration pragma%"); end if; end Check_Valid_Configuration_Pragma; ------------------------------------- -- Check_Valid_Library_Unit_Pragma -- ------------------------------------- procedure Check_Valid_Library_Unit_Pragma is Plist : List_Id; Parent_Node : Node_Id; Unit_Name : Entity_Id; Valid : Boolean := True; Unit_Kind : Node_Kind; Unit_Node : Node_Id; Sindex : Source_File_Index; begin if not Is_List_Member (N) then Pragma_Misplaced; Valid := False; else Plist := List_Containing (N); Parent_Node := Parent (Plist); if Parent_Node = Empty then Pragma_Misplaced; -- Case of pragma appearing after a compilation unit. In this -- case it must have an argument with the corresponding name -- and must be part of the following pragmas of its parent. elsif Nkind (Parent_Node) = N_Compilation_Unit_Aux then if Plist /= Pragmas_After (Parent_Node) then Pragma_Misplaced; elsif Arg_Count = 0 then Error_Pragma ("argument required if outside compilation unit"); else Check_No_Identifiers; Check_Arg_Count (1); Unit_Node := Unit (Parent (Parent_Node)); Unit_Kind := Nkind (Unit_Node); Analyze (Expression (Arg1)); if Unit_Kind = N_Generic_Subprogram_Declaration or else Unit_Kind = N_Subprogram_Declaration then Unit_Name := Defining_Entity (Unit_Node); elsif Unit_Kind = N_Function_Instantiation or else Unit_Kind = N_Package_Instantiation or else Unit_Kind = N_Procedure_Instantiation then Unit_Name := Defining_Entity (Unit_Node); else Unit_Name := Cunit_Entity (Current_Sem_Unit); end if; if Chars (Unit_Name) /= Chars (Entity (Expression (Arg1))) then Error_Pragma_Arg ("pragma% argument is not current unit name", Arg1); end if; if Ekind (Unit_Name) = E_Package and then Present (Renamed_Entity (Unit_Name)) then Error_Pragma ("pragma% not allowed for renamed package"); end if; end if; -- Pragma appears other than after a compilation unit else -- Here we check for the generic instantiation case and also -- for the case of processing a generic formal package. We -- detect these cases by noting that the Sloc on the node -- does not belong to the current compilation unit. Sindex := Source_Index (Current_Sem_Unit); if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then Rewrite (N, Make_Null_Statement (Loc)); return; -- If before first declaration, the pragma applies to the -- enclosing unit, and the name if present must be this name. elsif Is_Before_First_Decl (N, Plist) then Unit_Node := Unit_Declaration_Node (Current_Scope); Unit_Kind := Nkind (Unit_Node); if Nkind (Parent (Unit_Node)) /= N_Compilation_Unit then Pragma_Misplaced; elsif Unit_Kind = N_Subprogram_Body and then not Acts_As_Spec (Unit_Node) then Pragma_Misplaced; elsif Nkind (Parent_Node) = N_Package_Body then Pragma_Misplaced; elsif Nkind (Parent_Node) = N_Package_Specification and then Plist = Private_Declarations (Parent_Node) then Pragma_Misplaced; elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration or else Nkind (Parent_Node) = N_Generic_Subprogram_Declaration) and then Plist = Generic_Formal_Declarations (Parent_Node) then Pragma_Misplaced; elsif Arg_Count > 0 then Analyze (Expression (Arg1)); if Entity (Expression (Arg1)) /= Current_Scope then Error_Pragma_Arg ("name in pragma% must be enclosing unit", Arg1); end if; -- It is legal to have no argument in this context else return; end if; -- Error if not before first declaration. This is because a -- library unit pragma argument must be the name of a library -- unit (RM 10.1.5(7)), but the only names permitted in this -- context are (RM 10.1.5(6)) names of subprogram declarations, -- generic subprogram declarations or generic instantiations. else Error_Pragma ("pragma% misplaced, must be before first declaration"); end if; end if; end if; end Check_Valid_Library_Unit_Pragma; ------------------ -- Error_Pragma -- ------------------ procedure Error_Pragma (Msg : String) is begin Error_Msg_Name_1 := Chars (N); Error_Msg_N (Msg, N); raise Pragma_Exit; end Error_Pragma; ---------------------- -- Error_Pragma_Arg -- ---------------------- procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id) is begin Error_Msg_Name_1 := Chars (N); Error_Msg_N (Msg, Get_Pragma_Arg (Arg)); raise Pragma_Exit; end Error_Pragma_Arg; procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id) is begin Error_Msg_Name_1 := Chars (N); Error_Msg_N (Msg1, Get_Pragma_Arg (Arg)); Error_Pragma_Arg (Msg2, Arg); end Error_Pragma_Arg; ---------------------------- -- Error_Pragma_Arg_Ident -- ---------------------------- procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id) is begin Error_Msg_Name_1 := Chars (N); Error_Msg_N (Msg, Arg); raise Pragma_Exit; end Error_Pragma_Arg_Ident; ------------------------ -- Find_Lib_Unit_Name -- ------------------------ function Find_Lib_Unit_Name return Entity_Id is begin -- Return inner compilation unit entity, for case of nested -- categorization pragmas. This happens in generic unit. if Nkind (Parent (N)) = N_Package_Specification and then Defining_Entity (Parent (N)) /= Current_Scope then return Defining_Entity (Parent (N)); else return Current_Scope; end if; end Find_Lib_Unit_Name; ---------------------------- -- Find_Program_Unit_Name -- ---------------------------- procedure Find_Program_Unit_Name (Id : Node_Id) is Unit_Name : Entity_Id; Unit_Kind : Node_Kind; P : constant Node_Id := Parent (N); begin if Nkind (P) = N_Compilation_Unit then Unit_Kind := Nkind (Unit (P)); if Unit_Kind = N_Subprogram_Declaration or else Unit_Kind = N_Package_Declaration or else Unit_Kind in N_Generic_Declaration then Unit_Name := Defining_Entity (Unit (P)); if Chars (Id) = Chars (Unit_Name) then Set_Entity (Id, Unit_Name); Set_Etype (Id, Etype (Unit_Name)); else Set_Etype (Id, Any_Type); Error_Pragma ("cannot find program unit referenced by pragma%"); end if; else Set_Etype (Id, Any_Type); Error_Pragma ("pragma% inapplicable to this unit"); end if; else Analyze (Id); end if; end Find_Program_Unit_Name; ------------------------- -- Gather_Associations -- ------------------------- procedure Gather_Associations (Names : Name_List; Args : out Args_List) is Arg : Node_Id; begin -- Initialize all parameters to Empty for J in Args'Range loop Args (J) := Empty; end loop; -- That's all we have to do if there are no argument associations if No (Pragma_Argument_Associations (N)) then return; end if; -- Otherwise first deal with any positional parameters present Arg := First (Pragma_Argument_Associations (N)); for Index in Args'Range loop exit when No (Arg) or else Chars (Arg) /= No_Name; Args (Index) := Expression (Arg); Next (Arg); end loop; -- Positional parameters all processed, if any left, then we -- have too many positional parameters. if Present (Arg) and then Chars (Arg) = No_Name then Error_Pragma_Arg ("too many positional associations for pragma%", Arg); end if; -- Process named parameters if any are present while Present (Arg) loop if Chars (Arg) = No_Name then Error_Pragma_Arg ("positional association cannot follow named association", Arg); else for Index in Names'Range loop if Names (Index) = Chars (Arg) then if Present (Args (Index)) then Error_Pragma_Arg ("duplicate argument association for pragma%", Arg); else Args (Index) := Expression (Arg); exit; end if; end if; if Index = Names'Last then Error_Pragma_Arg_Ident ("pragma% does not allow & argument", Arg); end if; end loop; end if; Next (Arg); end loop; end Gather_Associations; -------------------- -- Get_Pragma_Arg -- -------------------- function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is begin if Nkind (Arg) = N_Pragma_Argument_Association then return Expression (Arg); else return Arg; end if; end Get_Pragma_Arg; ----------------- -- GNAT_Pragma -- ----------------- procedure GNAT_Pragma is begin Check_Restriction (No_Implementation_Pragmas, N); end GNAT_Pragma; -------------------------- -- Is_Before_First_Decl -- -------------------------- function Is_Before_First_Decl (Pragma_Node : Node_Id; Decls : List_Id) return Boolean is Item : Node_Id := First (Decls); begin -- Only other pragmas can come before this pragma loop if No (Item) or else Nkind (Item) /= N_Pragma then return False; elsif Item = Pragma_Node then return True; end if; Next (Item); end loop; end Is_Before_First_Decl; ----------------------------- -- Is_Configuration_Pragma -- ----------------------------- -- A configuration pragma must appear in the context clause of -- a compilation unit, at the start of the list (i.e. only other -- pragmas may precede it). function Is_Configuration_Pragma return Boolean is Lis : constant List_Id := List_Containing (N); Par : constant Node_Id := Parent (N); Prg : Node_Id; begin -- If no parent, then we are in the configuration pragma file, -- so the placement is definitely appropriate. if No (Par) then return True; -- Otherwise we must be in the context clause of a compilation unit -- and the only thing allowed before us in the context list is more -- configuration pragmas. elsif Nkind (Par) = N_Compilation_Unit and then Context_Items (Par) = Lis then Prg := First (Lis); loop if Prg = N then return True; elsif Nkind (Prg) /= N_Pragma then return False; end if; Next (Prg); end loop; else return False; end if; end Is_Configuration_Pragma; ---------------------- -- Pragma_Misplaced -- ---------------------- procedure Pragma_Misplaced is begin Error_Pragma ("incorrect placement of pragma%"); end Pragma_Misplaced; ------------------------------------ -- Process Atomic_Shared_Volatile -- ------------------------------------ procedure Process_Atomic_Shared_Volatile is E_Id : Node_Id; E : Entity_Id; D : Node_Id; K : Node_Kind; begin GNAT_Pragma; Check_Ada_83_Warning; Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); E_Id := Expression (Arg1); if Etype (E_Id) = Any_Type then return; end if; E := Entity (E_Id); D := Declaration_Node (E); K := Nkind (D); if Is_Type (E) then if Rep_Item_Too_Early (E, N) or else Rep_Item_Too_Late (E, N) then return; else Check_First_Subtype (Arg1); end if; if Prag_Id /= Pragma_Volatile then Set_Is_Atomic (E); Set_Is_Atomic (Underlying_Type (E)); end if; Set_Is_Volatile (E); Set_Is_Volatile (Underlying_Type (E)); elsif K = N_Object_Declaration or else (K = N_Component_Declaration and then Original_Record_Component (E) = E) then if Rep_Item_Too_Late (E, N) then return; end if; if Prag_Id /= Pragma_Volatile then Set_Is_Atomic (E); end if; Set_Is_Volatile (E); else Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1); end if; end Process_Atomic_Shared_Volatile; ------------------------ -- Process_Convention -- ------------------------ procedure Process_Convention (C : out Convention_Id; E : out Entity_Id) is Id : Node_Id; E1 : Entity_Id; Comp_Unit : Unit_Number_Type; Cname : Name_Id; procedure Set_Convention_From_Pragma (E : Entity_Id); -- Set convention in entity E, and also flag that the entity has a -- convention pragma. If entity is for a private or incomplete type, -- also set convention and flag on underlying type. This procedure -- also deals with the special case of C_Pass_By_Copy convention. -------------------------------- -- Set_Convention_From_Pragma -- -------------------------------- procedure Set_Convention_From_Pragma (E : Entity_Id) is begin Set_Convention (E, C); Set_Has_Convention_Pragma (E); if Is_Incomplete_Or_Private_Type (E) then Set_Convention (Underlying_Type (E), C); Set_Has_Convention_Pragma (Underlying_Type (E), True); end if; -- A class-wide type should inherit the convention of -- the specific root type (although this isn't specified -- clearly by the RM). if Is_Type (E) and then Present (Class_Wide_Type (E)) then Set_Convention (Class_Wide_Type (E), C); end if; -- If the entity is a record type, then check for special case -- of C_Pass_By_Copy, which is treated the same as C except that -- the special record flag is set. This convention is also only -- permitted on record types (see AI95-00131). if Cname = Name_C_Pass_By_Copy then if Is_Record_Type (E) then Set_C_Pass_By_Copy (Base_Type (E)); elsif Is_Incomplete_Or_Private_Type (E) and then Is_Record_Type (Underlying_Type (E)) then Set_C_Pass_By_Copy (Base_Type (Underlying_Type (E))); else Error_Pragma_Arg ("C_Pass_By_Copy convention allowed only for record type", Arg2); end if; end if; -- If the entity is a derived boolean type, check for the -- special case of convention C, C++, or Fortran, where we -- consider any nonzero value to represent true. if Is_Discrete_Type (E) and then Root_Type (Etype (E)) = Standard_Boolean and then (C = Convention_C or else C = Convention_CPP or else C = Convention_Fortran) then Set_Nonzero_Is_True (Base_Type (E)); end if; end Set_Convention_From_Pragma; -- Start of processing for Process_Convention begin Check_At_Least_N_Arguments (2); Check_Arg_Is_Identifier (Arg1); Check_Optional_Identifier (Arg1, Name_Convention); Cname := Chars (Expression (Arg1)); -- C_Pass_By_Copy is treated as a synonym for convention C -- (this is tested again below to set the critical flag) if Cname = Name_C_Pass_By_Copy then C := Convention_C; -- Otherwise we must have something in the standard convention list elsif Is_Convention_Name (Cname) then C := Get_Convention_Id (Chars (Expression (Arg1))); -- In DEC VMS, it seems that there is an undocumented feature -- that any unrecognized convention is treated as the default, -- which for us is convention C. It does not seem so terrible -- to do this unconditionally, silently in the VMS case, and -- with a warning in the non-VMS case. else if not OpenVMS_On_Target then Error_Msg_N ("?unrecognized convention name, C assumed", Expression (Arg1)); end if; C := Convention_C; end if; Check_Arg_Is_Local_Name (Arg2); Check_Optional_Identifier (Arg2, Name_Entity); Id := Expression (Arg2); Analyze (Id); if not Is_Entity_Name (Id) then Error_Pragma_Arg ("entity name required", Arg2); end if; E := Entity (Id); -- Go to renamed subprogram if present, since convention applies -- to the actual renamed entity, not to the renaming entity. if Is_Subprogram (E) and then Present (Alias (E)) and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Renaming_Declaration then E := Alias (E); end if; -- Check that we not applying this to a specless body if Is_Subprogram (E) and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body then Error_Pragma ("pragma% requires separate spec and must come before body"); end if; -- Check that we are not applying this to a named constant if Ekind (E) = E_Named_Integer or else Ekind (E) = E_Named_Real then Error_Msg_Name_1 := Chars (N); Error_Msg_N ("cannot apply pragma% to named constant!", Get_Pragma_Arg (Arg2)); Error_Pragma_Arg ("\supply appropriate type for&!", Arg2); end if; if Etype (E) = Any_Type or else Rep_Item_Too_Early (E, N) then raise Pragma_Exit; else E := Underlying_Type (E); end if; if Rep_Item_Too_Late (E, N) then raise Pragma_Exit; end if; if Has_Convention_Pragma (E) then Error_Pragma_Arg ("at most one Convention/Export/Import pragma is allowed", Arg2); elsif Convention (E) = Convention_Protected or else Ekind (Scope (E)) = E_Protected_Type then Error_Pragma_Arg ("a protected operation cannot be given a different convention", Arg2); end if; -- For Intrinsic, a subprogram is required if C = Convention_Intrinsic and then not Is_Subprogram (E) and then not Is_Generic_Subprogram (E) then Error_Pragma_Arg ("second argument of pragma% must be a subprogram", Arg2); end if; -- For Stdcall, a subprogram, variable or subprogram type is required if C = Convention_Stdcall and then not Is_Subprogram (E) and then not Is_Generic_Subprogram (E) and then Ekind (E) /= E_Variable and then not (Is_Access_Type (E) and then Ekind (Designated_Type (E)) = E_Subprogram_Type) then Error_Pragma_Arg ("second argument of pragma% must be subprogram (type)", Arg2); end if; if not Is_Subprogram (E) and then not Is_Generic_Subprogram (E) then Set_Convention_From_Pragma (E); if Is_Type (E) then Check_First_Subtype (Arg2); Set_Convention_From_Pragma (Base_Type (E)); -- For subprograms, we must set the convention on the -- internally generated directly designated type as well. if Ekind (E) = E_Access_Subprogram_Type then Set_Convention_From_Pragma (Directly_Designated_Type (E)); end if; end if; -- For the subprogram case, set proper convention for all homonyms -- in same compilation unit. -- Is the test of compilation unit really necessary ??? -- What about subprogram renamings here??? else Comp_Unit := Get_Source_Unit (E); Set_Convention_From_Pragma (E); E1 := E; loop E1 := Homonym (E1); exit when No (E1) or else Scope (E1) /= Current_Scope; -- Note: below we are missing a check for Rep_Item_Too_Late. -- That is deliberate, we cannot chain the rep item on more -- than one Rep_Item chain, to be fixed later ??? if Comp_Unit = Get_Source_Unit (E1) then Set_Convention_From_Pragma (E1); end if; end loop; end if; end Process_Convention; ----------------------------------------------------- -- Process_Extended_Import_Export_Exception_Pragma -- ----------------------------------------------------- procedure Process_Extended_Import_Export_Exception_Pragma (Arg_Internal : Node_Id; Arg_External : Node_Id; Arg_Form : Node_Id; Arg_Code : Node_Id) is Def_Id : Entity_Id; Code_Val : Uint; begin Process_Extended_Import_Export_Internal_Arg (Arg_Internal); Def_Id := Entity (Arg_Internal); if Ekind (Def_Id) /= E_Exception then Error_Pragma_Arg ("pragma% must refer to declared exception", Arg_Internal); end if; Set_Extended_Import_Export_External_Name (Def_Id, Arg_External); if Present (Arg_Form) then Check_Arg_Is_One_Of (Arg_Form, Name_Ada, Name_VMS); end if; if Present (Arg_Form) and then Chars (Arg_Form) = Name_Ada then null; else Set_Is_VMS_Exception (Def_Id); Set_Exception_Code (Def_Id, No_Uint); end if; if Present (Arg_Code) then if not Is_VMS_Exception (Def_Id) then Error_Pragma_Arg ("Code option for pragma% not allowed for Ada case", Arg_Code); end if; Check_Arg_Is_Static_Expression (Arg_Code, Any_Integer); Code_Val := Expr_Value (Arg_Code); if not UI_Is_In_Int_Range (Code_Val) then Error_Pragma_Arg ("Code option for pragma% must be in 32-bit range", Arg_Code); else Set_Exception_Code (Def_Id, Code_Val); end if; end if; end Process_Extended_Import_Export_Exception_Pragma; ------------------------------------------------- -- Process_Extended_Import_Export_Internal_Arg -- ------------------------------------------------- procedure Process_Extended_Import_Export_Internal_Arg (Arg_Internal : Node_Id := Empty) is begin GNAT_Pragma; if No (Arg_Internal) then Error_Pragma ("Internal parameter required for pragma%"); end if; if Nkind (Arg_Internal) = N_Identifier then null; elsif Nkind (Arg_Internal) = N_Operator_Symbol and then (Prag_Id = Pragma_Import_Function or else Prag_Id = Pragma_Export_Function) then null; else Error_Pragma_Arg ("wrong form for Internal parameter for pragma%", Arg_Internal); end if; Check_Arg_Is_Local_Name (Arg_Internal); end Process_Extended_Import_Export_Internal_Arg; -------------------------------------------------- -- Process_Extended_Import_Export_Object_Pragma -- -------------------------------------------------- procedure Process_Extended_Import_Export_Object_Pragma (Arg_Internal : Node_Id; Arg_External : Node_Id; Arg_Size : Node_Id) is Def_Id : Entity_Id; begin Process_Extended_Import_Export_Internal_Arg (Arg_Internal); Def_Id := Entity (Arg_Internal); if Ekind (Def_Id) /= E_Constant and then Ekind (Def_Id) /= E_Variable then Error_Pragma_Arg ("pragma% must designate an object", Arg_Internal); end if; if Is_Psected (Def_Id) then Error_Pragma_Arg ("previous Psect_Object applies, pragma % not permitted", Arg_Internal); end if; if Rep_Item_Too_Late (Def_Id, N) then raise Pragma_Exit; end if; Set_Extended_Import_Export_External_Name (Def_Id, Arg_External); if Present (Arg_Size) and then Nkind (Arg_Size) /= N_Identifier and then Nkind (Arg_Size) /= N_String_Literal then Error_Pragma_Arg ("pragma% Size argument must be identifier or string literal", Arg_Size); end if; -- Export_Object case if Prag_Id = Pragma_Export_Object then if not Is_Library_Level_Entity (Def_Id) then Error_Pragma_Arg ("argument for pragma% must be library level entity", Arg_Internal); end if; if Ekind (Current_Scope) = E_Generic_Package then Error_Pragma ("pragma& cannot appear in a generic unit"); end if; if not Size_Known_At_Compile_Time (Etype (Def_Id)) then Error_Pragma_Arg ("exported object must have compile time known size", Arg_Internal); end if; if Is_Exported (Def_Id) then Error_Msg_N ("?duplicate Export_Object pragma", N); else Set_Exported (Def_Id, Arg_Internal); end if; -- Import_Object case else if Is_Concurrent_Type (Etype (Def_Id)) then Error_Pragma_Arg ("cannot use pragma% for task/protected object", Arg_Internal); end if; if Ekind (Def_Id) = E_Constant then Error_Pragma_Arg ("cannot import a constant", Arg_Internal); end if; if Has_Discriminants (Etype (Def_Id)) then Error_Msg_N ("imported value must be initialized?", Arg_Internal); end if; if Is_Access_Type (Etype (Def_Id)) then Error_Pragma_Arg ("cannot import object of an access type?", Arg_Internal); end if; if Is_Imported (Def_Id) then Error_Msg_N ("?duplicate Import_Object pragma", N); else Set_Imported (Def_Id); end if; end if; end Process_Extended_Import_Export_Object_Pragma; ------------------------------------------------------ -- Process_Extended_Import_Export_Subprogram_Pragma -- ------------------------------------------------------ procedure Process_Extended_Import_Export_Subprogram_Pragma (Arg_Internal : Node_Id; Arg_External : Node_Id; Arg_Parameter_Types : Node_Id; Arg_Result_Type : Node_Id := Empty; Arg_Mechanism : Node_Id; Arg_Result_Mechanism : Node_Id := Empty; Arg_First_Optional_Parameter : Node_Id := Empty) is Ent : Entity_Id; Def_Id : Entity_Id; Hom_Id : Entity_Id; Formal : Entity_Id; Ambiguous : Boolean; Match : Boolean; Dval : Node_Id; function Same_Base_Type (Ptype, Formal : Entity_Id) return Boolean; -- Determines if Ptype references the type of Formal. Note that -- only the base types need to match according to the spec. function Same_Base_Type (Ptype, Formal : Entity_Id) return Boolean is begin Find_Type (Ptype); if not Is_Entity_Name (Ptype) or else Entity (Ptype) = Any_Type then raise Pragma_Exit; end if; return Base_Type (Entity (Ptype)) = Base_Type (Etype (Formal)); end Same_Base_Type; -- Start of processing for -- Process_Extended_Import_Export_Subprogram_Pragma begin Process_Extended_Import_Export_Internal_Arg (Arg_Internal); Hom_Id := Entity (Arg_Internal); Ent := Empty; Ambiguous := False; -- Loop through homonyms (overloadings) of Hom_Id while Present (Hom_Id) loop Def_Id := Get_Base_Subprogram (Hom_Id); -- We need a subprogram in the current scope if not Is_Subprogram (Def_Id) or else Scope (Def_Id) /= Current_Scope then null; else Match := True; -- Pragma cannot apply to subprogram body if Is_Subprogram (Def_Id) and then Nkind (Parent (Declaration_Node (Def_Id))) = N_Subprogram_Body then Error_Pragma ("pragma% requires separate spec" & " and must come before body"); end if; -- Test result type if given, note that the result type -- parameter can only be present for the function cases. if Present (Arg_Result_Type) and then not Same_Base_Type (Arg_Result_Type, Def_Id) then Match := False; -- Test parameter types if given. Note that this parameter -- has not been analyzed (and must not be, since it is -- semantic nonsense), so we get it as the parser left it. elsif Present (Arg_Parameter_Types) then Check_Matching_Types : declare Formal : Entity_Id; Ptype : Node_Id; begin Formal := First_Formal (Def_Id); if Nkind (Arg_Parameter_Types) = N_Null then if Present (Formal) then Match := False; end if; -- A list of one type, e.g. (List) is parsed as -- a parenthesized expression. elsif Nkind (Arg_Parameter_Types) /= N_Aggregate and then Paren_Count (Arg_Parameter_Types) = 1 then if No (Formal) or else Present (Next_Formal (Formal)) then Match := False; else Match := Same_Base_Type (Arg_Parameter_Types, Formal); end if; -- A list of more than one type is parsed as a aggregate elsif Nkind (Arg_Parameter_Types) = N_Aggregate and then Paren_Count (Arg_Parameter_Types) = 0 then Ptype := First (Expressions (Arg_Parameter_Types)); while Present (Ptype) or else Present (Formal) loop if No (Ptype) or else No (Formal) or else not Same_Base_Type (Ptype, Formal) then Match := False; exit; else Next_Formal (Formal); Next (Ptype); end if; end loop; -- Anything else is of the wrong form else Error_Pragma_Arg ("wrong form for Parameter_Types parameter", Arg_Parameter_Types); end if; end Check_Matching_Types; end if; -- Match is now False if the entry we found did not match -- either a supplied Parameter_Types or Result_Types argument if Match then if No (Ent) then Ent := Def_Id; -- Ambiguous case, the flag Ambiguous shows if we already -- detected this and output the initial messages. else if not Ambiguous then Ambiguous := True; Error_Msg_Name_1 := Chars (N); Error_Msg_N ("pragma% does not uniquely identify subprogram!", N); Error_Msg_Sloc := Sloc (Ent); Error_Msg_N ("matching subprogram #!", N); Ent := Empty; end if; Error_Msg_Sloc := Sloc (Def_Id); Error_Msg_N ("matching subprogram #!", N); end if; end if; end if; Hom_Id := Homonym (Hom_Id); end loop; -- See if we found an entry if No (Ent) then if not Ambiguous then if Is_Generic_Subprogram (Entity (Arg_Internal)) then Error_Pragma ("pragma% cannot be given for generic subprogram"); else Error_Pragma ("pragma% does not identify local subprogram"); end if; end if; return; end if; -- Import pragmas must be be for imported entities if (Prag_Id = Pragma_Import_Function or else Prag_Id = Pragma_Import_Procedure or else Prag_Id = Pragma_Import_Valued_Procedure) then if not Is_Imported (Ent) then Error_Pragma ("pragma Import or Interface must precede pragma%"); end if; -- For the Export cases, the pragma Export is sufficient to set -- the entity as exported, if it is not exported already. We -- leave the default Ada convention in this case. else Set_Exported (Ent, Arg_Internal); end if; -- Special processing for Valued_Procedure cases if Prag_Id = Pragma_Import_Valued_Procedure or else Prag_Id = Pragma_Export_Valued_Procedure then Formal := First_Formal (Ent); if No (Formal) then Error_Pragma ("at least one parameter required for pragma%"); elsif Ekind (Formal) /= E_Out_Parameter then Error_Pragma ("first parameter must have mode out for pragma%"); else Set_Is_Valued_Procedure (Ent); end if; end if; Set_Extended_Import_Export_External_Name (Ent, Arg_External); -- Process Result_Mechanism argument if present. We have already -- checked that this is only allowed for the function case. if Present (Arg_Result_Mechanism) then Set_Mechanism_Value (Ent, Arg_Result_Mechanism); end if; -- Process Mechanism parameter if present. Note that this parameter -- is not analyzed, and must not be analyzed since it is semantic -- nonsense, so we get it in exactly as the parser left it. if Present (Arg_Mechanism) then declare Formal : Entity_Id; Massoc : Node_Id; Mname : Node_Id; Choice : Node_Id; begin -- A single mechanism association without a formal parameter -- name is parsed as a parenthesized expression. All other -- cases are parsed as aggregates, so we rewrite the single -- parameter case as an aggregate for consistency. if Nkind (Arg_Mechanism) /= N_Aggregate and then Paren_Count (Arg_Mechanism) = 1 then Rewrite (Arg_Mechanism, Make_Aggregate (Sloc (Arg_Mechanism), Expressions => New_List ( Relocate_Node (Arg_Mechanism)))); end if; -- Case of only mechanism name given, applies to all formals if Nkind (Arg_Mechanism) /= N_Aggregate then Formal := First_Formal (Ent); while Present (Formal) loop Set_Mechanism_Value (Formal, Arg_Mechanism); Next_Formal (Formal); end loop; -- Case of list of mechanism associations given else if Null_Record_Present (Arg_Mechanism) then Error_Pragma_Arg ("inappropriate form for Mechanism parameter", Arg_Mechanism); end if; -- Deal with positional ones first Formal := First_Formal (Ent); if Present (Expressions (Arg_Mechanism)) then Mname := First (Expressions (Arg_Mechanism)); while Present (Mname) loop if No (Formal) then Error_Pragma_Arg ("too many mechanism associations", Mname); end if; Set_Mechanism_Value (Formal, Mname); Next_Formal (Formal); Next (Mname); end loop; end if; -- Deal with named entries if Present (Component_Associations (Arg_Mechanism)) then Massoc := First (Component_Associations (Arg_Mechanism)); while Present (Massoc) loop Choice := First (Choices (Massoc)); if Nkind (Choice) /= N_Identifier or else Present (Next (Choice)) then Error_Pragma_Arg ("incorrect form for mechanism association", Massoc); end if; Formal := First_Formal (Ent); loop if No (Formal) then Error_Pragma_Arg ("parameter name & not present", Choice); end if; if Chars (Choice) = Chars (Formal) then Set_Mechanism_Value (Formal, Expression (Massoc)); exit; end if; Next_Formal (Formal); end loop; Next (Massoc); end loop; end if; end if; end; end if; -- Process First_Optional_Parameter argument if present. We have -- already checked that this is only allowed for the Import case. if Present (Arg_First_Optional_Parameter) then if Nkind (Arg_First_Optional_Parameter) /= N_Identifier then Error_Pragma_Arg ("first optional parameter must be formal parameter name", Arg_First_Optional_Parameter); end if; Formal := First_Formal (Ent); loop if No (Formal) then Error_Pragma_Arg ("specified formal parameter& not found", Arg_First_Optional_Parameter); end if; exit when Chars (Formal) = Chars (Arg_First_Optional_Parameter); Next_Formal (Formal); end loop; Set_First_Optional_Parameter (Ent, Formal); -- Check specified and all remaining formals have right form while Present (Formal) loop if Ekind (Formal) /= E_In_Parameter then Error_Msg_NE ("optional formal& is not of mode in!", Arg_First_Optional_Parameter, Formal); else Dval := Default_Value (Formal); if not Present (Dval) then Error_Msg_NE ("optional formal& does not have default value!", Arg_First_Optional_Parameter, Formal); elsif Compile_Time_Known_Value_Or_Aggr (Dval) then null; else Error_Msg_NE ("default value for optional formal& is non-static!", Arg_First_Optional_Parameter, Formal); end if; end if; Set_Is_Optional_Parameter (Formal); Next_Formal (Formal); end loop; end if; end Process_Extended_Import_Export_Subprogram_Pragma; -------------------------- -- Process_Generic_List -- -------------------------- procedure Process_Generic_List is Arg : Node_Id; Exp : Node_Id; begin GNAT_Pragma; Check_No_Identifiers; Check_At_Least_N_Arguments (1); Arg := Arg1; while Present (Arg) loop Exp := Expression (Arg); Analyze (Exp); if not Is_Entity_Name (Exp) or else (not Is_Generic_Instance (Entity (Exp)) and then not Is_Generic_Unit (Entity (Exp))) then Error_Pragma_Arg ("pragma% argument must be name of generic unit/instance", Arg); end if; Next (Arg); end loop; end Process_Generic_List; --------------------------------- -- Process_Import_Or_Interface -- --------------------------------- procedure Process_Import_Or_Interface is C : Convention_Id; Def_Id : Entity_Id; Hom_Id : Entity_Id; begin Process_Convention (C, Def_Id); Kill_Size_Check_Code (Def_Id); Note_Possible_Modification (Expression (Arg2)); if Ekind (Def_Id) = E_Variable or else Ekind (Def_Id) = E_Constant then -- User initialization is not allowed for imported object, but -- the object declaration may contain a default initialization, -- that will be discarded. if Present (Expression (Parent (Def_Id))) and then Comes_From_Source (Expression (Parent (Def_Id))) then Error_Msg_Sloc := Sloc (Def_Id); Error_Pragma_Arg ("no initialization allowed for declaration of& #", "\imported entities cannot be initialized ('R'M' 'B.1(24))", Arg2); else Set_Imported (Def_Id); Set_Is_Public (Def_Id); Process_Interface_Name (Def_Id, Arg3, Arg4); end if; elsif Is_Subprogram (Def_Id) or else Is_Generic_Subprogram (Def_Id) then -- If the name is overloaded, pragma applies to all of the -- denoted entities in the same declarative part. Hom_Id := Def_Id; while Present (Hom_Id) loop Def_Id := Get_Base_Subprogram (Hom_Id); -- Ignore inherited subprograms because the pragma will -- apply to the parent operation, which is the one called. if Is_Overloadable (Def_Id) and then Present (Alias (Def_Id)) then null; -- Verify that the homonym is in the same declarative -- part (not just the same scope). elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N) and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux then exit; else Set_Imported (Def_Id); -- If Import intrinsic, set intrinsic flag -- and verify that it is known as such. if C = Convention_Intrinsic then Set_Is_Intrinsic_Subprogram (Def_Id); Check_Intrinsic_Subprogram (Def_Id, Expression (Arg2)); end if; -- All interfaced procedures need an external -- symbol created for them since they are -- always referenced from another object file. Set_Is_Public (Def_Id); Set_Has_Completion (Def_Id); Process_Interface_Name (Def_Id, Arg3, Arg4); end if; if Is_Compilation_Unit (Hom_Id) then -- Its possible homonyms are not affected by the pragma. -- Such homonyms might be present in the context of other -- units being compiled. exit; else Hom_Id := Homonym (Hom_Id); end if; end loop; -- When the convention is Java, we also allow Import to be given -- for packages, exceptions, and record components. elsif C = Convention_Java and then (Ekind (Def_Id) = E_Package or else Ekind (Def_Id) = E_Exception or else Nkind (Parent (Def_Id)) = N_Component_Declaration) then Set_Imported (Def_Id); Set_Is_Public (Def_Id); Process_Interface_Name (Def_Id, Arg3, Arg4); else Error_Pragma_Arg ("second argument of pragma% must be object or subprogram", Arg2); end if; -- If this pragma applies to a compilation unit, then the unit, -- which is a subprogram, does not require (or allow) a body. -- We also do not need to elaborate imported procedures. if Nkind (Parent (N)) = N_Compilation_Unit_Aux then declare Cunit : constant Node_Id := Parent (Parent (N)); begin Set_Body_Required (Cunit, False); end; end if; end Process_Import_Or_Interface; -------------------- -- Process_Inline -- -------------------- procedure Process_Inline (Active : Boolean) is Assoc : Node_Id; Decl : Node_Id; Subp_Id : Node_Id; Subp : Entity_Id; Applies : Boolean; procedure Make_Inline (Subp : Entity_Id); -- Subp is the defining unit name of the subprogram -- declaration. Set the flag, as well as the flag in the -- corresponding body, if there is one present. procedure Set_Inline_Flags (Subp : Entity_Id); -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp ----------------- -- Make_Inline -- ----------------- procedure Make_Inline (Subp : Entity_Id) is Kind : Entity_Kind := Ekind (Subp); Inner_Subp : Entity_Id := Subp; begin if Etype (Subp) = Any_Type then return; -- Here we have a candidate for inlining, but we must exclude -- derived operations. Otherwise we will end up trying to -- inline a phantom declaration, and the result would be to -- drag in a body which has no direct inlining associated with -- it. That would not only be inefficient but would also result -- in the backend doing cross-unit inlining in cases where it -- was definitely inappropriate to do so. -- However, a simple Comes_From_Source test is insufficient, -- since we do want to allow inlining of generic instances, -- which also do not come from source. Predefined operators do -- not come from source but are not inlineable either. elsif not Comes_From_Source (Subp) and then not Is_Generic_Instance (Subp) and then Scope (Subp) /= Standard_Standard then Applies := True; return; -- The referenced entity must either be the enclosing entity, -- or an entity declared within the current open scope. elsif Present (Scope (Subp)) and then Scope (Subp) /= Current_Scope and then Subp /= Current_Scope then Error_Pragma_Arg ("argument of% must be entity in current scope", Assoc); return; end if; -- Processing for procedure, operator or function. -- If subprogram is aliased (as for an instance) indicate -- that the renamed entity is inlined. if Kind = E_Procedure or else Kind = E_Function or else Kind = E_Operator then while Present (Alias (Inner_Subp)) loop Inner_Subp := Alias (Inner_Subp); end loop; Set_Inline_Flags (Inner_Subp); Decl := Parent (Parent (Inner_Subp)); if Nkind (Decl) = N_Subprogram_Declaration and then Present (Corresponding_Body (Decl)) then Set_Inline_Flags (Corresponding_Body (Decl)); end if; Applies := True; -- For a generic subprogram set flag as well, for use at -- the point of instantiation, to determine whether the -- body should be generated. elsif Kind = E_Generic_Procedure or else Kind = E_Generic_Function then Set_Inline_Flags (Subp); Applies := True; -- Literals are by definition inlined. elsif Kind = E_Enumeration_Literal then null; -- Anything else is an error else Error_Pragma_Arg ("expect subprogram name for pragma%", Assoc); end if; end Make_Inline; ---------------------- -- Set_Inline_Flags -- ---------------------- procedure Set_Inline_Flags (Subp : Entity_Id) is begin if Active then Set_Is_Inlined (Subp, True); end if; if not Has_Pragma_Inline (Subp) then Set_Has_Pragma_Inline (Subp); Set_Next_Rep_Item (N, First_Rep_Item (Subp)); Set_First_Rep_Item (Subp, N); end if; end Set_Inline_Flags; -- Start of processing for Process_Inline begin Check_No_Identifiers; Check_At_Least_N_Arguments (1); if Active then Inline_Processing_Required := True; end if; Assoc := Arg1; while Present (Assoc) loop Subp_Id := Expression (Assoc); Analyze (Subp_Id); Applies := False; if Is_Entity_Name (Subp_Id) then Subp := Entity (Subp_Id); if Subp = Any_Id then Applies := True; else Make_Inline (Subp); while Present (Homonym (Subp)) and then Scope (Homonym (Subp)) = Current_Scope loop Make_Inline (Homonym (Subp)); Subp := Homonym (Subp); end loop; end if; end if; if not Applies then Error_Pragma_Arg ("inappropriate argument for pragma%", Assoc); end if; Next (Assoc); end loop; end Process_Inline; ---------------------------- -- Process_Interface_Name -- ---------------------------- procedure Process_Interface_Name (Subprogram_Def : Entity_Id; Ext_Arg : Node_Id; Link_Arg : Node_Id) is Ext_Nam : Node_Id; Link_Nam : Node_Id; String_Val : String_Id; procedure Check_Form_Of_Interface_Name (SN : Node_Id); -- SN is a string literal node for an interface name. This routine -- performs some minimal checks that the name is reasonable. In -- particular that no spaces or other obviously incorrect characters -- appear. This is only a warning, since any characters are allowed. procedure Check_Form_Of_Interface_Name (SN : Node_Id) is S : constant String_Id := Strval (Expr_Value_S (SN)); SL : constant Nat := String_Length (S); C : Char_Code; begin if SL = 0 then Error_Msg_N ("interface name cannot be null string", SN); end if; for J in 1 .. SL loop C := Get_String_Char (S, J); if not In_Character_Range (C) or else Get_Character (C) = ' ' or else Get_Character (C) = ',' then Error_Msg_N ("?interface name contains illegal character", SN); end if; end loop; end Check_Form_Of_Interface_Name; -- Start of processing for Process_Interface_Name begin if No (Link_Arg) then if No (Ext_Arg) then return; elsif Chars (Ext_Arg) = Name_Link_Name then Ext_Nam := Empty; Link_Nam := Expression (Ext_Arg); else Check_Optional_Identifier (Ext_Arg, Name_External_Name); Ext_Nam := Expression (Ext_Arg); Link_Nam := Empty; end if; else Check_Optional_Identifier (Ext_Arg, Name_External_Name); Check_Optional_Identifier (Link_Arg, Name_Link_Name); Ext_Nam := Expression (Ext_Arg); Link_Nam := Expression (Link_Arg); end if; -- Check expressions for external name and link name are static if Present (Ext_Nam) then Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String); Check_Form_Of_Interface_Name (Ext_Nam); -- Verify that the external name is not the name of a local -- entity, which would hide the imported one and lead to -- run-time surprises. The problem can only arise for entities -- declared in a package body (otherwise the external name is -- fully qualified and won't conflict). declare Nam : Name_Id; E : Entity_Id; Par : Node_Id; begin if Prag_Id = Pragma_Import then String_To_Name_Buffer (Strval (Expr_Value_S (Ext_Nam))); Nam := Name_Find; E := Entity_Id (Get_Name_Table_Info (Nam)); if Nam /= Chars (Subprogram_Def) and then Present (E) and then not Is_Overloadable (E) and then Is_Immediately_Visible (E) and then not Is_Imported (E) and then Ekind (Scope (E)) = E_Package then Par := Parent (E); while Present (Par) loop if Nkind (Par) = N_Package_Body then Error_Msg_Sloc := Sloc (E); Error_Msg_NE ("imported entity is hidden by & declared#", Ext_Arg, E); exit; end if; Par := Parent (Par); end loop; end if; end if; end; end if; if Present (Link_Nam) then Check_Arg_Is_Static_Expression (Link_Nam, Standard_String); Check_Form_Of_Interface_Name (Link_Nam); end if; -- If there is no link name, just set the external name if No (Link_Nam) then Set_Encoded_Interface_Name (Get_Base_Subprogram (Subprogram_Def), Adjust_External_Name_Case (Expr_Value_S (Ext_Nam))); -- For the Link_Name case, the given literal is preceded by an -- asterisk, which indicates to GCC that the given name should -- be taken literally, and in particular that no prepending of -- underlines should occur, even in systems where this is the -- normal default. else Start_String; Store_String_Char (Get_Char_Code ('*')); String_Val := Strval (Expr_Value_S (Link_Nam)); for J in 1 .. String_Length (String_Val) loop Store_String_Char (Get_String_Char (String_Val, J)); end loop; Link_Nam := Make_String_Literal (Sloc (Link_Nam), End_String); Set_Encoded_Interface_Name (Get_Base_Subprogram (Subprogram_Def), Link_Nam); end if; end Process_Interface_Name; ----------------------------------------- -- Process_Interrupt_Or_Attach_Handler -- ----------------------------------------- procedure Process_Interrupt_Or_Attach_Handler is Arg1_X : constant Node_Id := Expression (Arg1); Prot_Proc : constant Entity_Id := Entity (Arg1_X); Prot_Type : constant Entity_Id := Scope (Prot_Proc); begin Set_Is_Interrupt_Handler (Prot_Proc); if Prag_Id = Pragma_Interrupt_Handler or Prag_Id = Pragma_Attach_Handler then Record_Rep_Item (Prot_Type, N); end if; end Process_Interrupt_Or_Attach_Handler; --------------------------------- -- Process_Suppress_Unsuppress -- --------------------------------- procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean) is C : Check_Id; E_Id : Node_Id; E : Entity_Id; Effective : Boolean; procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id); -- Used to suppress a single check on the given entity procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is begin -- First set appropriate suppress flags in the entity case C is when Access_Check => Effective := Suppress_Access_Checks (E); Set_Suppress_Access_Checks (E, Suppress_Case); when Accessibility_Check => Effective := Suppress_Accessibility_Checks (E); Set_Suppress_Accessibility_Checks (E, Suppress_Case); when Discriminant_Check => Effective := Suppress_Discriminant_Checks (E); Set_Suppress_Discriminant_Checks (E, Suppress_Case); when Division_Check => Effective := Suppress_Division_Checks (E); Set_Suppress_Division_Checks (E, Suppress_Case); when Elaboration_Check => Effective := Suppress_Elaboration_Checks (E); Set_Suppress_Elaboration_Checks (E, Suppress_Case); when Index_Check => Effective := Suppress_Index_Checks (E); Set_Suppress_Index_Checks (E, Suppress_Case); when Length_Check => Effective := Suppress_Length_Checks (E); Set_Suppress_Length_Checks (E, Suppress_Case); when Overflow_Check => Effective := Suppress_Overflow_Checks (E); Set_Suppress_Overflow_Checks (E, Suppress_Case); when Range_Check => Effective := Suppress_Range_Checks (E); Set_Suppress_Range_Checks (E, Suppress_Case); when Storage_Check => Effective := Suppress_Storage_Checks (E); Set_Suppress_Storage_Checks (E, Suppress_Case); when Tag_Check => Effective := Suppress_Tag_Checks (E); Set_Suppress_Tag_Checks (E, Suppress_Case); when All_Checks => Suppress_Unsuppress_Echeck (E, Access_Check); Suppress_Unsuppress_Echeck (E, Accessibility_Check); Suppress_Unsuppress_Echeck (E, Discriminant_Check); Suppress_Unsuppress_Echeck (E, Division_Check); Suppress_Unsuppress_Echeck (E, Elaboration_Check); Suppress_Unsuppress_Echeck (E, Index_Check); Suppress_Unsuppress_Echeck (E, Length_Check); Suppress_Unsuppress_Echeck (E, Overflow_Check); Suppress_Unsuppress_Echeck (E, Range_Check); Suppress_Unsuppress_Echeck (E, Storage_Check); Suppress_Unsuppress_Echeck (E, Tag_Check); end case; -- If the entity is not declared in the current scope, then we -- make an entry in the Entity_Suppress table so that the flag -- will be removed on exit. This entry is only made if the -- suppress did something (i.e. the flag was not already set). if Effective and then Scope (E) /= Current_Scope then Entity_Suppress.Increment_Last; Entity_Suppress.Table (Entity_Suppress.Last).Entity := E; Entity_Suppress.Table (Entity_Suppress.Last).Check := C; end if; -- If this is a first subtype, and the base type is distinct, -- then also set the suppress flags on the base type. if Is_First_Subtype (E) and then Etype (E) /= E then Suppress_Unsuppress_Echeck (Etype (E), C); end if; end Suppress_Unsuppress_Echeck; -- Start of processing for Process_Suppress_Unsuppress begin -- Suppress/Unsuppress can appear as a configuration pragma, -- or in a declarative part or a package spec (RM 11.5(5)) if not Is_Configuration_Pragma then Check_Is_In_Decl_Part_Or_Package_Spec; end if; Check_At_Least_N_Arguments (1); Check_At_Most_N_Arguments (2); Check_No_Identifier (Arg1); Check_Arg_Is_Identifier (Arg1); if not Is_Check_Name (Chars (Expression (Arg1))) then Error_Pragma_Arg ("argument of pragma% is not valid check name", Arg1); else C := Get_Check_Id (Chars (Expression (Arg1))); end if; if Arg_Count = 1 then case C is when Access_Check => Scope_Suppress.Access_Checks := Suppress_Case; when Accessibility_Check => Scope_Suppress.Accessibility_Checks := Suppress_Case; when Discriminant_Check => Scope_Suppress.Discriminant_Checks := Suppress_Case; when Division_Check => Scope_Suppress.Division_Checks := Suppress_Case; when Elaboration_Check => Scope_Suppress.Elaboration_Checks := Suppress_Case; when Index_Check => Scope_Suppress.Index_Checks := Suppress_Case; when Length_Check => Scope_Suppress.Length_Checks := Suppress_Case; when Overflow_Check => Scope_Suppress.Overflow_Checks := Suppress_Case; when Range_Check => Scope_Suppress.Range_Checks := Suppress_Case; when Storage_Check => Scope_Suppress.Storage_Checks := Suppress_Case; when Tag_Check => Scope_Suppress.Tag_Checks := Suppress_Case; when All_Checks => Scope_Suppress := (others => Suppress_Case); end case; -- Case of two arguments present, where the check is -- suppressed for a specified entity (given as the second -- argument of the pragma) else Check_Optional_Identifier (Arg2, Name_On); E_Id := Expression (Arg2); Analyze (E_Id); if not Is_Entity_Name (E_Id) then Error_Pragma_Arg ("second argument of pragma% must be entity name", Arg2); end if; E := Entity (E_Id); if E = Any_Id then return; else loop Suppress_Unsuppress_Echeck (E, C); if Is_Generic_Instance (E) and then Is_Subprogram (E) and then Present (Alias (E)) then Suppress_Unsuppress_Echeck (Alias (E), C); end if; if C = Elaboration_Check and then Suppress_Case then Set_Suppress_Elaboration_Warnings (E); end if; -- If we are within a package specification, the -- pragma only applies to homonyms in the same scope. exit when No (Homonym (E)) or else (Scope (Homonym (E)) /= Current_Scope and then Ekind (Current_Scope) = E_Package and then not In_Package_Body (Current_Scope)); E := Homonym (E); end loop; end if; end if; end Process_Suppress_Unsuppress; ------------------ -- Set_Exported -- ------------------ procedure Set_Exported (E : Entity_Id; Arg : Node_Id) is begin if Is_Imported (E) then Error_Pragma_Arg ("cannot export entity& that was previously imported", Arg); elsif Present (Address_Clause (E)) then Error_Pragma_Arg ("cannot export entity& that has an address clause", Arg); end if; Set_Is_Exported (E); -- Deal with exporting non-library level entity if not Is_Library_Level_Entity (E) then -- Not allowed at all for subprograms if Is_Subprogram (E) then Error_Pragma_Arg ("local subprogram& cannot be exported", Arg); -- Otherwise set public and statically allocated else Set_Is_Public (E); Set_Is_Statically_Allocated (E); end if; end if; if Inside_A_Generic then Error_Msg_NE ("all instances of& will have the same external name?", Arg, E); end if; end Set_Exported; ---------------------------------------------- -- Set_Extended_Import_Export_External_Name -- ---------------------------------------------- procedure Set_Extended_Import_Export_External_Name (Internal_Ent : Entity_Id; Arg_External : Node_Id) is Old_Name : constant Node_Id := Interface_Name (Internal_Ent); New_Name : Node_Id; begin if No (Arg_External) then return; elsif Nkind (Arg_External) = N_String_Literal then if String_Length (Strval (Arg_External)) = 0 then return; else New_Name := Adjust_External_Name_Case (Arg_External); end if; elsif Nkind (Arg_External) = N_Identifier then New_Name := Get_Default_External_Name (Arg_External); else Error_Pragma_Arg ("incorrect form for External parameter for pragma%", Arg_External); end if; -- If we already have an external name set (by a prior normal -- Import or Export pragma), then the external names must match if Present (Interface_Name (Internal_Ent)) then declare S1 : constant String_Id := Strval (Old_Name); S2 : constant String_Id := Strval (New_Name); procedure Mismatch; -- Called if names do not match procedure Mismatch is begin Error_Msg_Sloc := Sloc (Old_Name); Error_Pragma_Arg ("external name does not match that given #", Arg_External); end Mismatch; begin if String_Length (S1) /= String_Length (S2) then Mismatch; else for J in 1 .. String_Length (S1) loop if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then Mismatch; end if; end loop; end if; end; -- Otherwise set the given name else Set_Encoded_Interface_Name (Internal_Ent, New_Name); end if; end Set_Extended_Import_Export_External_Name; ------------------ -- Set_Imported -- ------------------ procedure Set_Imported (E : Entity_Id) is begin Error_Msg_Sloc := Sloc (E); if Is_Exported (E) or else Is_Imported (E) then Error_Msg_NE ("import of& declared# not allowed", N, E); if Is_Exported (E) then Error_Msg_N ("\entity was previously exported", N); else Error_Msg_N ("\entity was previously imported", N); end if; Error_Pragma ("\(pragma% applies to all previous entities)"); else Set_Is_Imported (E); -- If the entity is an object that is not at the library -- level, then it is statically allocated. We do not worry -- about objects with address clauses in this context since -- they are not really imported in the linker sense. if Is_Object (E) and then not Is_Library_Level_Entity (E) and then No (Address_Clause (E)) then Set_Is_Statically_Allocated (E); end if; end if; end Set_Imported; ------------------------- -- Set_Mechanism_Value -- ------------------------- -- Note: the mechanism name has not been analyzed (and cannot indeed -- be analyzed, since it is semantic nonsense), so we get it in the -- exact form created by the parser. procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is Class : Node_Id; Param : Node_Id; procedure Bad_Class; -- Signal bad descriptor class name procedure Bad_Mechanism; -- Signal bad mechanism name procedure Bad_Class is begin Error_Pragma_Arg ("unrecognized descriptor class name", Class); end Bad_Class; procedure Bad_Mechanism is begin Error_Pragma_Arg ("unrecognized mechanism name", Mech_Name); end Bad_Mechanism; -- Start of processing for Set_Mechanism_Value begin if Mechanism (Ent) /= Default_Mechanism then Error_Msg_NE ("mechanism for & has already been set", Mech_Name, Ent); end if; -- MECHANISM_NAME ::= value | reference | descriptor if Nkind (Mech_Name) = N_Identifier then if Chars (Mech_Name) = Name_Value then Set_Mechanism (Ent, By_Copy); return; elsif Chars (Mech_Name) = Name_Reference then Set_Mechanism (Ent, By_Reference); return; elsif Chars (Mech_Name) = Name_Descriptor then Check_VMS (Mech_Name); Set_Mechanism (Ent, By_Descriptor); return; elsif Chars (Mech_Name) = Name_Copy then Error_Pragma_Arg ("bad mechanism name, Value assumed", Mech_Name); else Bad_Mechanism; end if; -- MECHANISM_NAME ::= descriptor (CLASS_NAME) -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca -- Note: this form is parsed as an indexed component elsif Nkind (Mech_Name) = N_Indexed_Component then Class := First (Expressions (Mech_Name)); if Nkind (Prefix (Mech_Name)) /= N_Identifier or else Chars (Prefix (Mech_Name)) /= Name_Descriptor or else Present (Next (Class)) then Bad_Mechanism; end if; -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME) -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca -- Note: this form is parsed as a function call elsif Nkind (Mech_Name) = N_Function_Call then Param := First (Parameter_Associations (Mech_Name)); if Nkind (Name (Mech_Name)) /= N_Identifier or else Chars (Name (Mech_Name)) /= Name_Descriptor or else Present (Next (Param)) or else No (Selector_Name (Param)) or else Chars (Selector_Name (Param)) /= Name_Class then Bad_Mechanism; else Class := Explicit_Actual_Parameter (Param); end if; else Bad_Mechanism; end if; -- Fall through here with Class set to descriptor class name Check_VMS (Mech_Name); if Nkind (Class) /= N_Identifier then Bad_Class; elsif Chars (Class) = Name_UBS then Set_Mechanism (Ent, By_Descriptor_UBS); elsif Chars (Class) = Name_UBSB then Set_Mechanism (Ent, By_Descriptor_UBSB); elsif Chars (Class) = Name_UBA then Set_Mechanism (Ent, By_Descriptor_UBA); elsif Chars (Class) = Name_S then Set_Mechanism (Ent, By_Descriptor_S); elsif Chars (Class) = Name_SB then Set_Mechanism (Ent, By_Descriptor_SB); elsif Chars (Class) = Name_A then Set_Mechanism (Ent, By_Descriptor_A); elsif Chars (Class) = Name_NCA then Set_Mechanism (Ent, By_Descriptor_NCA); else Bad_Class; end if; end Set_Mechanism_Value; -- Start of processing for Analyze_Pragma begin if not Is_Pragma_Name (Chars (N)) then Error_Pragma ("unrecognized pragma%!?"); else Prag_Id := Get_Pragma_Id (Chars (N)); end if; -- Preset arguments Arg1 := Empty; Arg2 := Empty; Arg3 := Empty; Arg4 := Empty; if Present (Pragma_Argument_Associations (N)) then Arg1 := First (Pragma_Argument_Associations (N)); if Present (Arg1) then Arg2 := Next (Arg1); if Present (Arg2) then Arg3 := Next (Arg2); if Present (Arg3) then Arg4 := Next (Arg3); end if; end if; end if; end if; -- Count number of arguments declare Arg_Node : Node_Id; begin Arg_Count := 0; Arg_Node := Arg1; while Present (Arg_Node) loop Arg_Count := Arg_Count + 1; Next (Arg_Node); end loop; end; -- An enumeration type defines the pragmas that are supported by the -- implementation. Get_Pragma_Id (in package Prag) transorms a name -- into the corresponding enumeration value for the following case. case Prag_Id is ----------------- -- Abort_Defer -- ----------------- -- pragma Abort_Defer; when Pragma_Abort_Defer => GNAT_Pragma; Check_Arg_Count (0); -- The only required semantic processing is to check the -- placement. This pragma must appear at the start of the -- statement sequence of a handled sequence of statements. if Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements or else N /= First (Statements (Parent (N))) then Pragma_Misplaced; end if; ------------ -- Ada_83 -- ------------ -- pragma Ada_83; -- Note: this pragma also has some specific processing in Par.Prag -- because we want to set the Ada 83 mode switch during parsing. when Pragma_Ada_83 => GNAT_Pragma; Ada_83 := True; Ada_95 := False; Check_Arg_Count (0); ------------ -- Ada_95 -- ------------ -- pragma Ada_95; -- Note: this pragma also has some specific processing in Par.Prag -- because we want to set the Ada 83 mode switch during parsing. when Pragma_Ada_95 => GNAT_Pragma; Ada_83 := False; Ada_95 := True; Check_Arg_Count (0); ---------------------- -- All_Calls_Remote -- ---------------------- -- pragma All_Calls_Remote [(library_package_NAME)]; when Pragma_All_Calls_Remote => All_Calls_Remote : declare Lib_Entity : Entity_Id; begin Check_Ada_83_Warning; Check_Valid_Library_Unit_Pragma; if Nkind (N) = N_Null_Statement then return; end if; Lib_Entity := Find_Lib_Unit_Name; -- This pragma should only apply to a RCI unit (RM E.2.3(23)). if Present (Lib_Entity) and then not Debug_Flag_U then if not Is_Remote_Call_Interface (Lib_Entity) then Error_Pragma ("pragma% only apply to rci unit"); -- Set flag for entity of the library unit else Set_Has_All_Calls_Remote (Lib_Entity); end if; end if; end All_Calls_Remote; -------------- -- Annotate -- -------------- -- pragma Annotate (IDENTIFIER {, ARG}); -- ARG ::= NAME | EXPRESSION when Pragma_Annotate => Annotate : begin GNAT_Pragma; Check_At_Least_N_Arguments (1); Check_Arg_Is_Identifier (Arg1); declare Arg : Node_Id := Arg2; Exp : Node_Id; begin while Present (Arg) loop Exp := Expression (Arg); Analyze (Exp); if Is_Entity_Name (Exp) then null; elsif Nkind (Exp) = N_String_Literal then Resolve (Exp, Standard_String); elsif Is_Overloaded (Exp) then Error_Pragma_Arg ("ambiguous argument for pragma%", Exp); else Resolve (Exp, Etype (Exp)); end if; Next (Arg); end loop; end; end Annotate; ------------ -- Assert -- ------------ -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]); when Pragma_Assert => GNAT_Pragma; Check_No_Identifiers; if Arg_Count > 1 then Check_Arg_Count (2); Check_Arg_Is_Static_Expression (Arg2, Standard_String); end if; -- If expansion is active and assertions are inactive, then -- we rewrite the Assertion as: -- if False and then condition then -- null; -- end if; -- The reason we do this rewriting during semantic analysis -- rather than as part of normal expansion is that we cannot -- analyze and expand the code for the boolean expression -- directly, or it may cause insertion of actions that would -- escape the attempt to suppress the assertion code. if Expander_Active and not Assertions_Enabled then Rewrite (N, Make_If_Statement (Loc, Condition => Make_And_Then (Loc, Left_Opnd => New_Occurrence_Of (Standard_False, Loc), Right_Opnd => Get_Pragma_Arg (Arg1)), Then_Statements => New_List ( Make_Null_Statement (Loc)))); Analyze (N); -- Otherwise (if assertions are enabled, or if we are not -- operating with expansion active), then we just analyze -- and resolve the expression. else Analyze_And_Resolve (Expression (Arg1), Any_Boolean); end if; --------------- -- AST_Entry -- --------------- -- pragma AST_Entry (entry_IDENTIFIER); when Pragma_AST_Entry => AST_Entry : declare Ent : Node_Id; begin GNAT_Pragma; Check_VMS (N); Check_Arg_Count (1); Check_No_Identifiers; Check_Arg_Is_Local_Name (Arg1); Ent := Entity (Expression (Arg1)); -- Note: the implementation of the AST_Entry pragma could handle -- the entry family case fine, but for now we are consistent with -- the DEC rules, and do not allow the pragma, which of course -- has the effect of also forbidding the attribute. if Ekind (Ent) /= E_Entry then Error_Pragma_Arg ("pragma% argument must be simple entry name", Arg1); elsif Is_AST_Entry (Ent) then Error_Pragma_Arg ("duplicate % pragma for entry", Arg1); elsif Has_Homonym (Ent) then Error_Pragma_Arg ("pragma% argument cannot specify overloaded entry", Arg1); else declare FF : constant Entity_Id := First_Formal (Ent); begin if Present (FF) then if Present (Next_Formal (FF)) then Error_Pragma_Arg ("entry for pragma% can have only one argument", Arg1); elsif Parameter_Mode (FF) /= E_In_Parameter then Error_Pragma_Arg ("entry parameter for pragma% must have mode IN", Arg1); end if; end if; end; Set_Is_AST_Entry (Ent); end if; end AST_Entry; ------------------ -- Asynchronous -- ------------------ -- pragma Asynchronous (LOCAL_NAME); when Pragma_Asynchronous => Asynchronous : declare Nm : Entity_Id; C_Ent : Entity_Id; L : List_Id; S : Node_Id; N : Node_Id; Formal : Entity_Id; procedure Process_Async_Pragma; -- Common processing for procedure and access-to-procedure case -------------------------- -- Process_Async_Pragma -- -------------------------- procedure Process_Async_Pragma is begin if not Present (L) then Set_Is_Asynchronous (Nm); return; end if; -- The formals should be of mode IN (RM E.4.1(6)) S := First (L); while Present (S) loop Formal := Defining_Identifier (S); if Nkind (Formal) = N_Defining_Identifier and then Ekind (Formal) /= E_In_Parameter then Error_Pragma_Arg ("pragma% procedure can only have IN parameter", Arg1); end if; Next (S); end loop; Set_Is_Asynchronous (Nm); end Process_Async_Pragma; -- Start of processing for pragma Asynchronous begin Check_Ada_83_Warning; Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); if Debug_Flag_U then return; end if; C_Ent := Cunit_Entity (Current_Sem_Unit); Analyze (Expression (Arg1)); Nm := Entity (Expression (Arg1)); if not Is_Remote_Call_Interface (C_Ent) and then not Is_Remote_Types (C_Ent) then -- This pragma should only appear in an RCI or Remote Types -- unit (RM E.4.1(4)) Error_Pragma ("pragma% not in Remote_Call_Interface or " & "Remote_Types unit"); end if; if Ekind (Nm) = E_Procedure and then Nkind (Parent (Nm)) = N_Procedure_Specification then if not Is_Remote_Call_Interface (Nm) then Error_Pragma_Arg ("pragma% cannot be applied on non-remote procedure", Arg1); end if; L := Parameter_Specifications (Parent (Nm)); Process_Async_Pragma; return; elsif Ekind (Nm) = E_Function then Error_Pragma_Arg ("pragma% cannot be applied to function", Arg1); elsif Ekind (Nm) = E_Record_Type and then Present (Corresponding_Remote_Type (Nm)) then N := Declaration_Node (Corresponding_Remote_Type (Nm)); if Nkind (N) = N_Full_Type_Declaration and then Nkind (Type_Definition (N)) = N_Access_Procedure_Definition then L := Parameter_Specifications (Type_Definition (N)); Process_Async_Pragma; else Error_Pragma_Arg ("pragma% cannot reference access-to-function type", Arg1); end if; -- Only other possibility is Access-to-class-wide type elsif Is_Access_Type (Nm) and then Is_Class_Wide_Type (Designated_Type (Nm)) then Check_First_Subtype (Arg1); Set_Is_Asynchronous (Nm); if Expander_Active then RACW_Type_Is_Asynchronous (Nm); end if; else Error_Pragma_Arg ("inappropriate argument for pragma%", Arg1); end if; end Asynchronous; ------------ -- Atomic -- ------------ -- pragma Atomic (LOCAL_NAME); when Pragma_Atomic => Process_Atomic_Shared_Volatile; ----------------------- -- Atomic_Components -- ----------------------- -- pragma Atomic_Components (array_LOCAL_NAME); -- This processing is shared by Volatile_Components when Pragma_Atomic_Components | Pragma_Volatile_Components => Atomic_Components : declare E_Id : Node_Id; E : Entity_Id; D : Node_Id; K : Node_Kind; begin GNAT_Pragma; Check_Ada_83_Warning; Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); E_Id := Expression (Arg1); if Etype (E_Id) = Any_Type then return; end if; E := Entity (E_Id); if Rep_Item_Too_Early (E, N) or else Rep_Item_Too_Late (E, N) then return; end if; D := Declaration_Node (E); K := Nkind (D); if (K = N_Full_Type_Declaration and then Is_Array_Type (E)) or else ((Ekind (E) = E_Constant or else Ekind (E) = E_Variable) and then Nkind (D) = N_Object_Declaration and then Nkind (Object_Definition (D)) = N_Constrained_Array_Definition) then -- The flag is set on the object, or on the base type if Nkind (D) /= N_Object_Declaration then E := Base_Type (E); end if; Set_Has_Volatile_Components (E); if Prag_Id = Pragma_Atomic_Components then Set_Has_Atomic_Components (E); if Is_Packed (E) then Set_Is_Packed (E, False); Error_Pragma_Arg ("?Pack canceled, cannot pack atomic components", Arg1); end if; end if; else Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1); end if; end Atomic_Components; -------------------- -- Attach_Handler -- -------------------- -- pragma Attach_Handler (handler_NAME, EXPRESSION); when Pragma_Attach_Handler => Check_Ada_83_Warning; Check_No_Identifiers; Check_Arg_Count (2); Check_Interrupt_Or_Attach_Handler; Analyze_And_Resolve (Expression (Arg2), RTE (RE_Interrupt_Id)); Process_Interrupt_Or_Attach_Handler; -------------------- -- C_Pass_By_Copy -- -------------------- -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION); when Pragma_C_Pass_By_Copy => C_Pass_By_Copy : declare Arg : Node_Id; Val : Uint; begin GNAT_Pragma; Check_Valid_Configuration_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, "max_size"); Arg := Expression (Arg1); Check_Arg_Is_Static_Expression (Arg, Any_Integer); Val := Expr_Value (Arg); if Val <= 0 then Error_Pragma_Arg ("maximum size for pragma% must be positive", Arg1); elsif UI_Is_In_Int_Range (Val) then Default_C_Record_Mechanism := UI_To_Int (Val); -- If a giant value is given, Int'Last will do well enough. -- If sometime someone complains that a record larger than -- two gigabytes is not copied, we will worry about it then! else Default_C_Record_Mechanism := Mechanism_Type'Last; end if; end C_Pass_By_Copy; ------------- -- Comment -- ------------- -- pragma Comment (static_string_EXPRESSION) -- Processing for pragma Comment shares the circuitry for -- pragma Ident. The only differences are that Ident enforces -- a limit of 31 characters on its argument, and also enforces -- limitations on placement for DEC compatibility. Pragma -- Comment shares neither of these restrictions. ------------------- -- Common_Object -- ------------------- -- pragma Common_Object ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, [Size =>] EXTERNAL_SYMBOL]); -- Processing for this pragma is shared with Psect_Object ---------------------------- -- Complex_Representation -- ---------------------------- -- pragma Complex_Representation ([Entity =>] LOCAL_NAME); when Pragma_Complex_Representation => Complex_Representation : declare E_Id : Entity_Id; E : Entity_Id; Ent : Entity_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Local_Name (Arg1); E_Id := Expression (Arg1); if Etype (E_Id) = Any_Type then return; end if; E := Entity (E_Id); if not Is_Record_Type (E) then Error_Pragma_Arg ("argument for pragma% must be record type", Arg1); end if; Ent := First_Entity (E); if No (Ent) or else No (Next_Entity (Ent)) or else Present (Next_Entity (Next_Entity (Ent))) or else not Is_Floating_Point_Type (Etype (Ent)) or else Etype (Ent) /= Etype (Next_Entity (Ent)) then Error_Pragma_Arg ("record for pragma% must have two fields of same fpt type", Arg1); else Set_Has_Complex_Representation (Base_Type (E)); end if; end Complex_Representation; ------------------------- -- Component_Alignment -- ------------------------- -- pragma Component_Alignment ( -- [Form =>] ALIGNMENT_CHOICE -- [, [Name =>] type_LOCAL_NAME]); -- -- ALIGNMENT_CHOICE ::= -- Component_Size -- | Component_Size_4 -- | Storage_Unit -- | Default when Pragma_Component_Alignment => Component_AlignmentP : declare Args : Args_List (1 .. 2); Names : Name_List (1 .. 2) := ( Name_Form, Name_Name); Form : Node_Id renames Args (1); Name : Node_Id renames Args (2); Atype : Component_Alignment_Kind; Typ : Entity_Id; begin GNAT_Pragma; Gather_Associations (Names, Args); if No (Form) then Error_Pragma ("missing Form argument for pragma%"); end if; Check_Arg_Is_Identifier (Form); -- Get proper alignment, note that Default = Component_Size -- on all machines we have so far, and we want to set this -- value rather than the default value to indicate that it -- has been explicitly set (and thus will not get overridden -- by the default component alignment for the current scope) if Chars (Form) = Name_Component_Size then Atype := Calign_Component_Size; elsif Chars (Form) = Name_Component_Size_4 then Atype := Calign_Component_Size_4; elsif Chars (Form) = Name_Default then Atype := Calign_Component_Size; elsif Chars (Form) = Name_Storage_Unit then Atype := Calign_Storage_Unit; else Error_Pragma_Arg ("invalid Form parameter for pragma%", Form); end if; -- Case with no name, supplied, affects scope table entry if No (Name) then Scope_Stack.Table (Scope_Stack.Last).Component_Alignment_Default := Atype; -- Case of name supplied else Check_Arg_Is_Local_Name (Name); Find_Type (Name); Typ := Entity (Name); if Typ = Any_Type or else Rep_Item_Too_Early (Typ, N) then return; else Typ := Underlying_Type (Typ); end if; if not Is_Record_Type (Typ) and then not Is_Array_Type (Typ) then Error_Pragma_Arg ("Name parameter of pragma% must identify record or " & "array type", Name); end if; -- An explicit Component_Alignment pragma overrides an -- implicit pragma Pack, but not an explicit one. if not Has_Pragma_Pack (Base_Type (Typ)) then Set_Is_Packed (Base_Type (Typ), False); Set_Component_Alignment (Base_Type (Typ), Atype); end if; end if; end Component_AlignmentP; ---------------- -- Controlled -- ---------------- -- pragma Controlled (first_subtype_LOCAL_NAME); when Pragma_Controlled => Controlled : declare Arg : Node_Id; begin Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); Arg := Expression (Arg1); if not Is_Entity_Name (Arg) or else not Is_Access_Type (Entity (Arg)) then Error_Pragma_Arg ("pragma% requires access type", Arg1); else Set_Has_Pragma_Controlled (Base_Type (Entity (Arg))); end if; end Controlled; ---------------- -- Convention -- ---------------- -- pragma Convention ([Convention =>] convention_IDENTIFIER, -- [Entity =>] LOCAL_NAME); when Pragma_Convention => Convention : declare C : Convention_Id; E : Entity_Id; begin Check_Ada_83_Warning; Check_Arg_Count (2); Process_Convention (C, E); end Convention; --------------- -- CPP_Class -- --------------- -- pragma CPP_Class ([Entity =>] local_NAME) when Pragma_CPP_Class => CPP_Class : declare Arg : Node_Id; Typ : Entity_Id; Default_DTC : Entity_Id := Empty; VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr); C : Entity_Id; Tag_C : Entity_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Local_Name (Arg1); Arg := Expression (Arg1); Analyze (Arg); if Etype (Arg) = Any_Type then return; end if; if not Is_Entity_Name (Arg) or else not Is_Type (Entity (Arg)) then Error_Pragma_Arg ("pragma% requires a type mark", Arg1); end if; Typ := Entity (Arg); if not Is_Record_Type (Typ) then Error_Pragma_Arg ("pragma% applicable to a record, " & "tagged record or record extension", Arg1); end if; Default_DTC := First_Component (Typ); while Present (Default_DTC) and then Etype (Default_DTC) /= VTP_Type loop Next_Component (Default_DTC); end loop; -- Case of non tagged type if not Is_Tagged_Type (Typ) then Set_Is_CPP_Class (Typ); if Present (Default_DTC) then Error_Pragma_Arg ("only tagged records can contain vtable pointers", Arg1); end if; -- Case of tagged type with no vtable ptr -- What is test for Typ = Root_Typ (Typ) about here ??? elsif Is_Tagged_Type (Typ) and then Typ = Root_Type (Typ) and then No (Default_DTC) then Error_Pragma_Arg ("a cpp_class must contain a vtable pointer", Arg1); -- Tagged type that has a vtable ptr elsif Present (Default_DTC) then Set_Is_CPP_Class (Typ); Set_Is_Limited_Record (Typ); Set_Is_Tag (Default_DTC); Set_DT_Entry_Count (Default_DTC, No_Uint); -- Since a CPP type has no direct link to its associated tag -- most tags checks cannot be performed Set_Suppress_Tag_Checks (Typ); Set_Suppress_Tag_Checks (Class_Wide_Type (Typ)); -- Get rid of the _tag component when there was one. -- It is only useful for regular tagged types if Expander_Active and then Typ = Root_Type (Typ) then Tag_C := Tag_Component (Typ); C := First_Entity (Typ); if C = Tag_C then Set_First_Entity (Typ, Next_Entity (Tag_C)); else while Next_Entity (C) /= Tag_C loop Next_Entity (C); end loop; Set_Next_Entity (C, Next_Entity (Tag_C)); end if; end if; end if; end CPP_Class; --------------------- -- CPP_Constructor -- --------------------- -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME); when Pragma_CPP_Constructor => CPP_Constructor : declare Id : Entity_Id; Def_Id : Entity_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Local_Name (Arg1); Id := Expression (Arg1); Find_Program_Unit_Name (Id); -- If we did not find the name, we are done if Etype (Id) = Any_Type then return; end if; Def_Id := Entity (Id); if Ekind (Def_Id) = E_Function and then Is_Class_Wide_Type (Etype (Def_Id)) and then Is_CPP_Class (Etype (Etype (Def_Id))) then -- What the heck is this??? this pragma allows only 1 arg if Arg_Count >= 2 then Check_At_Most_N_Arguments (3); Process_Interface_Name (Def_Id, Arg2, Arg3); end if; if No (Parameter_Specifications (Parent (Def_Id))) then Set_Has_Completion (Def_Id); Set_Is_Constructor (Def_Id); else Error_Pragma_Arg ("non-default constructors not implemented", Arg1); end if; else Error_Pragma_Arg ("pragma% requires function returning a 'C'P'P_Class type", Arg1); end if; end CPP_Constructor; ----------------- -- CPP_Virtual -- ----------------- -- pragma CPP_Virtual -- [Entity =>] LOCAL_NAME -- [ [Vtable_Ptr =>] LOCAL_NAME, -- [Position =>] static_integer_EXPRESSION]); when Pragma_CPP_Virtual => CPP_Virtual : declare Arg : Node_Id; Typ : Entity_Id; Subp : Entity_Id; VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr); DTC : Entity_Id; V : Uint; begin GNAT_Pragma; if Arg_Count = 3 then Check_Optional_Identifier (Arg2, "vtable_ptr"); -- We allow Entry_Count as well as Position for the third -- parameter for back compatibility with versions of GNAT -- before version 3.12. The documentation has always said -- Position, but the code up to 3.12 said Entry_Count. if Chars (Arg3) /= Name_Position then Check_Optional_Identifier (Arg3, "entry_count"); end if; else Check_Arg_Count (1); end if; Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Local_Name (Arg1); -- First argument must be a subprogram name Arg := Expression (Arg1); Find_Program_Unit_Name (Arg); if Etype (Arg) = Any_Type then return; else Subp := Entity (Arg); end if; if not (Is_Subprogram (Subp) and then Is_Dispatching_Operation (Subp)) then Error_Pragma_Arg ("pragma% must reference a primitive operation", Arg1); end if; Typ := Find_Dispatching_Type (Subp); -- If only one Argument defaults are : -- . DTC_Entity is the default Vtable pointer -- . DT_Position will be set at the freezing point if Arg_Count = 1 then Set_DTC_Entity (Subp, Tag_Component (Typ)); return; end if; -- Second argument is a component name of type Vtable_Ptr Arg := Expression (Arg2); if Nkind (Arg) /= N_Identifier then Error_Msg_NE ("must be a& component name", Arg, Typ); raise Pragma_Exit; end if; DTC := First_Component (Typ); while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop Next_Component (DTC); end loop; if No (DTC) then Error_Msg_NE ("must be a& component name", Arg, Typ); raise Pragma_Exit; elsif Etype (DTC) /= VTP_Type then Wrong_Type (Arg, VTP_Type); return; end if; -- Third argument is an integer (DT_Position) Arg := Expression (Arg3); Analyze_And_Resolve (Arg, Any_Integer); if not Is_Static_Expression (Arg) then Error_Pragma_Arg ("third argument of pragma% must be a static expression", Arg3); else V := Expr_Value (Expression (Arg3)); if V <= 0 then Error_Pragma_Arg ("third argument of pragma% must be positive", Arg3); else Set_DTC_Entity (Subp, DTC); Set_DT_Position (Subp, V); end if; end if; end CPP_Virtual; ---------------- -- CPP_Vtable -- ---------------- -- pragma CPP_Vtable ( -- [Entity =>] LOCAL_NAME -- [Vtable_Ptr =>] LOCAL_NAME, -- [Entry_Count =>] static_integer_EXPRESSION); when Pragma_CPP_Vtable => CPP_Vtable : declare Arg : Node_Id; Typ : Entity_Id; VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr); DTC : Entity_Id; V : Uint; Elmt : Elmt_Id; begin GNAT_Pragma; Check_Arg_Count (3); Check_Optional_Identifier (Arg1, Name_Entity); Check_Optional_Identifier (Arg2, "vtable_ptr"); Check_Optional_Identifier (Arg3, "entry_count"); Check_Arg_Is_Local_Name (Arg1); -- First argument is a record type name Arg := Expression (Arg1); Analyze (Arg); if Etype (Arg) = Any_Type then return; else Typ := Entity (Arg); end if; if not (Is_Tagged_Type (Typ) and then Is_CPP_Class (Typ)) then Error_Pragma_Arg ("'C'P'P_Class tagged type expected", Arg1); end if; -- Second argument is a component name of type Vtable_Ptr Arg := Expression (Arg2); if Nkind (Arg) /= N_Identifier then Error_Msg_NE ("must be a& component name", Arg, Typ); raise Pragma_Exit; end if; DTC := First_Component (Typ); while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop Next_Component (DTC); end loop; if No (DTC) then Error_Msg_NE ("must be a& component name", Arg, Typ); raise Pragma_Exit; elsif Etype (DTC) /= VTP_Type then Wrong_Type (DTC, VTP_Type); return; -- If it is the first pragma Vtable, This becomes the default tag elsif (not Is_Tag (DTC)) and then DT_Entry_Count (Tag_Component (Typ)) = No_Uint then Set_Is_Tag (Tag_Component (Typ), False); Set_Is_Tag (DTC, True); Set_DT_Entry_Count (DTC, No_Uint); end if; -- Those pragmas must appear before any primitive operation -- definition (except inherited ones) otherwise the default -- may be wrong Elmt := First_Elmt (Primitive_Operations (Typ)); while Present (Elmt) loop if No (Alias (Node (Elmt))) then Error_Msg_Sloc := Sloc (Node (Elmt)); Error_Pragma ("pragma% must appear before this primitive operation"); end if; Next_Elmt (Elmt); end loop; -- Third argument is an integer (DT_Entry_Count) Arg := Expression (Arg3); Analyze_And_Resolve (Arg, Any_Integer); if not Is_Static_Expression (Arg) then Error_Pragma_Arg ("entry count for pragma% must be a static expression", Arg3); else V := Expr_Value (Expression (Arg3)); if V <= 0 then Error_Pragma_Arg ("entry count for pragma% must be positive", Arg3); else Set_DT_Entry_Count (DTC, V); end if; end if; end CPP_Vtable; ----------- -- Debug -- ----------- -- pragma Debug (PROCEDURE_CALL_STATEMENT); when Pragma_Debug => Debug : begin GNAT_Pragma; -- If assertions are enabled, and we are expanding code, then -- we rewrite the pragma with its corresponding procedure call -- and then analyze the call. if Assertions_Enabled and Expander_Active then Rewrite (N, Relocate_Node (Debug_Statement (N))); Analyze (N); -- Otherwise we work a bit to get a tree that makes sense -- for ASIS purposes, namely a pragma with an analyzed -- argument that looks like a procedure call. else Expander_Mode_Save_And_Set (False); Rewrite (N, Relocate_Node (Debug_Statement (N))); Analyze (N); Rewrite (N, Make_Pragma (Loc, Chars => Name_Debug, Pragma_Argument_Associations => New_List (Relocate_Node (N)))); Expander_Mode_Restore; end if; end Debug; ------------------- -- Discard_Names -- ------------------- -- pragma Discard_Names [([On =>] LOCAL_NAME)]; when Pragma_Discard_Names => Discard_Names : declare E_Id : Entity_Id; E : Entity_Id; begin GNAT_Pragma; Check_Ada_83_Warning; -- Deal with configuration pragma case if Arg_Count = 0 and then Is_Configuration_Pragma then Global_Discard_Names := True; return; -- Otherwise, check correct appropriate context else Check_Is_In_Decl_Part_Or_Package_Spec; if Arg_Count = 0 then -- If there is no parameter, then from now on this pragma -- applies to any enumeration, exception or tagged type -- defined in the current declarative part. Set_Discard_Names (Current_Scope); return; else Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_On); Check_Arg_Is_Local_Name (Arg1); E_Id := Expression (Arg1); if Etype (E_Id) = Any_Type then return; else E := Entity (E_Id); end if; if (Is_First_Subtype (E) and then (Is_Enumeration_Type (E) or else Is_Tagged_Type (E))) or else Ekind (E) = E_Exception then Set_Discard_Names (E); else Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1); end if; end if; end if; end Discard_Names; --------------- -- Elaborate -- --------------- -- pragma Elaborate (library_unit_NAME {, library_unit_NAME}); when Pragma_Elaborate => Elaborate : declare Plist : List_Id; Parent_Node : Node_Id; Arg : Node_Id; Citem : Node_Id; begin -- Pragma must be in context items list of a compilation unit if not Is_List_Member (N) then Pragma_Misplaced; return; else Plist := List_Containing (N); Parent_Node := Parent (Plist); if Parent_Node = Empty or else Nkind (Parent_Node) /= N_Compilation_Unit or else Context_Items (Parent_Node) /= Plist then Pragma_Misplaced; return; end if; end if; -- Must be at least one argument if Arg_Count = 0 then Error_Pragma ("pragma% requires at least one argument"); end if; -- In Ada 83 mode, there can be no items following it in the -- context list except other pragmas and implicit with clauses -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this -- placement rule does not apply. if Ada_83 and then Comes_From_Source (N) then Citem := Next (N); while Present (Citem) loop if Nkind (Citem) = N_Pragma or else (Nkind (Citem) = N_With_Clause and then Implicit_With (Citem)) then null; else Error_Pragma ("(Ada 83) pragma% must be at end of context clause"); end if; Next (Citem); end loop; end if; -- Finally, the arguments must all be units mentioned in a with -- clause in the same context clause. Note we already checked -- (in Par.Prag) that the arguments are either identifiers or Arg := Arg1; Outer : while Present (Arg) loop Citem := First (Plist); Inner : while Citem /= N loop if Nkind (Citem) = N_With_Clause and then Same_Name (Name (Citem), Expression (Arg)) then Set_Elaborate_Present (Citem, True); Set_Unit_Name (Expression (Arg), Name (Citem)); Set_Suppress_Elaboration_Warnings (Entity (Name (Citem))); exit Inner; end if; Next (Citem); end loop Inner; if Citem = N then Error_Pragma_Arg ("argument of pragma% is not with'ed unit", Arg); end if; Next (Arg); end loop Outer; end Elaborate; ------------------- -- Elaborate_All -- ------------------- -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME}); when Pragma_Elaborate_All => Elaborate_All : declare Plist : List_Id; Parent_Node : Node_Id; Arg : Node_Id; Citem : Node_Id; begin Check_Ada_83_Warning; -- Pragma must be in context items list of a compilation unit if not Is_List_Member (N) then Pragma_Misplaced; return; else Plist := List_Containing (N); Parent_Node := Parent (Plist); if Parent_Node = Empty or else Nkind (Parent_Node) /= N_Compilation_Unit or else Context_Items (Parent_Node) /= Plist then Pragma_Misplaced; return; end if; end if; -- Must be at least one argument if Arg_Count = 0 then Error_Pragma ("pragma% requires at least one argument"); end if; -- Note: unlike pragma Elaborate, pragma Elaborate_All does not -- have to appear at the end of the context clause, but may -- appear mixed in with other items, even in Ada 83 mode. -- Final check: the arguments must all be units mentioned in -- a with clause in the same context clause. Note that we -- already checked (in Par.Prag) that all the arguments are -- either identifiers or selected components. Arg := Arg1; Outr : while Present (Arg) loop Citem := First (Plist); Innr : while Citem /= N loop if Nkind (Citem) = N_With_Clause and then Same_Name (Name (Citem), Expression (Arg)) then Set_Elaborate_All_Present (Citem, True); Set_Unit_Name (Expression (Arg), Name (Citem)); Set_Suppress_Elaboration_Warnings (Entity (Name (Citem))); exit Innr; end if; Next (Citem); end loop Innr; if Citem = N then Error_Pragma_Arg ("argument of pragma% is not with'ed unit", Arg); end if; Next (Arg); end loop Outr; end Elaborate_All; -------------------- -- Elaborate_Body -- -------------------- -- pragma Elaborate_Body [( library_unit_NAME )]; when Pragma_Elaborate_Body => Elaborate_Body : declare Cunit_Node : Node_Id; Cunit_Ent : Entity_Id; begin Check_Ada_83_Warning; Check_Valid_Library_Unit_Pragma; if Nkind (N) = N_Null_Statement then return; end if; Cunit_Node := Cunit (Current_Sem_Unit); Cunit_Ent := Cunit_Entity (Current_Sem_Unit); if Nkind (Unit (Cunit_Node)) = N_Package_Body or else Nkind (Unit (Cunit_Node)) = N_Subprogram_Body then Error_Pragma ("pragma% must refer to a spec, not a body"); else Set_Body_Required (Cunit_Node, True); Set_Has_Pragma_Elaborate_Body (Cunit_Ent); -- If we are in dynamic elaboration mode, then we suppress -- elaboration warnings for the unit, since it is definitely -- fine NOT to do dynamic checks at the first level (and such -- checks will be suppressed because no elaboration boolean -- is created for Elaborate_Body packages). -- But in the static model of elaboration, Elaborate_Body is -- definitely NOT good enough to ensure elaboration safety on -- its own, since the body may WITH other units that are not -- safe from an elaboration point of view, so a client must -- still do an Elaborate_All on such units. -- Debug flag -gnatdD restores the old behavior of 3.13, -- where Elaborate_Body always suppressed elab warnings. if Dynamic_Elaboration_Checks or Debug_Flag_DD then Set_Suppress_Elaboration_Warnings (Cunit_Ent); end if; end if; end Elaborate_Body; ------------------------ -- Elaboration_Checks -- ------------------------ -- pragma Elaboration_Checks (Static | Dynamic); when Pragma_Elaboration_Checks => GNAT_Pragma; Check_Arg_Count (1); Check_Arg_Is_One_Of (Arg1, Name_Static, Name_Dynamic); Dynamic_Elaboration_Checks := (Chars (Get_Pragma_Arg (Arg1)) = Name_Dynamic); --------------- -- Eliminate -- --------------- -- pragma Eliminate ( -- [Unit_Name =>] IDENTIFIER | -- SELECTED_COMPONENT -- [,[Entity =>] IDENTIFIER | -- SELECTED_COMPONENT | -- STRING_LITERAL] -- [,[Parameter_Types =>] PARAMETER_TYPES] -- [,[Result_Type =>] result_SUBTYPE_MARK]); -- PARAMETER_TYPES ::= -- null -- (SUBTYPE_MARK, SUBTYPE_MARK, ...) when Pragma_Eliminate => Eliminate : begin GNAT_Pragma; Check_Ada_83_Warning; Check_Valid_Configuration_Pragma; Check_At_Least_N_Arguments (1); Check_At_Most_N_Arguments (4); if Arg_Count = 3 and then Chars (Arg3) = Name_Result_Type then Arg4 := Arg3; Arg3 := Empty; else Check_Optional_Identifier (Arg1, "unit_name"); Check_Optional_Identifier (Arg2, Name_Entity); Check_Optional_Identifier (Arg3, Name_Parameter_Types); Check_Optional_Identifier (Arg4, Name_Result_Type); end if; Process_Eliminate_Pragma (Arg1, Arg2, Arg3, Arg4); end Eliminate; ------------ -- Export -- ------------ -- pragma Export ( -- [ Convention =>] convention_IDENTIFIER, -- [ Entity =>] local_NAME -- [, [External_Name =>] static_string_EXPRESSION ] -- [, [Link_Name =>] static_string_EXPRESSION ]); when Pragma_Export => Export : declare C : Convention_Id; Def_Id : Entity_Id; begin Check_Ada_83_Warning; Check_At_Least_N_Arguments (2); Check_At_Most_N_Arguments (4); Process_Convention (C, Def_Id); if Ekind (Def_Id) /= E_Constant then Note_Possible_Modification (Expression (Arg2)); end if; Process_Interface_Name (Def_Id, Arg3, Arg4); Set_Exported (Def_Id, Arg2); end Export; ---------------------- -- Export_Exception -- ---------------------- -- pragma Export_Exception ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL,] -- [, [Form =>] Ada | VMS] -- [, [Code =>] static_integer_EXPRESSION]); when Pragma_Export_Exception => Export_Exception : declare Args : Args_List (1 .. 4); Names : Name_List (1 .. 4) := ( Name_Internal, Name_External, Name_Form, Name_Code); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Form : Node_Id renames Args (3); Code : Node_Id renames Args (4); begin GNAT_Pragma; if Inside_A_Generic then Error_Pragma ("pragma% cannot be used for generic entities"); end if; Gather_Associations (Names, Args); Process_Extended_Import_Export_Exception_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Form => Form, Arg_Code => Code); if not Is_VMS_Exception (Entity (Internal)) then Set_Exported (Entity (Internal), Internal); end if; end Export_Exception; --------------------- -- Export_Function -- --------------------- -- pragma Export_Function ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL,] -- [, [Parameter_Types =>] (PARAMETER_TYPES)] -- [, [Result_Type =>] SUBTYPE_MARK] -- [, [Mechanism =>] MECHANISM] -- [, [Result_Mechanism =>] MECHANISM_NAME]); when Pragma_Export_Function => Export_Function : declare Args : Args_List (1 .. 6); Names : Name_List (1 .. 6) := ( Name_Internal, Name_External, Name_Parameter_Types, Name_Result_Type, Name_Mechanism, Name_Result_Mechanism); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Parameter_Types : Node_Id renames Args (3); Result_Type : Node_Id renames Args (4); Mechanism : Node_Id renames Args (5); Result_Mechanism : Node_Id renames Args (6); begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Subprogram_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Parameter_Types => Parameter_Types, Arg_Result_Type => Result_Type, Arg_Mechanism => Mechanism, Arg_Result_Mechanism => Result_Mechanism); end Export_Function; ------------------- -- Export_Object -- ------------------- -- pragma Export_Object ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, [Size =>] EXTERNAL_SYMBOL]); when Pragma_Export_Object => Export_Object : declare Args : Args_List (1 .. 3); Names : Name_List (1 .. 3) := ( Name_Internal, Name_External, Name_Size); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Size : Node_Id renames Args (3); begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Object_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Size => Size); end Export_Object; ---------------------- -- Export_Procedure -- ---------------------- -- pragma Export_Procedure ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL,] -- [, [Parameter_Types =>] (PARAMETER_TYPES)] -- [, [Mechanism =>] MECHANISM]); when Pragma_Export_Procedure => Export_Procedure : declare Args : Args_List (1 .. 4); Names : Name_List (1 .. 4) := ( Name_Internal, Name_External, Name_Parameter_Types, Name_Mechanism); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Parameter_Types : Node_Id renames Args (3); Mechanism : Node_Id renames Args (4); begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Subprogram_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Parameter_Types => Parameter_Types, Arg_Mechanism => Mechanism); end Export_Procedure; ----------------------------- -- Export_Valued_Procedure -- ----------------------------- -- pragma Export_Valued_Procedure ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL,] -- [, [Parameter_Types =>] (PARAMETER_TYPES)] -- [, [Mechanism =>] MECHANISM]); when Pragma_Export_Valued_Procedure => Export_Valued_Procedure : declare Args : Args_List (1 .. 4); Names : Name_List (1 .. 4) := ( Name_Internal, Name_External, Name_Parameter_Types, Name_Mechanism); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Parameter_Types : Node_Id renames Args (3); Mechanism : Node_Id renames Args (4); begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Subprogram_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Parameter_Types => Parameter_Types, Arg_Mechanism => Mechanism); end Export_Valued_Procedure; ------------------- -- Extend_System -- ------------------- -- pragma Extend_System ([Name =>] Identifier); when Pragma_Extend_System => Extend_System : declare begin GNAT_Pragma; Check_Valid_Configuration_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Name); Check_Arg_Is_Identifier (Arg1); Get_Name_String (Chars (Expression (Arg1))); if Name_Len > 4 and then Name_Buffer (1 .. 4) = "aux_" then if Present (System_Extend_Pragma_Arg) then if Chars (Expression (Arg1)) = Chars (Expression (System_Extend_Pragma_Arg)) then null; else Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg); Error_Pragma ("pragma% conflicts with that at#"); end if; else System_Extend_Pragma_Arg := Arg1; end if; else Error_Pragma ("incorrect name for pragma%, must be Aux_xxx"); end if; end Extend_System; ------------------------ -- Extensions_Allowed -- ------------------------ -- pragma Extensions_Allowed (ON | OFF); when Pragma_Extensions_Allowed => GNAT_Pragma; Check_Arg_Count (1); Check_No_Identifiers; Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off); Extensions_Allowed := (Chars (Expression (Arg1)) = Name_On); -------------- -- External -- -------------- -- pragma External ( -- [ Convention =>] convention_IDENTIFIER, -- [ Entity =>] local_NAME -- [, [External_Name =>] static_string_EXPRESSION ] -- [, [Link_Name =>] static_string_EXPRESSION ]); when Pragma_External => External : declare C : Convention_Id; Def_Id : Entity_Id; begin GNAT_Pragma; Check_At_Least_N_Arguments (2); Check_At_Most_N_Arguments (4); Process_Convention (C, Def_Id); Note_Possible_Modification (Expression (Arg2)); Process_Interface_Name (Def_Id, Arg3, Arg4); Set_Exported (Def_Id, Arg2); end External; -------------------------- -- External_Name_Casing -- -------------------------- -- pragma External_Name_Casing ( -- UPPERCASE | LOWERCASE -- [, AS_IS | UPPERCASE | LOWERCASE]); when Pragma_External_Name_Casing => External_Name_Casing : declare begin GNAT_Pragma; Check_No_Identifiers; if Arg_Count = 2 then Check_Arg_Is_One_Of (Arg2, Name_As_Is, Name_Uppercase, Name_Lowercase); case Chars (Get_Pragma_Arg (Arg2)) is when Name_As_Is => Opt.External_Name_Exp_Casing := As_Is; when Name_Uppercase => Opt.External_Name_Exp_Casing := Uppercase; when Name_Lowercase => Opt.External_Name_Exp_Casing := Lowercase; when others => null; end case; else Check_Arg_Count (1); end if; Check_Arg_Is_One_Of (Arg1, Name_Uppercase, Name_Lowercase); case Chars (Get_Pragma_Arg (Arg1)) is when Name_Uppercase => Opt.External_Name_Imp_Casing := Uppercase; when Name_Lowercase => Opt.External_Name_Imp_Casing := Lowercase; when others => null; end case; end External_Name_Casing; --------------------------- -- Finalize_Storage_Only -- --------------------------- -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME); when Pragma_Finalize_Storage_Only => Finalize_Storage : declare Assoc : Node_Id := Arg1; Type_Id : Node_Id := Expression (Assoc); Typ : Entity_Id; begin Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); Find_Type (Type_Id); Typ := Entity (Type_Id); if Typ = Any_Type or else Rep_Item_Too_Early (Typ, N) then return; else Typ := Underlying_Type (Typ); end if; if not Is_Controlled (Typ) then Error_Pragma ("pragma% must specify controlled type"); end if; Check_First_Subtype (Arg1); if Finalize_Storage_Only (Typ) then Error_Pragma ("duplicate pragma%, only one allowed"); elsif not Rep_Item_Too_Late (Typ, N) then Set_Finalize_Storage_Only (Typ, True); end if; end Finalize_Storage; -------------------------- -- Float_Representation -- -------------------------- -- pragma Float_Representation (VAX_Float | IEEE_Float); when Pragma_Float_Representation => Float_Representation : declare Argx : Node_Id; Digs : Nat; Ent : Entity_Id; begin GNAT_Pragma; if Arg_Count = 1 then Check_Valid_Configuration_Pragma; else Check_Arg_Count (2); Check_Optional_Identifier (Arg2, Name_Entity); Check_Arg_Is_Local_Name (Arg2); end if; Check_No_Identifier (Arg1); Check_Arg_Is_One_Of (Arg1, Name_VAX_Float, Name_IEEE_Float); if not OpenVMS_On_Target then if Chars (Expression (Arg1)) = Name_VAX_Float then Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)"); end if; return; end if; -- One argument case if Arg_Count = 1 then if Chars (Expression (Arg1)) = Name_VAX_Float then if Opt.Float_Format = 'I' then Error_Pragma ("'I'E'E'E format previously specified"); end if; Opt.Float_Format := 'V'; else if Opt.Float_Format = 'V' then Error_Pragma ("'V'A'X format previously specified"); end if; Opt.Float_Format := 'I'; end if; Set_Standard_Fpt_Formats; -- Two argument case else Argx := Get_Pragma_Arg (Arg2); if not Is_Entity_Name (Argx) or else not Is_Floating_Point_Type (Entity (Argx)) then Error_Pragma_Arg ("second argument of% pragma must be floating-point type", Arg2); end if; Ent := Entity (Argx); Digs := UI_To_Int (Digits_Value (Ent)); -- Two arguments, VAX_Float case if Chars (Expression (Arg1)) = Name_VAX_Float then case Digs is when 6 => Set_F_Float (Ent); when 9 => Set_D_Float (Ent); when 15 => Set_G_Float (Ent); when others => Error_Pragma_Arg ("wrong digits value, must be 6,9 or 15", Arg2); end case; -- Two arguments, IEEE_Float case else case Digs is when 6 => Set_IEEE_Short (Ent); when 15 => Set_IEEE_Long (Ent); when others => Error_Pragma_Arg ("wrong digits value, must be 6 or 15", Arg2); end case; end if; end if; end Float_Representation; ----------- -- Ident -- ----------- -- pragma Ident (static_string_EXPRESSION) -- Note: pragma Comment shares this processing. Pragma Comment -- is identical to Ident, except that the restriction of the -- argument to 31 characters and the placement restrictions -- are not enforced for pragma Comment. when Pragma_Ident | Pragma_Comment => Ident : declare Str : Node_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_No_Identifiers; Check_Arg_Is_Static_Expression (Arg1, Standard_String); -- For pragma Ident, preserve DEC compatibility by requiring -- the pragma to appear in a declarative part or package spec. if Prag_Id = Pragma_Ident then Check_Is_In_Decl_Part_Or_Package_Spec; end if; Str := Expr_Value_S (Expression (Arg1)); -- For pragma Ident, preserve DEC compatibility by limiting -- the length to 31 characters. if Prag_Id = Pragma_Ident and then String_Length (Strval (Str)) > 31 then Error_Pragma_Arg ("argument for pragma% is too long, maximum is 31", Arg1); end if; declare CS : Node_Id; GP : Node_Id; begin GP := Parent (Parent (N)); if Nkind (GP) = N_Package_Declaration or else Nkind (GP) = N_Generic_Package_Declaration then GP := Parent (GP); end if; -- If we have a compilation unit, then record the ident -- value, checking for improper duplication. if Nkind (GP) = N_Compilation_Unit then CS := Ident_String (Current_Sem_Unit); if Present (CS) then -- For Ident, we do not permit multiple instances if Prag_Id = Pragma_Ident then Error_Pragma ("duplicate% pragma not permitted"); -- For Comment, we concatenate the string, unless we -- want to preserve the tree structure for ASIS. elsif not Tree_Output then Start_String (Strval (CS)); Store_String_Char (' '); Store_String_Chars (Strval (Str)); Set_Strval (CS, End_String); end if; else -- In VMS, the effect of IDENT is achieved by passing -- IDENTIFICATION=name as a --for-linker switch. if OpenVMS_On_Target then Start_String; Store_String_Chars ("--for-linker=IDENTIFICATION="); String_To_Name_Buffer (Strval (Str)); Store_String_Chars (Name_Buffer (1 .. Name_Len)); -- Only the last processed IDENT is saved. The main -- purpose is so an IDENT associated with a main -- procedure will be used in preference to an IDENT -- associated with a with'd package. Replace_Linker_Option_String (End_String, "--for-linker=IDENTIFICATION="); end if; Set_Ident_String (Current_Sem_Unit, Str); end if; -- For subunits, we just ignore the Ident, since in GNAT -- these are not separate object files, and hence not -- separate units in the unit table. elsif Nkind (GP) = N_Subunit then null; -- Otherwise we have a misplaced pragma Ident, but we ignore -- this if we are in an instantiation, since it comes from -- a generic, and has no relevance to the instantiation. elsif Prag_Id = Pragma_Ident then if Instantiation_Location (Loc) = No_Location then Error_Pragma ("pragma% only allowed at outer level"); end if; end if; end; end Ident; ------------ -- Import -- ------------ -- pragma Import ( -- [ Convention =>] convention_IDENTIFIER, -- [ Entity =>] local_NAME -- [, [External_Name =>] static_string_EXPRESSION ] -- [, [Link_Name =>] static_string_EXPRESSION ]); when Pragma_Import => Check_Ada_83_Warning; Check_At_Least_N_Arguments (2); Check_At_Most_N_Arguments (4); Process_Import_Or_Interface; ---------------------- -- Import_Exception -- ---------------------- -- pragma Import_Exception ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL,] -- [, [Form =>] Ada | VMS] -- [, [Code =>] static_integer_EXPRESSION]); when Pragma_Import_Exception => Import_Exception : declare Args : Args_List (1 .. 4); Names : Name_List (1 .. 4) := ( Name_Internal, Name_External, Name_Form, Name_Code); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Form : Node_Id renames Args (3); Code : Node_Id renames Args (4); begin GNAT_Pragma; Gather_Associations (Names, Args); if Present (External) and then Present (Code) then Error_Pragma ("cannot give both External and Code options for pragma%"); end if; Process_Extended_Import_Export_Exception_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Form => Form, Arg_Code => Code); if not Is_VMS_Exception (Entity (Internal)) then Set_Imported (Entity (Internal)); end if; end Import_Exception; --------------------- -- Import_Function -- --------------------- -- pragma Import_Function ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, [Parameter_Types =>] (PARAMETER_TYPES)] -- [, [Result_Type =>] SUBTYPE_MARK] -- [, [Mechanism =>] MECHANISM] -- [, [Result_Mechanism =>] MECHANISM_NAME] -- [, [First_Optional_Parameter =>] IDENTIFIER]); when Pragma_Import_Function => Import_Function : declare Args : Args_List (1 .. 7); Names : Name_List (1 .. 7) := ( Name_Internal, Name_External, Name_Parameter_Types, Name_Result_Type, Name_Mechanism, Name_Result_Mechanism, Name_First_Optional_Parameter); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Parameter_Types : Node_Id renames Args (3); Result_Type : Node_Id renames Args (4); Mechanism : Node_Id renames Args (5); Result_Mechanism : Node_Id renames Args (6); First_Optional_Parameter : Node_Id renames Args (7); begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Subprogram_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Parameter_Types => Parameter_Types, Arg_Result_Type => Result_Type, Arg_Mechanism => Mechanism, Arg_Result_Mechanism => Result_Mechanism, Arg_First_Optional_Parameter => First_Optional_Parameter); end Import_Function; ------------------- -- Import_Object -- ------------------- -- pragma Import_Object ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, [Size =>] EXTERNAL_SYMBOL]); when Pragma_Import_Object => Import_Object : declare Args : Args_List (1 .. 3); Names : Name_List (1 .. 3) := ( Name_Internal, Name_External, Name_Size); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Size : Node_Id renames Args (3); begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Object_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Size => Size); end Import_Object; ---------------------- -- Import_Procedure -- ---------------------- -- pragma Import_Procedure ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, [Parameter_Types =>] (PARAMETER_TYPES)] -- [, [Mechanism =>] MECHANISM] -- [, [First_Optional_Parameter =>] IDENTIFIER]); when Pragma_Import_Procedure => Import_Procedure : declare Args : Args_List (1 .. 5); Names : Name_List (1 .. 5) := ( Name_Internal, Name_External, Name_Parameter_Types, Name_Mechanism, Name_First_Optional_Parameter); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Parameter_Types : Node_Id renames Args (3); Mechanism : Node_Id renames Args (4); First_Optional_Parameter : Node_Id renames Args (5); begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Subprogram_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Parameter_Types => Parameter_Types, Arg_Mechanism => Mechanism, Arg_First_Optional_Parameter => First_Optional_Parameter); end Import_Procedure; ----------------------------- -- Import_Valued_Procedure -- ----------------------------- -- pragma Import_Valued_Procedure ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, [Parameter_Types =>] (PARAMETER_TYPES)] -- [, [Mechanism =>] MECHANISM] -- [, [First_Optional_Parameter =>] IDENTIFIER]); when Pragma_Import_Valued_Procedure => Import_Valued_Procedure : declare Args : Args_List (1 .. 5); Names : Name_List (1 .. 5) := ( Name_Internal, Name_External, Name_Parameter_Types, Name_Mechanism, Name_First_Optional_Parameter); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Parameter_Types : Node_Id renames Args (3); Mechanism : Node_Id renames Args (4); First_Optional_Parameter : Node_Id renames Args (5); begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Subprogram_Pragma ( Arg_Internal => Internal, Arg_External => External, Arg_Parameter_Types => Parameter_Types, Arg_Mechanism => Mechanism, Arg_First_Optional_Parameter => First_Optional_Parameter); end Import_Valued_Procedure; ------------------------ -- Initialize_Scalars -- ------------------------ -- pragma Initialize_Scalars; when Pragma_Initialize_Scalars => GNAT_Pragma; Check_Arg_Count (0); Check_Valid_Configuration_Pragma; Init_Or_Norm_Scalars := True; Initialize_Scalars := True; ------------ -- Inline -- ------------ -- pragma Inline ( NAME {, NAME} ); when Pragma_Inline => -- Pragma is active if inlining option is active if Inline_Active then Process_Inline (True); -- Pragma is active in a predefined file in no run time mode elsif No_Run_Time and then Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit)) then Process_Inline (True); else Process_Inline (False); end if; ------------------- -- Inline_Always -- ------------------- -- pragma Inline_Always ( NAME {, NAME} ); when Pragma_Inline_Always => Process_Inline (True); -------------------- -- Inline_Generic -- -------------------- -- pragma Inline_Generic (NAME {, NAME}); when Pragma_Inline_Generic => Process_Generic_List; ---------------------- -- Inspection_Point -- ---------------------- -- pragma Inspection_Point [(object_NAME {, object_NAME})]; when Pragma_Inspection_Point => Inspection_Point : declare Arg : Node_Id; Exp : Node_Id; begin if Arg_Count > 0 then Arg := Arg1; loop Exp := Expression (Arg); Analyze (Exp); if not Is_Entity_Name (Exp) or else not Is_Object (Entity (Exp)) then Error_Pragma_Arg ("object name required", Arg); end if; Next (Arg); exit when No (Arg); end loop; end if; end Inspection_Point; --------------- -- Interface -- --------------- -- pragma Interface ( -- convention_IDENTIFIER, -- local_NAME ); when Pragma_Interface => GNAT_Pragma; Check_Arg_Count (2); Check_No_Identifiers; Process_Import_Or_Interface; -------------------- -- Interface_Name -- -------------------- -- pragma Interface_Name ( -- [ Entity =>] local_NAME -- [,[External_Name =>] static_string_EXPRESSION ] -- [,[Link_Name =>] static_string_EXPRESSION ]); when Pragma_Interface_Name => Interface_Name : declare Id : Node_Id; Def_Id : Entity_Id; Hom_Id : Entity_Id; Found : Boolean; begin GNAT_Pragma; Check_At_Least_N_Arguments (2); Check_At_Most_N_Arguments (3); Id := Expression (Arg1); Analyze (Id); if not Is_Entity_Name (Id) then Error_Pragma_Arg ("first argument for pragma% must be entity name", Arg1); elsif Etype (Id) = Any_Type then return; else Def_Id := Entity (Id); end if; -- Special DEC-compatible processing for the object case, -- forces object to be imported. if Ekind (Def_Id) = E_Variable then Kill_Size_Check_Code (Def_Id); Note_Possible_Modification (Id); -- Initialization is not allowed for imported variable if Present (Expression (Parent (Def_Id))) and then Comes_From_Source (Expression (Parent (Def_Id))) then Error_Msg_Sloc := Sloc (Def_Id); Error_Pragma_Arg ("no initialization allowed for declaration of& #", Arg2); else -- For compatibility, support VADS usage of providing both -- pragmas Interface and Interface_Name to obtain the effect -- of a single Import pragma. if Is_Imported (Def_Id) and then Present (First_Rep_Item (Def_Id)) and then Nkind (First_Rep_Item (Def_Id)) = N_Pragma and then Chars (First_Rep_Item (Def_Id)) = Name_Interface then null; else Set_Imported (Def_Id); end if; Set_Is_Public (Def_Id); Process_Interface_Name (Def_Id, Arg2, Arg3); end if; -- Otherwise must be subprogram elsif not Is_Subprogram (Def_Id) then Error_Pragma_Arg ("argument of pragma% is not subprogram", Arg1); else Check_At_Most_N_Arguments (3); Hom_Id := Def_Id; Found := False; -- Loop through homonyms loop Def_Id := Get_Base_Subprogram (Hom_Id); if Is_Imported (Def_Id) then Process_Interface_Name (Def_Id, Arg2, Arg3); Found := True; end if; Hom_Id := Homonym (Hom_Id); exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope; end loop; if not Found then Error_Pragma_Arg ("argument of pragma% is not imported subprogram", Arg1); end if; end if; end Interface_Name; ----------------------- -- Interrupt_Handler -- ----------------------- -- pragma Interrupt_Handler (handler_NAME); when Pragma_Interrupt_Handler => Check_Ada_83_Warning; Check_Arg_Count (1); Check_No_Identifiers; Check_Interrupt_Or_Attach_Handler; Process_Interrupt_Or_Attach_Handler; ------------------------ -- Interrupt_Priority -- ------------------------ -- pragma Interrupt_Priority [(EXPRESSION)]; when Pragma_Interrupt_Priority => Interrupt_Priority : declare P : constant Node_Id := Parent (N); Arg : Node_Id; begin Check_Ada_83_Warning; if Arg_Count /= 0 then Arg := Expression (Arg1); Check_Arg_Count (1); Check_No_Identifiers; -- Set In_Default_Expression for per-object case??? Analyze_And_Resolve (Arg, Standard_Integer); if Expander_Active then Rewrite (Arg, Convert_To (RTE (RE_Interrupt_Priority), Arg)); end if; end if; if Nkind (P) /= N_Task_Definition and then Nkind (P) /= N_Protected_Definition then Pragma_Misplaced; return; elsif Has_Priority_Pragma (P) then Error_Pragma ("duplicate pragma% not allowed"); else Set_Has_Priority_Pragma (P, True); Record_Rep_Item (Defining_Identifier (Parent (P)), N); end if; end Interrupt_Priority; ---------------------- -- Java_Constructor -- ---------------------- -- pragma Java_Constructor ([Entity =>] LOCAL_NAME); when Pragma_Java_Constructor => Java_Constructor : declare Id : Entity_Id; Def_Id : Entity_Id; Hom_Id : Entity_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Local_Name (Arg1); Id := Expression (Arg1); Find_Program_Unit_Name (Id); -- If we did not find the name, we are done if Etype (Id) = Any_Type then return; end if; Hom_Id := Entity (Id); -- Loop through homonyms loop Def_Id := Get_Base_Subprogram (Hom_Id); -- The constructor is required to be a function returning -- an access type whose designated type has convention Java. if Ekind (Def_Id) = E_Function and then Ekind (Etype (Def_Id)) in Access_Kind and then (Atree.Convention (Designated_Type (Etype (Def_Id))) = Convention_Java or else Atree.Convention (Root_Type (Designated_Type (Etype (Def_Id)))) = Convention_Java) then Set_Is_Constructor (Def_Id); Set_Convention (Def_Id, Convention_Java); else Error_Pragma_Arg ("pragma% requires function returning a 'Java access type", Arg1); end if; Hom_Id := Homonym (Hom_Id); exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope; end loop; end Java_Constructor; ---------------------- -- Java_Interface -- ---------------------- -- pragma Java_Interface ([Entity =>] LOCAL_NAME); when Pragma_Java_Interface => Java_Interface : declare Arg : Node_Id; Typ : Entity_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Local_Name (Arg1); Arg := Expression (Arg1); Analyze (Arg); if Etype (Arg) = Any_Type then return; end if; if not Is_Entity_Name (Arg) or else not Is_Type (Entity (Arg)) then Error_Pragma_Arg ("pragma% requires a type mark", Arg1); end if; Typ := Underlying_Type (Entity (Arg)); -- For now we simply check some of the semantic constraints -- on the type. This currently leaves out some restrictions -- on interface types, namely that the parent type must be -- java.lang.Object.Typ and that all primitives of the type -- should be declared abstract. ??? if not Is_Tagged_Type (Typ) or else not Is_Abstract (Typ) then Error_Pragma_Arg ("pragma% requires an abstract " & "tagged type", Arg1); elsif not Has_Discriminants (Typ) or else Ekind (Etype (First_Discriminant (Typ))) /= E_Anonymous_Access_Type or else not Is_Class_Wide_Type (Designated_Type (Etype (First_Discriminant (Typ)))) then Error_Pragma_Arg ("type must have a class-wide access discriminant", Arg1); end if; end Java_Interface; ------------- -- License -- ------------- -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL); when Pragma_License => GNAT_Pragma; Check_Arg_Count (1); Check_No_Identifiers; Check_Valid_Configuration_Pragma; Check_Arg_Is_Identifier (Arg1); declare Sind : constant Source_File_Index := Source_Index (Current_Sem_Unit); begin case Chars (Get_Pragma_Arg (Arg1)) is when Name_GPL => Set_License (Sind, GPL); when Name_Modified_GPL => Set_License (Sind, Modified_GPL); when Name_Restricted => Set_License (Sind, Restricted); when Name_Unrestricted => Set_License (Sind, Unrestricted); when others => Error_Pragma_Arg ("invalid license name", Arg1); end case; end; --------------- -- Link_With -- --------------- -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION}); when Pragma_Link_With => Link_With : declare Arg : Node_Id; begin GNAT_Pragma; if Operating_Mode = Generate_Code and then In_Extended_Main_Source_Unit (N) then Check_At_Least_N_Arguments (1); Check_No_Identifiers; Check_Is_In_Decl_Part_Or_Package_Spec; Check_Arg_Is_Static_Expression (Arg1, Standard_String); Start_String; Arg := Arg1; while Present (Arg) loop Check_Arg_Is_Static_Expression (Arg, Standard_String); -- Store argument, converting sequences of spaces to -- a single null character (this is the difference in -- processing between Link_With, and Linker_Options). declare C : constant Char_Code := Get_Char_Code (' '); S : constant String_Id := Strval (Expr_Value_S (Expression (Arg))); F : Nat := 1; L : Nat := String_Length (S); procedure Skip_Spaces; -- Advance F past any spaces procedure Skip_Spaces is begin while F <= L and then Get_String_Char (S, F) = C loop F := F + 1; end loop; end Skip_Spaces; begin Skip_Spaces; -- skip leading spaces -- Loop through characters, changing any embedded -- sequence of spaces to a single null character -- (this is how Link_With/Linker_Options differ) while F <= L loop if Get_String_Char (S, F) = C then Skip_Spaces; exit when F > L; Store_String_Char (ASCII.NUL); else Store_String_Char (Get_String_Char (S, F)); F := F + 1; end if; end loop; end; Arg := Next (Arg); if Present (Arg) then Store_String_Char (ASCII.NUL); end if; end loop; Store_Linker_Option_String (End_String); end if; end Link_With; ------------------ -- Linker_Alias -- ------------------ -- pragma Linker_Alias ( -- [Entity =>] LOCAL_NAME -- [Alias =>] static_string_EXPRESSION); when Pragma_Linker_Alias => GNAT_Pragma; Check_Arg_Count (2); Check_Optional_Identifier (Arg1, Name_Entity); Check_Optional_Identifier (Arg2, "alias"); Check_Arg_Is_Library_Level_Local_Name (Arg1); Check_Arg_Is_Static_Expression (Arg2, Standard_String); -- The only processing required is to link this item on to the -- list of rep items for the given entity. This is accomplished -- by the call to Rep_Item_Too_Late (when no error is detected -- and False is returned). if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then return; else Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1))); end if; -------------------- -- Linker_Options -- -------------------- -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION}); -- Note: the use of multiple arguments is a GNAT extension when Pragma_Linker_Options => Linker_Options : declare Arg : Node_Id; begin if Operating_Mode = Generate_Code and then In_Extended_Main_Source_Unit (N) then Check_Ada_83_Warning; Check_At_Least_N_Arguments (1); Check_No_Identifiers; Check_Is_In_Decl_Part_Or_Package_Spec; Check_Arg_Is_Static_Expression (Arg1, Standard_String); Start_String (Strval (Expr_Value_S (Expression (Arg1)))); Arg := Arg2; while Present (Arg) loop Check_Arg_Is_Static_Expression (Arg, Standard_String); Store_String_Char (ASCII.NUL); Store_String_Chars (Strval (Expr_Value_S (Expression (Arg)))); Arg := Next (Arg); end loop; Store_Linker_Option_String (End_String); end if; end Linker_Options; -------------------- -- Linker_Section -- -------------------- -- pragma Linker_Section ( -- [Entity =>] LOCAL_NAME -- [Section =>] static_string_EXPRESSION); when Pragma_Linker_Section => GNAT_Pragma; Check_Arg_Count (2); Check_Optional_Identifier (Arg1, Name_Entity); Check_Optional_Identifier (Arg2, Name_Section); Check_Arg_Is_Library_Level_Local_Name (Arg1); Check_Arg_Is_Static_Expression (Arg2, Standard_String); -- The only processing required is to link this item on to the -- list of rep items for the given entity. This is accomplished -- by the call to Rep_Item_Too_Late (when no error is detected -- and False is returned). if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then return; else Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1))); end if; ---------- -- List -- ---------- -- pragma List (On | Off) -- There is nothing to do here, since we did all the processing -- for this pragma in Par.Prag (so that it works properly even in -- syntax only mode) when Pragma_List => null; -------------------- -- Locking_Policy -- -------------------- -- pragma Locking_Policy (policy_IDENTIFIER); when Pragma_Locking_Policy => declare LP : Character; begin Check_Ada_83_Warning; Check_Arg_Count (1); Check_No_Identifiers; Check_Arg_Is_Locking_Policy (Arg1); Check_Valid_Configuration_Pragma; Get_Name_String (Chars (Expression (Arg1))); LP := Fold_Upper (Name_Buffer (1)); if Locking_Policy /= ' ' and then Locking_Policy /= LP then Error_Msg_Sloc := Locking_Policy_Sloc; Error_Pragma ("locking policy incompatible with policy#"); else Locking_Policy := LP; Locking_Policy_Sloc := Loc; end if; end; ---------------- -- Long_Float -- ---------------- -- pragma Long_Float (D_Float | G_Float); when Pragma_Long_Float => GNAT_Pragma; Check_Valid_Configuration_Pragma; Check_Arg_Count (1); Check_No_Identifier (Arg1); Check_Arg_Is_One_Of (Arg1, Name_D_Float, Name_G_Float); if not OpenVMS_On_Target then Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)"); end if; -- D_Float case if Chars (Expression (Arg1)) = Name_D_Float then if Opt.Float_Format_Long = 'G' then Error_Pragma ("G_Float previously specified"); end if; Opt.Float_Format_Long := 'D'; -- G_Float case (this is the default, does not need overriding) else if Opt.Float_Format_Long = 'D' then Error_Pragma ("D_Float previously specified"); end if; Opt.Float_Format_Long := 'G'; end if; Set_Standard_Fpt_Formats; ----------------------- -- Machine_Attribute -- ----------------------- -- pragma Machine_Attribute ( -- [Entity =>] LOCAL_NAME, -- [Attribute_Name =>] static_string_EXPRESSION -- [,[Info =>] static_string_EXPRESSION] ); when Pragma_Machine_Attribute => Machine_Attribute : declare Def_Id : Entity_Id; begin GNAT_Pragma; if Arg_Count = 3 then Check_Optional_Identifier (Arg3, "info"); Check_Arg_Is_Static_Expression (Arg3, Standard_String); else Check_Arg_Count (2); end if; Check_Arg_Is_Local_Name (Arg1); Check_Optional_Identifier (Arg2, "attribute_name"); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Static_Expression (Arg2, Standard_String); Def_Id := Entity (Expression (Arg1)); if Is_Access_Type (Def_Id) then Def_Id := Designated_Type (Def_Id); end if; if Rep_Item_Too_Early (Def_Id, N) then return; end if; Def_Id := Underlying_Type (Def_Id); -- The only processing required is to link this item on to the -- list of rep items for the given entity. This is accomplished -- by the call to Rep_Item_Too_Late (when no error is detected -- and False is returned). if Rep_Item_Too_Late (Def_Id, N) then return; else Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1))); end if; end Machine_Attribute; ---------- -- Main -- ---------- -- pragma Main_Storage -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]); -- MAIN_STORAGE_OPTION ::= -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION when Pragma_Main => Main : declare Args : Args_List (1 .. 3); Names : Name_List (1 .. 3) := ( Name_Stack_Size, Name_Task_Stack_Size_Default, Name_Time_Slicing_Enabled); Nod : Node_Id; begin GNAT_Pragma; Gather_Associations (Names, Args); for J in 1 .. 2 loop if Present (Args (J)) then Check_Arg_Is_Static_Expression (Args (J), Any_Integer); end if; end loop; if Present (Args (3)) then Check_Arg_Is_Static_Expression (Args (3), Standard_Boolean); end if; Nod := Next (N); while Present (Nod) loop if Nkind (Nod) = N_Pragma and then Chars (Nod) = Name_Main then Error_Msg_Name_1 := Chars (N); Error_Msg_N ("duplicate pragma% not permitted", Nod); end if; Next (Nod); end loop; end Main; ------------------ -- Main_Storage -- ------------------ -- pragma Main_Storage -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]); -- MAIN_STORAGE_OPTION ::= -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION when Pragma_Main_Storage => Main_Storage : declare Args : Args_List (1 .. 2); Names : Name_List (1 .. 2) := ( Name_Working_Storage, Name_Top_Guard); Nod : Node_Id; begin GNAT_Pragma; Gather_Associations (Names, Args); for J in 1 .. 2 loop if Present (Args (J)) then Check_Arg_Is_Static_Expression (Args (J), Any_Integer); end if; end loop; Check_In_Main_Program; Nod := Next (N); while Present (Nod) loop if Nkind (Nod) = N_Pragma and then Chars (Nod) = Name_Main_Storage then Error_Msg_Name_1 := Chars (N); Error_Msg_N ("duplicate pragma% not permitted", Nod); end if; Next (Nod); end loop; end Main_Storage; ----------------- -- Memory_Size -- ----------------- -- pragma Memory_Size (NUMERIC_LITERAL) when Pragma_Memory_Size => GNAT_Pragma; -- Memory size is simply ignored Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Integer_Literal (Arg1); --------------- -- No_Return -- --------------- -- pragma No_Return (procedure_LOCAL_NAME); when Pragma_No_Return => declare Id : Node_Id; E : Entity_Id; Found : Boolean; begin GNAT_Pragma; Check_Arg_Count (1); Check_No_Identifiers; Check_Arg_Is_Local_Name (Arg1); Id := Expression (Arg1); Analyze (Id); if not Is_Entity_Name (Id) then Error_Pragma_Arg ("entity name required", Arg1); end if; if Etype (Id) = Any_Type then raise Pragma_Exit; end if; E := Entity (Id); Found := False; while Present (E) and then Scope (E) = Current_Scope loop if Ekind (E) = E_Procedure or else Ekind (E) = E_Generic_Procedure then Set_No_Return (E); Found := True; end if; E := Homonym (E); end loop; if not Found then Error_Pragma ("no procedures found for pragma%"); end if; end; ----------------- -- No_Run_Time -- ----------------- -- pragma No_Run_Time when Pragma_No_Run_Time => GNAT_Pragma; Check_Valid_Configuration_Pragma; Check_Arg_Count (0); Set_No_Run_Time_Mode; ----------------------- -- Normalize_Scalars -- ----------------------- -- pragma Normalize_Scalars; when Pragma_Normalize_Scalars => Check_Ada_83_Warning; Check_Arg_Count (0); Check_Valid_Configuration_Pragma; Normalize_Scalars := True; Init_Or_Norm_Scalars := True; -------------- -- Optimize -- -------------- -- pragma Optimize (Time | Space); -- The actual check for optimize is done in Gigi. Note that this -- pragma does not actually change the optimization setting, it -- simply checks that it is consistent with the pragma. when Pragma_Optimize => Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off); ---------- -- Pack -- ---------- -- pragma Pack (first_subtype_LOCAL_NAME); when Pragma_Pack => Pack : declare Assoc : Node_Id := Arg1; Type_Id : Node_Id; Typ : Entity_Id; begin Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); Type_Id := Expression (Assoc); Find_Type (Type_Id); Typ := Entity (Type_Id); if Typ = Any_Type or else Rep_Item_Too_Early (Typ, N) then return; else Typ := Underlying_Type (Typ); end if; if not Is_Array_Type (Typ) and then not Is_Record_Type (Typ) then Error_Pragma ("pragma% must specify array or record type"); end if; Check_First_Subtype (Arg1); if Has_Pragma_Pack (Typ) then Error_Pragma ("duplicate pragma%, only one allowed"); -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed, -- but not Has_Non_Standard_Rep, because we don't actually know -- till freeze time if the array can have packed representation. -- That's because in the general case we do not know enough about -- the component type until it in turn is frozen, which certainly -- happens before the array type is frozen, but not necessarily -- till that point (i.e. right now it may be unfrozen). elsif Is_Array_Type (Typ) then if Has_Aliased_Components (Base_Type (Typ)) then Error_Pragma ("pragma% ignored, cannot pack aliased components?"); elsif Has_Atomic_Components (Typ) then Error_Pragma ("?pragma% ignored, cannot pack atomic components"); elsif not Rep_Item_Too_Late (Typ, N) then Set_Is_Packed (Base_Type (Typ)); Set_Has_Pragma_Pack (Base_Type (Typ)); Set_Has_Non_Standard_Rep (Base_Type (Typ)); end if; -- Record type. For record types, the pack is always effective else -- Is_Record_Type (Typ) if not Rep_Item_Too_Late (Typ, N) then Set_Has_Pragma_Pack (Base_Type (Typ)); Set_Is_Packed (Base_Type (Typ)); Set_Has_Non_Standard_Rep (Base_Type (Typ)); end if; end if; end Pack; ---------- -- Page -- ---------- -- pragma Page; -- There is nothing to do here, since we did all the processing -- for this pragma in Par.Prag (so that it works properly even in -- syntax only mode) when Pragma_Page => null; ------------- -- Passive -- ------------- -- pragma Passive [(PASSIVE_FORM)]; -- PASSIVE_FORM ::= Semaphore | No when Pragma_Passive => GNAT_Pragma; if Nkind (Parent (N)) /= N_Task_Definition then Error_Pragma ("pragma% must be within task definition"); end if; if Arg_Count /= 0 then Check_Arg_Count (1); Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No); end if; ------------- -- Polling -- ------------- -- pragma Polling (ON | OFF); when Pragma_Polling => GNAT_Pragma; Check_Arg_Count (1); Check_No_Identifiers; Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off); Polling_Required := (Chars (Expression (Arg1)) = Name_On); ------------------ -- Preelaborate -- ------------------ -- pragma Preelaborate [(library_unit_NAME)]; -- Set the flag Is_Preelaborated of program unit name entity when Pragma_Preelaborate => Preelaborate : declare Ent : Entity_Id; Pa : Node_Id := Parent (N); Pk : Node_Kind := Nkind (Pa); begin Check_Ada_83_Warning; Check_Valid_Library_Unit_Pragma; if Nkind (N) = N_Null_Statement then return; end if; Ent := Find_Lib_Unit_Name; -- This filters out pragmas inside generic parent then -- show up inside instantiation if Present (Ent) and then not (Pk = N_Package_Specification and then Present (Generic_Parent (Pa))) then if not Debug_Flag_U then Set_Is_Preelaborated (Ent); Set_Suppress_Elaboration_Warnings (Ent); end if; end if; end Preelaborate; -------------- -- Priority -- -------------- -- pragma Priority (EXPRESSION); when Pragma_Priority => Priority : declare P : constant Node_Id := Parent (N); Arg : Node_Id; begin Check_No_Identifiers; Check_Arg_Count (1); Arg := Expression (Arg1); Analyze_And_Resolve (Arg, Standard_Integer); if not Is_Static_Expression (Arg) then Check_Restriction (Static_Priorities, Arg); end if; -- Subprogram case if Nkind (P) = N_Subprogram_Body then Check_In_Main_Program; -- Must be static if not Is_Static_Expression (Arg) then Error_Pragma_Arg ("main subprogram priority is not static", Arg1); -- If constraint error, then we already signalled an error elsif Raises_Constraint_Error (Arg) then null; -- Otherwise check in range else declare Val : constant Uint := Expr_Value (Arg); begin if Val < 0 or else Val > Expr_Value (Expression (Parent (RTE (RE_Max_Priority)))) then Error_Pragma_Arg ("main subprogram priority is out of range", Arg1); end if; end; end if; Set_Main_Priority (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg))); -- Task or Protected, must be of type Integer elsif Nkind (P) = N_Protected_Definition or else Nkind (P) = N_Task_Definition then if Expander_Active then Rewrite (Arg, Convert_To (RTE (RE_Any_Priority), Arg)); end if; -- Anything else is incorrect else Pragma_Misplaced; end if; if Has_Priority_Pragma (P) then Error_Pragma ("duplicate pragma% not allowed"); else Set_Has_Priority_Pragma (P, True); if Nkind (P) = N_Protected_Definition or else Nkind (P) = N_Task_Definition then Record_Rep_Item (Defining_Identifier (Parent (P)), N); -- exp_ch9 should use this ??? end if; end if; end Priority; -------------------------- -- Propagate_Exceptions -- -------------------------- -- pragma Propagate_Exceptions; when Pragma_Propagate_Exceptions => GNAT_Pragma; Check_Arg_Count (0); if In_Extended_Main_Source_Unit (N) then Propagate_Exceptions := True; end if; ------------------ -- Psect_Object -- ------------------ -- pragma Psect_Object ( -- [Internal =>] LOCAL_NAME, -- [, [External =>] EXTERNAL_SYMBOL] -- [, [Size =>] EXTERNAL_SYMBOL]); when Pragma_Psect_Object | Pragma_Common_Object => Psect_Object : declare Args : Args_List (1 .. 3); Names : Name_List (1 .. 3) := ( Name_Internal, Name_External, Name_Size); Internal : Node_Id renames Args (1); External : Node_Id renames Args (2); Size : Node_Id renames Args (3); R_Internal : Node_Id; R_External : Node_Id; MA : Node_Id; Str : String_Id; Def_Id : Entity_Id; procedure Check_Too_Long (Arg : Node_Id); -- Posts message if the argument is an identifier with more -- than 31 characters, or a string literal with more than -- 31 characters, and we are operating under VMS procedure Check_Too_Long (Arg : Node_Id) is X : Node_Id := Original_Node (Arg); begin if Nkind (X) /= N_String_Literal and then Nkind (X) /= N_Identifier then Error_Pragma_Arg ("inappropriate argument for pragma %", Arg); end if; if OpenVMS_On_Target then if (Nkind (X) = N_String_Literal and then String_Length (Strval (X)) > 31) or else (Nkind (X) = N_Identifier and then Length_Of_Name (Chars (X)) > 31) then Error_Pragma_Arg ("argument for pragma % is longer than 31 characters", Arg); end if; end if; end Check_Too_Long; -- Start of processing for Common_Object/Psect_Object begin GNAT_Pragma; Gather_Associations (Names, Args); Process_Extended_Import_Export_Internal_Arg (Internal); R_Internal := Relocate_Node (Internal); Def_Id := Entity (R_Internal); if Ekind (Def_Id) /= E_Constant and then Ekind (Def_Id) /= E_Variable then Error_Pragma_Arg ("pragma% must designate an object", Internal); end if; Check_Too_Long (R_Internal); if Is_Imported (Def_Id) or else Is_Exported (Def_Id) then Error_Pragma_Arg ("cannot use pragma% for imported/exported object", R_Internal); end if; if Is_Concurrent_Type (Etype (R_Internal)) then Error_Pragma_Arg ("cannot specify pragma % for task/protected object", R_Internal); end if; if Is_Psected (Def_Id) then Error_Msg_N ("?duplicate Psect_Object pragma", N); else Set_Is_Psected (Def_Id); end if; if Ekind (Def_Id) = E_Constant then Error_Pragma_Arg ("cannot specify pragma % for a constant", R_Internal); end if; if Is_Record_Type (Etype (R_Internal)) then declare Ent : Entity_Id; Decl : Entity_Id; begin Ent := First_Entity (Etype (R_Internal)); while Present (Ent) loop Decl := Declaration_Node (Ent); if Ekind (Ent) = E_Component and then Nkind (Decl) = N_Component_Declaration and then Present (Expression (Decl)) then Error_Msg_N ("?object for pragma % has defaults", R_Internal); exit; else Next_Entity (Ent); end if; end loop; end; end if; if Present (Size) then Check_Too_Long (Size); end if; -- Make Psect case-insensitive. if Present (External) then Check_Too_Long (External); if Nkind (External) = N_String_Literal then String_To_Name_Buffer (Strval (External)); else Get_Name_String (Chars (External)); end if; Set_All_Upper_Case; Start_String; Store_String_Chars (Name_Buffer (1 .. Name_Len)); Str := End_String; R_External := Make_String_Literal (Sloc => Sloc (External), Strval => Str); else Get_Name_String (Chars (Internal)); Set_All_Upper_Case; Start_String; Store_String_Chars (Name_Buffer (1 .. Name_Len)); Str := End_String; R_External := Make_String_Literal (Sloc => Sloc (Internal), Strval => Str); end if; -- Transform into pragma Linker_Section, add attributes to -- match what DEC Ada does. Ignore size for now? Rewrite (N, Make_Pragma (Sloc (N), Name_Linker_Section, New_List (Make_Pragma_Argument_Association (Sloc => Sloc (R_Internal), Expression => R_Internal), Make_Pragma_Argument_Association (Sloc => Sloc (R_External), Expression => R_External)))); Analyze (N); -- Add Machine_Attribute of "overlaid", so the section overlays -- other sections of the same name. Start_String; Store_String_Chars ("overlaid"); Str := End_String; MA := Make_Pragma (Sloc (N), Name_Machine_Attribute, New_List (Make_Pragma_Argument_Association (Sloc => Sloc (R_Internal), Expression => R_Internal), Make_Pragma_Argument_Association (Sloc => Sloc (R_External), Expression => Make_String_Literal (Sloc => Sloc (R_External), Strval => Str)))); Analyze (MA); -- Add Machine_Attribute of "global", so the section is visible -- everywhere Start_String; Store_String_Chars ("global"); Str := End_String; MA := Make_Pragma (Sloc (N), Name_Machine_Attribute, New_List (Make_Pragma_Argument_Association (Sloc => Sloc (R_Internal), Expression => R_Internal), Make_Pragma_Argument_Association (Sloc => Sloc (R_External), Expression => Make_String_Literal (Sloc => Sloc (R_External), Strval => Str)))); Analyze (MA); -- Add Machine_Attribute of "initialize", so the section is -- demand zeroed. Start_String; Store_String_Chars ("initialize"); Str := End_String; MA := Make_Pragma (Sloc (N), Name_Machine_Attribute, New_List (Make_Pragma_Argument_Association (Sloc => Sloc (R_Internal), Expression => R_Internal), Make_Pragma_Argument_Association (Sloc => Sloc (R_External), Expression => Make_String_Literal (Sloc => Sloc (R_External), Strval => Str)))); Analyze (MA); end Psect_Object; ---------- -- Pure -- ---------- -- pragma Pure [(library_unit_NAME)]; when Pragma_Pure => Pure : declare Ent : Entity_Id; begin Check_Ada_83_Warning; Check_Valid_Library_Unit_Pragma; if Nkind (N) = N_Null_Statement then return; end if; Ent := Find_Lib_Unit_Name; Set_Is_Pure (Ent); Set_Suppress_Elaboration_Warnings (Ent); end Pure; ------------------- -- Pure_Function -- ------------------- -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME); when Pragma_Pure_Function => Pure_Function : declare E_Id : Node_Id; E : Entity_Id; Def_Id : Entity_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Local_Name (Arg1); E_Id := Expression (Arg1); if Error_Posted (E_Id) then return; end if; -- Loop through homonyms (overloadings) of referenced entity E := Entity (E_Id); while Present (E) loop Def_Id := Get_Base_Subprogram (E); if Ekind (Def_Id) /= E_Function and then Ekind (Def_Id) /= E_Generic_Function and then Ekind (Def_Id) /= E_Operator then Error_Pragma_Arg ("pragma% requires a function name", Arg1); end if; Set_Is_Pure (Def_Id); Set_Has_Pragma_Pure_Function (Def_Id); E := Homonym (E); end loop; end Pure_Function; -------------------- -- Queuing_Policy -- -------------------- -- pragma Queuing_Policy (policy_IDENTIFIER); when Pragma_Queuing_Policy => declare QP : Character; begin Check_Ada_83_Warning; Check_Arg_Count (1); Check_No_Identifiers; Check_Arg_Is_Queuing_Policy (Arg1); Check_Valid_Configuration_Pragma; Get_Name_String (Chars (Expression (Arg1))); QP := Fold_Upper (Name_Buffer (1)); if Queuing_Policy /= ' ' and then Queuing_Policy /= QP then Error_Msg_Sloc := Queuing_Policy_Sloc; Error_Pragma ("queuing policy incompatible with policy#"); else Queuing_Policy := QP; Queuing_Policy_Sloc := Loc; end if; end; --------------------------- -- Remote_Call_Interface -- --------------------------- -- pragma Remote_Call_Interface [(library_unit_NAME)]; when Pragma_Remote_Call_Interface => Remote_Call_Interface : declare Cunit_Node : Node_Id; Cunit_Ent : Entity_Id; K : Node_Kind; begin Check_Ada_83_Warning; Check_Valid_Library_Unit_Pragma; if Nkind (N) = N_Null_Statement then return; end if; Cunit_Node := Cunit (Current_Sem_Unit); K := Nkind (Unit (Cunit_Node)); Cunit_Ent := Cunit_Entity (Current_Sem_Unit); if K = N_Package_Declaration or else K = N_Generic_Package_Declaration or else K = N_Subprogram_Declaration or else K = N_Generic_Subprogram_Declaration or else (K = N_Subprogram_Body and then Acts_As_Spec (Unit (Cunit_Node))) then null; else Error_Pragma ( "pragma% must apply to package or subprogram declaration"); end if; Set_Is_Remote_Call_Interface (Cunit_Ent); end Remote_Call_Interface; ------------------ -- Remote_Types -- ------------------ -- pragma Remote_Types [(library_unit_NAME)]; when Pragma_Remote_Types => Remote_Types : declare Cunit_Node : Node_Id; Cunit_Ent : Entity_Id; begin Check_Ada_83_Warning; Check_Valid_Library_Unit_Pragma; if Nkind (N) = N_Null_Statement then return; end if; Cunit_Node := Cunit (Current_Sem_Unit); Cunit_Ent := Cunit_Entity (Current_Sem_Unit); if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration and then Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration then Error_Pragma ( "pragma% can only apply to a package declaration"); end if; Set_Is_Remote_Types (Cunit_Ent); end Remote_Types; --------------- -- Ravenscar -- --------------- when Pragma_Ravenscar => GNAT_Pragma; Check_Arg_Count (0); Check_Valid_Configuration_Pragma; Set_Ravenscar; ------------------------- -- Restricted_Run_Time -- ------------------------- when Pragma_Restricted_Run_Time => GNAT_Pragma; Check_Arg_Count (0); Check_Valid_Configuration_Pragma; Set_Restricted_Profile; ------------------ -- Restrictions -- ------------------ -- pragma Restrictions (RESTRICTION {, RESTRICTION}); -- RESTRICTION ::= -- restriction_IDENTIFIER -- | restriction_parameter_IDENTIFIER => EXPRESSION when Pragma_Restrictions => Restrictions_Pragma : declare Arg : Node_Id; R_Id : Restriction_Id; RP_Id : Restriction_Parameter_Id; Id : Name_Id; Expr : Node_Id; Val : Uint; begin Check_Ada_83_Warning; Check_At_Least_N_Arguments (1); Check_Valid_Configuration_Pragma; Arg := Arg1; while Present (Arg) loop Id := Chars (Arg); Expr := Expression (Arg); -- Case of no restriction identifier if Id = No_Name then if Nkind (Expr) /= N_Identifier then Error_Pragma_Arg ("invalid form for restriction", Arg); else R_Id := Get_Restriction_Id (Chars (Expr)); if R_Id = Not_A_Restriction_Id then Error_Pragma_Arg ("invalid restriction identifier", Arg); -- Restriction is active else Restrictions (R_Id) := True; Restrictions_Loc (R_Id) := Sloc (N); -- Record the restriction if we are in the main unit, -- or in the extended main unit. The reason that we -- test separately for Main_Unit is that gnat.adc is -- processed with Current_Sem_Unit = Main_Unit, but -- nodes in gnat.adc do not appear to be the extended -- main source unit (they probably should do ???) if Current_Sem_Unit = Main_Unit or else In_Extended_Main_Source_Unit (N) then Main_Restrictions (R_Id) := True; end if; -- A very special case that must be processed here: -- pragma Restrictions (No_Exceptions) turns off all -- run-time checking. This is a bit dubious in terms -- of the formal language definition, but it is what -- is intended by the wording of RM H.4(12). if R_Id = No_Exceptions then Scope_Suppress := (others => True); end if; end if; end if; -- Case of restriction identifier present else RP_Id := Get_Restriction_Parameter_Id (Id); Analyze_And_Resolve (Expr, Any_Integer); if RP_Id = Not_A_Restriction_Parameter_Id then Error_Pragma_Arg ("invalid restriction parameter identifier", Arg); elsif not Is_OK_Static_Expression (Expr) or else not Is_Integer_Type (Etype (Expr)) or else Expr_Value (Expr) < 0 then Error_Pragma_Arg ("value must be non-negative static integer", Arg); -- Restriction pragma is active else Val := Expr_Value (Expr); -- Record pragma if most restrictive so far if Restriction_Parameters (RP_Id) = No_Uint or else Val < Restriction_Parameters (RP_Id) then Restriction_Parameters (RP_Id) := Expr_Value (Expr); Restriction_Parameters_Loc (RP_Id) := Sloc (N); end if; end if; end if; Next (Arg); end loop; end Restrictions_Pragma; ---------------- -- Reviewable -- ---------------- -- pragma Reviewable; when Pragma_Reviewable => Check_Ada_83_Warning; Check_Arg_Count (0); ------------------- -- Share_Generic -- ------------------- -- pragma Share_Generic (NAME {, NAME}); when Pragma_Share_Generic => GNAT_Pragma; Process_Generic_List; ------------ -- Shared -- ------------ -- pragma Shared (LOCAL_NAME); when Pragma_Shared => Process_Atomic_Shared_Volatile; -------------------- -- Shared_Passive -- -------------------- -- pragma Shared_Passive [(library_unit_NAME)]; -- Set the flag Is_Shared_Passive of program unit name entity when Pragma_Shared_Passive => Shared_Passive : declare Cunit_Node : Node_Id; Cunit_Ent : Entity_Id; begin Check_Ada_83_Warning; Check_Valid_Library_Unit_Pragma; if Nkind (N) = N_Null_Statement then return; end if; Cunit_Node := Cunit (Current_Sem_Unit); Cunit_Ent := Cunit_Entity (Current_Sem_Unit); if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration and then Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration then Error_Pragma ( "pragma% can only apply to a package declaration"); end if; Set_Is_Shared_Passive (Cunit_Ent); end Shared_Passive; ---------------------- -- Source_File_Name -- ---------------------- -- pragma Source_File_Name ( -- [UNIT_NAME =>] unit_NAME, -- [BODY_FILE_NAME | SPEC_FILE_NAME] => STRING_LITERAL); -- No processing here. Processing was completed during parsing, -- since we need to have file names set as early as possible. -- Units are loaded well before semantic processing starts. -- The only processing we defer to this point is the check -- for correct placement. when Pragma_Source_File_Name => GNAT_Pragma; Check_Valid_Configuration_Pragma; ---------------------- -- Source_Reference -- ---------------------- -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]); -- Nothing to do, all processing completed in Par.Prag, since we -- need the information for possible parser messages that are output when Pragma_Source_Reference => GNAT_Pragma; ------------------ -- Storage_Size -- ------------------ -- pragma Storage_Size (EXPRESSION); when Pragma_Storage_Size => Storage_Size : declare P : constant Node_Id := Parent (N); X : Node_Id; begin Check_No_Identifiers; Check_Arg_Count (1); -- Set In_Default_Expression for per-object case??? X := Expression (Arg1); Analyze_And_Resolve (X, Any_Integer); if not Is_Static_Expression (X) then Check_Restriction (Static_Storage_Size, X); end if; if Nkind (P) /= N_Task_Definition then Pragma_Misplaced; return; else if Has_Storage_Size_Pragma (P) then Error_Pragma ("duplicate pragma% not allowed"); else Set_Has_Storage_Size_Pragma (P, True); end if; Record_Rep_Item (Defining_Identifier (Parent (P)), N); -- ??? exp_ch9 should use this! end if; end Storage_Size; ------------------ -- Storage_Unit -- ------------------ -- pragma Storage_Unit (NUMERIC_LITERAL); -- Only permitted argument is System'Storage_Unit value when Pragma_Storage_Unit => Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Integer_Literal (Arg1); if Intval (Expression (Arg1)) /= UI_From_Int (Ttypes.System_Storage_Unit) then Error_Msg_Uint_1 := UI_From_Int (Ttypes.System_Storage_Unit); Error_Pragma_Arg ("the only allowed argument for pragma% is ^", Arg1); end if; -------------------- -- Stream_Convert -- -------------------- -- pragma Stream_Convert ( -- [Entity =>] type_LOCAL_NAME, -- [Read =>] function_NAME, -- [Write =>] function NAME); when Pragma_Stream_Convert => Stream_Convert : begin GNAT_Pragma; Check_Arg_Count (3); Check_Optional_Identifier (Arg1, Name_Entity); Check_Optional_Identifier (Arg2, Name_Read); Check_Optional_Identifier (Arg3, Name_Write); Check_Arg_Is_Local_Name (Arg1); Check_Non_Overloaded_Function (Arg2); Check_Non_Overloaded_Function (Arg3); declare Typ : constant Entity_Id := Underlying_Type (Entity (Expression (Arg1))); Read : constant Entity_Id := Entity (Expression (Arg2)); Write : constant Entity_Id := Entity (Expression (Arg3)); begin if Etype (Typ) = Any_Type or else Etype (Read) = Any_Type or else Etype (Write) = Any_Type then return; end if; Check_First_Subtype (Arg1); if Rep_Item_Too_Early (Typ, N) or else Rep_Item_Too_Late (Typ, N) then return; end if; if Underlying_Type (Etype (Read)) /= Typ then Error_Pragma_Arg ("incorrect return type for function&", Arg2); end if; if Underlying_Type (Etype (First_Formal (Write))) /= Typ then Error_Pragma_Arg ("incorrect parameter type for function&", Arg3); end if; if Underlying_Type (Etype (First_Formal (Read))) /= Underlying_Type (Etype (Write)) then Error_Pragma_Arg ("result type of & does not match Read parameter type", Arg3); end if; end; end Stream_Convert; ------------------------- -- Style_Checks (GNAT) -- ------------------------- -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL); -- This is processed by the parser since some of the style -- checks take place during source scanning and parsing. This -- means that we don't need to issue error messages here. when Pragma_Style_Checks => Style_Checks : declare A : constant Node_Id := Expression (Arg1); S : String_Id; C : Char_Code; begin GNAT_Pragma; Check_No_Identifiers; -- Two argument form if Arg_Count = 2 then Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off); declare E_Id : Node_Id; E : Entity_Id; begin E_Id := Expression (Arg2); Analyze (E_Id); if not Is_Entity_Name (E_Id) then Error_Pragma_Arg ("second argument of pragma% must be entity name", Arg2); end if; E := Entity (E_Id); if E = Any_Id then return; else loop Set_Suppress_Style_Checks (E, (Chars (Expression (Arg1)) = Name_Off)); exit when No (Homonym (E)); E := Homonym (E); end loop; end if; end; -- One argument form else Check_Arg_Count (1); if Nkind (A) = N_String_Literal then S := Strval (A); declare Slen : Natural := Natural (String_Length (S)); Options : String (1 .. Slen); J : Natural; begin J := 1; loop C := Get_String_Char (S, Int (J)); exit when not In_Character_Range (C); Options (J) := Get_Character (C); if J = Slen then Set_Style_Check_Options (Options); exit; else J := J + 1; end if; end loop; end; elsif Nkind (A) = N_Identifier then if Chars (A) = Name_All_Checks then Set_Default_Style_Check_Options; elsif Chars (A) = Name_On then Style_Check := True; elsif Chars (A) = Name_Off then Style_Check := False; end if; end if; end if; end Style_Checks; -------------- -- Subtitle -- -------------- -- pragma Subtitle ([Subtitle =>] STRING_LITERAL); when Pragma_Subtitle => GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Subtitle); Check_Arg_Is_String_Literal (Arg1); -------------- -- Suppress -- -------------- -- pragma Suppress (IDENTIFIER [, [On =>] NAME]); when Pragma_Suppress => Process_Suppress_Unsuppress (True); ------------------ -- Suppress_All -- ------------------ -- pragma Suppress_All; -- The only check made here is that the pragma appears in the -- proper place, i.e. following a compilation unit. If indeed -- it appears in this context, then the parser has already -- inserted an equivalent pragma Suppress (All_Checks) to get -- the required effect. when Pragma_Suppress_All => GNAT_Pragma; Check_Arg_Count (0); if Nkind (Parent (N)) /= N_Compilation_Unit_Aux or else not Is_List_Member (N) or else List_Containing (N) /= Pragmas_After (Parent (N)) then Error_Pragma ("misplaced pragma%, must follow compilation unit"); end if; ------------------------- -- Suppress_Debug_Info -- ------------------------- -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME); when Pragma_Suppress_Debug_Info => GNAT_Pragma; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); Check_Optional_Identifier (Arg1, Name_Entity); Set_Debug_Info_Off (Entity (Get_Pragma_Arg (Arg1))); ----------------------------- -- Suppress_Initialization -- ----------------------------- -- pragma Suppress_Initialization ([Entity =>] type_Name); when Pragma_Suppress_Initialization => Suppress_Init : declare E_Id : Node_Id; E : Entity_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Local_Name (Arg1); E_Id := Expression (Arg1); if Etype (E_Id) = Any_Type then return; end if; E := Entity (E_Id); if Is_Type (E) then if Is_Incomplete_Or_Private_Type (E) then if No (Full_View (Base_Type (E))) then Error_Pragma_Arg ("argument of pragma% cannot be an incomplete type", Arg1); else Set_Suppress_Init_Proc (Full_View (Base_Type (E))); end if; else Set_Suppress_Init_Proc (Base_Type (E)); end if; else Error_Pragma_Arg ("pragma% requires argument that is a type name", Arg1); end if; end Suppress_Init; ----------------- -- System_Name -- ----------------- -- pragma System_Name (DIRECT_NAME); -- Syntax check: one argument, which must be the identifier GNAT -- or the identifier GCC, no other identifiers are acceptable. when Pragma_System_Name => Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat); ----------------------------- -- Task_Dispatching_Policy -- ----------------------------- -- pragma Task_Dispatching_Policy (policy_IDENTIFIER); when Pragma_Task_Dispatching_Policy => declare DP : Character; begin Check_Ada_83_Warning; Check_Arg_Count (1); Check_No_Identifiers; Check_Arg_Is_Task_Dispatching_Policy (Arg1); Check_Valid_Configuration_Pragma; Get_Name_String (Chars (Expression (Arg1))); DP := Fold_Upper (Name_Buffer (1)); if Task_Dispatching_Policy /= ' ' and then Task_Dispatching_Policy /= DP then Error_Msg_Sloc := Task_Dispatching_Policy_Sloc; Error_Pragma ("task dispatching policy incompatible with policy#"); else Task_Dispatching_Policy := DP; Task_Dispatching_Policy_Sloc := Loc; end if; end; -------------- -- Task_Info -- -------------- -- pragma Task_Info (EXPRESSION); when Pragma_Task_Info => Task_Info : declare P : constant Node_Id := Parent (N); begin GNAT_Pragma; if Nkind (P) /= N_Task_Definition then Error_Pragma ("pragma% must appear in task definition"); end if; Check_No_Identifiers; Check_Arg_Count (1); Analyze_And_Resolve (Expression (Arg1), RTE (RE_Task_Info_Type)); if Etype (Expression (Arg1)) = Any_Type then return; end if; if Has_Task_Info_Pragma (P) then Error_Pragma ("duplicate pragma% not allowed"); else Set_Has_Task_Info_Pragma (P, True); end if; end Task_Info; --------------- -- Task_Name -- --------------- -- pragma Task_Name (string_EXPRESSION); when Pragma_Task_Name => Task_Name : declare -- pragma Priority (EXPRESSION); P : constant Node_Id := Parent (N); Arg : Node_Id; begin Check_No_Identifiers; Check_Arg_Count (1); Arg := Expression (Arg1); Analyze_And_Resolve (Arg, Standard_String); if Nkind (P) /= N_Task_Definition then Pragma_Misplaced; end if; if Has_Task_Name_Pragma (P) then Error_Pragma ("duplicate pragma% not allowed"); else Set_Has_Task_Name_Pragma (P, True); Record_Rep_Item (Defining_Identifier (Parent (P)), N); end if; end Task_Name; ------------------ -- Task_Storage -- ------------------ -- pragma Task_Storage ( -- [Task_Type =>] LOCAL_NAME, -- [Top_Guard =>] static_integer_EXPRESSION); when Pragma_Task_Storage => Task_Storage : declare Args : Args_List (1 .. 2); Names : Name_List (1 .. 2) := ( Name_Task_Type, Name_Top_Guard); Task_Type : Node_Id renames Args (1); Top_Guard : Node_Id renames Args (2); Ent : Entity_Id; begin GNAT_Pragma; Gather_Associations (Names, Args); Check_Arg_Is_Local_Name (Task_Type); Ent := Entity (Task_Type); if not Is_Task_Type (Ent) then Error_Pragma_Arg ("argument for pragma% must be task type", Task_Type); end if; if No (Top_Guard) then Error_Pragma_Arg ("pragma% takes two arguments", Task_Type); else Check_Arg_Is_Static_Expression (Top_Guard, Any_Integer); end if; Check_First_Subtype (Task_Type); if Rep_Item_Too_Late (Ent, N) then raise Pragma_Exit; end if; end Task_Storage; ---------------- -- Time_Slice -- ---------------- -- pragma Time_Slice (static_duration_EXPRESSION); when Pragma_Time_Slice => Time_Slice : declare Val : Ureal; Nod : Node_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_No_Identifiers; Check_In_Main_Program; Check_Arg_Is_Static_Expression (Arg1, Standard_Duration); if not Error_Posted (Arg1) then Nod := Next (N); while Present (Nod) loop if Nkind (Nod) = N_Pragma and then Chars (Nod) = Name_Time_Slice then Error_Msg_Name_1 := Chars (N); Error_Msg_N ("duplicate pragma% not permitted", Nod); end if; Next (Nod); end loop; end if; -- Process only if in main unit if Get_Source_Unit (Loc) = Main_Unit then Opt.Time_Slice_Set := True; Val := Expr_Value_R (Expression (Arg1)); if Val <= Ureal_0 then Opt.Time_Slice_Value := 0; elsif Val > UR_From_Uint (UI_From_Int (1000)) then Opt.Time_Slice_Value := 1_000_000_000; else Opt.Time_Slice_Value := UI_To_Int (UR_To_Uint (Val * UI_From_Int (1_000_000))); end if; end if; end Time_Slice; ----------- -- Title -- ----------- -- pragma Title (TITLING_OPTION [, TITLING OPTION]); -- TITLING_OPTION ::= -- [Title =>] STRING_LITERAL -- | [Subtitle =>] STRING_LITERAL when Pragma_Title => Title : declare Args : Args_List (1 .. 2); Names : Name_List (1 .. 2) := ( Name_Title, Name_Subtitle); begin GNAT_Pragma; Gather_Associations (Names, Args); for J in 1 .. 2 loop if Present (Args (J)) then Check_Arg_Is_String_Literal (Args (J)); end if; end loop; end Title; --------------------- -- Unchecked_Union -- --------------------- -- pragma Unchecked_Union (first_subtype_LOCAL_NAME) when Pragma_Unchecked_Union => Unchecked_Union : declare Assoc : Node_Id := Arg1; Type_Id : Node_Id := Expression (Assoc); Typ : Entity_Id; Discr : Entity_Id; Tdef : Node_Id; Clist : Node_Id; Vpart : Node_Id; Comp : Node_Id; Variant : Node_Id; begin GNAT_Pragma; Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); Find_Type (Type_Id); Typ := Entity (Type_Id); if Typ = Any_Type or else Rep_Item_Too_Early (Typ, N) then return; else Typ := Underlying_Type (Typ); end if; if Rep_Item_Too_Late (Typ, N) then return; end if; Check_First_Subtype (Arg1); -- Note remaining cases are references to a type in the current -- declarative part. If we find an error, we post the error on -- the relevant type declaration at an appropriate point. if not Is_Record_Type (Typ) then Error_Msg_N ("Unchecked_Union must be record type", Typ); return; elsif Is_Tagged_Type (Typ) then Error_Msg_N ("Unchecked_Union must not be tagged", Typ); return; elsif Is_Limited_Type (Typ) then Error_Msg_N ("Unchecked_Union must not be limited record type", Typ); return; else if not Has_Discriminants (Typ) then Error_Msg_N ("Unchecked_Union must have one discriminant", Typ); return; end if; Discr := First_Discriminant (Typ); if Present (Next_Discriminant (Discr)) then Error_Msg_N ("Unchecked_Union must have exactly one discriminant", Next_Discriminant (Discr)); return; end if; if No (Discriminant_Default_Value (Discr)) then Error_Msg_N ("Unchecked_Union discriminant must have default value", Discr); end if; Tdef := Type_Definition (Declaration_Node (Typ)); Clist := Component_List (Tdef); if No (Clist) or else No (Variant_Part (Clist)) then Error_Msg_N ("Unchecked_Union must have variant part", Tdef); return; end if; Vpart := Variant_Part (Clist); if Is_Non_Empty_List (Component_Items (Clist)) then Error_Msg_N ("components before variant not allowed " & "in Unchecked_Union", First (Component_Items (Clist))); end if; Variant := First (Variants (Vpart)); while Present (Variant) loop Clist := Component_List (Variant); if Present (Variant_Part (Clist)) then Error_Msg_N ("Unchecked_Union may not have nested variants", Variant_Part (Clist)); end if; if not Is_Non_Empty_List (Component_Items (Clist)) then Error_Msg_N ("Unchecked_Union may not have empty component list", Variant); return; end if; Comp := First (Component_Items (Clist)); if Nkind (Comp) = N_Component_Declaration then if Present (Expression (Comp)) then Error_Msg_N ("default initialization not allowed " & "in Unchecked_Union", Expression (Comp)); end if; declare Sindic : constant Node_Id := Subtype_Indication (Comp); begin if Nkind (Sindic) = N_Subtype_Indication then Check_Static_Constraint (Constraint (Sindic)); end if; end; end if; if Present (Next (Comp)) then Error_Msg_N ("Unchecked_Union variant can have only one component", Next (Comp)); end if; Next (Variant); end loop; end if; Set_Is_Unchecked_Union (Typ, True); Set_Suppress_Discriminant_Checks (Typ, True); Set_Convention (Typ, Convention_C); Set_Has_Unchecked_Union (Base_Type (Typ), True); Set_Is_Unchecked_Union (Base_Type (Typ), True); end Unchecked_Union; ------------------------ -- Unimplemented_Unit -- ------------------------ -- pragma Unimplemented_Unit; -- Note: this only gives an error if we are generating code, -- or if we are in a generic library unit (where the pragma -- appears in the body, not in the spec). when Pragma_Unimplemented_Unit => Unimplemented_Unit : declare Cunitent : Entity_Id := Cunit_Entity (Get_Source_Unit (Loc)); Ent_Kind : Entity_Kind := Ekind (Cunitent); begin GNAT_Pragma; Check_Arg_Count (0); if Operating_Mode = Generate_Code or else Ent_Kind = E_Generic_Function or else Ent_Kind = E_Generic_Procedure or else Ent_Kind = E_Generic_Package then Get_Name_String (Chars (Cunitent)); Set_Casing (Mixed_Case); Write_Str (Name_Buffer (1 .. Name_Len)); Write_Str (" is not implemented"); Write_Eol; raise Unrecoverable_Error; end if; end Unimplemented_Unit; ------------------------------ -- Unreserve_All_Interrupts -- ------------------------------ -- pragma Unreserve_All_Interrupts; when Pragma_Unreserve_All_Interrupts => GNAT_Pragma; Check_Arg_Count (0); if In_Extended_Main_Code_Unit (Main_Unit_Entity) then Unreserve_All_Interrupts := True; end if; ---------------- -- Unsuppress -- ---------------- -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]); when Pragma_Unsuppress => GNAT_Pragma; Process_Suppress_Unsuppress (False); ------------------- -- Use_VADS_Size -- ------------------- -- pragma Use_VADS_Size; when Pragma_Use_VADS_Size => GNAT_Pragma; Check_Arg_Count (0); Check_Valid_Configuration_Pragma; Use_VADS_Size := True; --------------------- -- Validity_Checks -- --------------------- -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL); when Pragma_Validity_Checks => Validity_Checks : declare A : constant Node_Id := Expression (Arg1); S : String_Id; C : Char_Code; begin GNAT_Pragma; Check_Arg_Count (1); Check_No_Identifiers; if Nkind (A) = N_String_Literal then S := Strval (A); declare Slen : Natural := Natural (String_Length (S)); Options : String (1 .. Slen); J : Natural; begin J := 1; loop C := Get_String_Char (S, Int (J)); exit when not In_Character_Range (C); Options (J) := Get_Character (C); if J = Slen then Set_Validity_Check_Options (Options); exit; else J := J + 1; end if; end loop; end; elsif Nkind (A) = N_Identifier then if Chars (A) = Name_All_Checks then Set_Validity_Check_Options ("a"); elsif Chars (A) = Name_On then Validity_Checks_On := True; elsif Chars (A) = Name_Off then Validity_Checks_On := False; end if; end if; end Validity_Checks; -------------- -- Volatile -- -------------- -- pragma Volatile (LOCAL_NAME); when Pragma_Volatile => Process_Atomic_Shared_Volatile; ------------------------- -- Volatile_Components -- ------------------------- -- pragma Volatile_Components (array_LOCAL_NAME); -- Volatile is handled by the same circuit as Atomic_Components -------------- -- Warnings -- -------------- -- pragma Warnings (On | Off, [LOCAL_NAME]) when Pragma_Warnings => GNAT_Pragma; Check_At_Least_N_Arguments (1); Check_At_Most_N_Arguments (2); Check_No_Identifiers; -- One argument case was processed by parser in Par.Prag if Arg_Count /= 1 then Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off); Check_Arg_Count (2); declare E_Id : Node_Id; E : Entity_Id; begin E_Id := Expression (Arg2); Analyze (E_Id); if not Is_Entity_Name (E_Id) then Error_Pragma_Arg ("second argument of pragma% must be entity name", Arg2); end if; E := Entity (E_Id); if E = Any_Id then return; else loop Set_Warnings_Off (E, (Chars (Expression (Arg1)) = Name_Off)); if Is_Enumeration_Type (E) then declare Lit : Entity_Id := First_Literal (E); begin while Present (Lit) loop Set_Warnings_Off (Lit); Next_Literal (Lit); end loop; end; end if; exit when No (Homonym (E)); E := Homonym (E); end loop; end if; end; end if; ------------------- -- Weak_External -- ------------------- -- pragma Weak_External ([Entity =>] LOCAL_NAME); when Pragma_Weak_External => Weak_External : declare Ent : Entity_Id; begin GNAT_Pragma; Check_Arg_Count (1); Check_Optional_Identifier (Arg1, Name_Entity); Check_Arg_Is_Library_Level_Local_Name (Arg1); Ent := Entity (Expression (Arg1)); if Rep_Item_Too_Early (Ent, N) then return; else Ent := Underlying_Type (Ent); end if; -- The only processing required is to link this item on to the -- list of rep items for the given entity. This is accomplished -- by the call to Rep_Item_Too_Late (when no error is detected -- and False is returned). if Rep_Item_Too_Late (Ent, N) then return; else Set_Has_Gigi_Rep_Item (Ent); end if; end Weak_External; end case; exception when Pragma_Exit => null; end Analyze_Pragma; ------------------------- -- Get_Base_Subprogram -- ------------------------- function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is Result : Entity_Id; begin Result := Def_Id; -- Follow subprogram renaming chain while Is_Subprogram (Result) and then (Is_Generic_Instance (Result) or else Nkind (Parent (Declaration_Node (Result))) = N_Subprogram_Renaming_Declaration) and then Present (Alias (Result)) loop Result := Alias (Result); end loop; return Result; end Get_Base_Subprogram; --------------------------- -- Is_Generic_Subprogram -- --------------------------- function Is_Generic_Subprogram (Id : Entity_Id) return Boolean is begin return Ekind (Id) = E_Generic_Procedure or else Ekind (Id) = E_Generic_Function; end Is_Generic_Subprogram; ------------------------------ -- Is_Pragma_String_Literal -- ------------------------------ -- This function returns true if the corresponding pragma argument is -- a static string expression. These are the only cases in which string -- literals can appear as pragma arguments. We also allow a string -- literal as the first argument to pragma Assert (although it will -- of course always generate a type error). function Is_Pragma_String_Literal (Par : Node_Id) return Boolean is Pragn : constant Node_Id := Parent (Par); Assoc : constant List_Id := Pragma_Argument_Associations (Pragn); Pname : constant Name_Id := Chars (Pragn); Argn : Natural; N : Node_Id; begin Argn := 1; N := First (Assoc); loop exit when N = Par; Argn := Argn + 1; Next (N); end loop; if Pname = Name_Assert then return True; elsif Pname = Name_Export then return Argn > 2; elsif Pname = Name_Ident then return Argn = 1; elsif Pname = Name_Import then return Argn > 2; elsif Pname = Name_Interface_Name then return Argn > 1; elsif Pname = Name_Linker_Alias then return Argn = 2; elsif Pname = Name_Linker_Section then return Argn = 2; elsif Pname = Name_Machine_Attribute then return Argn = 2; elsif Pname = Name_Source_File_Name then return True; elsif Pname = Name_Source_Reference then return Argn = 2; elsif Pname = Name_Title then return True; elsif Pname = Name_Subtitle then return True; else return False; end if; end Is_Pragma_String_Literal; -------------------------------------- -- Process_Compilation_Unit_Pragmas -- -------------------------------------- procedure Process_Compilation_Unit_Pragmas (N : Node_Id) is begin -- A special check for pragma Suppress_All. This is a strange DEC -- pragma, strange because it comes at the end of the unit. If we -- have a pragma Suppress_All in the Pragmas_After of the current -- unit, then we insert a pragma Suppress (All_Checks) at the start -- of the context clause to ensure the correct processing. declare PA : constant List_Id := Pragmas_After (Aux_Decls_Node (N)); P : Node_Id; begin if Present (PA) then P := First (PA); while Present (P) loop if Chars (P) = Name_Suppress_All then Prepend_To (Context_Items (N), Make_Pragma (Sloc (P), Chars => Name_Suppress, Pragma_Argument_Associations => New_List ( Make_Pragma_Argument_Association (Sloc (P), Expression => Make_Identifier (Sloc (P), Chars => Name_All_Checks))))); exit; end if; Next (P); end loop; end if; end; end Process_Compilation_Unit_Pragmas; -------------------------------- -- Set_Encoded_Interface_Name -- -------------------------------- procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id) is Str : constant String_Id := Strval (S); Len : constant Int := String_Length (Str); CC : Char_Code; C : Character; J : Int; Hex : constant array (0 .. 15) of Character := "0123456789abcdef"; procedure Encode; -- Stores encoded value of character code CC. The encoding we -- use an underscore followed by four lower case hex digits. procedure Encode is begin Store_String_Char (Get_Char_Code ('_')); Store_String_Char (Get_Char_Code (Hex (Integer (CC / 2 ** 12)))); Store_String_Char (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#)))); Store_String_Char (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#)))); Store_String_Char (Get_Char_Code (Hex (Integer (CC and 16#0F#)))); end Encode; -- Start of processing for Set_Encoded_Interface_Name begin -- If first character is asterisk, this is a link name, and we -- leave it completely unmodified. We also ignore null strings -- (the latter case happens only in error cases) and no encoding -- should occur for Java interface names. if Len = 0 or else Get_String_Char (Str, 1) = Get_Char_Code ('*') or else Java_VM then Set_Interface_Name (E, S); else J := 1; loop CC := Get_String_Char (Str, J); exit when not In_Character_Range (CC); C := Get_Character (CC); exit when C /= '_' and then C /= '$' and then C not in '0' .. '9' and then C not in 'a' .. 'z' and then C not in 'A' .. 'Z'; if J = Len then Set_Interface_Name (E, S); return; else J := J + 1; end if; end loop; -- Here we need to encode. The encoding we use as follows: -- three underscores + four hex digits (lower case) Start_String; for J in 1 .. String_Length (Str) loop CC := Get_String_Char (Str, J); if not In_Character_Range (CC) then Encode; else C := Get_Character (CC); if C = '_' or else C = '$' or else C in '0' .. '9' or else C in 'a' .. 'z' or else C in 'A' .. 'Z' then Store_String_Char (CC); else Encode; end if; end if; end loop; Set_Interface_Name (E, Make_String_Literal (Sloc (S), Strval => End_String)); end if; end Set_Encoded_Interface_Name; ------------------- -- Set_Unit_Name -- ------------------- procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id) is Pref : Node_Id; Scop : Entity_Id; begin if Nkind (N) = N_Identifier and then Nkind (With_Item) = N_Identifier then Set_Entity (N, Entity (With_Item)); elsif Nkind (N) = N_Selected_Component then Change_Selected_Component_To_Expanded_Name (N); Set_Entity (N, Entity (With_Item)); Set_Entity (Selector_Name (N), Entity (N)); Pref := Prefix (N); Scop := Scope (Entity (N)); while Nkind (Pref) = N_Selected_Component loop Change_Selected_Component_To_Expanded_Name (Pref); Set_Entity (Selector_Name (Pref), Scop); Set_Entity (Pref, Scop); Pref := Prefix (Pref); Scop := Scope (Scop); end loop; Set_Entity (Pref, Scop); end if; end Set_Unit_Name; end Sem_Prag;
alloy4fun_models/trashltl/models/19/iiRMTNBjJfNNXgHP2.als
Kaixi26/org.alloytools.alloy
0
5271
<gh_stars>0 open main pred idiiRMTNBjJfNNXgHP2_prop20 { always all f : File | f not in Protected triggered f in Trash } pred __repair { idiiRMTNBjJfNNXgHP2_prop20 } check __repair { idiiRMTNBjJfNNXgHP2_prop20 <=> prop20o }
src/main/antlr4/com/github/vlsi/iec61131/parser/IEC61131.g4
vlsi/iec61131-parser
25
5562
<reponame>vlsi/iec61131-parser<filename>src/main/antlr4/com/github/vlsi/iec61131/parser/IEC61131.g4<gh_stars>10-100 /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ grammar IEC61131; pou : function | function_block ; function: 'FUNCTION' name=ID ':' type=type_rule var_blocks+=var_block*; function_block: 'FUNCTION_BLOCK' name=ID var_blocks+=var_block*; var_block locals[boolean input, boolean output, boolean temp] : ('VAR' | { $input=true; } 'VAR_INPUT' | { $output=true; } 'VAR_OUTPUT' | { $input=$output=true; } 'VAR_INPUT_OUTPUT' | { $temp=true; } 'VAR_TEMP') ( variables+=variable_declaration* 'END_VAR'); type_rule: name=ID #simpleType | array=array_type #arrayType | pointer=pointer_type #pointerType ; array_type : 'ARRAY' '[' ranges+=range (',' ranges+=range)* ']' 'OF' type=type_rule; range : lbound=integer_literal '..' ubound=integer_literal; pointer_type: 'POINTER' 'TO' type=type_rule; variable_declaration: names+=ID (',' names+=ID)* ':' type=type_rule (':=' initializer=variable_initializer)? ';' ; variable_initializer: literal; literal: numeric_literal | string_literal | boolean_literal; boolean_literal: 'TRUE' | 'FALSE'; numeric_literal : '-'? integer_literal | '-'? Floating_point_literal ; integer_literal : Binary_literal | Octal_literal | Decimal_literal | Pure_decimal_digits | Hexadecimal_literal ; Binary_literal : '2#' Binary_digit Binary_literal_characters? ; fragment Binary_digit : [01] ; fragment Binary_literal_character : Binary_digit | '_' ; fragment Binary_literal_characters : Binary_literal_character+ ; Octal_literal : '8#' Octal_digit Octal_literal_characters? ; fragment Octal_digit : [0-7] ; fragment Octal_literal_character : Octal_digit | '_' ; fragment Octal_literal_characters : Octal_literal_character+ ; Decimal_literal : [0-9] [0-9_]* ; Pure_decimal_digits : [0-9]+ ; fragment Decimal_digit : [0-9] ; fragment Decimal_literal_character : Decimal_digit | '_' ; fragment Decimal_literal_characters : Decimal_literal_character+ ; Hexadecimal_literal : '16#' Hexadecimal_digit Hexadecimal_literal_characters? ; fragment Hexadecimal_digit : [0-9a-fA-F] ; fragment Hexadecimal_literal_character : Hexadecimal_digit | '_' ; fragment Hexadecimal_literal_characters : Hexadecimal_literal_character+ ; Floating_point_literal : Decimal_literal Decimal_fraction? Decimal_exponent? ; fragment Decimal_fraction : '.' Decimal_literal ; fragment Decimal_exponent : Floating_point_e Sign? Decimal_literal ; fragment Floating_point_e : [eE] ; fragment Floating_point_p : [pP] ; fragment Sign : [+\-] ; string_literal : Static_string_literal ; Static_string_literal : '\'' Quoted_text? '\'' ; fragment Quoted_text : Quoted_text_item+ ; fragment Quoted_text_item : Escaped_character | ~["\n\r\\] ; fragment Escaped_character : '$' [$'LNPRT] | '$' Hexadecimal_digit Hexadecimal_digit ; ID: [A-Za-z][A-Za-z_0-9]*; WS : [ \n\r\t]+ -> channel(HIDDEN) ; Block_comment : '(*' (Block_comment|.)*? '*)' -> channel(HIDDEN) ; // nesting comments allowed
oeis/349/A349595.asm
neoneye/loda-programs
11
83410
; A349595: Number of self-counting sequences of length n (sequences indexed from 0 to (n-1) where a(i) is the number of times i appears in the sequence). ; Submitted by <NAME> ; 0,0,0,2,1,0,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,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 add $0,1 mov $2,6 mov $3,6 div $3,$0 pow $2,$3 mod $2,$0 mov $0,$2
programs/oeis/190/A190719.asm
karttu/loda
0
96073
; A190719: Numbers that are congruent to {0, 1, 3, 5, 7, 8, 11} mod 12. ; 0,1,3,5,7,8,11,12,13,15,17,19,20,23,24,25,27,29,31,32,35,36,37,39,41,43,44,47,48,49,51,53,55,56,59,60,61,63,65,67,68,71,72,73,75,77,79,80,83,84,85,87,89,91,92,95,96,97,99,101,103,104,107,108,109,111 mov $3,$0 add $0,2 lpb $0,1 sub $0,1 trn $0,2 add $1,2 mov $2,0 add $2,$0 trn $0,3 add $2,$1 mov $1,$2 sub $1,$0 trn $0,1 lpe lpb $3,1 add $1,1 sub $3,1 lpe sub $1,2
RefactorAgdaEngine/Test/Tests/ManualTestFiles/BabyAgda.agda
omega12345/RefactorAgda
5
815
module BabyAgda where data Nat : Set where zero : Nat suc : Nat -> Nat stuff : Nat nonDependent : Nat -> Nat -> Nat nonDependent a b = a dependent : {A : Set} -> A -> A dependent a = a asdf : {A : Set} -> {B : Nat} -> {renameMe0 : Nat} -> Nat asdf {_} {_} {zero} = zero asdf {_} {_} {suc c} = dependent c
llvm-gcc-4.2-2.9/gcc/ada/xgnatugn.adb
vidkidz/crossbridge
1
15378
<reponame>vidkidz/crossbridge<gh_stars>1-10 ------------------------------------------------------------------------------ -- -- -- GNAT SYSTEM UTILITIES -- -- -- -- X G N A T U G N -- -- -- -- B o d y -- -- -- -- Copyright (C) 2003-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- ------------------------------------------------------------------------------ -- This utility is used to process the source of gnat_ugn.texi to make a -- version suitable for running through standard Texinfo processor. It is -- invoked as follows: -- xgnatugn <target> <in-file> <word-list> [ <out-file> [ <warnings> ] ] -- 1. <target> is the target type of the manual, which is one of: -- unw Unix and Windows platforms -- vms OpenVMS -- 2. <in-file> is the file name of the Texinfo file to be -- preprocessed. -- 3. <word-list> is the name of the word list file. This file is used for -- rewriting the VMS edition. Each line contains a word mapping: The source -- word in the first column, the target word in the second column. The -- columns are separated by a '^' character. When preprocessing for VMS, the -- first word is replaced with the second. (Words consist of letters, -- digits, and the four characters "?-_~". A sequence of multiple words can -- be replaced if they are listed in the first column, separated by a single -- space character. If multiple words are to be replaced, there must be a -- replacement for each prefix.) -- 4. <out-file> (optional) is the name of the output file. It defaults to -- gnat_ugn_unw.texi or gnat_ugn_vms.texi, depending on the target. -- 5. <warnings> (optional, and allowed only if <out-file> is explicit) -- can be any string. If present, it indicates that warning messages are -- to be output to Standard_Error. If absent, no warning messages are -- generated. -- The following steps are performed: -- In VMS mode -- Any occurrences of ^alpha^beta^ are replaced by beta. The sequence -- must fit on a single line, and there can only be one occurrence on a -- line. -- Any occurrences of a word in the Ug_Words list are replaced by the -- appropriate vms equivalents. Note that replacements do not occur -- within ^alpha^beta^ sequences. -- Any occurence of [filename].extension, where extension one of the -- following: -- "o", "ads", "adb", "ali", "ada", "atb", "ats", "adc", "c" -- replaced by the appropriate VMS names (all upper case with .o -- replaced .OBJ). Note that replacements do not occur within -- ^alpha^beta^ sequences. -- In UNW mode -- Any occurrences of ^alpha^beta^ are replaced by alpha. The sequence -- must fit on a single line. -- In both modes -- The sequence ^^^ is replaced by a single ^. This escape sequence -- must be used if the literal character ^ is to appear in the -- output. A line containing this escape sequence may not also contain -- a ^alpha^beta^ sequence. -- Process @ifset and @ifclear for the target flags (unw, vms); -- this is because we have menu problems if we let makeinfo handle -- these ifset/ifclear pairs. -- Note: @ifset/@ifclear commands for the edition flags (FSFEDITION, -- PROEDITION, ACADEMICEDITION) are passed through unchanged with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Maps; use Ada.Strings.Maps; with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants; with Ada.Text_IO; use Ada.Text_IO; with GNAT.Spitbol; use GNAT.Spitbol; with GNAT.Spitbol.Table_VString; use GNAT.Spitbol.Table_VString; procedure Xgnatugn is procedure Usage; -- Print usage information. Invoked if an invalid command line is -- encountered. Output_File : File_Type; -- The preprocessed output is written to this file type Input_File is record Name : VString; Data : File_Type; Line : Natural := 0; end record; -- Records information on an input file. Name and Line are used -- in error messages, Line is updated automatically by Get_Line. function Get_Line (Input : access Input_File) return String; -- Returns a line from Input and performs the necessary -- line-oriented checks (length, character set, trailing spaces). Number_Of_Warnings : Natural := 0; Number_Of_Errors : Natural := 0; Warnings_Enabled : Boolean; procedure Error (Input : Input_File; At_Character : Natural; Message : String); procedure Error (Input : Input_File; Message : String); -- Prints a message reporting an error on line Input.Line. If -- At_Character is not 0, indicate the exact character at which -- the error occurs. procedure Warning (Input : Input_File; At_Character : Natural; Message : String); procedure Warning (Input : Input_File; Message : String); -- Like Error, but just print a warning message Dictionary_File : aliased Input_File; procedure Read_Dictionary_File; -- Dictionary_File is opened using the name given on the command -- line. It contains the replacements for the Ug_Words list. -- Read_Dictionary_File reads Dictionary_File and fills the -- Ug_Words table. Source_File : aliased Input_File; procedure Process_Source_File; -- Source_File is opened using the name given on the command line. -- It contains the Texinfo source code. Process_Source_File -- performs the necessary replacements. type Flag_Type is (UNW, VMS, FSFEDITION, PROEDITION, ACADEMICEDITION); -- The flags permitted in @ifset or @ifclear commands: -- -- Targets for preprocessing -- UNW (Unix and Windows) or VMS -- -- Editions of the manual -- FSFEDITION, PROEDITION, or ACADEMICEDITION -- -- Conditional commands for target are processed by xgnatugn -- -- Conditional commands for edition are passed through unchanged subtype Target_Type is Flag_Type range UNW .. VMS; subtype Edition_Type is Flag_Type range FSFEDITION .. ACADEMICEDITION; Target : Target_Type; -- The Target variable is initialized using the command line Valid_Characters : constant Character_Set := To_Set (Span => (' ', '~')); -- This array controls which characters are permitted in the input -- file (after line breaks have been removed). Valid characters -- are all printable ASCII characters and the space character. Word_Characters : constant Character_Set := (To_Set (Ranges => (('0', '9'), ('a', 'z'), ('A', 'Z'))) or To_Set ("?-_~")); -- The characters which are permitted in words. Other (valid) -- characters are assumed to be delimiters between words. Note that -- this set has to include all characters of the source words of the -- Ug_Words dictionary. Reject_Trailing_Spaces : constant Boolean := True; -- Controls whether Xgnatug rejects superfluous space characters -- at the end of lines. Maximum_Line_Length : constant Positive := 79; Fatal_Line_Length_Limit : constant Positive := 5000; Fatal_Line_Length : exception; -- If Maximum_Line_Length is exceeded in an input file, an error -- message is printed. If Fatal_Line_Length is exceeded, -- execution terminates with a Fatal_Line_Length exception. VMS_Escape_Character : constant Character := '^'; -- The character used to mark VMS alternatives (^alpha^beta^) Extensions : GNAT.Spitbol.Table_VString.Table (20); procedure Initialize_Extensions; -- This table records extensions and their replacement for -- rewriting filenames in the VMS version of the manual. function Is_Extension (Extension : String) return Boolean; function Get_Replacement_Extension (Extension : String) return String; -- These functions query the replacement table. Is_Extension -- checks if the given string is a known extension. -- Get_Replacement returns the replacement extension. Ug_Words : GNAT.Spitbol.Table_VString.Table (200); function Is_Known_Word (Word : String) return Boolean; function Get_Replacement_Word (Word : String) return String; -- The Ug_Words table lists replacement words for the VMS version -- of the manual. Is_Known_Word and Get_Replacement_Word query -- this table. The table is filled using Read_Dictionary_File. function Rewrite_Source_Line (Line : String) return String; -- This subprogram takes a line and rewrites it according to Target. -- It relies on information in Source_File to generate error messages. type Conditional is (Set, Clear); procedure Push_Conditional (Cond : Conditional; Flag : Target_Type); procedure Pop_Conditional (Cond : Conditional); -- These subprograms deal with conditional processing (@ifset/@ifclear). -- They rely on information in Source_File to generate error messages. function Currently_Excluding return Boolean; -- Returns true if conditional processing directives imply that the -- current line should not be included in the output. function VMS_Context_Determined return Boolean; -- Returns true if, in the current conditional preprocessing context, we -- always have a VMS or a non-VMS version, regardless of the value of -- Target. function In_VMS_Section return Boolean; -- Returns True if in an "@ifset vms" section procedure Check_No_Pending_Conditional; -- Checks that all preprocessing directives have been properly matched by -- their @end counterpart. If this is not the case, print an error -- message. -- The following definitions implement a stack to track the conditional -- preprocessing context. type Conditional_Context is record Starting_Line : Positive; Cond : Conditional; Flag : Flag_Type; Excluding : Boolean; end record; Conditional_Stack_Depth : constant := 3; Conditional_Stack : array (1 .. Conditional_Stack_Depth) of Conditional_Context; Conditional_TOS : Natural := 0; -- Pointer to the Top Of Stack for Conditional_Stack ----------- -- Usage -- ----------- procedure Usage is begin Put_Line (Standard_Error, "usage: xgnatugn TARGET SOURCE DICTIONARY [OUTFILE [WARNINGS]]"); New_Line; Put_Line (Standard_Error, "TARGET is one of:"); for T in Target_Type'Range loop Put_Line (Standard_Error, " " & Target_Type'Image (T)); end loop; New_Line; Put_Line (Standard_Error, "SOURCE is the source file to process."); New_Line; Put_Line (Standard_Error, "DICTIONARY is the name of a file " & "that contains word replacements"); Put_Line (Standard_Error, "for the VMS version."); New_Line; Put_Line (Standard_Error, "OUT-FILE, if present, is the output file to be created;"); Put_Line (Standard_Error, "If OUT-FILE is absent, the output file is either " & "gnat_ugn_unw.texi, "); Put_Line (Standard_Error, "or gnat_ugn_vms.texi, depending on TARGET."); New_Line; Put_Line (Standard_Error, "WARNINGS, if present, is any string;"); Put_Line (Standard_Error, "it will result in warning messages (e.g., line too long))"); Put_Line (Standard_Error, "being output to Standard_Error."); end Usage; -------------- -- Get_Line -- -------------- function Get_Line (Input : access Input_File) return String is Line_Buffer : String (1 .. Fatal_Line_Length_Limit); Last : Natural; begin Input.Line := Input.Line + 1; Get_Line (Input.Data, Line_Buffer, Last); if Last = Line_Buffer'Last then Error (Input.all, "line exceeds fatal line length limit"); raise Fatal_Line_Length; end if; declare Line : String renames Line_Buffer (Line_Buffer'First .. Last); begin for J in Line'Range loop if not Is_In (Line (J), Valid_Characters) then Error (Input.all, J, "invalid character"); exit; end if; end loop; if Line'Length > Maximum_Line_Length then Warning (Input.all, Maximum_Line_Length + 1, "line too long"); end if; if Reject_Trailing_Spaces and then Line'Length > 0 and then Line (Line'Last) = ' ' then Error (Input.all, Line'Last, "trailing space character"); end if; return Trim (Line, Right); end; end Get_Line; ----------- -- Error -- ----------- procedure Error (Input : Input_File; Message : String) is begin Error (Input, 0, Message); end Error; procedure Error (Input : Input_File; At_Character : Natural; Message : String) is Line_Image : constant String := Integer'Image (Input.Line); At_Character_Image : constant String := Integer'Image (At_Character); -- These variables are required because we have to drop the leading -- space character. begin Number_Of_Errors := Number_Of_Errors + 1; if At_Character > 0 then Put_Line (Standard_Error, S (Input.Name) & ':' & Line_Image (Line_Image'First + 1 .. Line_Image'Last) & ':' & At_Character_Image (At_Character_Image'First + 1 .. At_Character_Image'Last) & ": " & Message); else Put_Line (Standard_Error, S (Input.Name) & ':' & Line_Image (Line_Image'First + 1 .. Line_Image'Last) & ": " & Message); end if; end Error; ------------- -- Warning -- ------------- procedure Warning (Input : Input_File; Message : String) is begin if Warnings_Enabled then Warning (Input, 0, Message); end if; end Warning; procedure Warning (Input : Input_File; At_Character : Natural; Message : String) is Line_Image : constant String := Integer'Image (Input.Line); At_Character_Image : constant String := Integer'Image (At_Character); -- These variables are required because we have to drop the leading -- space character. begin if not Warnings_Enabled then return; end if; Number_Of_Warnings := Number_Of_Warnings + 1; if At_Character > 0 then Put_Line (Standard_Error, S (Input.Name) & ':' & Line_Image (Line_Image'First + 1 .. Line_Image'Last) & ':' & At_Character_Image (At_Character_Image'First + 1 .. At_Character_Image'Last) & ": warning: " & Message); else Put_Line (Standard_Error, S (Input.Name) & ':' & Line_Image (Line_Image'First + 1 .. Line_Image'Last) & ": warning: " & Message); end if; end Warning; -------------------------- -- Read_Dictionary_File -- -------------------------- procedure Read_Dictionary_File is begin while not End_Of_File (Dictionary_File.Data) loop declare Line : constant String := Get_Line (Dictionary_File'Access); Split : constant Natural := Index (Line, (1 => VMS_Escape_Character)); begin if Line'Length = 0 then Error (Dictionary_File, "empty line in dictionary file"); elsif Line (Line'First) = ' ' then Error (Dictionary_File, 1, "line starts with space character"); elsif Split = 0 then Error (Dictionary_File, "line does not contain " & VMS_Escape_Character & " character"); else declare Source : constant String := Trim (Line (1 .. Split - 1), Both); Target : constant String := Trim (Line (Split + 1 .. Line'Last), Both); Two_Spaces : constant Natural := Index (Source, " "); Non_Word_Character : constant Natural := Index (Source, Word_Characters or To_Set (" "), Outside); begin if Two_Spaces /= 0 then Error (Dictionary_File, Two_Spaces, "multiple space characters in source word"); end if; if Non_Word_Character /= 0 then Error (Dictionary_File, Non_Word_Character, "illegal character in source word"); end if; if Source'Length = 0 then Error (Dictionary_File, "source is empty"); elsif Target'Length = 0 then Error (Dictionary_File, "target is empty"); else Set (Ug_Words, Source, V (Target)); -- Ensure that if Source is a sequence of words -- "WORD1 WORD2 ...", we already have a mapping for -- "WORD1". for J in Source'Range loop if Source (J) = ' ' then declare Prefix : String renames Source (Source'First .. J - 1); begin if not Is_Known_Word (Prefix) then Error (Dictionary_File, "prefix '" & Prefix & "' not known at this point"); end if; end; end if; end loop; end if; end; end if; end; end loop; end Read_Dictionary_File; ------------------------- -- Rewrite_Source_Line -- ------------------------- function Rewrite_Source_Line (Line : String) return String is -- We use a simple lexer to split the line into tokens: -- Word consisting entirely of Word_Characters -- VMS_Alternative ^alpha^beta^ replacement (but not ^^^) -- Space a space character -- Other everything else (sequence of non-word characters) -- VMS_Error incomplete VMS alternative -- End_Of_Line no more characters on this line -- A sequence of three VMS_Escape_Characters is automatically -- collapsed to an Other token. type Token_Span is record First, Last : Positive; end record; -- The character range covered by a token in Line type Token_Kind is (End_Of_Line, Word, Other, VMS_Alternative, VMS_Error); type Token_Record (Kind : Token_Kind := End_Of_Line) is record First : Positive; case Kind is when Word | Other => Span : Token_Span; when VMS_Alternative => Non_VMS, VMS : Token_Span; when VMS_Error | End_Of_Line => null; end case; end record; Input_Position : Positive := Line'First; Token : Token_Record; -- The position of the next character to be processed by Next_Token procedure Next_Token; -- Returns the next token in Line, starting at Input_Position Rewritten_Line : VString; -- Collects the line as it is rewritten procedure Rewrite_Word; -- The current token is assumed to be a Word. When processing the VMS -- version of the manual, additional tokens are gathered to check if -- we have a file name or a sequence of known words. procedure Maybe_Rewrite_Extension; -- The current token is assumed to be Other. When processing the VMS -- version of the manual and the token represents a single dot ".", -- the following word is rewritten according to the rules for -- extensions. VMS_Token_Seen : Boolean := False; -- This is set to true if a VMS_Alternative has been encountered, or a -- ^^^ token. ---------------- -- Next_Token -- ---------------- procedure Next_Token is Remaining_Line : String renames Line (Input_Position .. Line'Last); Last_Character : Natural; begin if Remaining_Line'Length = 0 then Token := (End_Of_Line, Remaining_Line'First); return; end if; -- ^alpha^beta^, the VMS_Alternative case if Remaining_Line (Remaining_Line'First) = VMS_Escape_Character then declare VMS_Second_Character, VMS_Third_Character : Natural; begin if VMS_Token_Seen then Error (Source_File, Remaining_Line'First, "multiple " & VMS_Escape_Character & " characters on a single line"); else VMS_Token_Seen := True; end if; -- Find the second and third escape character. If one of -- them is not present, generate an error token. VMS_Second_Character := Index (Remaining_Line (Remaining_Line'First + 1 .. Remaining_Line'Last), (1 => VMS_Escape_Character)); if VMS_Second_Character = 0 then Input_Position := Remaining_Line'Last + 1; Token := (VMS_Error, Remaining_Line'First); return; end if; VMS_Third_Character := Index (Remaining_Line (VMS_Second_Character + 1 .. Remaining_Line'Last), (1 => VMS_Escape_Character)); if VMS_Third_Character = 0 then Input_Position := Remaining_Line'Last + 1; Token := (VMS_Error, Remaining_Line'First); return; end if; -- Consume all the characters we are about to include in -- the token. Input_Position := VMS_Third_Character + 1; -- Check if we are in a ^^^ situation, and return an Other -- token in this case. if Remaining_Line'First + 1 = VMS_Second_Character and then Remaining_Line'First + 2 = VMS_Third_Character then Token := (Other, Remaining_Line'First, (Remaining_Line'First, Remaining_Line'First)); return; end if; Token := (VMS_Alternative, Remaining_Line'First, (Remaining_Line'First + 1, VMS_Second_Character - 1), (VMS_Second_Character + 1, VMS_Third_Character - 1)); return; end; end if; -- VMS_Alternative -- The Word case. Search for characters not in Word_Characters. -- We have found a word if the first non-word character is not -- the first character in Remaining_Line, i.e. if Remaining_Line -- starts with a word character. Last_Character := Index (Remaining_Line, Word_Characters, Outside); if Last_Character /= Remaining_Line'First then -- If we haven't found a character which is not in -- Word_Characters, all remaining characters are part of the -- current Word token. if Last_Character = 0 then Last_Character := Remaining_Line'Last + 1; end if; Input_Position := Last_Character; Token := (Word, Remaining_Line'First, (Remaining_Line'First, Last_Character - 1)); return; end if; -- Remaining characters are in the Other category. To speed -- up processing, we collect them together if there are several -- of them. Input_Position := Last_Character + 1; Token := (Other, Remaining_Line'First, (Remaining_Line'First, Last_Character)); end Next_Token; ------------------ -- Rewrite_Word -- ------------------ procedure Rewrite_Word is First_Word : String renames Line (Token.Span.First .. Token.Span.Last); begin -- We do not perform any error checking below, so we can just skip -- all processing for the non-VMS version. if Target /= VMS then Append (Rewritten_Line, First_Word); Next_Token; return; end if; if Is_Known_Word (First_Word) then -- If we have a word from the dictionary, we look for the -- longest possible sequence we can rewrite. declare Seq : Token_Span := Token.Span; Lost_Space : Boolean := False; begin Next_Token; loop if Token.Kind = Other and then Line (Token.Span.First .. Token.Span.Last) = " " then Next_Token; if Token.Kind /= Word or else not Is_Known_Word (Line (Seq.First .. Token.Span.Last)) then -- When we reach this point, the following -- conditions are true: -- -- Seq is a known word. -- The previous token was a space character. -- Seq extended to the current token is not a -- known word. Lost_Space := True; exit; else -- Extend Seq to cover the current (known) word Seq.Last := Token.Span.Last; Next_Token; end if; else -- When we reach this point, the following conditions -- are true: -- -- Seq is a known word. -- The previous token was a word. -- The current token is not a space character. exit; end if; end loop; -- Rewrite Seq, and add the lost space if necessary Append (Rewritten_Line, Get_Replacement_Word (Line (Seq.First .. Seq.Last))); if Lost_Space then Append (Rewritten_Line, ' '); end if; -- The unknown token will be processed during the -- next iteration of the main loop. return; end; end if; Next_Token; if Token.Kind = Other and then Line (Token.Span.First .. Token.Span.Last) = "." then -- Deal with extensions Next_Token; if Token.Kind = Word and then Is_Extension (Line (Token.Span.First .. Token.Span.Last)) then -- We have discovered a file extension. Convert the file -- name to upper case. Append (Rewritten_Line, Translate (First_Word, Upper_Case_Map) & '.'); Append (Rewritten_Line, Get_Replacement_Extension (Line (Token.Span.First .. Token.Span.Last))); Next_Token; else -- We already have: Word ".", followed by an unknown token Append (Rewritten_Line, First_Word & '.'); -- The unknown token will be processed during the next -- iteration of the main loop. end if; else -- We have an unknown Word, followed by an unknown token. -- The unknown token will be processed by the outer loop. Append (Rewritten_Line, First_Word); end if; end Rewrite_Word; ----------------------------- -- Maybe_Rewrite_Extension -- ----------------------------- procedure Maybe_Rewrite_Extension is begin -- Again, we need no special processing in the non-VMS case if Target = VMS and then Line (Token.Span.First .. Token.Span.Last) = "." then -- This extension is not preceded by a word, otherwise -- Rewrite_Word would have handled it. Next_Token; if Token.Kind = Word and then Is_Extension (Line (Token.Span.First .. Token.Span.Last)) then Append (Rewritten_Line, '.' & Get_Replacement_Extension (Line (Token.Span.First .. Token.Span.Last))); Next_Token; else Append (Rewritten_Line, '.'); end if; else Append (Rewritten_Line, Line (Token.Span.First .. Token.Span.Last)); Next_Token; end if; end Maybe_Rewrite_Extension; -- Start of processing for Process_Source_Line begin -- The following parser recognizes the following special token -- sequences: -- Word "." Word rewrite as file name if second word is extension -- Word " " Word rewrite as a single word using Ug_Words table Next_Token; loop case Token.Kind is when End_Of_Line => exit; when Word => Rewrite_Word; when Other => Maybe_Rewrite_Extension; when VMS_Alternative => if VMS_Context_Determined then if (not In_VMS_Section) or else Line (Token.VMS.First .. Token.VMS.Last) /= Line (Token.Non_VMS.First .. Token.Non_VMS.Last) then Warning (Source_File, Token.First, "VMS alternative already determined " & "by conditionals"); end if; end if; if Target = VMS then Append (Rewritten_Line, Line (Token.VMS.First .. Token.VMS.Last)); else Append (Rewritten_Line, Line (Token.Non_VMS.First .. Token.Non_VMS.Last)); end if; Next_Token; when VMS_Error => Error (Source_File, Token.First, "invalid VMS alternative"); Next_Token; end case; end loop; return S (Rewritten_Line); end Rewrite_Source_Line; ------------------------- -- Process_Source_File -- ------------------------- procedure Process_Source_File is Ifset : constant String := "@ifset "; Ifclear : constant String := "@ifclear "; Endsetclear : constant String := "@end "; -- Strings to be recognized for conditional processing begin while not End_Of_File (Source_File.Data) loop declare Line : constant String := Get_Line (Source_File'Access); Rewritten : constant String := Rewrite_Source_Line (Line); -- We unconditionally rewrite the line so that we can check the -- syntax of all lines, and not only those which are actually -- included in the output. Have_Conditional : Boolean := False; -- True if we have encountered a conditional preprocessing -- directive. Cond : Conditional; -- The kind of the directive Flag : Flag_Type; -- Its flag begin -- If the line starts with @ifset or @ifclear, we try to convert -- the following flag to one of our flag types. If we fail, -- Have_Conditional remains False. if Line'Length >= Ifset'Length and then Line (1 .. Ifset'Length) = Ifset then Cond := Set; declare Arg : constant String := Trim (Line (Ifset'Length + 1 .. Line'Last), Both); begin Flag := Flag_Type'Value (Arg); Have_Conditional := True; case Flag is when Target_Type => if Translate (Target_Type'Image (Flag), Lower_Case_Map) /= Arg then Error (Source_File, "flag has to be lowercase"); end if; when Edition_Type => null; end case; exception when Constraint_Error => Error (Source_File, "unknown flag for '@ifset'"); end; elsif Line'Length >= Ifclear'Length and then Line (1 .. Ifclear'Length) = Ifclear then Cond := Clear; declare Arg : constant String := Trim (Line (Ifclear'Length + 1 .. Line'Last), Both); begin Flag := Flag_Type'Value (Arg); Have_Conditional := True; case Flag is when Target_Type => if Translate (Target_Type'Image (Flag), Lower_Case_Map) /= Arg then Error (Source_File, "flag has to be lowercase"); end if; when Edition_Type => null; end case; exception when Constraint_Error => Error (Source_File, "unknown flag for '@ifclear'"); end; end if; if Have_Conditional and (Flag in Target_Type) then -- We create a new conditional context and suppress the -- directive in the output. Push_Conditional (Cond, Flag); elsif Line'Length >= Endsetclear'Length and then Line (1 .. Endsetclear'Length) = Endsetclear and then (Flag in Target_Type) then -- The '@end ifset'/'@end ifclear' case is handled here. We -- have to pop the conditional context. declare First, Last : Natural; begin Find_Token (Source => Line (Endsetclear'Length + 1 .. Line'Length), Set => Letter_Set, Test => Inside, First => First, Last => Last); if Last = 0 then Error (Source_File, "'@end' without argument"); else if Line (First .. Last) = "ifset" then Have_Conditional := True; Cond := Set; elsif Line (First .. Last) = "ifclear" then Have_Conditional := True; Cond := Clear; end if; if Have_Conditional then Pop_Conditional (Cond); end if; -- We fall through to the ordinary case for other @end -- directives. end if; -- @end without argument end; end if; -- Have_Conditional if (not Have_Conditional) or (Flag in Edition_Type) then -- The ordinary case if not Currently_Excluding then Put_Line (Output_File, Rewritten); end if; end if; end; end loop; Check_No_Pending_Conditional; end Process_Source_File; --------------------------- -- Initialize_Extensions -- --------------------------- procedure Initialize_Extensions is procedure Add (Extension : String); -- Adds an extension which is replaced with itself (in upper -- case). procedure Add (Extension, Replacement : String); -- Adds an extension with a custom replacement --------- -- Add -- --------- procedure Add (Extension : String) is begin Add (Extension, Translate (Extension, Upper_Case_Map)); end Add; procedure Add (Extension, Replacement : String) is begin Set (Extensions, Extension, V (Replacement)); end Add; -- Start of processing for Initialize_Extensions begin -- To avoid performance degradation, increase the constant in the -- definition of Extensions above if you add more extensions here. Add ("o", "OBJ"); Add ("ads"); Add ("adb"); Add ("ali"); Add ("ada"); Add ("atb"); Add ("ats"); Add ("adc"); Add ("c"); end Initialize_Extensions; ------------------ -- Is_Extension -- ------------------ function Is_Extension (Extension : String) return Boolean is begin return Present (Extensions, Extension); end Is_Extension; ------------------------------- -- Get_Replacement_Extension -- ------------------------------- function Get_Replacement_Extension (Extension : String) return String is begin return S (Get (Extensions, Extension)); end Get_Replacement_Extension; ------------------- -- Is_Known_Word -- ------------------- function Is_Known_Word (Word : String) return Boolean is begin return Present (Ug_Words, Word); end Is_Known_Word; -------------------------- -- Get_Replacement_Word -- -------------------------- function Get_Replacement_Word (Word : String) return String is begin return S (Get (Ug_Words, Word)); end Get_Replacement_Word; ---------------------- -- Push_Conditional -- ---------------------- procedure Push_Conditional (Cond : Conditional; Flag : Target_Type) is Will_Exclude : Boolean; begin -- If we are already in an excluding context, inherit this property, -- otherwise calculate it from scratch. if Conditional_TOS > 0 and then Conditional_Stack (Conditional_TOS).Excluding then Will_Exclude := True; else case Cond is when Set => Will_Exclude := Flag /= Target; when Clear => Will_Exclude := Flag = Target; end case; end if; -- Check if the current directive is pointless because of a previous, -- enclosing directive. for J in 1 .. Conditional_TOS loop if Conditional_Stack (J).Flag = Flag then Warning (Source_File, "directive without effect because of line" & Integer'Image (Conditional_Stack (J).Starting_Line)); end if; end loop; Conditional_TOS := Conditional_TOS + 1; Conditional_Stack (Conditional_TOS) := (Starting_Line => Source_File.Line, Cond => Cond, Flag => Flag, Excluding => Will_Exclude); end Push_Conditional; --------------------- -- Pop_Conditional -- --------------------- procedure Pop_Conditional (Cond : Conditional) is begin if Conditional_TOS > 0 then case Cond is when Set => if Conditional_Stack (Conditional_TOS).Cond /= Set then Error (Source_File, "'@end ifset' does not match '@ifclear' at line" & Integer'Image (Conditional_Stack (Conditional_TOS).Starting_Line)); end if; when Clear => if Conditional_Stack (Conditional_TOS).Cond /= Clear then Error (Source_File, "'@end ifclear' does not match '@ifset' at line" & Integer'Image (Conditional_Stack (Conditional_TOS).Starting_Line)); end if; end case; Conditional_TOS := Conditional_TOS - 1; else case Cond is when Set => Error (Source_File, "'@end ifset' without corresponding '@ifset'"); when Clear => Error (Source_File, "'@end ifclear' without corresponding '@ifclear'"); end case; end if; end Pop_Conditional; ------------------------- -- Currently_Excluding -- ------------------------- function Currently_Excluding return Boolean is begin return Conditional_TOS > 0 and then Conditional_Stack (Conditional_TOS).Excluding; end Currently_Excluding; ---------------------------- -- VMS_Context_Determined -- ---------------------------- function VMS_Context_Determined return Boolean is begin for J in 1 .. Conditional_TOS loop if Conditional_Stack (J).Flag = VMS then return True; end if; end loop; return False; end VMS_Context_Determined; -------------------- -- In_VMS_Section -- -------------------- function In_VMS_Section return Boolean is begin for J in 1 .. Conditional_TOS loop if Conditional_Stack (J).Flag = VMS then return Conditional_Stack (J).Cond = Set; end if; end loop; return False; end In_VMS_Section; ---------------------------------- -- Check_No_Pending_Conditional -- ---------------------------------- procedure Check_No_Pending_Conditional is begin for J in 1 .. Conditional_TOS loop case Conditional_Stack (J).Cond is when Set => Error (Source_File, "Missing '@end ifset' for '@ifset' at line" & Integer'Image (Conditional_Stack (J).Starting_Line)); when Clear => Error (Source_File, "Missing '@end ifclear' for '@ifclear' at line" & Integer'Image (Conditional_Stack (J).Starting_Line)); end case; end loop; end Check_No_Pending_Conditional; -- Start of processing for Xgnatugn Valid_Command_Line : Boolean; Output_File_Name : VString; begin Initialize_Extensions; Valid_Command_Line := Argument_Count in 3 .. 5; -- First argument: Target if Valid_Command_Line then begin Target := Flag_Type'Value (Argument (1)); if not Target'Valid then Valid_Command_Line := False; end if; exception when Constraint_Error => Valid_Command_Line := False; end; end if; -- Second argument: Source_File if Valid_Command_Line then begin Source_File.Name := V (Argument (2)); Open (Source_File.Data, In_File, Argument (2)); exception when Name_Error => Valid_Command_Line := False; end; end if; -- Third argument: Dictionary_File if Valid_Command_Line then begin Dictionary_File.Name := V (Argument (3)); Open (Dictionary_File.Data, In_File, Argument (3)); exception when Name_Error => Valid_Command_Line := False; end; end if; -- Fourth argument: Output_File if Valid_Command_Line then if Argument_Count in 4 .. 5 then Output_File_Name := V (Argument (4)); else case Target is when UNW => Output_File_Name := V ("gnat_ugn_unw.texi"); when VMS => Output_File_Name := V ("gnat_ugn_vms.texi"); end case; end if; Warnings_Enabled := Argument_Count = 5; begin Create (Output_File, Out_File, S (Output_File_Name)); exception when Name_Error | Use_Error => Valid_Command_Line := False; end; end if; if not Valid_Command_Line then Usage; Set_Exit_Status (Failure); else Read_Dictionary_File; Close (Dictionary_File.Data); -- Main processing starts here Process_Source_File; Close (Output_File); Close (Source_File.Data); New_Line (Standard_Error); if Number_Of_Warnings = 0 then Put_Line (Standard_Error, " NO Warnings"); else Put (Standard_Error, Integer'Image (Number_Of_Warnings)); Put (Standard_Error, " Warning"); if Number_Of_Warnings > 1 then Put (Standard_Error, "s"); end if; New_Line (Standard_Error); end if; if Number_Of_Errors = 0 then Put_Line (Standard_Error, " NO Errors"); else Put (Standard_Error, Integer'Image (Number_Of_Errors)); Put (Standard_Error, " Error"); if Number_Of_Errors > 1 then Put (Standard_Error, "s"); end if; New_Line (Standard_Error); end if; if Number_Of_Errors /= 0 then Set_Exit_Status (Failure); else Set_Exit_Status (Success); end if; end if; end Xgnatugn;
Cubical/Foundations/BiInvEquiv.agda
cj-xu/cubical
0
17109
{- Some theory about Bi-Invertible Equivalences - BiInvEquiv to Iso - BiInvEquiv to Equiv - BiInvEquiv to HAEquiv - Iso to BiInvEquiv -} {-# OPTIONS --cubical --safe #-} module Cubical.Foundations.BiInvEquiv where open import Cubical.Core.Glue open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.HAEquiv record BiInvEquiv {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where constructor biInvEquiv field fun : A → B invr : B → A invr-rightInv : section fun invr invl : B → A invl-leftInv : retract fun invl invr≡invl : ∀ b → invr b ≡ invl b invr≡invl b = invr b ≡⟨ sym (invl-leftInv (invr b)) ⟩ invl (fun (invr b)) ≡⟨ cong invl (invr-rightInv b) ⟩ invl b ∎ invr-leftInv : retract fun invr invr-leftInv a = invr≡invl (fun a) □ (invl-leftInv a) invr≡invl-leftInv : ∀ a → PathP (λ j → invr≡invl (fun a) j ≡ a) (invr-leftInv a) (invl-leftInv a) invr≡invl-leftInv a j i = compPath'-filler (invr≡invl (fun a)) (invl-leftInv a) (~ j) i invl-rightInv : section fun invl invl-rightInv a = sym (cong fun (invr≡invl a)) □ (invr-rightInv a) invr≡invl-rightInv : ∀ a → PathP (λ j → fun (invr≡invl a j) ≡ a) (invr-rightInv a) (invl-rightInv a) invr≡invl-rightInv a j i = compPath'-filler (sym (cong fun (invr≡invl a))) (invr-rightInv a) j i module _ {ℓ} {A B : Type ℓ} (e : BiInvEquiv A B) where open BiInvEquiv e biInvEquiv→Iso-right : Iso A B Iso.fun biInvEquiv→Iso-right = fun Iso.inv biInvEquiv→Iso-right = invr Iso.rightInv biInvEquiv→Iso-right = invr-rightInv Iso.leftInv biInvEquiv→Iso-right = invr-leftInv biInvEquiv→Iso-left : Iso A B Iso.fun biInvEquiv→Iso-left = fun Iso.inv biInvEquiv→Iso-left = invl Iso.rightInv biInvEquiv→Iso-left = invl-rightInv Iso.leftInv biInvEquiv→Iso-left = invl-leftInv biInvEquiv→Equiv-right biInvEquiv→Equiv-left : A ≃ B biInvEquiv→Equiv-right = fun , isoToIsEquiv biInvEquiv→Iso-right biInvEquiv→Equiv-left = fun , isoToIsEquiv biInvEquiv→Iso-left -- since Iso.rightInv ends up getting modified during iso→HAEquiv, in some sense biInvEquiv→Iso-left -- is the most natural choice for forming a HAEquiv from a BiInvEquiv biInvEquiv→HAEquiv : HAEquiv A B biInvEquiv→HAEquiv = iso→HAEquiv biInvEquiv→Iso-left module _ {ℓ} {A B : Type ℓ} (i : Iso A B) where open Iso i iso→BiInvEquiv : BiInvEquiv A B BiInvEquiv.fun iso→BiInvEquiv = fun BiInvEquiv.invr iso→BiInvEquiv = inv BiInvEquiv.invr-rightInv iso→BiInvEquiv = rightInv BiInvEquiv.invl iso→BiInvEquiv = inv BiInvEquiv.invl-leftInv iso→BiInvEquiv = leftInv
test1.asm
zxYin/mips-pipeline-simulator
0
101374
addi $t0, $zero, 10 addi $t1, $zero, 5 addi $t2, $zero, 10 add $s0, $t0, $t1 addi $t3, $zero, 6 sw $s0, 0($zero) sub $s1, $t2, $t3 sw $s1, 4($zero)
programs/oeis/049/A049779.asm
neoneye/loda
22
83070
<reponame>neoneye/loda ; A049779: a(n) = Sum_{k=1..floor(n/2)} T(n, 2k), array T as in A049777. ; 2,5,13,23,41,62,94,130,180,235,307,385,483,588,716,852,1014,1185,1385,1595,1837,2090,2378,2678,3016,3367,3759,4165,4615,5080,5592,6120,6698,7293,7941,8607,9329,10070,10870,11690,12572,13475,14443,15433,16491,17572,18724,19900,21150,22425,23777,25155,26613,28098,29666,31262,32944,34655,36455,38285,40207,42160,44208,46288,48466,50677,52989,55335,57785,60270,62862,65490,68228,71003,73891,76817,79859,82940,86140,89380,92742,96145,99673,103243,106941,110682,114554,118470,122520,126615,130847,135125,139543,144008,148616,153272,158074,162925,167925,172975 add $0,2 lpb $0 mov $1,$4 add $2,$0 sub $0,1 sub $1,$3 mov $3,$1 add $4,$2 lpe mov $0,$1
Library/ParentC/parentControl.asm
steakknife/pcgeos
504
172713
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Globalpc 1999 -- All Rights Reserved PROJECT: PC GEOS MODULE: Parental Control library FILE: parentControl.asm AUTHOR: <NAME>, July 27, 1999 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- edwin 7/27/99 Initial revision DESCRIPTION: $Id: $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ include timedate.def idata segment ParentalControlClass idata ends PCCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PCControlBringupPassword %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Bring up the Password dialog, for either setting a new password, or enter a password for authentication. CALLED BY: Other library or application. PASS: *ds:si = ParentalControlClass object ds:di = ParentalControlClass instance data ds:bx = ParentalControlClass object (same as *ds:si) es = segment of ParentalControlClass ax = message cx = PC_ON - bring up the 'set password' dialog PC_OFF - bring up the 'enter password' dialog RETURN: ax = IC_OK - password(s) is verified. IC_CANCEL - password not set, or incorrect. DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: (1) Duplicate the Password resource segment (2) Append the top password dialog to the controller object, set it usable. (3) UserDoDialog (4) Destroy the duplicated resource block (5) Return the user interaction flag: IC_OK, IC_CANCEL REVISION HISTORY: Name Date Description ---- ---- ----------- edwin 7/28/99 Initial version jfh 6/5/02 added im and ftp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ accessCat char "PCtrl", 0 accessBrowser char "BWS", 0 accessBrowserL char "BWSL", 0 accessEmail char "EML", 0 accessNewsgroup char "NWS", 0 accessChat char "CHT", 0 accessIM char "IM", 0 accessFTP char "FTP", 0 accessState char "TURN", 0 PCControlBringupPassword method dynamic ParentalControlClass, MSG_PC_BRING_UP_PASSWORD_DB uses di .enter ; ; First, duplicate the right resource block. ; mov di, offset SetPassword cmp cx, 0 ; 0 == user selected ParentalCcontrol_ON je SetPasswd mov di, offset EnterPassword SetPasswd: mov bx, handle PCControlPasswordUI call DuplicateResourceAndAddChildToRoot jc done tryAgain: call UserDoDialog cmp ax, IC_NULL je cancelAction cmp ax, IC_DISMISS je cancelAction ; ; If we're dealing with Set Password, verify the first entered and ; the re-confirmed passwords are the same. ; If we're dealing with Enter Password, check the authentication of ; entered password against the stored one. cmp cx, 0 ; 0 == user selected ParentalControl_ON je compare2passwds ; Otherwise verify authentication call VerifyAuthentication jmp result compare2passwds: call VerifyEnteredPasswords result: jnc same jmp tryAgain ; password(s) is(are) invalid(inconsistent) same: ; ; Set parental control ON/OFF in the ini file ; push ds, si, ax, dx mov dx, 1 jcxz setOn clr dx setOn: mov ax, dx segmov ds, cs mov si, offset accessCat ; ds:si - category ASCIIZ string mov cx, cs mov dx, offset accessState ; cx:dx - key ASCIIZ string call InitFileWriteBoolean pop ds, si, ax, dx cancelAction: call UserDestroyDialog done: .leave ret PCControlBringupPassword endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PCControlBringupWebSiteControl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Bring up the web site control dialog. CALLED BY: PASS: *ds:si = ParentalControlClass object ds:di = ParentalControlClass instance data ds:bx = ParentalControlClass object (same as *ds:si) es = segment of ParentalControlClass ax = message cx = PC_ON - bring up the 'set password' dialog PC_OFF - bring up the 'enter password' dialog RETURN: ax = IC_OK or IC_CANCEL DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: (1) Duplicate the Password resource segment (2) Append the top password dialog to the controller object, set it usable. (3) UserDoDialog (4) Destroy the duplicated resource block (5) Return the user interaction flag: IC_OK, IC_CANCEL REVISION HISTORY: Name Date Description ---- ---- ----------- edwin 7/28/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PCControlBringupWebSiteControl method dynamic ParentalControlClass, MSG_PC_BRING_UP_WEBSITE_DB uses di .enter call PCEnsureOpenData mov di, offset WWWDialog mov bx, handle PCControlWebSiteUI call DuplicateResourceAndAddChildToRoot ; bx = object block jc done ; ; before putting up dialog, set trigger data to pass block handle ; push si mov si, offset DeleteButton call setTrigData mov si, offset PermissionAddButton call setTrigData mov si, offset PermissionChangeButton call setTrigData pop si call UserDoDialog ; ; close child dialogs (in case closed by shutdown) ; push ax, si mov si, offset PermissionAddDialog call closeDialog mov si, offset PermissionModifyDialog call closeDialog pop ax, si call UserDestroyDialog done: call PCCloseData .leave ret setTrigData label near sub sp, size AddVarDataParams + size word mov bp, sp mov ss:[bp].AVDP_data.segment, ss mov ss:[bp].AVDP_data.offset, bp add ss:[bp].AVDP_data.offset, size AddVarDataParams mov ss:[bp].AVDP_dataSize, size word mov ss:[bp].AVDP_dataType, ATTR_GEN_TRIGGER_ACTION_DATA mov {word}ss:[bp][(size AddVarDataParams)], bx ; our handle mov ax, MSG_META_ADD_VAR_DATA mov di, mask MF_FIXUP_DS or mask MF_CALL call ObjMessage add sp, size AddVarDataParams + size word retn closeDialog label near mov ax, MSG_GEN_GUP_INTERACTION_COMMAND mov cx, IC_DISMISS mov di, mask MF_FIXUP_DS or mask MF_CALL call ObjMessage retn PCControlBringupWebSiteControl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PCControlBringupWebSiteControl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Bring up the web site control dialog. CALLED BY: Other applications. PASS: *ds:si = ParentalControlClass object ds:di = ParentalControlClass instance data ds:bx = ParentalControlClass object (same as *ds:si) es = segment of ParentalControlClass ax = message RETURN: ax = IC_OK or IC_CANCEL DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: (1) Duplicate the Password resource segment (2) Append the top password dialog to the controller object, set it usable. (3) UserDoDialog (4) Destroy the duplicated resource block (5) Return the user interaction flag: IC_OK, IC_CANCEL REVISION HISTORY: Name Date Description ---- ---- ----------- edwin 7/28/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PCControlCheckPassWordControl method dynamic ParentalControlClass, MSG_PC_CHECK_PASSWORD_DB uses di .enter mov di, offset CheckPassWordDialog mov bx, handle PCControlCheckPasswordUI call DuplicateResourceAndAddChildToRoot jc exit call ChangeDialogTitle tryAgain: call UserDoDialog cmp ax, IC_NULL je done cmp ax, IC_DISMISS je done call VerifyAuthentication2 jc tryAgain done: call UserDestroyDialog exit: .leave ret PCControlCheckPassWordControl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PCControlStoreWebSites %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Store the entered web sites into the database file. CALLED BY: PASS: *ds:si = ParentalControlClass object ds:di = ParentalControlClass instance data ds:bx = ParentalControlClass object (same as *ds:si) es = segment of ParentalControlClass ax = message cx = object block RETURN: none DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- edwin 8/03/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PCControlStoreWebSites method dynamic ParentalControlClass, MSG_PC_SET_WEBSITES .enter ; ; Get duplicated resource block handle (passed in CX) ; mov bx, cx mov si, offset PermissionAddInput mov ax, MSG_VIS_TEXT_GET_ALL_BLOCK clr dx mov di, mask MF_CALL call ObjMessage ; cx - block handle, ax - length push bx mov bx, cx call MemLock ; ax:0 - input text input field. call ParseWebSiteList call MemFree pop bx call PCDataGetCount ; dx:ax - count mov cx, ax mov si, offset PermissibleList ; bx:si = PermissbleList mov ax, MSG_GEN_DYNAMIC_LIST_INITIALIZE mov di, mask MF_CALL call ObjMessage ; ; send out changes ; mov cx, MANUFACTURER_ID_GEOWORKS mov dx, GWNT_PARENTAL_CONTROL_WEBSITE_LIST_CHANGE mov bx, MANUFACTURER_ID_GEOWORKS mov ax, GCNSLT_PARENTAL_CONTROL_WEBSITE_LIST_CHANGES mov bp, PCWLCT_ADD call SendPCGCN .leave ret PCControlStoreWebSites endm PCControlDeleteWebSite method dynamic ParentalControlClass, MSG_PC_DELETE_WEBSITE .enter ; ; Get duplicated resource block handle (passed in CX) ; ; ; Delete the current selection ; push cx mov bx, cx mov si, offset PermissibleList ; bx:si = PermissbleList mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION mov di, mask MF_CALL call ObjMessage ; ax - selection call PCDataDeleteItem call PCDataGetCount ; dx:ax - count mov cx, ax pop bx mov si, offset PermissibleList ; bx:si = PermissbleList mov ax, MSG_GEN_DYNAMIC_LIST_INITIALIZE mov di, mask MF_CALL call ObjMessage call DisableDeleteModifyTriggers ; ; send out changes ; mov cx, MANUFACTURER_ID_GEOWORKS mov dx, GWNT_PARENTAL_CONTROL_WEBSITE_LIST_CHANGE mov bx, MANUFACTURER_ID_GEOWORKS mov ax, GCNSLT_PARENTAL_CONTROL_WEBSITE_LIST_CHANGES mov bp, PCWLCT_DELETE call SendPCGCN .leave ret PCControlDeleteWebSite endm PCControlModifyWebSite method dynamic ParentalControlClass, MSG_PC_MODIFY_WEBSITE .enter ; ; Get duplicated resource block handle (passed in CX) ; ; ; Delete the current selection ; push cx mov bx, cx mov si, offset PermissibleList ; bx:si = PermissbleList mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION mov di, mask MF_CALL call ObjMessage ; ax - selection call PCDataDeleteItem ; ; Read the modified text ; mov si, offset PermissionModifyInput mov ax, MSG_VIS_TEXT_GET_ALL_BLOCK clr dx mov di, mask MF_CALL call ObjMessage ; cx - block handle, ax - length mov bx, cx call MemLock ; ax:0 - input text input field. call ParseWebSiteList call MemFree call PCDataGetCount ; dx:ax - count mov cx, ax pop bx mov si, offset PermissibleList ; bx:si = PermissbleList mov ax, MSG_GEN_DYNAMIC_LIST_INITIALIZE mov di, mask MF_CALL call ObjMessage call DisableDeleteModifyTriggers ; ; send out changes ; mov cx, MANUFACTURER_ID_GEOWORKS mov dx, GWNT_PARENTAL_CONTROL_WEBSITE_LIST_CHANGE mov bx, MANUFACTURER_ID_GEOWORKS mov ax, GCNSLT_PARENTAL_CONTROL_WEBSITE_LIST_CHANGES mov bp, PCWLCT_MODIFY call SendPCGCN .leave ret PCControlModifyWebSite endm ; ; Internal code. ; User friedly: disable modify and delete button. ; DisableDeleteModifyTriggers proc near uses ax, si, cx, dx, di, bp .enter mov si, offset ModifyButton ; bx:si = ModifyButton mov ax, MSG_GEN_SET_NOT_ENABLED mov dl, VUM_DELAYED_VIA_UI_QUEUE mov di, mask MF_CALL call ObjMessage ; ax - selection mov si, offset DeleteButton ; bx:si = ModifyButton mov ax, MSG_GEN_SET_NOT_ENABLED mov dl, VUM_DELAYED_VIA_UI_QUEUE mov di, mask MF_CALL call ObjMessage ; ax - selection .leave ret DisableDeleteModifyTriggers endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ParentalControlGetAccessInfo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the current access settings of the following: WWW browser, email, newsgroup reading, chat room discussion. PASS: nothing RETURN: ax = AccessFlags PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- edwin 7/28/99 Initial version jfh 6/5/02 added im and ftp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ParentalControlGetAccessInfo proc far uses bx, cx, dx, ds, si .enter clr bx segmov ds, cs mov si, offset accessCat ; ds:si - category ASCIIZ string mov cx, cs mov dx, offset accessBrowser ; cx:dx - key ASCIIZ string clr ax call InitFileReadBoolean tst ax jz BrowserOff or bx, mask AF_WWWBROWSING ; ; Is it limited browsing? ; mov dx, offset accessBrowserL ; cx:dx - key ASCIIZ string clr ax call InitFileReadBoolean tst ax jz BrowserOff or bx, mask AF_WWWLIMITED BrowserOff: ; ; Is email off? ; mov dx, offset accessEmail ; cx:dx - key ASCIIZ string clr ax call InitFileReadBoolean tst ax jz EmailOff or bx, mask AF_EMAIL EmailOff: ; ; Is newsgroup off? ; mov dx, offset accessNewsgroup ; cx:dx - key ASCIIZ string clr ax call InitFileReadBoolean tst ax jz NewsgroupOff or bx, mask AF_NEWSGROUP NewsgroupOff: ; ; Is Chatroom off? ; mov dx, offset accessChat ; cx:dx - key ASCIIZ string clr ax call InitFileReadBoolean tst ax jz ChatroomOff or bx, mask AF_CHATROOM ChatroomOff: ; ; Is IM off? ; mov dx, offset accessIM ; cx:dx - key ASCIIZ string clr ax call InitFileReadBoolean tst ax jz FTPOff or bx, mask AF_IM FTPOff: ; ; Is FTP off? ; mov dx, offset accessFTP ; cx:dx - key ASCIIZ string clr ax call InitFileReadBoolean tst ax jz ParentalControl or bx, mask AF_FTP ParentalControl: ; ; Is parental control on? ; mov dx, offset accessState ; cx:dx - key ASCIIZ string clr ax call InitFileReadBoolean tst ax jz done or bx, mask AF_PCON done: ; mov ax, mask AF_WWWBROWSING or mask AF_CHATROOM mov ax, bx .leave ret ParentalControlGetAccessInfo endp ; ; bx:ax = GCNSLT_ ; cx:dx = manuf ID:GWNT_ ; bp = data ; SendPCGCN proc near push bx, ax mov ax, MSG_META_NOTIFY clr bx, si ; let any object class handle mov di, mask MF_RECORD call ObjMessage pop bx, ax mov cx, di ; cx = notify event clr dx ; no data block mov bp, mask GCNLSF_FORCE_QUEUE ; (just in case) call GCNListSend ret SendPCGCN endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ParentalControlSetAccessInfo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the current access settings to the ini file. WWW browser, email, newsgroup reading, chat room discussion. PASS: ax = AccessFlags RETURN: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- edwin 7/28/99 Initial version jfh 6/5/02 added IM & FTP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ParentalControlSetAccessInfo proc far uses ax, bx, cx, dx, ds, si, di, bp .enter mov bx, ax segmov ds, cs mov si, offset accessCat ; ds:si - category ASCIIZ string mov cx, cs mov dx, offset accessBrowser ; cx:dx - key ASCIIZ string clr ax test bx, mask AF_WWWBROWSING jz browserOff mov ax, TRUE browserOff: call InitFileWriteBoolean ; ; Is it limited browsing? ; mov dx, offset accessBrowserL ; cx:dx - key ASCIIZ string clr ax test bx, mask AF_WWWLIMITED jz limitedOff mov ax, TRUE limitedOff: call InitFileWriteBoolean ; ; Is email off? ; mov dx, offset accessEmail ; cx:dx - key ASCIIZ string clr ax test bx, mask AF_EMAIL jz emailOff mov ax, TRUE emailOff: call InitFileWriteBoolean ; ; Is newsgroup off? ; mov dx, offset accessNewsgroup ; cx:dx - key ASCIIZ string clr ax test bx, mask AF_NEWSGROUP jz newsgroupOff mov ax, TRUE newsgroupOff: call InitFileWriteBoolean ; ; Is Chatroom off? ; mov dx, offset accessChat ; cx:dx - key ASCIIZ string clr ax test bx, mask AF_CHATROOM jz chatroomOff mov ax, TRUE chatroomOff: call InitFileWriteBoolean ; ; Is IM off? ; mov dx, offset accessIM ; cx:dx - key ASCIIZ string clr ax test bx, mask AF_IM jz IMOff mov ax, TRUE IMOff: call InitFileWriteBoolean ; ; Is FTP off? ; mov dx, offset accessFTP ; cx:dx - key ASCIIZ string clr ax test bx, mask AF_FTP jz FTPOff mov ax, TRUE FTPOff: call InitFileWriteBoolean ; ; notify of change ; mov bp, bx ; bp = new AccessFlags mov cx, MANUFACTURER_ID_GEOWORKS mov dx, GWNT_PARENTAL_CONTROL_CHANGE mov bx, MANUFACTURER_ID_GEOWORKS mov ax, GCNSLT_PARENTAL_CONTROL_CHANGE call SendPCGCN .leave ret ParentalControlSetAccessInfo endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The following are the internal code. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; Internal code ; ; Pass: ax:0 - starting address of URLs, separated by white spaces by ; assumption. ; Return: dx - number of items added to the database file ; Strategy: - scan through the input entry, ; - extract URLs, and ; - store the URLs into the database file ; ParseWebSiteList proc near uses ds, si, di, ax, cx, bp .enter mov ds, ax clr si, di ; ds:[si] points to the url addresses clr cx, dx ; dx - counter of entered URLs nextUrl: cmp {TCHAR}ds:[si], C_SPACE je whiteSpace ifdef DO_DBCS cmp {TCHAR}ds:[si], C_HORIZONTAL_TABULATION je whiteSpace cmp {TCHAR}ds:[si], C_CARRIAGE_RETURN je whiteSpace cmp {TCHAR}ds:[si], C_LINE_FEED je whiteSpace else cmp {TCHAR}ds:[si], C_TAB je whiteSpace cmp {TCHAR}ds:[si], C_CR je whiteSpace cmp {TCHAR}ds:[si], C_LF je whiteSpace endif cmp {TCHAR}ds:[si], C_NULL je whiteSpace ; edwdig was here cmp {TCHAR}ds:[si], ',' je whiteSpace cmp {TCHAR}ds:[si], ';' je whiteSpace ; end edwdig jcxz newUrl jmp ok newUrl: mov cx, 1 ; turn on a flag that we got a non-white space char mov di, si jmp ok whiteSpace: cmp cx, 1 jne skipWhiteSpace ; From ds:[di] to ds:[si] is the new URL ; store the new URL into a database call PCStoreURLs mov cx, 0 jnc skipWhiteSpace ; already there, didn't store inc dx ; dx - counter of URLs skipWhiteSpace: mov di, si ok: tst {TCHAR}ds:[si] jz noMore LocalNextChar dssi jmp nextUrl noMore: .leave ret ParseWebSiteList endp ; Internal code ; ; Verify the two entered new passwords are the same. ; ; Pass: ^lbx:si - dialog object ; VerifyEnteredPasswords proc near passwdBuf local MAX_PASSWORD_SOURCE_LENGTH + 1 dup (TCHAR) passwd2Buf local MAX_PASSWORD_SOURCE_LENGTH + 1 dup (TCHAR) uses ax, cx, dx, bp, di, si, ds, es .enter push bp mov dx, ss lea bp, passwdBuf mov si, offset SetPasswordInput mov ax, MSG_VIS_TEXT_GET_ALL_PTR mov di, mask MF_CALL call ObjMessage ; passwdBuf filled pop bp push bp lea bp, passwd2Buf mov si, offset ConfirmPassword mov ax, MSG_VIS_TEXT_GET_ALL_PTR mov di, mask MF_CALL call ObjMessage ; passwd2Buf filled pop bp segmov ds, ss segmov es, ss lea si, passwdBuf lea di, passwd2Buf clr cx ; compare full null-term'ed length call LocalCmpStrings jz equal ; ; The confirmation password is different from the first ; entered password. Bring up a warning. ; mov si, offset PasswordInconsistent call UserDoDialog stc jmp exit equal: call StorePasswordToInit clc exit: .leave ret VerifyEnteredPasswords endp ; Internal code ; es:di - password ; accessPassword TCHAR "<PASSWORD>", 0 ; password StorePasswordToInit proc near passwordEncripted local PASSWORD_ENCRYPTED_SIZE + 1 dup (TCHAR) uses cx, dx, si, ds .enter segmov ds, es mov si, di segmov es, ss lea di, passwordEncripted call UserEncryptPassword ; es:di - filled with enscripted password mov {TCHAR}es:[di+8*(size TCHAR)], 0 segmov ds, cs mov si, offset accessCat ; ds:si - category ASCIIZ string mov cx, cs mov dx, offset accessPassword ; cx:dx - key ASCIIZ string ; es:di - encripted password call InitFileWriteString .leave ret StorePasswordToInit endp ; Internal code ; ; Verify the entered password is the same as stored. ; ; Pass: ^lbx:si - root dialog box ; Return: carry clear - ok,passed. ; carry set - nope, intrusion. ; VerifyAuthentication proc near passwdBuf2 local MAX_PASSWORD_SOURCE_LENGTH + 1 dup (TCHAR) uses ax, cx, dx, bp, di, si, ds, es .enter push bp mov dx, ss lea bp, passwdBuf2 mov si, offset EnterPasswordInput mov ax, MSG_VIS_TEXT_GET_ALL_PTR mov di, mask MF_CALL call ObjMessage ; dx:bp=passwd2Buf filled mov cx, bp pop bp ; dx:cx = string to be compared with call VerifyAuthenticationLow jnc equal ; ; The confirmation password is different from the first ; entered password. Bring up a warning. ; mov si, offset InvalidPassword call UserDoDialog stc equal: .leave ret VerifyAuthentication endp ; Internal code ; ; Verify the entered password is the same as stored. ; ; Pass: ^<PASSWORD>:si - root dialog box ; Return: carry clear - ok,passed. ; carry set - nope, intrusion. ; VerifyAuthentication2 proc near passwdBuf2 local MAX_PASSWORD_SOURCE_LENGTH + 1 dup (TCHAR) uses ax, cx, dx, bp, di, si, ds, es .enter push bp mov dx, ss lea bp, passwdBuf2 mov si, offset NewsReaderEnterPassword mov ax, MSG_VIS_TEXT_GET_ALL_PTR mov di, mask MF_CALL call ObjMessage ; dx:bp=passwd2Buf filled mov cx, bp pop bp ; dx:cx = string to be compared with call VerifyAuthenticationLow jnc equal ; ; The confirmation password is different from the first ; entered password. Bring up a warning. ; mov si, offset InvalidPassword2 call UserDoDialog stc equal: .leave ret VerifyAuthentication2 endp ; ; Pass: dx:cx = string to be compared with the one stored in ini file ; Return: carry set if entered password is not same as stored. ; VerifyAuthenticationLow proc near StringSeg local word push dx StringOff local word push cx passwdBuf local PASSWORD_ENCRYPTED_SIZE + 1 dup (TCHAR) passwordEncripted local PASSWORD_ENCRYPTED_SIZE + 1 dup (TCHAR) dateTimeBuffer local DATE_TIME_BUFFER_SIZE dup (TCHAR) uses ax, bx, cx, dx, di, si, ds, es .enter mov ds, dx mov si, cx ; ds:si - original password text segmov es, ss lea di, passwordEncripted ; es:di - buffered encripted passwd call UserEncryptPassword segmov ds, cs mov si, offset accessCat ; ds:si - category ASCIIZ string mov cx, cs mov dx, offset accessPassword ; cx:dx - key ASCIIZ string lea di, passwdBuf push bp mov bp, InitFileReadFlags <IFCC_INTACT,0,0,PASSWORD_ENCRYPTED_SIZE+1> call InitFileReadString ; es:di - filled pop bp jc error segmov ds, ss lea si, passwordEncripted mov cx, PASSWORD_ENCRYPTED_SIZE SBCS < repe cmpsb > DBCS < repe cmpsw > clc jz equal ; ; Not equal. Let's check if the enetered password is ; equal to the date. ; call TimerGetDateAndTime ; ax = year, bl = month ; bh = day, cl = day of week segmov es, ss lea di, dateTimeBuffer mov si, DTF_SHORT call LocalFormatDateTime ; cx = size w/o null clr {TCHAR}es:[di+8] segmov es, ss segmov ds, ss lea si, dateTimeBuffer lea di, passwordEncripted ; es:di - buffered encripted passwd call UserEncryptPassword mov ds, StringSeg mov si, StringOff mov cx, PASSWORD_ENCRYPTED_SIZE SBCS < repe cmpsb > DBCS < repe cmpsw > clc jz equal error: stc equal: .leave ret VerifyAuthenticationLow endp ; ; Internal code ; ; Duplicate the resource ; ; pass: *ds:si - root object ; di - offset of the child dialog ; bx - resource segment handle where the child locates ; Return carry clear if successful ; ^lbx:si - child object that is desired. ; carry set if error (no app object) ; ax = IC_OK ; ; Revision: edwin 7/28/99 ; DuplicateResourceAndAddChildToRoot proc near uses ax, cx, dx, bp, di .enter mov bp, bx ; bp = template resource mov cx, ds:[LMBH_handle] ; ^lcx:dx = root object mov dx, si clr bx call GeodeGetAppObject tst bx mov ax, IC_OK ; in case no app object stc jz done push cx, dx ; (1) ^lcx:dx = root object push bx, si ; (2) ^lbx:si = app obj mov ax, MGIT_OTHER_INFO call MemGetInfo ; ax = burden thread mov cx, ax mov ax, 0 mov bx, bp call ObjDuplicateResource ; bx - handle of duplicate block mov cx, bx ; handle of duplicated block mov dx, di ; ^lcx:dx - child object to append mov bp, CCO_LAST pop bx, si ; (2) ^lbx:si = app obj mov ax, MSG_GEN_ADD_CHILD mov di, mask MF_FIXUP_DS call ObjMessage movdw bxsi, cxdx ; ^lbx:si = child object pop cx, dx ; (1) ^lcx:dx = root object mov ax, MSG_META_SET_OBJ_BLOCK_OUTPUT call ObjMessage mov ax, MSG_GEN_SET_USABLE ; set child object usable mov dl, VUM_NOW call ObjMessage clc done: .leave ret DuplicateResourceAndAddChildToRoot endp ; Internal code ; ; Verify the entered password is the same as stored. ; ; Pass: ; Return: carry clear - ok,passed. ; carry set - nope, intrusion. ; ChangeDialogTitle proc near uses ax, cx, dx, bp, di, si .enter cmp cl, PC_WWW je www cmp cl, PC_CHAT je chat cmp cl, PC_NEWSGROUP je newsgroup cmp cl, PC_EMAIL je email cmp cl, PC_PARENTAL_CONTROL je pctrl mov bp, offset defaultTitle jmp ok www: mov bp, offset wwwTitle jmp ok chat: mov bp, offset chatTitle jmp ok newsgroup: mov bp, offset newsgroupTitle jmp ok email: mov bp, offset emailTitle jmp ok pctrl: mov bp, offset pcTitle ok: mov ax, MSG_VIS_TEXT_REPLACE_ALL_OPTR mov dx, handle PCControlStrings mov si, offset PasswordTitle clr cx mov di, mask MF_CALL call ObjMessage .leave ret ChangeDialogTitle endp ; ; C stubs ; SetGeosConvention global PARENTALCONTROLGETACCESSINFO:far PARENTALCONTROLGETACCESSINFO proc far .enter call ParentalControlGetAccessInfo ; ax = flags .leave ret PARENTALCONTROLGETACCESSINFO endp global PARENTALCONTROLSETACCESSINFO:far PARENTALCONTROLSETACCESSINFO proc far flags:word .enter mov ax, flags call ParentalControlSetAccessInfo .leave ret PARENTALCONTROLSETACCESSINFO endp PCCode ends
oeis/194/A194715.asm
neoneye/loda-programs
11
14252
<filename>oeis/194/A194715.asm ; A194715: 15 times triangular numbers. ; 0,15,45,90,150,225,315,420,540,675,825,990,1170,1365,1575,1800,2040,2295,2565,2850,3150,3465,3795,4140,4500,4875,5265,5670,6090,6525,6975,7440,7920,8415,8925,9450,9990,10545,11115,11700,12300,12915,13545,14190,14850,15525,16215,16920,17640,18375,19125,19890,20670,21465,22275,23100,23940,24795,25665,26550,27450,28365,29295,30240,31200,32175,33165,34170,35190,36225,37275,38340,39420,40515,41625,42750,43890,45045,46215,47400,48600,49815,51045,52290,53550,54825,56115,57420,58740,60075,61425,62790 sub $1,$0 bin $1,2 mul $1,15 mov $0,$1
src/third_party/nasm/test/a32offs.asm
Mr-Sheep/naiveproxy
2,219
104972
<reponame>Mr-Sheep/naiveproxy ;Testname=unoptimized; Arguments=-O0 -fbin -oa32offs.bin; Files=a32offs.bin stdout stderr ;Testname=optimized; Arguments=-Ox -fbin -oa32offs.bin; Files=a32offs.bin stdout stderr bits 16 foo: a32 loop foo bar: loop bar, ecx bits 32 baz: a16 loop baz qux: loop qux, cx
programs/asm/menu.asm
Zenith80/initial_emulator
9
26350
.include "keyboard.inc" menu: call line ld hl, .strings ld bc, 0 call indexed_print .poll: call poll_character ld de, .end push de cp keyn jp z, new_game cp keyl jp z, load_game cp keya jp z, about cp keys jp z, settings jp .nokey .end: ret .nokey: ld hl, .strings ld bc, 1 call indexed_print jr .poll .strings: .dw options@menu, invalid@menu .options: .db "Select option: \n","\t'n' - New Game\n","\t'l' - Load Game\n","\t'a' - About page\n","\t's' - Settings screen\n", 0 .invalid: .db "Invalid key pressed!\n",0 to_menu: ld a, 0 out (2), a
data/pokemon/location_evolution.asm
AtmaBuster/pokeplat-gen2
6
247251
<reponame>AtmaBuster/pokeplat-gen2 LocationEvolutionTable: dw .moss_rock dw .ice_rock dw .magnet_field .moss_rock db ILEX_FOREST db ROUTE_2 db -1 .ice_rock db ICE_PATH db -1 .magnet_field db POWER_PLANT db -1
src/Lens/Non-dependent/Traditional.agda
nad/dependent-lenses
3
13376
<gh_stars>1-10 ------------------------------------------------------------------------ -- Traditional non-dependent lenses ------------------------------------------------------------------------ {-# OPTIONS --cubical #-} import Equality.Path as P module Lens.Non-dependent.Traditional {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude open import Bijection equality-with-J as Bij using (_↔_) open import Circle eq as Circle using (𝕊¹) open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_; Is-equivalence) open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J as H-level open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional eq as Trunc using (∥_∥; ∣_∣) open import Preimage equality-with-J using (_⁻¹_) open import Surjection equality-with-J using (_↠_) open import Univalence-axiom equality-with-J open import Lens.Non-dependent eq as Non-dependent hiding (no-first-projection-lens; no-singleton-projection-lens) private variable a b c p : Level A A₁ A₂ B B₁ B₂ : Type a u v x₁ x₂ y₁ y₂ : A ------------------------------------------------------------------------ -- Traditional lenses -- Lenses. record Lens (A : Type a) (B : Type b) : Type (a ⊔ b) where field -- Getter and setter. get : A → B set : A → B → A -- Lens laws. get-set : ∀ a b → get (set a b) ≡ b set-get : ∀ a → set a (get a) ≡ a set-set : ∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂ -- A combination of get and set. modify : (B → B) → A → A modify f x = set x (f (get x)) instance -- Traditional lenses have getters and setters. has-getter-and-setter : Has-getter-and-setter (Lens {a = a} {b = b}) has-getter-and-setter = record { get = Lens.get ; set = Lens.set } -- Lens A B is isomorphic to a nested Σ-type. Lens-as-Σ : Lens A B ↔ ∃ λ (get : A → B) → ∃ λ (set : A → B → A) → (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂) Lens-as-Σ = record { surjection = record { logical-equivalence = record { to = λ l → get l , set l , get-set l , set-get l , set-set l ; from = λ { (get , set , get-set , set-get , set-set) → record { get = get ; set = set ; get-set = get-set ; set-get = set-get ; set-set = set-set } } } ; right-inverse-of = refl } ; left-inverse-of = refl } where open Lens private variable l₁ l₂ : Lens A B -- An example: A lens corresponding to the value of a function for a -- certain input. function-at : Decidable-equality A → A → Lens (A → B) B function-at _≟_ a = record { get = λ f → f a ; set = λ f b a′ → if a ≟ a′ then b else f a′ ; get-set = λ f b → lemma₁ (a ≟ a) ; set-get = λ f → ⟨ext⟩ λ a′ → lemma₂ f (a ≟ a′) ; set-set = λ f b₁ b₂ → ⟨ext⟩ λ a′ → lemma₃ (a ≟ a′) } where lemma₁ : ∀ {b₁ b₂} (d : Dec (a ≡ a)) → if d then b₁ else b₂ ≡ b₁ lemma₁ (yes _) = refl _ lemma₁ (no a≢a) = ⊥-elim $ a≢a (refl _) lemma₂ : ∀ f {a′} (d : Dec (a ≡ a′)) → if d then f a else f a′ ≡ f a′ lemma₂ f (yes a≡a′) = cong f a≡a′ lemma₂ _ (no _) = refl _ lemma₃ : ∀ {a′ b₁ b₂ b₃} (d : Dec (a ≡ a′)) → if d then b₂ else (if d then b₁ else b₃) ≡ if d then b₂ else b₃ lemma₃ (yes _) = refl _ lemma₃ (no _) = refl _ ------------------------------------------------------------------------ -- Somewhat coherent lenses -- Traditional lenses that satisfy some extra coherence properties. record Coherent-lens (A : Type a) (B : Type b) : Type (a ⊔ b) where field lens : Lens A B open Lens lens public field get-set-get : ∀ a → cong get (set-get a) ≡ get-set a (get a) get-set-set : ∀ a b₁ b₂ → cong get (set-set a b₁ b₂) ≡ trans (get-set (set a b₁) b₂) (sym (get-set a b₂)) instance -- Somewhat coherent lenses have getters and setters. coherent-has-getter-and-setter : Has-getter-and-setter (Coherent-lens {a = a} {b = b}) coherent-has-getter-and-setter = record { get = Coherent-lens.get ; set = Coherent-lens.set } -- Coherent-lens A B is equivalent to a nested Σ-type. Coherent-lens-as-Σ : Coherent-lens A B ≃ ∃ λ (l : Lens A B) → let open Lens l in (∀ a → cong get (set-get a) ≡ get-set a (get a)) × (∀ a b₁ b₂ → cong get (set-set a b₁ b₂) ≡ trans (get-set (set a b₁) b₂) (sym (get-set a b₂))) Coherent-lens-as-Σ = Eq.↔→≃ (λ l → lens l , get-set-get l , get-set-set l) (λ (l , get-set-get , get-set-set) → record { lens = l ; get-set-get = get-set-get ; get-set-set = get-set-set }) refl refl where open Coherent-lens ------------------------------------------------------------------------ -- Some lemmas -- If two lenses have equal setters, then they also have equal -- getters. getters-equal-if-setters-equal : let open Lens in (l₁ l₂ : Lens A B) → set l₁ ≡ set l₂ → get l₁ ≡ get l₂ getters-equal-if-setters-equal l₁ l₂ setters-equal = ⟨ext⟩ λ a → get l₁ a ≡⟨ cong (get l₁) $ sym $ set-get l₂ _ ⟩ get l₁ (set l₂ a (get l₂ a)) ≡⟨ cong (λ f → get l₁ (f _ _)) $ sym setters-equal ⟩ get l₁ (set l₁ a (get l₂ a)) ≡⟨ get-set l₁ _ _ ⟩∎ get l₂ a ∎ where open Lens -- If the forward direction of an equivalence is Lens.get l, then the -- setter of l can be expressed using the other direction of the -- equivalence. from≡set : ∀ (l : Lens A B) is-equiv → let open Lens A≃B = Eq.⟨ get l , is-equiv ⟩ in ∀ a b → _≃_.from A≃B b ≡ set l a b from≡set l is-equiv a b = _≃_.to-from Eq.⟨ get , is-equiv ⟩ ( get (set a b) ≡⟨ get-set _ _ ⟩∎ b ∎) where open Lens l ------------------------------------------------------------------------ -- Some lens isomorphisms -- Lens preserves equivalences. Lens-cong : A₁ ≃ A₂ → B₁ ≃ B₂ → Lens A₁ B₁ ≃ Lens A₂ B₂ Lens-cong {A₁ = A₁} {A₂ = A₂} {B₁ = B₁} {B₂ = B₂} A₁≃A₂ B₁≃B₂ = Lens A₁ B₁ ↔⟨ Lens-as-Σ ⟩ (∃ λ (get : A₁ → B₁) → ∃ λ (set : A₁ → B₁ → A₁) → (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂)) ↝⟨ (Σ-cong (→-cong ext A₁≃A₂ B₁≃B₂) λ get → Σ-cong (→-cong ext A₁≃A₂ $ →-cong ext B₁≃B₂ A₁≃A₂) λ set → (Π-cong ext A₁≃A₂ λ a → Π-cong ext B₁≃B₂ λ b → inverse (Eq.≃-≡ B₁≃B₂) F.∘ (≡⇒≃ $ cong (_≡ _) (get (set a b) ≡⟨ sym $ cong₂ (λ a b → get (set a b)) (_≃_.left-inverse-of A₁≃A₂ _) (_≃_.left-inverse-of B₁≃B₂ _) ⟩ get (set (_≃_.from A₁≃A₂ (_≃_.to A₁≃A₂ a)) (_≃_.from B₁≃B₂ (_≃_.to B₁≃B₂ b))) ≡⟨ cong get $ sym $ _≃_.left-inverse-of A₁≃A₂ _ ⟩∎ get (_≃_.from A₁≃A₂ (_≃_.to A₁≃A₂ (set (_≃_.from A₁≃A₂ (_≃_.to A₁≃A₂ a)) (_≃_.from B₁≃B₂ (_≃_.to B₁≃B₂ b))))) ∎))) ×-cong (Π-cong ext A₁≃A₂ λ a → inverse (Eq.≃-≡ A₁≃A₂) F.∘ (≡⇒≃ $ cong (_≡ _) (set a (get a) ≡⟨ cong (set a) $ sym $ _≃_.left-inverse-of B₁≃B₂ _ ⟩ set a (_≃_.from B₁≃B₂ (_≃_.to B₁≃B₂ (get a))) ≡⟨ cong (λ a → set a (_≃_.from B₁≃B₂ (_≃_.to B₁≃B₂ (get a)))) $ sym $ _≃_.left-inverse-of A₁≃A₂ _ ⟩∎ set (_≃_.from A₁≃A₂ (_≃_.to A₁≃A₂ a)) (_≃_.from B₁≃B₂ (_≃_.to B₁≃B₂ (get (_≃_.from A₁≃A₂ (_≃_.to A₁≃A₂ a))))) ∎))) ×-cong (inverse $ Π-cong ext (inverse A₁≃A₂) λ a → inverse $ Π-cong ext B₁≃B₂ λ b₁ → inverse $ Π-cong ext (inverse B₁≃B₂) λ b₂ → (≡⇒≃ $ cong (λ a′ → set a′ (_≃_.from B₁≃B₂ b₂) ≡ set (_≃_.from A₁≃A₂ a) (_≃_.from B₁≃B₂ b₂)) (_≃_.from A₁≃A₂ (_≃_.to A₁≃A₂ (set (_≃_.from A₁≃A₂ a) (_≃_.from B₁≃B₂ (_≃_.to B₁≃B₂ b₁)))) ≡⟨ _≃_.left-inverse-of A₁≃A₂ _ ⟩ set (_≃_.from A₁≃A₂ a) (_≃_.from B₁≃B₂ (_≃_.to B₁≃B₂ b₁)) ≡⟨ cong (set (_≃_.from A₁≃A₂ a)) $ _≃_.left-inverse-of B₁≃B₂ _ ⟩∎ set (_≃_.from A₁≃A₂ a) b₁ ∎)) F.∘ Eq.≃-≡ A₁≃A₂)) ⟩ (∃ λ (get : A₂ → B₂) → ∃ λ (set : A₂ → B₂ → A₂) → (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂)) ↔⟨ inverse Lens-as-Σ ⟩□ Lens A₂ B₂ □ -- If B is a proposition, then Lens A B is isomorphic to -- (A → B) × ((a : A) → a ≡ a). lens-to-proposition↔ : Is-proposition B → Lens A B ↔ (A → B) × ((a : A) → a ≡ a) lens-to-proposition↔ {B = B} {A = A} B-prop = Lens A B ↝⟨ Lens-as-Σ ⟩ (∃ λ (get : A → B) → ∃ λ (set : A → B → A) → (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂)) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → drop-⊤-left-× λ _ → _⇔_.to contractible⇔↔⊤ $ Π-closure ext 0 λ _ → Π-closure ext 0 λ _ → +⇒≡ B-prop) ⟩ (∃ λ (get : A → B) → ∃ λ (set : A → B → A) → (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂)) ↝⟨ (∃-cong λ get → ∃-cong λ set → ∃-cong λ _ → ∀-cong ext λ a → ∀-cong ext λ b₁ → ∀-cong ext λ b₂ → ≡⇒↝ _ ( (set (set a b₁) b₂ ≡ set a b₂) ≡⟨ cong (λ b → set (set a b) b₂ ≡ _) (B-prop _ _) ⟩ (set (set a (get a)) b₂ ≡ set a b₂) ≡⟨ cong (λ b → set (set a (get a)) b ≡ _) (B-prop _ _) ⟩ (set (set a (get a)) (get (set a (get a))) ≡ set a b₂) ≡⟨ cong (λ b → _ ≡ set a b) (B-prop _ _) ⟩∎ (set (set a (get a)) (get (set a (get a))) ≡ set a (get a)) ∎)) ⟩ (∃ λ (get : A → B) → ∃ λ (set : A → B → A) → (∀ a → set a (get a) ≡ a) × (∀ a → B → B → set (set a (get a)) (get (set a (get a))) ≡ set a (get a))) ↝⟨ (∃-cong λ get → Σ-cong (A→B→A↔A→A get) λ _ → F.id) ⟩ ((A → B) × ∃ λ (f : A → A) → (∀ a → f a ≡ a) × (∀ a → B → B → f (f a) ≡ f a)) ↝⟨ (∃-cong λ get → ∃-cong λ _ → ∃-cong λ _ → ∀-cong ext λ a → drop-⊤-left-Π ext (B↔⊤ (get a)) F.∘ drop-⊤-left-Π ext (B↔⊤ (get a))) ⟩ ((A → B) × ∃ λ (f : A → A) → (∀ a → f a ≡ a) × (∀ a → f (f a) ≡ f a)) ↝⟨ (∃-cong λ _ → ∃-cong λ f → ∃-cong λ f≡id → ∀-cong ext λ a → ≡⇒↝ _ (cong₂ _≡_ (trans (f≡id (f a)) (f≡id a)) (f≡id a))) ⟩ ((A → B) × ∃ λ (f : A → A) → (∀ a → f a ≡ a) × (∀ a → a ≡ a)) ↝⟨ (∃-cong λ _ → Σ-assoc F.∘ (∃-cong λ _ → Σ-cong (Eq.extensionality-isomorphism ext) λ _ → F.id)) ⟩ (A → B) × (∃ λ (f : A → A) → f ≡ id) × (∀ a → a ≡ a) ↝⟨ (∃-cong λ _ → drop-⊤-left-× λ _ → _⇔_.to contractible⇔↔⊤ $ singleton-contractible _) ⟩□ (A → B) × (∀ a → a ≡ a) □ where B↔⊤ : B → B ↔ ⊤ B↔⊤ b = _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible B-prop b A→B→A↔A→A : (A → B) → (A → B → A) ↔ (A → A) A→B→A↔A→A get = (A → B → A) ↝⟨ ∀-cong ext (λ a → drop-⊤-left-Π ext $ B↔⊤ (get a)) ⟩□ (A → A) □ -- Lens A ⊤ is isomorphic to (a : A) → a ≡ a. lens-to-⊤↔ : Lens A ⊤ ↔ ((a : A) → a ≡ a) lens-to-⊤↔ {A = A} = Lens A ⊤ ↝⟨ lens-to-proposition↔ (mono₁ 0 ⊤-contractible) ⟩ (A → ⊤) × ((a : A) → a ≡ a) ↝⟨ drop-⊤-left-× (λ _ → →-right-zero) ⟩□ ((a : A) → a ≡ a) □ -- Lens A ⊥ is isomorphic to ¬ A. lens-to-⊥↔ : Lens A (⊥ {ℓ = b}) ↔ ¬ A lens-to-⊥↔ {A = A} = Lens A ⊥ ↝⟨ lens-to-proposition↔ ⊥-propositional ⟩ (A → ⊥) × ((a : A) → a ≡ a) ↝⟨ →-cong ext F.id (Bij.⊥↔uninhabited ⊥-elim) ×-cong F.id ⟩ ¬ A × ((a : A) → a ≡ a) ↝⟨ drop-⊤-right lemma ⟩□ ¬ A □ where lemma : ¬ A → ((a : A) → a ≡ a) ↔ ⊤ lemma ¬a = record { surjection = record { logical-equivalence = record { to = _ ; from = λ _ _ → refl _ } ; right-inverse-of = λ _ → refl _ } ; left-inverse-of = λ eq → ⟨ext⟩ λ a → ⊥-elim (¬a a) } -- See also lens-from-⊥≃⊤ and lens-from-⊤≃codomain-contractible below. ------------------------------------------------------------------------ -- Some lens results related to h-levels -- If the domain of a lens is inhabited and has h-level n, -- then the codomain also has h-level n. h-level-respects-lens-from-inhabited : ∀ n → Lens A B → A → H-level n A → H-level n B h-level-respects-lens-from-inhabited {A = A} {B = B} n l a = H-level n A ↝⟨ H-level.respects-surjection surj n ⟩□ H-level n B □ where open Lens l surj : A ↠ B surj = record { logical-equivalence = record { to = get ; from = set a } ; right-inverse-of = λ b → get (set a b) ≡⟨ get-set a b ⟩∎ b ∎ } -- Lenses with contractible domains have contractible codomains. contractible-to-contractible : Lens A B → Contractible A → Contractible B contractible-to-contractible l c = h-level-respects-lens-from-inhabited _ l (proj₁ c) c -- If A and B have h-level n given the assumption that A is inhabited, -- then Lens A B also has h-level n. lens-preserves-h-level : ∀ n → (A → H-level n A) → (A → H-level n B) → H-level n (Lens A B) lens-preserves-h-level n hA hB = H-level.respects-surjection (_↔_.surjection (inverse Lens-as-Σ)) n $ Σ-closure n (Π-closure ext n λ a → hB a) λ _ → Σ-closure n (Π-closure ext n λ a → Π-closure ext n λ _ → hA a) λ _ → ×-closure n (Π-closure ext n λ a → Π-closure ext n λ _ → +⇒≡ $ mono₁ n (hB a)) $ ×-closure n (Π-closure ext n λ a → +⇒≡ $ mono₁ n (hA a)) (Π-closure ext n λ a → Π-closure ext n λ _ → Π-closure ext n λ _ → +⇒≡ $ mono₁ n (hA a)) -- If A has positive h-level n, then Lens A B also has h-level n. lens-preserves-h-level-of-domain : ∀ n → H-level (1 + n) A → H-level (1 + n) (Lens A B) lens-preserves-h-level-of-domain n hA = [inhabited⇒+]⇒+ n λ l → lens-preserves-h-level (1 + n) (λ _ → hA) λ a → h-level-respects-lens-from-inhabited _ l a hA -- Lens 𝕊¹ ⊤ is not propositional (assuming univalence). -- -- (The lemma does not actually use the univalence argument, but -- univalence is used by Circle.¬-type-of-refl-propositional.) ¬-lens-to-⊤-propositional : Univalence (# 0) → ¬ Is-proposition (Lens 𝕊¹ ⊤) ¬-lens-to-⊤-propositional _ = Is-proposition (Lens 𝕊¹ ⊤) ↝⟨ H-level.respects-surjection (_↔_.surjection lens-to-⊤↔) 1 ⟩ Is-proposition ((x : 𝕊¹) → x ≡ x) ↝⟨ H-level-cong _ 1 (Π-cong ext (inverse Bij.↑↔) λ _ → Eq.≃-≡ $ Eq.↔⇒≃ Bij.↑↔) ⟩ Is-proposition ((x : ↑ lzero 𝕊¹) → x ≡ x) ↝⟨ proj₂ $ Circle.¬-type-of-refl-propositional ⟩□ ⊥ □ ------------------------------------------------------------------------ -- Some equality characterisation lemmas abstract -- An equality characterisation lemma. equality-characterisation₁ : let open Lens in l₁ ≡ l₂ ↔ ∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → subst (λ get → get (set l₂ a b) ≡ b) g (subst (λ set → get l₁ (set a b) ≡ b) s (get-set l₁ a b)) ≡ get-set l₂ a b) × (∀ a → subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂) equality-characterisation₁ {l₁ = l₁} {l₂ = l₂} = let l₁′ = _↔_.to Lens-as-Σ l₁ l₂′ = _↔_.to Lens-as-Σ l₂ in l₁ ≡ l₂ ↔⟨ Eq.≃-≡ (Eq.↔⇒≃ (inverse Lens-as-Σ)) ⟩ l₁′ ≡ l₂′ ↔⟨ Eq.≃-≡ (Eq.↔⇒≃ (inverse Σ-assoc)) ⟩ ((get l₁ , set l₁) , proj₂ (proj₂ l₁′)) ≡ ((get l₂ , set l₂) , proj₂ (proj₂ l₂′)) ↝⟨ inverse Bij.Σ-≡,≡↔≡ ⟩ (∃ λ (gs : (get l₁ , set l₁) ≡ (get l₂ , set l₂)) → subst (λ { (get , set) → (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂) }) gs (proj₂ (proj₂ l₁′)) ≡ proj₂ (proj₂ l₂′)) ↝⟨ Σ-cong (inverse ≡×≡↔≡) (λ gs → ≡⇒↝ _ $ cong (λ (gs : (get l₁ , set l₁) ≡ (get l₂ , set l₂)) → subst (λ { (get , set) → (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂) }) gs (proj₂ (proj₂ l₁′)) ≡ proj₂ (proj₂ l₂′)) (sym $ _↔_.right-inverse-of ≡×≡↔≡ gs)) ⟩ (∃ λ (gs : get l₁ ≡ get l₂ × set l₁ ≡ set l₂) → subst (λ { (get , set) → (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂) }) (_↔_.to ≡×≡↔≡ gs) (proj₂ (proj₂ l₁′)) ≡ proj₂ (proj₂ l₂′)) ↝⟨ inverse Σ-assoc ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → subst (λ { (get , set) → (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂) }) (_↔_.to ≡×≡↔≡ (g , s)) (proj₂ (proj₂ l₁′)) ≡ proj₂ (proj₂ l₂′)) ↝⟨ (∃-cong λ g → ∃-cong λ s → ≡⇒↝ _ $ cong (λ x → x ≡ proj₂ (proj₂ l₂′)) (push-subst-, {y≡z = _↔_.to ≡×≡↔≡ (g , s)} _ _)) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → ( subst (λ { (get , set) → ∀ a b → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s)) (get-set l₁) , subst (λ { (get , set) → (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂) }) (_↔_.to ≡×≡↔≡ (g , s)) (proj₂ (proj₂ (proj₂ l₁′))) ) ≡ proj₂ (proj₂ l₂′)) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → inverse ≡×≡↔≡) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → subst (λ { (get , set) → ∀ a b → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s)) (get-set l₁) ≡ get-set l₂ × subst (λ { (get , set) → (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂) }) (_↔_.to ≡×≡↔≡ (g , s)) (proj₂ (proj₂ (proj₂ l₁′))) ≡ proj₂ (proj₂ (proj₂ l₂′))) ↝⟨ (∃-cong λ g → ∃-cong λ s → ∃-cong λ _ → ≡⇒↝ _ $ cong (λ x → x ≡ proj₂ (proj₂ (proj₂ l₂′))) (push-subst-, {y≡z = _↔_.to ≡×≡↔≡ (g , s)} _ _)) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → subst (λ { (get , set) → ∀ a b → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s)) (get-set l₁) ≡ get-set l₂ × ( subst (λ { (get , set) → ∀ a → set a (get a) ≡ a }) (_↔_.to ≡×≡↔≡ (g , s)) (set-get l₁) , subst (λ { (get , set) → ∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂ }) (_↔_.to ≡×≡↔≡ (g , s)) (set-set l₁) ) ≡ proj₂ (proj₂ (proj₂ l₂′))) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → inverse ≡×≡↔≡) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → subst (λ { (get , set) → ∀ a b → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s)) (get-set l₁) ≡ get-set l₂ × subst (λ { (get , set) → ∀ a → set a (get a) ≡ a }) (_↔_.to ≡×≡↔≡ (g , s)) (set-get l₁) ≡ set-get l₂ × subst (λ { (get , set) → ∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂ }) (_↔_.to ≡×≡↔≡ (g , s)) (set-set l₁) ≡ set-set l₂) ↝⟨ (∃-cong λ g → ∃-cong λ s → lemma₁ (λ { (get , set) a → ∀ b → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s)) ×-cong lemma₁ (λ { (get , set) a → set a (get a) ≡ a }) (_↔_.to ≡×≡↔≡ (g , s)) ×-cong lemma₁ (λ { (get , set) a → ∀ b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂ }) (_↔_.to ≡×≡↔≡ (g , s))) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a → subst (λ { (get , set) → ∀ b → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s)) (get-set l₁ a) ≡ get-set l₂ a) × (∀ a → subst (λ { (get , set) → set a (get a) ≡ a }) (_↔_.to ≡×≡↔≡ (g , s)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a → subst (λ { (get , set) → ∀ b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂ }) (_↔_.to ≡×≡↔≡ (g , s)) (set-set l₁ a) ≡ set-set l₂ a)) ↝⟨ (∃-cong λ g → ∃-cong λ s → (∀-cong ext λ a → lemma₁ (λ { (get , set) b → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s))) ×-cong F.id ×-cong (∀-cong ext λ a → lemma₁ (λ { (get , set) b₁ → ∀ b₂ → set (set a b₁) b₂ ≡ set a b₂ }) (_↔_.to ≡×≡↔≡ (g , s)))) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → subst (λ { (get , set) → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s)) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → subst (λ { (get , set) → set a (get a) ≡ a }) (_↔_.to ≡×≡↔≡ (g , s)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ → subst (λ { (get , set) → ∀ b₂ → set (set a b₁) b₂ ≡ set a b₂ }) (_↔_.to ≡×≡↔≡ (g , s)) (set-set l₁ a b₁) ≡ set-set l₂ a b₁)) ↝⟨ (∃-cong λ g → ∃-cong λ s → ∃-cong λ _ → ∃-cong λ _ → ∀-cong ext λ a → ∀-cong ext λ b₁ → lemma₁ (λ { (get , set) b₂ → set (set a b₁) b₂ ≡ set a b₂ }) (_↔_.to ≡×≡↔≡ (g , s))) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → subst (λ { (get , set) → get (set a b) ≡ b }) (_↔_.to ≡×≡↔≡ (g , s)) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → subst (λ { (get , set) → set a (get a) ≡ a }) (_↔_.to ≡×≡↔≡ (g , s)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ { (get , set) → set (set a b₁) b₂ ≡ set a b₂ }) (_↔_.to ≡×≡↔≡ (g , s)) (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂)) ↝⟨ (∃-cong λ g → ∃-cong λ s → (∀-cong ext λ a → ∀-cong ext λ b → lemma₂ (λ { (get , set) → get (set a b) ≡ b }) g s) ×-cong (∀-cong ext λ a → lemma₂ (λ { (get , set) → set a (get a) ≡ a }) g s) ×-cong (∀-cong ext λ a → ∀-cong ext λ b₁ → ∀-cong ext λ b₂ → lemma₂ (λ { (get , set) → set (set a b₁) b₂ ≡ set a b₂ }) g s)) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → subst (λ get → get (set l₂ a b) ≡ b) g (subst (λ set → get l₁ (set a b) ≡ b) s (get-set l₁ a b)) ≡ get-set l₂ a b) × (∀ a → subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ get → set l₂ (set l₂ a b₁) b₂ ≡ set l₂ a b₂) g (subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂)) ≡ set-set l₂ a b₁ b₂)) ↝⟨ (∃-cong λ g → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ≡⇒↝ _ $ cong (λ x → x ≡ _) $ subst-const g) ⟩□ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → subst (λ get → get (set l₂ a b) ≡ b) g (subst (λ set → get l₁ (set a b) ≡ b) s (get-set l₁ a b)) ≡ get-set l₂ a b) × (∀ a → subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂)) □ where open Lens abstract lemma₁ : ∀ (C : A → B → Type c) (eq : u ≡ v) {f g} → (subst (λ x → ∀ y → C x y) eq f ≡ g) ↔ (∀ y → subst (λ x → C x y) eq (f y) ≡ g y) lemma₁ C eq {f} {g} = subst (λ x → ∀ y → C x y) eq f ≡ g ↔⟨ inverse $ Eq.extensionality-isomorphism ext ⟩ (∀ y → subst (λ x → ∀ y → C x y) eq f y ≡ g y) ↝⟨ (∀-cong ext λ y → ≡⇒↝ _ $ cong (λ x → x ≡ _) (sym $ push-subst-application eq _)) ⟩□ (∀ y → subst (λ x → C x y) eq (f y) ≡ g y) □ lemma₂ : (P : A × B → Type p) (x₁≡x₂ : x₁ ≡ x₂) (y₁≡y₂ : y₁ ≡ y₂) → ∀ {p p′} → (subst P (_↔_.to ≡×≡↔≡ (x₁≡x₂ , y₁≡y₂)) p ≡ p′) ↔ (subst (λ x → P (x , y₂)) x₁≡x₂ (subst (λ y → P (x₁ , y)) y₁≡y₂ p) ≡ p′) lemma₂ P x₁≡x₂ y₁≡y₂ {p = p} = ≡⇒↝ _ $ cong (_≡ _) $ elim¹ (λ y₁≡y₂ → subst P (_↔_.to ≡×≡↔≡ (x₁≡x₂ , y₁≡y₂)) p ≡ subst (λ x → P (x , _)) x₁≡x₂ (subst (λ y → P (_ , y)) y₁≡y₂ p)) (subst P (_↔_.to ≡×≡↔≡ (x₁≡x₂ , refl _)) p ≡⟨⟩ subst P (cong₂ _,_ x₁≡x₂ (refl _)) p ≡⟨⟩ subst P (trans (cong (_, _) x₁≡x₂) (cong (_ ,_) (refl _))) p ≡⟨ cong (λ eq → subst P (trans (cong (_, _) x₁≡x₂) eq) p) $ cong-refl _ ⟩ subst P (trans (cong (_, _) x₁≡x₂) (refl _)) p ≡⟨ cong (λ eq → subst P eq p) $ trans-reflʳ _ ⟩ subst P (cong (_, _) x₁≡x₂) p ≡⟨ sym $ subst-∘ _ _ _ ⟩ subst (λ x → P (x , _)) x₁≡x₂ p ≡⟨ cong (subst (λ x → P (x , _)) x₁≡x₂) $ sym $ subst-refl _ _ ⟩∎ subst (λ x → P (x , _)) x₁≡x₂ (subst (λ y → P (_ , y)) (refl _) p) ∎) _ -- Another equality characterisation lemma. equality-characterisation₂ : let open Lens in l₁ ≡ l₂ ↔ ∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → trans (sym (cong₂ (λ set get → get (set a b)) s g)) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → trans (sym (cong₂ (λ set get → set a (get a)) s g)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂) equality-characterisation₂ {l₁ = l₁} {l₂ = l₂} = l₁ ≡ l₂ ↝⟨ equality-characterisation₁ ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → subst (λ get → get (set l₂ a b) ≡ b) g (subst (λ set → get l₁ (set a b) ≡ b) s (get-set l₁ a b)) ≡ get-set l₂ a b) × (∀ a → subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂)) ↝⟨ (∃-cong λ g → ∃-cong λ s → (∀-cong ext λ a → ∀-cong ext λ b → ≡⇒↝ _ $ cong (_≡ _) $ lemma₁ g s a b) ×-cong (∀-cong ext λ a → ≡⇒↝ _ $ cong (_≡ _) $ lemma₂ g s a) ×-cong F.id) ⟩□ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → trans (sym (cong₂ (λ set get → get (set a b)) s g)) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → trans (sym (cong₂ (λ set get → set a (get a)) s g)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂)) □ where open Lens lemma₁ : (g : get l₁ ≡ get l₂) (s : set l₁ ≡ set l₂) → ∀ a b → subst (λ get → get (set l₂ a b) ≡ b) g (subst (λ set → get l₁ (set a b) ≡ b) s (get-set l₁ a b)) ≡ trans (sym (cong₂ (λ set get → get (set a b)) s g)) (get-set l₁ a b) lemma₁ g s a b = subst (λ get → get (set l₂ a b) ≡ b) g (subst (λ set → get l₁ (set a b) ≡ b) s (get-set l₁ a b)) ≡⟨ cong (λ eq → subst (λ get → get (set l₂ a b) ≡ b) g eq) $ subst-in-terms-of-trans-and-cong {x≡y = s} {fx≡gx = (get-set l₁ a b)} ⟩ subst (λ get → get (set l₂ a b) ≡ b) g (trans (sym (cong (λ set → get l₁ (set a b)) s)) (trans (get-set l₁ a b) (cong (const b) s))) ≡⟨ cong (λ eq → subst (λ get → get (set l₂ a b) ≡ b) g (trans (sym (cong (λ set → get l₁ (set a b)) s)) (trans _ eq))) $ cong-const s ⟩ subst (λ get → get (set l₂ a b) ≡ b) g (trans (sym (cong (λ set → get l₁ (set a b)) s)) (trans (get-set l₁ a b) (refl _))) ≡⟨ cong (λ eq → subst (λ get → get (set l₂ a b) ≡ b) g (trans _ eq)) $ trans-reflʳ _ ⟩ subst (λ get → get (set l₂ a b) ≡ b) g (trans (sym (cong (λ set → get l₁ (set a b)) s)) (get-set l₁ a b)) ≡⟨ subst-in-terms-of-trans-and-cong {x≡y = g} {fx≡gx = trans _ (get-set l₁ a b)} ⟩ trans (sym (cong (λ get → get (set l₂ a b)) g)) (trans (trans (sym (cong (λ set → get l₁ (set a b)) s)) (get-set l₁ a b)) (cong (const b) g)) ≡⟨ cong (λ eq → trans (sym (cong (λ get → get (set l₂ a b)) g)) (trans (trans (sym (cong (λ set → get l₁ (set a b)) s)) (get-set l₁ a b)) eq)) $ cong-const g ⟩ trans (sym (cong (λ get → get (set l₂ a b)) g)) (trans (trans (sym (cong (λ set → get l₁ (set a b)) s)) (get-set l₁ a b)) (refl _)) ≡⟨ cong (trans _) $ trans-reflʳ _ ⟩ trans (sym (cong (λ get → get (set l₂ a b)) g)) (trans (sym (cong (λ set → get l₁ (set a b)) s)) (get-set l₁ a b)) ≡⟨ sym $ trans-assoc _ _ (get-set l₁ a b) ⟩ trans (trans (sym (cong (λ get → get (set l₂ a b)) g)) (sym (cong (λ set → get l₁ (set a b)) s))) (get-set l₁ a b) ≡⟨ cong (λ eq → trans eq (get-set l₁ a b)) $ sym $ sym-trans _ (cong (λ get → get (set l₂ a b)) g) ⟩ trans (sym (trans (cong (λ set → get l₁ (set a b)) s) (cong (λ get → get (set l₂ a b)) g))) (get-set l₁ a b) ≡⟨⟩ trans (sym (cong₂ (λ set get → get (set a b)) s g)) (get-set l₁ a b) ∎ lemma₂ : (g : get l₁ ≡ get l₂) (s : set l₁ ≡ set l₂) → ∀ a → subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡ trans (sym (cong₂ (λ set get → set a (get a)) s g)) (set-get l₁ a) lemma₂ g s a = subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡⟨⟩ subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡⟨ cong (subst (λ get → set l₂ a (get a) ≡ a) g) $ subst-in-terms-of-trans-and-cong {x≡y = s} {fx≡gx = set-get l₁ a} ⟩ subst (λ get → set l₂ a (get a) ≡ a) g (trans (sym (cong (λ set → set a (get l₁ a)) s)) (trans (set-get l₁ a) (cong (const a) s))) ≡⟨ cong (λ eq → subst (λ get → set l₂ a (get a) ≡ a) g (trans (sym (cong (λ set → set a (get l₁ a)) s)) (trans _ eq))) $ cong-const s ⟩ subst (λ get → set l₂ a (get a) ≡ a) g (trans (sym (cong (λ set → set a (get l₁ a)) s)) (trans (set-get l₁ a) (refl _))) ≡⟨ cong (λ eq → subst (λ get → set l₂ a (get a) ≡ a) g (trans _ eq)) $ trans-reflʳ _ ⟩ subst (λ get → set l₂ a (get a) ≡ a) g (trans (sym (cong (λ set → set a (get l₁ a)) s)) (set-get l₁ a)) ≡⟨ subst-in-terms-of-trans-and-cong {x≡y = g} {fx≡gx = trans (sym (cong (λ set → set a (get l₁ a)) s)) (set-get l₁ a)} ⟩ trans (sym (cong (λ get → set l₂ a (get a)) g)) (trans (trans (sym (cong (λ set → set a (get l₁ a)) s)) (set-get l₁ a)) (cong (const a) g)) ≡⟨ cong (λ eq → trans (sym (cong (λ get → set l₂ a (get a)) g)) (trans (trans (sym (cong (λ set → set a (get l₁ a)) s)) (set-get l₁ a)) eq)) $ cong-const g ⟩ trans (sym (cong (λ get → set l₂ a (get a)) g)) (trans (trans (sym (cong (λ set → set a (get l₁ a)) s)) (set-get l₁ a)) (refl _)) ≡⟨ cong (trans _) $ trans-reflʳ _ ⟩ trans (sym (cong (λ get → set l₂ a (get a)) g)) (trans (sym (cong (λ set → set a (get l₁ a)) s)) (set-get l₁ a)) ≡⟨ sym $ trans-assoc _ _ (set-get l₁ a) ⟩ trans (trans (sym (cong (λ get → set l₂ a (get a)) g)) (sym (cong (λ set → set a (get l₁ a)) s))) (set-get l₁ a) ≡⟨ cong (λ eq → trans eq (set-get l₁ a)) $ sym $ sym-trans _ (cong (λ get → set l₂ a (get a)) g) ⟩ trans (sym (trans (cong (λ set → set a (get l₁ a)) s) (cong (λ get → set l₂ a (get a)) g))) (set-get l₁ a) ≡⟨⟩ trans (sym (cong₂ (λ set get → set a (get a)) s g)) (set-get l₁ a) ∎ -- And another one. equality-characterisation₃ : let open Lens in l₁ ≡ l₂ ↔ ∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → trans (sym (cong₂ (λ set get → get (set a b)) s g)) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → trans (sym (cong₂ (λ set get → set a (get a)) s g)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → trans (set-set l₁ a b₁ b₂) (cong (λ set → set a b₂) s) ≡ trans (cong (λ set → set (set a b₁) b₂) s) (set-set l₂ a b₁ b₂)) equality-characterisation₃ {l₁ = l₁} {l₂ = l₂} = l₁ ≡ l₂ ↝⟨ equality-characterisation₂ ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → trans (sym (cong₂ (λ set get → get (set a b)) s g)) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → trans (sym (cong₂ (λ set get → set a (get a)) s g)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂)) ↝⟨ (∃-cong λ g → ∃-cong λ s → ∃-cong λ _ → ∃-cong λ _ → ∀-cong ext λ a → ∀-cong ext λ b₁ → ∀-cong ext λ b₂ → ≡⇒↝ _ $ lemma g s a b₁ b₂) ⟩□ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → trans (sym (cong₂ (λ set get → get (set a b)) s g)) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → trans (sym (cong₂ (λ set get → set a (get a)) s g)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → trans (set-set l₁ a b₁ b₂) (cong (λ set → set a b₂) s) ≡ trans (cong (λ set → set (set a b₁) b₂) s) (set-set l₂ a b₁ b₂))) □ where open Lens lemma : (g : get l₁ ≡ get l₂) (s : set l₁ ≡ set l₂) → ∀ a b₁ b₂ → (subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂) ≡ (trans (set-set l₁ a b₁ b₂) (cong (λ set → set a b₂) s) ≡ trans (cong (λ set → set (set a b₁) b₂) s) (set-set l₂ a b₁ b₂)) lemma g s a b₁ b₂ = subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂ ≡⟨ cong (_≡ _) $ subst-in-terms-of-trans-and-cong {x≡y = s} {fx≡gx = set-set l₁ a b₁ b₂} ⟩ trans (sym (cong (λ set → set (set a b₁) b₂) s)) (trans (set-set l₁ a b₁ b₂) (cong (λ set → set a b₂) s)) ≡ set-set l₂ a b₁ b₂ ≡⟨ [trans≡]≡[≡trans-symˡ] _ _ _ ⟩ trans (set-set l₁ a b₁ b₂) (cong (λ set → set a b₂) s) ≡ trans (sym (sym (cong (λ set → set (set a b₁) b₂) s))) (set-set l₂ a b₁ b₂) ≡⟨ cong (λ eq → trans _ (cong (λ set → set a b₂) s) ≡ trans eq (set-set l₂ a b₁ b₂)) $ sym-sym (cong (λ set → set (set a b₁) b₂) s) ⟩ trans (set-set l₁ a b₁ b₂) (cong (λ set → set a b₂) s) ≡ trans (cong (λ set → set (set a b₁) b₂) s) (set-set l₂ a b₁ b₂) ∎ -- And yet another one. equality-characterisation₄ : let open Lens in l₁ ≡ l₂ ↔ ∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (s : ∀ a b → set l₁ a b ≡ set l₂ a b) → (∀ a b → trans (sym (trans (cong (get l₁) (s a b)) (g (set l₂ a b)))) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → trans (sym (trans (s a (get l₁ a)) (cong (set l₂ a) (g a)))) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → trans (set-set l₁ a b₁ b₂) (s a b₂) ≡ trans (cong (λ set → set (set a b₁) b₂) (⟨ext⟩ (⟨ext⟩ ∘ s))) (set-set l₂ a b₁ b₂)) equality-characterisation₄ {l₁ = l₁} {l₂ = l₂} = l₁ ≡ l₂ ↝⟨ equality-characterisation₃ ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → trans (sym (cong₂ (λ set get → get (set a b)) s g)) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → trans (sym (cong₂ (λ set get → set a (get a)) s g)) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → trans (set-set l₁ a b₁ b₂) (cong (λ set → set a b₂) s) ≡ trans (cong (λ set → set (set a b₁) b₂) s) (set-set l₂ a b₁ b₂))) ↝⟨ (Σ-cong (inverse $ Eq.extensionality-isomorphism ext) λ g → Σ-cong (inverse $ Eq.extensionality-isomorphism ext F.∘ ∀-cong ext λ _ → Eq.extensionality-isomorphism ext) λ s → (∀-cong ext λ a → ∀-cong ext λ b → ≡⇒↝ _ $ cong (λ eq → trans (sym eq) (get-set l₁ a b) ≡ _) ( cong₂ (λ set get → get (set a b)) s g ≡⟨⟩ trans (cong (λ set → get l₁ (set a b)) s) (cong (λ get → get (set l₂ a b)) g) ≡⟨ cong (λ eq → trans eq (ext⁻¹ g (set l₂ a b))) $ sym $ cong-∘ _ _ s ⟩ trans (cong (get l₁ ∘ (_$ b)) (ext⁻¹ s a)) (ext⁻¹ g (set l₂ a b)) ≡⟨ cong (λ eq → trans eq (ext⁻¹ g (set l₂ a b))) $ sym $ cong-∘ _ _ (ext⁻¹ s a) ⟩∎ trans (cong (get l₁) (ext⁻¹ (ext⁻¹ s a) b)) (ext⁻¹ g (set l₂ a b)) ∎)) ×-cong (∀-cong ext λ a → ≡⇒↝ _ $ cong (λ eq → trans (sym eq) (set-get l₁ a) ≡ _) ( cong₂ (λ set get → set a (get a)) s g ≡⟨⟩ trans (cong (λ set → set a (get l₁ a)) s) (cong (λ get → set l₂ a (get a)) g) ≡⟨ sym $ cong₂ trans (cong-∘ _ _ s) (cong-∘ _ _ g) ⟩ trans (ext⁻¹ (ext⁻¹ s a) (get l₁ a)) (cong (set l₂ a) (ext⁻¹ g a)) ∎)) ×-cong ∀-cong ext λ a → ∀-cong ext λ b₁ → ∀-cong ext λ b₂ → ≡⇒↝ _ $ cong₂ (λ p q → trans _ p ≡ trans (cong (λ set → set (set a b₁) b₂) q) (set-set l₂ a b₁ b₂)) ( cong (λ set → set a b₂) s ≡⟨ sym $ cong-∘ _ _ s ⟩∎ ext⁻¹ (ext⁻¹ s a) b₂ ∎) ( s ≡⟨ sym $ _≃_.right-inverse-of (Eq.extensionality-isomorphism bad-ext) _ ⟩ ⟨ext⟩ (ext⁻¹ s) ≡⟨ (cong ⟨ext⟩ $ ⟨ext⟩ λ _ → sym $ _≃_.right-inverse-of (Eq.extensionality-isomorphism bad-ext) _) ⟩∎ ⟨ext⟩ (⟨ext⟩ ∘ ext⁻¹ ∘ ext⁻¹ s) ∎)) ⟩□ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (s : ∀ a b → set l₁ a b ≡ set l₂ a b) → (∀ a b → trans (sym (trans (cong (get l₁) (s a b)) (g (set l₂ a b)))) (get-set l₁ a b) ≡ get-set l₂ a b) × (∀ a → trans (sym (trans (s a (get l₁ a)) (cong (set l₂ a) (g a)))) (set-get l₁ a) ≡ set-get l₂ a) × (∀ a b₁ b₂ → trans (set-set l₁ a b₁ b₂) (s a b₂) ≡ trans (cong (λ set → set (set a b₁) b₂) (⟨ext⟩ (⟨ext⟩ ∘ s))) (set-set l₂ a b₁ b₂))) □ where open Lens -- A lemma that can be used to prove that two lenses with -- definitionally equal getters and setters are equal. equal-laws→≡ : {get : A → B} {set : A → B → A} {l₁′ l₂′ : (∀ a b → get (set a b) ≡ b) × (∀ a → set a (get a) ≡ a) × (∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂)} → let l₁ = _↔_.from Lens-as-Σ (get , set , l₁′) l₂ = _↔_.from Lens-as-Σ (get , set , l₂′) open Lens in (∀ a b → get-set l₁ a b ≡ get-set l₂ a b) → (∀ a → set-get l₁ a ≡ set-get l₂ a) → (∀ a b₁ b₂ → set-set l₁ a b₁ b₂ ≡ set-set l₂ a b₁ b₂) → l₁ ≡ l₂ equal-laws→≡ {l₁′ = l₁′} {l₂′ = l₂′} hyp₁ hyp₂ hyp₃ = let l₁″ = _↔_.from Lens-as-Σ (_ , _ , l₁′) l₂″ = _↔_.from Lens-as-Σ (_ , _ , l₂′) in _↔_.from equality-characterisation₂ ( refl _ , refl _ , (λ a b → trans (sym (cong₂ (λ set get → get (set a b)) (refl _) (refl _))) (get-set l₁″ a b) ≡⟨ cong (λ eq → trans (sym eq) _) $ cong₂-refl _ ⟩ trans (sym (refl _)) (get-set l₁″ a b) ≡⟨ cong (flip trans _) sym-refl ⟩ trans (refl _) (get-set l₁″ a b) ≡⟨ trans-reflˡ _ ⟩ get-set l₁″ a b ≡⟨ hyp₁ _ _ ⟩∎ get-set l₂″ a b ∎) , (λ a → trans (sym (cong₂ (λ set get → set a (get a)) (refl _) (refl _))) (set-get l₁″ a) ≡⟨ cong (λ eq → trans (sym eq) _) $ cong₂-refl _ ⟩ trans (sym (refl _)) (set-get l₁″ a) ≡⟨ cong (flip trans _) sym-refl ⟩ trans (refl _) (set-get l₁″ a) ≡⟨ trans-reflˡ _ ⟩ set-get l₁″ a ≡⟨ hyp₂ _ ⟩∎ set-get l₂″ a ∎) , (λ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) (refl _) (set-set l₁″ a b₁ b₂) ≡⟨ subst-refl _ _ ⟩ set-set l₁″ a b₁ b₂ ≡⟨ hyp₃ _ _ _ ⟩∎ set-set l₂″ a b₁ b₂ ∎) ) where open Lens -- An equality characterisation lemma for lenses from sets. equality-characterisation-for-sets : let open Lens in {l₁ l₂ : Lens A B} → Is-set A → l₁ ≡ l₂ ↔ set l₁ ≡ set l₂ equality-characterisation-for-sets {A = A} {B = B} {l₁ = l₁} {l₂ = l₂} A-set = l₁ ≡ l₂ ↝⟨ equality-characterisation₁ ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b → subst (λ get → get (set l₂ a b) ≡ b) g (subst (λ set → get l₁ (set a b) ≡ b) s (get-set l₁ a b)) ≡ get-set l₂ a b) × (∀ a → subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂)) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $ Π-closure ext 0 λ a → Π-closure ext 0 λ _ → +⇒≡ (B-set a)) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a → subst (λ get → set l₂ a (get a) ≡ a) g (subst (λ set → set a (get l₁ a) ≡ a) s (set-get l₁ a)) ≡ set-get l₂ a) × (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂)) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $ Π-closure ext 0 λ _ → +⇒≡ A-set) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (s : set l₁ ≡ set l₂) → (∀ a b₁ b₂ → subst (λ set → set (set a b₁) b₂ ≡ set a b₂) s (set-set l₁ a b₁ b₂) ≡ set-set l₂ a b₁ b₂)) ↝⟨ (∃-cong λ _ → drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ Π-closure ext 0 λ _ → Π-closure ext 0 λ _ → Π-closure ext 0 λ _ → +⇒≡ A-set) ⟩ get l₁ ≡ get l₂ × set l₁ ≡ set l₂ ↝⟨ (drop-⊤-left-× λ setters-equal → _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (Π-closure ext 2 λ a → B-set a) (getters-equal-if-setters-equal l₁ l₂ setters-equal)) ⟩□ set l₁ ≡ set l₂ □ where open Lens B-set : A → Is-set B B-set a = h-level-respects-lens-from-inhabited 2 l₁ a A-set ------------------------------------------------------------------------ -- More isomorphisms/equivalences related to lenses -- Lens ⊤ B is equivalent to Contractible B. lens-from-⊤≃codomain-contractible : Lens ⊤ B ≃ Contractible B lens-from-⊤≃codomain-contractible = Eq.⇔→≃ (lens-preserves-h-level-of-domain 0 (mono₁ 0 ⊤-contractible)) (H-level-propositional ext 0) (λ l → contractible-to-contractible l ⊤-contractible) (λ (b , irrB) → record { get = λ _ → b ; get-set = λ _ → irrB ; set-get = refl ; set-set = λ _ _ _ → refl _ }) -- Lens ⊥ B is equivalent to the unit type. lens-from-⊥≃⊤ : Lens (⊥ {ℓ = a}) B ≃ ⊤ lens-from-⊥≃⊤ = Eq.⇔→≃ (lens-preserves-h-level-of-domain 0 ⊥-propositional) (mono₁ 0 ⊤-contractible) _ (λ _ → record { get = ⊥-elim ; set = ⊥-elim ; get-set = λ a → ⊥-elim a ; set-get = λ a → ⊥-elim a ; set-set = λ a → ⊥-elim a }) -- If A is a set and there is a lens from A to B, then A is equivalent -- to the cartesian product of some type (that can be expressed using -- the setter of l) and B. -- -- This result is based on Theorem 2.3.9 from "Lenses and View Update -- Translation" by Pierce and Schmitt. -- -- See also Lens.Non-dependent.Traditional.Combinators.≄Σ∥set⁻¹∥×. ≃Σ∥set⁻¹∥× : Is-set A → (l : Lens A B) → A ≃ ((∃ λ (f : B → A) → ∥ Lens.set l ⁻¹ f ∥) × B) ≃Σ∥set⁻¹∥× {A = A} {B = B} A-set l = Eq.↔→≃ (λ a → (set a , ∣ a , refl _ ∣) , get a) (λ ((f , _) , b) → f b) (λ ((f , p) , b) → flip (Trunc.rec (×-closure 2 (Σ-closure 2 (Π-closure ext 2 λ _ → A-set) λ _ → mono₁ 1 Trunc.truncation-is-proposition) (B-set (f b)))) p λ (a , q) → let lemma₁ = set (f b) ≡⟨ cong (λ f → set (f b)) $ sym q ⟩ set (set a b) ≡⟨ ⟨ext⟩ $ set-set a b ⟩ set a ≡⟨ q ⟩∎ f ∎ lemma₂ = get (f b) ≡⟨ cong (λ f → get (f b)) $ sym q ⟩ get (set a b) ≡⟨ get-set _ _ ⟩∎ b ∎ in (set (f b) , ∣ f b , refl _ ∣) , get (f b) ≡⟨ cong₂ _,_ (Σ-≡,≡→≡ lemma₁ (Trunc.truncation-is-proposition _ _)) lemma₂ ⟩∎ (f , p ) , b ∎) (λ a → set a (get a) ≡⟨ set-get a ⟩∎ a ∎) where open Lens l B-set : A → Is-set B B-set a = h-level-respects-lens-from-inhabited 2 l a A-set -- If B is an inhabited set and there is a lens from A to B, then A is -- equivalent to the cartesian product of some type (that can be -- expressed using the getter of l) and B. -- -- This result is based on Corollary 13 from "Algebras and Update -- Strategies" by Johnson, Rosebrugh and Wood. ≃get⁻¹× : Is-set B → (b : B) (l : Lens A B) → A ≃ (Lens.get l ⁻¹ b × B) ≃get⁻¹× {B = B} {A = A} B-set b₀ l = Eq.↔→≃ (λ a → (set a b₀ , get-set a b₀) , get a) (λ ((a , _) , b) → set a b) (λ ((a , h) , b) → let lemma = set (set a b) b₀ ≡⟨ set-set a b b₀ ⟩ set a b₀ ≡⟨ cong (set a) (sym h) ⟩ set a (get a) ≡⟨ set-get a ⟩∎ a ∎ in (set (set a b) b₀ , get-set (set a b) b₀) , get (set a b) ≡⟨ cong₂ _,_ (Σ-≡,≡→≡ lemma (B-set _ _)) (get-set a b) ⟩∎ (a , h ) , b ∎) (λ a → set (set a b₀) (get a) ≡⟨ set-set a b₀ (get a) ⟩ set a (get a) ≡⟨ set-get a ⟩∎ a ∎) where open Lens l -- For somewhat coherent lenses the previous result can be proved -- without the assumption that the codomain is a set. ≃get⁻¹×-coherent : (b : B) (l : Coherent-lens A B) → A ≃ (Coherent-lens.get l ⁻¹ b × B) ≃get⁻¹×-coherent {B = B} {A = A} b₀ l = Eq.↔→≃ (λ a → (set a b₀ , get-set a b₀) , get a) (λ ((a , _) , b) → set a b) (λ ((a , h) , b) → let lemma₁ = set (set a b) b₀ ≡⟨ set-set a b b₀ ⟩ set a b₀ ≡⟨ cong (set a) (sym h) ⟩ set a (get a) ≡⟨ set-get a ⟩∎ a ∎ lemma₂₁ = cong get (trans (set-set a b b₀) (trans (cong (set a) (sym h)) (set-get a))) ≡⟨ trans (cong-trans _ _ _) $ cong (trans _) $ trans (cong-trans _ _ _) $ cong (flip trans _) $ cong-∘ _ _ _ ⟩ trans (cong get (set-set a b b₀)) (trans (cong (get ∘ set a) (sym h)) (cong get (set-get a))) ≡⟨ cong₂ (λ p q → trans p (trans (cong (get ∘ set a) (sym h)) q)) (get-set-set _ _ _) (get-set-get _) ⟩∎ trans (trans (get-set (set a b) b₀) (sym (get-set a b₀))) (trans (cong (get ∘ set a) (sym h)) (get-set a (get a))) ∎ lemma₂₂ = sym (trans (trans (get-set (set a b) b₀) (sym (get-set a b₀))) (trans (cong (get ∘ set a) (sym h)) (get-set a (get a)))) ≡⟨ trans (sym-trans _ _) $ cong₂ trans (sym-trans _ _) (sym-trans _ _) ⟩ trans (trans (sym (get-set a (get a))) (sym (cong (get ∘ set a) (sym h)))) (trans (sym (sym (get-set a b₀))) (sym (get-set (set a b) b₀))) ≡⟨ cong₂ (λ p q → trans (trans (sym (get-set a (get a))) p) (trans q (sym (get-set (set a b) b₀)))) (trans (cong sym $ cong-sym _ _) $ sym-sym _) (sym-sym _) ⟩ trans (trans (sym (get-set a (get a))) (cong (get ∘ set a) h)) (trans (get-set a b₀) (sym (get-set (set a b) b₀))) ≡⟨ trans (sym $ trans-assoc _ _ _) $ cong (flip trans _) $ trans-assoc _ _ _ ⟩∎ trans (trans (sym (get-set a (get a))) (trans (cong (get ∘ set a) h) (get-set a b₀))) (sym (get-set (set a b) b₀)) ∎ lemma₂ = subst (λ a → get a ≡ b₀) (trans (set-set a b b₀) (trans (cong (set a) (sym h)) (set-get a))) (get-set (set a b) b₀) ≡⟨ subst-∘ _ _ _ ⟩ subst (_≡ b₀) (cong get (trans (set-set a b b₀) (trans (cong (set a) (sym h)) (set-get a)))) (get-set (set a b) b₀) ≡⟨ subst-trans-sym ⟩ trans (sym (cong get (trans (set-set a b b₀) (trans (cong (set a) (sym h)) (set-get a))))) (get-set (set a b) b₀) ≡⟨ cong (flip (trans ∘ sym) _) lemma₂₁ ⟩ trans (sym (trans (trans (get-set (set a b) b₀) (sym (get-set a b₀))) (trans (cong (get ∘ set a) (sym h)) (get-set a (get a))))) (get-set (set a b) b₀) ≡⟨ cong (flip trans _) lemma₂₂ ⟩ trans (trans (trans (sym (get-set a (get a))) (trans (cong (get ∘ set a) h) (get-set a b₀))) (sym (get-set (set a b) b₀))) (get-set (set a b) b₀) ≡⟨ trans-[trans-sym]- _ _ ⟩ trans (sym (get-set a (get a))) (trans (cong (get ∘ set a) h) (get-set a b₀)) ≡⟨ cong (λ f → trans (sym (f (get a))) (trans (cong (get ∘ set a) h) (f b₀))) $ sym $ _≃_.left-inverse-of (Eq.extensionality-isomorphism bad-ext) (get-set a) ⟩ trans (sym (ext⁻¹ (⟨ext⟩ (get-set a)) (get a))) (trans (cong (get ∘ set a) h) (ext⁻¹ (⟨ext⟩ (get-set a)) b₀)) ≡⟨ elim₁ (λ {f} eq → trans (sym (ext⁻¹ eq (get a))) (trans (cong f h) (ext⁻¹ eq b₀)) ≡ h) ( trans (sym (ext⁻¹ (refl id) (get a))) (trans (cong id h) (ext⁻¹ (refl id) b₀)) ≡⟨ cong₂ (λ p q → trans p (trans (cong id h) q)) (trans (cong sym (ext⁻¹-refl _)) sym-refl) (ext⁻¹-refl _) ⟩ trans (refl _) (trans (cong id h) (refl _)) ≡⟨ trans-reflˡ _ ⟩ trans (cong id h) (refl _) ≡⟨ trans-reflʳ _ ⟩ cong id h ≡⟨ sym $ cong-id _ ⟩∎ h ∎) _ ⟩∎ h ∎ in ((set (set a b) b₀ , get-set (set a b) b₀) , get (set a b)) ≡⟨ cong₂ _,_ (Σ-≡,≡→≡ lemma₁ lemma₂) (get-set a b) ⟩∎ ((a , h ) , b ) ∎) (λ a → set (set a b₀) (get a) ≡⟨ set-set a b₀ (get a) ⟩ set a (get a) ≡⟨ set-get a ⟩∎ a ∎) where open Coherent-lens l ------------------------------------------------------------------------ -- A conversion function -- If A is a set, then Lens A B is equivalent to Coherent-lens A B. ≃coherent : Is-set A → Lens A B ≃ Coherent-lens A B ≃coherent {A = A} {B = B} A-set = Eq.↔→≃ to Coherent-lens.lens (λ l → let l′ = Coherent-lens.lens l in $⟨ ×-closure 1 (Π-closure ext 1 λ a → mono₁ 2 (B-set l′ a)) (Π-closure ext 1 λ a → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → mono₁ 2 (B-set l′ a)) ⟩ Is-proposition _ ↝⟨ (λ p → cong (l′ ,_) (p _ _)) ⦂ (_ → _) ⟩ (l′ , _) ≡ (l′ , _) ↔⟨ Eq.≃-≡ Coherent-lens-as-Σ ⟩□ to l′ ≡ l □) refl where B-set : Lens A B → A → Is-set B B-set l a = h-level-respects-lens-from-inhabited 2 l a A-set to : Lens A B → Coherent-lens A B to l = record { lens = l ; get-set-get = λ a → B-set l a _ _ ; get-set-set = λ a _ _ → B-set l a _ _ } -- The conversion preserves getters and setters. ≃coherent-preserves-getters-and-setters : {A : Type a} (s : Is-set A) → Preserves-getters-and-setters-⇔ A B (_≃_.logical-equivalence (≃coherent s)) ≃coherent-preserves-getters-and-setters _ = (λ _ → refl _ , refl _) , (λ _ → refl _ , refl _) ------------------------------------------------------------------------ -- Some existence results -- There is, in general, no lens for the first projection from a -- Σ-type. no-first-projection-lens : ¬ Lens (∃ λ (b : Bool) → b ≡ true) Bool no-first-projection-lens = Non-dependent.no-first-projection-lens Lens contractible-to-contractible -- A variant of the previous result: If A is merely inhabited, and one -- can "project" out a boolean from a value of type A, but this -- boolean is necessarily true, then there is no lens corresponding to -- this projection. no-singleton-projection-lens : ∥ A ∥ → (bool : A → Bool) → (∀ x → bool x ≡ true) → ¬ ∃ λ (l : Lens A Bool) → ∀ x → Lens.get l x ≡ bool x no-singleton-projection-lens = Non-dependent.no-singleton-projection-lens _ _ Lens.get-set -- There are two lenses with equal setters that are not equal -- (assuming univalence). -- -- (The lemma does not actually use the univalence argument, but -- univalence is used by Circle.not-refl≢refl.) equal-setters-but-not-equal : Univalence lzero → ∃ λ (A : Type) → ∃ λ (B : Type) → ∃ λ (l₁ : Lens A B) → ∃ λ (l₂ : Lens A B) → Lens.set l₁ ≡ Lens.set l₂ × l₁ ≢ l₂ equal-setters-but-not-equal _ = 𝕊¹ , ⊤ , l₁′ , l₂′ , refl _ , l₁′≢l₂′ where open Lens lemma : Lens 𝕊¹ ⊤ ≃ ((x : 𝕊¹) → x ≡ x) lemma = Lens 𝕊¹ ⊤ ↔⟨ lens-to-proposition↔ (mono₁ 0 ⊤-contractible) ⟩ (𝕊¹ → ⊤) × ((x : 𝕊¹) → x ≡ x) ↔⟨ (drop-⊤-left-× λ _ → →-right-zero) ⟩□ ((x : 𝕊¹) → x ≡ x) □ l₁′ : Lens 𝕊¹ ⊤ l₁′ = _≃_.from lemma Circle.not-refl l₂′ : Lens 𝕊¹ ⊤ l₂′ = _≃_.from lemma refl set-l₁′≡set-l₂′ : set l₁′ ≡ set l₂′ set-l₁′≡set-l₂′ = refl _ l₁′≢l₂′ : l₁′ ≢ l₂′ l₁′≢l₂′ = l₁′ ≡ l₂′ ↔⟨ Eq.≃-≡ (inverse lemma) {x = Circle.not-refl} {y = refl} ⟩ Circle.not-refl ≡ refl ↝⟨ Circle.not-refl≢refl ⟩□ ⊥ □ -- A lens which is used in some counterexamples below. bad : (a : Level) → Lens (↑ a 𝕊¹) (↑ a 𝕊¹) bad a = record { get = id ; set = const id ; get-set = λ _ → cong lift ∘ Circle.not-refl ∘ lower ; set-get = refl ; set-set = λ _ _ → cong lift ∘ Circle.not-refl ∘ lower } -- The lens bad a has a getter which is an equivalence, but it does -- not satisfy either of the coherence laws that Coherent-lens lenses -- must satisfy (assuming univalence). -- -- (The lemma does not actually use the univalence argument, but -- univalence is used by Circle.not-refl≢refl.) getter-equivalence-but-not-coherent : Univalence lzero → let open Lens (bad a) in Is-equivalence get × ¬ (∀ a → cong get (set-get a) ≡ get-set a (get a)) × ¬ (∀ a₁ a₂ a₃ → cong get (set-set a₁ a₂ a₃) ≡ trans (get-set (set a₁ a₂) a₃) (sym (get-set a₁ a₃))) getter-equivalence-but-not-coherent {a = a} _ = _≃_.is-equivalence F.id , (((x : ↑ a 𝕊¹) → cong get (set-get x) ≡ get-set x (get x)) ↔⟨⟩ ((x : ↑ a 𝕊¹) → cong id (refl _) ≡ cong lift (Circle.not-refl (lower x))) ↔⟨ (Π-cong ext Bij.↑↔ λ _ → Eq.id) ⟩ ((x : 𝕊¹) → cong id (refl _) ≡ cong lift (Circle.not-refl x)) ↝⟨ trans (trans (cong-refl _) (cong-id _)) ∘_ ⟩ ((x : 𝕊¹) → cong lift (refl x) ≡ cong lift (Circle.not-refl x)) ↔⟨ (∀-cong ext λ _ → Eq.≃-≡ $ inverse $ Eq.≃-≡ $ Eq.↔⇒≃ $ inverse Bij.↑↔) ⟩ ((x : 𝕊¹) → refl x ≡ Circle.not-refl x) ↔⟨ Eq.extensionality-isomorphism ext ⟩ refl ≡ Circle.not-refl ↝⟨ Circle.not-refl≢refl ∘ sym ⟩□ ⊥ □) , (((x y z : ↑ a 𝕊¹) → cong get (set-set x y z) ≡ trans (get-set (set x y) z) (sym (get-set x z))) ↔⟨⟩ ((x y z : ↑ a 𝕊¹) → cong id (cong lift (Circle.not-refl (lower z))) ≡ trans (cong lift (Circle.not-refl (lower z))) (sym (cong lift (Circle.not-refl (lower z))))) ↔⟨ (Π-cong ext Bij.↑↔ λ _ → Π-cong ext Bij.↑↔ λ _ → Π-cong ext Bij.↑↔ λ _ → Eq.id) ⟩ ((x y z : 𝕊¹) → cong id (cong lift (Circle.not-refl z)) ≡ trans (cong lift (Circle.not-refl z)) (sym (cong lift (Circle.not-refl z)))) ↝⟨ (λ hyp → hyp Circle.base Circle.base) ⟩ ((x : 𝕊¹) → cong id (cong lift (Circle.not-refl x)) ≡ trans (cong lift (Circle.not-refl x)) (sym (cong lift (Circle.not-refl x)))) ↔⟨ (∀-cong ext λ _ → ≡⇒≃ $ cong₂ _≡_ (sym $ cong-id _) (trans (trans-symʳ _) $ sym $ cong-refl _)) ⟩ ((x : 𝕊¹) → cong lift (Circle.not-refl x) ≡ cong lift (refl x)) ↔⟨ (∀-cong ext λ _ → Eq.≃-≡ $ inverse $ Eq.≃-≡ $ Eq.↔⇒≃ $ inverse Bij.↑↔) ⟩ ((x : 𝕊¹) → Circle.not-refl x ≡ refl x) ↔⟨ Eq.extensionality-isomorphism ext ⟩ Circle.not-refl ≡ refl ↝⟨ Circle.not-refl≢refl ⟩□ ⊥ □) where open Lens (bad a)
programs/oeis/136/A136480.asm
neoneye/loda
22
4676
<reponame>neoneye/loda ; A136480: Number of trailing equal digits in binary representation of n. ; 1,1,1,2,2,1,1,3,3,1,1,2,2,1,1,4,4,1,1,2,2,1,1,3,3,1,1,2,2,1,1,5,5,1,1,2,2,1,1,3,3,1,1,2,2,1,1,4,4,1,1,2,2,1,1,3,3,1,1,2,2,1,1,6,6,1,1,2,2,1,1,3,3,1,1,2,2,1,1,4,4,1,1,2,2,1,1,3,3,1,1,2,2,1,1,5,5,1,1,2 add $0,1 bin $0,2 mov $1,7 lpb $0 dif $0,2 add $1,1 lpe sub $1,6 mov $0,$1
src/babel_main.adb
stcarrez/babel
1
26660
<gh_stars>1-10 with GNAT.Command_Line; use GNAT.Command_Line; with GNAT.IO; use GNAT.IO; with GNAT.Traceback.Symbolic; with Ada.Exceptions; with Ada.Command_Line; with Ada.Text_IO; with Babel; with Babel.Files; with Ada.Directories; with Ada.Strings.Unbounded; with Util.Encoders; with Util.Encoders.Base16; with Util.Log.Loggers; with Babel.Filters; with Babel.Files.Buffers; with Babel.Files.Queues; with Babel.Stores.Local; with Babel.Strategies.Default; with Babel.Strategies.Workers; with Babel.Base.Text; with Babel.Base.Users; with Babel.Streams; with Babel.Streams.XZ; with Babel.Streams.Cached; with Babel.Streams.Files; with Tar; procedure babel_main is use Ada.Strings.Unbounded; Out_Dir : Ada.Strings.Unbounded.Unbounded_String; Dir : Babel.Files.Directory_Type; Hex_Encoder : Util.Encoders.Base16.Encoder; Exclude : aliased Babel.Filters.Exclude_Directory_Filter_Type; Local : aliased Babel.Stores.Local.Local_Store_Type; Backup : aliased Babel.Strategies.Default.Default_Strategy_Type; Buffers : aliased Babel.Files.Buffers.Buffer_Pool; Store : aliased Babel.Stores.Local.Local_Store_Type; Database : aliased Babel.Base.Text.Text_Database; Queue : aliased Babel.Files.Queues.File_Queue; Debug : Boolean := False; Task_Count : Positive := 2; -- -- procedure Print_Sha (Path : in String; -- File : in out Babel.Files.File) is -- Sha : constant String := Hex_Encoder.Transform (File.SHA1); -- begin -- Put_Line (Path & "/" & To_String (File.Name) & " => " & Sha); -- end Print_Sha; procedure Usage is begin Ada.Text_IO.Put_Line ("babel [-d] [-t count] {command} [options]"); Ada.Text_IO.Put_Line (" -d Debug mode"); Ada.Text_IO.Put_Line (" -t count Number of tasks to create"); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Commands:"); Ada.Text_IO.Put_Line (" copy <dst-dir> <src-dir>"); Ada.Text_IO.Put_Line (" scan <src-dir>"); Ada.Command_Line.Set_Exit_Status (2); end Usage; package Backup_Workers is new Babel.Strategies.Workers (Babel.Strategies.Default.Default_Strategy_Type); procedure Do_Backup (Count : in Positive) is Workers : Backup_Workers.Worker_Type (Count); Container : Babel.Files.Default_Container; Dir_Queue : Babel.Files.Queues.Directory_Queue; procedure Configure (Strategy : in out Babel.Strategies.Default.Default_Strategy_Type) is begin Strategy.Set_Filters (Exclude'Unchecked_Access); Strategy.Set_Stores (Read => Local'Unchecked_Access, Write => Store'Unchecked_Access); Strategy.Set_Buffers (Buffers'Unchecked_Access); Strategy.Set_Queue (Queue'Unchecked_Access); end Configure; begin Babel.Files.Queues.Add_Directory (Dir_Queue, Dir); Configure (Backup); Backup_Workers.Configure (Workers, Configure'Access); Backup_Workers.Start (Workers); Backup.Scan (Dir_Queue, Container); Backup_Workers.Finish (Workers, Database); end Do_Backup; procedure Do_Copy is Dst : constant String := GNAT.Command_Line.Get_Argument; Src : constant String := GNAT.Command_Line.Get_Argument; begin Dir := Babel.Files.Allocate (Name => Src, Dir => Babel.Files.NO_DIRECTORY); Store.Set_Root_Directory (Dst); Local.Set_Root_Directory (""); Do_Backup (Task_Count); Database.Save ("database.txt"); end Do_Copy; procedure Do_Scan is Src : constant String := GNAT.Command_Line.Get_Argument; Workers : Backup_Workers.Worker_Type (Task_Count); Container : Babel.Files.Default_Container; Dir_Queue : Babel.Files.Queues.Directory_Queue; procedure Configure (Strategy : in out Babel.Strategies.Default.Default_Strategy_Type) is begin Strategy.Set_Filters (Exclude'Unchecked_Access); Strategy.Set_Stores (Read => Local'Unchecked_Access, Write => null); Strategy.Set_Buffers (Buffers'Unchecked_Access); Strategy.Set_Queue (Queue'Unchecked_Access); end Configure; begin Dir := Babel.Files.Allocate (Name => Src, Dir => Babel.Files.NO_DIRECTORY); Local.Set_Root_Directory (""); Babel.Files.Queues.Add_Directory (Dir_Queue, Dir); Configure (Backup); Backup_Workers.Configure (Workers, Configure'Access); Backup_Workers.Start (Workers); Backup.Scan (Dir_Queue, Container); Backup_Workers.Finish (Workers, Database); Database.Save ("database-scan.txt"); end Do_Scan; begin Util.Log.Loggers.Initialize ("babel.properties"); Initialize_Option_Scan (Stop_At_First_Non_Switch => True, Section_Delimiters => "targs"); -- Parse the command line loop case Getopt ("* v o: t:") is when ASCII.NUL => exit; when 'o' => Out_Dir := To_Unbounded_String (Parameter & "/"); when 'd' => Debug := True; when 't' => Task_Count := Positive'Value (Parameter); when '*' => exit; when others => null; end case; end loop; if Ada.Command_Line.Argument_Count = 0 then Usage; return; end if; Babel.Files.Buffers.Create_Pool (Into => Buffers, Count => 100, Size => 64 * 1024); Store.Set_Buffers (Buffers'Unchecked_Access); Local.Set_Buffers (Buffers'Unchecked_Access); declare Cmd_Name : constant String := Full_Switch; begin if Cmd_Name = "copy" then Do_Copy; elsif Cmd_Name = "scan" then Do_Scan; else Usage; end if; end; exception when E : Invalid_Switch => Ada.Text_IO.Put_Line ("Invalid option: " & Ada.Exceptions.Exception_Message (E)); Usage; when E : others => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); Ada.Command_Line.Set_Exit_Status (1); end babel_main;
wof/lcs/enemy/C4.asm
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
6
100350
<filename>wof/lcs/enemy/C4.asm<gh_stars>1-10 copyright zengfr site:http://github.com/zengfr/romhack 001590 lea ($20,A0), A0 0122AE move.l (A2)+, (A3)+ [enemy+C0, enemy+C2] 0122B0 move.l (A2)+, (A3)+ [enemy+C4, enemy+C6] 01A75E dbra D4, $1a75c 026946 bra $26966 [enemy+C4] 026956 bra $26966 [enemy+C4] 02695E bra $26966 [enemy+C4] 026966 addq.b #2, ($c2,A0) [enemy+C4] 0269B6 move.w ($c4,A0), D1 [123p+ 4] 0269BA add.w D1, D0 [enemy+C4] 026A00 move.w ($c4,A0), D1 [123p+ 4] 026A04 add.w D1, D0 [enemy+C4] 026A28 move.w ($c4,A0), D1 [123p+ 4] 026A2C add.w D1, D0 [enemy+C4] 026A54 move.w ($c4,A0), D1 [123p+ 4] 026A58 add.w D1, D0 [enemy+C4] copyright zengfr site:http://github.com/zengfr/romhack
alloy4fun_models/trashltl/models/17/M3fRNrsWHiXGEHTBN.als
Kaixi26/org.alloytools.alloy
0
2674
<filename>alloy4fun_models/trashltl/models/17/M3fRNrsWHiXGEHTBN.als open main pred idM3fRNrsWHiXGEHTBN_prop18 { always (all f : File | f in Protected releases f in Trash) } pred __repair { idM3fRNrsWHiXGEHTBN_prop18 } check __repair { idM3fRNrsWHiXGEHTBN_prop18 <=> prop18o }
Working Disassembly/General/Sprites/Buttons/Map - Button.asm
TeamASM-Blur/Sonic-3-Blue-Balls-Edition
5
22701
dc.w word_2C724-Map_Button dc.w word_2C732-Map_Button dc.w word_2C73A-Map_Button word_2C724: dc.w 2 ; DATA XREF: ROM:0002C71Eo dc.b $F4, $C, 0, 0, $FF, $F0 dc.b $FC, 4, 0, 4, $FF, $F8 word_2C732: dc.w 1 ; DATA XREF: ROM:0002C71Eo dc.b $FC, $C, 0, 0, $FF, $F0 word_2C73A: dc.w 2 ; DATA XREF: ROM:0002C71Eo dc.b $F8, $C, 0, 0, $FF, $F0 dc.b 0, 4, 0, 4, $FF, $F8
Transynther/x86/_processed/NONE/_xt_sm_/i3-7100_9_0x84_notsx.log_20572_1448.asm
ljhsiun2/medusa
9
169386
<filename>Transynther/x86/_processed/NONE/_xt_sm_/i3-7100_9_0x84_notsx.log_20572_1448.asm .global s_prepare_buffers s_prepare_buffers: push %r10 push %r9 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0x3ab2, %rbp nop nop nop and %rax, %rax mov $0x6162636465666768, %rsi movq %rsi, %xmm6 and $0xffffffffffffffc0, %rbp movntdq %xmm6, (%rbp) nop inc %rbx lea addresses_A_ht+0x14c70, %r10 nop nop nop nop sub $50707, %rdi mov $0x6162636465666768, %r9 movq %r9, (%r10) and %rbx, %rbx lea addresses_WC_ht+0xbd61, %rsi lea addresses_WC_ht+0xc2b2, %rdi nop and $1976, %r10 mov $24, %rcx rep movsl nop nop nop nop and $40757, %rdi lea addresses_normal_ht+0x6dde, %r9 nop nop nop nop sub $10289, %rbp movb $0x61, (%r9) nop nop nop add %rdi, %rdi lea addresses_normal_ht+0x178b2, %rbp nop nop nop nop nop dec %r9 movw $0x6162, (%rbp) nop cmp $51974, %rbx lea addresses_D_ht+0x6b2, %rbp nop nop nop nop dec %rsi mov (%rbp), %rcx nop nop sub $45593, %r10 lea addresses_D_ht+0x1d6be, %rbp nop nop nop nop xor %rsi, %rsi mov (%rbp), %r10d xor $4282, %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r9 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r15 push %r9 push %rax push %rbp push %rdi push %rsi // Store lea addresses_UC+0x1bf16, %rbp sub $4235, %r15 mov $0x5152535455565758, %r9 movq %r9, %xmm4 vmovups %ymm4, (%rbp) nop nop nop lfence // Store lea addresses_PSE+0x4eb2, %rsi nop nop add $57086, %r9 mov $0x5152535455565758, %rdi movq %rdi, %xmm1 movups %xmm1, (%rsi) nop nop nop nop nop xor $50911, %r15 // Store lea addresses_D+0x17ea2, %r15 sub $25710, %rax mov $0x5152535455565758, %r9 movq %r9, %xmm2 vmovups %ymm2, (%r15) cmp $26344, %rdi // Store mov $0xeb2, %r12 nop nop nop nop nop cmp %r15, %r15 movw $0x5152, (%r12) nop nop nop nop xor $41540, %r15 // Store lea addresses_D+0x5296, %r9 xor %rdi, %rdi movb $0x51, (%r9) nop dec %rsi // Store lea addresses_PSE+0x5b66, %rbp nop nop nop nop nop dec %rdi movl $0x51525354, (%rbp) nop cmp $54325, %r15 // Store mov $0x280, %r9 cmp %rax, %rax movw $0x5152, (%r9) nop sub %r9, %r9 // Store lea addresses_RW+0x1b412, %r12 clflush (%r12) nop nop nop xor $49749, %rbp movl $0x51525354, (%r12) nop nop nop nop nop add $50817, %r9 // Store lea addresses_D+0x18c2, %rsi clflush (%rsi) nop nop nop nop cmp $25367, %rax mov $0x5152535455565758, %r15 movq %r15, (%rsi) add $55788, %rsi // Store lea addresses_RW+0xdab2, %rax nop add $3988, %rsi mov $0x5152535455565758, %rdi movq %rdi, (%rax) nop nop nop dec %r9 // Load lea addresses_normal+0x120b2, %rsi inc %r15 mov (%rsi), %rax nop nop nop add $25042, %r15 // Store lea addresses_UC+0x10ef2, %r15 nop nop nop nop nop sub %rbp, %rbp movw $0x5152, (%r15) nop nop nop nop xor %rsi, %rsi // Store mov $0x16122400000007ac, %rbp nop nop inc %r15 movb $0x51, (%rbp) nop nop sub %rsi, %rsi // Faulty Load lea addresses_RW+0xdab2, %r9 nop nop xor %rdi, %rdi mov (%r9), %r12w lea oracles, %r15 and $0xff, %r12 shlq $12, %r12 mov (%r15,%r12,1), %r12 pop %rsi pop %rdi pop %rbp pop %rax pop %r9 pop %r15 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_RW', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 16, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_P', 'same': False, 'size': 2, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 4, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_P', 'same': False, 'size': 2, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_RW', 'same': False, 'size': 4, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_RW', 'same': True, 'size': 8, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 2, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_NC', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_RW', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 8, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'same': True, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'58': 20572} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
src/ada/src/route_aggregator_communication.ads
pat-rogers/OpenUxAS
0
17034
<reponame>pat-rogers/OpenUxAS with Route_Aggregator_Messages; use Route_Aggregator_Messages; with Route_Aggregator_Common; use Route_Aggregator_Common; private with Ada.Strings.Unbounded; private with UxAS.Comms.LMCP_Object_Message_Sender_Pipes; -- Package only concerned with message passing. It defines its own state, -- named Mailbox here, which is not mixed with the state of the service. package Route_Aggregator_Communication with SPARK_Mode is type Route_Aggregator_Mailbox is limited private; type MessageGroup is (GroundPathPlanner, AircraftPathPlanner); procedure Initialize (This : out Route_Aggregator_Mailbox; Source_Group : String; Unique_Id : Int64; Entity_Id : UInt32; Service_Id : UInt32); procedure sendLimitedCastMessage (This : in out Route_Aggregator_Mailbox; Group : MessageGroup; Msg : Message_Root'Class); procedure sendBroadcastMessage (This : in out Route_Aggregator_Mailbox; Msg : Message_Root'Class); procedure Get_Next_Unique_Sending_Message_Id (This : in out Route_Aggregator_Mailbox; Value : out Int64); private pragma SPARK_Mode (Off); use Ada.Strings.Unbounded; use UxAS.Comms.LMCP_Object_Message_Sender_Pipes; type Route_Aggregator_Mailbox is tagged limited record Message_Sender_Pipe : LMCP_Object_Message_Sender_Pipe; Source_Group : Unbounded_String; Unique_Entity_Send_Message_Id : Int64; end record; end Route_Aggregator_Communication;
Task/Equilibrium-index/Ada/equilibrium-index-3.ada
LaudateCorpus1/RosettaCodeData
1
18290
with Ada.Text_IO; with Equilibrium; with Ada.Containers.Vectors; procedure Main is subtype Index_Type is Positive range 1 .. 7; package Vectors is new Ada.Containers.Vectors (Element_Type => Integer, Index_Type => Index_Type); type Plain_Array is array (Index_Type) of Integer; function Element (From : Plain_Array; Key : Index_Type) return Integer is begin return From (Key); end Element; package Vector_Equilibrium is new Equilibrium (Index_Type => Index_Type, Element_Type => Integer, Zero => 0, Array_Type => Vectors.Vector, Element => Vectors.Element); package Array_Equilibrium is new Equilibrium (Index_Type => Index_Type, Element_Type => Integer, Zero => 0, Array_Type => Plain_Array); My_Vector : Vectors.Vector; My_Array : Plain_Array := (-7, 1, 5, 2, -4, 3, 0); Vector_Result : Vector_Equilibrium.Index_Vectors.Vector; Array_Result : Array_Equilibrium.Index_Vectors.Vector := Array_Equilibrium.Get_Indices (My_Array); begin Vectors.Append (My_Vector, -7); Vectors.Append (My_Vector, 1); Vectors.Append (My_Vector, 5); Vectors.Append (My_Vector, 2); Vectors.Append (My_Vector, -4); Vectors.Append (My_Vector, 3); Vectors.Append (My_Vector, 0); Vector_Result := Vector_Equilibrium.Get_Indices (My_Vector); Ada.Text_IO.Put_Line ("Results:"); Ada.Text_IO.Put ("Array: "); for I in Array_Result.First_Index .. Array_Result.Last_Index loop Ada.Text_IO.Put (Integer'Image (Array_Equilibrium.Index_Vectors.Element (Array_Result, I))); end loop; Ada.Text_IO.New_Line; Ada.Text_IO.Put ("Vector: "); for I in Vector_Result.First_Index .. Vector_Result.Last_Index loop Ada.Text_IO.Put (Integer'Image (Vector_Equilibrium.Index_Vectors.Element (Vector_Result, I))); end loop; Ada.Text_IO.New_Line; end Main;
VirtualBox-5.0.0/src/VBox/Runtime/win/amd64/ASMBitFirstClear.asm
egraba/vbox_openbsd
1
82262
;; @file ; IPRT - ASMBitFirstClear(). ; ; ; Copyright (C) 2006-2015 Oracle Corporation ; ; This file is part of VirtualBox Open Source Edition (OSE), as ; available from http://www.virtualbox.org. This file is free software; ; you can redistribute it and/or modify it under the terms of the GNU ; General Public License (GPL) as published by the Free Software ; Foundation, in version 2 as it comes in the "COPYING" file of the ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ; ; The contents of this file may alternatively be used under the terms ; of the Common Development and Distribution License Version 1.0 ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the ; VirtualBox OSE distribution, in which case the provisions of the ; CDDL are applicable instead of those of the GPL. ; ; You may elect to license modified versions of this file under the ; terms and conditions of either the GPL or the CDDL or both. ; ;******************************************************************************* ;* Header Files * ;******************************************************************************* %include "iprt/asmdefs.mac" BEGINCODE ;; ; Finds the first clear bit in a bitmap. ; ; @returns eax Index of the first zero bit. ; @returns eax -1 if no clear bit was found. ; @param rcx pvBitmap Pointer to the bitmap. ; @param edx cBits The number of bits in the bitmap. Multiple of 32. ; BEGINPROC_EXPORTED ASMBitFirstClear ;if (cBits) or edx, edx jz short .failed ;{ push rdi ; asm {...} mov rdi, rcx ; rdi = start of scasd mov ecx, edx add ecx, 31 ; 32 bit aligned shr ecx, 5 ; number of dwords to scan. mov rdx, rdi ; rdx = saved pvBitmap mov eax, 0ffffffffh repe scasd ; Scan for the first dword with any clear bit. je .failed_restore ; find the bit in question lea rdi, [rdi - 4] ; one step back. xor eax, [rdi] ; eax = NOT [rdi] sub rdi, rdx shl edi, 3 ; calc bit offset. mov ecx, 0ffffffffh bsf ecx, eax add ecx, edi mov eax, ecx ; return success pop rdi ret ; failure ;} ;return -1; .failed_restore: pop rdi ret .failed: mov eax, 0ffffffffh ret ENDPROC ASMBitFirstClear
programs/oeis/160/A160378.asm
neoneye/loda
22
174562
<reponame>neoneye/loda<filename>programs/oeis/160/A160378.asm ; A160378: a(n) = n^3 - n*(n+1)/2. ; 0,0,5,21,54,110,195,315,476,684,945,1265,1650,2106,2639,3255,3960,4760,5661,6669,7790,9030,10395,11891,13524,15300,17225,19305,21546,23954,26535,29295,32240,35376,38709,42245,45990,49950,54131,58539 mov $1,$0 mul $0,2 bin $1,2 mul $0,$1 add $0,$1
source/types/adam-a_type-signed_integer_type.ads
charlie5/aIDE
3
12621
with Ada.Streams; package AdaM.a_Type.signed_integer_type is type Item is new a_Type.integer_Type with private; type View is access all Item'Class; -- Forge -- function new_Type (Name : in String := "") return signed_integer_type.view; overriding procedure destruct (Self : in out Item); procedure free (Self : in out signed_integer_type.view); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; overriding function to_Source (Self : in Item) return text_Vectors.Vector; function First (Self : in Item) return Long_Long_Integer; procedure First_is (Self : in out Item; Now : in Long_Long_Integer); function Last (Self : in Item) return Long_Long_Integer; procedure Last_is (Self : in out Item; Now : in Long_Long_Integer); private type Item is new a_Type.integer_Type with record First : Long_Long_Integer := 0; Last : Long_Long_Integer := Long_Long_Integer'Last; end record; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View); procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View); for View'write use View_write; for View'read use View_read; end AdaM.a_Type.signed_integer_type;
agda/Module.agda
mchristianl/synthetic-reals
3
3225
{-# OPTIONS --cubical --no-import-sorts #-} module Module where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Structures.Ring open import Cubical.Structures.Group open import Cubical.Structures.AbGroup open import NumberBundles2 record IsLeftRModule {ℓ ℓᴿ : Level} {R : Type ℓᴿ} ( 1ᴿ : R) (_+ᴿ_ _·ᴿ_ : R → R → R) {X : Type ℓ} (0ᴹ : X) (_+ᴹ_ : X → X → X) (_·ᴹ_ : R → X → X) (-ᴹ_ : X → X) : Type (ℓ-max ℓ ℓᴿ) where field isAbGroupᴹ : IsAbGroup 0ᴹ _+ᴹ_ -ᴹ_ ·ᴹ-dist-+ᴹ : ∀ r x y → r ·ᴹ (x +ᴹ y) ≡ (r ·ᴹ x) +ᴹ (r ·ᴹ y) ·ᴹ-dist-+ᴿ : ∀ r s x → (r +ᴿ s) ·ᴹ x ≡ (r ·ᴹ x) +ᴹ (s ·ᴹ x) ·ᴹ-assoc-·ᴿ : ∀ r s x → (r ·ᴿ s) ·ᴹ x ≡ r ·ᴹ (s ·ᴹ x) ·ᴹ-identity : ∀ x → 1ᴿ ·ᴹ x ≡ x open IsAbGroup isAbGroupᴹ renaming ( _-_ to _-ᴹ_ ; assoc to +ᴹ-assoc ; identity to +ᴹ-identity ; lid to +ᴹ-lid ; rid to +ᴹ-rid ; inverse to +ᴹ-inv ; invl to +ᴹ-linv ; invr to +ᴹ-rinv ; comm to +ᴹ-comm ; isSemigroup to +ᴹ-isSemigroup ; isMonoid to +ᴹ-isMonoid ; isGroup to +ᴹ-isGroup ) public ApartnessRingWithAbs = Ring -- TODO define `ApartnessRingWithAbs` record LeftRModule {ℓ ℓᴿ : Level} (ring : ApartnessRingWithAbs {ℓᴿ}) : Type (ℓ-suc (ℓ-max ℓ ℓᴿ)) where open Ring ring renaming ( Carrier to Carrierᴿ ; 0r to 0ᴿ ; 1r to 1ᴿ ; _+_ to _+ᴿ_ ; _·_ to _·ᴿ_ ; -_ to -ᴿ_ ; is-set to is-setᴿ ; +-assoc to +ᴿ-assoc ; +-identity to +ᴿ-identity ; +-lid to +ᴿ-lid ; +-rid to +ᴿ-rid ; +-inv to +ᴿ-inv ; +-linv to +ᴿ-linv ; +-rinv to +ᴿ-rinv ; +-comm to +ᴿ-comm ; +-isSemigroup to +ᴿ-isSemigroup ; +-isMonoid to +ᴿ-isMonoid ; +-isGroup to +ᴿ-isGroup ; ·-assoc to ·ᴿ-assoc ; ·-identity to ·ᴿ-identity ; ·-lid to ·ᴿ-lid ; ·-rid to ·ᴿ-rid ; ·-isSemigroup to ·ᴿ-isSemigroup ; ·-rdist-+ to ·ᴿ-rdist-+ᴿ ; ·-ldist-+ to ·ᴿ-ldist-+ᴿ ) public field Carrier : Type ℓ 0ᴹ : Carrier _+ᴹ_ : Carrier → Carrier → Carrier _·ᴹ_ : Carrierᴿ → Carrier → Carrier -ᴹ_ : Carrier → Carrier isLeftRModule : IsLeftRModule 1ᴿ _+ᴿ_ _·ᴿ_ 0ᴹ _+ᴹ_ _·ᴹ_ -ᴹ_ open IsLeftRModule isLeftRModule public infix 8 -ᴹ_ infixl 7 _·ᴹ_ infixl 6 _+ᴹ_ record LeftKModule {ℓ ℓᴷ : Level} (ffield : CompleteApartnessFieldWithAbs {ℓᴷ}) : Type (ℓ-suc (ℓ-max ℓ ℓᴷ)) where open CompleteApartnessFieldWithAbs ffield renaming ( Carrier to Carrierᴷ ; 0f to 0ᴷ ; 1f to 1ᴷ ; _+_ to _+ᴷ_ ; _·_ to _·ᴷ_ ; -_ to -ᴷ_ ) public field Carrier : Type ℓ 0ᴹ : Carrier _+ᴹ_ : Carrier → Carrier → Carrier _·ᴹ_ : Carrierᴷ → Carrier → Carrier -ᴹ_ : Carrier → Carrier isLeftRModule : IsLeftRModule 1ᴷ _+ᴷ_ _·ᴷ_ 0ᴹ _+ᴹ_ _·ᴹ_ -ᴹ_
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_258.asm
ljhsiun2/medusa
9
24363
<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %rcx push %rdi push %rsi lea addresses_WT_ht+0x1cb23, %rsi lea addresses_WC_ht+0x19a83, %rdi nop nop sub %r8, %r8 mov $67, %rcx rep movsb nop nop nop cmp %r11, %r11 pop %rsi pop %rdi pop %rcx pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r9 push %rbp push %rcx push %rdi push %rdx // Faulty Load lea addresses_UC+0x1683, %rcx nop nop nop nop dec %rdx vmovups (%rcx), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $0, %xmm5, %rbp lea oracles, %rdi and $0xff, %rbp shlq $12, %rbp mov (%rdi,%rbp,1), %rbp pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_UC', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_UC', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'} {'37': 21829} 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 */
bb-runtimes/arm/stm32/stm32f7x9/svd/a-intnam.ads
JCGobbi/Nucleo-STM32G474RE
0
24008
<gh_stars>0 -- -- Copyright (C) 2017, AdaCore -- -- This spec has been automatically generated from STM32F7x9.svd -- This is a version for the STM32F7x9 MCU package Ada.Interrupts.Names is -- All identifiers in this unit are implementation defined pragma Implementation_Defined; ---------------- -- Interrupts -- ---------------- -- System tick Sys_Tick_Interrupt : constant Interrupt_ID := -1; -- Window Watchdog interrupt WWDG_Interrupt : constant Interrupt_ID := 0; -- Tamper and TimeStamp interrupts through the EXTI line TAMP_STAMP_Interrupt : constant Interrupt_ID := 2; -- RTC Tamper or TimeStamp /CSS on LSE through EXTI line 19 interrupts RTC_WKUP_Interrupt : constant Interrupt_ID := 3; -- Flash global interrupt FLASH_Interrupt : constant Interrupt_ID := 4; -- RCC global interrupt RCC_Interrupt : constant Interrupt_ID := 5; -- EXTI Line0 interrupt EXTI0_Interrupt : constant Interrupt_ID := 6; -- EXTI Line1 interrupt EXTI1_Interrupt : constant Interrupt_ID := 7; -- EXTI Line2 interrupt EXTI2_Interrupt : constant Interrupt_ID := 8; -- EXTI Line3 interrupt EXTI3_Interrupt : constant Interrupt_ID := 9; -- EXTI Line4 interrupt EXTI4_Interrupt : constant Interrupt_ID := 10; -- DMA1 Stream0 global interrupt DMA1_Stream0_Interrupt : constant Interrupt_ID := 11; -- DMA1 Stream1 global interrupt DMA1_Stream1_Interrupt : constant Interrupt_ID := 12; -- DMA1 Stream2 global interrupt DMA1_Stream2_Interrupt : constant Interrupt_ID := 13; -- DMA1 Stream3 global interrupt DMA1_Stream3_Interrupt : constant Interrupt_ID := 14; -- DMA1 Stream4 global interrupt DMA1_Stream4_Interrupt : constant Interrupt_ID := 15; -- DMA1 Stream5 global interrupt DMA1_Stream5_Interrupt : constant Interrupt_ID := 16; -- DMA1 Stream6 global interrupt DMA1_Stream6_Interrupt : constant Interrupt_ID := 17; -- ADC1 global interrupt ADC_Interrupt : constant Interrupt_ID := 18; -- CAN1 TX interrupts CAN1_TX_Interrupt : constant Interrupt_ID := 19; -- CAN1 RX0 interrupts CAN1_RX0_Interrupt : constant Interrupt_ID := 20; -- CAN1 RX1 interrupts CAN1_RX1_Interrupt : constant Interrupt_ID := 21; -- CAN1 SCE interrupt CAN1_SCE_Interrupt : constant Interrupt_ID := 22; -- EXTI Line[9:5] interrupts EXTI9_5_Interrupt : constant Interrupt_ID := 23; -- TIM1 Break interrupt and TIM9 global interrupt TIM1_BRK_TIM9_Interrupt : constant Interrupt_ID := 24; -- TIM1 Update interrupt and TIM10 global interrupt TIM1_UP_TIM10_Interrupt : constant Interrupt_ID := 25; -- TIM1 Trigger and Commutation interrupts and TIM11 global interrupt TIM1_TRG_COM_TIM11_Interrupt : constant Interrupt_ID := 26; -- TIM1 Capture Compare interrupt TIM1_CC_Interrupt : constant Interrupt_ID := 27; -- TIM2 global interrupt TIM2_Interrupt : constant Interrupt_ID := 28; -- TIM3 global interrupt TIM3_Interrupt : constant Interrupt_ID := 29; -- TIM4 global interrupt TIM4_Interrupt : constant Interrupt_ID := 30; -- I2C1 event interrupt I2C1_EV_Interrupt : constant Interrupt_ID := 31; -- I2C1 error interrupt I2C1_ER_Interrupt : constant Interrupt_ID := 32; -- I2C2 event interrupt I2C2_EV_Interrupt : constant Interrupt_ID := 33; -- I2C2 error interrupt I2C2_ER_Interrupt : constant Interrupt_ID := 34; -- SPI1 global interrupt SPI1_Interrupt : constant Interrupt_ID := 35; -- SPI2 global interrupt SPI2_Interrupt : constant Interrupt_ID := 36; -- USART1 global interrupt USART1_Interrupt : constant Interrupt_ID := 37; -- USART2 global interrupt USART2_Interrupt : constant Interrupt_ID := 38; -- USART3 global interrupt USART3_Interrupt : constant Interrupt_ID := 39; -- EXTI Line[15:10] interrupts EXTI15_10_Interrupt : constant Interrupt_ID := 40; -- RTC alarms through EXTI line 18 interrupts RTC_ALARM_Interrupt : constant Interrupt_ID := 41; -- USB On-The-Go FS Wakeup through EXTI line interrupt OTG_FS_WKUP_Interrupt : constant Interrupt_ID := 42; -- TIM8 Break interrupt and TIM12 global interrupt TIM8_BRK_TIM12_Interrupt : constant Interrupt_ID := 43; -- TIM8 Update interrupt and TIM13 global interrupt TIM8_UP_TIM13_Interrupt : constant Interrupt_ID := 44; -- TIM8 Trigger and Commutation interrupts and TIM14 global interrupt TIM8_TRG_COM_TIM14_Interrupt : constant Interrupt_ID := 45; -- TIM8 Capture Compare interrupt TIM8_CC_Interrupt : constant Interrupt_ID := 46; -- DMA1 Stream7 global interrupt DMA1_Stream7_Interrupt : constant Interrupt_ID := 47; -- FMC global interrupt FMC_Interrupt : constant Interrupt_ID := 48; -- SDMMC1 global interrupt SDMMC1_Interrupt : constant Interrupt_ID := 49; -- TIM5 global interrupt TIM5_Interrupt : constant Interrupt_ID := 50; -- SPI3 global interrupt SPI3_Interrupt : constant Interrupt_ID := 51; -- UART4 global interrupt UART4_Interrupt : constant Interrupt_ID := 52; -- UART5 global interrupt UART5_Interrupt : constant Interrupt_ID := 53; -- TIM6 global interrupt, DAC1 and DAC2 underrun error interrupt TIM6_DAC_Interrupt : constant Interrupt_ID := 54; -- TIM7 global interrupt TIM7_Interrupt : constant Interrupt_ID := 55; -- DMA2 Stream0 global interrupt DMA2_Stream0_Interrupt : constant Interrupt_ID := 56; -- DMA2 Stream1 global interrupt DMA2_Stream1_Interrupt : constant Interrupt_ID := 57; -- DMA2 Stream2 global interrupt DMA2_Stream2_Interrupt : constant Interrupt_ID := 58; -- DMA2 Stream3 global interrupt DMA2_Stream3_Interrupt : constant Interrupt_ID := 59; -- DMA2 Stream4 global interrupt DMA2_Stream4_Interrupt : constant Interrupt_ID := 60; -- Ethernet global interrupt ETH_Interrupt : constant Interrupt_ID := 61; -- Ethernet global interrupt ETH_WKUP_Interrupt : constant Interrupt_ID := 62; -- CAN2 TX interrupts CAN2_TX_Interrupt : constant Interrupt_ID := 63; -- CAN2 RX0 interrupts CAN2_RX0_Interrupt : constant Interrupt_ID := 64; -- CAN2 RX1 interrupts CAN2_RX1_Interrupt : constant Interrupt_ID := 65; -- CAN2 SCE interrupt CAN2_SCE_Interrupt : constant Interrupt_ID := 66; -- USB On The Go FS global interrupt OTG_FS_Interrupt : constant Interrupt_ID := 67; -- DMA2 Stream5 global interrupt DMA2_Stream5_Interrupt : constant Interrupt_ID := 68; -- DMA2 Stream6 global interrupt DMA2_Stream6_Interrupt : constant Interrupt_ID := 69; -- DMA2 Stream7 global interrupt DMA2_Stream7_Interrupt : constant Interrupt_ID := 70; -- USART6 global interrupt USART6_Interrupt : constant Interrupt_ID := 71; -- I2C3 event interrupt I2C3_EV_Interrupt : constant Interrupt_ID := 72; -- I2C3 error interrupt I2C3_ER_Interrupt : constant Interrupt_ID := 73; -- USB On The Go HS End Point 1 Out global interrupt OTG_HS_EP1_OUT_Interrupt : constant Interrupt_ID := 74; -- USB On The Go HS End Point 1 In global interrupt OTG_HS_EP1_IN_Interrupt : constant Interrupt_ID := 75; -- USB On The Go HS Wakeup through EXTI interrupt OTG_HS_WKUP_Interrupt : constant Interrupt_ID := 76; -- USB On The Go HS global interrupt OTG_HS_Interrupt : constant Interrupt_ID := 77; -- DCMI global interrupt DCMI_Interrupt : constant Interrupt_ID := 78; -- Hash and Rng global interrupt HASH_RNG_Interrupt : constant Interrupt_ID := 80; -- FPU global interrupt FPU_Interrupt : constant Interrupt_ID := 81; -- UART7 global interrupt UART7_Interrupt : constant Interrupt_ID := 82; -- UART 8 global interrupt UART8_Interrupt : constant Interrupt_ID := 83; -- SPI 4 global interrupt SPI4_Interrupt : constant Interrupt_ID := 84; -- SPI 5 global interrupt SPI5_Interrupt : constant Interrupt_ID := 85; -- SPI 6 global interrupt SPI6_Interrupt : constant Interrupt_ID := 86; -- SAI1 global interrupt SAI1_Interrupt : constant Interrupt_ID := 87; -- LTDC global interrupt LTDC_Interrupt : constant Interrupt_ID := 88; -- LTDC Error global interrupt LTDC_ER_Interrupt : constant Interrupt_ID := 89; -- DMA2D global interrupt DMA2D_Interrupt : constant Interrupt_ID := 90; -- SAI2 global interrupt SAI2_Interrupt : constant Interrupt_ID := 91; -- QUADSPI global interrupt QUADSPI_Interrupt : constant Interrupt_ID := 92; -- LPTIM1 global interrupt LPTIM1_Interrupt : constant Interrupt_ID := 93; -- CEC global interrupt CEC_Interrupt : constant Interrupt_ID := 94; -- I2C4 event interrupt I2C4_EV_Interrupt : constant Interrupt_ID := 95; -- I2C4 error interrupt I2C4_ER_Interrupt : constant Interrupt_ID := 96; -- SPDIF_RX global interrupt SPDIF_RX_Interrupt : constant Interrupt_ID := 97; -- DSI global interrupt DSI_Interrupt : constant Interrupt_ID := 98; -- DFSDM1 Filter 0 global interrupt DFSDM1_FLT0_Interrupt : constant Interrupt_ID := 99; -- DFSDM1 Filter 1 global interrupt DFSDM1_FLT1_Interrupt : constant Interrupt_ID := 100; -- DFSDM1 Filter 2 global interrupt DFSDM1_FLT2_Interrupt : constant Interrupt_ID := 101; -- DFSDM1 Filter 3 global interrupt DFSDM1_FLT3_Interrupt : constant Interrupt_ID := 102; -- SDMMC2 global interrupt SDMMC2_Interrupt : constant Interrupt_ID := 103; -- CAN3 TX interrupt CAN3_TX_Interrupt : constant Interrupt_ID := 104; -- CAN3 RX0 interrupt CAN3_RX0_Interrupt : constant Interrupt_ID := 105; -- CAN3 RX1 interrupt CAN3_RX1_Interrupt : constant Interrupt_ID := 106; -- CAN3 SCE interrupt CAN3_SCE_Interrupt : constant Interrupt_ID := 107; -- JPEG global interrupt JPEG_Interrupt : constant Interrupt_ID := 108; -- MDIO slave global interrupt MDIOS_Interrupt : constant Interrupt_ID := 109; end Ada.Interrupts.Names;
assembler/tests/t_68kaddr/t_68kaddr.asm
paulscottrobson/RCA-Cosmac-VIP-III
0
247535
<filename>assembler/tests/t_68kaddr/t_68kaddr.asm cpu 68000 page 0 ; basic 68000 modes move.l d3,d7 move.l a3,d7 move.l (a3),d7 move.l (a3)+,d7 move.l -(a3),d7 move.l 1000(a3),d7 ; "68000 style" move.l (1000,a3),d7 ; "68020 style" move.l 120(a3,a4.w),d7 ; "68000 style" move.l (120,a3,a4.w),d7 ; "68020 style" move.l 120(a3,a4.l),d7 ; "68000 style" move.l (120,a3,a4.l),d7 ; "68020 style" move.l 120(a3,d4.w),d7 ; "68000 style" move.l (120,a3,d4.w),d7 ; "68020 style" move.l 120(a3,d4.l),d7 ; "68000 style" move.l (120,a3,d4.l),d7 ; "68020 style" move.l 10000,d7 ; "68000 style" move.l 10000.l,d7 ; "68000 style" move.l 100000,d7 ; "68000 style" move.l (10000),d7 ; "68020 style" move.l (10000.l),d7 ; "68020 style" move.l (100000),d7 ; "68020 style" move.l *(pc,a4.w),d7 ; "68000 style" move.l (*,pc,a4.w),d7 ; "68020 style" move.l *(pc,a4.l),d7 ; "68000 style" move.l (*,pc,a4.l),d7 ; "68020 style" move.l *(pc,d4.w),d7 ; "68000 style" move.l (*,pc,d4.w),d7 ; "68020 style" move.l *(pc,d4.l),d7 ; "68000 style" move.l (*,pc,d4.l),d7 ; "68020 style" move.l #$aa554711,d7 ; extended 68020+ modes cpu 68020 ; base displacement move.l (10000,a3,d4.l*4),d7 ; all components move.l (10000.l,a3,d4.l*4),d7 move.l (10000,a3,d4.l*1),d7 ; ->scale field zero move.l (10000.l,a3,d4.l*1),d7 move.l (10000,a3,d4.w*1),d7 ; ->word instead of longword index move.l (10000.l,a3,d4.w*1),d7 move.l (10000,a3),d7 ; no index move.l (10000.l,a3),d7 move.l (10000,d4.w*1),d7 ; no basereg move.l (10000.l,d4.w*1),d7 ; no index (post/pre-indexed setting in I/IS irrelevant?) move.l ([10000]),d7 move.l ([10000.l]),d7 move.l ([a3]),d7 move.l ([a3,10000]),d7 move.l ([a3,10000.l]),d7 move.l ([10000],20000),d7 move.l ([10000.l],20000.l),d7 move.l ([a3],20000),d7 move.l ([a3],20000.l),d7 move.l ([10000,a3],20000),d7 move.l ([10000.l,a3],20000.l),d7 ; postindexed move.l ([10000],d4.w*1),d7 move.l ([10000.l],d4.l*4),d7 move.l ([a3],d4.w*1),d7 move.l ([a3],d4.l*4),d7 move.l ([10000,a3],d4.w*1),d7 move.l ([10000.l,a3],d4.l*4),d7 move.l ([10000],d4.w*1,20000),d7 move.l ([10000.l],d4.l*4,20000.l),d7 move.l ([a3],d4.w*1,20000),d7 move.l ([a3],d4.l*4,20000.l),d7 move.l ([10000,a3],d4.w*1,20000),d7 move.l ([10000.l,a3],d4.l*4,20000.l),d7 ; preindexed move.l ([10000,d4.w*1]),d7 move.l ([10000.l,d4.l*4]),d7 move.l ([a3,d4.w*1]),d7 move.l ([a3,d4.l*4]),d7 move.l ([10000,a3,d4.w*1]),d7 move.l ([10000.l,a3,d4.l*4]),d7 move.l ([10000,d4.w*1],20000),d7 move.l ([10000.l,d4.l*4],20000.l),d7 move.l ([a3,d4.w*1],20000),d7 move.l ([a3,d4.l*4],20000.l),d7 move.l ([10000,a3,d4.w*1],20000),d7 move.l ([10000.l,a3,d4.l*4],20000.l),d7 ; PC with base displacement move.l (*,pc,d4.l*4),d7 ; all components move.l (*.l,pc,d4.l*4),d7 move.l (*,pc,d4.l*1),d7 ; ->scale field zero move.l (*.l,pc,d4.l*1),d7 move.l (*,pc,d4.w*1),d7 ; ->word instead of longword index move.l (*.l,pc,d4.w*1),d7 move.l (*,pc),d7 ; no index move.l (*.l,pc),d7 ; PC postindexed move.l ([pc],d4.w*1),d7 move.l ([pc],d4.l*4),d7 move.l ([*,pc],d4.w*1),d7 move.l ([*.l,pc],d4.l*4),d7 move.l ([pc],d4.w*1,20000),d7 move.l ([pc],d4.l*4,20000.l),d7 move.l ([*,pc],d4.w*1,20000),d7 move.l ([*.l,pc],d4.l*4,20000.l),d7 ; PC preindexed move.l ([pc,d4.w*1]),d7 move.l ([pc,d4.l*4]),d7 move.l ([*,pc,d4.w*1]),d7 move.l ([*.l,pc,d4.l*4]),d7 move.l ([pc,d4.w*1],20000),d7 move.l ([pc,d4.l*4],20000.l),d7 move.l ([*,pc,d4.w*1],20000),d7 move.l ([*.l,pc,d4.l*4],20000.l),d7
programs/oeis/044/A044667.asm
jmorken/loda
1
160038
; A044667: Numbers n such that string 3,8 occurs in the base 9 representation of n but not of n+1. ; 35,116,197,278,323,359,440,521,602,683,764,845,926,1007,1052,1088,1169,1250,1331,1412,1493,1574,1655,1736,1781,1817,1898,1979,2060,2141,2222,2303,2384,2465,2510,2546,2627,2708,2789 mov $4,$0 mov $5,$0 add $5,1 mov $7,$0 lpb $5 mov $0,$7 sub $5,1 sub $0,$5 lpb $0 add $0,56 mov $2,$0 mov $0,0 mod $2,10 add $2,2 mov $3,2 add $3,$2 mov $6,5 mod $6,$3 mul $6,2 lpe mov $8,$6 div $8,2 mul $8,9 add $8,35 add $1,$8 lpe add $1,$4
source/a-unccon.ads
ytomino/drake
33
13328
<gh_stars>10-100 pragma License (Unrestricted); generic type Source (<>) is limited private; type Target (<>) is limited private; function Ada.Unchecked_Conversion (S : Source) return Target with Import, Convention => Intrinsic; pragma Pure (Ada.Unchecked_Conversion);
server/node_modules/node-osascript/demos/externalFile/external.scpt
c99koder/wear-imessage
5
2424
<reponame>c99koder/wear-imessage<filename>server/node_modules/node-osascript/demos/externalFile/external.scpt display dialog "What should I do?" buttons buttonNames set DlogResult to result return result
oeis/060/A060001.asm
neoneye/loda-programs
11
95158
; A060001: a(n) = Fibonacci(n)!. ; Submitted by <NAME> ; 1,1,2,6,120,40320,6227020800,51090942171709440000,295232799039604140847618609643520000000,12696403353658275925965100847566516959580321051449436762275840000000000000,16507955160908461081216919262453619309839666236496541854913520707833171034378509739399912570787600662729080382999756800000000000000000000 add $0,1 seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. mov $2,1 lpb $0 mul $2,$0 sub $0,1 lpe mov $0,$2
testsuite/ubivm/output/returning_one_value2.asm
alexgarzao/UOP
0
24289
.constant_pool .const 0 string [start] .const 1 string [adicao] .const 2 string [x] .const 3 string [y] .const 4 string [constructor] .const 5 string [a] .const 6 int [10] .const 7 int [20] .const 8 string [Adicao dos valores : ] .const 9 int [2] .const 10 string [io.writeln] .end .entity start .valid_context_when (always) .method adicao .param 0 int x .param 1 int y .result 0 int ldparam 0 --> [x] ldparam 1 --> [y] add stresult 0 ret .end .method constructor .var 0 int a ldconst 6 --> [10] ldconst 7 --> [20] ldself mcall 1 --> [adicao] stvar 0 --> [a] ldconst 8 --> [Adicao dos valores : ] ldvar 0 --> [a] ldconst 9 --> [2] lcall 10 --> [io.writeln] exit .end .end
libsrc/target/sms/read_joypad1.asm
dikdom/z88dk
1
3845
<gh_stars>1-10 SECTION code_clib PUBLIC read_joypad1 PUBLIC _read_joypad1 ;============================================================== ; int read_joypad1() ;============================================================== ; Reads the joystick 1 ;============================================================== read_joypad1: _read_joypad1: in a, ($dc) ; Reads joystick 1 cpl ; Inverts all bits ld h, 0 ld l, a ; Puts the result in HL ret
src/loaders/stivale2/smp.nasm
Matt8898/TomatBoot-UEFI
88
14945
<filename>src/loaders/stivale2/smp.nasm [SECTION .data] [GLOBAL gSmpTrampoline] gSmpTrampoline: [BITS 16] ; At this point CS = 0x(vv00) and ip= 0x0. ; clear everything cli cld ; set the gdt mov si, gSmpTplGdt - gSmpTrampoline o32 lgdt [cs:si] ; calculate our physical address ((.mode32 - base) + cs * 16) mov edi, .mode32 - gSmpTrampoline mov ax, cs shl eax, 4 add edi, eax ; set it in the buffer mov si, gMode32Addr - gSmpTrampoline mov [cs:si], edi ; enter protected mode mov eax, cr0 bts eax, 0 mov cr0, eax ; jump to it jmp far [cs:si] [BITS 32] ; set all the segment registers .mode32: mov ax, 0x20 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax mov eax, cr0 btr eax, 29 btr eax, 30 mov cr0, eax ; check if we need to enable x2apic test dword [gSmpTplTargetMode], (1 << 2) jz .nox2apic ; configure x2apic mov ecx, 0x1b rdmsr bts eax, 10 bts eax, 11 wrmsr .nox2apic: ; mov eax, cr4 bts eax, 5 mov cr4, eax ; check for 5 level paging test dword [gSmpTplTargetMode], (1 << 1) jz .no5lv ; enable 5 level paging mov eax, cr4 bts eax, 12 mov cr4, eax .no5lv: ; set the pagetable mov eax, dword [gSmpTplPagemap] mov cr3, eax ; enable long mode mov ecx, 0xc0000080 rdmsr bts eax, 8 wrmsr ; enable paging mov eax, cr0 bts eax, 31 mov cr0, eax ; actually enter long mode jmp 0x28:.mode64 [BITS 64] .mode64: ; set the data segments mov ax, 0x30 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; load the info struct and set the booted flag mov rdi, qword [rel gSmpTplInfoStruct] mov eax, 1 lock xchg dword [rel gSmpTplBootedFlag], eax xor eax, eax .loop: ; check if the flag was set lock xadd qword [rdi + 16], rax test rax, rax jnz .out ; no, pause and jump ; back to loop pause jmp .loop .out: mov rsp, qword [rdi + 8] push 0 push rax xor rax, rax xor rbx, rbx xor rcx, rcx xor rdx, rdx xor rsi, rsi xor rbp, rbp xor r8, r8 xor r9, r9 xor r10, r10 xor r11, r11 xor r12, r12 xor r13, r13 xor r14, r14 xor r15, r15 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; These variables are accessed with relative addressing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gMode32Addr: dd 0x0000 dw 24 [GLOBAL gSmpTplBootedFlag] gSmpTplBootedFlag: dd 0 [GLOBAL gSmpTplInfoStruct] gSmpTplInfoStruct: dq 0 [GLOBAL gSmpTplGdt] gSmpTplGdt: dw 0 dd 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; [GLOBAL gSmpTrampolineEnd] gSmpTrampolineEnd: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; these variables are accessed with abs addresses ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; [GLOBAL gSmpTplTargetMode] gSmpTplTargetMode: dd 0 [GLOBAL gSmpTplPagemap] gSmpTplPagemap: dd 0 [GLOBAL gGdtPtr] gGdtPtr: dw .size - 1 ; GDT size dd .start ; GDT start address .start: ; Null desc dq 0 ; 16-bit code dw 0xffff ; Limit dw 0x0000 ; Base (low 16 bits) db 0x00 ; Base (mid 8 bits) db 10011010b ; Access db 00000000b ; Granularity db 0x00 ; Base (high 8 bits) ; 16-bit data dw 0xffff ; Limit dw 0x0000 ; Base (low 16 bits) db 0x00 ; Base (mid 8 bits) db 10010010b ; Access db 00000000b ; Granularity db 0x00 ; Base (high 8 bits) ; 32-bit code dw 0xffff ; Limit dw 0x0000 ; Base (low 16 bits) db 0x00 ; Base (mid 8 bits) db 10011010b ; Access db 11001111b ; Granularity db 0x00 ; Base (high 8 bits) ; 32-bit data dw 0xffff ; Limit dw 0x0000 ; Base (low 16 bits) db 0x00 ; Base (mid 8 bits) db 10010010b ; Access db 11001111b ; Granularity db 0x00 ; Base (high 8 bits) ; 64-bit code dw 0x0000 ; Limit dw 0x0000 ; Base (low 16 bits) db 0x00 ; Base (mid 8 bits) db 10011010b ; Access db 00100000b ; Granularity db 0x00 ; Base (high 8 bits) ; 64-bit data dw 0x0000 ; Limit dw 0x0000 ; Base (low 16 bits) db 0x00 ; Base (mid 8 bits) db 10010010b ; Access db 00000000b ; Granularity db 0x00 ; Base (high 8 bits) .end: .size: equ .end - .start
solutions/32 - Creative Writhing/size-5_speed-1103.asm
michaelgundlach/7billionhumans
45
96455
-- 7 Billion Humans (2053) -- -- 32: Creative Writhing -- -- Author: soerface -- Size: 5 -- Speed: 1103 a: step w,n,s,e pickup c write 99 drop jump a
contrib/gnu/gdb/dist/zlib/contrib/ada/zlib-streams.ads
TheSledgeHammer/2.11BSD
3
5131
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 <NAME> -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-streams.ads,v 1.2 2020/09/15 02:05:31 christos Exp $ package ZLib.Streams is type Stream_Mode is (In_Stream, Out_Stream, Duplex); type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; type Stream_Type is new Ada.Streams.Root_Stream_Type with private; procedure Read (Stream : in out Stream_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Write (Stream : in out Stream_Type; Item : in Ada.Streams.Stream_Element_Array); procedure Flush (Stream : in out Stream_Type; Mode : in Flush_Mode := Sync_Flush); -- Flush the written data to the back stream, -- all data placed to the compressor is flushing to the Back stream. -- Should not be used until necessary, because it is decreasing -- compression. function Read_Total_In (Stream : in Stream_Type) return Count; pragma Inline (Read_Total_In); -- Return total number of bytes read from back stream so far. function Read_Total_Out (Stream : in Stream_Type) return Count; pragma Inline (Read_Total_Out); -- Return total number of bytes read so far. function Write_Total_In (Stream : in Stream_Type) return Count; pragma Inline (Write_Total_In); -- Return total number of bytes written so far. function Write_Total_Out (Stream : in Stream_Type) return Count; pragma Inline (Write_Total_Out); -- Return total number of bytes written to the back stream. procedure Create (Stream : out Stream_Type; Mode : in Stream_Mode; Back : in Stream_Access; Back_Compressed : in Boolean; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Header : in Header_Type := Default; Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size); -- Create the Comression/Decompression stream. -- If mode is In_Stream then Write operation is disabled. -- If mode is Out_Stream then Read operation is disabled. -- If Back_Compressed is true then -- Data written to the Stream is compressing to the Back stream -- and data read from the Stream is decompressed data from the Back stream. -- If Back_Compressed is false then -- Data written to the Stream is decompressing to the Back stream -- and data read from the Stream is compressed data from the Back stream. -- !!! When the Need_Header is False ZLib-Ada is using undocumented -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers. function Is_Open (Stream : Stream_Type) return Boolean; procedure Close (Stream : in out Stream_Type); private use Ada.Streams; type Buffer_Access is access all Stream_Element_Array; type Stream_Type is new Root_Stream_Type with record Mode : Stream_Mode; Buffer : Buffer_Access; Rest_First : Stream_Element_Offset; Rest_Last : Stream_Element_Offset; -- Buffer for Read operation. -- We need to have this buffer in the record -- because not all read data from back stream -- could be processed during the read operation. Buffer_Size : Stream_Element_Offset; -- Buffer size for write operation. -- We do not need to have this buffer -- in the record because all data could be -- processed in the write operation. Back : Stream_Access; Reader : Filter_Type; Writer : Filter_Type; end record; end ZLib.Streams;
P5/P5_TestCode/P5_L1_testcase28/P5_L1_testcase28/mips28.asm
alxzzhou/BUAA_CO_2020
1
18143
<gh_stars>1-10 ori $t1,$t1,1 ori $t2,$t2,2 addu $t0,$t1,$t2 nop sw $t0,0($0)
test/Succeed/Issue1532.agda
alhassy/agda
3
4747
module _ where infixr 5 _⇒_ infixl 6 _▻_ infix 3 _⊢_ _∈_ infixr 5 vs_ infixr 4 ƛ_ infixl 6 _·_ data Type : Set where ι : Type _⇒_ : Type → Type → Type data Con : Set where ε : Con _▻_ : Con → Type → Con data _∈_ σ : Con → Set where vz : ∀ {Γ} → σ ∈ Γ ▻ σ vs_ : ∀ {Γ τ} → σ ∈ Γ → σ ∈ Γ ▻ τ data _⊢_ Γ : Type → Set where var : ∀ {σ} → σ ∈ Γ → Γ ⊢ σ ƛ_ : ∀ {σ τ} → Γ ▻ σ ⊢ τ → Γ ⊢ σ ⇒ τ _·_ : ∀ {σ τ} → Γ ⊢ σ ⇒ τ → Γ ⊢ σ → Γ ⊢ τ Term : Type → Set Term σ = ε ⊢ σ postulate _extends_ : Con → Con → Set instance extends-stop : ∀ {Γ} → Γ extends Γ extends-skip : ∀ {Γ Δ σ} {{_ : Δ extends Γ}} → (Δ ▻ σ) extends Γ lam : ∀ {Γ σ τ} → ((∀ {Δ} {{_ : Δ extends (Γ ▻ σ)}} → Δ ⊢ σ) → Γ ▻ σ ⊢ τ) → Γ ⊢ σ ⇒ τ I : Term (ι ⇒ ι) I = lam λ x → x K : Term (ι ⇒ ι ⇒ ι) K = lam λ x → lam λ y → x A : Term ((ι ⇒ ι) ⇒ ι ⇒ ι) A = lam λ f → lam λ x → f {{extends-skip {{extends-stop}}}} · x {{extends-stop}} loop : Term ((ι ⇒ ι) ⇒ ι ⇒ ι) loop = lam λ f → lam λ x → f · x
src/mainprg/transition.asm
Ralakimus/sega-cd-asic-demo
4
86037
<filename>src/mainprg/transition.asm<gh_stars>1-10 ; ------------------------------------------------------------------------- ; ; Sega CD Base ; By Ralakimus 2021 ; ; ------------------------------------------------------------------------- DoTransition: move #$2700,sr ; Disable interrupts move.l #VInterrupt,_LEVEL6+2.w ; Set interrupts move.l #IntBlank,_LEVEL4+2.w move.w #_LEVEL4,GA_HINT z80Stop ; Initialize controllers moveq #$40,d0 move.b d0,IO_A_CTRL move.b d0,IO_B_CTRL move.b d0,IO_C_CTRL z80Start lea vars_start.w,a0 ; Clear variables move.w #(vars_end-vars_start)/2-1,d0 .ClearRAM: clr.w (a0)+ dbf d0,.ClearRAM lea VDP_CTRL,a0 ; Set VDP registers move.w #$8004,(a0) move.w #$8174,(a0) move.w #$8D3F,(a0) move.w #$9001,(a0) lea palette.w,a1 ; Prepare to copy palette moveq #$80/2-1,d0 .WaitVBlank: move.w (a0),ccr ; Wait until we are in the VBlank period first bmi.s .WaitVBlank move.l #$00000020,(a0) ; Now copy the palette .CopyPal: move.w -4(a0),(a1)+ dbf d0,.CopyPal bsr.w FadeToBlack ; Fade the colors to black move #$2700,sr ; Disable interrupts bra.w Main ; Go to main program ; -------------------------------------------------------------------------
oeis/250/A250764.asm
neoneye/loda-programs
11
82081
; A250764: Number of (n+1) X (3+1) 0..1 arrays with nondecreasing x(i,j)-x(i,j-1) in the i direction and nondecreasing absolute value of x(i,j)-x(i-1,j) in the j direction. ; 35,62,114,216,418,820,1622,3224,6426,12828,25630,51232,102434,204836,409638,819240,1638442,3276844,6553646,13107248,26214450,52428852,104857654,209715256,419430458,838860860,1677721662,3355443264,6710886466,13421772868,26843545670,53687091272,107374182474,214748364876,429496729678,858993459280,1717986918482,3435973836884,6871947673686,13743895347288,27487790694490,54975581388892,109951162777694,219902325555296,439804651110498,879609302220900,1759218604441702,3518437208883304,7036874417766506 mov $2,2 pow $2,$0 mul $2,25 add $2,21 add $2,$0 add $0,$2 sub $0,11
mac/disable_sound_effects.scpt
treaz/local-dev-env-setup
1
1029
<reponame>treaz/local-dev-env-setup # Reference: https://apple.stackexchange.com/questions/44886/modifying-user-interface-sound-effects-with-applescript#44892 tell application "System Preferences" reveal anchor "effects" of pane id "com.apple.preference.sound" end tell tell application "System Events" tell process "System Preferences" set theBox to checkbox 1 of tab group 1 of window 1 if value of theBox is not 1 then -- or "is 1" click theBox end if end tell end tell
45/beef/cw/kernel/cwos2.asm
minblock/msdos
0
86263
;* ;* CW : Character Windows ;* ;* cwos2.asm : jump table data for OS/2 (copied to inosDrv) include kernel.inc include indrv.inc ;***************************************************************************** IFNDEF DUAL ;!DUAL Assert ;* DUAL only ENDIF ;!DUAL ;***************************************************************************** externFP <CWBeginIO,CWEndIO> ;***************************************************************************** createSeg CWOS2,CWOS2,BYTE,PUBLIC,CODE sBegin CWOS2 assumes CS,CWOS2 assumes DS,CWOS2 PUBLIC inosDrvOS2 inosDrv: ;* this label is not exported but referenced by _inos.asm inosDrvOS2: include _inos.asm sEnd CWOS2 ;***************************************************************************** END
programs/oeis/021/A021459.asm
neoneye/loda
22
9919
; A021459: Decimal expansion of 1/455. ; 0,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2,1,9,7,8,0,2 add $0,1 mov $1,10 pow $1,$0 mul $1,6 div $1,2730 mod $1,10 mov $0,$1
libsrc/_DEVELOPMENT/arch/sms/vdp/c/sccz80/sms_vdp_init.asm
jpoikela/z88dk
640
104101
<reponame>jpoikela/z88dk<gh_stars>100-1000 ; void sms_vdp_init(void *vdp_register_array) SECTION code_clib SECTION code_arch PUBLIC sms_vdp_init EXTERN asm_sms_vdp_init sms_vdp_init: di call asm_sms_vdp_init ei ret
Definition/LogicalRelation/Properties/Reduction.agda
loic-p/logrel-mltt
0
2715
<gh_stars>0 {-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Reduction {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties.Reflexivity open import Definition.LogicalRelation.Properties.Universe open import Definition.LogicalRelation.Properties.Escape open import Tools.Embedding open import Tools.Product import Tools.PropositionalEquality as PE -- Weak head expansion of reducible types. redSubst* : ∀ {A B l Γ} → Γ ⊢ A ⇒* B → Γ ⊩⟨ l ⟩ B → ∃ λ ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / [A] redSubst* D (Uᵣ′ l′ l< ⊢Γ) rewrite redU* D = Uᵣ′ l′ l< ⊢Γ , U₌ PE.refl redSubst* D (ℕᵣ [ ⊢B , ⊢ℕ , D′ ]) = let ⊢A = redFirst* D in ℕᵣ ([ ⊢A , ⊢ℕ , D ⇨* D′ ]) , ιx (ℕ₌ D′) redSubst* D (ne′ K [ ⊢B , ⊢K , D′ ] neK K≡K) = let ⊢A = redFirst* D in (ne′ K [ ⊢A , ⊢K , D ⇨* D′ ] neK K≡K) , ιx (ne₌ _ [ ⊢B , ⊢K , D′ ] neK K≡K) redSubst* D (Πᵣ′ F G [ ⊢B , ⊢ΠFG , D′ ] ⊢F ⊢G A≡A [F] [G] G-ext) = let ⊢A = redFirst* D in (Πᵣ′ F G [ ⊢A , ⊢ΠFG , D ⇨* D′ ] ⊢F ⊢G A≡A [F] [G] G-ext) , (Π₌ _ _ D′ A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a]))) redSubst* D (emb′ 0<1 x) with redSubst* D x redSubst* D (emb′ 0<1 x) | y , y₁ = emb′ 0<1 y , ιx y₁ -- Weak head expansion of reducible terms. redSubst*Term : ∀ {A t u l Γ} → Γ ⊢ t ⇒* u ∷ A → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ u ∷ A / [A] → Γ ⊩⟨ l ⟩ t ∷ A / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A] redSubst*Term t⇒u (Uᵣ′ .⁰ 0<1 ⊢Γ) (Uₜ A [ ⊢t , ⊢u , d ] typeA A≡A [u]) = let [d] = [ ⊢t , ⊢u , d ] [d′] = [ redFirst*Term t⇒u , ⊢u , t⇒u ⇨∷* d ] q = redSubst* (univ* t⇒u) (univEq (Uᵣ′ ⁰ 0<1 ⊢Γ) (Uₜ A [d] typeA A≡A [u])) in Uₜ A [d′] typeA A≡A (proj₁ q) , Uₜ₌ A A [d′] [d] typeA typeA A≡A (proj₁ q) [u] (proj₂ q) redSubst*Term t⇒u (ℕᵣ D) (ιx (ℕₜ n [ ⊢u , ⊢n , d ] n≡n prop)) = let A≡ℕ = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡ℕ t⇒u′ = conv* t⇒u A≡ℕ in ιx (ℕₜ n [ ⊢t , ⊢n , t⇒u′ ⇨∷* d ] n≡n prop) , ιx (ℕₜ₌ n n [ ⊢t , ⊢n , t⇒u′ ⇨∷* d ] [ ⊢u , ⊢n , d ] n≡n (reflNatural-prop prop)) redSubst*Term t⇒u (ne′ K D neK K≡K) (ιx (neₜ k [ ⊢t , ⊢u , d ] (neNfₜ neK₁ ⊢k k≡k))) = let A≡K = subset* (red D) [d] = [ ⊢t , ⊢u , d ] [d′] = [ conv (redFirst*Term t⇒u) A≡K , ⊢u , conv* t⇒u A≡K ⇨∷* d ] in ιx (neₜ k [d′] (neNfₜ neK₁ ⊢k k≡k)) , ιx (neₜ₌ k k [d′] [d] (neNfₜ₌ neK₁ neK₁ k≡k)) redSubst*Term {A} {t} {u} {l} {Γ} t⇒u (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f [ ⊢t , ⊢u , d ] funcF f≡f [f] [f]₁) = let A≡ΠFG = subset* (red D) t⇒u′ = conv* t⇒u A≡ΠFG [d] = [ ⊢t , ⊢u , d ] [d′] = [ conv (redFirst*Term t⇒u) A≡ΠFG , ⊢u , conv* t⇒u A≡ΠFG ⇨∷* d ] in Πₜ f [d′] funcF f≡f [f] [f]₁ , Πₜ₌ f f [d′] [d] funcF funcF f≡f (Πₜ f [d′] funcF f≡f [f] [f]₁) (Πₜ f [d] funcF f≡f [f] [f]₁) (λ [ρ] ⊢Δ [a] → reflEqTerm ([G] [ρ] ⊢Δ [a]) ([f]₁ [ρ] ⊢Δ [a])) redSubst*Term t⇒u (emb′ 0<1 x) (ιx [u]) = let x = redSubst*Term t⇒u x [u] in ιx (proj₁ x) , ιx (proj₂ x) -- Weak head expansion of reducible types with single reduction step. redSubst : ∀ {A B l Γ} → Γ ⊢ A ⇒ B → Γ ⊩⟨ l ⟩ B → ∃ λ ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / [A] redSubst A⇒B [B] = redSubst* (A⇒B ⇨ id (escape [B])) [B] -- Weak head expansion of reducible terms with single reduction step. redSubstTerm : ∀ {A t u l Γ} → Γ ⊢ t ⇒ u ∷ A → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ u ∷ A / [A] → Γ ⊩⟨ l ⟩ t ∷ A / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A] redSubstTerm t⇒u [A] [u] = redSubst*Term (t⇒u ⇨ id (escapeTerm [A] [u])) [A] [u]
sharding-core/src/main/antlr4/imports/PostgreSQLTCLStatement.g4
ahugeStone/sharding-sphere
0
2641
<reponame>ahugeStone/sharding-sphere grammar PostgreSQLTCLStatement; import PostgreSQLKeyword, Keyword, BaseRule, DataType, Symbol; setTransaction : SET TRANSACTION (transactionMode (COMMA transactionMode)* | SNAPSHOT ID) | SET SESSION CHARACTERISTICS AS TRANSACTION transactionMode (COMMA transactionMode)* ; transactionMode : ISOLATION LEVEL (SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED) | READ (WRITE | ONLY) | NOT? DEFERRABLE ; commit : COMMIT workOrTransaction? | COMMIT PREPARED ID ; rollback : ROLLBACK (workOrTransaction? | PREPARED ID | workOrTransaction? TO SAVEPOINT? ID) ; savepoint : SAVEPOINT ID ; beginWork : BEGIN workOrTransaction? (transactionMode (COMMA transactionMode)*)? ; startTransaction : START TRANSACTION workOrTransaction? (transactionMode (COMMA transactionMode)*)? ; workOrTransaction : WORK | TRANSACTION ;
programs/oeis/111/A111883.asm
neoneye/loda
22
101839
<filename>programs/oeis/111/A111883.asm ; A111883: Unsigned row sums of triangle A111595 (normalized rescaled squared Hermite polynomials). ; 1,1,4,16,100,676,5776,53824,583696,6864400,90174016,1274204416,19642583104,323196798016,5714394630400,107112895415296,2135062451773696,44858948563673344,994634863541502976,23133227941938073600,564474119626559497216,14388648533002088866816,383018196281236624543744,10613546763550619089125376,305976731203078221621760000,9154747318220746808811851776,284073232160611346199846731776,9124488003677449505828181704704,303152579564225693135839298338816,10402006251486235301040551707033600,368348572513852920094887201527627776 seq $0,85 ; Number of self-inverse permutations on n letters, also known as involutions; number of standard Young tableaux with n cells. pow $0,2
src/DualLMRefined.agda
kcaliban/dual-session
0
891
<reponame>kcaliban/dual-session {-# OPTIONS --rewriting #-} module DualLMRefined where open import Data.Bool open import Data.Nat hiding (compare) open import Data.Nat.Properties open import Data.Fin hiding (_+_) open import Data.Product open import Function open import Relation.Binary.PropositionalEquality hiding (Extensionality) open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite open import Extensionality open import Direction -- variables variable n m : ℕ ---------------------------------------------------------------------- -- auxiliaries for automatic rewriting n+1=suc-n : n + 1 ≡ suc n n+1=suc-n {zero} = refl n+1=suc-n {suc n} = cong suc (n+1=suc-n {n}) {-# REWRITE n+1=suc-n #-} n+0=n : n + 0 ≡ n n+0=n {zero} = refl n+0=n {suc n} = cong suc (n+0=n {n}) {-# REWRITE n+0=n #-} inject+0-x=x : {x : Fin m} → inject+ 0 x ≡ x inject+0-x=x {x = zero} = refl inject+0-x=x {x = suc x} = cong suc inject+0-x=x {-# REWRITE inject+0-x=x #-} n+sucm : n + suc m ≡ suc (n + m) n+sucm {0} = refl n+sucm {suc n} = cong suc (n+sucm{n}) {-# REWRITE n+sucm #-} n=fromℕtoℕn : (toℕ (fromℕ n)) ≡ n n=fromℕtoℕn {zero} = refl n=fromℕtoℕn {suc n} = cong suc (n=fromℕtoℕn {n}) {-# REWRITE n=fromℕtoℕn #-} sucn∸suctoℕx≡n∸toℕx : {n : ℕ} {x : Fin n} → suc (n ∸ suc (toℕ x)) ≡ n ∸ (toℕ x) sucn∸suctoℕx≡n∸toℕx {suc n} {zero} = refl sucn∸suctoℕx≡n∸toℕx {suc n} {suc x} = sucn∸suctoℕx≡n∸toℕx{n}{x} sym-sucn∸suctoℕx≡n∸toℕx : {n : ℕ} {x : Fin n} → n ∸ (toℕ x) ≡ suc (n ∸ suc (toℕ x)) sym-sucn∸suctoℕx≡n∸toℕx {n} {x} = sym (sucn∸suctoℕx≡n∸toℕx{n}{x}) {-# REWRITE sym-sucn∸suctoℕx≡n∸toℕx #-} n∸n≡0F : n ∸ n ≡ 0 n∸n≡0F {0} = refl n∸n≡0F {suc n} = n∸n≡0F{n} {-# REWRITE n∸n≡0F #-} {-# REWRITE m+n∸n≡m #-} ---------------------------------------------------------------------- -- some more required properties on natural numbers and fin toℕx≤n : {n : ℕ} {x : Fin n} → Data.Nat._≤_ (toℕ x) n toℕx≤n {suc n} {zero} = z≤n toℕx≤n {suc n} {suc x} = s≤s toℕx≤n toℕx≤n' : {n : ℕ} {x : Fin (suc n)} → Data.Nat._≤_ (toℕ x) n toℕx≤n' {0} {zero} = z≤n toℕx≤n' {suc n} {zero} = z≤n toℕx≤n' {suc n} {suc x} = s≤s (toℕx≤n'{n}{x}) n∸x+x≡n : {n x : ℕ} → Data.Nat._≤_ x n → n ∸ x + x ≡ n n∸x+x≡n {0} {zero} le = refl n∸x+x≡n {0} {suc x} () n∸x+x≡n {suc n} {zero} le = refl n∸x+x≡n {suc n} {suc x} (s≤s le) = cong suc (n∸x+x≡n le) toℕx<n : {n : ℕ} {x : Fin n} → Data.Nat._<_ (toℕ x) n toℕx<n {suc n} {zero} = s≤s z≤n toℕx<n {suc n} {suc x} = s≤s toℕx<n n∸x≡suc[n∸sucx] : {n x : ℕ} → Data.Nat._<_ x n → n ∸ x ≡ suc (n ∸ (suc x)) n∸x≡suc[n∸sucx] {suc n} {0} le = refl n∸x≡suc[n∸sucx] {suc n} {suc x} (s≤s le) = n∸x≡suc[n∸sucx] le suc[n+x]≡n+sucx : {n x : ℕ} → suc (n + x) ≡ (n + suc x) suc[n+x]≡n+sucx {0} {x} = refl suc[n+x]≡n+sucx {suc n} {x} = refl suc[n∸sucx+x]≡n : {n x : ℕ} → Data.Nat._<_ x n → suc (n ∸ (suc x) + x) ≡ n suc[n∸sucx+x]≡n {suc n} {0} le = refl suc[n∸sucx+x]≡n {suc n} {suc x} (s≤s le) = cong suc (suc[n∸sucx+x]≡n {n} {x} le) suc[n∸suc[toℕi]+toℕi]≡n : {n : ℕ} {i : Fin n} → suc (n ∸ (suc (toℕ i)) + toℕ i) ≡ n suc[n∸suc[toℕi]+toℕi]≡n {n} {i} = suc[n∸sucx+x]≡n{n}{toℕ i} toℕx<n {-# REWRITE suc[n∸suc[toℕi]+toℕi]≡n #-} m∸toℕ+toℕ≡m : {n : ℕ} {i : Fin (suc n)} → n ∸ (toℕ i) + (toℕ i) ≡ n m∸toℕ+toℕ≡m {n} {i} = m∸n+n≡m{n}{toℕ i} toℕx≤n' {-# REWRITE m∸toℕ+toℕ≡m #-} <suc : {n x : ℕ} → Data.Nat._<_ x n → Data.Nat._<_ x (suc n) <suc {suc n} {0} le = s≤s z≤n <suc {suc n} {suc x} (s≤s le) = s≤s (<suc {n} {x} le) ≤suc : {n x : ℕ} → Data.Nat._≤_ x n → Data.Nat._≤_ x (suc n) ≤suc {n} {0} le = z≤n ≤suc {suc n} {suc x} (s≤s le) = s≤s (≤suc {n} {x} le) ---------------------------------------------------------------------- module IND where mutual data Type (n : ℕ) : Set where TUnit TInt : Type n TPair : Type n → Type n → Type n TChan : SType n → Type n data SType (n : ℕ) : Set where gdd : (gst : GType n) → SType n rec : (gst : GType (suc n)) → SType n var : (x : Fin n) → SType n data GType (n : ℕ) : Set where transmit : (d : Dir) (t : Type n) (s : SType n) → GType n choice : (d : Dir) (m : ℕ) (alt : Fin m → SType n) → GType n end : GType n data MClType (n : ℕ) : Set where MClTUnit MClTInt : MClType n MClTPair : MClType n → MClType n → MClType n MClTChan : SType 0 → MClType n data MClSType (n : ℕ) : Set where tgdd : (tgst : MClGType n) → MClSType n trec : (tgst : MClGType (suc n)) → MClSType n tvar : (x : Fin n) → MClSType n data MClGType (n : ℕ) : Set where ttransmit : (d : Dir) (t : MClType n) (s : MClSType n) → MClGType n tchoice : (d : Dir) (m : ℕ) (alt : Fin m → MClSType n) → MClGType n end : MClGType n ---------------------------------------------------------------------- weaken1'N : Fin (suc n) → Fin n → Fin (suc n) weaken1'N zero x = suc x weaken1'N (suc i) zero = zero weaken1'N (suc i) (suc x) = suc (weaken1'N i x) weaken1'S : Fin (suc n) → SType n → SType (suc n) weaken1'G : Fin (suc n) → GType n → GType (suc n) weaken1'T : Fin (suc n) → Type n → Type (suc n) weaken1'S i (gdd gst) = gdd (weaken1'G i gst) weaken1'S i (rec gst) = rec (weaken1'G (suc i) gst) weaken1'S i (var x) = var (weaken1'N i x) weaken1'G i (transmit d t s) = transmit d (weaken1'T i t) (weaken1'S i s) weaken1'G i (choice d m alt) = choice d m (weaken1'S i ∘ alt) weaken1'G i end = end weaken1'T i TUnit = TUnit weaken1'T i TInt = TInt weaken1'T i (TPair t₁ t₂) = TPair (weaken1'T i t₁) (weaken1'T i t₂) weaken1'T i (TChan x) = TChan (weaken1'S i x) weaken1S : SType n → SType (suc n) weaken1G : GType n → GType (suc n) weaken1T : Type n → Type (suc n) weaken1S = weaken1'S zero weaken1G = weaken1'G zero weaken1T = weaken1'T zero weakenS : (n : ℕ) → SType m → SType (m + n) weakenG : (n : ℕ) → GType m → GType (m + n) weakenT : (n : ℕ) → Type m → Type (m + n) weakenS n (gdd gst) = gdd (weakenG n gst) weakenS n (rec gst) = rec (weakenG n gst) weakenS n (var x) = var (inject+ n x) weakenG n (transmit d t s) = transmit d (weakenT n t) (weakenS n s) weakenG n (choice d m alt) = choice d m (λ i → weakenS n (alt i)) weakenG n end = end weakenT n TUnit = TUnit weakenT n TInt = TInt weakenT n (TPair ty ty₁) = TPair (weakenT n ty) (weakenT n ty₁) weakenT n (TChan x) = TChan (weakenS n x) ---------------------------------------------------------------------- -- Single substitution with SType 0 st-substS : SType (suc n) → Fin (suc n) → SType 0 → SType n st-substG : GType (suc n) → Fin (suc n) → SType 0 → GType n st-substT : Type (suc n) → Fin (suc n) → SType 0 → Type n st-substS (gdd gst) i st0 = gdd (st-substG gst i st0) st-substS (rec gst) i st0 = rec (st-substG gst (suc i) st0) st-substS {n} (var zero) zero st0 = weakenS n st0 st-substS {suc n} (var zero) (suc i) st0 = var zero st-substS {suc n} (var (suc x)) zero st0 = var x st-substS {suc n} (var (suc x)) (suc i) st0 = weaken1S (st-substS (var x) i st0) st-substG (transmit d t s) i st0 = transmit d (st-substT t i st0) (st-substS s i st0) st-substG (choice d m alt) i st0 = choice d m (λ j → st-substS (alt j) i st0) st-substG end i st0 = end st-substT TUnit i st0 = TUnit st-substT TInt i st0 = TInt st-substT (TPair ty ty₁) i st0 = TPair (st-substT ty i st0) (st-substT ty₁ i st0) st-substT (TChan st) i st0 = TChan (st-substS st i st0) -- Single substitution with SType n st-substS' : Fin (suc n) → SType n → SType (suc n) → SType n st-substG' : Fin (suc n) → SType n → GType (suc n) → GType n st-substT' : Fin (suc n) → SType n → Type (suc n) → Type n st-substS' i st (gdd gst) = gdd (st-substG' i st gst) st-substS' i st (rec gst) = rec (st-substG' (suc i) (weaken1S st) gst) st-substS' i st (var x) with compare x i st-substS' i st (var .(inject least)) | less .i least = var (inject! least) st-substS' .x st (var x) | equal .x = st st-substS' .(inject least) st (var (suc x)) | greater .(suc x) least = var x st-substG' i st (transmit d t s) = transmit d (st-substT' i st t) (st-substS' i st s) st-substG' i st (choice d m alt) = choice d m (λ j → st-substS' i st (alt j)) st-substG' i st end = end st-substT' i st TUnit = TUnit st-substT' i st TInt = TInt st-substT' i st (TPair ty ty₁) = TPair (st-substT' i st ty) (st-substT' i st ty₁) st-substT' i st (TChan s) = TChan (st-substS' i st s) ---------------------------------------------------------------------- ---------------------------------------------------------------------- ---------------------------------------------------------------------- open IND data Stack : ℕ → Set where ε : Stack 0 ⟪_,_⟫ : Stack n → IND.GType (suc n) → Stack (suc n) data StackS : ℕ → Set where ε : StackS 0 ⟪_,_⟫ : StackS n → IND.SType n → StackS (suc n) data StackS0 : ℕ → Set where ε : StackS0 0 ⟪_,_⟫ : StackS0 n → IND.SType 0 → StackS0 (suc n) data StackMCl : ℕ → Set where ε : StackMCl 0 ⟪_,_⟫ : StackMCl n → IND.MClGType (suc n) → StackMCl (suc n) -- Stack of length m starting at arbitrary type size n data Stack' : ℕ → ℕ → Set where ε : Stack' n 0 ⟪_,_⟫ : Stack' n m → IND.GType (suc (n + m)) → Stack' n (suc m) data Stack'S : ℕ → ℕ → Set where ε : Stack'S n 0 ⟪_,_⟫ : Stack'S n m → IND.SType (n + m) → Stack'S n (suc m) data Stack'Sn : ℕ → ℕ → Set where ε : Stack'Sn n 0 ⟪_,_⟫ : Stack'Sn n m → IND.SType n → Stack'Sn n (suc m) get : {n : ℕ} → (i : Fin n) → Stack n → Stack (n ∸ (suc (toℕ i))) × IND.GType (n ∸ (toℕ i)) get {suc n} zero ⟪ σ , x ⟫ = σ , x get {suc n} (suc i) ⟪ σ , x ⟫ = get i σ getS : {n : ℕ} → (i : Fin n) → StackS n → StackS (n ∸ (suc (toℕ i))) × IND.SType (n ∸ (suc (toℕ i))) getS {suc n} zero ⟪ σ , x ⟫ = σ , x getS {suc n} (suc i) ⟪ σ , x ⟫ = getS i σ getS0 : {n : ℕ} → (i : Fin n) → StackS0 n → StackS0 (n ∸ (suc (toℕ i))) × IND.SType 0 getS0 {suc n} zero ⟪ σ , x ⟫ = σ , x getS0 {suc n} (suc i) ⟪ σ , x ⟫ = getS0 i σ getMCl : {n : ℕ} → (i : Fin n) → StackMCl n → StackMCl (n ∸ (suc (toℕ i))) × IND.MClGType (n ∸ (toℕ i)) getMCl {suc n} zero ⟪ σ , x ⟫ = σ , x getMCl {suc n} (suc i) ⟪ σ , x ⟫ = getMCl i σ get' : {n m : ℕ} → (i : Fin m) → Stack' n m → Stack' n (m ∸ (suc (toℕ i))) × IND.GType (n + (m ∸ (toℕ i))) get' {n} {suc m} zero ⟪ σ , x ⟫ = σ , x get' {n} {suc m} (suc i) ⟪ σ , x ⟫ = get' i σ get'S : {n m : ℕ} → (i : Fin m) → Stack'S n m → Stack'S n (m ∸ (suc (toℕ i))) × IND.SType (n + (m ∸ (suc (toℕ i)))) get'S {n} {suc m} zero ⟪ σ , x ⟫ = σ , x get'S {n} {suc m} (suc i) ⟪ σ , x ⟫ = get'S i σ get'Sn : {n m : ℕ} → (i : Fin m) → Stack'Sn n m → Stack'Sn n (m ∸ (suc (toℕ i))) × IND.SType n get'Sn {n} {suc m} zero ⟪ σ , x ⟫ = σ , x get'Sn {n} {suc m} (suc i) ⟪ σ , x ⟫ = get'Sn i σ ---------------------------------------------------------------------- stack-split : (i : Fin (suc n)) → Stack n → Stack (n ∸ toℕ i) × Stack' (n ∸ toℕ i) (toℕ i) stack-split zero σ = σ , ε stack-split{n} (suc i) ⟪ σ , x ⟫ with stack-split i σ ... | σ' , σ'' = σ' , ⟪ σ'' , x ⟫ -- couldn't achieve this by rewriting alone suc[n+[m∸sucx]+x]≡n+m : {n m x : ℕ} → Data.Nat._<_ x m → suc (n + (m ∸ suc x) + x) ≡ n + m suc[n+[m∸sucx]+x]≡n+m {0} {m} {x} le = suc[n∸sucx+x]≡n{m}{x} le suc[n+[m∸sucx]+x]≡n+m {suc n} {suc m} {0} le = refl suc[n+[m∸sucx]+x]≡n+m {suc n} {suc m} {suc x} (s≤s le) = cong suc (cong suc (suc[n+[m∸sucx]+x]≡n+m le)) -- i from the top of the stack stack'-m-i : {n m : ℕ} → (i : Fin m) → Stack' n m → Stack' (n + (m ∸ (toℕ i))) (toℕ i) stack'-m-i {n} {m} zero σ = ε stack'-m-i {n} {suc m} (suc i) ⟪ σ , x ⟫ rewrite (sym (suc[n+[m∸sucx]+x]≡n+m{n}{m}{toℕ i} toℕx<n)) = ⟪ (stack'-m-i i σ) , x ⟫ weaken1-Stack' : (i : Fin (suc n)) → Stack' n m → Stack' (suc n) m weaken1-Stack' i ε = ε weaken1-Stack'{n}{m} i ⟪ σ , x ⟫ = ⟪ (weaken1-Stack' i σ) , (weaken1'G (inject+ m i) x) ⟫ weaken1-Stack'Sn : (i : Fin (suc n)) → Stack'Sn n m → Stack'Sn (suc n) m weaken1-Stack'Sn i ε = ε weaken1-Stack'Sn{n}{m} i ⟪ σ , x ⟫ = ⟪ (weaken1-Stack'Sn i σ) , (weaken1'S i x) ⟫ -- substitute after index i, required for rec case stack-sim-substS-i> : (i : Fin n) → StackS0 (n ∸ (toℕ (suc i))) → SType n → SType (toℕ (suc i)) stack-sim-substG-i> : (i : Fin n) → StackS0 (n ∸ (toℕ (suc i))) → GType n → GType (toℕ (suc i)) stack-sim-substT-i> : (i : Fin n) → StackS0 (n ∸ (toℕ (suc i))) → Type n → Type (toℕ (suc i)) stack-sim-substS-i> i σ (gdd gst) = gdd (stack-sim-substG-i> i σ gst) stack-sim-substS-i> i σ (rec gst) = rec (stack-sim-substG-i> (suc i) σ gst) stack-sim-substS-i>{suc n} zero σ (var zero) = var zero stack-sim-substS-i> zero σ (var (suc x)) with getS0 x σ ... | σ' , s = weaken1S s stack-sim-substS-i> (suc i) σ (var zero) = var zero stack-sim-substS-i> (suc i) σ (var (suc x)) = weaken1S (stack-sim-substS-i> i σ (var x)) stack-sim-substG-i> i σ (transmit d t s) = transmit d (stack-sim-substT-i> i σ t) (stack-sim-substS-i> i σ s) stack-sim-substG-i> i σ (choice d m alt) = choice d m (λ x → stack-sim-substS-i> i σ (alt x)) stack-sim-substG-i> i σ end = end stack-sim-substT-i> i σ TUnit = TUnit stack-sim-substT-i> i σ TInt = TInt stack-sim-substT-i> i σ (TPair t t₁) = TPair (stack-sim-substT-i> i σ t) (stack-sim-substT-i> i σ t₁) stack-sim-substT-i> i σ (TChan x) = TChan (stack-sim-substS-i> i σ x) -- substitute stack stack-sim-substS : StackS0 n → SType n → SType 0 stack-sim-substG : StackS0 n → GType n → GType 0 stack-sim-substT : StackS0 n → Type n → Type 0 stack-sim-substS σ (gdd gst) = gdd (stack-sim-substG σ gst) stack-sim-substS σ (rec gst) = rec (stack-sim-substG-i> zero σ gst) -- Apply stack substitution to variables 1, ..., suc n; keep 0F; can't extend StackS0 since only SType 0F allowed stack-sim-substS σ (var x) with getS0 x σ ... | σ' , s = s stack-sim-substG σ (transmit d t s) = transmit d (stack-sim-substT σ t) (stack-sim-substS σ s) stack-sim-substG σ (choice d m alt) = choice d m (λ x → stack-sim-substS σ (alt x)) stack-sim-substG σ end = end stack-sim-substT σ TUnit = TUnit stack-sim-substT σ TInt = TInt stack-sim-substT σ (TPair t t₁) = TPair (stack-sim-substT σ t) (stack-sim-substT σ t₁) stack-sim-substT σ (TChan x) = TChan (stack-sim-substS σ x) stack-sim-substS'-i≥ : (i : Fin (suc m)) → Stack'Sn n (m ∸ toℕ i) → SType m → SType (n + toℕ i) stack-sim-substG'-i≥ : (i : Fin (suc m)) → Stack'Sn n (m ∸ toℕ i) → GType m → GType (n + toℕ i) stack-sim-substT'-i≥ : (i : Fin (suc m)) → Stack'Sn n (m ∸ toℕ i) → Type m → Type (n + toℕ i) stack-sim-substS'-i≥ i σ (gdd gst) = gdd (stack-sim-substG'-i≥ i σ gst) stack-sim-substS'-i≥ i σ (rec gst) = rec (stack-sim-substG'-i≥ (suc i) σ gst) stack-sim-substS'-i≥ zero σ (var x) with get'Sn x σ ... | σ' , y = y stack-sim-substS'-i≥ (suc i) σ (var zero) = var zero stack-sim-substS'-i≥ (suc i) σ (var (suc x)) = weaken1S (stack-sim-substS'-i≥ i σ (var x)) stack-sim-substG'-i≥ i σ (transmit d t s) = transmit d (stack-sim-substT'-i≥ i σ t) (stack-sim-substS'-i≥ i σ s) stack-sim-substG'-i≥ i σ (choice d m alt) = choice d m (λ x → stack-sim-substS'-i≥ i σ (alt x)) stack-sim-substG'-i≥ i σ end = end stack-sim-substT'-i≥ i σ TUnit = TUnit stack-sim-substT'-i≥ i σ TInt = TInt stack-sim-substT'-i≥ i σ (TPair t t₁) = TPair (stack-sim-substT'-i≥ i σ t) (stack-sim-substT'-i≥ i σ t₁) stack-sim-substT'-i≥ i σ (TChan x) = TChan (stack-sim-substS'-i≥ i σ x) -- substitute stack' stack-sim-substS' : Stack'Sn n m → SType m → SType n stack-sim-substG' : Stack'Sn n m → GType m → GType n stack-sim-substT' : Stack'Sn n m → Type m → Type n stack-sim-substS' σ (gdd gst) = gdd (stack-sim-substG' σ gst) stack-sim-substS'{n}{m} σ (rec gst) = rec (stack-sim-substG'-i≥ (suc zero) σ gst) stack-sim-substS' σ (var x) with get'Sn x σ ... | σ' , s = s stack-sim-substG' σ (transmit d t s) = transmit d (stack-sim-substT' σ t) (stack-sim-substS' σ s) stack-sim-substG' σ (choice d m alt) = choice d m (λ x → stack-sim-substS' σ (alt x)) stack-sim-substG' σ end = end stack-sim-substT' σ TUnit = TUnit stack-sim-substT' σ TInt = TInt stack-sim-substT' σ (TPair t t₁) = TPair (stack-sim-substT' σ t) (stack-sim-substT' σ t₁) stack-sim-substT' σ (TChan x) = TChan (stack-sim-substS' σ x) {- required for alt. def. of rec case of stack-sim-substS'-top stack-sim-substS'-top-i≥ : (i : Fin (suc m)) → Stack'Sn n (m ∸ toℕ i) → SType (n + m) → SType (n + toℕ i) stack-sim-substG'-top-i≥ : (i : Fin (suc m)) → Stack'Sn n (m ∸ toℕ i) → GType (n + m) → GType (n + toℕ i) stack-sim-substT'-top-i≥ : (i : Fin (suc m)) → Stack'Sn n (m ∸ toℕ i) → Type (n + m) → Type (n + toℕ i) stack-sim-substS'-top-i≥ i σ (gdd gst) = {!!} stack-sim-substS'-top-i≥ i σ (rec gst) = rec (stack-sim-substG'-top-i≥ (suc i) σ gst) stack-sim-substS'-top-i≥ i σ (var x) = {!!} stack-sim-substS'-top-i≥' : (i : Fin (suc m)) → Stack'Sn (n + toℕ i) (toℕ i) → SType (n + m) → SType (n + m ∸ toℕ i) stack-sim-substG'-top-i≥' : (i : Fin (suc m)) → Stack'Sn (n + toℕ i) (toℕ i) → GType (n + m) → GType (n + m ∸ toℕ i) stack-sim-substS'-top-i≥'{m = m}{n = suc n} i σ (rec gst) = rec (stack-sim-substG'-top-i≥' {!!} {!!} gst) -} -- substitute top variables from stack' stack-sim-substS'-top : Stack'Sn n m → SType (n + m) → SType n stack-sim-substG'-top : Stack'Sn n m → GType (n + m) → GType n stack-sim-substT'-top : Stack'Sn n m → Type (n + m) → Type n stack-sim-substS'-top σ (gdd gst) = gdd (stack-sim-substG'-top σ gst) stack-sim-substS'-top{n}{m} σ (rec gst) = rec (stack-sim-substG'-top{m = m} (weaken1-Stack'Sn zero σ) gst) -- alternative: rec (stack-sim-substG'-top-i≥ 1 σ gst) stack-sim-substS'-top{n}{m} σ (var x) = {!!} -- <= n => var n, > n => substitute -- Transform Stack of STypes to Stack of closed STypes by substitution -- ⟪ ε , SType 0 , SType 1 , SType 2 , ⋯ ⟫ -- ⟪ ε , SType 0 , SType 1 [0 ↦ SType 0], SType 2 [0 ↦ SType 0, 1 ↦ SType 1 [0 ↦ SType 0]], ⋯ ⟫ -- ⟪ ε , SType 0 , SType 0 , SType 0 , ⋯ ⟫ stack-transform : StackS n → StackS0 n stack-transform ε = ε stack-transform ⟪ σ , x ⟫ with stack-transform σ ... | σ' = ⟪ σ' , (stack-sim-substS σ' x) ⟫ stack-transform' : Stack'S n m → Stack'Sn n m stack-transform' ε = ε stack-transform'{n} ⟪ σ , x ⟫ with stack-transform' σ ... | σ' = ⟪ σ' , stack-sim-substS'-top σ' x ⟫ stack-cat : Stack n → Stack' n m → Stack (n + m) stack-cat σ ε = σ stack-cat σ ⟪ σ' , x ⟫ = ⟪ (stack-cat σ σ') , x ⟫ stack-cat' : Stack' 0 n → Stack' n m → Stack' 0 (n + m) stack-cat' σ ε = σ stack-cat' σ ⟪ σ' , x ⟫ = ⟪ (stack-cat' σ σ') , x ⟫ stack-sim-substS-refl : (s : SType 0) → stack-sim-substS ε s ≡ s stack-sim-substG-refl : (g : GType 0) → stack-sim-substG ε g ≡ g stack-sim-substT-refl : (t : Type 0) → stack-sim-substT ε t ≡ t stack-sim-substS-refl (gdd gst) = cong gdd (stack-sim-substG-refl gst) stack-sim-substS-refl (rec gst) = {!!} -- requires stack-sim-substG-i>-refl stack-sim-substG-refl (transmit d t s) = cong₂ (transmit d) (stack-sim-substT-refl t) (stack-sim-substS-refl s) stack-sim-substG-refl (choice d m alt) = cong (choice d m) (ext (λ x → stack-sim-substS-refl (alt x))) stack-sim-substG-refl end = refl stack-sim-substT-refl TUnit = refl stack-sim-substT-refl TInt = refl stack-sim-substT-refl (TPair t t₁) = cong₂ TPair (stack-sim-substT-refl t) (stack-sim-substT-refl t₁) stack-sim-substT-refl (TChan x) = cong TChan (stack-sim-substS-refl x) ---------------------------------------------------------------------- -- Message closure mclS : (σ : StackS n) → SType n → MClSType n mclG : (σ : StackS n) → GType n → MClGType n mclT : (σ : StackS n) → Type n → MClType n mclS σ (gdd gst) = tgdd (mclG σ gst) mclS σ (rec gst) = trec (mclG ⟪ σ , (rec gst) ⟫ gst) mclS σ (var x) = tvar x mclG σ (transmit d t s) = ttransmit d (mclT σ t) (mclS σ s) mclG σ (choice d m alt) = tchoice d m (λ x → mclS σ (alt x)) mclG σ end = end mclT σ TUnit = MClTUnit mclT σ TInt = MClTInt mclT σ (TPair t t₁) = MClTPair (mclT σ t) (mclT σ t₁) mclT σ (TChan x) = MClTChan (stack-sim-substS (stack-transform σ) x) ---------------------------------------------------------------------- -- Any mcl type is a normal type with weakening mcl2indS : MClSType n → SType n mcl2indG : MClGType n → GType n mcl2indT : MClType n → Type n mcl2indS (tgdd tgst) = gdd (mcl2indG tgst) mcl2indS (trec tgst) = rec (mcl2indG tgst) mcl2indS (tvar x) = var x mcl2indG (ttransmit d t s) = transmit d (mcl2indT t) (mcl2indS s) mcl2indG (tchoice d m alt) = choice d m (λ x → mcl2indS (alt x)) mcl2indG end = end mcl2indT MClTUnit = TUnit mcl2indT MClTInt = TInt mcl2indT (MClTPair t t₁) = TPair (mcl2indT t) (mcl2indT t₁) mcl2indT{n} (MClTChan x) = TChan (weakenS n x) ---------------------------------------------------------------------- stack2StackS : Stack n → StackS n stack2StackS ε = ε stack2StackS ⟪ σ , x ⟫ = ⟪ (stack2StackS σ) , (rec x) ⟫ stackMCl2Stack : StackMCl n → Stack n stackMCl2Stack ε = ε stackMCl2Stack ⟪ σ , x ⟫ = ⟪ (stackMCl2Stack σ) , (mcl2indG x) ⟫ stackMCl2StackS : StackMCl n → StackS n stackMCl2StackS ε = ε stackMCl2StackS ⟪ σ , x ⟫ = ⟪ (stackMCl2StackS σ) , (rec (mcl2indG x)) ⟫ stack2StackMCl : Stack n → StackMCl n stack2StackMCl ε = ε stack2StackMCl ⟪ σ , x ⟫ = ⟪ (stack2StackMCl σ) , (mclG ⟪ stack2StackS σ , rec x ⟫ x) ⟫ stack2Stack' : Stack n → Stack' 0 n stack2Stack' ε = ε stack2Stack' ⟪ σ , x ⟫ = ⟪ stack2Stack' σ , x ⟫ stack'2Stack : Stack' 0 n → Stack n stack'2Stack ε = ε stack'2Stack ⟪ σ , x ⟫ = ⟪ stack'2Stack σ , x ⟫ stack'2Stack'S : Stack' n m → Stack'S n m stack'2Stack'S ε = ε stack'2Stack'S ⟪ σ , x ⟫ = ⟪ (stack'2Stack'S σ) , (rec x) ⟫ stack-stack'-refl : (σ : Stack n) → (stack'2Stack (stack2Stack' σ)) ≡ σ stack-stack'-refl ε = refl stack-stack'-refl ⟪ σ , x ⟫ rewrite (stack-stack'-refl σ) = refl {-# REWRITE stack-stack'-refl #-} ---------------------------------------------------------------------- naive-dualS : SType n → SType n naive-dualG : GType n → GType n naive-dualT : Type n → Type n naive-dualS (gdd gst) = gdd (naive-dualG gst) naive-dualS (rec gst) = rec (naive-dualG gst) naive-dualS (var x) = var x naive-dualG (transmit d t s) = transmit (dual-dir d) (naive-dualT t) (naive-dualS s) naive-dualG (choice d m alt) = choice (dual-dir d) m (λ x → naive-dualS (alt x)) naive-dualG end = end naive-dualT TUnit = TUnit naive-dualT TInt = TInt naive-dualT (TPair t t₁) = TPair (naive-dualT t) (naive-dualT t₁) naive-dualT (TChan x) = TChan (naive-dualS x) naive-dualSt : MClSType n → MClSType n naive-dualGt : MClGType n → MClGType n naive-dualTt : MClType n → MClType n naive-dualSt (tgdd tgst) = tgdd (naive-dualGt tgst) naive-dualSt (trec tgst) = trec (naive-dualGt tgst) naive-dualSt (tvar x) = tvar x naive-dualGt (ttransmit d t s) = ttransmit (dual-dir d) (naive-dualTt t) (naive-dualSt s) naive-dualGt (tchoice d m alt) = tchoice (dual-dir d) m (λ x → naive-dualSt (alt x)) naive-dualGt end = end naive-dualTt MClTUnit = MClTUnit naive-dualTt MClTInt = MClTInt naive-dualTt (MClTPair t t₁) = MClTPair (naive-dualTt t) (naive-dualTt t₁) naive-dualTt (MClTChan x) = MClTChan (naive-dualS x) ---------------------------------------------------------------------- dualS : (σ : StackS n) → SType n → MClSType n dualG : (σ : StackS n) → GType n → MClGType n dualT : (σ : StackS n) → Type n → MClType n dualS σ (gdd gst) = tgdd (dualG σ gst) dualS σ (rec gst) = trec (dualG ⟪ σ , (rec gst) ⟫ gst) dualS σ (var x) = (tvar x) dualG{n} σ (transmit d t s) = ttransmit (dual-dir d) (dualT σ t) (dualS σ s) dualG σ (choice d m alt) = tchoice (dual-dir d) m ((dualS σ) ∘ alt) dualG σ end = end dualT σ TUnit = MClTUnit dualT σ TInt = MClTInt dualT σ (TPair t t₁) = MClTPair (dualT σ t) (dualT σ t₁) dualT σ (TChan x) = MClTChan (stack-sim-substS (stack-transform σ) x) module sanity-check where -- μx.!x.x → μx.?(μx.!x.x).x S : SType 0 S = rec (transmit SND (TChan (var zero)) (var zero)) DS = rec (transmit RCV (weaken1T (TChan S)) (var zero)) _ : mclS ε DS ≡ dualS ε S _ = refl -- μx.!x.!x.x → μx.?(μx.!x.!x.x).?(μx.!x.!x.x).x S' : SType 0 S' = rec (transmit SND (TChan (var zero)) (gdd ((transmit SND (TChan (var zero)) (var zero))))) DS' = rec (transmit RCV (weaken1T (TChan S')) (gdd ((transmit RCV (weaken1T (TChan S')) (var zero))))) _ : mclS ε DS' ≡ dualS ε S' _ = refl -- μx.!x.(μy.!y.y) → μx.?(μx.!x.(μy.!y.y)).(μy.?(μy.!y.y).y) S'' : SType 0 S'' = rec (transmit SND (TChan (var zero)) (rec (transmit SND (TChan (var zero)) (var zero)))) DS'' = rec (transmit RCV (weaken1T (TChan S'')) (weaken1S DS)) _ : mclS ε DS'' ≡ dualS ε S'' _ = refl ---------------------------------------------------------------------- open import DualCoinductive hiding (n ; m) _≈_ = COI._≈_ _≈'_ = COI._≈'_ _≈ᵗ_ = COI._≈ᵗ_ -- IND to Coinductive using two stacks -- e.g. i = 0 => σ -- i = 1 => σ , g -- g = get σ' 0 -- i = 2F => σ , g' , g -- g = get σ' 0; g' = get σ' 1 -- i = n => σ' ind2coiS' : (i : Fin (suc n)) → Stack (n ∸ toℕ i) → Stack' (n ∸ toℕ i) (toℕ i) → IND.SType n → COI.SType ind2coiG' : (i : Fin (suc n)) → Stack (n ∸ toℕ i) → Stack' (n ∸ toℕ i) (toℕ i) → IND.GType n → COI.STypeF COI.SType ind2coiT' : (i : Fin (suc n)) → Stack (n ∸ toℕ i) → Stack' (n ∸ toℕ i) (toℕ i) → IND.Type n → COI.Type COI.SType.force (ind2coiS' i σ σ' (gdd gst)) = ind2coiG' i σ σ' gst COI.SType.force (ind2coiS'{n} i σ σ' (rec gst)) = ind2coiG' (suc i) σ ⟪ σ' , gst ⟫ gst COI.SType.force (ind2coiS' i σ σ' (var x)) = {!!} -- IND to Coinductive ind2coiS : Stack n → IND.SType n → COI.SType ind2coiG : Stack n → IND.GType n → COI.STypeF COI.SType ind2coiT : Stack n → IND.Type n → COI.Type ind2coiT σ TUnit = COI.TUnit ind2coiT σ TInt = COI.TInt ind2coiT σ (TPair t t₁) = COI.TPair (ind2coiT σ t) (ind2coiT σ t₁) ind2coiT σ (TChan x) = COI.TChan (ind2coiS σ x) COI.SType.force (ind2coiS σ (gdd gst)) = ind2coiG σ gst COI.SType.force (ind2coiS σ (rec gst)) = ind2coiG ⟪ σ , gst ⟫ gst COI.SType.force (ind2coiS{n} σ (var x)) with get x σ ... | σ' , gxs rewrite (n∸x≡suc[n∸sucx]{n}{toℕ x} toℕx<n) = ind2coiG ⟪ σ' , gxs ⟫ gxs ind2coiG σ (transmit d t s) = COI.transmit d (ind2coiT σ t) (ind2coiS σ s) ind2coiG σ (choice d m alt) = COI.choice d m (λ x → ind2coiS σ (alt x)) ind2coiG σ end = COI.end -- IND to Coinductive using StackS0 ind2coiS'' : StackS0 n → IND.SType n → COI.SType ind2coiG'' : StackS0 n → IND.GType n → COI.STypeF COI.SType COI.SType.force (ind2coiS'' σ (gdd gst)) = ind2coiG'' σ gst COI.SType.force (ind2coiS''{n} σ (rec gst)) = ind2coiG''{suc n} ⟪ σ , stack-sim-substS σ (rec gst) ⟫ gst ind2coiS'' σ (var x) with getS0 x σ ... | σ' , gxs = ind2coiS'' ε gxs -- Equivalence of IND to COI with one stack and IND to COI with two stacks ind2coiS≈ind2coiS' : (σ : Stack' 0 n) (s : IND.SType n) → ind2coiS' (fromℕ n) ε σ s ≈ ind2coiS (stack'2Stack σ) s ind2coiG≈ind2coiG' : (σ : Stack' 0 n) (g : IND.GType n) → ind2coiG' (fromℕ n) ε σ g ≈' ind2coiG (stack'2Stack σ) g COI.Equiv.force (ind2coiS≈ind2coiS' σ (gdd gst)) = ind2coiG≈ind2coiG' σ gst COI.Equiv.force (ind2coiS≈ind2coiS'{n} σ (rec gst)) = ind2coiG≈ind2coiG'{suc n} ⟪ σ , gst ⟫ gst COI.Equiv.force (ind2coiS≈ind2coiS' σ (var x)) = {!!} -- Message closure to Coinductive mcl2coiT : StackMCl n → MClType n → COI.Type mcl2coiS : StackMCl n → MClSType n → COI.SType mcl2coiG : StackMCl n → MClGType n → COI.STypeF COI.SType mcl2coiT σ MClTUnit = COI.TUnit mcl2coiT σ MClTInt = COI.TInt mcl2coiT σ (MClTPair t t₁) = COI.TPair (mcl2coiT σ t) (mcl2coiT σ t₁) mcl2coiT σ (MClTChan s) = COI.TChan (ind2coiS ε s) COI.SType.force (mcl2coiS σ (tgdd g)) = mcl2coiG σ g COI.SType.force (mcl2coiS σ (trec g)) = mcl2coiG ⟪ σ , g ⟫ g COI.SType.force (mcl2coiS{n} σ (tvar x)) with getMCl x σ ... | σ' , gxs rewrite (n∸x≡suc[n∸sucx]{n}{toℕ x} toℕx<n) = mcl2coiG ⟪ σ' , gxs ⟫ gxs mcl2coiG σ (ttransmit d t s) = COI.transmit d (mcl2coiT σ t) (mcl2coiS σ s) mcl2coiG σ (tchoice d m alt) = COI.choice d m (mcl2coiS σ ∘ alt) mcl2coiG σ end = COI.end ---------------------------------------------------------------------- -- lemm 1 -- stack-sim-substS (stack-transform ⟪ stack2StackS σ , (rec x) ⟫) s ≡ stack-sim-substS (stack-transform (stack2StackS σ)) (st-substS' 0 (rec x) s) -- lemm 2 -- ind2coiS ⟪ σ , x ⟫ s ≈ ind2coiS σ (st-substS' 0 (rec x) s) -- unfolding vs single substitution ind2coi-substS : (σ : Stack n) (g : GType (suc n)) (s : SType (suc n)) → ind2coiS ⟪ σ , g ⟫ s ≈ ind2coiS σ (st-substS' zero (rec g) s) ind2coi-substG : (σ : Stack n) (g : GType (suc n)) (g' : GType (suc n)) → ind2coiG ⟪ σ , g ⟫ g' ≈' ind2coiG σ (st-substG' zero (rec g) g') COI.Equiv.force (ind2coi-substS σ g (gdd gst)) = ind2coi-substG σ g gst COI.Equiv.force (ind2coi-substS σ g (rec gst)) = {!!} -- the following line for rec-case is a contradiction for gst = transmit d t (var 1) -- COI.≈'-trans (COI.≈'-trans (ind2coi-substG ⟪ σ , g ⟫ gst gst) (ind2coi-substG σ g (st-substG' 0 (rec gst) gst))) (COI.≈'-trans {!!} (COI.≈'-symm (ind2coi-substG σ (st-substG' 1 (weaken1S (rec g)) gst) (st-substG' 1 (weaken1S (rec g)) gst)))) COI.Equiv.force (ind2coi-substS σ g (var zero)) = COI.≈'-refl COI.Equiv.force (ind2coi-substS {n} σ g (var (suc x))) = {!!} ind2coi-substG σ g (transmit d t s) = COI.eq-transmit d {!!} (ind2coi-substS σ g s) ind2coi-substG σ g (choice d m alt) = COI.eq-choice d λ i → ind2coi-substS σ g (alt i) ind2coi-substG σ g end = COI.eq-end -- unfolding vs simultaneous substitution: special, needed case st-unfold : {n : ℕ} (σ : Stack n) (s : IND.SType n) → ind2coiS ε (stack-sim-substS (stack-transform (stack2StackS σ)) s) ≈ ind2coiS σ s st-unfold {0} ε s rewrite (stack-sim-substS-refl s) = COI.≈-refl st-unfold {suc n} ⟪ σ , x ⟫ s = {!st-unfold σ (st-substS' 0 (rec x) s)!} -- provable if lemm 1 & lemm 2 hold -- unfolding vs simultaneous substitution: general case stack-unfoldS : (σ : Stack n) (σ' : Stack' n m) (s : IND.SType (n + m)) → ind2coiS σ (stack-sim-substS'-top (stack-transform' (stack'2Stack'S σ')) s) ≈ ind2coiS (stack-cat σ σ') s COI.Equiv.force (stack-unfoldS {n} σ σ' (gdd gst)) = {!!} COI.Equiv.force (stack-unfoldS σ σ' (rec gst)) = {!!} COI.Equiv.force (stack-unfoldS {n} σ σ' (var x)) = {!!} -- unfolding vs simultaneous substition: general case w/ alt. def. for ind2coiS stack-unfoldS' : (i : Fin (suc n)) (σ : Stack (n ∸ toℕ i)) (σ' : Stack' (n ∸ toℕ i) (toℕ i)) (s : IND.SType n) → ind2coiS σ (stack-sim-substS'-top (stack-transform' (stack'2Stack'S σ')) s) ≈ ind2coiS' i σ σ' s COI.Equiv.force (stack-unfoldS' i σ σ' (gdd gst)) = {!!} COI.Equiv.force (stack-unfoldS' i σ σ' (rec gst)) = {!!} -- req. first lemma from graveyard of lemmas COI.Equiv.force (stack-unfoldS' i σ σ' (var x)) = {!!} ---------------------------------------------------------------------- -- proof idea for var case: -- mcl2coiS (stack2StackMCl σ) (tvar x) -------- getMCl x (stack2StackMCl σ) = σ' , g -- => mcl2coiG ⟪ σ' , g ⟫ g -------- getMCl x (stack2StackMCl σ) = (stack2StackMCl (get x σ).1 , mclG ⟪ stack2StackS (get x σ).1 , rec (get x σ).2 ⟫ (get x σ).2 -- => mcl2coiG ⟪ (stack2StackMCl (get x σ).1 , mclG ⟪ stack2StackS (get x σ).1 , rec (get x σ).2 ⟫ (get x σ).2 ⟫ (mclG ⟪ stack2StackS (get x σ).1 , rec (get x σ).2 ⟫ (get x σ).2) ------- which by definition of stack2StackMCl and stack2StackS is equivalent to -- = mcl2coiG (stack2StackMCl ⟪ (get x σ).1 , (get x σ).2 ⟫) (mclG (stack2StackS ⟪ (get x σ).1 , (get x σ).2 ⟫) g) ------- which, by mcl-equiv-G -- ≈' ind2coiG ⟪ (get x σ).1 , (get x σ).2 ⟫ (get x σ).2 -- = ind2coiG σ (var x) getMCl-get : (x : Fin n) (σ : Stack n) → getMCl x (stack2StackMCl σ) ≡ (stack2StackMCl (proj₁ (get x σ)) , mclG ⟪ stack2StackS (proj₁ (get x σ)) , rec (proj₂ (get x σ)) ⟫ (proj₂ (get x σ))) getMCl-get zero ⟪ σ , x ⟫ = refl getMCl-get (suc x) ⟪ σ , x₁ ⟫ = getMCl-get x σ ---------------------------------------------------------------------- mcl-equiv-S : (σ : Stack n) (s : IND.SType n) → mcl2coiS (stack2StackMCl σ) (mclS (stack2StackS σ) s) ≈ ind2coiS σ s mcl-equiv-G : (σ : Stack n) (g : IND.GType n) → mcl2coiG (stack2StackMCl σ) (mclG (stack2StackS σ) g) ≈' ind2coiG σ g mcl-equiv-T : (σ : Stack n) (t : IND.Type n) → mcl2coiT (stack2StackMCl σ) (mclT (stack2StackS σ) t) ≈ᵗ ind2coiT σ t COI.Equiv.force (mcl-equiv-S σ (gdd gst)) = mcl-equiv-G σ gst COI.Equiv.force (mcl-equiv-S σ (rec gst)) = mcl-equiv-G ⟪ σ , gst ⟫ gst COI.Equiv.force (mcl-equiv-S{n} σ (var x)) rewrite (getMCl-get x σ) with (proj₁ (get x σ)) | (proj₂ (get x σ)) ... | σ' | g rewrite (n∸x≡suc[n∸sucx]{n}{toℕ x} toℕx<n) = mcl-equiv-G ⟪ σ' , g ⟫ g mcl-equiv-G σ (transmit d t s) = COI.eq-transmit d (mcl-equiv-T σ t) (mcl-equiv-S σ s) mcl-equiv-G σ (choice d m alt) = COI.eq-choice d (λ i → mcl-equiv-S σ (alt i)) mcl-equiv-G σ end = COI.eq-end mcl-equiv-T σ TUnit = COI.eq-unit mcl-equiv-T σ TInt = COI.eq-int mcl-equiv-T σ (TPair t t₁) = COI.eq-pair (mcl-equiv-T σ t) (mcl-equiv-T σ t₁) mcl-equiv-T {n} σ (TChan x) = COI.eq-chan {!!} σ : Stack 1 σ = ⟪ ε , end ⟫ g : GType 2 g = transmit SND TInt (var (suc zero)) s : COI.SType s = ind2coiS σ (rec g) s' : COI.SType s' = ind2coiS ε (stack-sim-substS (stack-transform (stack2StackS σ)) (rec g)) s≈s' : s ≈ s' COI.Equiv.force s≈s' = COI.eq-transmit SND COI.eq-int (record { force = COI.eq-end }) -- naive-mcl-dual : (σ : StackMCl n) (s : IND.SType n) → -- mcl2coiS σ (naive-dualSt (mclS (stackTail2StackS σ) s)) ≈ mcl2coiS σ (dualS (stackTail2StackS σ) s) {- graveyard of attempted lemmas -- idea: "move" a substitution that is done at stack unfolding to a simultaneous subtitution before unfolding -- problem: cannot formulate this for SType since Stack requires a GType stack-unfold-lemmaG : {m n : ℕ} (σ : Stack n) (σ' : Stack' n m) (g : GType (suc (n + m))) → ind2coiG ⟪ σ , stack-sim-substG'-top (weaken1-Stack'Sn 0 (stack-transform' (stack'2Stack'S σ'))) g ⟫ (stack-sim-substG'-top (weaken1-Stack'Sn 0 (stack-transform' (stack'2Stack'S σ'))) g) ≈' ind2coiG σ (stack-sim-substG'-top (stack-transform' (stack'2Stack'S ⟪ σ' , g ⟫)) g) stack-unfold-lemmaG {m} {n} σ σ' (transmit d t s) = {!!} stack-unfold-lemmaG {m} {n} σ σ' (choice d m₁ alt) = {!!} stack-unfold-lemmaG {m} {n} σ σ' end = {!!} ------------------------------------------------------------ -- won't work for the same reason as below stack-unfoldS-i : (i : Fin n) (σ : Stack n) (s : IND.SType (suc (n ∸ suc (toℕ i) + toℕ i))) → ind2coiS (proj₁ (stack-split i σ)) (stack-sim-substS'-top (stack-transform' (stack'2Stack'S (proj₂ (stack-split i σ)))) s) ≈ ind2coiS σ (rewrfixS{n}{i} s) stack-unfoldG-i : (i : Fin n) (σ : Stack n) (g : IND.GType (suc (n ∸ suc (toℕ i) + toℕ i))) → ind2coiG (proj₁ (stack-split i σ)) (stack-sim-substG'-top (stack-transform' (stack'2Stack'S (proj₂ (stack-split i σ)))) g) ≈' ind2coiG σ (rewrfixG{n}{i} g) COI.Equiv.force (stack-unfoldS-i i σ (gdd gst)) = {!!} COI.Equiv.force (stack-unfoldS-i{n} i σ (rec gst)) = {!stack-unfoldG-i (suc i) ? gst!} COI.Equiv.force (stack-unfoldS-i i σ (var x)) = {!!} -- won't work. rec case adds something to σ on the left side, but something at the end of (stack-cat σ σ') on the right side. stack-unfoldS' : (σ : Stack n) (σ' : Stack' n m) (s : IND.SType (n + m)) → ind2coiS σ (stack-sim-substS'-top (stack-transform' (stack'2Stack'S σ')) s) ≈ ind2coiS (stack-cat σ σ') s stack-unfoldG' : (σ : Stack n) (σ' : Stack' n m) (g : IND.GType (n + m)) → ind2coiG σ (stack-sim-substG'-top (stack-transform' (stack'2Stack'S σ')) g) ≈' ind2coiG (stack-cat σ σ') g COI.Equiv.force (stack-unfoldS' σ σ' (gdd gst)) = {!!} COI.Equiv.force (stack-unfoldS'{n}{m} σ σ' (rec gst)) = {!!} -- {!stack-unfoldG'{suc n}{m} ⟪ σ , stack-sim-substG'-top-i≥ 1 (stack-transform' (stack'2Stack'S σ')) gst ⟫ (weaken1-Stack' 0 σ') gst!} COI.Equiv.force (stack-unfoldS' σ σ' (var x)) = {!!} -}
programs/oeis/334/A334706.asm
neoneye/loda
22
164331
<reponame>neoneye/loda ; A334706: Number of collinear triples in a 4 X n rectangular grid. ; 4,8,20,44,84,140,224,332,472,648,864,1120,1428,1784,2196,2668,3204,3804,4480,5228,6056,6968,7968,9056,10244,11528,12916,14412,16020,17740,19584,21548,23640,25864,28224,30720,33364,36152,39092,42188,45444,48860,52448,56204,60136,64248,68544,73024,77700,82568,87636,92908,98388,104076,109984,116108,122456,129032,135840,142880,150164,157688,165460,173484,181764,190300,199104,208172,217512,227128,237024,247200,257668,268424,279476,290828,302484,314444,326720,339308,352216,365448,379008,392896,407124,421688,436596,451852,467460,483420,499744,516428,533480,550904,568704,586880,605444,624392,643732,663468 mov $2,$0 add $2,1 mov $5,$0 lpb $2 mov $0,$5 sub $2,1 sub $0,$2 mov $6,0 mov $7,$0 add $7,1 mov $9,$0 mov $10,0 lpb $7 mov $0,$9 sub $7,1 sub $0,$7 mov $8,$0 gcd $0,3 mov $4,$0 add $0,1 mod $6,2 add $6,1 add $8,$0 sub $8,$6 mul $8,2 mov $3,$8 sub $3,$4 mov $4,$3 div $4,2 mul $4,4 add $10,$4 lpe add $1,$10 lpe mov $0,$1
init.asm
B10401023/xv6
0
9767
<reponame>B10401023/xv6<filename>init.asm _init: file format elf32-i386 Disassembly of section .text: 00000000 <main>: char *argv[] = { "sh", 0 }; int main(void) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 53 push %ebx e: 51 push %ecx int pid, wpid; chpr(getpid(), 1); f: e8 ae 03 00 00 call 3c2 <getpid> 14: 83 ec 08 sub $0x8,%esp 17: 6a 01 push $0x1 19: 50 push %eax 1a: e8 d3 03 00 00 call 3f2 <chpr> if(open("console", O_RDWR) < 0){ 1f: 58 pop %eax 20: 5a pop %edx 21: 6a 02 push $0x2 23: 68 e0 07 00 00 push $0x7e0 28: e8 55 03 00 00 call 382 <open> 2d: 83 c4 10 add $0x10,%esp 30: 85 c0 test %eax,%eax 32: 0f 88 a0 00 00 00 js d8 <main+0xd8> mknod("console", 1, 1); open("console", O_RDWR); } dup(0); // stdout 38: 83 ec 0c sub $0xc,%esp 3b: 6a 00 push $0x0 3d: e8 78 03 00 00 call 3ba <dup> dup(0); // stderr 42: c7 04 24 00 00 00 00 movl $0x0,(%esp) 49: e8 6c 03 00 00 call 3ba <dup> #ifdef DEFAULT printf(1, "Scheduler policy: DEFAULT\n"); 4e: 58 pop %eax 4f: 5a pop %edx 50: 68 e8 07 00 00 push $0x7e8 55: 6a 01 push $0x1 57: e8 64 04 00 00 call 4c0 <printf> 5c: 83 c4 10 add $0x10,%esp 5f: 90 nop #endif #endif #endif for(;;){ printf(1, "init: starting sh\n"); 60: 83 ec 08 sub $0x8,%esp 63: 68 03 08 00 00 push $0x803 68: 6a 01 push $0x1 6a: e8 51 04 00 00 call 4c0 <printf> pid = fork(); 6f: e8 c6 02 00 00 call 33a <fork> if(pid < 0){ 74: 83 c4 10 add $0x10,%esp 77: 85 c0 test %eax,%eax #endif #endif for(;;){ printf(1, "init: starting sh\n"); pid = fork(); 79: 89 c3 mov %eax,%ebx if(pid < 0){ 7b: 78 24 js a1 <main+0xa1> printf(1, "init: fork failed\n"); exit(); } if(pid == 0){ 7d: 74 35 je b4 <main+0xb4> 7f: 90 nop exec("sh", argv); printf(1, "init: exec sh failed\n"); exit(); } while((wpid=wait()) >= 0 && wpid != pid) 80: e8 c5 02 00 00 call 34a <wait> 85: 85 c0 test %eax,%eax 87: 78 d7 js 60 <main+0x60> 89: 39 c3 cmp %eax,%ebx 8b: 74 d3 je 60 <main+0x60> printf(1, "zombie!\n"); 8d: 83 ec 08 sub $0x8,%esp 90: 68 42 08 00 00 push $0x842 95: 6a 01 push $0x1 97: e8 24 04 00 00 call 4c0 <printf> 9c: 83 c4 10 add $0x10,%esp 9f: eb df jmp 80 <main+0x80> for(;;){ printf(1, "init: starting sh\n"); pid = fork(); if(pid < 0){ printf(1, "init: fork failed\n"); a1: 53 push %ebx a2: 53 push %ebx a3: 68 16 08 00 00 push $0x816 a8: 6a 01 push $0x1 aa: e8 11 04 00 00 call 4c0 <printf> exit(); af: e8 8e 02 00 00 call 342 <exit> } if(pid == 0){ exec("sh", argv); b4: 50 push %eax b5: 50 push %eax b6: 68 f0 0a 00 00 push $0xaf0 bb: 68 29 08 00 00 push $0x829 c0: e8 b5 02 00 00 call 37a <exec> printf(1, "init: exec sh failed\n"); c5: 5a pop %edx c6: 59 pop %ecx c7: 68 2c 08 00 00 push $0x82c cc: 6a 01 push $0x1 ce: e8 ed 03 00 00 call 4c0 <printf> exit(); d3: e8 6a 02 00 00 call 342 <exit> int pid, wpid; chpr(getpid(), 1); if(open("console", O_RDWR) < 0){ mknod("console", 1, 1); d8: 51 push %ecx d9: 6a 01 push $0x1 db: 6a 01 push $0x1 dd: 68 e0 07 00 00 push $0x7e0 e2: e8 a3 02 00 00 call 38a <mknod> open("console", O_RDWR); e7: 5b pop %ebx e8: 58 pop %eax e9: 6a 02 push $0x2 eb: 68 e0 07 00 00 push $0x7e0 f0: e8 8d 02 00 00 call 382 <open> f5: 83 c4 10 add $0x10,%esp f8: e9 3b ff ff ff jmp 38 <main+0x38> fd: 66 90 xchg %ax,%ax ff: 90 nop 00000100 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 53 push %ebx 104: 8b 45 08 mov 0x8(%ebp),%eax 107: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 10a: 89 c2 mov %eax,%edx 10c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 110: 83 c1 01 add $0x1,%ecx 113: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 117: 83 c2 01 add $0x1,%edx 11a: 84 db test %bl,%bl 11c: 88 5a ff mov %bl,-0x1(%edx) 11f: 75 ef jne 110 <strcpy+0x10> ; return os; } 121: 5b pop %ebx 122: 5d pop %ebp 123: c3 ret 124: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 12a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000130 <strcmp>: int strcmp(const char *p, const char *q) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 56 push %esi 134: 53 push %ebx 135: 8b 55 08 mov 0x8(%ebp),%edx 138: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 13b: 0f b6 02 movzbl (%edx),%eax 13e: 0f b6 19 movzbl (%ecx),%ebx 141: 84 c0 test %al,%al 143: 75 1e jne 163 <strcmp+0x33> 145: eb 29 jmp 170 <strcmp+0x40> 147: 89 f6 mov %esi,%esi 149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 150: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 153: 0f b6 02 movzbl (%edx),%eax p++, q++; 156: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 159: 0f b6 59 01 movzbl 0x1(%ecx),%ebx 15d: 84 c0 test %al,%al 15f: 74 0f je 170 <strcmp+0x40> 161: 89 f1 mov %esi,%ecx 163: 38 d8 cmp %bl,%al 165: 74 e9 je 150 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; 167: 29 d8 sub %ebx,%eax } 169: 5b pop %ebx 16a: 5e pop %esi 16b: 5d pop %ebp 16c: c3 ret 16d: 8d 76 00 lea 0x0(%esi),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 170: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 172: 29 d8 sub %ebx,%eax } 174: 5b pop %ebx 175: 5e pop %esi 176: 5d pop %ebp 177: c3 ret 178: 90 nop 179: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000180 <strlen>: uint strlen(char *s) { 180: 55 push %ebp 181: 89 e5 mov %esp,%ebp 183: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 186: 80 39 00 cmpb $0x0,(%ecx) 189: 74 12 je 19d <strlen+0x1d> 18b: 31 d2 xor %edx,%edx 18d: 8d 76 00 lea 0x0(%esi),%esi 190: 83 c2 01 add $0x1,%edx 193: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 197: 89 d0 mov %edx,%eax 199: 75 f5 jne 190 <strlen+0x10> ; return n; } 19b: 5d pop %ebp 19c: c3 ret uint strlen(char *s) { int n; for(n = 0; s[n]; n++) 19d: 31 c0 xor %eax,%eax ; return n; } 19f: 5d pop %ebp 1a0: c3 ret 1a1: eb 0d jmp 1b0 <memset> 1a3: 90 nop 1a4: 90 nop 1a5: 90 nop 1a6: 90 nop 1a7: 90 nop 1a8: 90 nop 1a9: 90 nop 1aa: 90 nop 1ab: 90 nop 1ac: 90 nop 1ad: 90 nop 1ae: 90 nop 1af: 90 nop 000001b0 <memset>: void* memset(void *dst, int c, uint n) { 1b0: 55 push %ebp 1b1: 89 e5 mov %esp,%ebp 1b3: 57 push %edi 1b4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1b7: 8b 4d 10 mov 0x10(%ebp),%ecx 1ba: 8b 45 0c mov 0xc(%ebp),%eax 1bd: 89 d7 mov %edx,%edi 1bf: fc cld 1c0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 1c2: 89 d0 mov %edx,%eax 1c4: 5f pop %edi 1c5: 5d pop %ebp 1c6: c3 ret 1c7: 89 f6 mov %esi,%esi 1c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001d0 <strchr>: char* strchr(const char *s, char c) { 1d0: 55 push %ebp 1d1: 89 e5 mov %esp,%ebp 1d3: 53 push %ebx 1d4: 8b 45 08 mov 0x8(%ebp),%eax 1d7: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 1da: 0f b6 10 movzbl (%eax),%edx 1dd: 84 d2 test %dl,%dl 1df: 74 1d je 1fe <strchr+0x2e> if(*s == c) 1e1: 38 d3 cmp %dl,%bl 1e3: 89 d9 mov %ebx,%ecx 1e5: 75 0d jne 1f4 <strchr+0x24> 1e7: eb 17 jmp 200 <strchr+0x30> 1e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1f0: 38 ca cmp %cl,%dl 1f2: 74 0c je 200 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 1f4: 83 c0 01 add $0x1,%eax 1f7: 0f b6 10 movzbl (%eax),%edx 1fa: 84 d2 test %dl,%dl 1fc: 75 f2 jne 1f0 <strchr+0x20> if(*s == c) return (char*)s; return 0; 1fe: 31 c0 xor %eax,%eax } 200: 5b pop %ebx 201: 5d pop %ebp 202: c3 ret 203: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <gets>: char* gets(char *buf, int max) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 57 push %edi 214: 56 push %esi 215: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 216: 31 f6 xor %esi,%esi cc = read(0, &c, 1); 218: 8d 7d e7 lea -0x19(%ebp),%edi return 0; } char* gets(char *buf, int max) { 21b: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 21e: eb 29 jmp 249 <gets+0x39> cc = read(0, &c, 1); 220: 83 ec 04 sub $0x4,%esp 223: 6a 01 push $0x1 225: 57 push %edi 226: 6a 00 push $0x0 228: e8 2d 01 00 00 call 35a <read> if(cc < 1) 22d: 83 c4 10 add $0x10,%esp 230: 85 c0 test %eax,%eax 232: 7e 1d jle 251 <gets+0x41> break; buf[i++] = c; 234: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 238: 8b 55 08 mov 0x8(%ebp),%edx 23b: 89 de mov %ebx,%esi if(c == '\n' || c == '\r') 23d: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 23f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 243: 74 1b je 260 <gets+0x50> 245: 3c 0d cmp $0xd,%al 247: 74 17 je 260 <gets+0x50> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 249: 8d 5e 01 lea 0x1(%esi),%ebx 24c: 3b 5d 0c cmp 0xc(%ebp),%ebx 24f: 7c cf jl 220 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 251: 8b 45 08 mov 0x8(%ebp),%eax 254: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 258: 8d 65 f4 lea -0xc(%ebp),%esp 25b: 5b pop %ebx 25c: 5e pop %esi 25d: 5f pop %edi 25e: 5d pop %ebp 25f: c3 ret break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 260: 8b 45 08 mov 0x8(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 263: 89 de mov %ebx,%esi break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 265: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 269: 8d 65 f4 lea -0xc(%ebp),%esp 26c: 5b pop %ebx 26d: 5e pop %esi 26e: 5f pop %edi 26f: 5d pop %ebp 270: c3 ret 271: eb 0d jmp 280 <stat> 273: 90 nop 274: 90 nop 275: 90 nop 276: 90 nop 277: 90 nop 278: 90 nop 279: 90 nop 27a: 90 nop 27b: 90 nop 27c: 90 nop 27d: 90 nop 27e: 90 nop 27f: 90 nop 00000280 <stat>: int stat(char *n, struct stat *st) { 280: 55 push %ebp 281: 89 e5 mov %esp,%ebp 283: 56 push %esi 284: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 285: 83 ec 08 sub $0x8,%esp 288: 6a 00 push $0x0 28a: ff 75 08 pushl 0x8(%ebp) 28d: e8 f0 00 00 00 call 382 <open> if(fd < 0) 292: 83 c4 10 add $0x10,%esp 295: 85 c0 test %eax,%eax 297: 78 27 js 2c0 <stat+0x40> return -1; r = fstat(fd, st); 299: 83 ec 08 sub $0x8,%esp 29c: ff 75 0c pushl 0xc(%ebp) 29f: 89 c3 mov %eax,%ebx 2a1: 50 push %eax 2a2: e8 f3 00 00 00 call 39a <fstat> 2a7: 89 c6 mov %eax,%esi close(fd); 2a9: 89 1c 24 mov %ebx,(%esp) 2ac: e8 b9 00 00 00 call 36a <close> return r; 2b1: 83 c4 10 add $0x10,%esp 2b4: 89 f0 mov %esi,%eax } 2b6: 8d 65 f8 lea -0x8(%ebp),%esp 2b9: 5b pop %ebx 2ba: 5e pop %esi 2bb: 5d pop %ebp 2bc: c3 ret 2bd: 8d 76 00 lea 0x0(%esi),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 2c0: b8 ff ff ff ff mov $0xffffffff,%eax 2c5: eb ef jmp 2b6 <stat+0x36> 2c7: 89 f6 mov %esi,%esi 2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002d0 <atoi>: return r; } int atoi(const char *s) { 2d0: 55 push %ebp 2d1: 89 e5 mov %esp,%ebp 2d3: 53 push %ebx 2d4: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 2d7: 0f be 11 movsbl (%ecx),%edx 2da: 8d 42 d0 lea -0x30(%edx),%eax 2dd: 3c 09 cmp $0x9,%al 2df: b8 00 00 00 00 mov $0x0,%eax 2e4: 77 1f ja 305 <atoi+0x35> 2e6: 8d 76 00 lea 0x0(%esi),%esi 2e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 2f0: 8d 04 80 lea (%eax,%eax,4),%eax 2f3: 83 c1 01 add $0x1,%ecx 2f6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 2fa: 0f be 11 movsbl (%ecx),%edx 2fd: 8d 5a d0 lea -0x30(%edx),%ebx 300: 80 fb 09 cmp $0x9,%bl 303: 76 eb jbe 2f0 <atoi+0x20> n = n*10 + *s++ - '0'; return n; } 305: 5b pop %ebx 306: 5d pop %ebp 307: c3 ret 308: 90 nop 309: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000310 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 310: 55 push %ebp 311: 89 e5 mov %esp,%ebp 313: 56 push %esi 314: 53 push %ebx 315: 8b 5d 10 mov 0x10(%ebp),%ebx 318: 8b 45 08 mov 0x8(%ebp),%eax 31b: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 31e: 85 db test %ebx,%ebx 320: 7e 14 jle 336 <memmove+0x26> 322: 31 d2 xor %edx,%edx 324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 328: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 32c: 88 0c 10 mov %cl,(%eax,%edx,1) 32f: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 332: 39 da cmp %ebx,%edx 334: 75 f2 jne 328 <memmove+0x18> *dst++ = *src++; return vdst; } 336: 5b pop %ebx 337: 5e pop %esi 338: 5d pop %ebp 339: c3 ret 0000033a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 33a: b8 01 00 00 00 mov $0x1,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <exit>: SYSCALL(exit) 342: b8 02 00 00 00 mov $0x2,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <wait>: SYSCALL(wait) 34a: b8 03 00 00 00 mov $0x3,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <pipe>: SYSCALL(pipe) 352: b8 04 00 00 00 mov $0x4,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <read>: SYSCALL(read) 35a: b8 05 00 00 00 mov $0x5,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <write>: SYSCALL(write) 362: b8 10 00 00 00 mov $0x10,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <close>: SYSCALL(close) 36a: b8 15 00 00 00 mov $0x15,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <kill>: SYSCALL(kill) 372: b8 06 00 00 00 mov $0x6,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <exec>: SYSCALL(exec) 37a: b8 07 00 00 00 mov $0x7,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <open>: SYSCALL(open) 382: b8 0f 00 00 00 mov $0xf,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <mknod>: SYSCALL(mknod) 38a: b8 11 00 00 00 mov $0x11,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <unlink>: SYSCALL(unlink) 392: b8 12 00 00 00 mov $0x12,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <fstat>: SYSCALL(fstat) 39a: b8 08 00 00 00 mov $0x8,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <link>: SYSCALL(link) 3a2: b8 13 00 00 00 mov $0x13,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <mkdir>: SYSCALL(mkdir) 3aa: b8 14 00 00 00 mov $0x14,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <chdir>: SYSCALL(chdir) 3b2: b8 09 00 00 00 mov $0x9,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <dup>: SYSCALL(dup) 3ba: b8 0a 00 00 00 mov $0xa,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <getpid>: SYSCALL(getpid) 3c2: b8 0b 00 00 00 mov $0xb,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <sbrk>: SYSCALL(sbrk) 3ca: b8 0c 00 00 00 mov $0xc,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <sleep>: SYSCALL(sleep) 3d2: b8 0d 00 00 00 mov $0xd,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <uptime>: SYSCALL(uptime) 3da: b8 0e 00 00 00 mov $0xe,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <getptable>: SYSCALL(getptable) 3e2: b8 16 00 00 00 mov $0x16,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <getppid>: SYSCALL(getppid) 3ea: b8 17 00 00 00 mov $0x17,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <chpr>: SYSCALL(chpr) 3f2: b8 18 00 00 00 mov $0x18,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 000003fa <wait2>: SYSCALL(wait2) 3fa: b8 19 00 00 00 mov $0x19,%eax 3ff: cd 40 int $0x40 401: c3 ret 00000402 <yield>: SYSCALL(yield) 402: b8 1a 00 00 00 mov $0x1a,%eax 407: cd 40 int $0x40 409: c3 ret 0000040a <chtickets>: SYSCALL(chtickets) 40a: b8 1b 00 00 00 mov $0x1b,%eax 40f: cd 40 int $0x40 411: c3 ret 412: 66 90 xchg %ax,%ax 414: 66 90 xchg %ax,%ax 416: 66 90 xchg %ax,%ax 418: 66 90 xchg %ax,%ax 41a: 66 90 xchg %ax,%ax 41c: 66 90 xchg %ax,%ax 41e: 66 90 xchg %ax,%ax 00000420 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 420: 55 push %ebp 421: 89 e5 mov %esp,%ebp 423: 57 push %edi 424: 56 push %esi 425: 53 push %ebx 426: 89 c6 mov %eax,%esi 428: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 42b: 8b 5d 08 mov 0x8(%ebp),%ebx 42e: 85 db test %ebx,%ebx 430: 74 7e je 4b0 <printint+0x90> 432: 89 d0 mov %edx,%eax 434: c1 e8 1f shr $0x1f,%eax 437: 84 c0 test %al,%al 439: 74 75 je 4b0 <printint+0x90> neg = 1; x = -xx; 43b: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 43d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) x = -xx; 444: f7 d8 neg %eax 446: 89 75 c0 mov %esi,-0x40(%ebp) } else { x = xx; } i = 0; 449: 31 ff xor %edi,%edi 44b: 8d 5d d7 lea -0x29(%ebp),%ebx 44e: 89 ce mov %ecx,%esi 450: eb 08 jmp 45a <printint+0x3a> 452: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 458: 89 cf mov %ecx,%edi 45a: 31 d2 xor %edx,%edx 45c: 8d 4f 01 lea 0x1(%edi),%ecx 45f: f7 f6 div %esi 461: 0f b6 92 54 08 00 00 movzbl 0x854(%edx),%edx }while((x /= base) != 0); 468: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 46a: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 46d: 75 e9 jne 458 <printint+0x38> if(neg) 46f: 8b 45 c4 mov -0x3c(%ebp),%eax 472: 8b 75 c0 mov -0x40(%ebp),%esi 475: 85 c0 test %eax,%eax 477: 74 08 je 481 <printint+0x61> buf[i++] = '-'; 479: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 47e: 8d 4f 02 lea 0x2(%edi),%ecx 481: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi 485: 8d 76 00 lea 0x0(%esi),%esi 488: 0f b6 07 movzbl (%edi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 48b: 83 ec 04 sub $0x4,%esp 48e: 83 ef 01 sub $0x1,%edi 491: 6a 01 push $0x1 493: 53 push %ebx 494: 56 push %esi 495: 88 45 d7 mov %al,-0x29(%ebp) 498: e8 c5 fe ff ff call 362 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 49d: 83 c4 10 add $0x10,%esp 4a0: 39 df cmp %ebx,%edi 4a2: 75 e4 jne 488 <printint+0x68> putc(fd, buf[i]); } 4a4: 8d 65 f4 lea -0xc(%ebp),%esp 4a7: 5b pop %ebx 4a8: 5e pop %esi 4a9: 5f pop %edi 4aa: 5d pop %ebp 4ab: c3 ret 4ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 4b0: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 4b2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 4b9: eb 8b jmp 446 <printint+0x26> 4bb: 90 nop 4bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000004c0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4c0: 55 push %ebp 4c1: 89 e5 mov %esp,%ebp 4c3: 57 push %edi 4c4: 56 push %esi 4c5: 53 push %ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4c6: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4c9: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4cc: 8b 75 0c mov 0xc(%ebp),%esi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4cf: 8b 7d 08 mov 0x8(%ebp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4d2: 89 45 d0 mov %eax,-0x30(%ebp) 4d5: 0f b6 1e movzbl (%esi),%ebx 4d8: 83 c6 01 add $0x1,%esi 4db: 84 db test %bl,%bl 4dd: 0f 84 b0 00 00 00 je 593 <printf+0xd3> 4e3: 31 d2 xor %edx,%edx 4e5: eb 39 jmp 520 <printf+0x60> 4e7: 89 f6 mov %esi,%esi 4e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4f0: 83 f8 25 cmp $0x25,%eax 4f3: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 4f6: ba 25 00 00 00 mov $0x25,%edx state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4fb: 74 18 je 515 <printf+0x55> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4fd: 8d 45 e2 lea -0x1e(%ebp),%eax 500: 83 ec 04 sub $0x4,%esp 503: 88 5d e2 mov %bl,-0x1e(%ebp) 506: 6a 01 push $0x1 508: 50 push %eax 509: 57 push %edi 50a: e8 53 fe ff ff call 362 <write> 50f: 8b 55 d4 mov -0x2c(%ebp),%edx 512: 83 c4 10 add $0x10,%esp 515: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 518: 0f b6 5e ff movzbl -0x1(%esi),%ebx 51c: 84 db test %bl,%bl 51e: 74 73 je 593 <printf+0xd3> c = fmt[i] & 0xff; if(state == 0){ 520: 85 d2 test %edx,%edx uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 522: 0f be cb movsbl %bl,%ecx 525: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 528: 74 c6 je 4f0 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 52a: 83 fa 25 cmp $0x25,%edx 52d: 75 e6 jne 515 <printf+0x55> if(c == 'd'){ 52f: 83 f8 64 cmp $0x64,%eax 532: 0f 84 f8 00 00 00 je 630 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 538: 81 e1 f7 00 00 00 and $0xf7,%ecx 53e: 83 f9 70 cmp $0x70,%ecx 541: 74 5d je 5a0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 543: 83 f8 73 cmp $0x73,%eax 546: 0f 84 84 00 00 00 je 5d0 <printf+0x110> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 54c: 83 f8 63 cmp $0x63,%eax 54f: 0f 84 ea 00 00 00 je 63f <printf+0x17f> putc(fd, *ap); ap++; } else if(c == '%'){ 555: 83 f8 25 cmp $0x25,%eax 558: 0f 84 c2 00 00 00 je 620 <printf+0x160> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 55e: 8d 45 e7 lea -0x19(%ebp),%eax 561: 83 ec 04 sub $0x4,%esp 564: c6 45 e7 25 movb $0x25,-0x19(%ebp) 568: 6a 01 push $0x1 56a: 50 push %eax 56b: 57 push %edi 56c: e8 f1 fd ff ff call 362 <write> 571: 83 c4 0c add $0xc,%esp 574: 8d 45 e6 lea -0x1a(%ebp),%eax 577: 88 5d e6 mov %bl,-0x1a(%ebp) 57a: 6a 01 push $0x1 57c: 50 push %eax 57d: 57 push %edi 57e: 83 c6 01 add $0x1,%esi 581: e8 dc fd ff ff call 362 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 586: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 58a: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 58d: 31 d2 xor %edx,%edx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 58f: 84 db test %bl,%bl 591: 75 8d jne 520 <printf+0x60> putc(fd, c); } state = 0; } } } 593: 8d 65 f4 lea -0xc(%ebp),%esp 596: 5b pop %ebx 597: 5e pop %esi 598: 5f pop %edi 599: 5d pop %ebp 59a: c3 ret 59b: 90 nop 59c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 5a0: 83 ec 0c sub $0xc,%esp 5a3: b9 10 00 00 00 mov $0x10,%ecx 5a8: 6a 00 push $0x0 5aa: 8b 5d d0 mov -0x30(%ebp),%ebx 5ad: 89 f8 mov %edi,%eax 5af: 8b 13 mov (%ebx),%edx 5b1: e8 6a fe ff ff call 420 <printint> ap++; 5b6: 89 d8 mov %ebx,%eax 5b8: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 5bb: 31 d2 xor %edx,%edx if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 5bd: 83 c0 04 add $0x4,%eax 5c0: 89 45 d0 mov %eax,-0x30(%ebp) 5c3: e9 4d ff ff ff jmp 515 <printf+0x55> 5c8: 90 nop 5c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 5d0: 8b 45 d0 mov -0x30(%ebp),%eax 5d3: 8b 18 mov (%eax),%ebx ap++; 5d5: 83 c0 04 add $0x4,%eax 5d8: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) s = "(null)"; 5db: b8 4b 08 00 00 mov $0x84b,%eax 5e0: 85 db test %ebx,%ebx 5e2: 0f 44 d8 cmove %eax,%ebx while(*s != 0){ 5e5: 0f b6 03 movzbl (%ebx),%eax 5e8: 84 c0 test %al,%al 5ea: 74 23 je 60f <printf+0x14f> 5ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 5f0: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5f3: 8d 45 e3 lea -0x1d(%ebp),%eax 5f6: 83 ec 04 sub $0x4,%esp 5f9: 6a 01 push $0x1 ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 5fb: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5fe: 50 push %eax 5ff: 57 push %edi 600: e8 5d fd ff ff call 362 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 605: 0f b6 03 movzbl (%ebx),%eax 608: 83 c4 10 add $0x10,%esp 60b: 84 c0 test %al,%al 60d: 75 e1 jne 5f0 <printf+0x130> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 60f: 31 d2 xor %edx,%edx 611: e9 ff fe ff ff jmp 515 <printf+0x55> 616: 8d 76 00 lea 0x0(%esi),%esi 619: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 620: 83 ec 04 sub $0x4,%esp 623: 88 5d e5 mov %bl,-0x1b(%ebp) 626: 8d 45 e5 lea -0x1b(%ebp),%eax 629: 6a 01 push $0x1 62b: e9 4c ff ff ff jmp 57c <printf+0xbc> } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 630: 83 ec 0c sub $0xc,%esp 633: b9 0a 00 00 00 mov $0xa,%ecx 638: 6a 01 push $0x1 63a: e9 6b ff ff ff jmp 5aa <printf+0xea> 63f: 8b 5d d0 mov -0x30(%ebp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 642: 83 ec 04 sub $0x4,%esp 645: 8b 03 mov (%ebx),%eax 647: 6a 01 push $0x1 649: 88 45 e4 mov %al,-0x1c(%ebp) 64c: 8d 45 e4 lea -0x1c(%ebp),%eax 64f: 50 push %eax 650: 57 push %edi 651: e8 0c fd ff ff call 362 <write> 656: e9 5b ff ff ff jmp 5b6 <printf+0xf6> 65b: 66 90 xchg %ax,%ax 65d: 66 90 xchg %ax,%ax 65f: 90 nop 00000660 <free>: static Header base; static Header *freep; void free(void *ap) { 660: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 661: a1 f8 0a 00 00 mov 0xaf8,%eax static Header base; static Header *freep; void free(void *ap) { 666: 89 e5 mov %esp,%ebp 668: 57 push %edi 669: 56 push %esi 66a: 53 push %ebx 66b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 66e: 8b 10 mov (%eax),%edx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 670: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 673: 39 c8 cmp %ecx,%eax 675: 73 19 jae 690 <free+0x30> 677: 89 f6 mov %esi,%esi 679: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 680: 39 d1 cmp %edx,%ecx 682: 72 1c jb 6a0 <free+0x40> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 684: 39 d0 cmp %edx,%eax 686: 73 18 jae 6a0 <free+0x40> static Header base; static Header *freep; void free(void *ap) { 688: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 68a: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 68c: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 68e: 72 f0 jb 680 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 690: 39 d0 cmp %edx,%eax 692: 72 f4 jb 688 <free+0x28> 694: 39 d1 cmp %edx,%ecx 696: 73 f0 jae 688 <free+0x28> 698: 90 nop 699: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(bp + bp->s.size == p->s.ptr){ 6a0: 8b 73 fc mov -0x4(%ebx),%esi 6a3: 8d 3c f1 lea (%ecx,%esi,8),%edi 6a6: 39 d7 cmp %edx,%edi 6a8: 74 19 je 6c3 <free+0x63> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 6aa: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6ad: 8b 50 04 mov 0x4(%eax),%edx 6b0: 8d 34 d0 lea (%eax,%edx,8),%esi 6b3: 39 f1 cmp %esi,%ecx 6b5: 74 23 je 6da <free+0x7a> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6b7: 89 08 mov %ecx,(%eax) freep = p; 6b9: a3 f8 0a 00 00 mov %eax,0xaf8 } 6be: 5b pop %ebx 6bf: 5e pop %esi 6c0: 5f pop %edi 6c1: 5d pop %ebp 6c2: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 6c3: 03 72 04 add 0x4(%edx),%esi 6c6: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6c9: 8b 10 mov (%eax),%edx 6cb: 8b 12 mov (%edx),%edx 6cd: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 6d0: 8b 50 04 mov 0x4(%eax),%edx 6d3: 8d 34 d0 lea (%eax,%edx,8),%esi 6d6: 39 f1 cmp %esi,%ecx 6d8: 75 dd jne 6b7 <free+0x57> p->s.size += bp->s.size; 6da: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 6dd: a3 f8 0a 00 00 mov %eax,0xaf8 bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 6e2: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6e5: 8b 53 f8 mov -0x8(%ebx),%edx 6e8: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 6ea: 5b pop %ebx 6eb: 5e pop %esi 6ec: 5f pop %edi 6ed: 5d pop %ebp 6ee: c3 ret 6ef: 90 nop 000006f0 <malloc>: return freep; } void* malloc(uint nbytes) { 6f0: 55 push %ebp 6f1: 89 e5 mov %esp,%ebp 6f3: 57 push %edi 6f4: 56 push %esi 6f5: 53 push %ebx 6f6: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6f9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 6fc: 8b 15 f8 0a 00 00 mov 0xaf8,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 702: 8d 78 07 lea 0x7(%eax),%edi 705: c1 ef 03 shr $0x3,%edi 708: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 70b: 85 d2 test %edx,%edx 70d: 0f 84 a3 00 00 00 je 7b6 <malloc+0xc6> 713: 8b 02 mov (%edx),%eax 715: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 718: 39 cf cmp %ecx,%edi 71a: 76 74 jbe 790 <malloc+0xa0> 71c: 81 ff 00 10 00 00 cmp $0x1000,%edi 722: be 00 10 00 00 mov $0x1000,%esi 727: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 72e: 0f 43 f7 cmovae %edi,%esi 731: ba 00 80 00 00 mov $0x8000,%edx 736: 81 ff ff 0f 00 00 cmp $0xfff,%edi 73c: 0f 46 da cmovbe %edx,%ebx 73f: eb 10 jmp 751 <malloc+0x61> 741: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 748: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 74a: 8b 48 04 mov 0x4(%eax),%ecx 74d: 39 cf cmp %ecx,%edi 74f: 76 3f jbe 790 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 751: 39 05 f8 0a 00 00 cmp %eax,0xaf8 757: 89 c2 mov %eax,%edx 759: 75 ed jne 748 <malloc+0x58> char *p; Header *hp; if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); 75b: 83 ec 0c sub $0xc,%esp 75e: 53 push %ebx 75f: e8 66 fc ff ff call 3ca <sbrk> if(p == (char*)-1) 764: 83 c4 10 add $0x10,%esp 767: 83 f8 ff cmp $0xffffffff,%eax 76a: 74 1c je 788 <malloc+0x98> return 0; hp = (Header*)p; hp->s.size = nu; 76c: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 76f: 83 ec 0c sub $0xc,%esp 772: 83 c0 08 add $0x8,%eax 775: 50 push %eax 776: e8 e5 fe ff ff call 660 <free> return freep; 77b: 8b 15 f8 0a 00 00 mov 0xaf8,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 781: 83 c4 10 add $0x10,%esp 784: 85 d2 test %edx,%edx 786: 75 c0 jne 748 <malloc+0x58> return 0; 788: 31 c0 xor %eax,%eax 78a: eb 1c jmp 7a8 <malloc+0xb8> 78c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) 790: 39 cf cmp %ecx,%edi 792: 74 1c je 7b0 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 794: 29 f9 sub %edi,%ecx 796: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 799: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 79c: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 79f: 89 15 f8 0a 00 00 mov %edx,0xaf8 return (void*)(p + 1); 7a5: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 7a8: 8d 65 f4 lea -0xc(%ebp),%esp 7ab: 5b pop %ebx 7ac: 5e pop %esi 7ad: 5f pop %edi 7ae: 5d pop %ebp 7af: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 7b0: 8b 08 mov (%eax),%ecx 7b2: 89 0a mov %ecx,(%edx) 7b4: eb e9 jmp 79f <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 7b6: c7 05 f8 0a 00 00 fc movl $0xafc,0xaf8 7bd: 0a 00 00 7c0: c7 05 fc 0a 00 00 fc movl $0xafc,0xafc 7c7: 0a 00 00 base.s.size = 0; 7ca: b8 fc 0a 00 00 mov $0xafc,%eax 7cf: c7 05 00 0b 00 00 00 movl $0x0,0xb00 7d6: 00 00 00 7d9: e9 3e ff ff ff jmp 71c <malloc+0x2c>
Cubical/Codata/M/AsLimit/M/Properties.agda
dan-iel-lee/cubical
0
9093
{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-} module Cubical.Codata.M.AsLimit.M.Properties where open import Cubical.Data.Unit open import Cubical.Data.Prod open import Cubical.Data.Nat as ℕ using (ℕ ; suc ; _+_ ) open import Cubical.Data.Sum open import Cubical.Data.Sigma open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv using (_≃_) open import Cubical.Foundations.Function using (_∘_) open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Functions.Embedding open import Cubical.Codata.M.AsLimit.helper open import Cubical.Codata.M.AsLimit.M.Base open import Cubical.Codata.M.AsLimit.Container -- in-fun and out-fun are inverse open Iso in-inverse-out : ∀ {ℓ} {S : Container ℓ} → (in-fun {S = S} ∘ out-fun {S = S}) ≡ idfun (M S) in-inverse-out {S = S} = subst (λ inv → in-fun {S = S} ∘ inv ≡ idfun (M S)) idpath def where -- substituting refl makes type-checking work a lot faster, but introduces a transport -- TODO (2020-05-23): revisit this at some point to see if it's still needed in future versions of agda def : (in-fun {S = S} ∘ inv (shift-iso S)) ≡ idfun (M S) def = funExt (rightInv (shift-iso S)) idpath : inv (shift-iso S) ≡ out-fun {S = S} idpath = refl out-inverse-in : ∀ {ℓ} {S : Container ℓ} → (out-fun {S = S} ∘ in-fun {S = S}) ≡ idfun (P₀ S (M S)) out-inverse-in {S = S} = subst (λ fun → out-fun {S = S} ∘ fun ≡ idfun (P₀ S (M S))) idpath def where def : (out-fun {S = S} ∘ fun (shift-iso S)) ≡ idfun (P₀ S (M S)) def = funExt (leftInv (shift-iso S)) idpath : fun (shift-iso S) ≡ in-fun {S = S} idpath = refl in-out-id : ∀ {ℓ} {S : Container ℓ} -> ∀ {x y : M S} → (in-fun (out-fun x) ≡ in-fun (out-fun y)) ≡ (x ≡ y) in-out-id {x = x} {y} i = (in-inverse-out i x) ≡ (in-inverse-out i y) -- constructor properties in-inj : ∀ {ℓ} {S : Container ℓ} {Z : Type ℓ} → ∀ {f g : Z → P₀ S (M S)} → (in-fun ∘ f ≡ in-fun ∘ g) ≡ (f ≡ g) in-inj {ℓ} {S = S} {Z = Z} {f = f} {g = g} = iso→fun-Injection-Path {ℓ = ℓ} {A = P₀ S (M S)} {B = M S} {C = Z} (shift-iso S) {f = f} {g = g} out-inj : ∀ {ℓ} {S : Container ℓ} {Z : Type ℓ} → ∀ {f g : Z → M S} → (out-fun ∘ f ≡ out-fun ∘ g) ≡ (f ≡ g) out-inj {ℓ} {S = S} {Z = Z} {f = f} {g = g} = iso→inv-Injection-Path {ℓ = ℓ} {A = P₀ S (M S)} {B = M S} {C = Z} (shift-iso S) {f = f} {g = g} in-inj-x : ∀ {ℓ} {S : Container ℓ} → ∀ {x y : P₀ S (M S)} → (in-fun x ≡ in-fun y) ≡ (x ≡ y) in-inj-x {ℓ} {S = S} {x = x} {y} = iso→fun-Injection-Path-x (shift-iso S) {x} {y} out-inj-x : ∀ {ℓ} {S : Container ℓ} → ∀ {x y : M S} → (out-fun x ≡ out-fun y) ≡ (x ≡ y) out-inj-x {ℓ} {S = S} {x = x} {y} = iso→inv-Injection-Path-x (shift-iso S) {x} {y}
runtime/sourdebug.asm
paulscottrobson/xcpl
1
88071
; ***************************************************************************** ; ***************************************************************************** ; ; Name: sourdebug.asm ; Purpose: Support routines (debugging) ; Date: 11th June 2020 ; Author: <NAME> (<EMAIL>) ; ; ***************************************************************************** ; ***************************************************************************** ; ***************************************************************************** ; ; Debugging console I/O routines ; ; ***************************************************************************** DebugPrintChar: ;; [PRINT.CHAR1] .byte CodeOpcode lda Vars+2 ; get R1 OSPrintChar: jmp $FFD2 ; call output routine DebugPrintString: ;; [PRINT.STRING1] .byte CodeOpcode ldy #0 _DPSLoop: lda (Vars+2),y beq _DPSExit jsr OSPrintChar iny bra _DPSLoop _DPSExit: rts DebugPrintHex: ;; [PRINT.HEX1] .byte CodeOpcode lda #' ' jsr OSPrintChar lda Vars+3 jsr _DPH1 lda Vars+2 _DPH1: pha lsr a lsr a lsr a lsr a jsr _DPH2 pla _DPH2: and #$0F cmp #$0A bcc _DPH3 adc #6 _DPH3: adc #48 jmp OSPrintChar